Isis 3 Programmer Reference
ScatterPlotTool.cpp
1#include "ScatterPlotTool.h"
2
3#include <QAction>
4#include <QHBoxLayout>
5#include <QPushButton>
6
7#include "IString.h"
8#include "MdiCubeViewport.h"
9#include "ScatterPlotConfigDialog.h"
10#include "ScatterPlotWindow.h"
11#include "ToolPad.h"
12
13namespace Isis {
14
21 m_plotWindows(new QList< QPointer<ScatterPlotWindow> >) {
22 }
23
24
32 m_action->setChecked(checked);
33 }
34
35
43 void ScatterPlotTool::paintViewport(MdiCubeViewport *vp, QPainter *painter) {
44 m_plotWindows->removeAll(NULL);
45
46 foreach (ScatterPlotWindow *window, *m_plotWindows) {
47 window->paint(vp, painter);
48 }
49 }
50
51
60 m_action = new QAction(toolpad);
61 m_action->setIcon(QPixmap(toolIconDir() + "/scatterplot.png"));
62 m_action->setToolTip("Scatter Plot");
63 //action->setShortcut(Qt::Key_C);
64 connect(m_action, SIGNAL(triggered()),
65 this, SLOT(showNewScatterPlotConfig()));
66
67 QString text =
68 "<b>Function:</b> Compare two bands of same image or of a different image. \
69 <p><b>Shortcut:</b>nonexsistant right now</p> ";
70 m_action->setWhatsThis(text);
71 return m_action;
72 }
73
74
83
84
92 QWidget *wrapper = new QWidget;
93
94 QPushButton *create = new QPushButton("New Scatter Plot");
95 connect(create, SIGNAL(clicked()),
96 this, SLOT(showNewScatterPlotConfig()));
97
98
99 QHBoxLayout *layout = new QHBoxLayout(wrapper);
100 layout->setMargin(0);
101
102 layout->addWidget(create);
103
104 layout->addStretch(1);
105 wrapper->setLayout(layout);
106 return wrapper;
107 }
108
109
115 try {
116 if (m_configDialog) {
117 ScatterPlotWindow *window = new ScatterPlotWindow("Scatter Plot",
118 m_configDialog->xAxisCube(), m_configDialog->xAxisCubeBand(),
119 m_configDialog->xAxisBinCount(), m_configDialog->yAxisCube(),
120 m_configDialog->yAxisCubeBand(), m_configDialog->yAxisBinCount(),
121 m_configDialog->sampleRange(), m_configDialog->lineRange(),
122 qobject_cast<QWidget *>(parent()));
123 connect(window, SIGNAL(closed()), window, SLOT(deleteLater()));
124 connect(window, SIGNAL(plotChanged()),
125 this, SLOT(repaintViewports()));
126 connect(m_configDialog->xAxisCubeViewport(),
127 SIGNAL(destroyed(QObject *)),
128 window, SLOT(forgetCubes()));
129 connect(m_configDialog->yAxisCubeViewport(),
130 SIGNAL(destroyed(QObject *)),
131 window, SLOT(forgetCubes()));
132
133 delete m_configDialog;
134 m_plotWindows->append(window);
135 window->show();
136 }
137 }
138 catch (...) {
139 delete m_configDialog;
140 m_configDialog = NULL;
141 }
142 }
143
144
152
153
160 void ScatterPlotTool::mouseMove(QPoint p, Qt::MouseButton) {
161 m_plotWindows->removeAll(NULL);
162
163 foreach (ScatterPlotWindow *window, *m_plotWindows) {
164 window->setMousePosition(cubeViewport(), p);
165 }
166 }
167
168
174 m_plotWindows->removeAll(NULL);
175
176 foreach (ScatterPlotWindow *window, *m_plotWindows) {
177 window->setMousePosition(NULL, QPoint());
178 }
179 }
180
181
187 QVector<MdiCubeViewport *> allViewports = *cubeViewportList();
188
189 foreach (MdiCubeViewport * viewport, allViewports) {
190 viewport->viewport()->repaint();
191 }
192 }
193
194
199 try {
200 if (!m_configDialog) {
202 cubeViewport(), workspace());
203 connect(m_configDialog, SIGNAL(accepted()),
204 this, SLOT(onScatterPlotConfigAccepted()));
205 connect(m_configDialog, SIGNAL(rejected()),
206 this, SLOT(onScatterPlotConfigRejected()));
207 m_configDialog->show();
208 }
209 else {
210 m_configDialog->activateWindow();
211 }
212 }
213 catch (...) {
214 m_configDialog = NULL;
215 throw;
216 }
217 }
218}
219
Cube display widget for certain Isis MDI applications.
This configuration dialog is for users to determine the scatter plot parameters required to create a ...
void mouseLeave()
The user moused out of the viewport.
virtual void paintViewport(MdiCubeViewport *vp, QPainter *painter)
When a viewport needs repainted this is called.
QWidget * createToolBarWidget(QStackedWidget *parent)
Create the toolbar options widget for this tool's options.
void onScatterPlotConfigAccepted()
The user has asked to create a scatter plot.
void setActionChecked(bool checked)
Gives the programmer more flexibility on when the action button for this tool is checked or not.
QAction * toolAction()
Get the action which activates this tool.
void showNewScatterPlotConfig()
Ask the user to give us information for a new scatter plot.
QPointer< ScatterPlotConfigDialog > m_configDialog
This is the configuration dialog for a new scatter plot.
void repaintViewports()
This is a helper method for asking every viewport to repaint.
QPointer< QAction > m_action
The action which activates this tool.
void mouseMove(QPoint p, Qt::MouseButton)
The user has moved their mouse on the cube viewport.
QScopedPointer< QList< QPointer< ScatterPlotWindow > > > m_plotWindows
This is a list of all of the plot windows used for painting/alarming.
ScatterPlotTool(QWidget *parent)
ScatterPlotTool constructor.
QAction * toolPadAction(ToolPad *pad)
Configure the QAction for this tool.
void onScatterPlotConfigRejected()
The user has cancelled creating a scatter plot.
Scatter Plot Window.
Base class for the Qisis tools.
Definition Tool.h:67
CubeViewportList * cubeViewportList() const
Return the list of cubeviewports.
Definition Tool.cpp:390
MdiCubeViewport * cubeViewport() const
Return the current cubeviewport.
Definition Tool.h:197
QString toolIconDir() const
returns the path to the icon directory.
Definition Tool.h:113
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16