Commit 3d3b33e3 authored by Tracie Sucharski's avatar Tracie Sucharski
Browse files

Changed WorkOrder::isUndoable and WorkOrder::isSynchronous to virtual.

parent d0f272bc
Loading
Loading
Loading
Loading
+47 −11
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ namespace Isis {
    m_watcher = NULL;

    QAction::setText(tr("Import &Control Networks..."));
    QUndoCommand::setText(tr("Import Control Networks"));

    setModifiesDiskState(true);

@@ -71,8 +70,33 @@ namespace Isis {
    return new ImportControlNetWorkOrder(*this);
  }

  /**
   * @brief Returns if the WorkOrder is synchronous
   * 
   * @description This method overrides WorkOrder's isSynchronous. This will return false as this 
   * WorkOrder is asynchronous.
   * 
   * @see WorkOrder::isSynchronous()
   * 
   * @return bool Returns false because this WorkOrder is asynchronous.
   */
  bool ImportControlNetWorkOrder::isSynchronous() const {
    return false;
  }
  
  /**
   * @brief Sets up the work order for execution.
   * 
   * @description This method prompts the user for a control net to open. That control net is then
   * saved using setInternalData data. This method was renamed from execute() to setupExecution()
   * 
   * @see WorkOrder::setupExecution()
   * 
   * @return bool Returns a boolean. This boolean is true if the internal data was set correctly.
   */
  bool ImportControlNetWorkOrder::setupExecution() {
    QUndoCommand::setText(tr("Import Control Networks"));
    
    WorkOrder::setupExecution();

    QStringList cnetFileNames = QFileDialog::getOpenFileNames(
@@ -89,8 +113,13 @@ namespace Isis {
    return internalData().count() > 0;
  }


  void ImportControlNetWorkOrder::syncRedo() {
  /**
   * @brief Imports the control network asynchronously.
   * 
   * @description This method asynchronously imports the control net. This method replaces both
   * syncRedo() and asyncRedo().
   */
  void ImportControlNetWorkOrder::execute() {

    QDir cnetFolder = project()->addCnetFolder("controlNetworks");

@@ -106,10 +135,7 @@ namespace Isis {

    m_watcher->setFuture(QtConcurrent::mapped(cnetFileNamesAndProgress,
                                              CreateControlsFunctor(project(), cnetFolder)));
  }


  void ImportControlNetWorkOrder::asyncRedo() {
    while (!m_watcher->isFinished()) {
      setProgressRange(0, 100 * m_readProgresses.count());
      int totalProgress = 0;
@@ -133,8 +159,13 @@ namespace Isis {
    }
  }


  void ImportControlNetWorkOrder::postSyncRedo() {
  /**
   * @brief Clears progress.
   * 
   * @description This method clears the progresses created in execute(). This method was renamed 
   * from postSyncRedo() to postExecution().
   */
  void ImportControlNetWorkOrder::postExecution() {

    foreach (Progress *progress, m_readProgresses) {
      delete progress;
@@ -142,8 +173,13 @@ namespace Isis {
    m_readProgresses.clear();
  }


  void ImportControlNetWorkOrder::syncUndo() {
  /**
   * @brief Deletes the control network
   * 
   * @description This method deletes the control network from the project. This method is was 
   * renamed from undoSyncRedo() to undoExecution().
   */
  void ImportControlNetWorkOrder::undoExecution() {
    if (m_watcher->isFinished()) {
      ControlList *list = project()->controls().last();
      list->deleteFromDisk(project());
+9 −4
Original line number Diff line number Diff line
@@ -43,6 +43,10 @@ namespace Isis {
   * @internal 
   *   @history 2012-09-11 Tracie Sucharski and Steven Lambright - Added asynchronous functionality
   *                           for redo.
   *   @history 2017-04-04 Makayla Shepherd - Combined syncRedo and asyncRedo into execute, changed
   *                           execute to setupExecution, and renamed postSyncRedo to postExecution
   *                           and undoSyncRedo to undoExecution. This was done to match the 
   *                           WorkOrder redesign. Fixes #4716.
   */
  class ImportControlNetWorkOrder : public WorkOrder {
      Q_OBJECT
@@ -53,13 +57,14 @@ namespace Isis {

      virtual ImportControlNetWorkOrder *clone() const;

      virtual bool isSynchronous() const;
      
      bool setupExecution();
      void execute();

    protected:
      void syncRedo();
      void asyncRedo();
      void postSyncRedo();
      void syncUndo();
      void undoExecution();
      void postExecution();

    private slots:
      void cnetReady(int ready);
+46 −14
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ namespace Isis {

    QAction::setText(tr("Set Active Control Network") );
    QUndoCommand::setText(tr("Set Active Control Network"));

  }


@@ -85,32 +86,63 @@ namespace Isis {


  /**
   * @brief Attempt to set control as active control.
   * @return @b bool True if successful, False otherwise.
   * @brief Indicates whether this work order is undoable. 
   * 
   * @return bool Returns false indicating that setting the active control net is not undoable.
   */
  bool SetActiveControlWorkOrder::setupExecution() {
    bool success = WorkOrder::setupExecution();
  bool SetActiveControlWorkOrder::isUndoable() const {

    if (success) {
    return false;
  }

      if (project()->activeImageList()) {
        project()->setActiveControl(controlList()->at(0)->displayProperties()->displayName());

        QUndoCommand::setText(tr("Set Active Control Network to [%1]").arg(
                                 controlList()->at(0)->displayProperties()->displayName()));
        success = true;
  /**
   * @brief Indicates that setting the active control net is a synchronous process
   * 
   * @return bool Returns true indicating that setting the active control net is syncronous.
   */
  bool SetActiveControlWorkOrder::isSynchronous() const {

    return true;
  }
      else {


  /**
   * @desc Make sure an active ImageList has been chosen. 
   *  
   * @return @b bool True if project has an active ImageList, False otherwise.
   */
  bool SetActiveControlWorkOrder::setupExecution() {

    bool success = WorkOrder::setupExecution();
    if (success) {
      if (!project()->activeImageList()) {

        QMessageBox::critical(NULL, tr("Unable to set active control."), 
                              tr("You must first choose an active Image List before setting "
                              "the active control net."));
        success = false;
      }
//    internalData.append(activeControl()->displayProperties()->displayName());
//    setInternalData(internalData);
      //  So far, so good, set the command text
      else {
        QUndoCommand::setText(tr("Set Active Control Network to [%1]").arg(
                                 controlList()->at(0)->displayProperties()->displayName()));
      }
    }

    return success;
  }


  /**
   * @desc  Set the active control net for the project.  This allows any views to operate on the 
   *        same control net.  The active image list must be set before the active control net is
   *        chosen.  If not, a critical message dialog is displayed and we return false.
   * 
   */
  void SetActiveControlWorkOrder::execute() {

    project()->setActiveControl(controlList()->at(0)->displayProperties()->displayName());
  }
}
+5 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ namespace Isis {
   * @history 2017-01-09 Tracie Sucharski - Moved the SetImages step to the 
   *                         Project::setActiveControl.
   * @history 2017-01-30 Tracie Sucharski - Print active control in the Undo text. 
   *
   *          2017-04-04 Tracie Sucharski - Updated to reflect the new WorkOrder design.
   */

  class SetActiveControlWorkOrder : public WorkOrder {
@@ -51,7 +51,11 @@ namespace Isis {
      virtual SetActiveControlWorkOrder *clone() const;

      virtual bool isExecutable(ControlList *controls);
      virtual bool isUndoable() const;
      virtual bool isSynchronous() const;

      bool setupExecution();
      void execute();

    private:
      SetActiveControlWorkOrder &operator=(const SetActiveControlWorkOrder &rhs);
+1 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ namespace Isis {
    newItem->setData(0, Qt::UserRole, qVariantFromValue(workOrder));

    // Do font for save work orders or work orders not on QUndoStack
    if (workOrder->createsCleanState() || !workOrder->onUndoStack()) {
    if (workOrder->createsCleanState() || !workOrder->isUndoable()) {
      QFont saveFont = newItem->font(0);
      saveFont.setBold(true);
      saveFont.setItalic(true);
Loading