void
RockPhysicsInversion4D::makeNewPredictionTable(std::vector<std::vector<double> >  mSamp,std::vector<double>   rSamp)
{
  ClearContentInPredictionTable( );
  fillInTable( mSamp,rSamp,1);
  smoothAllDirectionsAndNormalize();
}
Esempio n. 2
0
void ResultWidget::edit()
{
  RatioChoiceDialog rChoiceDiag(this);
  rChoiceDiag.exec();
  const int& chosenRow = rChoiceDiag.chosenActualDataVisRow;
  const int idxToAdd = chosenRow * 20;

  normValuesType curTableValues;
  curTableValues.rationMin = mResData[0 + idxToAdd].toInt();
  curTableValues.rationMax = mResData[1 + idxToAdd].toInt();
  curTableValues.rationValue1 = mResData[2 + idxToAdd];
  curTableValues.rationValue2 = mResData[4 + idxToAdd];
  curTableValues.rationValue3 = mResData[6 + idxToAdd];
  curTableValues.rationValue4 = mResData[8 + idxToAdd];
  curTableValues.overflowMin = mResData[10 + idxToAdd].toInt();
  curTableValues.overflowMax = mResData[11 + idxToAdd].toInt();
  curTableValues.overflowValue1 = mResData[12 + idxToAdd];
  curTableValues.overflowValue2 = mResData[14 + idxToAdd];
  curTableValues.overflowValue3 = mResData[16 + idxToAdd];
  curTableValues.overflowValue4 = mResData[18 + idxToAdd];

  NormDialog dialog(this, curTableValues);
  dialog.setNormsVisible(true);
  dialog.exec() ;

  mResData[0 + idxToAdd] = QString::number(dialog.mData.rationMin);
  mResData[1 + idxToAdd] = QString::number(dialog.mData.rationMax);
  mResData[2 + idxToAdd] = dialog.mData.rationValue1;
  mResData[4 + idxToAdd] = dialog.mData.rationValue2;
  mResData[6 + idxToAdd] = dialog.mData.rationValue3;
  mResData[8 + idxToAdd] = dialog.mData.rationValue4;
  mResData[10 + idxToAdd] = QString::number(dialog.mData.overflowMin);
  mResData[11 + idxToAdd] = QString::number(dialog.mData.overflowMax);
  mResData[12 + idxToAdd] = dialog.mData.overflowValue1;
  mResData[14 + idxToAdd] = dialog.mData.overflowValue2;
  mResData[16 + idxToAdd] = dialog.mData.overflowValue3;
  mResData[18 + idxToAdd] = dialog.mData.overflowValue4;

  //recalc if results(changed) are between norms
  auto recalcResult = [&](int minNormIdx, int maxNormIdx
          , int resultIdx, int testIdx)
  {
      if(mResData[resultIdx].toInt() >= mResData[minNormIdx].toInt()
              && mResData[resultIdx].toInt() <= mResData[maxNormIdx].toInt())
          mResData[testIdx] = "OK";
      else
          mResData[testIdx] = "NG";
  };
  recalcResult(0 + idxToAdd, 1 + idxToAdd, 2 + idxToAdd, 3 + idxToAdd);
  recalcResult(0 + idxToAdd, 1 + idxToAdd, 4 + idxToAdd, 5 + idxToAdd);
  recalcResult(0 + idxToAdd, 1 + idxToAdd, 6 + idxToAdd, 7 + idxToAdd);
  recalcResult(0 + idxToAdd, 1 + idxToAdd, 8 + idxToAdd, 9 + idxToAdd);
  recalcResult(10 + idxToAdd, 11 + idxToAdd, 12 + idxToAdd, 13 + idxToAdd);
  recalcResult(10 + idxToAdd, 11 + idxToAdd, 14 + idxToAdd, 15 + idxToAdd);
  recalcResult(10 + idxToAdd, 11 + idxToAdd, 16 + idxToAdd, 17 + idxToAdd);
  recalcResult(10 + idxToAdd, 11 + idxToAdd, 18 + idxToAdd, 19 + idxToAdd);

  fillInTable(0, mResData);//update table
}
Esempio n. 3
0
void MainWindow::onModelActualized()
{
    game.gameTime = game.gameTime.addMSecs(SERVER_SEND_INTERVAL);
    Player &player = game.model2.players[game.player.id];
    if (!updated)
    {
        QColor color = player.group == Player::RED_GROUP ? QColor(255, 0, 0) : QColor(0, 100, 255);
        ui->playerName->setText(QString("<font color='%1'>%2</font>").arg(color.name(), game.playerName));
        updated = true;
    }
    ui->healthBar->setValue(player.health);
    ui->powerBar->setValue(player.power);
    ui->pointsLabel->setText(QString("Punkty: %1").arg(player.points));
    ui->timeLabel->setText(QString("Czas: %1 / %2").arg(game.gameTime.toString("mm:ss"), game.maxTime.toString("mm:ss")));
    fillInTable(ui->top);
}
Esempio n. 4
0
ResultWidget::ResultWidget(QWidget *parent, QStringList data, QStringList resData, QString name, RESULT_DIALOG_TYPE type)
    : QWidget(parent, Qt::WindowTitleHint)
    , ui(new Ui::ResultWidget)
    , stackedWidget(qobject_cast<SlidingStackedWidget*>(parent))
    , hwName(name)
    , mData(data)
    , mResData(resData)
{
  ui -> setupUi(this) ;
  canceled = false ;
  ui->titleLabel->setText(hwName);

  if(type == SHOW_ONLY)
  {
      ui->resNormPart->setVisible(true);
      ui->resEditPart->setVisible(false);
  }
  else//EDIT
  {
      ui->resNormPart->setVisible(false);
      ui->resEditPart->setVisible(true);
  }

  //1st line
  //1st line
  ui->lowerTable->setSpan(0, 1, 1, 2);
  ui->lowerTable->setSpan(0, 3, 1, 8);
  ui->lowerTable->setSpan(0, 11, 1, 2);
  ui->lowerTable->setSpan(0, 13, 1, 8);
  //2nd line
  ui->lowerTable->setSpan(1, 1, 1, 2);
  ui->lowerTable->setSpan(1, 3, 1, 2);
  ui->lowerTable->setSpan(1, 5, 1, 2);
  ui->lowerTable->setSpan(1, 7, 1, 2);
  ui->lowerTable->setSpan(1, 9, 1, 2);
  ui->lowerTable->setSpan(1, 11, 1, 2);
  ui->lowerTable->setSpan(1, 13, 1, 2);
  ui->lowerTable->setSpan(1, 15, 1, 2);
  ui->lowerTable->setSpan(1, 17, 1, 2);
  ui->lowerTable->setSpan(1, 19, 1, 2);

  tableColumnBaseWidth.push_back(120);
  tableColumnBaseWidth.push_back(50);
  tableColumnBaseWidth.push_back(50);
  tableColumnBaseWidth.push_back(50);
  tableColumnBaseWidth.push_back(35);
  tableColumnBaseWidth.push_back(50);
  tableColumnBaseWidth.push_back(35);
  tableColumnBaseWidth.push_back(50);
  tableColumnBaseWidth.push_back(35);
  tableColumnBaseWidth.push_back(50);
  tableColumnBaseWidth.push_back(35);
  tableColumnBaseWidth.push_back(50);
  tableColumnBaseWidth.push_back(50);
  tableColumnBaseWidth.push_back(50);
  tableColumnBaseWidth.push_back(35);
  tableColumnBaseWidth.push_back(50);
  tableColumnBaseWidth.push_back(35);
  tableColumnBaseWidth.push_back(50);
  tableColumnBaseWidth.push_back(35);
  tableColumnBaseWidth.push_back(50);
  tableColumnBaseWidth.push_back(35);

  tableRowBaseHeight.push_back(25);
  tableRowBaseHeight.push_back(39);
  tableRowBaseHeight.push_back(39);
  tableRowBaseHeight.push_back(39);
  tableRowBaseHeight.push_back(39);
  tableRowBaseHeight.push_back(39);
  tableRowBaseHeight.push_back(39);

  for(size_t i = 0; i < tableColumnBaseWidth.size(); i++)
      ui->lowerTable->setColumnWidth(i, tableColumnBaseWidth[i]);
  for(size_t i = 0; i < tableRowBaseHeight.size(); i++)
      ui->lowerTable->setRowHeight(i, tableRowBaseHeight[i]);

  ui -> editl1u1 -> setText(data[0]) ;
  ui -> editl1u2 -> setText(data[1]) ;
  ui -> editl1u3 -> setText(data[2]) ;
  ui -> editl1u4 -> setText(data[3]) ;

  ui -> editl2u1 -> setText(data[8]) ;
  ui -> editl2u2 -> setText(data[9]) ;
  ui -> editl2u3 -> setText(data[10]) ;
  ui -> editl2u4 -> setText(data[11]) ;

  ui -> editl3u1 -> setText(data[16]) ;
  ui -> editl3u2 -> setText(data[17]) ;
  ui -> editl3u3 -> setText(data[18]) ;
  ui -> editl3u4 -> setText(data[19]) ;

  ui -> editl4u1 -> setText(data[24]) ;
  ui -> editl4u2 -> setText(data[25]) ;
  ui -> editl4u3 -> setText(data[26]) ;
  ui -> editl4u4 -> setText(data[27]) ;

  ui -> editl5u1 -> setText(data[32]) ;
  ui -> editl5u2 -> setText(data[33]) ;
  ui -> editl5u3 -> setText(data[34]) ;
  ui -> editl5u4 -> setText(data[35]) ;

  fillInTable(0, resData);

  //show_only enum
  connect(ui ->closeDialogButton, SIGNAL(clicked() ), this, SLOT(closeDialog() ) ) ;
  //edit_res enum
  connect(ui -> cancelButton, SIGNAL(clicked() ), this, SLOT(cancel() ) ) ;
  connect(ui -> editButton, SIGNAL(clicked() ), this, SLOT(edit() ) ) ;
  connect(ui -> saveButton, SIGNAL(clicked() ), this, SLOT(save() ) ) ;

}
Esempio n. 5
0
void MainWindow::onGameStatusChanged(Game::STATUS gameStatus)
{
    switch (gameStatus)
    {
    case Game::NO_PLAYING:
        ui->connectButton->setText("Połącz");
        if (ui->stackedWidget->currentWidget() != ui->gameOver)
            ui->stackedWidget->setCurrentWidget(ui->menu);
        if (!game.errCode)
            ui->statusbar->showMessage("");
        break;
    case Game::CONNECTING:
        game.errCode = 0;
        ui->connectButton->setText("Rozłącz");
        ui->statusbar->showMessage("Łączenie z serwerem...");
        break;
    case Game::SENDING_HELLO:
        ui->statusbar->showMessage("Wysyłanie komunikatu powitalnego...");
        break;
    case Game::WAITING_FOR_PLAYER:
        ui->statusbar->showMessage("Oczekiwanie na graczy...");
        break;
    case Game::PLAYING:
        ui->stackedWidget->setCurrentWidget(ui->game);
        ui->exitGameButton->setEnabled(true);
        ui->statusbar->showMessage("Połączono!");
        updated = false;
        break;
    case Game::SENDING_GOODBYE:
        ui->exitGameButton->setEnabled(true);
        ui->statusbar->showMessage("Wysyłanie komunikatu pożegnalnego...");
        break;
    case Game::DISCONNECTING:
        ui->statusbar->showMessage("Rozłączanie...");
        break;
    case Game::GAME_OVER:
        int redPoints = 0, bluePoints = 0;
        foreach (const Player &player, game.model2.players)
        {
            switch (player.group)
            {
            case Player::RED_GROUP:
                redPoints += player.points;
                break;
            case Player::BLUE_GROUP:
                bluePoints += player.points;
                break;
            }
        }
        ui->redPointsLabel->setText(QString("Czerwoni: %1 pkt.").arg(redPoints));
        ui->bluePointsLabel->setText(QString("Niebiescy: %1 pkt.").arg(bluePoints));
        if (redPoints == bluePoints)
            ui->yourStatusLabel->setText(QStringLiteral("<font color='#ff0'>Remis!</font>"));
        else if (
                 ((redPoints > bluePoints) && (game.model2.players[game.player.id].group == Player::RED_GROUP)) ||
                 ((redPoints < bluePoints) && (game.model2.players[game.player.id].group == Player::BLUE_GROUP))
        )
            ui->yourStatusLabel->setText(QStringLiteral("<font color='#6f6'>Wygrana!</font>"));
        else
            ui->yourStatusLabel->setText(QStringLiteral("<font color='#f66'>Przegrana!</font>"));
        fillInTable(ui->topSummary);
        ui->stackedWidget->setCurrentWidget(ui->gameOver);
        break;
    }
}
RockPhysicsInversion4D::RockPhysicsInversion4D(NRLib::Vector                      priorMean,
                                               NRLib::Matrix                      priorCov,
                                               NRLib::Matrix                      posteriorCov,
                                               std::vector<std::vector<double> >  mSamp)
{
  nf_.resize(4);
  nf_[0] = 60;
  nf_[1] = 60;
  nf_[2] = 60;
  nf_[3] = 60;
  nfp_= 135;

  fftplan1_ = rfftwnd_create_plan(1, &nfp_, FFTW_REAL_TO_COMPLEX, FFTW_ESTIMATE | FFTW_IN_PLACE);
  fftplan2_ = rfftwnd_create_plan(1, &nfp_, FFTW_COMPLEX_TO_REAL, FFTW_ESTIMATE | FFTW_IN_PLACE);

  v_.resize(4,6);
  SolveGEVProblem(priorCov,posteriorCov, v_);
  NRLib::Matrix tmp;
  NRLib::Matrix priorCovF;
  NRLib::Matrix posteriorCovF;

  meanf_        = priorMean*v_;
  tmp           = priorCov*v_;
  priorCovF     = transpose(v_)*tmp;
  tmp           = posteriorCov*v_;
  posteriorCovF = transpose(v_)*tmp;

  int nSamp = mSamp[0].size();

  NRLib::Vector m(6);
  for(int k=0;k<6;k++)
      m(k)=mSamp[k][0];

  maxf_=m*v_;
  minf_=m*v_;

  for(int i=0;i<nSamp;i++)
  {
    NRLib::Vector f;
    for(int k=0;k<6;k++)
      m(k)=mSamp[k][i];
    f=m*v_;
    for(int k=0;k<4;k++)
    {
      if(minf_(k) > f(k))
        minf_(k)=f(k);
      if(maxf_(k) < f(k))
        maxf_(k)=f(k);
    }
  }

  for(int k=0;k<4;k++)
  {
    minf_(k)-=3*sqrt(posteriorCovF(k,k));
    maxf_(k)+=3*sqrt(posteriorCovF(k,k));
  }

  smoothingFilter_.resize(4);
  priorDistribution_.resize(4);

  for(int i=0;i<4;i++)
  {
    double df=(maxf_(i)-minf_(i))/double(nf_[i]);
    priorDistribution_[i]=MakeGaussKernel(meanf_(i),priorCovF(i,i),minf_(i),df,nfp_);
    smoothingFilter_[i]=MakeSmoothingFilter(posteriorCovF(i,i),df);
  }

  allocatePredictionTables( );

  std::vector<double> dummy(nSamp);
  for(int i=0;i<nSamp;i++)
    dummy[i]=1.0;

  fillInTable( mSamp,dummy,0);
  DivideAndSmoothTable(0,priorDistribution_,smoothingFilter_);
}