Commit 23d624f0 authored by Ian Humphrey's avatar Ian Humphrey
Browse files

Updated jigsaw dialog and setup to restore selected control net. References #4817.

parent 9b147c68
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ namespace Isis {
    m_project = project;
    m_bundleSettings = bundleSettings;
    m_selectedControl = selectedControl;
    m_selectedControlName = FileName(selectedControl->fileName()).name();
    init();
  }

@@ -67,6 +68,9 @@ namespace Isis {
  void JigsawDialog::init() {
    m_ui->setupUi(this);

    // Note: The buttons are added to the UI setup from the JigsawDialog.ui file.
    // These could have been added to the UI file itself (as XML).

    // Three buttons: Accept, Reject, Close. Initially only close is enabled.
    // Close is only disabled when a bundle is running.
    // After a bundle is successfully run, reject and accept are enabled.
@@ -84,6 +88,8 @@ namespace Isis {
    m_close->setToolTip(tr("Close this dialog."));

    // Add the buttons to the QDialogButtonBox defined in the UI file.
    // Note that according to the Qt doc'n for QDialogButtonBox, addButton() causes the
    // dialog box to take ownership of the QPushButton's, so we don't manually manage their memory.
    m_ui->buttonBox->addButton(m_accept, QDialogButtonBox::ActionRole);
    m_ui->buttonBox->addButton(m_reject, QDialogButtonBox::ActionRole);
    m_ui->buttonBox->addButton(m_close, QDialogButtonBox::AcceptRole);
@@ -153,6 +159,8 @@ namespace Isis {
    // are present in the setup dialog.
    if (m_bundleSettings && !m_ui->useLastSettings->isChecked()) {
      setupdlg.loadSettings(m_bundleSettings);
      // We also tell the setup dialog what the last selected control is.
      setupdlg.selectControl(m_selectedControlName);
    }

    if (setupdlg.exec() == QDialog::Accepted) {
@@ -189,6 +197,9 @@ namespace Isis {
         if (lastBundleSettings) {
           m_bundleSettings = lastBundleSettings;
         }

         // Grab the control name that was used in that bundle adjustment.
         m_selectedControlName = FileName(bundleSolutionInfo.last()->controlNetworkFileName()).name();
      }

      // Clear the dialog displays.
+3 −1
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@ namespace Isis {
   *   @history 2017-04-26 Ian Humphrey - Added updateScrollBar() and clearDialog() to reduce
   *                           code duplication. Modified the run clicked slot to clear the
   *                           dialog display anytime that a bundle adjust is re-ran. Fixes #4808.
   *   @history 2017-04-27 Ian Humphrey - Modified to track the last used control net to properly
   *                           update the jigsaw setup dialog's cnet combo box. References #4817.
   */
  class JigsawDialog : public QDialog {
    Q_OBJECT
@@ -81,7 +83,7 @@ namespace Isis {
    BundleAdjust *m_bundleAdjust;
    Project *m_project;
    Control *m_selectedControl;
    QString *m_selectedControlName;
    QString m_selectedControlName;
    BundleSettingsQsp m_bundleSettings;

  private:
+3 −3
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
   <rect>
    <x>0</x>
    <y>0</y>
    <width>520</width>
    <width>540</width>
    <height>300</height>
   </rect>
  </property>
@@ -38,7 +38,7 @@
    <rect>
     <x>320</x>
     <y>10</y>
     <width>189</width>
     <width>208</width>
     <height>94</height>
    </rect>
   </property>
@@ -60,7 +60,7 @@
    <item row="2" column="0">
     <widget class="QCheckBox" name="useLastSettings">
      <property name="text">
       <string>Use Last Settings</string>
       <string>Use Last Accepted Settings</string>
      </property>
     </widget>
    </item>
+35 −5
Original line number Diff line number Diff line
@@ -64,6 +64,10 @@ namespace Isis {
    QList<BundleSolutionInfo *> bundleSolutionInfo = m_project->bundleSolutionInfo();
    if (useLastSettings && bundleSolutionInfo.size() > 0) {
     BundleSettingsQsp lastBundleSettings = (bundleSolutionInfo.last())->bundleSettings();
     // Retrieve the control net name used in the last bundle adjustment.
     // Note that this returns a fully specified path and filename, while the cnet combo box
     // only stores file names.
     selectControl(bundleSolutionInfo.last()->controlNetworkFileName());
     fillFromSettings(lastBundleSettings);
    }

@@ -616,6 +620,35 @@ namespace Isis {
  }


  /**
   * Selects a control in the control network combo box by trying to find an item with the
   * matching name. If the name is found in the combo box, the box's index is set to that
   * found control network index. If the name is not found and the box is not empty, the
   * current index is set to 0 (the first item). If the name is not found and the box is
   * empty, the index is set to -1 (see Qt).
   *
   * @param const QString &controlName The name of the control to try to find in the combo box.
   */
  void JigsawSetupDialog::selectControl(const QString &controlName) {
    QComboBox &cnetBox = *(m_ui->controlNetworkComboBox);
    int foundControlIndex = cnetBox.findText(FileName(controlName).name());
    // We did not find it, so we need to see if the combo box is empty or not.
    if (foundControlIndex == -1) {
      if (cnetBox.count() == 0) {
       cnetBox.setCurrentIndex(-1);
      }
      // If it is not empty, just set the current index to the first item.
      else {
        cnetBox.setCurrentIndex(0);
      }
    }
    // Otherwise, set the current index to the found control net index.
    else {
      cnetBox.setCurrentIndex(foundControlIndex);
    }
  } 


  Control *JigsawSetupDialog::selectedControl() {

      int nIndex = m_ui->controlNetworkComboBox->currentIndex();
@@ -626,11 +659,8 @@ namespace Isis {
  }


  QString *JigsawSetupDialog::selectedControlName() {

    QString *name = new QString(m_ui->controlNetworkComboBox->currentText());
      return name;

  QString JigsawSetupDialog::selectedControlName() {
    return QString(m_ui->controlNetworkComboBox->currentText());
  }


+5 −1
Original line number Diff line number Diff line
@@ -38,6 +38,9 @@ namespace Isis {
   *   @history 2016-08-25 Adam Paquette - Updated documentation. Fixes #4299.
   *   @history 2017-04-25 Ian Humphrey - Added public loadSettings() to allow JigsawDialog to
   *                           load its current settings into the setup dialog. Fixes #4817.
   *   @history 2017-04-27 Ian Humphrey - Added selectControl() to allow JigsawDialog to
   *                           properly tell the setup dialog which control to select in its
   *                           combo box. References #4817.
   */

  class JigsawSetupDialog : public QDialog {
@@ -52,10 +55,11 @@ namespace Isis {
    ~JigsawSetupDialog();

    Control *selectedControl();// TODO: return const references ???
    QString *selectedControlName();// TODO: return const references ???
    QString selectedControlName();// TODO: return const references ???
    BundleSettingsQsp bundleSettings();// TODO: return const references ???

    void loadSettings(const BundleSettingsQsp settings);
    void selectControl(const QString &controlName);

  private slots:

Loading