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 
13 namespace Isis {
14 
21  m_plotWindows(new QList< QPointer<ScatterPlotWindow> >) {
22  }
23 
24 
31  void ScatterPlotTool::setActionChecked(bool checked) {
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 
81  return m_action;
82  }
83 
84 
91  QWidget *ScatterPlotTool::createToolBarWidget(QStackedWidget *parent) {
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 
150  delete m_configDialog;
151  }
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 
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 
Isis::ScatterPlotTool::m_action
QPointer< QAction > m_action
The action which activates this tool.
Definition: ScatterPlotTool.h:54
Isis::MdiCubeViewport
Cube display widget for certain Isis MDI applications.
Definition: MdiCubeViewport.h:39
QWidget
QList
This is free and unencumbered software released into the public domain.
Definition: BoxcarCachingAlgorithm.h:13
Isis::Tool::cubeViewportList
CubeViewportList * cubeViewportList() const
Return the list of cubeviewports.
Definition: Tool.cpp:390
Isis::Tool
Base class for the Qisis tools.
Definition: Tool.h:67
Isis::ScatterPlotTool::createToolBarWidget
QWidget * createToolBarWidget(QStackedWidget *parent)
Create the toolbar options widget for this tool's options.
Definition: ScatterPlotTool.cpp:91
Isis::Tool::toolIconDir
QString toolIconDir() const
returns the path to the icon directory.
Definition: Tool.h:113
Isis::ScatterPlotTool::setActionChecked
void setActionChecked(bool checked)
Gives the programmer more flexibility on when the action button for this tool is checked or not.
Definition: ScatterPlotTool.cpp:31
Isis::ScatterPlotTool::mouseLeave
void mouseLeave()
The user moused out of the viewport.
Definition: ScatterPlotTool.cpp:173
Isis::ScatterPlotTool::m_plotWindows
QScopedPointer< QList< QPointer< ScatterPlotWindow > > > m_plotWindows
This is a list of all of the plot windows used for painting/alarming.
Definition: ScatterPlotTool.h:58
Isis::ScatterPlotTool::toolPadAction
QAction * toolPadAction(ToolPad *pad)
Configure the QAction for this tool.
Definition: ScatterPlotTool.cpp:59
Isis::ScatterPlotTool::paintViewport
virtual void paintViewport(MdiCubeViewport *vp, QPainter *painter)
When a viewport needs repainted this is called.
Definition: ScatterPlotTool.cpp:43
Isis::ScatterPlotTool::onScatterPlotConfigRejected
void onScatterPlotConfigRejected()
The user has cancelled creating a scatter plot.
Definition: ScatterPlotTool.cpp:149
Isis::ScatterPlotWindow
Scatter Plot Window.
Definition: ScatterPlotWindow.h:28
Isis::ScatterPlotWindow::paint
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,...
Definition: ScatterPlotWindow.cpp:316
Isis::ScatterPlotConfigDialog
This configuration dialog is for users to determine the scatter plot parameters required to create a ...
Definition: ScatterPlotConfigDialog.h:29
Isis::ScatterPlotTool::repaintViewports
void repaintViewports()
This is a helper method for asking every viewport to repaint.
Definition: ScatterPlotTool.cpp:186
Isis::ToolPad
Definition: ToolPad.h:14
Isis::ScatterPlotTool::onScatterPlotConfigAccepted
void onScatterPlotConfigAccepted()
The user has asked to create a scatter plot.
Definition: ScatterPlotTool.cpp:114
Isis::ScatterPlotTool::ScatterPlotTool
ScatterPlotTool(QWidget *parent)
ScatterPlotTool constructor.
Definition: ScatterPlotTool.cpp:20
Isis::ScatterPlotWindow::setMousePosition
void setMousePosition(MdiCubeViewport *vp, QPoint mouseLoc)
Saves the current mouse position in the viewport so that the plot can be alarmed around that position...
Definition: ScatterPlotWindow.cpp:405
Isis::ScatterPlotTool::showNewScatterPlotConfig
void showNewScatterPlotConfig()
Ask the user to give us information for a new scatter plot.
Definition: ScatterPlotTool.cpp:198
QObject
QVector
This is free and unencumbered software released into the public domain.
Definition: Calculator.h:18
Isis::ScatterPlotTool::mouseMove
void mouseMove(QPoint p, Qt::MouseButton)
The user has moved their mouse on the cube viewport.
Definition: ScatterPlotTool.cpp:160
QAction
Isis::Tool::cubeViewport
MdiCubeViewport * cubeViewport() const
Return the current cubeviewport.
Definition: Tool.h:197
Isis::ScatterPlotTool::toolAction
QAction * toolAction()
Get the action which activates this tool.
Definition: ScatterPlotTool.cpp:80
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::ScatterPlotTool::m_configDialog
QPointer< ScatterPlotConfigDialog > m_configDialog
This is the configuration dialog for a new scatter plot.
Definition: ScatterPlotTool.h:56