Unverified Commit c7013cd1 authored by kledmundson's avatar kledmundson Committed by GitHub
Browse files

Merge pull request #191 from chrisryancombs/ipceBundleWindow

Changed JigsawDialog to JigsawRunWidget to become dockable. Fixes #5428.
parents d188bb2b 5c6e81b8
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@
#include "FileName.h"
#include "IException.h"
#include "IString.h"
#include "JigsawRunWidget.h"
#include "MosaicSceneWidget.h"
#include "ProgressWidget.h"
#include "Project.h"
@@ -216,7 +217,8 @@ namespace Isis {
  void IpceMainWindow::addView(QWidget *newWidget) {
    if ( qobject_cast<SensorInfoWidget *>(newWidget) ||
         qobject_cast<TargetInfoWidget *>(newWidget) ||
         qobject_cast<TemplateEditorWidget *>(newWidget)) {
         qobject_cast<TemplateEditorWidget *>(newWidget)||
         qobject_cast<JigsawRunWidget *>(newWidget)) {
      QDockWidget *dock = new QDockWidget( newWidget->windowTitle() );
      dock->setAttribute(Qt::WA_DeleteOnClose, true);
      dock->setWidget(newWidget);
+2 −0
Original line number Diff line number Diff line
@@ -129,6 +129,8 @@ namespace Isis {
   *                           test to determine whether project needs saving.
   *   @history 2018-05-01 Tracie Sucharski - Code accidently left commented from previous checking.
   *                           Fixes #5412.
   *   @history 2018-05-31 Christopher Combs - Added support for JigsawRunWidget to be created as a 
   *                           dockable widget in addView(). Fixes #5428.
   *  
   */
  class IpceMainWindow : public QMainWindow {
+35 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@
#include "ImportImagesWorkOrder.h"
#include "ImportShapesWorkOrder.h"
#include "ImportTemplateWorkOrder.h"
#include "JigsawRunWidget.h"
#include "JigsawWorkOrder.h"
#include "MatrixSceneWidget.h"
#include "MatrixViewWorkOrder.h"
@@ -299,6 +300,7 @@ namespace Isis {
    m_sensorInfoWidgets.clear();
    m_targetInfoWidgets.clear();
    m_templateEditorWidgets.clear();
    m_jigsawRunWidget.clear();

    m_projectItemModel->clean();
    emit directoryCleaned();
@@ -933,6 +935,23 @@ namespace Isis {
    return result;
  }

  JigsawRunWidget *Directory::addJigsawRunWidget() {
    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;
  }


  /**
   * @brief Add sensor data view widget to the window.
@@ -1195,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.
@@ -1342,6 +1370,13 @@ namespace Isis {
    return m_controlPointEditViewWidget;
  }


  JigsawRunWidget *Directory::jigsawRunWidget() {

    return m_jigsawRunWidget;
  }


/*
  ChipViewportsWidget *Directory::controlPointChipViewports() {

+9 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ namespace Isis {
  class Footprint2DView;
  class HistoryTreeWidget;
  class ImageFileListWidget;
  class JigsawRunWidget;
  class MatrixSceneWidget;
  class MosaicSceneWidget;
  class Project;
@@ -236,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
@@ -253,6 +257,7 @@ namespace Isis {
      CnetEditorView *addCnetEditorView(Control *control);
      CubeDnView *addCubeDnView();
      Footprint2DView *addFootprint2DView();
      JigsawRunWidget *addJigsawView();
      MatrixSceneWidget *addMatrixView();
      TargetInfoWidget *addTargetInfoView(TargetBodyQsp target);
      TemplateEditorWidget *addTemplateEditorView(Template *currentTemplate);
@@ -289,6 +294,7 @@ namespace Isis {
      QList<ImageFileListWidget *> imageFileListViews();
      QList<QProgressBar *> progressBars();
      ControlPointEditView *controlPointEditView();
      JigsawRunWidget *jigsawRunWidget();
//      ChipViewportsWidget *controlPointChipViewports();

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

@@ -448,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 −63
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,55 +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) {

      QStringList internalData;

      // 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()) {
          internalData.append(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;
        }
        // set output control network file name
        if (!setup.outputControlName().isEmpty()) {
          internalData.append(setup.outputControlName());
        }
        else {
          QString msg = "You must set an output control network filename.";
          QMessageBox::critical(qobject_cast<QWidget *>(parent()), "Error", msg);
          success = false;
        }
      }
      else {
        success = false;
      }
      setInternalData(internalData);
    }

    return success;
    // Is this code ever run?
    return (project()->controls().size() > 0 && 
            project()->images().size() > 0 &&
            !project()->directory()->jigsawRunWidget());
  }


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

    Project *proj = project();

    // Get the selected control and bundle settings and give them to the JigsawDialog for now.
    Control *selectedControl = proj->control(internalData().first());

    QString outputControlFileName = internalData().at(1);

    JigsawDialog *runDialog = new JigsawDialog(project(), m_bundleSettings, selectedControl,
                                               outputControlFileName);
    runDialog->setAttribute(Qt::WA_DeleteOnClose);
    runDialog->show();
    if (!runDialog) {
      QString msg = "Unable to open Jigsaw Run Widget";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }
  }
}
Loading