File failed to load: https://isis.astrogeology.usgs.gov/6.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
SpectralPlotWindow.cpp
1 #include "IsisDebug.h"
2 
3 #include "SpectralPlotWindow.h"
4 
5 #include <QAction>
6 #include <QMenu>
7 #include <QMenuBar>
8 #include <QString>
9 
10 #include "Cube.h"
11 #include "MdiCubeViewport.h"
12 #include "Pvl.h"
13 #include "PvlGroup.h"
14 #include "PvlObject.h"
15 
16 
17 using namespace std;
18 
19 namespace Isis {
27  SpectralPlotWindow::SpectralPlotWindow(PlotCurve::Units xUnits,
28  QWidget *parent) : PlotWindow("Spectral Plot", xUnits,
29  PlotCurve::CubeDN, parent) {
30  nullify();
31 
32  m_showHideBandMarkers = new QAction("Show Band Markers", this);
33  m_showHideBandMarkers->setCheckable(true);
34  m_showHideBandMarkers->setChecked(true);
35  connect(m_showHideBandMarkers, SIGNAL(toggled(bool)),
36  this, SLOT(setBandMarkersVisible(bool)));
37 
38  m_grayBandLine = createMarker(Qt::white);
39  m_redBandLine = createMarker(Qt::red);
40  m_greenBandLine = createMarker(Qt::green);
41  m_blueBandLine = createMarker(Qt::blue);
42 
44 
45  foreach (QAction *menuAction, menuBar()->actions()) {
46  if (menuAction->text() == "&Options") {
47  QMenu *optsMenu = qobject_cast<QMenu *>(menuAction->parentWidget());
48 
49  optsMenu->addAction(m_showHideBandMarkers);
50  }
51  }
52  }
53 
54 
55  SpectralPlotWindow::~SpectralPlotWindow() {
56  nullify();
57  }
58 
59 
64  m_cvp = NULL;
65  m_grayBandLine = NULL;
66  m_redBandLine = NULL;
67  m_greenBandLine = NULL;
68  m_blueBandLine = NULL;
69  m_showHideBandMarkers = NULL;
70  }
71 
72 
80  QwtPlotMarker *SpectralPlotWindow::createMarker(QColor color) {
81  QPen markerPen(color);
82  markerPen.setWidth(1);
83 
84  QwtPlotMarker *newMarker = new QwtPlotMarker;
85  newMarker->setLineStyle(QwtPlotMarker::LineStyle(2));
86  newMarker->setLinePen(markerPen);
87  newMarker->attach(plot());
88  newMarker->setVisible(false);
89 
90  return newMarker;
91  }
92 
93 
100  if (m_cvp) {
101  int redBand = 0, greenBand = 0, blueBand = 0, grayBand = 0;
102 
103  Cube *cube = m_cvp->cube();
104  Pvl &pvl = *cube->label();
105  PvlKeyword wavelengths;
106 
107  if (pvl.findObject("IsisCube").hasGroup("BandBin")) {
108  PvlGroup &bandBin = pvl.findObject("IsisCube").findGroup("BandBin");
109  if (bandBin.hasKeyword("Center")) {
110  wavelengths = bandBin.findKeyword("Center");
111  }
112  }
113 
114  if (m_cvp->isColor()) {
115  redBand = m_cvp->redBand();
116  greenBand = m_cvp->greenBand();
117  blueBand = m_cvp->blueBand();
118  }
119  else {
120  grayBand = m_cvp->grayBand();
121  }
122 
123  /*This is were we need to set the x value to the band number.*/
124  if (grayBand > 0) {
126  m_grayBandLine->setXValue(toDouble(wavelengths[grayBand-1]));
127  }
128  else {
129  m_grayBandLine->setXValue(grayBand);
130  }
131 
132  if (m_markersVisible)
133  m_grayBandLine->show();
134  }
135  else {
136  m_grayBandLine->hide();
137  }
138 
139  if (redBand > 0) {
141  m_redBandLine->setXValue(toDouble(wavelengths[redBand-1]));
142  }
143  else {
144  m_redBandLine->setXValue(redBand);
145  }
146 
147  if (m_markersVisible)
148  m_redBandLine->show();
149  }
150  else {
151  m_redBandLine->hide();
152  }
153  if (greenBand > 0) {
155  m_greenBandLine->setXValue(toDouble(wavelengths[greenBand-1]));
156  }
157  else {
158  m_greenBandLine->setXValue(greenBand);
159  }
160 
161  if (m_markersVisible)
162  m_greenBandLine->show();
163  }
164  else {
165  m_greenBandLine->hide();
166  }
167 
168  if (blueBand > 0) {
170  m_blueBandLine->setXValue(toDouble(wavelengths[blueBand-1]));
171  }
172  else {
173  m_blueBandLine->setXValue(blueBand);
174  }
175 
176  if (m_markersVisible)
177  m_blueBandLine->show();
178  }
179  else {
180  m_blueBandLine->hide();
181  }
182 
183  plot()->replot();
184  }
185  }
186 
187 
195  m_cvp = cvp;
196 
197  }
198 
199 
206  m_markersVisible = visible;
207 
208  m_blueBandLine->setVisible(m_markersVisible);
209  m_redBandLine->setVisible(m_markersVisible);
210  m_greenBandLine->setVisible(m_markersVisible);
211  m_grayBandLine->setVisible(m_markersVisible);
212 
213  replot();
214  }
215 
216 
224  setViewport(activeViewport);
225  drawBandMarkers();
226  }
227 
228 
236  return m_markersVisible;
237  }
238 }
239 
Isis::MdiCubeViewport
Cube display widget for certain Isis MDI applications.
Definition: MdiCubeViewport.h:39
QWidget
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
QMenu
Isis::CubeViewport::isColor
bool isColor() const
Definition: CubeViewport.h:184
Isis::SpectralPlotWindow::m_grayBandLine
QwtPlotMarker * m_grayBandLine
The band marker for the gray band.
Definition: SpectralPlotWindow.h:54
Isis::PlotCurve
Definition: PlotCurve.h:44
Isis::PvlContainer::hasKeyword
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
Definition: PvlContainer.cpp:159
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::PlotCurve::Units
Units
These are all the possible units for the x or y data in a plot curve.
Definition: PlotCurve.h:54
Isis::SpectralPlotWindow::nullify
void nullify()
This initializes the class member data to NULL.
Definition: SpectralPlotWindow.cpp:63
Isis::SpectralPlotWindow::m_greenBandLine
QwtPlotMarker * m_greenBandLine
The band marker for the green band.
Definition: SpectralPlotWindow.h:58
Isis::SpectralPlotWindow::m_blueBandLine
QwtPlotMarker * m_blueBandLine
The band marker for the blue band.
Definition: SpectralPlotWindow.h:60
Isis::CubeViewport::blueBand
int blueBand() const
Definition: CubeViewport.h:209
Isis::PlotWindow::xAxisUnits
PlotCurve::Units xAxisUnits() const
This is the data-type of the curves' x data in this plot window.
Definition: PlotWindow.cpp:266
Isis::SpectralPlotWindow::update
void update(MdiCubeViewport *activeViewport)
This window can show markers for the currently visible bands.
Definition: SpectralPlotWindow.cpp:223
Isis::CubeViewport::grayBand
int grayBand() const
Definition: CubeViewport.h:194
Isis::SpectralPlotWindow::createMarker
QwtPlotMarker * createMarker(QColor color)
This is a helper method to create new band markers with the same line style and a custom color.
Definition: SpectralPlotWindow.cpp:80
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Isis::SpectralPlotWindow::m_cvp
MdiCubeViewport * m_cvp
The viewport to be used as a reference for band markers.
Definition: SpectralPlotWindow.h:50
Isis::PvlObject::findObject
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
Definition: PvlObject.h:274
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::SpectralPlotWindow::m_showHideBandMarkers
QAction * m_showHideBandMarkers
This action toggles band marker visibility.
Definition: SpectralPlotWindow.h:62
Isis::PlotCurve::Wavelength
@ Wavelength
The data is a wavelength.
Definition: PlotCurve.h:92
Isis::SpectralPlotWindow::setBandMarkersVisible
void setBandMarkersVisible(bool visible)
Definition: SpectralPlotWindow.cpp:205
Isis::PlotWindow::plot
QwtPlot * plot()
Get the plot encapsulated by this PlotWindow.
Definition: PlotWindow.cpp:1653
Isis::toDouble
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition: IString.cpp:149
std
Namespace for the standard library.
Isis::Cube::label
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1701
Isis::SpectralPlotWindow::m_markersVisible
bool m_markersVisible
True if the visibile state of the active markers should be true.
Definition: SpectralPlotWindow.h:52
Isis::SpectralPlotWindow::bandMarkersVisible
bool bandMarkersVisible() const
Definition: SpectralPlotWindow.cpp:235
Isis::PvlContainer::findKeyword
PvlKeyword & findKeyword(const QString &name)
Find a keyword with a specified name.
Definition: PvlContainer.cpp:62
Isis::SpectralPlotWindow::m_redBandLine
QwtPlotMarker * m_redBandLine
The band marker for the red band.
Definition: SpectralPlotWindow.h:56
Isis::SpectralPlotWindow::setViewport
void setViewport(MdiCubeViewport *cvp)
This class needs to know which viewport the user is looking at so it can appropriately draw in the ba...
Definition: SpectralPlotWindow.cpp:194
Isis::PlotWindow::replot
void replot()
Reset the scale of the plot, replot it and emit plot changed.
Definition: PlotWindow.cpp:1797
Isis::PlotWindow
Definition: PlotWindow.h:88
QAction
Isis::CubeViewport::cube
Cube * cube() const
Definition: CubeViewport.h:338
Isis::SpectralPlotWindow::drawBandMarkers
void drawBandMarkers()
This method actually draws in the vertical band line(s) on the plot area.
Definition: SpectralPlotWindow.cpp:99
Isis::CubeViewport::redBand
int redBand() const
Definition: CubeViewport.h:199
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::CubeViewport::greenBand
int greenBand() const
Definition: CubeViewport.h:204

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:17:18