2 #include "ScatterPlotWindow.h" 7 #include <qwt_color_map.h> 9 #include <qwt_plot_layout.h> 10 #include <qwt_plot_panner.h> 11 #include <qwt_plot_spectrogram.h> 12 #include <qwt_plot_zoomer.h> 13 #include <qwt_scale_draw.h> 14 #include <qwt_scale_widget.h> 19 #include "ScatterPlotAlarmConfigDialog.h" 20 #include "ScatterPlotData.h" 21 #include "ScatterPlotTool.h" 23 #include "ViewportMainWindow.h" 44 ScatterPlotWindow::ScatterPlotWindow(QString title,
45 Cube *xAxisCube,
int xAxisBand,
int xAxisBinCount,
46 Cube *yAxisCube,
int yAxisBand,
int yAxisBinCount,
47 QwtInterval sampleRange, QwtInterval lineRange,
52 ~BackgroundSwitchMenuOption &
53 ~ShowTableMenuOption &
54 ~ClearPlotMenuOption &
55 ~ShowHideMarkersMenuOption &
56 ~ShowHideCurvesMenuOption &
57 ~ConfigurePlotMenuOption)) {
72 xAxisCube, xAxisBand, xAxisBinCount,
73 yAxisCube, yAxisBand, yAxisBinCount,
74 sampleRange, lineRange);
89 QwtScaleWidget *rightAxis =
plot()->axisWidget(QwtPlot::yRight);
90 rightAxis->setTitle(
"Counts");
91 rightAxis->setColorBarEnabled(
true);
95 plot()->setAxisScale(QwtPlot::yRight,
98 plot()->enableAxis(QwtPlot::yRight);
100 plot()->setAxisTitle(QwtPlot::xBottom,
101 QFileInfo(xAxisCube->
fileName()).baseName() +
" Band " +
102 QString::number(xAxisBand) +
" " +
103 plot()->axisTitle(QwtPlot::xBottom).text());
104 plot()->setAxisTitle(QwtPlot::yLeft,
105 QFileInfo(yAxisCube->
fileName()).baseName() +
" Band " +
106 QString::number(yAxisBand) +
" " +
107 plot()->axisTitle(QwtPlot::yLeft).text());
110 QwtInterval range =
m_spectrogram->data()->interval(Qt::ZAxis);
112 for (
double level = range.minValue();
113 level < range.maxValue();
114 level += ((range.maxValue() - range.minValue()) / 6.0)) {
115 contourLevels += level;
127 m_contour->setText(
"Hide Contour Lines");
129 QPixmap(
FileName(
"$base/icons/scatterplotcontour.png").expanded()));
134 configureAlarmingAct->setText(
"Change Alarming");
135 configureAlarmingAct->setIcon(
136 QPixmap(
FileName(
"$base/icons/scatterplotalarming.png").expanded()));
137 connect(configureAlarmingAct, SIGNAL(triggered()),
140 foreach (
QAction *menuAction, menuBar()->actions()) {
141 if (menuAction->text() ==
"&Options") {
142 QMenu *optsMenu = qobject_cast<
QMenu *>(menuAction->parentWidget());
145 optsMenu->addAction(configureAlarmingAct);
152 plot()->canvas()->installEventFilter(
this);
153 plot()->canvas()->setMouseTracking(
true);
157 QString instanceName = windowTitle();
158 FileName config(
"$HOME/.Isis/qview/" + instanceName +
".config");
159 QSettings settings(config.
expanded(),
160 QSettings::NativeFormat);
161 m_alarmPlot = settings.value(
"alarmOntoPlot",
true).toBool();
171 settings.value(
"alarmViewportScreenWidth", 5).toInt();
173 settings.value(
"alarmViewportScreenHeight", 5).toInt();
176 settings.value(
"alarmViewportXDnBoxSize", 1.0).toDouble();
178 settings.value(
"alarmViewportYDnBoxSize", 1.0).toDouble();
182 ScatterPlotWindow::~ScatterPlotWindow() {
183 QString instanceName = windowTitle();
184 FileName config(
"$HOME/.Isis/qview/" + instanceName +
".config");
185 QSettings settings(config.expanded(),
186 QSettings::NativeFormat);
285 if (o ==
plot()->canvas()) {
287 case QEvent::MouseMove: {
288 if (((QMouseEvent *)e)->buttons() == Qt::NoButton)
292 case QEvent::Leave: {
325 painter->setPen(QPen(Qt::red));
332 QScopedPointer<Portal> portal;
343 for (
int yIndex = 0; yIndex < numLines; yIndex++) {
344 const vector<double> &line = buffer->
getLine(yIndex);
346 for (
int xIndex = 0; xIndex < (int)line.size(); xIndex++) {
347 int viewportPointX = xIndex + buffer->
bufferXYRect().left();
348 int viewportPointY = yIndex + buffer->
bufferXYRect().top();
350 double cubeSample =
Null;
351 double cubeLine =
Null;
353 cubeSample, cubeLine);
369 double yDnValue = (*portal)[0];
373 painter->drawPoint(viewportPointX, viewportPointY);
382 double xDnValue = (*portal)[0];
386 painter->drawPoint(viewportPointX, viewportPointY);
414 QScopedPointer<Portal> xCubePortal(
417 QScopedPointer<Portal> yCubePortal(
421 double cubeSample =
Null;
422 double cubeLine =
Null;
424 vp->
viewportToCube(mouseLoc.x(), mouseLoc.y(), cubeSample, cubeLine);
437 ASSERT(xCubePortal->size() == yCubePortal->size());
438 for (
int i = 0; i < xCubePortal->size(); i++) {
439 double x = (*xCubePortal)[i];
440 double y = (*yCubePortal)[i];
443 scatterData->
alarm(x, y);
552 if (
m_colorize->text().compare(
"Colorize") == 0) {
555 QwtLinearColorMap *colorMap =
new QwtLinearColorMap(Qt::darkCyan, Qt::red);
556 colorMap->addColorStop(DBL_EPSILON, Qt::cyan);
557 colorMap->addColorStop(0.3, Qt::green);
558 colorMap->addColorStop(0.50, Qt::yellow);
560 plot()->setCanvasBackground(Qt::darkCyan);
565 QwtLinearColorMap *colorMap =
new QwtLinearColorMap(Qt::black, Qt::white);
566 colorMap->addColorStop(DBL_EPSILON, Qt::darkGray);
568 plot()->setCanvasBackground(Qt::black);
586 if (
m_contour->text() ==
"Show Contour Lines") {
587 m_contour->setText(
"Hide Contour Lines");
588 m_spectrogram->setDisplayMode(QwtPlotSpectrogram::ContourMode,
true);
592 m_contour->setText(
"Show Contour Lines");
593 m_spectrogram->setDisplayMode(QwtPlotSpectrogram::ContourMode,
false);
714 connect(config, SIGNAL(finished(
int)),
715 config, SLOT(deleteLater()));
Cube display widget for certain Isis MDI applications.
bool isXCube(MdiCubeViewport *vp) const
Returns true if the viewport's cube is the cube currently being used on the x-axis.
void mouseMoveEvent(QMouseEvent *e)
When the mosue moves, this updates the alarming information and causes repaints on the cube viewports...
bool eventFilter(QObject *o, QEvent *e)
We override events done on the plot canvas for alarming purposes.
ViewportBuffer * grayBuffer()
Returns the gray viewport buffer (Will be NULL if in RGB mode.)
int m_yAxisCubeBand
The band on the Y-Axis cube used for the scatter plot.
bool m_alarmViewport
Alarm onto viewport... aka alarm plot->viewport.
Reads and stores visible DN values.
const double Null
Value for an Isis Null pixel.
AlarmRangeUnits m_alarmViewportUnits
Alarm plot->viewport current units.
void setAlarmViewportUnits(AlarmRangeUnits)
This sets the units to be used for alarming plot->viewport.
double yCubeMax() const
Return the max DN value for the y-axis cube's data range.
File name manipulation and expansion.
MenuOptions
There is a menu option for everything in the plot window's menu.
void colorPlot()
This method switches the color mode of the scatter plot from black and white to color and visa versa...
Buffer for containing a two dimensional section of an image.
void setAlarmingPlot(bool)
This enables or disables alarming viewport->plot.
virtual void paint(MdiCubeViewport *vp, QPainter *painter)
Paint plot curve information onto the viewport.
const std::vector< double > & getLine(int line)
Retrieves a line from the buffer.
int m_alarmPlotSamples
Alarm viewport->plot viewport sample box size.
QwtPlotZoomer * zoomer()
Get this window's plot's zoomer.
Namespace for the standard library.
int m_alarmPlotLines
Alarm viewport->plot viewport line box size.
AlarmRangeUnits alarmViewportUnits() const
This is the active alarming units for plot->viewport.
QPair< double, double > m_yCubeDnAlarmRange
The DN range of the Y-Axis Cube to be alarmed when painting.
bool m_alarmPlot
Alarm onto plot... aka alarm viewport->plot.
QRect bufferXYRect()
Returns a rect, in screen pixels, of the area this buffer covers.
double yCubeMin() const
Return the min DN value for the y-axis cube's data range.
QPair< int, int > alarmPlotBoxSize() const
This is the sample/line box sizes for alarming from viewport to plot.
int m_alarmViewportScreenHeight
Alarm plot->viewport Y (screen pixels) box size.
void setAlarmViewportDnBoxSize(double, double)
This sets the cube DN box size for alarming plot->viewport.
virtual bool eventFilter(QObject *o, QEvent *e)
This method filters the events of the objects it is connected to.
QPointer< QAction > m_colorize
The action for switching the scatter plot from B/W to color.
double xCubeMin() const
Return the min DN value for the x-axis cube's data range.
QwtInterval m_sampleRange
The sample range (1-based inclusive) of data used for the scatter plot.
void alarm(double x, double y)
Alarm the bin (highlight it) at the given x/y DN value.
void plotChanged()
Emitted every time there is a change to the plot window.
Alarming is a visible area around the mouse.
virtual void paint(MdiCubeViewport *vp, QPainter *painter)
If the viewport is showing the x axis cube data or y axis cube data, and alarming is enabled...
void read(Blob &blob) const
This method will read data from the specified Blob object.
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
void updateContourPen()
This sets the contour pen to an appropriate color based on the color of the plot (B/W v...
void setAlarmPlotBoxSize(int, int)
This sets the box size for alarming viewport->plot in cube samples/lines.
QPair< double, double > alarmViewportDnBoxSize() const
This is the alarming box size for plot->viewport in cube units (number of samples/lines).
bool IsSpecial(const double d)
Returns if the input pixel is special.
int m_xAxisCubeBand
The band on the X-Axis cube used for the scatter plot.
double m_alarmViewportYDnBoxSize
Alarm plot->viewport Y (Cube DN) box size.
This is the configuration dialog for alarming scatter plots between the plot window and cube viewport...
void mouseLeaveEvent(QMouseEvent *e)
When the mouse leaves the plot canvas we disable all alarming from plot->viewport.
AlarmRangeUnits
This enumeration differentiates alarming a strict cube DN box size from a screen region.
double m_alarmViewportXDnBoxSize
Alarm plot->viewport X (Cube DN) box size.
void forgetCubes()
This causes the window to lose it's pointers to the input cubes.
bool working()
This tests if queued actions exist in the viewport buffer.
QPair< int, int > alarmViewportScreenBoxSize() const
This is the alarming box size for plot->viewport in screen units.
PixelType pixelType() const
void setAlarmViewportScreenBoxSize(int, int)
This sets the screen pixel box size for alarming plot->viewport.
This is the QwtRasterData for a scatter plot.
Cube * m_xAxisCube
The cube associated with the X-Axis DN values.
double xCubeMax() const
Return the max DN value for the y-axis cube's data range.
QPair< double, double > m_xCubeDnAlarmRange
The DN range of the X-Axis Cube to be alarmed when painting.
void clearAlarms()
Forget all alarmed bins (viewport->plot).
void setMousePosition(MdiCubeViewport *vp, QPoint mouseLoc)
Saves the current mouse position in the viewport so that the plot can be alarmed around that position...
void disableAxisAutoScale()
This turns off scaling the x/y axes automatically.
Cube * m_yAxisCube
The cube associated with the Y-Axis DN values.
virtual QString fileName() const
Returns the opened cube's filename.
void showHideContour()
This method hides or displays the contour lines on the spectrogram.
Namespace for ISIS/Bullet specific routines.
bool alarmingPlot() const
This indicates if we are alarming from viewport to plot.
void setAlarmingViewport(bool)
This enables or disables alarming plot->viewport.
void replot()
Reset the scale of the plot, replot it and emit plot changed.
QwtInterval m_lineRange
The line range (1-based inclusive) of data used for the scatter plot.
bool alarmingViewport() const
This indicates if we are alarming from plot to viewport.
QwtPlot * plot()
Get the plot encapsulated by this PlotWindow.
void viewportToCube(int x, int y, double &sample, double &line) const
Turns a viewport into a cube.
QPointer< QAction > m_contour
The action for switching on and off contour lines.
QwtPlotSpectrogram * m_spectrogram
This is the scatter plot's Qwt plot item.
bool isYCube(MdiCubeViewport *vp) const
Returns true if the viewport's cube is the cube currently being used on the y-axis.
int m_alarmViewportScreenWidth
Alarm plot->viewport X (screen pixels) box size.
void configureAlarming()
Give the users an alarm config dialog to change the alarming settings.
IO Handler for Isis Cubes.