1#include "ScatterPlotWindow.h"
6#include <qwt_color_map.h>
7#include <qwt_interval.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>
18#include "MdiCubeViewport.h"
20#include "ScatterPlotAlarmConfigDialog.h"
21#include "ScatterPlotData.h"
22#include "ScatterPlotTool.h"
23#include "ViewportBuffer.h"
24#include "ViewportMainWindow.h"
46 Cube *xAxisCube,
int xAxisBand,
int xAxisBinCount,
47 Cube *yAxisCube,
int yAxisBand,
int yAxisBinCount,
48 QwtInterval sampleRange, QwtInterval lineRange,
53 ~BackgroundSwitchMenuOption &
54 ~ShowTableMenuOption &
55 ~ClearPlotMenuOption &
56 ~ShowHideMarkersMenuOption &
57 ~ShowHideCurvesMenuOption &
58 ~ConfigurePlotMenuOption)) {
73 xAxisCube, xAxisBand, xAxisBinCount,
74 yAxisCube, yAxisBand, yAxisBinCount,
75 sampleRange, lineRange);
90 QwtScaleWidget *rightAxis =
plot()->axisWidget(QwtPlot::yRight);
91 rightAxis->setTitle(
"Counts");
92 rightAxis->setColorBarEnabled(
true);
96 plot()->setAxisScale(QwtPlot::yRight,
99 plot()->enableAxis(QwtPlot::yRight);
101 plot()->setAxisTitle(QwtPlot::xBottom,
102 QFileInfo(xAxisCube->
fileName()).baseName() +
" Band " +
103 QString::number(xAxisBand) +
" " +
104 plot()->axisTitle(QwtPlot::xBottom).text());
105 plot()->setAxisTitle(QwtPlot::yLeft,
106 QFileInfo(yAxisCube->
fileName()).baseName() +
" Band " +
107 QString::number(yAxisBand) +
" " +
108 plot()->axisTitle(QwtPlot::yLeft).text());
110 QList<double> contourLevels;
111 QwtInterval range =
m_spectrogram->data()->interval(Qt::ZAxis);
113 for (
double level = range.minValue();
114 level < range.maxValue();
115 level += ((range.maxValue() - range.minValue()) / 6.0)) {
116 contourLevels += level;
123 m_colorize->setIcon(QPixmap(
FileName(
"$ISISROOT/appdata/images/icons/rgb.png").expanded()));
128 m_contour->setText(
"Hide Contour Lines");
130 QPixmap(
FileName(
"$ISISROOT/appdata/images/icons/scatterplotcontour.png").expanded()));
135 configureAlarmingAct->setText(
"Change Alarming");
136 configureAlarmingAct->setIcon(
137 QPixmap(
FileName(
"$ISISROOT/appdata/images/icons/scatterplotalarming.png").expanded()));
138 connect(configureAlarmingAct, SIGNAL(triggered()),
141 foreach (
QAction *menuAction, menuBar()->actions()) {
142 if (menuAction->text() ==
"&Options") {
143 QMenu *optsMenu = qobject_cast<QMenu *>(menuAction->parentWidget());
146 optsMenu->addAction(configureAlarmingAct);
153 plot()->canvas()->installEventFilter(
this);
154 plot()->canvas()->setMouseTracking(
true);
158 QString instanceName = windowTitle();
159 FileName config(
"$HOME/.Isis/qview/" + instanceName +
".config");
160 QSettings settings(config.expanded(),
161 QSettings::NativeFormat);
162 m_alarmPlot = settings.value(
"alarmOntoPlot",
true).toBool();
172 settings.value(
"alarmViewportScreenWidth", 5).toInt();
174 settings.value(
"alarmViewportScreenHeight", 5).toInt();
177 settings.value(
"alarmViewportXDnBoxSize", 1.0).toDouble();
179 settings.value(
"alarmViewportYDnBoxSize", 1.0).toDouble();
183 ScatterPlotWindow::~ScatterPlotWindow() {
184 QString instanceName = windowTitle();
185 FileName config(
"$HOME/.Isis/qview/" + instanceName +
".config");
186 QSettings settings(config.expanded(),
187 QSettings::NativeFormat);
286 if (o ==
plot()->canvas()) {
288 case QEvent::MouseMove: {
289 if (((QMouseEvent *)e)->buttons() == Qt::NoButton)
293 case QEvent::Leave: {
326 painter->setPen(QPen(Qt::red));
333 QScopedPointer<Portal> portal;
344 for (
int yIndex = 0; yIndex < numLines; yIndex++) {
345 const vector<double> &line = buffer->
getLine(yIndex);
347 for (
int xIndex = 0; xIndex < (int)line.size(); xIndex++) {
348 int viewportPointX = xIndex + buffer->
bufferXYRect().left();
349 int viewportPointY = yIndex + buffer->
bufferXYRect().top();
351 double cubeSample =
Null;
352 double cubeLine =
Null;
353 vp->viewportToCube(viewportPointX, viewportPointY,
354 cubeSample, cubeLine);
370 double yDnValue = (*portal)[0];
374 painter->drawPoint(viewportPointX, viewportPointY);
383 double xDnValue = (*portal)[0];
387 painter->drawPoint(viewportPointX, viewportPointY);
415 QScopedPointer<Portal> xCubePortal(
418 QScopedPointer<Portal> yCubePortal(
422 double cubeSample =
Null;
423 double cubeLine =
Null;
425 vp->viewportToCube(mouseLoc.x(), mouseLoc.y(), cubeSample, cubeLine);
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) {
553 m_colorize->setIcon(QPixmap(
FileName(
"$ISISROOT/appdata/images/icons/gray.png").expanded()));
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);
563 m_colorize->setIcon(QPixmap(
FileName(
"$ISISROOT/appdata/images/icons/rgb.png").expanded()));
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()));
IO Handler for Isis Cubes.
PixelType pixelType() const
void read(Blob &blob, const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
This method will read data from the specified Blob object.
virtual QString fileName() const
Returns the opened cube's filename.
File name manipulation and expansion.
Cube display widget for certain Isis MDI applications.
void plotChanged()
Emitted every time there is a change to the plot window.
MenuOptions
There is a menu option for everything in the plot window's menu.
void replot()
Reset the scale of the plot, replot it and emit plot changed.
virtual bool eventFilter(QObject *o, QEvent *e)
This method filters the events of the objects it is connected to.
virtual void paint(MdiCubeViewport *vp, QPainter *painter)
Paint plot curve information onto the viewport.
void disableAxisAutoScale()
This turns off scaling the x/y axes automatically.
QwtPlot * plot()
Get the plot encapsulated by this PlotWindow.
QwtPlotZoomer * zoomer()
Get this window's plot's zoomer.
Buffer for containing a two dimensional section of an image.
This is the configuration dialog for alarming scatter plots between the plot window and cube viewport...
This is the QwtRasterData for a scatter plot.
void clearAlarms()
Forget all alarmed bins (viewport->plot).
double xCubeMax() const
Return the max DN value for the y-axis cube's data range.
double yCubeMin() const
Return the min DN value for the y-axis cube's data range.
double xCubeMin() const
Return the min DN value for the x-axis cube's data range.
double yCubeMax() const
Return the max DN value for the y-axis cube's data range.
QPointer< QAction > m_contour
The action for switching on and off contour lines.
int m_alarmViewportScreenHeight
Alarm plot->viewport Y (screen pixels) box size.
QPair< double, double > m_xCubeDnAlarmRange
The DN range of the X-Axis Cube to be alarmed when painting.
ScatterPlotWindow(QString title, Cube *xAxisCube, int xAxisBand, int xAxisBinCount, Cube *yAxisCube, int yAxisBand, int yAxisBinCount, QwtInterval sampleRange, QwtInterval lineRange, QWidget *parent)
Create a scatter plot window with the given data.
void setAlarmViewportScreenBoxSize(int, int)
This sets the screen pixel box size for alarming plot->viewport.
Cube * m_xAxisCube
The cube associated with the X-Axis DN values.
Cube * m_yAxisCube
The cube associated with the Y-Axis DN values.
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,...
QPointer< QAction > m_colorize
The action for switching the scatter plot from B/W to color.
void setAlarmingViewport(bool)
This enables or disables alarming plot->viewport.
bool m_alarmPlot
Alarm onto plot... aka alarm viewport->plot.
int m_alarmViewportScreenWidth
Alarm plot->viewport X (screen pixels) box size.
void updateContourPen()
This sets the contour pen to an appropriate color based on the color of the plot (B/W v.
bool alarmingPlot() const
This indicates if we are alarming from viewport to plot.
QPair< double, double > alarmViewportDnBoxSize() const
This is the alarming box size for plot->viewport in cube units (number of samples/lines).
AlarmRangeUnits
This enumeration differentiates alarming a strict cube DN box size from a screen region.
@ ScreenUnits
Alarming is a visible area around the mouse.
void colorPlot()
This method switches the color mode of the scatter plot from black and white to color and visa versa.
QPair< double, double > m_yCubeDnAlarmRange
The DN range of the Y-Axis Cube to be alarmed when painting.
void mouseMoveEvent(QMouseEvent *e)
When the mosue moves, this updates the alarming information and causes repaints on the cube viewports...
bool alarmingViewport() const
This indicates if we are alarming from plot to viewport.
void setAlarmPlotBoxSize(int, int)
This sets the box size for alarming viewport->plot in cube samples/lines.
void setMousePosition(MdiCubeViewport *vp, QPoint mouseLoc)
Saves the current mouse position in the viewport so that the plot can be alarmed around that position...
QwtInterval m_sampleRange
The sample range (1-based inclusive) of data used for the scatter plot.
QPair< int, int > alarmPlotBoxSize() const
This is the sample/line box sizes for alarming from viewport to plot.
void setAlarmViewportDnBoxSize(double, double)
This sets the cube DN box size for alarming plot->viewport.
int m_yAxisCubeBand
The band on the Y-Axis cube used for the scatter plot.
bool isXCube(MdiCubeViewport *vp) const
Returns true if the viewport's cube is the cube currently being used on the x-axis.
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.
void configureAlarming()
Give the users an alarm config dialog to change the alarming settings.
double m_alarmViewportXDnBoxSize
Alarm plot->viewport X (Cube DN) box size.
bool eventFilter(QObject *o, QEvent *e)
We override events done on the plot canvas for alarming purposes.
QwtInterval m_lineRange
The line range (1-based inclusive) of data used for the scatter plot.
void forgetCubes()
This causes the window to lose it's pointers to the input cubes.
bool isYCube(MdiCubeViewport *vp) const
Returns true if the viewport's cube is the cube currently being used on the y-axis.
void showHideContour()
This method hides or displays the contour lines on the spectrogram.
QPair< int, int > alarmViewportScreenBoxSize() const
This is the alarming box size for plot->viewport in screen units.
void setAlarmingPlot(bool)
This enables or disables alarming viewport->plot.
AlarmRangeUnits m_alarmViewportUnits
Alarm plot->viewport current units.
bool m_alarmViewport
Alarm onto viewport... aka alarm plot->viewport.
void mouseLeaveEvent(QMouseEvent *e)
When the mouse leaves the plot canvas we disable all alarming from plot->viewport.
void setAlarmViewportUnits(AlarmRangeUnits)
This sets the units to be used for alarming plot->viewport.
int m_alarmPlotSamples
Alarm viewport->plot viewport sample box size.
QwtPlotSpectrogram * m_spectrogram
This is the scatter plot's Qwt plot item.
int m_alarmPlotLines
Alarm viewport->plot viewport line box size.
AlarmRangeUnits alarmViewportUnits() const
This is the active alarming units for plot->viewport.
Reads and stores visible DN values.
const std::vector< double > & getLine(int line)
Retrieves a line from the buffer.
QRect bufferXYRect()
Returns a rect, in screen pixels, of the area this buffer covers.
bool working()
This tests if queued actions exist in the viewport buffer.
This is free and unencumbered software released into the public domain.
const double Null
Value for an Isis Null pixel.
bool IsSpecial(const double d)
Returns if the input pixel is special.
Namespace for the standard library.