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 
11 namespace 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()) {
119  MainWindow::closeEvent(event);
120  }
121  else {
122  event->ignore();
123  }
124  }
125  else {
126  event->ignore();
127  }
128  }
129 }
Isis::ViewportMainWindow::p_workspace
Workspace * p_workspace
The current workspace.
Definition: ViewportMainWindow.h:86
QWidget
Isis::ViewportMainWindow::closeWindow
void closeWindow(QCloseEvent *event=NULL)
Signal called when the window receives a close event.
Isis::ViewportMainWindow::getMenu
QMenu * getMenu(const QString &name)
Returns the menu with menu name = name.
Definition: ViewportMainWindow.cpp:87
Isis::TrackTool::displayWarning
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
Isis::ViewportMainWindow::p_activeToolbar
QToolBar * p_activeToolbar
The active toolbar.
Definition: ViewportMainWindow.h:88
QMenu
Isis::ViewportMainWindow::resetWarning
void resetWarning(void)
Slot which receives the message to reset warning status.
Definition: ViewportMainWindow.cpp:74
QToolBar
Isis::Workspace::confirmClose
bool confirmClose()
Confirms that the user wishes toc lose the Workspace.
Definition: Workspace.cpp:267
Isis::MainWindow::closeEvent
virtual void closeEvent(QCloseEvent *event)
This method is overridden so that we can be sure to write the current settings of the Main window.
Definition: MainWindow.cpp:37
Isis::ViewportMainWindow::closeEvent
virtual void closeEvent(QCloseEvent *event)
This class is called when a close event occurs, it emits a signal and ignores the close event.
Definition: ViewportMainWindow.cpp:115
Isis::Tool::addTo
void addTo(ViewportMainWindow *mw)
Adds the tool to the application.
Definition: Tool.cpp:78
Isis::ViewportMainWindow::mTrackTool
TrackTool * mTrackTool
Pointer to application's Status bar.
Definition: ViewportMainWindow.h:92
Isis::MainWindow::readSettings
virtual void readSettings(QSize defaultSize=QSize())
This method ensure that the settings get written even if the Main window was only hidden,...
Definition: MainWindow.cpp:80
Isis::ToolPad
Definition: ToolPad.h:14
Isis::TrackTool::resetStatusWarning
void resetStatusWarning(void)
Resets the warning status on the status bar to default.
Definition: TrackTool.cpp:104
Isis::ViewportMainWindow::p_permToolbar
QToolBar * p_permToolbar
The permanent toolbar.
Definition: ViewportMainWindow.h:87
Isis::Workspace
Definition: Workspace.h:78
Isis::MainWindow
Base class for the Qisis main windows.
Definition: MainWindow.h:24
Isis::ViewportMainWindow::p_menus
std::map< QString, QMenu * > p_menus
Map of qstrings to menus.
Definition: ViewportMainWindow.h:90
Isis::TrackTool
This tool is part of the Qisis namespace and displays the statusbar of the window.
Definition: TrackTool.h:42
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::ViewportMainWindow::ViewportMainWindow
ViewportMainWindow(QString title, QWidget *parent=0)
Constructs a ViewportMainWindow object with windowTitle = title.
Definition: ViewportMainWindow.cpp:18
Isis::ViewportMainWindow::p_toolpad
ToolPad * p_toolpad
The toolpad.
Definition: ViewportMainWindow.h:89
Isis::ViewportMainWindow::displayWarning
void displayWarning(std::string &pStr, const std::string &pExStr)
Slot which receives the warning signal.
Definition: ViewportMainWindow.cpp:65