Commit 95e58172 authored by chrisryancombs's avatar chrisryancombs
Browse files

Cleaned up changes to JigsawDialog, now JigsawRunWidget

parent 14b182b5
Loading
Loading
Loading
Loading
+27 −4
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@
#include "ImportImagesWorkOrder.h"
#include "ImportShapesWorkOrder.h"
#include "ImportTemplateWorkOrder.h"
#include "JigsawDialog.h"
#include "JigsawRunWidget.h"
#include "JigsawWorkOrder.h"
#include "MatrixSceneWidget.h"
#include "MatrixViewWorkOrder.h"
@@ -300,6 +300,7 @@ namespace Isis {
    m_sensorInfoWidgets.clear();
    m_targetInfoWidgets.clear();
    m_templateEditorWidgets.clear();
    m_jigsawRunWidget.clear();

    m_projectItemModel->clean();
    emit directoryCleaned();
@@ -934,14 +935,20 @@ namespace Isis {
    return result;
  }

  JigsawDialog *Directory::addJigsawView() {
    JigsawDialog *result = new JigsawDialog(m_project);
  JigsawRunWidget *Directory::addJigsawView() {
    if (jigsawRunWidget()) {
      return m_jigsawRunWidget;
    }
    JigsawRunWidget *result = new JigsawRunWidget(m_project);

    connect( result, SIGNAL( destroyed(QObject *) ),
             this, SLOT( cleanupJigsawRunWidget(QObject *) ) );
    m_jigsawRunWidget = result;

    result->setAttribute(Qt::WA_DeleteOnClose);
    result->show();

    emit newWidgetAvailable(result);

    return result;
  }

@@ -1207,6 +1214,15 @@ namespace Isis {
  }


  void Directory::cleanupJigsawRunWidget(QObject *obj) {
     JigsawRunWidget *jigsawRunWidget = static_cast<JigsawRunWidget *>(obj);
     if (!jigsawRunWidget) {
       return;
     }
     m_jigsawRunWidget = NULL;
  }


  /**
   * @brief  Adds a new Project object to the list of recent projects if it has not
   * already been added.
@@ -1354,6 +1370,13 @@ namespace Isis {
    return m_controlPointEditViewWidget;
  }


  JigsawRunWidget *Directory::jigsawRunWidget() {

    return m_jigsawRunWidget;
  }


/*
  ChipViewportsWidget *Directory::controlPointChipViewports() {

+9 −2
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ namespace Isis {
  class Footprint2DView;
  class HistoryTreeWidget;
  class ImageFileListWidget;
  class JigsawDialog;
  class JigsawRunWidget;
  class MatrixSceneWidget;
  class MosaicSceneWidget;
  class Project;
@@ -237,6 +237,9 @@ namespace Isis {
   *   @history 2018-05-14 Tracie Sucharski - Serialize Footprint2DView rather than
   *                           MosaicSceneWidget. This will allow all parts of Footprint2DView to be
   *                           saved/restored including the ImageFileListWidget. Fixes #5422.
   *   @history 2018-05-25 Christopher Combs - Made changes to reflect updates to JigsawRunWidget.
   *                           Added addJigsawView method and m_jigsawRunWidget member variable.
   *                           Fixes #5428.
   */
  class Directory : public QObject {
    Q_OBJECT
@@ -254,7 +257,7 @@ namespace Isis {
      CnetEditorView *addCnetEditorView(Control *control);
      CubeDnView *addCubeDnView();
      Footprint2DView *addFootprint2DView();
      JigsawDialog *addJigsawView();
      JigsawRunWidget *addJigsawView();
      MatrixSceneWidget *addMatrixView();
      TargetInfoWidget *addTargetInfoView(TargetBodyQsp target);
      TemplateEditorWidget *addTemplateEditorView(Template *currentTemplate);
@@ -291,6 +294,7 @@ namespace Isis {
      QList<ImageFileListWidget *> imageFileListViews();
      QList<QProgressBar *> progressBars();
      ControlPointEditView *controlPointEditView();
      JigsawRunWidget *jigsawRunWidget();
//      ChipViewportsWidget *controlPointChipViewports();

      bool controlUsedInCnetEditorWidget(Control *control);
@@ -376,6 +380,7 @@ namespace Isis {
      void cleanupSensorInfoWidgets(QObject *);
      void cleanupTargetInfoWidgets(QObject *);
      void cleanupTemplateEditorWidgets(QObject *);
      void cleanupJigsawRunWidget(QObject *);
      //void imagesAddedToProject(ImageList *images);
      void updateControlNetEditConnections();

@@ -450,6 +455,8 @@ namespace Isis {
      QPointer<HistoryTreeWidget> m_historyTreeWidget;  //!< Pointer to the HistoryTreeWidget.
      QPointer<Project> m_project;                      //!< Pointer to the Project.
      QPointer<WarningTreeWidget> m_warningTreeWidget;  //!< Pointer to the WarningTreeWidget.
      QPointer<JigsawRunWidget> m_jigsawRunWidget;         //!< Pointer to the JigsawRunWidget.


      //!< List of BundleObservationView
      QList< QPointer<BundleObservationView> > m_bundleObservationViews;
+12 −43
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@
#include "BundleSolutionInfo.h"
#include "Control.h"
#include "Directory.h"
#include "JigsawDialog.h"
#include "JigsawRunWidget.h"
#include "JigsawSetupDialog.h"
#include "Project.h"

@@ -43,11 +43,11 @@ namespace Isis {
   * @brief Constructs a JigsawWorkOrder.
   *
   * This creates a work order to run bundle adjustments. Note that right now,
   * the design implemented means that this work order finishes after a JigsawDialog
   * the design implemented means that this work order finishes after a JigsawRunWidget
   * is shown. This work order is synchronous and not undoable. Note is is synchronous
   * in that it simply displays a dialog. The actual bundle adjust is threaded.
   *
   * @see JigsawDialog
   * @see JigsawRunWidget
   *
   * @param project The Project that we are going to Bundle Adjust
   *
@@ -99,41 +99,10 @@ namespace Isis {
   *         is greater than 0.
   */
  bool JigsawWorkOrder::isExecutable() {
    return (project()->controls().size() > 0 && project()->images().size() > 0);
  }


  /**
   * If WorkOrder:setupExecution() returns true, this creates a setup dialog.
   *
   * When the setup is successful (i.e. the user does not cancel the dialog), this work order
   * will be read to execute.
   *
   * @return bool Returns True if setup dialog for the bundle adjustment is successful.
   */
  bool JigsawWorkOrder::setupExecution() {
    bool success = WorkOrder::setupExecution();

    // if (success) {
    //   // Create a blocking setup dialog initially and check to make sure we get valid info
    //   JigsawSetupDialog setup(project());
    //   if (setup.exec() == QDialog::Accepted) {
    //     m_bundleSettings = setup.bundleSettings();
    //     if (setup.selectedControl()) {
    //       setInternalData(QStringList(setup.selectedControl()->id()));
    //     }
    //     // This else should not happen, the work order should be disabled if there are no controls.
    //     else {
    //       QString msg = "Cannot run a bundle adjustment without a selected control network.";
    //       QMessageBox::critical(qobject_cast<QWidget *>(parent()), "Error", msg);
    //       success = false;
    //     }
    //   }
    //   else {
    //     success = false;
    //   }
    // }
    return success;
    // Is this code ever run?
    return (project()->controls().size() > 0 && 
            project()->images().size() > 0 &&
            !project()->directory()->jigsawRunWidget());
  }


@@ -158,11 +127,11 @@ namespace Isis {
   * @see WorkOrder::execute()
   */
  void JigsawWorkOrder::execute() {
    JigsawRunWidget *runDialog = project()->directory()->addJigsawView();

    Project *proj = project();

    // Get the selected control and bundle settings and give them to the JigsawDialog for now.
    // Control *selectedControl = project()->control(internalData().first());
    JigsawDialog *runDialog = project()->directory()->addJigsawView();
    if (!runDialog) {
      QString msg = "Unable to open Jigsaw Run Widget";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }
  }
}
+3 −2
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ namespace Isis {
   *                           active cnet and image list have been set. Fixes #4749.
   *   @history 2017-04-25 Ian Humphrey - Modified tool tip text. Fixes #4819.
   *   @history 2017-07-25 Cole Neubauer - Added project()->setClean call #4969
   *   @history 2017-07-25 Cole Neubauer - Moved project()->setClean call to JigsawDialog because
   *   @history 2017-07-25 Cole Neubauer - Moved project()->setClean call to JigsawRunWidget because
   *                           the workorder does not actually execute the bundle adjustment #4960
   *   @history 2018-03-22 Ken Edmundson - Modified setupExecution method to append output control
   *                           network filename to internalData. Modified execute method to look for
@@ -56,6 +56,8 @@ namespace Isis {
   *   @history 2018-03-23 Ken Edmundson - In execute method, removed search for input control
   *                           network in BundleSolutionInfos. No longer needed as control is now
   *                           properly saved in projects m_idToControlMap.
   *   @history 2018-05-25 Christopher Combs - Updated to reflect change from JigsawDialog to 
   *                           JigsawRunWidget. Removed setupExecution() method. Fixes #5428.
   */
  class JigsawWorkOrder : public WorkOrder {
      Q_OBJECT
@@ -67,7 +69,6 @@ namespace Isis {
      virtual JigsawWorkOrder *clone() const;

      virtual bool isExecutable();
      virtual bool setupExecution();
      virtual void execute();

    protected:
+24 −23
Original line number Diff line number Diff line
#include "JigsawDialog.h"
#include "JigsawRunWidget.h"

#include <QtConcurrent>
#include <QDebug>
@@ -22,7 +22,7 @@
#include "iTime.h"
#include "Process.h"
#include "Project.h"
#include "ui_JigsawDialog.h"
#include "ui_JigsawRunWidget.h"

namespace Isis {

@@ -34,7 +34,7 @@ namespace Isis {
   * @param Project *project Pointer to the project this dialog belongs to.
   * @param QWidget *parent Pointer to parent widget.
   */
  JigsawDialog::JigsawDialog(Project *project, QWidget *parent) : m_ui(new Ui::JigsawDialog) {
  JigsawRunWidget::JigsawRunWidget(Project *project, QWidget *parent) : m_ui(new Ui::JigsawRunWidget) {
    m_project = project;
    m_selectedControl = NULL;
    init();
@@ -52,10 +52,11 @@ namespace Isis {
   * @param Control *selectedControl Pointer to the selected control to adjust.
   * @param QWidget *parent Pointer to the parent widget.
   */
  JigsawDialog::JigsawDialog(Project *project,
  JigsawRunWidget::JigsawRunWidget(Project *project,
                             BundleSettingsQsp bundleSettings,
                             Control *selectedControl,
                             QWidget *parent) : m_ui(new Ui::JigsawDialog) {
                             QString outputControlFileName,
                             QWidget *parent) : m_ui(new Ui::JigsawRunWidget) {

    m_project = project;
    m_bundleSettings = bundleSettings;
@@ -71,10 +72,10 @@ namespace Isis {
   *
   * Delegate method that helps the constructors. This is used to reduce repeated code.
   */
  void JigsawDialog::init() {
  void JigsawRunWidget::init() {
    m_ui->setupUi(this);

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

    // Three buttons: Accept, Reject, Close. Initially only close is enabled.
@@ -137,7 +138,7 @@ namespace Isis {
  /**
   * Destructor.
   */
  JigsawDialog::~JigsawDialog() {
  JigsawRunWidget::~JigsawRunWidget() {
    if (m_bundleSolutionInfo) {
      delete m_bundleSolutionInfo;
    }
@@ -153,7 +154,7 @@ namespace Isis {
  }


  void JigsawDialog::on_JigsawSetupButton_pressed() {
  void JigsawRunWidget::on_JigsawSetupButton_pressed() {

    // Each time the SetUp button is pressed, create JigsawSetupDialog object with
    // project,
@@ -186,7 +187,7 @@ namespace Isis {
  }


  void JigsawDialog::on_JigsawRunButton_clicked() {
  void JigsawRunWidget::on_JigsawRunButton_clicked() {
    // Once a bundle is run, the previous results cannot be accepted or rejected.
    m_accept->setEnabled(false);
    m_reject->setEnabled(false);
@@ -288,7 +289,7 @@ namespace Isis {
   * Constructs a image copier functor for copying images used in the bundle adjustment to the
   * bundle solution info results (when the bundle is accepted).
   */
  JigsawDialog::CopyImageToResultsFunctor::CopyImageToResultsFunctor(const QDir &destination) {
  JigsawRunWidget::CopyImageToResultsFunctor::CopyImageToResultsFunctor(const QDir &destination) {
    m_destinationFolder = destination;
  }

@@ -296,7 +297,7 @@ namespace Isis {
  /**
   * Destructor.
   */
  JigsawDialog::CopyImageToResultsFunctor::~CopyImageToResultsFunctor() {
  JigsawRunWidget::CopyImageToResultsFunctor::~CopyImageToResultsFunctor() {
    m_destinationFolder = QDir();
  }

@@ -312,7 +313,7 @@ namespace Isis {
   * @return Cube* Returns a pointer to the external cube copy. Returns NULL if an error
   *               occurs.
   */
  Cube *JigsawDialog::CopyImageToResultsFunctor::operator()(const FileName &image) {
  Cube *JigsawRunWidget::CopyImageToResultsFunctor::operator()(const FileName &image) {
    try {
      Cube *result = NULL;

@@ -364,7 +365,7 @@ namespace Isis {
   * Accepts the bundle results and saves them to the project. The "Accept" and "Reject" buttons
   * will be disabled.
   */
  void JigsawDialog::acceptBundleResults() {
  void JigsawRunWidget::acceptBundleResults() {
    m_accept->setEnabled(false);
    m_reject->setEnabled(false);

@@ -486,7 +487,7 @@ namespace Isis {
   * Rejects the bundle results and discards them. The "Accept" and "Reject" buttons will be
   * disabled.
   */
  void JigsawDialog::rejectBundleResults() {
  void JigsawRunWidget::rejectBundleResults() {
    // TODO should there be a prompt to user (are you sure?) -- Annoying?
    // TODO Add tooltip/what'sthis for the buttons!!!! (CTR)
    // Disable the "Accept" and "Reject" buttons, enable the "Close" button
@@ -512,7 +513,7 @@ namespace Isis {
   * reset the lcd displays to 0, and update the scroll on the scroll bar. This does NOT affect
   * the state of the buttons.
   */
  void JigsawDialog::clearDialog() {
  void JigsawRunWidget::clearDialog() {
    m_ui->iterationLcdNumber->display(0);
    m_ui->sigma0LcdNumber->display(0);
    m_ui->statusUpdatesLabel->clear();
@@ -523,7 +524,7 @@ namespace Isis {
  /**
   * Updates the scroll bar to position to its maximum setting (the bottom).
   */
  void JigsawDialog::updateScrollBar() {
  void JigsawRunWidget::updateScrollBar() {
    m_ui->statusUpdateScrollArea->verticalScrollBar()->setSliderPosition(
        m_ui->statusUpdateScrollArea->verticalScrollBar()->maximum());
  }
@@ -535,7 +536,7 @@ namespace Isis {
   *
   * @param status Current status of bundle.
   */
  void JigsawDialog::outputBundleStatus(QString status) {
  void JigsawRunWidget::outputBundleStatus(QString status) {
    QString updateStr = "\n" + status;

    m_ui->statusUpdatesLabel->setText( m_ui->statusUpdatesLabel->text().append(updateStr) );
@@ -551,7 +552,7 @@ namespace Isis {
   *
   * @param error Error status of bundle.
   */
  void JigsawDialog::errorString(QString error) {
  void JigsawRunWidget::errorString(QString error) {
    QString errorStr = "\n" + error;
    m_ui->statusUpdatesLabel->setText( m_ui->statusUpdatesLabel->text().append(errorStr) );

@@ -569,7 +570,7 @@ namespace Isis {
   *
   * @param error Error status of bundle.
   */
  void JigsawDialog::reportException(QString exception) {
  void JigsawRunWidget::reportException(QString exception) {
    QString exceptionStr = "\n" + exception;
    m_ui->statusUpdatesLabel->setText( m_ui->statusUpdatesLabel->text().append(exceptionStr) );

@@ -584,7 +585,7 @@ namespace Isis {
   *
   * @param error Error status of bundle.
   */
  void JigsawDialog::updateIterationSigma0(int iteration, double sigma0) {
  void JigsawRunWidget::updateIterationSigma0(int iteration, double sigma0) {
    m_ui->iterationLcdNumber->display(iteration);
    m_ui->sigma0LcdNumber->display(sigma0);

@@ -599,7 +600,7 @@ namespace Isis {
   * finishes when the bundle adjust finishes (either successfully or unsuccessfully, or if the
   * user aborts the run).
   */
  void JigsawDialog::notifyThreadFinished() {
  void JigsawRunWidget::notifyThreadFinished() {
    //QString str = "\nThread Finished signal received";
    //m_ui->statusUpdatesLabel->setText( m_ui->statusUpdatesLabel->text().append(str) );

@@ -624,7 +625,7 @@ namespace Isis {
   *
   * @param bundleSolutionInfo The results of the bundle run.
   */
  void JigsawDialog::bundleFinished(BundleSolutionInfo *bundleSolutionInfo) {
  void JigsawRunWidget::bundleFinished(BundleSolutionInfo *bundleSolutionInfo) {

    bundleSolutionInfo->setRunTime( Isis::iTime::CurrentLocalTime().toLatin1().data() );
    m_bundleSolutionInfo = bundleSolutionInfo;
Loading