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

Merge pull request #104 from TracieSucharski/ipce

Ipce - Updates to BundleSolutionInfo to save input and output control; Use work order to set default active imageList and control; prefix bundle adjusted control with "Out-".
parents 313785e9 481026d3
Loading
Loading
Loading
Loading
+107 −26
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include <QXmlStreamWriter>

#include "BundleResults.h"
#include "ControlList.h"
#include "ControlMeasure.h"
#include "ControlNet.h"
#include "ControlPoint.h"
@@ -44,7 +45,9 @@ namespace Isis {

    m_name = m_runTime;

    m_controlNetworkFileName = new FileName(controlNetworkFileName);
    m_inputControlNetFileName = new FileName(controlNetworkFileName);

    m_outputControlNetFileName = new FileName();

    m_settings = inputSettings;

@@ -70,7 +73,8 @@ namespace Isis {
    m_id = new QUuid(QUuid::createUuid());
    m_runTime = "";
    m_name = m_runTime;
    m_controlNetworkFileName = NULL;
    m_inputControlNetFileName = NULL;
    m_outputControlNetFileName = NULL;
    m_statisticsResults = NULL;
    // what about the rest of the member data ? should we set defaults ??? CREATE INITIALIZE METHOD
    m_images = new QList<ImageList *>;
@@ -90,7 +94,8 @@ namespace Isis {
      : m_id(new QUuid(QUuid::createUuid())),
        m_name(src.m_name),
        m_runTime(src.m_runTime),
        m_controlNetworkFileName(new FileName(src.m_controlNetworkFileName->expanded())),
        m_inputControlNetFileName(new FileName(src.m_inputControlNetFileName->expanded())),
        m_outputControlNetFileName(new FileName(src.m_outputControlNetFileName->expanded())),
        m_settings(new BundleSettings(*src.m_settings)),
        m_statisticsResults(new BundleResults(*src.m_statisticsResults)),
        m_images(new QList<ImageList *>(*src.m_images)),
@@ -107,8 +112,11 @@ namespace Isis {
  BundleSolutionInfo::~BundleSolutionInfo() {
    delete m_id;

    delete m_controlNetworkFileName;
    m_controlNetworkFileName = NULL;
    delete m_inputControlNetFileName;
    m_inputControlNetFileName = NULL;

    delete m_outputControlNetFileName;
    m_outputControlNetFileName = NULL;

    delete m_statisticsResults;
    m_statisticsResults = NULL;
@@ -150,8 +158,11 @@ namespace Isis {
        m_name = src.m_name;
      }

      delete m_controlNetworkFileName;
      m_controlNetworkFileName = new FileName(src.m_controlNetworkFileName->expanded());
      delete m_inputControlNetFileName;
      m_inputControlNetFileName = new FileName(src.m_inputControlNetFileName->expanded());

      delete m_outputControlNetFileName;
      m_outputControlNetFileName = new FileName(src.m_outputControlNetFileName->expanded());

      m_settings = src.m_settings;

@@ -167,14 +178,32 @@ namespace Isis {
    return *this;
  }


  /**
   * Returns filename of output bundle images csv file.
   *
   * @return QString filename of output bundle images csv file.
   */
  QString BundleSolutionInfo::savedImagesFilename() {
    return m_csvSavedImagesFilename;
  }


  /**
   * Returns filename of output bundle points csv file.
   *
   * @return QString filename of output bundle points csv file.
   */
  QString BundleSolutionInfo::savedPointsFilename() {
    return m_csvSavedPointsFilename;
  }


  /**
   * Returns filename of output bundle residuals csv file.
   *
   * @return QString filename of output bundle residuals csv file.
   */
  QString BundleSolutionInfo::savedResidualsFilename() {
    return m_csvSavedResidualsFilename;
  }
@@ -216,10 +245,15 @@ namespace Isis {

    //TODO do we need to close anything here?

    FileName oldFileName(*m_controlNetworkFileName);
    FileName newName(project->cnetRoot() + "/" +
                     oldFileName.dir().dirName() + "/" + oldFileName.name());
    *m_controlNetworkFileName = newName.expanded();
    FileName oldInputFileName(*m_inputControlNetFileName);
    FileName newInputFileName(project->cnetRoot() + "/" +
                     oldInputFileName.dir().dirName() + "/" + oldInputFileName.name());
    *m_inputControlNetFileName = newInputFileName.expanded();

    FileName oldOutputFileName(*m_outputControlNetFileName);
    FileName newOutputFileName(project->cnetRoot() + "/" +
                     oldOutputFileName.dir().dirName() + "/" + oldOutputFileName.name());
    *m_outputControlNetFileName = newOutputFileName.expanded();
  }


@@ -244,6 +278,16 @@ namespace Isis {
  }


  /**
   * Sets the output control network filename.
   *
   * @param fileName The the output control network filename..
   */
  void BundleSolutionInfo::setOutputControlNetworkFileName(FileName fileName) {
    *m_outputControlNetFileName = fileName;
  }


  /**
   * Sets the run time, and the name if a name is not already set.
   *
@@ -277,12 +321,22 @@ namespace Isis {


  /**
   * Returns the name of the control network.
   * Returns the name of the input control network.
   *
   * @return @b QString The name of the input control network.
   */
  QString BundleSolutionInfo::inputControlNetFileName() const {
    return m_inputControlNetFileName->expanded();
  }


  /**
   * Returns the name of the output control network.
   *
   * @return @b QString The name of the control network.
   * @return @b QString The name of the output control network.
   */
  QString BundleSolutionInfo::controlNetworkFileName() const {
    return m_controlNetworkFileName->expanded();
  QString BundleSolutionInfo::outputControlNetFileName() const {
    return m_outputControlNetFileName->expanded();
  }


@@ -538,7 +592,7 @@ namespace Isis {
                  Isis::iTime::CurrentLocalTime().toLatin1().data());
    fpOut << buf;
    sprintf(buf, "\n               Network Filename: %s",
                  m_controlNetworkFileName->expanded().toLatin1().data());
                  m_inputControlNetFileName->expanded().toLatin1().data());
    fpOut << buf;
    sprintf(buf, "\n                     Network Id: %s",
                  m_statisticsResults->outputControlNet()->GetNetworkId().toLatin1().data());
@@ -1502,6 +1556,7 @@ namespace Isis {
  void BundleSolutionInfo::save(QXmlStreamWriter &stream, const Project *project,
                                FileName newProjectRoot) const {

    // TODO: comment below not clear, why is this done?
    // This is done for unitTest which has no Project
    QString relativeBundlePath;
    FileName bundleSolutionInfoRoot;
@@ -1521,13 +1576,20 @@ namespace Isis {
                             .arg(bundleSolutionInfoRoot.path()),
                           _FILEINFO_);
        }
        QString oldFile = oldPath + "/" + m_controlNetworkFileName->name();
        QString newFile = newPath + "/" + m_controlNetworkFileName->name();
        //QString outputControlFile = m_statisticsResults->outputControlNet()->
        QString oldFile = oldPath + "/" + m_inputControlNetFileName->name();
        QString newFile = newPath + "/" + m_inputControlNetFileName->name();
        if (!QFile::copy(oldFile, newFile)) {
          throw IException(IException::Io,
                           QString("Failed to copy file [%1] to new file [%2]")
                             .arg(m_inputControlNetFileName->name()).arg(newFile),
                           _FILEINFO_);
        }
        oldFile = oldPath + "/" + m_outputControlNetFileName->name();
        newFile = newPath + "/" + m_outputControlNetFileName->name();
        if (!QFile::copy(oldFile, newFile)) {
          throw IException(IException::Io,
                           QString("Failed to copy file [%1] to new file [%2]")
                             .arg(m_controlNetworkFileName->name()).arg(newFile),
                             .arg(m_outputControlNetFileName->name()).arg(newFile),
                           _FILEINFO_);
        }
        newFile = newPath + "/" + FileName(m_csvSavedImagesFilename).name();
@@ -1562,14 +1624,28 @@ namespace Isis {
      relativeBundlePath += "/";
    }

    // TODO: so, we can do the stuff below if project is NULL?

    stream.writeStartElement("bundleSolutionInfo");
    // save ID, cnet file name, and run time to stream
    stream.writeStartElement("generalAttributes");
    stream.writeTextElement("id", m_id->toString());
    stream.writeTextElement("name", m_name);
    stream.writeTextElement("runTime", runTime());
    stream.writeTextElement("fileName",
                            relativeBundlePath + m_controlNetworkFileName->name());
//    stream.writeTextElement("inputFileName",
//                            relativeBundlePath + m_inputControlNetFileName->name());

    QString relativePath = m_inputControlNetFileName->expanded().remove(project->newProjectRoot());
    // Get rid of any preceding "/" , but add on ending "/"
    if (relativePath.startsWith("/")) {
      relativePath.remove(0,1);
    }

    stream.writeTextElement("inputFileName",
                            relativePath);

    stream.writeTextElement("outputFileName",
                            relativeBundlePath + m_outputControlNetFileName->name());
    stream.writeTextElement("imagesCSV",
                            relativeBundlePath + FileName(m_csvSavedImagesFilename).name());
    stream.writeTextElement("pointsCSV",
@@ -1699,9 +1775,14 @@ namespace Isis {
    else if (localName == "runTime") {
      m_xmlHandlerBundleSolutionInfo->m_runTime = m_xmlHandlerCharacters;
    }
    else if (localName == "fileName") {
      assert(m_xmlHandlerBundleSolutionInfo->m_controlNetworkFileName == NULL);
      m_xmlHandlerBundleSolutionInfo->m_controlNetworkFileName = new FileName(
    else if (localName == "inputFileName") {
      assert(m_xmlHandlerBundleSolutionInfo->m_inputControlNetFileName == NULL);
      m_xmlHandlerBundleSolutionInfo->m_inputControlNetFileName = new FileName(
        projectRoot + m_xmlHandlerCharacters);
    }
    else if (localName == "outputFileName") {
      assert(m_xmlHandlerBundleSolutionInfo->m_outputControlNetFileName == NULL);
      m_xmlHandlerBundleSolutionInfo->m_outputControlNetFileName = new FileName(
        projectRoot + m_xmlHandlerCharacters);
    }
    else if (localName == "imagesCSV") {
+16 −10
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ class QXmlStreamWriter;

namespace Isis {
  class BundleResults;
  class Control;
  class FileName;
  class ImageList;
  class Project;  //TODO does xml stuff need project???
@@ -119,6 +120,8 @@ namespace Isis {
   *   @history 2018-01-17 Tracie Sucharski - Added conditional code to check for null project in
   *                           xml serialization to allow the unitTest to use xml serialization
   *                           without having a project. References #5104.
   *   @history 2018-03-15 Ken Edmundson - Save input and output control and added methods to return
   *                           input control and output control.  Update documentation.
   */
  class BundleSolutionInfo : public QObject {
    Q_OBJECT
@@ -141,12 +144,14 @@ namespace Isis {

      void addAdjustedImages(ImageList *images);
      void setOutputStatistics(BundleResults statisticsResults);
      void setOutputControlNetworkFileName(FileName fileName);
      void setRunTime(QString runTime);
      void setName(QString name);

      QList<ImageList *> adjustedImages() const;
      QString id() const;
      QString controlNetworkFileName() const;
      QString inputControlNetFileName() const;
      QString outputControlNetFileName() const;
      BundleSettingsQsp bundleSettings();
      BundleResults bundleResults();
      QList<ImageList *> imageList();
@@ -203,15 +208,16 @@ namespace Isis {
      //! A unique ID for this BundleSolutionInfo object (useful for others to reference this
      //! object when saving to disk).
      QUuid              *m_id;
      QString             m_name; //!< The name of the bundle. Defaults to the id
      QString             m_runTime; //!< The run time of the bundle adjust
      FileName           *m_controlNetworkFileName; //!< The name of the control network
      BundleSettingsQsp   m_settings; //!< The settings from the bundle adjust
      BundleResults      *m_statisticsResults; //!< The results of the bundle adjust
      QList<ImageList *> *m_images; //!< The list of images as input to the bundle
      QList<ImageList *> *m_adjustedImages; //!< The list of images that were adjsuted

      // In theory the path in the BundlesSettings can change while running.  So we save the
      QString             m_name;                        //!< Name of the bundle. Defaults to the id
      QString             m_runTime;                     //!< Run time of the bundle adjustment
      FileName           *m_inputControlNetFileName;     //!< Input control network name
      FileName           *m_outputControlNetFileName;    //!< Output control network name
      BundleSettingsQsp   m_settings;                    //!< Bundle settings
      BundleResults      *m_statisticsResults;           //!< Bundle statistical results
      QList<ImageList *> *m_images;                      //!< Input image list
      QList<ImageList *> *m_adjustedImages;              //!< Adjusted image list

      // In theory the path in the BundleSettings can change while running. So we save the
      // filenames actually used when the most recent save of the file was done.
      QString m_csvSavedImagesFilename;
      QString m_csvSavedPointsFilename;
+4 −4
Original line number Diff line number Diff line
@@ -35,9 +35,9 @@ using namespace std;

namespace Isis {
  /**
   * Ipce (Qnet) tool - Handles mouse button actions and drawing control points on viewports
   * ControlNet (Qnet) tool - Handles mouse button actions and drawing control points on viewports
   *
   * @param parent Pointer to the parent widget for the Ipce tool
   * @param parent Pointer to the parent widget for the ControlNet tool
   *
   * @author 2016-09-01 Tracie Sucharski
   *
@@ -56,10 +56,10 @@ namespace Isis {


  /**
    * Adds the Ipce tool action to the tool pad.
    * Adds the ControlNet tool action to the tool pad.
    *
    * @param pad Tool pad
    * @return @b QAction* Pointer to Tie tool action
    * @return @b QAction* Pointer to ControlNet tool action
    *
    * @internal
    *   @history 2017-07-25 Tyler Wilson - Set the
+4 −2
Original line number Diff line number Diff line
@@ -29,8 +29,8 @@ namespace Isis {
  class UniversalGroundMap;

  /**
   * @brief ControlNetTool operations ipce, handles mouse events on views for control point editing 
   *        for the ipce app.
   * @brief ControlNetTool Handles mouse events on CubeDnViews for control point editing for the 
   *        ipce app.
   *
   * @ingroup Visualization Tools
   *
@@ -52,6 +52,8 @@ namespace Isis {
   *   @history 2017-08-08 Cole Neubauer - Renamed from IpceTool.  Fixes #5090. 
   *   @history 2017-08-09 Cole Neubauer - Added loadNetwork() for changing inbetween active
   *                           networks Fixes #4567
   *   @history 2018-03-12 Tracie Sucharski - Fixed some documentation leftover from renaming from
   *                           IpceTool.  References #5090.
   */
  class ControlNetTool : public Tool {
    Q_OBJECT
+5 −4
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@
#include "ControlDisplayProperties.h"
#include "ControlList.h"
#include "ControlNet.h"
#include "ControlNetTool.h"
#include "ControlPointEditView.h"
#include "ControlPointEditWidget.h"
#include "CubeDnView.h"
@@ -740,13 +741,13 @@ namespace Isis {
    if (!project()->activeControl()) {
      QList<QAction *> toolbar = result->toolPadActions();
      QAction* cnetAction = toolbar[0];
      MosaicControlNetTool *cnetButton = static_cast<MosaicControlNetTool *>(cnetAction->parent());
      ControlNetTool *cnetTool = static_cast<ControlNetTool *>(cnetAction->parent());

      cnetAction->setEnabled(false);
      connect (project(), SIGNAL(activeControlSet(bool)),
              cnetAction, SLOT(setEnabled(bool)));
      connect (project(), SIGNAL(activeControlSet(bool)),
              cnetButton, SLOT(loadNetwork()));
              cnetTool, SLOT(loadNetwork()));
    }

    return result;
Loading