Commit 084b7d39 authored by Ian Humphrey's avatar Ian Humphrey
Browse files

Merge branch 'ipceBundleWindow' into ipceBundleWindow_speedupSetup

parents f91eaddc 153723d6
Loading
Loading
Loading
Loading
+78 −85
Original line number Diff line number Diff line
@@ -1506,78 +1506,14 @@ namespace Isis {
   *
   * This slot populates the Instrument Position Solve Options table according to the value of the
   * SPK Solve Degree. Rows are added depending on the degree set, where number of rows added is
   * equal to the SPK Solve Degree + 1.
   * equal to the SPK Solve Degree + 1. Note that this relies on the updateSolveSettingsSigmaTables
   * slot, which uses the SPK Solve Degree if the ALL position option is selected.
   *
   * @param int Value the SPK Solve Degree spin box was changed to.
   */
  void JigsawSetupDialog::on_spkSolveDegreeSpinBox_valueChanged(int i) {
    // number of rows == spkSolveDegree value + 1 (i+1)
    QTableWidget *table = m_ui->positionAprioriSigmaTable;
    const int oldRowCount = table->rowCount();
    table->setRowCount(i + 1);
    const int newRowCount = table->rowCount();

    // Need to check if table is valid in case a row is removed (a row is removed implicitly when
    // the setRowCount() is called when newRowCount < oldRowCount
    validateSigmaTables();

    // Rows need to be added
    if (newRowCount > oldRowCount) {
      for (int row = oldRowCount; row < newRowCount; row++) {
        // Headers : coefficient, description, units, a priori sigma
        QTableWidgetItem *coefficient = new QTableWidgetItem();
        coefficient->setFlags(Qt::ItemIsEnabled);
        coefficient->setText(QString::number(row + 1));
        table->setItem(row, 0, coefficient);

        QTableWidgetItem *description = new QTableWidgetItem();
        description->setFlags(Qt::ItemIsEnabled);
        description->setText("N/A");
        table->setItem(row, 1, description);

        QTableWidgetItem *units = new QTableWidgetItem();
        units->setFlags(Qt::ItemIsEnabled);
        units->setText("m/s^" + QString::number(row));
        table->setItem(row, 2, units);

        QTableWidgetItem *sigma = new QTableWidgetItem();
        sigma->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
        sigma->setText("0.0");
        sigma->setData(Qt::UserRole, QVariant(true));
        table->setItem(row, 3, sigma);

        // Solve option: spk degree { NONE: -1, POSITION: 0, VELOCITY: 1, ACCELERATION: 2, ALL: 2 }
        // POSITION
        if (row == 0) { 
          QTableWidgetItem *description = table->item(0, 1);
          description->setText("POSITION");

          QTableWidgetItem *units = table->item(0, 2);
          units->setText("meters");
        }

        // VELOCITY
        else if (row == 1) {
          QTableWidgetItem *description = table->item(1, 1);
          description->setText("VELOCITY");

          QTableWidgetItem *units = table->item(1, 2);
          units->setText("m/s");
        }

        // ACCELERATION
        else if (row == 2) {
          QTableWidgetItem *description = table->item(2, 1);
          description->setText("ACCELERATION");

          QTableWidgetItem *units = table->item(2, 2);
          units->setText("m/s^2");
        }
      }
    }

    table->resizeColumnToContents(1);
    table->resizeColumnToContents(2);
    // Update the position apriori sigma table and use the position combo box solve option
    updateSolveSettingsSigmaTables(m_ui->positionComboBox, m_ui->positionAprioriSigmaTable);
  }


@@ -1586,21 +1522,70 @@ namespace Isis {
   *
   * This slot populates the Instrument Pointing Solve Options table according to the value of the
   * CK Solve Degree. Rows are added depending on the degree set, where number of rows added is
   * equal to the CK Solve Degree + 1.
   * equal to the CK Solve Degree + 1. Note that this relies on the updateSolveSettingsSigmaTables
   * slot, which uses the CK Solve Degree if the ALL pointing option is selected.
   *
   * @param int Value the CK Solve Degree spin box was changed to.
   */
  void JigsawSetupDialog::on_ckSolveDegreeSpinBox_valueChanged(int i) {
    // number of rows == ckSolveDegree value + 1 (i+1)
    QTableWidget *table = m_ui->pointingAprioriSigmaTable;
    // Update the pointing apriori sigma table and use the pointing combo box solve option
    updateSolveSettingsSigmaTables(m_ui->pointingComboBox, m_ui->pointingAprioriSigmaTable);
  }


  /**
   * Slot that updates the sigma tables based on the current solve option selection.
   *
   * This will add/remove rows based on the solve option selected, and if ALL, the current
   * solve degree value.
   *
   * @param const QComboBox * The solve option combo box to read the solve option from
   * @param QTableWidget * The a priori sigma table we are going to update rows for
   */
  void JigsawSetupDialog::updateSolveSettingsSigmaTables(const QComboBox *solveOptionComboBox,
                                                         QTableWidget *table) {
    int rowCount = solveOptionComboBox->currentIndex();

    // Position: { NONE, POSITION, VELOCITY, ACCELERATION, ALL }
    // Pointing: { NONE, ANGLES, ANGULAR VELOCITY, ANGULAR ACCELERATION, ALL }
    // Need to add to the solve degree value since number of rows == number of solve coefficients,
    // and for our polynomials the number of solve coefficients == solve degree + 1
    // When solve option is ALL (index 4), use the spk/ck solve degree value + 1 for number of rows
    if (rowCount == 4) {
      if (solveOptionComboBox == m_ui->positionComboBox) {
        rowCount = m_ui->spkSolveDegreeSpinBox->value() + 1;
      }
      else { // if (solveOptionComboBox == m_ui->pointingComboBox)
        rowCount = m_ui->ckSolveDegreeSpinBox->value() + 1;
      }
    }

    // number of rows == position solve option == SolveDegree value + 1 (i+1)
    const int oldRowCount = table->rowCount();
    table->setRowCount(i + 1);
    // if solving ALL, don't add extra row
    table->setRowCount(rowCount);
    const int newRowCount = table->rowCount();

    // Need to check if table is valid in case a row is removed (a row is removed implicitly when
    // the setRowCount() is called when newRowCount < oldRowCount
    validateSigmaTables();

    // Determine the units for either position or pointing
    QStringList solveOptions;
    QString longUnits("N/A");
    QString shortUnits("N/A");
    if (solveOptionComboBox == m_ui->positionComboBox) {
      longUnits = "meters";
      shortUnits = "m";
      solveOptions += {"POSITION", "VELOCITY", "ACCELERATION"};
    }
    else { // if (solveOptionComboBox == m_ui->pointingComboBox) {
      longUnits = "degrees";
      shortUnits = "deg";
      solveOptions += {"ANGLES", "ANGULAR VELOCITY", "ANGULAR ACCELERATION"};
    }

    // Rows need to be added
    if (newRowCount > oldRowCount) {
      for (int row = oldRowCount; row < newRowCount; row++) {
        // Headers : coefficient, description, units, a priori sigma
@@ -1616,7 +1601,7 @@ namespace Isis {

        QTableWidgetItem *units = new QTableWidgetItem();
        units->setFlags(Qt::ItemIsEnabled);
        units->setText("deg/s^" + QString::number(row));
        units->setText(shortUnits + "/s^" + QString::number(row));
        table->setItem(row, 2, units);

        QTableWidgetItem *sigma = new QTableWidgetItem();
@@ -1625,32 +1610,32 @@ namespace Isis {
        sigma->setData(Qt::UserRole, QVariant(true));
        table->setItem(row, 3, sigma);

        // { NONE: N/A, ANGLES: 0, ANGULAR VELOCITY: 1, ANGULAR ACCELERATION: 2, ALL: 2 }
        // ANGLES
        // Solve option: spk degree { NONE: -1, POSITION: 0, VELOCITY: 1, ACCELERATION: 2, ALL: 2 }
        // POSITION
        if (row == 0) { 
          QTableWidgetItem *description = table->item(0, 1);
          description->setText("ANGLES");
          description->setText(solveOptions.at(row));

          QTableWidgetItem *units = table->item(0, 2);
          units->setText("degrees");
          units->setText(longUnits);
        }

        // VELOCITY
        if (row == 1) {
        else if (row == 1) {
          QTableWidgetItem *description = table->item(1, 1);
          description->setText("ANGULAR VELOCITY");
          description->setText(solveOptions.at(row));

          QTableWidgetItem *units = table->item(1, 2);
          units->setText("deg/s");
          units->setText(shortUnits + "/s");
        }

        // ACCELERATION
        if (row == 2) {
        else if (row == 2) {
          QTableWidgetItem *description = table->item(2, 1);
          description->setText("ANGULAR ACCELERATION");
          description->setText(solveOptions.at(row));

          QTableWidgetItem *units = table->item(2, 2);
          units->setText("deg/s^2");
          units->setText(shortUnits + "/s^2");
        }
      }
    }
@@ -1681,10 +1666,14 @@ namespace Isis {
        spinBox->setEnabled(true);
      }
      else {
        spinBox->setValue(solveIndex - 1);
        // The default value for the spk solve degree and spk degree spinboxes is 2. This is
        // emulating jigsaw's defaults for position solve options that are not ALL.
        spinBox->setValue(2);
        spinBox->setEnabled(false);
      }
    }

    updateSolveSettingsSigmaTables(m_ui->positionComboBox, m_ui->positionAprioriSigmaTable);
  }


@@ -1709,10 +1698,14 @@ namespace Isis {
        spinBox->setEnabled(true);
      }
      else {
        spinBox->setValue(solveIndex - 1);
        // The default value for the ck solve degree and spk degree spinboxes is 2. This is
        // emulating jigsaw's defaults for pointing solve options that are not ALL.
        spinBox->setValue(2);
        spinBox->setEnabled(false);
      }
    }

    updateSolveSettingsSigmaTables(m_ui->pointingComboBox, m_ui->pointingAprioriSigmaTable);
  }


+8 −0
Original line number Diff line number Diff line
@@ -9,7 +9,9 @@ namespace Ui {
  class JigsawSetupDialog;
}

class QComboBox;
class QItemSelection;
class QTableWidget;
class QTableWidgetItem;

namespace Isis {
@@ -87,6 +89,10 @@ namespace Isis {
   *                           until all the a priori sigma values are valid again. References #497.
   *   @history 2018-06-28 Christopher Combs - Implemented pseudocode in on_applySettings... method.
   *                           Added selected images to default BOSS object. References #497.
   *   @history 2018-07-01 Ian Humphrey - Added updateSolveSettingsSigmaTables() to try to
   *                           generalize how the sigma tables are updated. Solve options have
   *                           their respective solve degree and degree combo boxes set to 2 unless
   *                           the solve option is ALL. References #497.
   */
  class JigsawSetupDialog : public QDialog {
    Q_OBJECT
@@ -161,6 +167,8 @@ namespace Isis {
    void on_positionComboBox_currentIndexChanged(const QString &arg1);
    void on_pointingComboBox_currentIndexChanged(const QString &arg1);

    void updateSolveSettingsSigmaTables(const QComboBox *solveOptionComboBox, 
                                        QTableWidget *table);
    void validateSigmaValue(QTableWidgetItem *);
    void validateSigmaTables();