Commit 8ce336cf authored by Ian Humphrey's avatar Ian Humphrey
Browse files

Updated ImportImagesWorkOrder according to the new WorkOrder design. Fixes #4732.

parent 7421cf58
Loading
Loading
Loading
Loading
+73 −4
Original line number Diff line number Diff line
@@ -63,6 +63,37 @@ namespace Isis {
  }


  /**
   * @brief Indicates that this work order is an asynchronous work order.
   *
   * @description Indicates that ImportImagesWorkOrder is not a synchronous work order; i.e.,
   *              it is asynchronous.
   *
   * @see WorkOrder::isSynchronous()
   *
   * @return Returns false, as this is an asynchronous work order.
   *
   */
  bool ImportImagesWorkOrder::isSynchronous() const {
    return false;
  }


  /**
   * @brief Sets up this work order before being executed.
   *
   * @description First invokes WorkOrder's setupExecution(). Prompts the user for cubes and image
   * list files to import and stores them via a setInternalData() call. If there are more than 100
   * images to import, the user is prompted if they want to save their project before the import
   * occurs. If yes, a SaveProjectWorkOrder will be executed. This setup is considered successful
   * if the user does not hit cancel on a dialog prompt and if there is at least one image has been
   * selected by the user to import. This method was renamed from execute() to setupExecution()
   * according to the WorkOrder redesign.
   *
   * @see WorkOrder::setupExecution()
   *
   * @return bool Returns true if the setup was successful.
   */
  bool ImportImagesWorkOrder::setupExecution() {
    WorkOrder::setupExecution();

@@ -134,13 +165,31 @@ namespace Isis {
  }


  void ImportImagesWorkOrder::asyncUndo() {
  /**
   * @brief Undoes the work order's execute.
   *
   * @description After this ImportImagesWorkOrder has executed and finished (all the images have
   * been read), this removes the images from this import from disk in the project's directory.
   * This was renamed from asyncUndo() to undoExecution() according to the WorkOrder redesign.
   *
   * @see WorkOrder::undoExecution()
   */
  void ImportImagesWorkOrder::undoExecution() {
    project()->waitForImageReaderFinished();
    project()->images().last()->deleteFromDisk(project());
  }


  void ImportImagesWorkOrder::postSyncUndo() {
  /**
   * @brief Cleans up memory (images) after the undo execution occurs.
   *
   * @description After the undoExecution() occurs, this cleans up memory that was allocated for
   * the images from this import. This was renamed from postSyncUndo() to postUndoExecution()
   * according to the WorkOrder redesign.
   *
   * @see WorkOrder::postUndoExecution()
   */
  void ImportImagesWorkOrder::postUndoExecution() {
    QPointer<ImageList> imagesWeAdded = project()->images().last();

    foreach (Image *image, *imagesWeAdded) {
@@ -150,14 +199,34 @@ namespace Isis {
  }


  void ImportImagesWorkOrder::asyncRedo() {
  /**
   * @brief Executes the work order.
   *
   * @description This actually "does" the work order task. In this case, this imports the images
   * into memory and copies any necessary data to disk. This was renamed from asyncRedo() to
   * execute() according to the WorkOrder redesign.
   *
   * @see ImportImagesWorkOrder::importConfirmedImages(QStringList confirmedImages, bool copyDnData)
   * @see WorkOrder::execute()
   */
  void ImportImagesWorkOrder::execute() {
    if (internalData().count() > 0) {
      importConfirmedImages(internalData().mid(1), (internalData()[0] == "copy"));
    }
  }


  void ImportImagesWorkOrder::postSyncRedo() {
  /**
   * @brief Associates the imported images to the project.
   *
   * @description After execute finishes, associates the imported images to the project. This will
   * also notifies the project if there are any warnings that occurred related to the import. This
   * was renamed from postSyncRedo() to postExecution() according to the WorkOrder redesign.
   *
   * @see Project::addImages(Imagelist newImages)
   * @see WorkOrder::postExecution()
   */
  void ImportImagesWorkOrder::postExecution() {
    if (!m_newImages->isEmpty()) {
      project()->addImages(*m_newImages);

+12 −5
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ namespace Isis {
  /**
   * @brief Add cubes to a project
   *
   * Asks the user for a list of cube file names and whether they should be copied into
   * @description Asks the user for a list of cube file names and whether they should be copied into
   * the project. The cubes are then converted to external cube label files inside the project (and
   * cube files if the user said to copy the DN data). These files are then handed off to the
   * project.
@@ -57,6 +57,11 @@ namespace Isis {
   *                           images are freed from memory undo/redo correctly.
   *   @history 2012-10-29 Steven Lambright - Added a prompt to save the project if importing a lot
   *                           of images to a temporary project.
   *   @history 2017-04-05 Ian Humphrey and Makayla Shepherd - Renamed the following: execute() to
   *                           setupExeuction(), asyncRedo() to execute(), syncUndo() to
   *                           undoExecution(), postSyncRedo() to postExecution(), and
   *                           postSyncUndo() to postUndoExecution(). Added isSynchronous(). This is
   *                           related to the WorkOrder redesign. Fixes #4732.
   */
  class ImportImagesWorkOrder : public WorkOrder {
      Q_OBJECT
@@ -67,12 +72,14 @@ namespace Isis {

      virtual ImportImagesWorkOrder *clone() const;

      bool isSynchronous() const;

      bool setupExecution();

      void asyncRedo();
      void postSyncRedo();
      void asyncUndo();
      void postSyncUndo();
      void execute();
      void undoExecution();
      void postExecution();
      void postUndoExecution();

    private:
      ImportImagesWorkOrder &operator=(const ImportImagesWorkOrder &rhs);