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

Updated documentation and reviewed coding standards for MatrixGraphicsScene,...

Updated documentation and reviewed coding standards for MatrixGraphicsScene, MatrixGraphicsView, MatrixOptions, and MatrixOptionsDialog in preparation to add these classes to trunk. Fixes #4081.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@6893 41f8697f-d340-4b68-9986-7bafba869bb8
parent da7f4e8d
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
#include "MatrixGraphicsScene.h"

#include <QGraphicsSceneContextMenuEvent>
#include <QGraphicsSceneMouseEvent>

#include "MatrixSceneWidget.h"

namespace Isis {
  /**
   * Constructor.
   *
   * Constructs the MatrixGraphicsScene.
   *
   * @param parent Pointer to parent widget, MatrixSceneWidget.
   */
  MatrixGraphicsScene::MatrixGraphicsScene(MatrixSceneWidget *parent) : QGraphicsScene(parent) {
  }


  /**
   * Destructor.
   */
  MatrixGraphicsScene::~MatrixGraphicsScene() {
  }


  /**
   * Handles context menu events for the matrix graphics scene.
   *
   * @param contextMenuEvent Pointer to the context menu event that is being captured.
   */
  void MatrixGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent) {
    if ( selectedItems().count() < 2 ||
         !qobject_cast<MatrixSceneWidget *>( parent() )->contextMenuEvent(contextMenuEvent) ) {
@@ -20,6 +37,11 @@ namespace Isis {
  }


  /**
   * Handles mouse press events for the matrix graphics scene.
   *
   * @param mouseEvent Pointer to the mouse event that is being captured.
   */
  void MatrixGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) {
    if (mouseEvent->button() == Qt::RightButton) {
      // Do nothing on right click... this prevents the loss of selection before a context event
+6 −1
Original line number Diff line number Diff line
#ifndef MatrixGraphicsScene_H
#define MatrixGraphicsScene_H

#include <QGraphicsView>
#include <QGraphicsScene>

class QGraphicsSceneContextMenuEvent;
class QGraphicsSceneMouseEvent;

namespace Isis {
  class MatrixSceneWidget;
@@ -17,6 +20,8 @@ namespace Isis {
   *
   * @internal
   *   @history 2014-07-14 Kimberly Oyama - Adapted from MosaicGraphicsScene.
   *   @history 2016-07-08 Ian Humphrey - Updated includes for coding standards in preparing to add
   *                           to trunk. Fixes #4095, #4081.
   */
  class MatrixGraphicsScene : public QGraphicsScene {
      Q_OBJECT
+25 −1
Original line number Diff line number Diff line
@@ -2,10 +2,20 @@

#include <iostream>

#include <QContextMenuEvent>
#include <QGraphicsScene>
#include <QResizeEvent>
#include <QScrollBar>

namespace Isis {
  /**
   * Constructor.
   *
   * Constructs the MatrixGraphicsView.
   *
   * @param scene Pointer to the graphics scene to visualize.
   * @param widget Pointer to the parent widget.
   */
  MatrixGraphicsView::MatrixGraphicsView(QGraphicsScene *scene,
      QWidget *parent) : QGraphicsView(scene, parent) {
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
@@ -20,15 +30,29 @@ namespace Isis {
    setCacheMode(QGraphicsView::CacheBackground);
  }


  /**
   * Destructor.
   */
  MatrixGraphicsView::~MatrixGraphicsView() {
  }


  /**
   * Handles context menu events on the matrix graphics view.
   *
   * @param event Pointer to the context menu event being captured
   */
  void MatrixGraphicsView::contextMenuEvent(QContextMenuEvent *event) {
    QGraphicsView::contextMenuEvent(event);
  }


  /**
   * Handles resize events on the matrix graphics view.
   *
   * @param event Pointer to the resize event being captured.
   */
  void MatrixGraphicsView::resizeEvent(QResizeEvent *event) {
    if (event->oldSize().isEmpty() || p_resizeZooming) {
      QRectF sceneRect(scene()->itemsBoundingRect());
+12 −1
Original line number Diff line number Diff line
@@ -3,6 +3,10 @@

#include <QGraphicsView>

class QContextMenuEvent;
class QGraphicsScene;
class QResizeEvent;

namespace Isis {
  /**
   * @brief A graphics view that resizes in a more friendly way
@@ -11,6 +15,8 @@ namespace Isis {
   *
   * @internal
   *   @history 2014-07-14 Kimberly Oyama - Adapted from MosaicGraphicsView.
   *   @history 2016-07-08 Ian Humphrey - Updated documentation and coding standards in preparing
   *                           to add to trunk. Fixes #4095, #4081.
   */
  class MatrixGraphicsView : public QGraphicsView {
      Q_OBJECT
@@ -19,6 +25,11 @@ namespace Isis {
      MatrixGraphicsView(QGraphicsScene *scene, QWidget *parent = 0);
      virtual ~MatrixGraphicsView();

      /**
       * Sets whether or not to allow resizing of the view.
       *
       * @param enabled Sets whether or not resize zooming is enabled.
       */
      void enableResizeZooming(bool enabled) {
        p_resizeZooming = enabled;
      }
@@ -28,7 +39,7 @@ namespace Isis {
      virtual void resizeEvent(QResizeEvent *event);

    private:
      bool p_resizeZooming;
      bool p_resizeZooming; //!< Whether or not to allow resizing of the view
  };
}

+137 −107
Original line number Diff line number Diff line
#include "MatrixOptions.h"

#include <QColor>
#include <QString>
#include <QList>
#include <QMap>
#include <QString>
#include <QStringList>

#include "CorrelationMatrix.h"
#include "MatrixSceneWidget.h"
@@ -10,9 +12,17 @@

namespace Isis {
  /**
   * Default Constructor
   * Default Constructor.
   *
   * Constructs a MatrixOptions object used for changing various options on the passed
   * CorrelationMatrix. Options include tolerances and colors for matching certain elements
   * in the CorrelationMatrix based on their correlation values.
   *
   * @param parent CorrelationMatrix to set options for.
   * @param scene Pointer to the MatrixSceneWidget for creating the MatrixOptionsDialog.
   */
  MatrixOptions::MatrixOptions(CorrelationMatrix parent, MatrixSceneWidget *scene) { // give parent? MatrixSceneWidget
  MatrixOptions::MatrixOptions(CorrelationMatrix parent, MatrixSceneWidget *scene) { 
      // give parent? MatrixSceneWidget
    m_parentMatrix = new CorrelationMatrix(parent);
    //Color Options
    m_tolerance = false; // if tolerance is false then we use gradient
@@ -28,7 +38,9 @@ namespace Isis {
    m_parameter1 = "Specific Param1";
    m_image2 = "Specific Img2";
    m_parameter2 = "Specific Param2";
//       m_imagesAndParameters = parentMatrix->imagesAndParameters(); // pointer the the one in correlation matrix?

    // pointer the the one in correlation matrix?
    // m_imagesAndParameters = m_parentMatrix->imagesAndParameters();

    // Tolerance
    m_focusTolSelectedElement = 1.0;
@@ -56,7 +68,6 @@ namespace Isis {
  }



  /**
   * Constructor that sets up all the variables
   */
@@ -64,94 +75,92 @@ namespace Isis {
//   }



  /**
   * Default Destructor
   * Default Destructor.
   */
  MatrixOptions::~MatrixOptions() {
  }

  
  
  // Color Options
  /**
   * The color selected for the correlation values that are below the given threshold.
   * Gets the color selected for the correlation values that are below the given threshold.
   *
   * @return
   * @return @b QColor Returns the selected color for good correlation values.
   */
  QColor MatrixOptions::goodCorrelationColor() {
    return m_goodColor;
  }



  /**
   * The color selected for the correlation values that are above the given threshold.
   * Gets the color selected for the correlation values that are above the given threshold.
   * 
   * @return
   * @return @b QColor Returns the selected color for bad correlation values
   */
  QColor MatrixOptions::badCorrelationColor() {
    return m_badColor;
  }



  /**
   * Threshold for what is considered a bad correlation.
   * Gets the threshold value for what is considered a bad correlation.
   * 
   * @return
   * @return @b double Returns the threshold for distinguishing good vs bad correlation.
   */
  double MatrixOptions::colorTolerance() {
    return m_colorTolerance;
  }


  
  /**
   * Gets the current colorScheme being used on the correlation matrix to show good vs bad
   * correlation values.
   *
   * Use the green-red gradient if false.
   * Use the 50/50 color split if true. You need the good/bad correlation color methods if true.
   * 
   * @return
   * @return @b bool Returns whether to use a color split (true) or gradient (false).
   */
  bool MatrixOptions::colorScheme() {
    return m_tolerance; // if tolerance is false then we use gradient
  }



  /**
   * Sets the color scheme to gradient (false) or split based on tolerance (true).
   *
   * @param
   * @param tolerance Use 50/50 split based on tolerance if true; otherwise, use color gradient.
   */
  void MatrixOptions::setColorScheme(bool tolerance) {
    m_tolerance = tolerance;
  }



  /**
   * Sets the color tolerance for what is considered a bad correlation.
   *
   * @param
   * @param tolerance Value to establish the color tolerance
   */
  void MatrixOptions::setColorTolerance(double tolerance) {
    m_colorTolerance = tolerance;
  }



  /**
   * Set the color for good correlation values.
   *
   * @param
   * @param color The QColor for good correlation.
   */
  void MatrixOptions::setGoodCorrelationColor(QColor color) {
    m_goodColor = color;
  }



  /**
   * Set the color for bad correlation values.
   *
   * @param
   * @param color The QColor for bad correlation.
   */
  void MatrixOptions::setBadCorrelationColor(QColor color) {
    m_badColor = color;
@@ -160,211 +169,231 @@ namespace Isis {
  
  // Focus Options
  /**
   * Returns the focus option for obtaining a specific correlation in the matrix.
   *
   * @return
   * @return @b MatrixOptions::FocusOption Option to determine which correlation to focus.
   */
  MatrixOptions::FocusOption MatrixOptions::focusOption() {
    return m_focusOption;
  }


  
  /**
   * The value of the spot on the matrix that we need to focus on. This can come from the best or
   * worst option as well as the good/bad lists when a tolerance is entered.
   * Gets the value of the spot on the matrix that we need to focus on. This can come from the best
   * or worst option as well as the good/bad lists when a tolerance is entered.
   *
   * @return
   * @return @b double Returns the correlation value to focus on.
   */
  double MatrixOptions::focusValue() {
    return m_focusTolSelectedElement;
  } // best, worst, the one selected from tolerance?



  /**
   * @return
   */
  /*
  QString MatrixOptions::focusImage1() {
    return m_image1;
  }

  */


  /**
   * @return
   */
  /*
  QString MatrixOptions::focusParameter1() {
    return m_parameter1;
  }

  */


  /**
   * @return
   */
  /*
  QString MatrixOptions::focusImage2() {
    return m_image2;
  }

  */


  /**
   * @return
   */
  /*
  QString MatrixOptions::focusParameter2() {
    return m_parameter2;
  }

  */


  /**
   * @return
   * Return the list of good correlation values based on set tolerance.
   *
   * @return @b QList<double> The List of good correlation values.
   */
  QList<double> MatrixOptions::goodElements() {
    return m_badElements;
    return m_goodElements;
  }



  /**
   * @return
   * Return the list of bad correlation values based on set tolerance
   *
   * @return @b QList<double> The List of bad correlation values.
   */
  QList<double> MatrixOptions::badElements() {
    return m_goodElements;
    return m_badElements;
  }



  /**
   * @param
   * Sets the focus option to focus on an element.
   *
   * @param option The option to specify how to set focus.
   */
  void MatrixOptions::setFocusOption(FocusOption option) {
    m_focusOption = option;
  }



  /**
   * @param
   * @param value
   */
  /*
  void MatrixOptions::setFocusValue(double value) {
    m_focusTolSelectedElement = value;
  }

  */
  
  
  /**
   * @param
   * Set the elements with good correlation values (defined by tolerance)
   *
   * @param goodElements QList of elements with good correlation values
   */
  /*
  void MatrixOptions::setGoodElements(QList<double> goodElements) {
    m_goodElements = goodElements;
  }

  */


  /**
   * @param
   * Set the elements with bad correlation values (defined by tolerance)
   * 
   * @param badElements QList of elements with bad correlation values
   */
  /*
  void MatrixOptions::setBadElements(QList<double> badElements) {
    m_badElements = badElements;
  }

  */
  

  // Current Correlation Information



  /**
   * @return
   * Returns the current selected correlation value.
   *
   * @return @b double The current correlation value.
   */
  double MatrixOptions::currentCorrelation() {
    return m_currentValue;
  }



  /**
   * @return
   */
  /*
  QString MatrixOptions::currentImage1() {
    return m_currentImg1;
  }

  */


  /**
   * @return
   */
  /*
  QString MatrixOptions::currentParameter1() {
    return m_currentParam1;
  }

  */


  /**
   * @return
   */
  /*
  QString MatrixOptions::currentImage2() {
    return m_currentImg2;
  }

  */


  /**
   * @return
   */
  /*
  QString MatrixOptions::currentParameter2() {
    return m_currentParam2;
  }

  */

  
  /**
   * @param
   * Updates the value of the current correlation.
   *
   * @param value Value to set the current correlation to.
   */
  void MatrixOptions::setCurrentCorrelation(double value) {
    m_currentValue = value;
  }



  /**
   * @param
   * Sets the value of the current image1 to the given QString.
   * 
   * @param current Name to set the current image1 to.
   */
  void MatrixOptions::setCurrentImage1(QString current) {
    m_currentImg1 = current;
  }



  /**
   * @param
   * Sets the value of the current parameter1 to the given QString.
   *
   * @param current Name to set current parameter1 to.
   */
  void MatrixOptions::setCurrentParameter1(QString current) {
    m_currentParam1= current;
  }



  /**
   * @param
   * Set the current image 2 to the given QString.
   *
   * @param current QString to set the current image 2 to.
   */
  void MatrixOptions::setCurrentImage2(QString current) {
    m_currentImg2 = current;
  }



  /**
   * @param
   * Set the current parameter 2 to the given QString.
   *
   * @param current QString to set current parameter 2 to.
   */
  void MatrixOptions::setCurrentParameter2(QString current) {
    m_currentParam2 = current;
  }



  //Slots 
  /**
   * This slot will be called when a matrix element is clicked on.
@@ -375,20 +404,21 @@ namespace Isis {
//   }



  /**
   * Gets the parent correlation matrix's images and parameters mapping.
   *
   * @return
   * @return @b QMap<QString,StringList> QMap of the correlation matrix image names to their
   *                                     parameters.
   */
  QMap<QString, QStringList> MatrixOptions::matrixImgsAndParams() {
    return *m_parentMatrix->imagesAndParameters();
  }



  /**
   * Accessor that returns the parent correlation matrix we are setting options for.
   *
   *
   * @return @b CorrelationMatrix* Pointer to the correlation matrix we are setting options for.
   */
  CorrelationMatrix *MatrixOptions::parentMatrix() {
    return m_parentMatrix;
Loading