Isis 3 Programmer Reference
ViewportMainWindow.cpp
1#include <QStatusBar>
2#include <QDockWidget>
3#include <QMenuBar>
4#include <QMenu>
5#include <QSettings>
6#include "ViewportMainWindow.h"
7#include "Workspace.h"
8#include "TrackTool.h"
9#include "ToolPad.h"
10
11namespace Isis {
18 ViewportMainWindow::ViewportMainWindow(QString title, QWidget *parent) : MainWindow(title, parent) {
19 p_workspace = new Workspace(false, this);
20 setCentralWidget(p_workspace);
21 setWindowTitle(title);
22 setObjectName("MainWindow");
23
24 p_permToolbar = new QToolBar("Standard Tools", this);
25 p_permToolbar->setObjectName("perm");
26 p_permToolbar->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
27 p_permToolbar->setIconSize(QSize(22, 22));
28 addToolBar(p_permToolbar);
29
30 p_activeToolbar = new QToolBar("Active Tool", this);
31 p_activeToolbar->setObjectName("Active");
32 p_activeToolbar->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
33 p_activeToolbar->setIconSize(QSize(22, 22));
34 addToolBar(p_activeToolbar);
35
36 QStatusBar *sbar = statusBar();
37 sbar->showMessage("Ready");
38
39 mTrackTool = new TrackTool(sbar);
40 mTrackTool->addTo(this);
41
42 p_toolpad = new ToolPad("Tool Pad", this);
43 p_toolpad->setObjectName("ViewportMainWindow");
44 p_toolpad->setAllowedAreas(Qt::LeftToolBarArea | Qt::RightToolBarArea);
45 addToolBar(Qt::RightToolBarArea, p_toolpad);
46
47 readSettings(QSize(800, 700));
48 }
49
50
55 ViewportMainWindow::~ViewportMainWindow() {
56 }
57
65 void ViewportMainWindow::displayWarning(std::string &pStr, const std::string &pExStr) {
66 if(mTrackTool != NULL) {
67 mTrackTool->displayWarning(pStr, pExStr);
68 }
69 }
70
75 if(mTrackTool != NULL) {
77 }
78 }
79
87 QMenu *ViewportMainWindow::getMenu(const QString &name) {
88 std::map<QString, QMenu *>::iterator pos;
89 pos = p_menus.find(name);
90 if(pos != p_menus.end()) {
91 return pos->second;
92 }
93 else {
94 QMenu *menu = menuBar()->addMenu(name);
95 p_menus[name] = menu;
96 return menu;
97 }
98 }
99
100
115 void ViewportMainWindow::closeEvent(QCloseEvent *event) {
116 if (p_workspace->confirmClose()) {
117 emit closeWindow(event);
118 if (event->isAccepted()) {
120 }
121 else {
122 event->ignore();
123 }
124 }
125 else {
126 event->ignore();
127 }
128 }
129}
Base class for the Qisis main windows.
Definition MainWindow.h:24
virtual void closeEvent(QCloseEvent *event)
This method is overridden so that we can be sure to write the current settings of the Main window.
virtual void readSettings(QSize defaultSize=QSize())
This method ensure that the settings get written even if the Main window was only hidden,...
void addTo(ViewportMainWindow *mw)
Adds the tool to the application.
Definition Tool.cpp:78
This tool is part of the Qisis namespace and displays the statusbar of the window.
Definition TrackTool.h:43
void resetStatusWarning(void)
Resets the warning status on the status bar to default.
void displayWarning(std::string &pStr, const std::string &pExStr)
Display the Warning icon in case of an exception, sent from the tool where the exception occured.
Definition TrackTool.cpp:97
void closeWindow(QCloseEvent *event=NULL)
Signal called when the window receives a close event.
QToolBar * p_activeToolbar
The active toolbar.
ToolPad * p_toolpad
The toolpad.
virtual void closeEvent(QCloseEvent *event)
This class is called when a close event occurs, it emits a signal and ignores the close event.
std::map< QString, QMenu * > p_menus
Map of qstrings to menus.
ViewportMainWindow(QString title, QWidget *parent=0)
Constructs a ViewportMainWindow object with windowTitle = title.
void resetWarning(void)
Slot which receives the message to reset warning status.
Workspace * p_workspace
The current workspace.
QToolBar * p_permToolbar
The permanent toolbar.
TrackTool * mTrackTool
Pointer to application's Status bar.
QMenu * getMenu(const QString &name)
Returns the menu with menu name = name.
void displayWarning(std::string &pStr, const std::string &pExStr)
Slot which receives the warning signal.
bool confirmClose()
Confirms that the user wishes toc lose the Workspace.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16