File failed to load: https://isis.astrogeology.usgs.gov/9.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
WindowTool.cpp
1#include "WindowTool.h"
2
3#include <iostream>
4
5#include <QAction>
6#include <QList>
7#include <QMdiArea>
8#include <QMdiSubWindow>
9#include <QMenu>
10#include <QMenuBar>
11#include <QPoint>
12#include <QRect>
13#include <QToolBar>
14
15#include "MdiCubeViewport.h"
16#include "MainWindow.h"
17#include "Workspace.h"
18
19namespace Isis {
26 WindowTool::WindowTool(QWidget *parent) : Tool(parent) {
27 p_cascadeWindows = new QAction(parent);
28 p_cascadeWindows->setText("&Cascade");
29 p_cascadeWindows->setEnabled(false);
30
31 p_tileWindows = new QAction(parent);
32 p_tileWindows->setText("&Tile");
33 p_tileWindows->setEnabled(false);
34
35 p_resizeWindows = new QAction(parent);
36 p_resizeWindows->setText("Resize");
37 p_resizeWindows->setEnabled(true);
38 connect(p_resizeWindows, SIGNAL(triggered()), this, SLOT(resizeWindows()));
39 QString text = "<b>Function: </b> Resize all linked viewports to the same \
40 size as the active viewport.";
41 p_resizeWindows->setWhatsThis(text);
42
43 p_closeWindow = new QAction(parent);
44 p_closeWindow->setText("Close");
45 p_closeWindow->setShortcut(Qt::Key_F3);
46 p_closeWindow->setEnabled(false);
47
48 p_closeAllWindows = new QAction(parent);
49 p_closeAllWindows->setText("Close All");
50 p_closeAllWindows->setShortcut(Qt::CTRL + Qt::Key_F3);
51 p_closeAllWindows->setEnabled(false);
52
53 p_nextWindow = new QAction(parent);
54 p_nextWindow->setText("&Next");
55 p_nextWindow->setShortcut(Qt::Key_F5);
56 p_nextWindow->setEnabled(false);
57
58 p_prevWindow = new QAction(parent);
59 p_prevWindow->setText("&Prev");
60 p_prevWindow->setShortcut(Qt::Key_F6);
61 p_prevWindow->setEnabled(false);
62
63 QIcon icon;
64 icon.addPixmap(toolIconDir() + "/linked.png", QIcon::Normal, QIcon::On);
65 icon.addPixmap(toolIconDir() + "/unlinked.png", QIcon::Normal, QIcon::Off);
66 p_linkWindow = new QAction(parent);
67 p_linkWindow->setIcon(icon);
68 p_linkWindow->setText("&Link");
69 p_linkWindow->setToolTip("Link viewports");
70 text =
71 "<b>Function:</b> Used to link viewports. Some tools apply their \
72 functions to all linked viewports. For example, when the zoom tool \
73 is used on a linked viewport then all other linked viewports will zoom \
74 as well. \
75 <p><b>Shortcut:</b> Ctrl+L</p> \
76 <p><b>Hint:</b> The icons <img src=\"" +
77 toolIconDir() + "/linked.png\" width=22 height=22> and <img src=\"" +
78 toolIconDir() + "/unlinked.png\" width=22 height=22> at the left edge \
79 of each viewport titlebar indicate the current link state</p> \
80 <p><b>Tools using Link:</b> Zoom, Pan, Blink, and Advanced Tracking </p>";
81 p_linkWindow->setWhatsThis(text);
82 p_linkWindow->setShortcut(Qt::CTRL + Qt::Key_L);
83 p_linkWindow->setCheckable(true);
84 p_linkWindow->setEnabled(false);
85
86 p_linkAllWindows = new QAction(parent);
87 p_linkAllWindows->setText("&Link All");
88 p_linkAllWindows->setToolTip("Link all viewports");
89 p_linkAllWindows->setWhatsThis("<b>Function: </b> Links all open viewports \
90 together. <p><b>Shortcut: </b> Ctrl+Shift+L");
91 p_linkAllWindows->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_L);
92 p_linkAllWindows->setEnabled(false);
93 connect(p_linkAllWindows, SIGNAL(triggered()), this, SLOT(linkWindows()));
94
95 p_unlinkAllWindows = new QAction(parent);
96 p_unlinkAllWindows->setText("&Unlink All");
97 p_unlinkAllWindows->setToolTip("Unlink all viewports");
98 p_unlinkAllWindows->setWhatsThis("<b>Function: </b> Unlinks all open viewports. \
99 <p><b>Shortcut: </b> Ctrl+Shift+U");
100 p_unlinkAllWindows->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_U);
101 p_unlinkAllWindows->setEnabled(false);
102 connect(p_unlinkAllWindows, SIGNAL(triggered()), this, SLOT(unlinkWindows()));
103
104 p_changeCursor = new QAction(parent);
105 p_changeCursor->setText("Change cursor to arrow.");
106 p_changeCursor->setWhatsThis("<b>Function: </b> Toggles the cursor shape between \
107 and arrow and crosshair cursor when cursor is over the \
108 viewport window.");
109 p_changeCursor->setEnabled(false);
110 connect(p_changeCursor, SIGNAL(triggered()), this, SLOT(changeCursor()));
111
112 activate(true);
113 }
114
115
123 p_mdiArea = ws->mdiArea();
124 Tool::addTo(ws);
125 connect(p_cascadeWindows, SIGNAL(triggered()), ws->mdiArea(), SLOT(cascadeSubWindows()));
126 connect(p_tileWindows, SIGNAL(triggered()), this, SLOT(tileViewports()));
127 connect(p_prevWindow, SIGNAL(triggered()), ws->mdiArea(), SLOT(activatePreviousSubWindow()));
128 connect(p_nextWindow, SIGNAL(triggered()), ws->mdiArea(), SLOT(activateNextSubWindow()));
129 connect(p_closeWindow, SIGNAL(triggered()), ws->mdiArea(), SLOT(closeActiveSubWindow()));
130 connect(p_closeAllWindows, SIGNAL(triggered()), ws->mdiArea(), SLOT(closeAllSubWindows()));
131 connect(ws, SIGNAL(cubeViewportAdded(MdiCubeViewport *)),
133 }
134
135
144 int numViewports = p_mdiArea->subWindowList().size();
145
146 double mdiWidth = p_mdiArea->width();
147 double mdiHeight = p_mdiArea->height();
148
149 double px = ceil(sqrt(numViewports*mdiWidth/mdiHeight));
150 double sx, sy;
151 if (floor(px*mdiHeight/mdiWidth)*px < numViewports) {
152 sx = mdiHeight/ceil(px*mdiHeight/mdiWidth);
153 }
154 else {
155 sx = mdiWidth/px;
156 }
157
158 double py = ceil(sqrt(numViewports * mdiHeight / mdiWidth));
159 if (floor(py*mdiWidth/mdiHeight)*py < numViewports) {
160 sy = mdiWidth/ceil(mdiWidth*py/mdiHeight);
161 }
162 else {
163 sy = mdiHeight/py;
164 }
165
166 return std::max(sx,sy);
167 }
168
176 int vpSize = viewportSize();
177
178 QPoint position(0, 0);
179
180 QList<QMdiSubWindow *> windowList = p_mdiArea->subWindowList();
181
182 for (int i = windowList.size() - 1; i >= 0; i--) {
183 QMdiSubWindow *window = windowList[i];
184 window->showNormal();
185 QRect rect(0, 0, vpSize, vpSize);
186 window->setGeometry(rect);
187 window->move(position);
188
189 position.setX(position.x() + window->width());
190 if (position.x() + window->width() > p_mdiArea->width()) {
191 position.setX(0);
192 position.setY(position.y() + window->height());
193 }
194 }
195 }
196
197
205 perm->addAction(p_linkWindow);
206 }
207
208
218 menu->addAction(p_cascadeWindows);
219 menu->addAction(p_tileWindows);
220 menu->addAction(p_resizeWindows);
221 menu->addSeparator();
222
223 menu->addAction(p_changeCursor);
224 menu->addSeparator();
225
226 menu->addAction(p_nextWindow);
227 menu->addAction(p_prevWindow);
228 menu->addAction(p_closeWindow);
229 menu->addAction(p_closeAllWindows);
230 menu->addSeparator();
231
232 menu->addAction(p_linkWindow);
233 menu->addAction(p_linkAllWindows);
234 menu->addAction(p_unlinkAllWindows);
235 }
236
237
245 connect(p_linkWindow, SIGNAL(toggled(bool)),
246 cubeViewport(), SLOT(setLinked(bool)));
247 connect(cvp, SIGNAL(linkChanging(bool)), p_linkWindow, SLOT(setChecked(bool)));
248 }
249
250
258 disconnect(p_linkWindow, SIGNAL(toggled(bool)),
259 cubeViewport(), SLOT(setLinked(bool)));
260 disconnect(cvp, SIGNAL(linkChanging(bool)), p_linkWindow, SLOT(setChecked(bool)));
261 }
262
263
270 for(int i = 0; i < (int)cubeViewportList()->size(); i++) {
271 d = (*(cubeViewportList()))[i];
272 d->setLinked(true);
273 }
274 }
275
276
283 for(int i = 0; i < (int)cubeViewportList()->size(); i++) {
284 d = (*(cubeViewportList()))[i];
285 d->setLinked(false);
286 }
287 }
288
294 if (p_changeCursor->text() == "Change cursor to arrow.") {
295 p_changeCursor->setText("Change cursor to crosshair.");
296 }
297 else {
298 p_changeCursor->setText("Change cursor to arrow.");
299 }
300
301 for (int i = 0; i < (int)cubeViewportList()->size(); i++) {
303 }
304 }
305
311 if (p_changeCursor->text() == "Change cursor to crosshair." &&
312 cvp->viewport()->cursor().shape() != Qt::ArrowCursor) {
313 cvp->viewport()->setCursor(Qt::ArrowCursor);
314 }
315 else if (p_changeCursor->text() == "Change cursor to arrow." &&
316 cvp->viewport()->cursor().shape() != Qt::CrossCursor) {
317 cvp->viewport()->setCursor(Qt::CrossCursor);
318 }
319 }
320
321
329 QSize size = cubeViewport()->parentWidget()->size();
330
331 for(int i = 0; i < (int)cubeViewportList()->size(); i++) {
332 d = (*(cubeViewportList()))[i];
333 if(d->isLinked()) d->parentWidget()->parentWidget()->resize(size);
334 }
335 }
336
337
343 if(cubeViewport() == NULL) {
344 p_linkWindow->setChecked(false);
345 p_linkWindow->setEnabled(false);
346 p_linkAllWindows->setEnabled(false);
347 p_unlinkAllWindows->setEnabled(false);
348 p_cascadeWindows->setEnabled(false);
349 p_tileWindows->setEnabled(false);
350 p_resizeWindows->setEnabled(false);
351 p_closeWindow->setEnabled(false);
352 p_closeAllWindows->setEnabled(false);
353 p_nextWindow->setEnabled(false);
354 p_prevWindow->setEnabled(false);
355 p_changeCursor->setEnabled(false);
356 }
357 else {
358 p_cascadeWindows->setEnabled(true);
359 p_tileWindows->setEnabled(true);
360 p_resizeWindows->setEnabled(true);
361 p_closeWindow->setEnabled(true);
362 p_closeAllWindows->setEnabled(true);
363 p_changeCursor->setEnabled(true);
364
365 if(cubeViewportList()->size() > 1) {
366 p_linkWindow->setEnabled(true);
367 p_linkAllWindows->setEnabled(true);
368 p_unlinkAllWindows->setEnabled(true);
369 p_nextWindow->setEnabled(true);
370 p_prevWindow->setEnabled(true);
371 p_linkWindow->setChecked(cubeViewport()->isLinked());
372 }
373 else {
374 p_linkWindow->setEnabled(false);
375 p_linkAllWindows->setEnabled(false);
376 p_unlinkAllWindows->setEnabled(false);
377 p_nextWindow->setEnabled(false);
378 p_prevWindow->setEnabled(false);
379 }
380 }
381 }
382}
Cube display widget for certain Isis MDI applications.
void setLinked(bool b)
Change the linked state of the viewport.
bool isLinked() const
Is the viewport linked with other viewports.
Tool(QWidget *parent)
Tool constructor.
Definition Tool.cpp:27
void addTo(ViewportMainWindow *mw)
Adds the tool to the application.
Definition Tool.cpp:78
void activate(bool)
Activates the tool.
Definition Tool.cpp:131
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
QAction * p_tileWindows
tile windows action
Definition WindowTool.h:60
QAction * p_closeWindow
close window action
Definition WindowTool.h:64
QAction * p_prevWindow
previous window action
Definition WindowTool.h:62
void linkWindows()
Links all viewport windows in the workspace.
QAction * p_changeCursor
changes the cursor when it moves over the viewport
Definition WindowTool.h:69
void removeConnections(MdiCubeViewport *cvp)
Removes the connections from the cube viewport.
QAction * p_nextWindow
next window action
Definition WindowTool.h:63
QMdiArea * p_mdiArea
area where viewports are displayed
Definition WindowTool.h:58
void unlinkWindows()
Unlinks all the viewport windows in the workspace.
void updateViewportCursor(MdiCubeViewport *)
Updates the cursor over the viewport.
int viewportSize()
Helper function for determining the size of the viewports.
QAction * p_unlinkAllWindows
unlink all windows action
Definition WindowTool.h:68
QAction * p_resizeWindows
resize windows action
Definition WindowTool.h:61
void resizeWindows()
Resizes all the viewport windows to the active viewport window size.
void changeCursor()
Toggles the cursor from an arrow to a crosshair.
QAction * p_linkAllWindows
link all windows action
Definition WindowTool.h:67
void updateTool()
Updates the WindowTool.
WindowTool(QWidget *parent)
WindowTool constructor.
QAction * p_closeAllWindows
close all action
Definition WindowTool.h:65
void tileViewports()
Tiles the cube viewports over the Cube DN View.
void addConnections(MdiCubeViewport *cvp)
Adds the connections to the cube viewport.
void addTo(QMenu *menu)
Adds the cascade windows, tile windows, resize windows, next window, previous window,...
QAction * p_cascadeWindows
cascade windows action
Definition WindowTool.h:59
void addToPermanent(QToolBar *toolbar)
Adds the link window action to the tool bar.
QAction * p_linkWindow
link window action
Definition WindowTool.h:66
QMdiArea * mdiArea()
This method returns the QMdiArea.
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