CustusX  16.12
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxMainWindow.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 #include "cxMainWindow.h"
34 
35 #include <QtWidgets>
36 #include "boost/bind.hpp"
37 
38 #include "cxConfig.h"
39 #include "cxDataLocations.h"
40 #include "cxLogicManager.h"
41 #include "cxSettings.h"
42 #include "cxPatientModelService.h"
43 #include "cxViewService.h"
45 #include "cxAudioImpl.h"
46 #include "cxLayoutInteractor.h"
47 #include "cxCameraControl.h"
48 
50 #include "cxStatusBar.h"
51 #include "cxSecondaryMainWindow.h"
53 #include "cxSamplerWidget.h"
54 #include "cxHelperWidgets.h"
55 #include "cxMainWindowActions.h"
56 
59 #include "cxToolManagerWidget.h"
60 #include "cxFrameTreeWidget.h"
61 #include "cxNavigationWidget.h"
63 #include "cxToolPropertiesWidget.h"
64 #include "cxPreferencesDialog.h"
66 #include "cxMeshInfoWidget.h"
67 #include "cxTrackPadWidget.h"
68 #include "cxConsoleWidget.h"
69 #include "cxMetricWidget.h"
70 #include "cxPlaybackWidget.h"
71 #include "cxEraserWidget.h"
72 #include "cxFiltersWidget.h"
74 #include "cxManageClippersWidget.h"
75 #include "cxBrowserWidget.h"
76 #include "cxActiveToolProxy.h"
77 
78 namespace cx
79 {
80 
82  mFullScreenAction(NULL),
83  mStandard3DViewActions(new QActionGroup(this)),
84  mControlPanel(NULL),
85  mDockWidgets(new DynamicMainWindowWidgets(this)),
86  mActions(NULL)
87 {
88  this->setObjectName("main_window");
89 
90  mServices = VisServices::create(logicManager()->getPluginContext());
91  mLayoutInteractor.reset(new LayoutInteractor());
92 
93  this->setCentralWidget(viewService()->createLayoutWidget(this, 0));
94 
95  mActions = new MainWindowActions(mServices, this);
96 
97  this->createActions();
98  this->createMenus();
99  this->createToolBars();
100  this->setStatusBar(new StatusBar());
101 
102  reporter()->setAudioSource(AudioPtr(new AudioImpl()));
103 
107 
108  this->updateWindowTitle();
109 
110  this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
111 
112  this->addAsDockWidget(new PlaybackWidget(this), "Browsing");
113  this->addAsDockWidget(new VideoConnectionWidget(mServices, this), "Utility");
114  this->addAsDockWidget(new EraserWidget(mServices->patient(), mServices->view(), this), "Properties");
115  this->addAsDockWidget(new MetricWidget(mServices->view(), mServices->patient(), this), "Utility");
116  this->addAsDockWidget(new SlicePropertiesWidget(mServices->patient(), mServices->view(), this), "Properties");
117  this->addAsDockWidget(new VolumePropertiesWidget(mServices, this), "Properties");
118  this->addAsDockWidget(new ActiveMeshPropertiesWidget(mServices, this), "Properties");
119  this->addAsDockWidget(new StreamPropertiesWidget(mServices->patient(), mServices->view(), this), "Properties");
120  this->addAsDockWidget(new TrackPadWidget(this), "Utility");
121  this->addAsDockWidget(new ActiveToolPropertiesWidget(mServices->tracking(), mServices->spaceProvider(), this), "Properties");
122  this->addAsDockWidget(new NavigationWidget(this), "Properties");
123  this->addAsDockWidget(new ConsoleWidget(this, "console_widget", "Console"), "Utility");
124  this->addAsDockWidget(new ConsoleWidget(this, "console_widget_2", "Extra Console"), "Utility");
125 // this->addAsDockWidget(new ConsoleWidgetCollection(this, "ConsoleWidgets", "Consoles"), "Utility");
126  this->addAsDockWidget(new FrameTreeWidget(mServices->patient(), this), "Browsing");
127  this->addAsDockWidget(new ToolManagerWidget(this), "Debugging");
128  this->addAsDockWidget(new PluginFrameworkWidget(this), "Browsing");
129  this->addAsDockWidget(new FiltersWidget(VisServices::create(logicManager()->getPluginContext()), this), "Algorithms");
130  this->addAsDockWidget(new ClippingPropertiesWidget(mServices, this), "Properties");
131 
132  this->addAsDockWidget(new BrowserWidget(this, mServices), "Browsing");
133 
135  connect(qApp, &QApplication::focusChanged, this, &MainWindow::focusChanged);
136 
137  this->setupGUIExtenders();
138 
139  // window menu must be created after all dock widgets are created
140  QMenu* popupMenu = this->createPopupMenu();
141  popupMenu->setTitle("Window");
142  this->menuBar()->insertMenu(mHelpMenuAction, popupMenu);
143 
144  // show after window has been initialized
145  QTimer::singleShot(0, this, SLOT(delayedShow()));
146 }
147 
149 {
150  // Restore saved window states
151  // Must be done after all DockWidgets are created
152  if (restoreGeometry(settings()->value("mainWindow/geometry").toByteArray()))
153  {
154  this->show();
155  }
156  else
157  {
158  this->showMaximized();
159  }
160 
161  if (settings()->value("gui/fullscreen").toBool())
162  {
163  this->setWindowState(this->windowState() | Qt::WindowFullScreen);
164  }
165 }
166 
167 void MainWindow::changeEvent(QEvent * event)
168 {
169  QMainWindow::changeEvent(event);
170 
171  if (event->type() == QEvent::WindowStateChange)
172  {
173  if (mFullScreenAction)
174  mFullScreenAction->setChecked(this->windowState() & Qt::WindowFullScreen);
175  }
176 }
177 
178 void MainWindow::setupGUIExtenders()
179 {
180  mServiceListener.reset(new ServiceTrackerListener<GUIExtenderService>(
181  LogicManager::getInstance()->getPluginContext(),
182  boost::bind(&MainWindow::onGUIExtenderServiceAdded, this, _1),
183  boost::bind(&MainWindow::onGUIExtenderServiceModified, this, _1),
184  boost::bind(&MainWindow::onGUIExtenderServiceRemoved, this, _1)
185  ));
186  mServiceListener->open();
187 }
188 
190 {
191  std::vector<GUIExtenderService::CategorizedWidget> widgets = service->createWidgets();
192  for (unsigned j = 0; j < widgets.size(); ++j)
193  {
194  if(!widgets[j].mPlaceInSeparateWindow)
195  mDockWidgets->addAsDockWidget(widgets[j].mWidget, widgets[j].mCategory, service);
196  else
197  this->createActionForWidgetInSeparateWindow(widgets[j].mWidget);
198  }
199 
200  std::vector<QToolBar*> toolBars = service->createToolBars();
201  for(unsigned j = 0; j < toolBars.size(); ++j)
202  {
203  mDockWidgets->registerToolBar(toolBars[j]);
204  }
205 }
206 
208 {
209 }
210 
212 {
213  mDockWidgets->owningServiceRemoved(service);
214 }
215 
217 {
218  if (val)
219  this->focusInsideDockWidget(sender());
220 }
221 
222 void MainWindow::focusChanged(QWidget * old, QWidget * now)
223 {
224  this->focusInsideDockWidget(now);
225 }
226 
227 void MainWindow::focusInsideDockWidget(QObject *dockWidget)
228 {
229  if (!dockWidget)
230  return;
231 
232 // CX_LOG_CHANNEL_DEBUG("HELP_DB") << QString(" try mw::focus [%1](%2)")
233 // .arg(dockWidget->objectName())
234 // .arg(dockWidget->metaObject()->className());
235 
236  // focusing to docked widgets is required by the help system
237 
238  // Assume structure: QDockWidget->QScrollArea->QWidget,
239  // as defined in MainWindow::addAsDockWidget()
240  QDockWidget* dw = dynamic_cast<QDockWidget*>(dockWidget);
241  if (!dw)
242  return;
243  if (dw->parent()!=this) // avoid events from other mainwindows
244  return;
245  QScrollArea* sa = dynamic_cast<QScrollArea*>(dw->widget());
246  if (!sa)
247  return;
248 
249  if (!sa->widget())
250  return;
251 
252 // CX_LOG_CHANNEL_DEBUG("HELP_DB") << QString(" do mw::focus [%1](%2)")
253 // .arg(sa->widget()->objectName())
254 // .arg(sa->widget()->metaObject()->className());
255 
256  QTimer::singleShot(0, sa->widget(), SLOT(setFocus())); // avoid loops etc by send async event.
257 }
258 
260 {
261  viewService()->deactivateLayout();
262  reporter()->setAudioSource(AudioPtr()); // important! QSound::play fires a thread, causes segfault during shutdown
263  mServiceListener.reset();
264 }
265 
267 {
268  return mDockWidgets->createPopupMenu();
269 }
270 
271 void MainWindow::createActions()
272 {
273  CameraControlPtr cameraControl = viewService()->getCameraControl();
274  if (cameraControl)
275  mStandard3DViewActions = cameraControl->createStandard3DViewActions();
276 
277  mShowContextSensitiveHelpAction = new QAction(QIcon(":/icons/open_icon_library/help-contents-5.png"),
278  "Context-sensitive help", this);
279  connect(mShowContextSensitiveHelpAction, &QAction::triggered, this, &MainWindow::onShowContextSentitiveHelp);
280 
281  mShowControlPanelAction = new QAction("Show Control Panel", this);
282  connect(mShowControlPanelAction, &QAction::triggered, this, &MainWindow::showControlPanelActionSlot);
283  mSecondaryViewLayoutWindowAction = new QAction("Show Secondary View Layout Window", this);
284  connect(mSecondaryViewLayoutWindowAction, &QAction::triggered, this, &MainWindow::showSecondaryViewLayoutWindowActionSlot);
285 
286  // Application
287  mAboutAction = new QAction(tr("About"), this);
288  mAboutAction->setStatusTip(tr("Show the application's About box"));
289  mPreferencesAction = new QAction(tr("Preferences"), this);
290  mPreferencesAction->setShortcut(tr("Ctrl+,"));
291  mPreferencesAction->setStatusTip(tr("Show the preferences dialog"));
292 
293  mFullScreenAction = new QAction(tr("Fullscreen"), this);
294  mFullScreenAction->setShortcut(tr("F11"));
295  mFullScreenAction->setStatusTip(tr("Toggle full screen"));
296  mFullScreenAction->setCheckable(true);
297  mFullScreenAction->setChecked(this->windowState() & Qt::WindowFullScreen);
298  connect(mFullScreenAction, &QAction::triggered, this, &MainWindow::toggleFullScreenSlot);
299 
300  mQuitAction = new QAction(tr("&Quit"), this);
301  mQuitAction->setShortcut(tr("Ctrl+Q"));
302  mQuitAction->setStatusTip(tr("Exit the application"));
303 
304  connect(mAboutAction, &QAction::triggered, this, &MainWindow::aboutSlot);
305  connect(mPreferencesAction, &QAction::triggered, this, &MainWindow::preferencesSlot);
306  connect(mQuitAction, &QAction::triggered, qApp, &QApplication::quit);
307 
308  mSaveDesktopAction = new QAction(QIcon(":/icons/workflow_state_save.png"), tr("Save desktop"), this);
309  mSaveDesktopAction->setToolTip("Save desktop for workflow step");
310  connect(mSaveDesktopAction, &QAction::triggered, this, &MainWindow::saveDesktopSlot);
311  mResetDesktopAction = new QAction(QIcon(":/icons/workflow_state_revert.png"), tr("Reset desktop"), this);
312  mResetDesktopAction->setToolTip("Reset desktop for workflow step");
313  connect(mResetDesktopAction, &QAction::triggered, this, &MainWindow::resetDesktopSlot);
314 
315  mInteractorStyleActionGroup = viewService()->getInteractorStyleActionGroup();
316 
317  // cross-connect save patient to save session
318  connect(mServices->session().get(), &SessionStorageService::isSaving, this, &MainWindow::saveDesktopSlot);
319 }
320 
321 
323 {
324  this->updateWindowTitle();
325 }
326 
327 void MainWindow::updateWindowTitle()
328 {
329  QString profileName = stateService()->getApplicationStateName();
330  QString versionName = stateService()->getVersionName();
331 
332  QString activePatientFolder = patientService()->getActivePatientFolder();
333  if (activePatientFolder.endsWith('/'))
334  activePatientFolder.chop(1);
335  QString patientName;
336 
337  if (!activePatientFolder.isEmpty())
338  {
339  QFileInfo info(activePatientFolder);
340  patientName = info.completeBaseName();
341  }
342 
343  QString format("%1 %2 - %3 - %4 (not approved for medical use)");
344  QString title = format
345  .arg(qApp->applicationDisplayName())
346  .arg(versionName)
347  .arg(profileName)
348  .arg(patientName);
349  this->setWindowTitle(title);
350 }
351 
353 {
354  Desktop desktop = stateService()->getActiveDesktop();
355 
356  mDockWidgets->restoreFrom(desktop);
357  viewService()->setActiveLayout(desktop.mLayoutUid, 0);
358  viewService()->setActiveLayout(desktop.mSecondaryLayoutUid, 1);
359  patientService()->autoSave();
360 
361  // moved to help plugin:
362 // // set initial focus to mainwindow in order to view it in the documentation
363 // // this is most important when starting up.
364 // QTimer::singleShot(0, this, SLOT(setFocus())); // avoid loops etc by send async event.
365 
366 //#ifdef CX_APPLE
367 // // HACK
368 // // Toolbars are not correctly refreshed on mac 10.8,
369 // // Cause is related to QVTKWidget (removing it removes the problem)
370 // // The following "force refresh by resize" solves repaint, but
371 // // inactive toolbars are still partly clickable.
372 // QSize size = this->size();
373 // this->resize(size.width()-1, size.height());
374 // this->resize(size);
375 //#endif
376 }
377 
379 {
380  Desktop desktop;
381  desktop.mMainWindowState = this->saveState();
382  desktop.mLayoutUid = viewService()->getActiveLayout(0);
383  desktop.mSecondaryLayoutUid = viewService()->getActiveLayout(1);
384  stateService()->saveDesktop(desktop);
385 
386  // save to settings file in addition
387  settings()->setValue("mainWindow/geometry", saveGeometry());
388  settings()->setValue("mainWindow/windowState", saveState());
389  settings()->sync();
390 }
391 
393 {
394  stateService()->resetDesktop();
396 }
397 
399 {
400  mDockWidgets->showWidget("Help");
401 }
402 
404 {
405  this->setWindowState(this->windowState() ^ Qt::WindowFullScreen);
406 
407  settings()->setValue("gui/fullscreen", (this->windowState() & Qt::WindowFullScreen)!=0);
408 }
409 
410 void MainWindow::createActionForWidgetInSeparateWindow(QWidget* widget)
411 {
412  QString uid = widget->objectName();
413  if(mSecondaryMainWindows.find(uid) == mSecondaryMainWindows.end())
414  {
415  SecondaryMainWindow* secondaryMainWindow = new SecondaryMainWindow(this, widget);
416  QAction* action = new QAction(widget->windowTitle(), this);
417 
418  mSecondaryMainWindows[uid] = secondaryMainWindow;
419  mSecondaryMainWindowsActions[uid] = action;
420 
421  connect(action, &QAction::triggered, secondaryMainWindow, &QWidget::show);
422 
423  mFileMenu->addAction(action);
424  }
425 }
426 
428 {
429  if (!mControlPanel)
430  {
431  TrackPadWidget* trackPadWidget = new TrackPadWidget(this);
432  mControlPanel = new SecondaryMainWindow(this, trackPadWidget);
433  }
434  mControlPanel->show();
435 }
436 
438 {
439  if (!mSecondaryViewLayoutWindow)
440  mSecondaryViewLayoutWindow = new SecondaryViewLayoutWindow(this);
441  mSecondaryViewLayoutWindow->tryShowOnSecondaryScreen();
442 }
443 
445 {
446  this->updateWindowTitle();
447 }
448 
449 void MainWindow::createMenus()
450 {
451 #ifdef CX_LINUX
452  // shortcuts defined on actions in the global menubar is not reachable on Qt5+Ubuntu14.04,
453  // solve by reverting to old style.
454  // This will create a double menubar: remove by autohiding menubar or using
455  // sudo apt-get autoremove appmenu-gtk appmenu-gtk3 appmenu-qt
456  // and reboot
457  this->menuBar()->setNativeMenuBar(false);
458 #endif
459  mFileMenu = new QMenu(tr("File"), this);
460  mWorkflowMenu = new QMenu(tr("Workflow"), this);
461  mToolMenu = new QMenu(tr("Tracking"), this);
462  mLayoutMenu = new QMenu(tr("Layouts"), this);
463  mNavigationMenu = new QMenu(tr("Navigation"), this);
464  mHelpMenu = new QMenu(tr("Help"), this);
465 
466  // File
467  mFileMenu->addAction(mPreferencesAction);
468  this->menuBar()->addMenu(mFileMenu);
469  mFileMenu->addAction(mActions->getAction("NewPatient"));
470  mFileMenu->addAction(mActions->getAction("SaveFile"));
471  mFileMenu->addAction(mActions->getAction("LoadFile"));
472  mFileMenu->addAction(mActions->getAction("LoadFileCopy"));
473  mFileMenu->addAction(mActions->getAction("ClearPatient"));
474  mFileMenu->addSeparator();
475  mFileMenu->addAction(mActions->getAction("ExportPatient"));
476  mFileMenu->addAction(mActions->getAction("ImportData"));
477  mFileMenu->addSeparator();
478  mFileMenu->addAction(mFullScreenAction);
479  mFileMenu->addAction(mActions->getAction("StartLogConsole"));
480  mFileMenu->addAction(mActions->getAction("ShootScreen"));
481  mFileMenu->addAction(mActions->getAction("ShootWindow"));
482  mFileMenu->addAction(mActions->getAction("RecordFullscreen"));
483  mFileMenu->addSeparator();
484  mFileMenu->addAction(mShowControlPanelAction);
485  mFileMenu->addAction(mSecondaryViewLayoutWindowAction);
486 
487  mFileMenu->addAction(mQuitAction);
488 
489  //workflow
490  this->menuBar()->addMenu(mWorkflowMenu);
491  QList<QAction*> actions = stateService()->getWorkflowActions()->actions();
492  for (int i=0; i<actions.size(); ++i)
493  {
494  mWorkflowMenu->addAction(actions[i]);
495  }
496 
497  mWorkflowMenu->addSeparator();
498  mWorkflowMenu->addAction(mSaveDesktopAction);
499  mWorkflowMenu->addAction(mResetDesktopAction);
500 
501  //tool
502  this->menuBar()->addMenu(mToolMenu);
503  mToolMenu->addAction(mActions->getAction("ConfigureTools"));
504  mToolMenu->addAction(mActions->getAction("InitializeTools"));
505  mToolMenu->addAction(mActions->getAction("TrackingTools"));
506  mToolMenu->addSeparator();
507  mToolMenu->addAction(mActions->getAction("StartStreaming"));
508  mToolMenu->addSeparator();
509 
510  //layout
511  this->menuBar()->addMenu(mLayoutMenu);
512  mLayoutInteractor->connectToMenu(mLayoutMenu);
513 
514  this->menuBar()->addMenu(mNavigationMenu);
515  mNavigationMenu->addAction(mActions->getAction("CenterToImageCenter"));
516  mNavigationMenu->addAction(mActions->getAction("CenterToTooltip"));
517  mNavigationMenu->addAction(mActions->getAction("ShowPointPicker"));
518  mNavigationMenu->addSeparator();
519  mNavigationMenu->addActions(mInteractorStyleActionGroup->actions());
520 
521  mHelpMenuAction = this->menuBar()->addMenu(mHelpMenu);
522  mHelpMenu->addAction(mAboutAction);
523  mHelpMenu->addAction(mActions->getAction("GotoDocumentation"));
524  mHelpMenu->addAction(mShowContextSensitiveHelpAction);
525 }
526 
527 void MainWindow::createToolBars()
528 {
529  mWorkflowToolBar = this->registerToolBar("Workflow");
530  QList<QAction*> actions = stateService()->getWorkflowActions()->actions();
531  for (int i=0; i<actions.size(); ++i)
532  mWorkflowToolBar->addAction(actions[i]);
533 
534  mDataToolBar = this->registerToolBar("Data");
535  mDataToolBar->addAction(mActions->getAction("NewPatient"));
536  mDataToolBar->addAction(mActions->getAction("LoadFile"));
537  mDataToolBar->addAction(mActions->getAction("SaveFile"));
538  mDataToolBar->addAction(mActions->getAction("ImportData"));
539 
540  mToolToolBar = this->registerToolBar("Tools");
541  mToolToolBar->addAction(mActions->getAction("TrackingTools"));
542  mToolToolBar->addAction(mActions->getAction("StartStreaming"));
543 
544  mNavigationToolBar = this->registerToolBar("Navigation");
545  mNavigationToolBar->addAction(mActions->getAction("CenterToImageCenter"));
546  mNavigationToolBar->addAction(mActions->getAction("CenterToTooltip"));
547  mNavigationToolBar->addAction(mActions->getAction("ShowPointPicker"));
548 
549  mInteractorStyleToolBar = this->registerToolBar("InteractorStyle");
550  mInteractorStyleToolBar->addActions(mInteractorStyleActionGroup->actions());
551 
552  mDesktopToolBar = this->registerToolBar("Desktop");
553  mDesktopToolBar->addAction(mSaveDesktopAction);
554  mDesktopToolBar->addAction(mResetDesktopAction);
555 
556  mScreenshotToolBar = this->registerToolBar("Screenshot");
557  mScreenshotToolBar->addAction(mActions->getAction("ShootScreen"));
558  mScreenshotToolBar->addAction(mActions->getAction("RecordFullscreen"));
559 
560  QToolBar* camera3DViewToolBar = this->registerToolBar("Camera 3D Views");
561  camera3DViewToolBar->addActions(mStandard3DViewActions->actions());
562 
563  QToolBar* samplerWidgetToolBar = this->registerToolBar("Sampler");
564  samplerWidgetToolBar->addWidget(new SamplerWidget(this));
565 
566  QToolBar* toolOffsetToolBar = this->registerToolBar("Tool Offset");
568  SpinBoxAndSliderGroupWidget* offsetWidget = new SpinBoxAndSliderGroupWidget(this, offset);
569  offsetWidget->showLabel(false);
570  toolOffsetToolBar->addWidget(offsetWidget);
571 
572  QToolBar* helpToolBar = this->registerToolBar("Help");
573  helpToolBar->addAction(mShowContextSensitiveHelpAction);
574 }
575 
576 QToolBar* MainWindow::registerToolBar(QString name, QString groupname)
577 {
578  QToolBar* toolbar = new QToolBar(name);
579  toolbar->setObjectName(QString(name).remove(" ")+"ToolBar");
580  mDockWidgets->registerToolBar(toolbar, groupname);
581  return toolbar;
582 }
583 
585 {
586  QString doc_path = DataLocations::getDocPath();
587  QString appName = qApp->applicationDisplayName();
588  QString url_website = DataLocations::getWebsiteURL();
589  QString url_license = QString("file://%1/License.txt").arg(doc_path);
590  QString url_config = QString("file://%1/cxConfigDescription.txt").arg(doc_path);
591 
592  QString text(""
593  "<h2>%1</h2>"
594  "<h4>%2</h4>"
595  "<p>A Research Platform for Image-Guided Therapy<p>"
596  "<p>%1 is NOT approved for medical use.<p>"
597  ""
598  "<p><a href=%3> website </a><p>"
599  "<p><a href=%4> license </a><p>"
600  "<p><a href=%5> configuration </a><p>");
601 
602  QMessageBox::about(this, tr("About %1").arg(appName), text
603  .arg(appName)
604  .arg(CustusX_VERSION_STRING)
605  .arg(url_website)
606  .arg(url_license)
607  .arg(url_config)
608  );
609 }
610 
612 {
613  PreferencesDialog prefDialog(mServices->view(), mServices->patient(), this);
614  prefDialog.exec();
615 }
616 
617 void MainWindow::closeEvent(QCloseEvent *event)
618 {
619  QMainWindow::closeEvent(event);
620  qApp->quit();
621 }
622 
623 QDockWidget* MainWindow::addAsDockWidget(QWidget* widget, QString groupname)
624 {
625  QDockWidget* dw = mDockWidgets->addAsDockWidget(widget, groupname);
626  return dw;
627 
628 }
629 
630 }//namespace cx
Widget for controlling camera follow style.
void registerToolBar(QToolBar *toolbar, QString groupname="Toolbars")
void dockWidgetVisibilityChanged(bool val)
Widget for displaying and changing clipper properties.
virtual QMenu * createPopupMenu()
ReporterPtr reporter()
Definition: cxReporter.cpp:59
void changeEvent(QEvent *event)
Statusbar with extended functionality.
Definition: cxStatusBar.h:92
void applicationStateChanged()
void showSecondaryViewLayoutWindowActionSlot()
Shows a treestructure containing the loaded images, meshes and tools.
void focusChanged(QWidget *old, QWidget *now)
void restoreFrom(const Desktop &desktop)
void patientChangedSlot()
static VisServicesPtr create(ctkPluginContext *context)
cxLogicManager_EXPORT StateServicePtr stateService()
Experimental class for IPad usage.This detached main window can be moved onto a secondary screen...
Widget for displaying status messages.
Widget for displaying and manipulating various 3D Volume properties.
void onApplicationStateChangedSlot()
void resetDesktopSlot()
static ActiveToolProxyPtr New(TrackingServicePtr trackingService)
void setValue(const QString &key, const QVariant &value)
Definition: cxSettings.cpp:79
GUI for setting up a connection to a video stream.
Widget for controlling the camera in the 3D view.This widget is designed for use on a touchpad device...
Experimental class for IPad usage.
void workflowStateAboutToChange()
void onGUIExtenderServiceAdded(GUIExtenderService *service)
void toggleFullScreenSlot()
void onGUIExtenderServiceRemoved(GUIExtenderService *service)
void preferencesSlot()
void saveDesktopSlot()
static QString getWebsiteURL()
QByteArray mMainWindowState
static LogicManager * getInstance()
Widget interface to PlaybackTime.
void onGUIExtenderServiceModified(GUIExtenderService *service)
boost::shared_ptr< class DoublePropertyBase > DoublePropertyBasePtr
void onShowContextSentitiveHelp()
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:42
Widget for displaying the FrameForest object.
Widget for displaying and manipulating TrackedStream properties.
Helper class for listening to services being added, modified and removed.
LogicManager * logicManager()
void workflowStateChanged()
Data class for CustusX desktop.
void showControlPanelActionSlot()
QAction * getAction(QString uid)
boost::shared_ptr< class CameraControl > CameraControlPtr
Definition: cxMainWindow.h:58
QString mLayoutUid
cxLogicManager_EXPORT ViewServicePtr viewService()
virtual ~MainWindow()
virtual std::vector< QToolBar * > createToolBars() const
cxLogicManager_EXPORT PatientModelServicePtr patientService()
QString mSecondaryLayoutUid
Designed as a debugging widget for the cxToolManager.
static boost::shared_ptr< DoublePropertyActiveToolOffset > create(ActiveToolProxyPtr activeTool)
virtual std::vector< CategorizedWidget > createWidgets() const =0
QDockWidget * addAsDockWidget(QWidget *widget, QString groupname, QObject *owningPlugin=NULL)
void onWorkflowStateChangedSlot()
static QString getDocPath()
return path to folder containing documentation files
Set application preferences.
boost::shared_ptr< Audio > AudioPtr
Definition: cxAudio.h:68
void isSaving(QDomElement &root)
xml storage is available
Widget for erasing parts of images/meshes.