Commit cbddac43 authored by Ian Humphrey's avatar Ian Humphrey
Browse files

Updated JigsawDialog with Accept, Reject, Close buttons. Fixes #4781.

parent 25f6f3cf
Loading
Loading
Loading
Loading
+52 −1
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@
#include <QThread>

#include "JigsawSetupDialog.h"
//#include "ui_JigsawDialog.h"

#include "BundleAdjust.h"
#include "BundleSolutionInfo.h"
@@ -51,6 +50,7 @@ namespace Isis {
                             BundleSettingsQsp bundleSettings,
                             Control *selectedControl,
                             QWidget *parent) : QDialog(parent), m_ui(new Ui::JigsawDialog) {

    m_project = project;
    m_bundleSettings = bundleSettings;
    m_selectedControl = selectedControl;
@@ -66,6 +66,28 @@ namespace Isis {
  void JigsawDialog::init() {
    m_ui->setupUi(this);

    // Three buttons: Accept, Reject, Close. Initially only close is enabled.
    // After a bundle is successfully run, reject and accept are enabled.
    // If aborting a bundle, only close will be enabled.
    m_accept = new QPushButton(tr("&Accept"));
    m_reject = new QPushButton(tr("&Reject"));
    m_close = new QPushButton(tr("&Close"));
    m_accept->setEnabled(false);
    m_reject->setEnabled(false);
    m_close->setEnabled(true);

    // Add the buttons to the QDialogButtonBox defined in the UI file.
    m_ui->buttonBox->addButton(m_accept, QDialogButtonBox::ActionRole);
    m_ui->buttonBox->addButton(m_reject, QDialogButtonBox::ActionRole);
    m_ui->buttonBox->addButton(m_close, QDialogButtonBox::AcceptRole);

    // Accept will handle saving the results.
    connect(m_accept, SIGNAL(clicked(bool)),
           this, SLOT(acceptBundleResults()));
    // Reject will handle discarding the results.
    connect(m_reject, SIGNAL(clicked(bool)),
           this, SLOT(rejectBundleResults()));

    m_bundleAdjust = NULL;

    m_bRunning = false;
@@ -123,6 +145,9 @@ namespace Isis {


  void JigsawDialog::on_JigsawRunButton_clicked() {
    // Once a bundle is run, the previous results cannot be accepted or rejected.
    m_accept->setEnabled(false);
    m_reject->setEnabled(false);

    if (!m_bRunning) {
      // ??? warning dialogs ???
@@ -265,6 +290,28 @@ namespace Isis {
  }


  /**
   * Accepts the bundle results and saves them to the project. The "Accept" and "Reject" buttons
   * will be disabled.
   */
  void JigsawDialog::acceptBundleResults() {
    qDebug() << "\n*** Accepting the results...\n";
    m_accept->setEnabled(false);
    m_reject->setEnabled(false);
  }


  /**
   * Rejects the bundle results and discards them. The "Accept" and "Reject" buttons will be
   * disabled.
   */
  void JigsawDialog::rejectBundleResults() {
    qDebug() << "\n*** Rejecting the results...\n";
    m_accept->setEnabled(false);
    m_reject->setEnabled(false);
  }


  /**
   * Update the label or text edit area with the most recent status update by appending to list and
   * refreshing.
@@ -361,6 +408,10 @@ namespace Isis {
   * @param bundleSolutionInfo The results of the bundle run.
   */
  void JigsawDialog::bundleFinished(BundleSolutionInfo *bundleSolutionInfo) {
    // Since results are available, the user can accept (save) or reject(discard) the results.
    m_accept->setEnabled(true);
    m_reject->setEnabled(true);
    // m_close->setEnabled(false);
    if ( bundleSolutionInfo->bundleResults().converged() ) {
      bundleSolutionInfo->setRunTime( Isis::iTime::CurrentLocalTime().toLatin1().data() );
      m_project->addBundleSolutionInfo( new BundleSolutionInfo(*bundleSolutionInfo) );
+13 −2
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
#include <QPointer>
#include <QWidget>

#include "BundleAdjustWorkOrder.h"
#include "BundleSettings.h"
#include "IException.h"

@@ -42,6 +43,11 @@ namespace Isis {
   *                           information to this dialog. Added init() delegate method for
   *                           constructors to use to reduce code duplication. Modified
   *                           notifyThreadFinished to update the Run button. References #4748.
   *   @history 2017-04-18 Ian Humphrey - Added members for an Accept, Reject, and Close button
   *                           to determine when to save a successful bundle adjust's results
   *                           to the project (or when to discard the results). Added placeholder
   *                           private slots for accepting and rejecting the results. Removed
   *                           default OK and Cancel buttons from UI file. Fixes #4781.
   */
  class JigsawDialog : public QDialog {
    Q_OBJECT
@@ -72,14 +78,19 @@ namespace Isis {
    BundleSettingsQsp m_bundleSettings;

  private:
    bool m_bRunning;
    bool m_bRunning; /**< Indicates whether or not the bundle adjust is running. */
    QPushButton *m_accept; /**< Dialog's accept button that is used to save the bundle results. */
    QPushButton *m_close; /**< Dialog's close button that is used to close the dialog. */
    QPushButton *m_reject; /**< Dialog's reject button that is used to discard the results. */

  private slots:
    void on_JigsawSetupButton_pressed();
    void on_JigsawRunButton_clicked();
    void acceptBundleResults();
    void rejectBundleResults();

  private:
    Ui::JigsawDialog *m_ui;
    Ui::JigsawDialog *m_ui; /**< Reference to self's UI generated with QtDesigner. */
  };
};
#endif
+0 −3
Original line number Diff line number Diff line
@@ -32,9 +32,6 @@
   <property name="orientation">
    <enum>Qt::Horizontal</enum>
   </property>
   <property name="standardButtons">
    <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
   </property>
  </widget>
  <widget class="QWidget" name="jigsawButtonsLayoutWidget">
   <property name="geometry">