Commit 895559fe authored by Cole Neubauer's avatar Cole Neubauer
Browse files

Only control nets being used will be in memory Fixes #5026

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@7968 41f8697f-d340-4b68-9986-7bafba869bb8
parent d15ef976
Loading
Loading
Loading
Loading
+64 −37
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ namespace Isis {

    m_controlNet = NULL;
    m_displayProperties = NULL;
    m_project = NULL;

    openControlNet();

@@ -40,6 +41,27 @@ namespace Isis {
  }


  /**
   * Create a Control from control net located on disk associated with a Project.
   *
   * @param cNetFileName The name of the control net on disk
   * @param parent The Qt-relationship parent
   */
  Control::Control(Project *project, QString cNetFileName, QObject *parent) : QObject(parent) {

    m_fileName = cNetFileName;

    m_controlNet = NULL;
    m_displayProperties = NULL;
    m_project = project;

    m_displayProperties
        = new ControlDisplayProperties(FileName(m_fileName).name(), this);

    m_id = new QUuid(QUuid::createUuid());
  }


  /**
   * Create a Control from a control network that has already been created and read from disk.
   *
@@ -54,6 +76,7 @@ namespace Isis {

    m_controlNet = controlNet;
    m_displayProperties = NULL;
    m_project = NULL;

    m_displayProperties
        = new ControlDisplayProperties(FileName(m_fileName).name(), this);
@@ -74,6 +97,7 @@ namespace Isis {
    m_controlNet = NULL;
    m_displayProperties = NULL;
    m_id = NULL;
    m_project = NULL;

    xmlReader->pushContentHandler(new XmlHandler(this, cnetFolder));
  }
@@ -89,6 +113,9 @@ namespace Isis {
    delete m_id;
    m_id = NULL;

    delete m_project;
    m_project = NULL;

    //  Image is a "Qt" parent of display properties, so the Image QObject
    //    destructor will take care of deleting the display props. See call to
    //    DisplayProperties' constructor.
@@ -122,6 +149,10 @@ namespace Isis {
    if (!m_controlNet) {
      try {
        m_controlNet = new ControlNet(m_fileName);
        if (m_project) {
          m_controlNet->SetMutex(m_project->mutex());
        }

      }
      catch (IException &e) {
        throw IException(e, IException::Programmer, "Error opening control net.", _FILEINFO_);
@@ -299,7 +330,6 @@ namespace Isis {

        if (!fileName.isEmpty()) {
          m_xmlHandlerControl->m_fileName = m_xmlHandlerCnetFolderName.expanded() + "/" + fileName;
          m_xmlHandlerControl->openControlNet();
        }
      }
      else if (localName == "displayProperties") {
@@ -310,6 +340,3 @@ namespace Isis {
    return true;
  }
}


+14 −8
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@
 *   http://www.usgs.gov/privacy.html.
 */
#include <QObject> // parent

#include <QString>

#include "FileName.h"
@@ -53,18 +52,25 @@ namespace Isis {
   *   @history 2015-10-14 Jeffrey Covington - Declared Control * as a Qt
   *                           metatype for use with QVariant. References #3949
   *   @history 2016-06-02 Jeannie Backer - Updated documentation. Fixes #3949
   *   @history 2017-08-02 Cole Neuabuer - Added new constructor. This constructor takes a Project
   *                           and a filename of a controlnet. This was added because the Control
   *                           object needs to assign a mutex when the control net is opened and by
   *                           doing this internally we can Close control nets and not have to
   *                           track whether this step has happened Fixes #5026
   */
  class Control : public QObject {
    Q_OBJECT
    public:
      ControlNet *m_controlNet; /**< A pointer to the ControlNet object associated with this
                                                    Control object.*/
    explicit Control(QString cnetFileName, QObject *parent = 0);
      explicit Control(Project *project, QString cnetFileName, QObject *parent = 0);
      explicit Control(ControlNet *controlNet, QString cnetFileName, QObject *parent = 0);
      Control(FileName cnetFolder, XmlStackedHandlerReader *xmlReader, QObject *parent = 0);
      ~Control();

      ControlNet *controlNet();
      void openControlNet();
      void closeControlNet();
      ControlDisplayProperties *displayProperties();
      const ControlDisplayProperties *displayProperties() const;
      QString fileName() const;
@@ -77,6 +83,7 @@ namespace Isis {

    public slots:
      void updateFileName(Project *);
      void closeControlNet();

    private:
      /**
@@ -106,10 +113,9 @@ namespace Isis {
      Control(const Control &other);
      Control &operator=(const Control &rhs);

      ControlNet *m_controlNet; /**< A pointer to the ControlNet object associated with this
                                     Control object.*/
      ControlDisplayProperties *m_displayProperties; /**< Contains the display properties for this
                                                          Control object.*/
      Project *m_project; //! Project associated with this control
      QString m_fileName; /**< File name of the control net associated with this control.*/

      /**
+6 −3
Original line number Diff line number Diff line
@@ -70,9 +70,7 @@ namespace Isis {
    *
    */
   QAction *ControlNetTool::toolPadAction(ToolPad *pad) {


     QAction *action = new QAction(pad);
     QAction *action = new QAction(this);
     action->setIcon(QPixmap(toolIconDir()+"/HILLBLU_molecola.png"));
     action->setToolTip("Control Point Editor (T)");
     action->setShortcut(Qt::Key_T);
@@ -107,6 +105,11 @@ namespace Isis {
   }


   void ControlNetTool::loadNetwork() {
     setControlNet(m_directory->project()->activeControl()->controlNet());
   }


  /**
   * Handle mouse events on CubeViewport
   *
+11 −9
Original line number Diff line number Diff line
#ifndef ControlNetTool_h
#define ControlNetTool_h
#ifndef IpceTool_h
#define IpceTool_h

#include "Tool.h"
#include "ControlPoint.h"
@@ -48,16 +48,15 @@ namespace Isis {
   *   @history 2017-08-02 Tracie Sucharski - Draw the current edit Control Point as a circle with
   *                           center crosshair in red.  Removed refresh method; it was not being
   *                           used.  Fixes #5007, #5008.
   *   @history 2017-08-03 Cole Neubauer - Changed all references from IpceTool to ControlNetTool
   *                           Fixes #5090
   *
   *   @history 2017-08-09 Cole Neubauer - Added loadNetwork() for changing inbetween active
   *                           networks Fixes #4567
   */
  class ControlNetTool : public Tool {
  class IpceTool : public Tool {
    Q_OBJECT

    public:
      ControlNetTool (Directory *directory, QWidget *parent);
      virtual ~ControlNetTool ();
      IpceTool (Directory *directory, QWidget *parent);
      virtual ~IpceTool ();

      void setControlNet(ControlNet *controlNet);
      void paintViewport (MdiCubeViewport *cvp, QPainter *painter);
@@ -68,6 +67,9 @@ namespace Isis {
      void createControlPoint(double latitude, double longitude, Cube *cube,
                              bool isGroundSource = false);

    public slots:
      void loadNetwork();

    protected:
      QAction *toolPadAction(ToolPad *pad);

@@ -82,7 +84,7 @@ namespace Isis {
      void createMenus();
      void drawAllMeasurements(MdiCubeViewport *vp, QPainter *painter);

      QPointer<MainWindow> m_ControlNetTool;
      QPointer<MainWindow> m_ipceTool;
      Directory *m_directory;
      CubeDnView *m_view;

+0 −1
Original line number Diff line number Diff line
@@ -90,7 +90,6 @@ namespace Isis {
  void CnetEditorViewWorkOrder::execute() {

    for (int i = 0; i < controlList()->size(); i++) {
      //project()->directory()->addCnetEditorView(controlList().first());
      project()->directory()->addCnetEditorView(controlList()->at(i));
    }
    project()->setClean(false);
Loading