  | 
  
    Isis 3 Programmer Reference
    
   | 
 
 
 
 
    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> 
   16 #include "Histogram.h" 
   17 #include "MdiCubeViewport.h" 
   19 #include "ScatterPlotAlarmConfigDialog.h" 
   20 #include "ScatterPlotData.h" 
   21 #include "ScatterPlotTool.h" 
   22 #include "ViewportBuffer.h" 
   23 #include "ViewportMainWindow.h" 
   24 #include "Workspace.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;
 
  122     m_colorize->setIcon(QPixmap(
FileName(
"$ISISROOT/appdata/images/icons/rgb.png").expanded()));
 
  127     m_contour->setText(
"Hide Contour Lines");
 
  129         QPixmap(
FileName(
"$ISISROOT/appdata/images/icons/scatterplotcontour.png").expanded()));
 
  134     configureAlarmingAct->setText(
"Change Alarming");
 
  135     configureAlarmingAct->setIcon(
 
  136         QPixmap(
FileName(
"$ISISROOT/appdata/images/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) {
 
  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()));
 
  
 
int m_yAxisCubeBand
The band on the Y-Axis cube used for the scatter plot.
 
void configureAlarming()
Give the users an alarm config dialog to change the alarming settings.
 
void setAlarmViewportUnits(AlarmRangeUnits)
This sets the units to be used for alarming plot->viewport.
 
Reads and stores visible DN values.
 
Cube display widget for certain Isis MDI applications.
 
QPointer< QAction > m_contour
The action for switching on and off contour lines.
 
virtual QString fileName() const
Returns the opened cube's filename.
 
const std::vector< double > & getLine(int line)
Retrieves a line from the buffer.
 
void mouseMoveEvent(QMouseEvent *e)
When the mosue moves, this updates the alarming information and causes repaints on the cube viewports...
 
int m_alarmViewportScreenWidth
Alarm plot->viewport X (screen pixels) box size.
 
bool m_alarmViewport
Alarm onto viewport... aka alarm plot->viewport.
 
Buffer for containing a two dimensional section of an image.
 
void setAlarmingPlot(bool)
This enables or disables alarming viewport->plot.
 
void read(Blob &blob, const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
This method will read data from the specified Blob object.
 
File name manipulation and expansion.
 
AlarmRangeUnits m_alarmViewportUnits
Alarm plot->viewport current units.
 
QPair< int, int > alarmPlotBoxSize() const
This is the sample/line box sizes for alarming from viewport to plot.
 
QPair< double, double > m_yCubeDnAlarmRange
The DN range of the Y-Axis Cube to be alarmed when painting.
 
MenuOptions
There is a menu option for everything in the plot window's menu.
 
double xCubeMax() const
Return the max DN value for the y-axis cube's data range.
 
void colorPlot()
This method switches the color mode of the scatter plot from black and white to color and visa versa.
 
QPointer< QAction > m_colorize
The action for switching the scatter plot from B/W to color.
 
int m_alarmPlotSamples
Alarm viewport->plot viewport sample box size.
 
void clearAlarms()
Forget all alarmed bins (viewport->plot).
 
AlarmRangeUnits alarmViewportUnits() const
This is the active alarming units for plot->viewport.
 
int m_alarmViewportScreenHeight
Alarm plot->viewport Y (screen pixels) box size.
 
bool IsSpecial(const double d)
Returns if the input pixel is special.
 
QwtPlotZoomer * zoomer()
Get this window's plot's zoomer.
 
int m_alarmPlotLines
Alarm viewport->plot viewport line box size.
 
double m_alarmViewportYDnBoxSize
Alarm plot->viewport Y (Cube DN) box size.
 
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
 
bool m_alarmPlot
Alarm onto plot... aka alarm viewport->plot.
 
Cube * m_xAxisCube
The cube associated with the X-Axis DN values.
 
QPair< int, int > alarmViewportScreenBoxSize() const
This is the alarming box size for plot->viewport in screen units.
 
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,...
 
QwtInterval m_sampleRange
The sample range (1-based inclusive) of data used for the scatter plot.
 
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).
 
int m_xAxisCubeBand
The band on the X-Axis cube used for the scatter plot.
 
double yCubeMin() const
Return the min DN value for the y-axis cube's data range.
 
double m_alarmViewportXDnBoxSize
Alarm plot->viewport X (Cube DN) box size.
 
void setAlarmViewportDnBoxSize(double, double)
This sets the cube DN box size for alarming plot->viewport.
 
AlarmRangeUnits
This enumeration differentiates alarming a strict cube DN box size from a screen region.
 
Cube * m_yAxisCube
The cube associated with the Y-Axis DN values.
 
This is the QwtRasterData for a scatter plot.
 
IO Handler for Isis Cubes.
 
void updateContourPen()
This sets the contour pen to an appropriate color based on the color of the plot (B/W v.
 
void disableAxisAutoScale()
This turns off scaling the x/y axes automatically.
 
QRect bufferXYRect()
Returns a rect, in screen pixels, of the area this buffer covers.
 
const double Null
Value for an Isis Null pixel.
 
double xCubeMin() const
Return the min DN value for the x-axis cube's data range.
 
QwtPlot * plot()
Get the plot encapsulated by this PlotWindow.
 
void forgetCubes()
This causes the window to lose it's pointers to the input cubes.
 
This is the configuration dialog for alarming scatter plots between the plot window and cube viewport...
 
void setAlarmViewportScreenBoxSize(int, int)
This sets the screen pixel box size for alarming plot->viewport.
 
bool alarmingViewport() const
This indicates if we are alarming from plot to viewport.
 
double yCubeMax() const
Return the max DN value for the y-axis cube's data range.
 
Namespace for the standard library.
 
QPair< double, double > m_xCubeDnAlarmRange
The DN range of the X-Axis Cube to be alarmed when painting.
 
PixelType pixelType() const
 
This is free and unencumbered software released into the public domain.
 
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 mouseLeaveEvent(QMouseEvent *e)
When the mouse leaves the plot canvas we disable all alarming from plot->viewport.
 
bool isXCube(MdiCubeViewport *vp) const
Returns true if the viewport's cube is the cube currently being used on the x-axis.
 
void viewportToCube(int x, int y, double &sample, double &line) const
Turns a viewport into a cube.
 
@ ScreenUnits
Alarming is a visible area around the mouse.
 
ViewportBuffer * grayBuffer()
Returns the gray viewport buffer (Will be NULL if in RGB mode.)
 
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.
 
virtual bool eventFilter(QObject *o, QEvent *e)
This method filters the events of the objects it is connected to.
 
void plotChanged()
Emitted every time there is a change to the plot window.
 
This is free and unencumbered software released into the public domain.
 
void showHideContour()
This method hides or displays the contour lines on the spectrogram.
 
bool eventFilter(QObject *o, QEvent *e)
We override events done on the plot canvas for alarming purposes.
 
QwtPlotSpectrogram * m_spectrogram
This is the scatter plot's Qwt plot item.
 
void alarm(double x, double y)
Alarm the bin (highlight it) at the given x/y DN value.
 
bool alarmingPlot() const
This indicates if we are alarming from viewport to plot.
 
virtual void paint(MdiCubeViewport *vp, QPainter *painter)
Paint plot curve information onto the viewport.
 
bool working()
This tests if queued actions exist in the viewport buffer.
 
bool isYCube(MdiCubeViewport *vp) const
Returns true if the viewport's cube is the cube currently being used on the y-axis.
 
void setAlarmingViewport(bool)
This enables or disables alarming plot->viewport.