Isis 3.0 Programmer Reference
Back | Home
WindowTool.cpp
1 #include "WindowTool.h"
2 
3 #include <iostream>
4 
5 #include <QAction>
6 #include <QMenu>
7 #include <QMenuBar>
8 #include <QToolBar>
9 
10 #include "MdiCubeViewport.h"
11 #include "MainWindow.h"
12 #include "Workspace.h"
13 
14 namespace Isis {
21  WindowTool::WindowTool(QWidget *parent) : Tool(parent) {
22  p_cascadeWindows = new QAction(parent);
23  p_cascadeWindows->setText("&Cascade");
24  p_cascadeWindows->setEnabled(false);
25 
26  p_tileWindows = new QAction(parent);
27  p_tileWindows->setText("&Tile");
28  p_tileWindows->setEnabled(false);
29 
30  p_resizeWindows = new QAction(parent);
31  p_resizeWindows->setText("Resize");
32  p_resizeWindows->setEnabled(true);
33  connect(p_resizeWindows, SIGNAL(triggered()), this, SLOT(resizeWindows()));
34  QString text = "<b>Function: </b> Resize all linked viewports to the same \
35  size as the active viewport.";
36  p_resizeWindows->setWhatsThis(text);
37 
38  p_closeWindow = new QAction(parent);
39  p_closeWindow->setText("Close");
40  p_closeWindow->setShortcut(Qt::Key_F3);
41  p_closeWindow->setEnabled(false);
42 
43  p_closeAllWindows = new QAction(parent);
44  p_closeAllWindows->setText("Close All");
45  p_closeAllWindows->setShortcut(Qt::CTRL + Qt::Key_F3);
46  p_closeAllWindows->setEnabled(false);
47 
48  p_nextWindow = new QAction(parent);
49  p_nextWindow->setText("&Next");
50  p_nextWindow->setShortcut(Qt::Key_F5);
51  p_nextWindow->setEnabled(false);
52 
53  p_prevWindow = new QAction(parent);
54  p_prevWindow->setText("&Prev");
55  p_prevWindow->setShortcut(Qt::Key_F6);
56  p_prevWindow->setEnabled(false);
57 
58  QIcon icon;
59  icon.addPixmap(toolIconDir() + "/linked.png", QIcon::Normal, QIcon::On);
60  icon.addPixmap(toolIconDir() + "/unlinked.png", QIcon::Normal, QIcon::Off);
61  p_linkWindow = new QAction(parent);
62  p_linkWindow->setIcon(icon);
63  p_linkWindow->setText("&Link");
64  p_linkWindow->setToolTip("Link viewports");
65  text =
66  "<b>Function:</b> Used to link viewports. Some tools apply their \
67  functions to all linked viewports. For example, when the zoom tool \
68  is used on a linked viewport then all other linked viewports will zoom \
69  as well. \
70  <p><b>Shortcut:</b> Ctrl+L</p> \
71  <p><b>Hint:</b> The icons <img src=\"" +
72  toolIconDir() + "/linked.png\" width=22 height=22> and <img src=\"" +
73  toolIconDir() + "/unlinked.png\" width=22 height=22> at the left edge \
74  of each viewport titlebar indicate the current link state</p> \
75  <p><b>Tools using Link:</b> Zoom, Pan, Blink, and Advanced Tracking </p>";
76  p_linkWindow->setWhatsThis(text);
77  p_linkWindow->setShortcut(Qt::CTRL + Qt::Key_L);
78  p_linkWindow->setCheckable(true);
79  p_linkWindow->setEnabled(false);
80 
81  p_linkAllWindows = new QAction(parent);
82  p_linkAllWindows->setText("&Link All");
83  p_linkAllWindows->setToolTip("Link all viewports");
84  p_linkAllWindows->setWhatsThis("<b>Function: </b> Links all open viewports \
85  together. <p><b>Shortcut: </b> Ctrl+Shift+L");
86  p_linkAllWindows->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_L);
87  p_linkAllWindows->setEnabled(false);
88  connect(p_linkAllWindows, SIGNAL(triggered()), this, SLOT(linkWindows()));
89 
90  p_unlinkAllWindows = new QAction(parent);
91  p_unlinkAllWindows->setText("&Unlink All");
92  p_unlinkAllWindows->setToolTip("Unlink all viewports");
93  p_unlinkAllWindows->setWhatsThis("<b>Function: </b> Unlinks all open viewports. \
94  <p><b>Shortcut: </b> Ctrl+Shift+U");
95  p_unlinkAllWindows->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_U);
96  p_unlinkAllWindows->setEnabled(false);
97  connect(p_unlinkAllWindows, SIGNAL(triggered()), this, SLOT(unlinkWindows()));
98 
99  p_changeCursor = new QAction(parent);
100  p_changeCursor->setText("Change cursor to arrow.");
101  p_changeCursor->setWhatsThis("<b>Function: </b> Toggles the cursor shape between \
102  and arrow and crosshair cursor when cursor is over the \
103  viewport window.");
104  p_changeCursor->setEnabled(false);
105  connect(p_changeCursor, SIGNAL(triggered()), this, SLOT(changeCursor()));
106 
107  activate(true);
108  }
109 
110 
118  Tool::addTo(ws);
119  connect(p_cascadeWindows, SIGNAL(triggered()), ws->mdiArea(), SLOT(cascadeSubWindows()));
120  connect(p_tileWindows, SIGNAL(triggered()), ws->mdiArea(), SLOT(tileSubWindows()));
121  connect(p_prevWindow, SIGNAL(triggered()), ws->mdiArea(), SLOT(activatePreviousSubWindow()));
122  connect(p_nextWindow, SIGNAL(triggered()), ws->mdiArea(), SLOT(activateNextSubWindow()));
123  connect(p_closeWindow, SIGNAL(triggered()), ws->mdiArea(), SLOT(closeActiveSubWindow()));
124  connect(p_closeAllWindows, SIGNAL(triggered()), ws->mdiArea(), SLOT(closeAllSubWindows()));
125  connect(ws, SIGNAL(cubeViewportAdded(MdiCubeViewport *)),
126  this, SLOT(updateViewportCursor(MdiCubeViewport *)));
127  }
128 
129 
137  perm->addAction(p_linkWindow);
138  }
139 
140 
149  void WindowTool::addTo(QMenu *menu) {
150  menu->addAction(p_cascadeWindows);
151  menu->addAction(p_tileWindows);
152  menu->addAction(p_resizeWindows);
153  menu->addSeparator();
154 
155  menu->addAction(p_changeCursor);
156  menu->addSeparator();
157 
158  menu->addAction(p_nextWindow);
159  menu->addAction(p_prevWindow);
160  menu->addAction(p_closeWindow);
161  menu->addAction(p_closeAllWindows);
162  menu->addSeparator();
163 
164  menu->addAction(p_linkWindow);
165  menu->addAction(p_linkAllWindows);
166  menu->addAction(p_unlinkAllWindows);
167  }
168 
169 
177  connect(p_linkWindow, SIGNAL(toggled(bool)),
178  cubeViewport(), SLOT(setLinked(bool)));
179  connect(cvp, SIGNAL(linkChanging(bool)), p_linkWindow, SLOT(setChecked(bool)));
180  }
181 
182 
190  disconnect(p_linkWindow, SIGNAL(toggled(bool)),
191  cubeViewport(), SLOT(setLinked(bool)));
192  disconnect(cvp, SIGNAL(linkChanging(bool)), p_linkWindow, SLOT(setChecked(bool)));
193  }
194 
195 
196  void newViewportOpened(CubeViewport *cvp) {
197 
198  }
199 
200 
206  MdiCubeViewport *d;
207  for(int i = 0; i < (int)cubeViewportList()->size(); i++) {
208  d = (*(cubeViewportList()))[i];
209  d->setLinked(true);
210  }
211  }
212 
213 
219  MdiCubeViewport *d;
220  for(int i = 0; i < (int)cubeViewportList()->size(); i++) {
221  d = (*(cubeViewportList()))[i];
222  d->setLinked(false);
223  }
224  }
225 
231  if(p_changeCursor->text() == "Change cursor to arrow.") {
232  p_changeCursor->setText("Change cursor to crosshair.");
233  }
234  else {
235  p_changeCursor->setText("Change cursor to arrow.");
236  }
237 
238  for(int i = 0; i < (int)cubeViewportList()->size(); i++) {
239  updateViewportCursor(cubeViewportList()->at(i));
240  }
241  }
242 
243 
244  void WindowTool::updateViewportCursor(MdiCubeViewport *cvp) {
245  if (p_changeCursor->text() == "Change cursor to crosshair." &&
246  cvp->viewport()->cursor().shape() != Qt::ArrowCursor) {
247  cvp->viewport()->setCursor(Qt::ArrowCursor);
248  }
249  else if (p_changeCursor->text() == "Change cursor to arrow." &&
250  cvp->viewport()->cursor().shape() != Qt::CrossCursor) {
251  cvp->viewport()->setCursor(Qt::CrossCursor);
252  }
253  }
254 
255 
262  MdiCubeViewport *d;
263  QSize size = cubeViewport()->parentWidget()->size();
264 
265  for(int i = 0; i < (int)cubeViewportList()->size(); i++) {
266  d = (*(cubeViewportList()))[i];
267  if(d->isLinked()) d->parentWidget()->parentWidget()->resize(size);
268  }
269  }
270 
271 
277  if(cubeViewport() == NULL) {
278  p_linkWindow->setChecked(false);
279  p_linkWindow->setEnabled(false);
280  p_linkAllWindows->setEnabled(false);
281  p_unlinkAllWindows->setEnabled(false);
282  p_cascadeWindows->setEnabled(false);
283  p_tileWindows->setEnabled(false);
284  p_resizeWindows->setEnabled(false);
285  p_closeWindow->setEnabled(false);
286  p_closeAllWindows->setEnabled(false);
287  p_nextWindow->setEnabled(false);
288  p_prevWindow->setEnabled(false);
289  p_changeCursor->setEnabled(false);
290  }
291  else {
292  p_cascadeWindows->setEnabled(true);
293  p_tileWindows->setEnabled(true);
294  p_resizeWindows->setEnabled(true);
295  p_closeWindow->setEnabled(true);
296  p_closeAllWindows->setEnabled(true);
297  p_changeCursor->setEnabled(true);
298 
299  if(cubeViewportList()->size() > 1) {
300  p_linkWindow->setEnabled(true);
301  p_linkAllWindows->setEnabled(true);
302  p_unlinkAllWindows->setEnabled(true);
303  p_nextWindow->setEnabled(true);
304  p_prevWindow->setEnabled(true);
305  p_linkWindow->setChecked(cubeViewport()->isLinked());
306  }
307  else {
308  p_linkWindow->setEnabled(false);
309  p_linkAllWindows->setEnabled(false);
310  p_unlinkAllWindows->setEnabled(false);
311  p_nextWindow->setEnabled(false);
312  p_prevWindow->setEnabled(false);
313  }
314  }
315  }
316 }
Cube display widget for certain Isis MDI applications.
void changeCursor()
toggles the cursor from an arrow to a crosshair.
Definition: WindowTool.cpp:230
CubeViewportList * cubeViewportList() const
Return the list of cubeviewports.
Definition: Tool.cpp:390
void resizeWindows()
Resizes all the viewport windows to the active viewport window size.
Definition: WindowTool.cpp:261
QAction * p_unlinkAllWindows
unlink all windows action
Definition: WindowTool.h:58
void removeConnections(MdiCubeViewport *cvp)
Removes the connections from the cube viewport.
Definition: WindowTool.cpp:189
void linkWindows()
Links all viewport windows in the workspace.
Definition: WindowTool.cpp:205
Widget to display Isis cubes for qt apps.
Definition: CubeViewport.h:121
QAction * p_prevWindow
previous window action
Definition: WindowTool.h:52
QAction * p_tileWindows
tile windows action
Definition: WindowTool.h:50
void setLinked(bool b)
Change the linked state of the viewport.
QAction * p_closeWindow
close window action
Definition: WindowTool.h:54
MdiCubeViewport * cubeViewport() const
Return the current cubeviewport.
Definition: Tool.h:211
void addToPermanent(QToolBar *toolbar)
Adds the link window action to the tool bar.
Definition: WindowTool.cpp:136
bool isLinked() const
Is the viewport linked with other viewports.
void addTo(ViewportMainWindow *mw)
Adds the tool to the application.
Definition: Tool.cpp:78
QAction * p_changeCursor
changes the cursor when it moves over the viewport
Definition: WindowTool.h:59
QAction * p_linkAllWindows
link all windows action
Definition: WindowTool.h:57
WindowTool(QWidget *parent)
WindowTool constructor.
Definition: WindowTool.cpp:21
void unlinkWindows()
Unlinks all the viewport windows in the workspace.
Definition: WindowTool.cpp:218
QAction * p_linkWindow
link window action
Definition: WindowTool.h:56
QString toolIconDir() const
returns the path to the icon directory.
Definition: Tool.h:127
void addConnections(MdiCubeViewport *cvp)
Adds the connections to the cube viewport.
Definition: WindowTool.cpp:176
void addTo(QMenu *menu)
Adds the cascade windows, tile windows, resize windows, next window, previous window, close window, and close all windows actions to the menu.
Definition: WindowTool.cpp:149
void updateTool()
Updates the WindowTool.
Definition: WindowTool.cpp:276
Base class for the Qisis tools.
Definition: Tool.h:81
QAction * p_nextWindow
next window action
Definition: WindowTool.h:53
void activate(bool)
Activates the tool.
Definition: Tool.cpp:131
QAction * p_resizeWindows
resize windows action
Definition: WindowTool.h:51
QAction * p_cascadeWindows
cascade windows action
Definition: WindowTool.h:49
QAction * p_closeAllWindows
close all action
Definition: WindowTool.h:55

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:31:45