Commit acd88e04 authored by Ian Humphrey's avatar Ian Humphrey
Browse files

PROG: Updated documentation and coding standards for MatrixSceneWidget class. Fixes #4006.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@6870 41f8697f-d340-4b68-9986-7bafba869bb8
parent c23f02f5
Loading
Loading
Loading
Loading
+58 −44
Original line number Diff line number Diff line
@@ -5,15 +5,15 @@
#include <float.h>
#include <sstream>

#include <QtCore>
#include <QtWidgets>
#include <QtXml>
#include <QGraphicsRectItem>
#include <QGraphicsSceneMouseEvent>
#include <QList>
#include <QPen>
#include <QMap>
#include <QPen>
#include <QtCore>
#include <QtWidgets>
#include <QtXml>
#include <QTransform>
#include <QGraphicsRectItem>

#include "CorrelationMatrix.h"
#include "Directory.h"
@@ -36,20 +36,20 @@
#include "XmlStackedHandlerReader.h"

#include <boost/numeric/ublas/fwd.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/io.hpp>

using namespace boost::numeric::ublas;
namespace Isis {
  /**
   * Create a scene widget.
   * Constructor, creates a matrix scene widget.
   *
   * @param status
   * @param showTools
   * @param internalizeToolBarsAndProgress
   * @param directory
   * @param parent
   * @param status Pointer to an existing status bar
   * @param showTools Whether or not create a matrix scene or matrix world view
   * @param internalizeToolBarsAndProgress Whether or not to show progress and status
   * @param directory The directory of the current project
   * @param parent QPointer to the parent widget
   */
  MatrixSceneWidget::MatrixSceneWidget(QStatusBar *status,
                                       bool showTools,
@@ -148,7 +148,6 @@ namespace Isis {
  }



  /**
   * Default Destructor
   */
@@ -160,29 +159,29 @@ namespace Isis {
  /**
   * Accessor for the QGraphicsView
   *
   * @return MatrixGraphicsView The matrix view.
   * @return @b MatrixGraphicsView* The matrix view.
   */
  MatrixGraphicsView *MatrixSceneWidget::getView() const {
    return m_graphicsView;
  }


  
  /**
   * Accessor for the QGraphicsScene
   *
   * @return MatrixGraphicsScene The matrix scene.
   * @return @b MatrixGraphicsScene* The matrix scene.
   */
  QGraphicsScene *MatrixSceneWidget::getScene() const {
    return m_graphicsScene;
  }



  /**
   * This is called by MatrixGraphicsScene::contextMenuEvent.
   *
   * Return false if not handled, true if handled.
   * @param event The context menu event
   *
   * @return @b bool false if not handled, true if handled.
   */
  bool MatrixSceneWidget::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
    bool handled = false;
@@ -239,8 +238,11 @@ namespace Isis {
  }



  
  /**
   * Accessor for the widget's progress bar
   *
   * @return @b QProgressBar* The progress bar
   */
  QProgressBar *MatrixSceneWidget::getProgress() {
    return m_progress;
  }
@@ -252,6 +254,11 @@ namespace Isis {
//   }


  /**
   * Returns the bounding rectangle for the images
   *
   * @return @b QRectF Bounding rectangle for image elements
   */
  QRectF MatrixSceneWidget::elementsBoundingRect() const {
    QRectF boundingRect;

@@ -262,13 +269,21 @@ namespace Isis {
  }



  /**
   * Accessor for the directory
   *
   * @return @b Directory* The directory
   */
  Directory *MatrixSceneWidget::directory() const {
    return m_directory;
  }



  /**
   * Accessor for the view actions
   *
   * @return @b QList<QAction*> List of view actions
   */
  QList<QAction *> MatrixSceneWidget::getViewActions() {
    QList<QAction *> viewActs;

@@ -281,12 +296,11 @@ namespace Isis {
  }


  
  /**
   * Get a list of applicable actions for the elements in this scene.
   *
   * @param
   * @return
   * @param matrix Pointer to the CorrelationMatrix that belongs to the project
   * @return @b QList<QAction*> List of supported actions for the CorrelationMatrix elements
   */
  QList<QAction *> MatrixSceneWidget::supportedActions(CorrelationMatrix *matrix) {
    QList<QAction *> results;
@@ -295,7 +309,6 @@ namespace Isis {
  }



  /**
   * This method refits the items in the graphics view.
   *
@@ -314,7 +327,9 @@ namespace Isis {
//   }



  /**
   * Update the visible bounding rectangle
   */
  void MatrixSceneWidget::sendVisibleRectChanged() {
    QPointF topLeft = getView()->mapToScene(0, 0);
    QPointF bottomRight =
@@ -325,23 +340,22 @@ namespace Isis {
  }



  /**
   * Pick the relevant actions given the type of event that occured in the scene.
   *
   * Mouse Events:
   * 
   * Press - Add matrix value to list?
   * Press - Emit elementClicked signal to update the options dialog
   * Release - nolowerColorValue?
   * Double-Click - same as press
   * Move - nolowerColorValue
   * Enter - change label to match current item.
   * Leave - clear label
   * 
   * @param obj
   * @param event
   * @param obj Pointer to the target QObject to watch events on
   * @param event The event to inspect
   *
   * @return bool 
   * @return @b bool True if the event is filter (stopping all future processing of the event) 
   */
  bool MatrixSceneWidget::eventFilter(QObject *obj, QEvent *event) {
    bool stopProcessingEvent = true;
@@ -374,7 +388,6 @@ namespace Isis {
  }



  /**
   * Redraws all the items in the view. Also makes sure to resize the view rectangle
   * to fit the newly drawn items.
@@ -501,7 +514,8 @@ namespace Isis {
              QString param1 = "Parameter 1: " + colIterator.value().at(column) + "\n";
              QString img2 = "Image 2       : " + rowIterator.key() + "\n";
              QString param2 = "Parameter 2: " + rowIterator.value().at(row);
              QString toolTip = "Correlation  : " + QString::number( ( *block.value() )(row, column) )
              QString toolTip = "Correlation  : " 
                  + QString::number( ( *block.value() )(row, column) )
                  + "\n" + img1 + param1 + img2 + param2;
              rectangle->setToolTip(toolTip);
            }
@@ -528,11 +542,10 @@ namespace Isis {
  }



  /**
   * Draw the lines that will show the columns and blocks for each image.
   *
   * @param matrix 
   * @param corrMatrix The matrix that belongs to the project
   */
  void MatrixSceneWidget::drawGrid(CorrelationMatrix corrMatrix) {
    int startVX = 20;
@@ -599,18 +612,14 @@ namespace Isis {
  }



  /**
   * Redraw matrix when the focus is chagned.
   *
   * @param
   * Redraw matrix when the focus is changed.
   */
  void MatrixSceneWidget::redrawElements() {
    drawElements( *m_matrixOptions->parentMatrix() );
  }



  /**
   * Change item colors when options are changed.
   *
@@ -634,6 +643,11 @@ namespace Isis {
//   }


  /**
   * Allows for changing the options on a CorrelationMatrix
   *
   * @param corrMat The matrix to set up options for
   */
  void MatrixSceneWidget::setUpOptions(CorrelationMatrix corrMat) {
    m_matrixOptions = new MatrixOptions(corrMat, this);
    connect(m_matrixOptions, SIGNAL( optionsUpdated() ),
+22 −15
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ namespace Isis {
   *   @history 2014-07-14 Kimberly Oyama - Original Version
   *   @history 2014-07-21 Kimberly Oyama - Added matrix options dialog. Color options are
   *                           functional.
   *   @history 2016-06-27 Ian Humphrey - Updated documentation and coding standards. Fixes #4006.
   */
  class MatrixSceneWidget : public QWidget {
      Q_OBJECT
@@ -83,6 +84,10 @@ namespace Isis {

      /**
       * Return an empty list of actions for unknown data types
       *
       * @param DataType The type of data we want to get actions for
       *
       * @return @b QList<QAction*> Empty list of actions (currently)
       */
      template <typename DataType>
      QList<QAction *> supportedActions(DataType) {
@@ -91,19 +96,21 @@ namespace Isis {

    signals:
// add roll over?
      void mouseEnter();
      void mouseMove(QPointF);
      void mouseLeave();
      void mouseDoubleClick(QPointF);
      void mouseButtonPress(QPointF, Qt::MouseButton s);
      void mouseButtonRelease(QPointF, Qt::MouseButton s);
      void mouseWheel(QPointF, int delta);
      // Not all these signals are used, descriptions show possible intended use
      void mouseEnter(); //!< Emitted when mouse enters widget focus
      void mouseMove(QPointF); //!< Emitted when mouse moves in widget
      void mouseLeave(); //!< Emitted when mouse leaves widget focus
      void mouseDoubleClick(QPointF); //!< Emitted when handling a mouse double-click
      void mouseButtonPress(QPointF, Qt::MouseButton s); //!< Emitted when mouse is pressed
      void mouseButtonRelease(QPointF, Qt::MouseButton s); //!< Emitted when mouse button released
      void mouseWheel(QPointF, int delta); //!< Emitted when mouse wheel is activated
      //! Emitted when rubber band selection is complete
      void rubberBandComplete(QRectF r, Qt::MouseButton s);
      void visibleRectChanged(QRectF);
      void elementsChanged();
      void queueSelectionChanged();
      void visibleRectChanged(QRectF); //!< Emitted when the visible rectangle is changed
      void elementsChanged(); //!< Emitted when an element of the widget is changed
      void queueSelectionChanged(); //!< Emitted when selection is changed

      void elementClicked(QString);
      void elementClicked(QString); //!< Emitted when an element of the widget is clicked

    public slots:
      void redrawElements();
@@ -122,18 +129,18 @@ namespace Isis {
      QList<double> getSelectedElements() const;

      // member variables
      Directory *m_directory;
      Directory *m_directory; //!< The directory of the project
      
      QGraphicsScene *m_graphicsScene; //!< The graphics scene holds the scene items.
      MatrixGraphicsView *m_graphicsView; //!< The graphics view that displays the scene

      QGraphicsRectItem *m_outlineRect; //!< Rectangle outlining the area where the images go.

      QAction *m_quickMapAction;
      QAction *m_quickMapAction; //!< ??? (always NULL)

      ProgressBar *m_progress;
      ProgressBar *m_progress; //!< Progress bar

      MatrixOptions *m_matrixOptions;
      MatrixOptions *m_matrixOptions; //!< Options for the correlation matrix
  };
}