Commit 062f9ee6 authored by Ian Humphrey's avatar Ian Humphrey
Browse files

Modified CubePlotCurveConfigureDialog and PlotWindow. 2D and 3D plots now have...

Modified CubePlotCurveConfigureDialog and PlotWindow. 2D and 3D plots now have a configure button in the plot window's toolbar, allowing user to configure multiple curves at once. Added what's this help to Spatial Plot Tool. Fixes #2089.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@5938 41f8697f-d340-4b68-9986-7bafba869bb8
parent cd760991
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -139,5 +139,15 @@
      Changed the character that is used as a token when parsing the list of file names used when
      the socket is already open. Fixes #1551.
    </change>
    <change name="Ian Humphrey" date="2014-07-30">
      Modified spectral plot tool to more accurately compute statistics for rectangular and 
      polygonal selections. Fixes #2071.
    </change>
    <change name="Ian Humphrey" date="2014-07-31">
      Added configurePlotCurves() method to PlotWindow. User can activate configure dialog on 
      single curve with right-click or activate dialog with combo box of all curves using the 
      toolbar button. Added What's This for SpatialPlotTool and removed the configure toolbar button
      for ScatterPlotWindow. Fixes #2089.
    </change>
  </history>
</application>
+2 −0
Original line number Diff line number Diff line
@@ -467,6 +467,8 @@ namespace Isis {
          deleteThisCurve = true;
        }
      }
      // handle the configure action dialog 
      // opens the dialog with only the right-clicked CubePlotCurve
      else if (chosenAct == configureAct) {
        CubePlotCurveConfigureDialog configure(this);
        configure.exec();
+2 −0
Original line number Diff line number Diff line
@@ -62,6 +62,8 @@ namespace Isis {
   *                           necessary. Fixes #688.
   *   @history 2012-03-14 Tracie Sucharski - Added functionality for multiple
   *                           viewports as a source for plots.
   *   @history 2014-07-02 Ian Humphrey - Added comment for executing configure dialog. 
   *                           References #2089.
   */  
  class CubePlotCurve : public QObject, public PlotCurve {
      Q_OBJECT
+82 −9
Original line number Diff line number Diff line
@@ -11,32 +11,59 @@
#include <QPushButton>

#include "CubePlotCurve.h"
#include "IException.h"
#include "PlotWindow.h"

namespace Isis {
  /**
   * This instantiates a configuration dialog associated with the given cube
   *   plot curve.
   *
   * @param curve The plot curve to be configured
   * @param curve The plot curve to be configured.
   * @param parent The parent widget/widget who owns this dialog.
   */
  CubePlotCurveConfigureDialog::CubePlotCurveConfigureDialog(
      CubePlotCurve *curve, QWidget *parent) : QDialog(parent) {
    m_plotCurve = curve; 
    m_parent = parent;
    // initially set selected curve index to 0 (first curve)
    m_selectedCurve = 0;
    
    // we can grab the CubePlotCurve QList from the parent widget (PlotWindow)
    if (parent) {
      connect( parent, SIGNAL( plotChanged() ),
               this, SLOT( updateCurvesList() ) );
      m_plotCurvesList = qobject_cast<PlotWindow *>(parent)->plotCurves();
    }    
    else {
      m_plotCurvesList.append(curve);
    }

    QGridLayout *optionsLayout = new QGridLayout;

    int row = 0; 
    QLabel *titleLabel = new QLabel("Curve Name: ");
    m_nameEdit = new QLineEdit(curve->title().text());
    optionsLayout->addWidget(titleLabel, row, 0);
    
    // only create a combo box if instantiating this dialog with the configure tool button
    if (parent) {
      QLabel *curvesLabel = new QLabel("Curves: ");
      m_curvesCombo = new QComboBox();
      connect( m_curvesCombo, SIGNAL( currentIndexChanged(int) ),
               this, SLOT( updateComboIndex(int) ) );
      optionsLayout->addWidget(curvesLabel, row, 0);
      optionsLayout->addWidget(m_curvesCombo, row, 1);
      row++;
    }
    
    QLabel *nameLabel = new QLabel("Curve Name: ");
    m_nameEdit = new QLineEdit( m_plotCurve->title().text() );
    optionsLayout->addWidget(nameLabel, row, 0);
    optionsLayout->addWidget(m_nameEdit, row, 1);
    row++;

    QLabel *colorLabel = new QLabel("Color: ");
    m_colorButton = new QPushButton;
    m_colorButton->setFixedWidth(25);
    connect(m_colorButton, SIGNAL(clicked()), this, SLOT(askUserForColor()));
    connect( m_colorButton, SIGNAL( clicked() ),
             this, SLOT( askUserForColor() ) );
    optionsLayout->addWidget(colorLabel, row, 0);
    optionsLayout->addWidget(m_colorButton, row, 1);
    row++;
@@ -175,7 +202,9 @@ namespace Isis {
    m_plotCurve->show();
    m_plotCurve->plot()->replot();

    // Put us in a state as if we just opened the config dialog
    // When user hits Apply, the current curve will still be selected
    // can't use m_curvesCombo->currentIndex() - CubePlotCurve instantiates this config dialog
    // without a combo box
    readSettingsFromCurve();
  }

@@ -185,8 +214,29 @@ namespace Isis {
   *   configuration dialog's widgets with the appropriate data/settings.
   */
  void CubePlotCurveConfigureDialog::readSettingsFromCurve() {
    // ensure that the m_selectedCurve index is in bounds
    if (m_selectedCurve > m_plotCurvesList.size() - 1 || m_selectedCurve < 0) {
      throw IException(IException::Programmer, "Curves combobox index out of bounds", _FILEINFO_);
    }
    
    m_plotCurve = m_plotCurvesList[m_selectedCurve];
    
    setWindowTitle( "Configure " + m_plotCurve->title().text() );

    // see if the curves combo box exists in the dialog (right-clicking a curve will not create
    // a combo box in the dialog)
    if (m_curvesCombo) {
      m_curvesCombo->blockSignals(true);
      m_curvesCombo->clear();
      // add items to combo box
      foreach(CubePlotCurve *curve, m_plotCurvesList) {
        m_curvesCombo->addItem( curve->title().text() );
      }
      m_curvesCombo->setCurrentIndex(m_selectedCurve);
//       m_curvesCombo->setItemText( m_curvesCombo->currentIndex(), m_plotCurve->title().text() );
      m_curvesCombo->blockSignals(false);
    }
    
    m_nameEdit->setText( m_plotCurve->title().text() );

    QPalette colorPalette;
@@ -212,8 +262,7 @@ namespace Isis {
    if ( m_symbolCombo->count() ) {
      m_symbolCombo->setCurrentIndex(0);
      for (int i = 0; i < m_symbolCombo->count(); i++) {
        if (m_symbolCombo->itemData(i).toInt() ==
            m_plotCurve->markerSymbol().style()) {
        if ( m_symbolCombo->itemData(i).toInt() == m_plotCurve->markerSymbol().style() ) {
          m_symbolCombo->setCurrentIndex(i);
        }
      }
@@ -221,6 +270,30 @@ namespace Isis {
  }

  
  void CubePlotCurveConfigureDialog::updateComboIndex(int selected) {
    m_selectedCurve = selected;
    readSettingsFromCurve();
  }
  
  
  void CubePlotCurveConfigureDialog::updateCurvesList() {
    QList<CubePlotCurve*> newPlotCurveList = qobject_cast<PlotWindow*>(m_parent)->plotCurves();
    // if we deleted a plot curve, the new list will be smaller in size, reset m_selectedCurve
    if ( newPlotCurveList.size() < m_plotCurvesList.size() ) {
      m_selectedCurve = 0;
    }
    m_plotCurvesList.clear();
    m_plotCurvesList = newPlotCurveList;
    // don't read settings if there are 0 curves in the plot window
    if (m_plotCurvesList.size() != 0) {
      readSettingsFromCurve();
    }
    // close the configure dialog if the last curve was deleted
    else {
      close();
    }
  }

  /**
   * This prompts the user to select a new color for the curve/curve markers.
   */
+18 −3
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@ class QWidget;

namespace Isis {
  class CubePlotCurve;
  class PlotWindow;


  /**
   * This should be an inner class for CubePlotCurve, but Qt doesn't support
@@ -23,6 +25,10 @@ namespace Isis {
   * @internal
   *   @history 2012-01-20 Steven Lambright and Jai Rideout - Completed
   *                           documentation.
   *   @history 2014-07-25 Ian Humphrey - Added configure tool menu item. This allows user to 
   *                           right-click a curve (as previously) or select  configure tool menu 
   *                           item to configure a plot curve's color, symbol, line style, etc.
   *                           Fixes #2089.
   */
  class CubePlotCurveConfigureDialog : public QDialog {
      Q_OBJECT
@@ -35,6 +41,8 @@ namespace Isis {
    public slots:
      void applySettingsToCurve();
      void readSettingsFromCurve();
      void updateComboIndex(int selected);
      void updateCurvesList();

    private slots:
      void askUserForColor();
@@ -58,19 +66,26 @@ namespace Isis {
          const CubePlotCurveConfigureDialog &other);

    private:
      //! The selection/combo box for the cube plot curve
      QPointer<QComboBox>   m_curvesCombo;
      //! The line edit containing the cube plot curve's name
      QPointer<QLineEdit>   m_nameEdit;
      //! The button for changing the cube plot curve's color
      QPointer<QPushButton> m_colorButton;
      //! The parent widget of the configuration dialog
      QPointer<QWidget> m_parent;
      //! The current plot curve to configure
      QPointer<CubePlotCurve> m_plotCurve;
      //! The list of plot curves to configure
      QList<CubePlotCurve *> m_plotCurvesList;
      //! The index of the selected curve in m_curvesCombo
      int m_selectedCurve;
      //! The selection/combo box for the cube plot curve's size/thickness
      QPointer<QComboBox>   m_sizeCombo;
      //! The selection/combo box for the cube plot curve's line style
      QPointer<QComboBox>   m_styleCombo;
      //! The selection/combo box for the cube plot curve's marker style
      QPointer<QComboBox>   m_symbolCombo;

      //! The plot curve we are configuring.
      QPointer<CubePlotCurve> m_plotCurve;
  };
}

Loading