Commit c88fe468 authored by Jeannie Backer's avatar Jeannie Backer
Browse files

Updated documentation on qisis Control class. Declared Control pointer as Qt...

Updated documentation on qisis Control class. Declared Control pointer as Qt metatype for use with QVariant. Fixes #3949.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@6750 41f8697f-d340-4b68-9986-7bafba869bb8
parent 15001c4b
Loading
Loading
Loading
Loading
+89 −19
Original line number Diff line number Diff line
@@ -3,16 +3,18 @@
#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include <QMutex>
#include <QString>
#include <QUuid>
#include <QXmlStreamWriter>

#include "ControlNet.h"
#include "ControlDisplayProperties.h"
#include "ControlNet.h"
#include "FileName.h"
#include "IString.h"
#include "IException.h"
#include "IString.h"
#include "Project.h"
#include "PvlObject.h"
#include "XmlStackedHandlerReader.h"

namespace Isis {
@@ -61,9 +63,9 @@ namespace Isis {


  /**
   * Construct this control from XML.  TODO:  Is this for reading saved project?
   * Construct this control from XML.
   *  
   * @param cnetFolder Location of control xml - /work/.../projectRoot/cnets/controlNetwork1 
   * @param cnetFolder Location of control xml
   * @param xmlReader An XML reader that's up to an <control/> tag.  
   * @param parent The Qt-relationship parent
   */
@@ -77,6 +79,9 @@ namespace Isis {
  }


  /**
   * Destroys Control object.
   */
  Control::~Control() {
    delete m_controlNet;
    m_controlNet = NULL;
@@ -91,6 +96,13 @@ namespace Isis {
  }


  /**
   * Open and return a pointer to the ControlNet for this Control. 
   *  
   * @see openControlNet() 
   * @return @b ControlNet* Pointer to the ControlNet object associated with 
   *         this Control.
   */
  ControlNet *Control::controlNet() {
    if (!m_controlNet) {
      openControlNet();
@@ -98,9 +110,13 @@ namespace Isis {

    return m_controlNet;
  }


  /**
   * Get the ControlNet * associated with this display property. This will
   *   allocate the ControlNet * if one is not already present.
   * Sets the ControlNet from the control net file name provided in the 
   * constructor. 
   *  
   * @throws IException::Programmer  "Error opening control net."
   */
  void Control::openControlNet() {
    if (!m_controlNet) {
@@ -115,9 +131,9 @@ namespace Isis {


  /**
   * Cleans up the ControlNet *. You want to call this once you're sure you are
   *   done with the ControlNet because the OS will limit how many of these we
    *  have open.
   * Cleans up the ControlNet pointer. This method should be called
   * once there is no more need for this network because the OS will limit 
   * how many of these can be open. 
   */  
  void Control::closeControlNet() {
    if (m_controlNet) {
@@ -127,28 +143,53 @@ namespace Isis {
  }


  /**
   * Access a pointer to the display properties for the control network.
   * 
   * @return @b ControlDisplayProperties * A pointer to the display properties.
   */
  ControlDisplayProperties *Control::displayProperties() {
    return m_displayProperties;
  }


  /**
   * Access a const pointer to the display properties for the control network.
   * 
   * @return @b ControlDisplayProperties * A pointer to the display properties.
   */
  const ControlDisplayProperties *Control::displayProperties() const {

    return m_displayProperties;

  }


  /**
   * Access the name of the control network file associated with this Control.
   * 
   * @return @b QString The file name of the control network.
   */
  QString Control::fileName() const {
    return m_fileName;
  }


  /**
   * Access the unique ID associated with this Control.
   * 
   * @return @b QString The Control ID.
   */
  QString Control::id() const {
    return m_id->toString().remove(QRegExp("[{}]"));
  }


  /**
   * Copies the files of the given Project to the given location. 
   *  
   * @param project A pointer to the Project.
   * @param newProjectRoot The name of the new root directory where the project 
   *                       will be copied.
   */
  void Control::copyToNewProjectRoot(const Project *project, FileName newProjectRoot) {
    if (FileName(newProjectRoot) != FileName(project->projectRoot())) {

@@ -163,6 +204,8 @@ namespace Isis {
  /**
   * Delete the control net from disk. The control net will no longer be accessible until you call
   * updateFileName(). 
   *  
   * @throws IException::Io  "Could not remove file."
   */
  void Control::deleteFromDisk() {

@@ -194,6 +237,14 @@ namespace Isis {
  }


  /**
   * Method to write this Control object's member data to an XML stream. 
   *  
   * @param stream The stream to which the Control will be saved.
   * @param project The Project to which this Control will be added.
   * @param newProjectRoot The location of the project root directory.
   * 
   */
  void Control::save(QXmlStreamWriter &stream, const Project *project,
                     FileName newProjectRoot) const {
    stream.writeStartElement("controlNet");
@@ -207,12 +258,31 @@ namespace Isis {
  }


  /**
   * Constructor for the Control object's XmlHandler 
   *  
   * @param control A pointer to the Control object.
   * @param cnetFolder The name of the folder for the Control xml
   * 
   */
  Control::XmlHandler::XmlHandler(Control *control, FileName cnetFolder) {
    m_control = control;
    m_cnetFolder = cnetFolder;
    m_xmlHandlerControl = control;
    m_xmlHandlerCnetFolderName = cnetFolder;
  }


  /**
   * Method to read the given XML formatted attribute for a Control object 
   * into the XmlHandler. 
   *  
   * @param namespaceURI ???
   * @param localName The keyword name given to the member variable in the XML.
   * @param qName ???
   * @param atts The attribute containing the keyword value for the given 
   *             localName.
   *  
   * @return @b bool Indicates whether the localName is recognized.
   */
  bool Control::XmlHandler::startElement(const QString &namespaceURI, const QString &localName,
                                         const QString &qName, const QXmlAttributes &atts) {
    if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) {
@@ -222,18 +292,18 @@ namespace Isis {
        QString fileName = atts.value("fileName");

        if (!id.isEmpty()) {
          delete m_control->m_id;
          m_control->m_id = NULL;
          m_control->m_id = new QUuid(id.toLatin1());
          delete m_xmlHandlerControl->m_id;
          m_xmlHandlerControl->m_id = NULL;
          m_xmlHandlerControl->m_id = new QUuid(id.toLatin1());
        }

        if (!fileName.isEmpty()) {
          m_control->m_fileName = m_cnetFolder.expanded() + "/" + fileName;
          m_control->openControlNet();
          m_xmlHandlerControl->m_fileName = m_xmlHandlerCnetFolderName.expanded() + "/" + fileName;
          m_xmlHandlerControl->openControlNet();
        }
      }
      else if (localName == "displayProperties") {
        m_control->m_displayProperties = new ControlDisplayProperties(reader());
        m_xmlHandlerControl->m_displayProperties = new ControlDisplayProperties(reader());
      }
    }

+21 −13
Original line number Diff line number Diff line

#ifndef Control_H
#define Control_H
/**
@@ -23,26 +22,27 @@
 *   http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on
 *   http://www.usgs.gov/privacy.html.
 */
#include <QObject>
#include <QObject> // parent

#include <QString>

#include "FileName.h"
#include "XmlStackedHandler.h"

class QUuid;
class QMutex;
class QUuid;
class QXmlStreamWriter;

namespace Isis {
  class ControlNet;
  class ControlDisplayProperties;
  class ControlNet;
  class FileName;
  class Project;
  class PvlObject;

  /**
   * @brief 
   * This represents an ISIS control net in a project-based GUI interface. This encapsulates ideas about a control net
   * such as it's filename and display properties.
   *
   * @author 2012-06-12 Ken Edmundson and Tracie Sucharski
   *
@@ -51,7 +51,8 @@ namespace Isis {
   *                           member variables.
   *   @history 2012-09-11 Tracie Sucharski - Added new constructor that takes a ControlNet *. 
   *   @history 2015-10-14 Jeffrey Covington - Declared Control * as a Qt
   *                           metatype for use with QVariant.
   *                           metatype for use with QVariant. References #3949
   *   @history 2016-06-02 Jeannie Backer - Updated documentation. Fixes #3949
   */
  class Control : public QObject {
    Q_OBJECT
@@ -79,7 +80,10 @@ namespace Isis {

    private:
      /**
       * @author 2012-??-?? ???
       * Nested class used to write the Control object information to an XML file for the purpose
       * of saving and restoring the state of the project.
       *
       * @author 2012-??-?? Steven Lambright
       *
       * @internal
       */
@@ -93,20 +97,24 @@ namespace Isis {
        private:
          Q_DISABLE_COPY(XmlHandler);

          Control *m_control;
          FileName m_cnetFolder;
          Control *m_xmlHandlerControl;        /**< A pointer to the Control object to be read or
                                                    written.*/
          FileName m_xmlHandlerCnetFolderName; /**< The name of the folder for the control xml.*/
      };

    private:
      Control(const Control &other);
      Control &operator=(const Control &rhs);

      ControlNet *m_controlNet;
      ControlDisplayProperties *m_displayProperties;
      QString m_fileName; //! File name of the control net associated with this control.
      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.*/
      QString m_fileName; /**< File name of the control net associated with this control.*/

      /**
       * A unique ID for this Control (useful for others to reference this Control when saving to disk).
       * A unique ID for this Control.
       * (useful for others to reference this Control when saving to disk).
       */
      QUuid *m_id;
  };