Fraxinus  17.12-rc2
An IGT application
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(mServices->view()));
92 
93  this->setCentralWidget(mServices->view()->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(mServices->tracking(), mServices->view(), mServices->video()));
101 
102  reporter()->setAudioSource(AudioPtr(new AudioImpl()));
103 
104  connect(mServices->state().get(), &StateService::applicationStateChanged, this, &MainWindow::onApplicationStateChangedSlot);
105  connect(mServices->state().get(), &StateService::workflowStateChanged, this, &MainWindow::onWorkflowStateChangedSlot);
106  connect(mServices->state().get(), &StateService::workflowStateAboutToChange, this, &MainWindow::saveDesktopSlot);
107 
108  this->updateWindowTitle();
109 
110  this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
111 
112  this->addAsDockWidget(new PlaybackWidget(mServices->tracking(), mServices->video(), mServices->patient(), 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, 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(mServices->view(), this), "Utility");
121  this->addAsDockWidget(new ActiveToolPropertiesWidget(mServices->tracking(), mServices->spaceProvider(), this), "Properties");
122  this->addAsDockWidget(new NavigationWidget(mServices->view(), mServices->tracking(), 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(mServices->tracking(), 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 
134  connect(mServices->patient().get(), &PatientModelService::patientChanged, this, &MainWindow::patientChangedSlot);
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  this->menuBar()->setVisible(settings()->value("Gui/showMenuBar").toBool());
144 
145  // show after window has been initialized
146  QTimer::singleShot(0, this, SLOT(delayedShow()));
147 }
148 
150 {
151  // Restore saved window states
152  // Must be done after all DockWidgets are created
153  if (restoreGeometry(settings()->value("mainWindow/geometry").toByteArray()))
154  {
155  this->show();
156  }
157  else
158  {
159  this->showMaximized();
160  }
161 
162  if (settings()->value("gui/fullscreen").toBool())
163  {
164  this->setWindowState(this->windowState() | Qt::WindowFullScreen);
165  }
166 }
167 
168 void MainWindow::changeEvent(QEvent * event)
169 {
170  QMainWindow::changeEvent(event);
171 
172  if (event->type() == QEvent::WindowStateChange)
173  {
174  if (mFullScreenAction)
175  mFullScreenAction->setChecked(this->windowState() & Qt::WindowFullScreen);
176  }
177 }
178 
179 void MainWindow::setupGUIExtenders()
180 {
181  mServiceListener.reset(new ServiceTrackerListener<GUIExtenderService>(
182  LogicManager::getInstance()->getPluginContext(),
183  boost::bind(&MainWindow::onGUIExtenderServiceAdded, this, _1),
184  boost::bind(&MainWindow::onGUIExtenderServiceModified, this, _1),
185  boost::bind(&MainWindow::onGUIExtenderServiceRemoved, this, _1)
186  ));
187  mServiceListener->open();
188 }
189 
191 {
192  std::vector<GUIExtenderService::CategorizedWidget> widgets = service->createWidgets();
193  for (unsigned j = 0; j < widgets.size(); ++j)
194  {
195  if(!widgets[j].mPlaceInSeparateWindow)
196  mDockWidgets->addAsDockWidget(widgets[j].mWidget, widgets[j].mCategory, service);
197  else
198  this->createActionForWidgetInSeparateWindow(widgets[j].mWidget);
199  }
200 
201  std::vector<QToolBar*> toolBars = service->createToolBars();
202  for(unsigned j = 0; j < toolBars.size(); ++j)
203  {
204  mDockWidgets->registerToolBar(toolBars[j]);
205  }
206 }
207 
209 {
210 }
211 
213 {
214  mDockWidgets->owningServiceRemoved(service);
215 }
216 
218 {
219  if (val)
220  this->focusInsideDockWidget(sender());
221 }
222 
223 void MainWindow::focusChanged(QWidget * old, QWidget * now)
224 {
225  this->focusInsideDockWidget(now);
226 }
227 
228 void MainWindow::focusInsideDockWidget(QObject *dockWidget)
229 {
230  if (!dockWidget)
231  return;
232 
233 // CX_LOG_CHANNEL_DEBUG("HELP_DB") << QString(" try mw::focus [%1](%2)")
234 // .arg(dockWidget->objectName())
235 // .arg(dockWidget->metaObject()->className());
236 
237  // focusing to docked widgets is required by the help system
238 
239  // Assume structure: QDockWidget->QScrollArea->QWidget,
240  // as defined in MainWindow::addAsDockWidget()
241  QDockWidget* dw = dynamic_cast<QDockWidget*>(dockWidget);
242  if (!dw)
243  return;
244  if (dw->parent()!=this) // avoid events from other mainwindows
245  return;
246  QScrollArea* sa = dynamic_cast<QScrollArea*>(dw->widget());
247  if (!sa)
248  return;
249 
250  if (!sa->widget())
251  return;
252 
253 // CX_LOG_CHANNEL_DEBUG("HELP_DB") << QString(" do mw::focus [%1](%2)")
254 // .arg(sa->widget()->objectName())
255 // .arg(sa->widget()->metaObject()->className());
256 
257  QTimer::singleShot(0, sa->widget(), SLOT(setFocus())); // avoid loops etc by send async event.
258 }
259 
261 {
262  mServices->view()->deactivateLayout();
263  reporter()->setAudioSource(AudioPtr()); // important! QSound::play fires a thread, causes segfault during shutdown
264  mServiceListener.reset();
265 }
266 
268 {
269  return mDockWidgets->createPopupMenu();
270 }
271 
272 void MainWindow::createActions()
273 {
274  CameraControlPtr cameraControl = mServices->view()->getCameraControl();
275  if (cameraControl)
276  mStandard3DViewActions = cameraControl->createStandard3DViewActions();
277 
278  mShowContextSensitiveHelpAction = new QAction(QIcon(":/icons/open_icon_library/help-contents-5.png"),
279  "Context-sensitive help", this);
280  connect(mShowContextSensitiveHelpAction, &QAction::triggered, this, &MainWindow::onShowContextSentitiveHelp);
281 
282  mShowControlPanelAction = new QAction("Show Control Panel", this);
283  connect(mShowControlPanelAction, &QAction::triggered, this, &MainWindow::showControlPanelActionSlot);
284  mSecondaryViewLayoutWindowAction = new QAction("Show Secondary View Layout Window", this);
285  connect(mSecondaryViewLayoutWindowAction, &QAction::triggered, this, &MainWindow::showSecondaryViewLayoutWindowActionSlot);
286 
287  // Application
288  mAboutAction = new QAction(tr("About"), this);
289  mAboutAction->setStatusTip(tr("Show the application's About box"));
290  mPreferencesAction = new QAction(tr("Preferences"), this);
291  mPreferencesAction->setShortcut(tr("Ctrl+,"));
292  mPreferencesAction->setStatusTip(tr("Show the preferences dialog"));
293 
294  mFullScreenAction = new QAction(tr("Fullscreen"), this);
295  mFullScreenAction->setShortcut(tr("F11"));
296  mFullScreenAction->setStatusTip(tr("Toggle full screen"));
297  mFullScreenAction->setCheckable(true);
298  mFullScreenAction->setChecked(this->windowState() & Qt::WindowFullScreen);
299  connect(mFullScreenAction, &QAction::triggered, this, &MainWindow::toggleFullScreenSlot);
300 
301  mQuitAction = new QAction(tr("&Quit"), this);
302  mQuitAction->setShortcut(tr("Ctrl+Q"));
303  mQuitAction->setStatusTip(tr("Exit the application"));
304 
305  connect(mAboutAction, &QAction::triggered, this, &MainWindow::aboutSlot);
306  connect(mPreferencesAction, &QAction::triggered, this, &MainWindow::preferencesSlot);
307  connect(mQuitAction, &QAction::triggered, qApp, &QApplication::quit);
308 
309  mSaveDesktopAction = new QAction(QIcon(":/icons/workflow_state_save.png"), tr("Save desktop"), this);
310  mSaveDesktopAction->setToolTip("Save desktop for workflow step");
311  connect(mSaveDesktopAction, &QAction::triggered, this, &MainWindow::saveDesktopSlot);
312  mResetDesktopAction = new QAction(QIcon(":/icons/workflow_state_revert.png"), tr("Reset desktop"), this);
313  mResetDesktopAction->setToolTip("Reset desktop for workflow step");
314  connect(mResetDesktopAction, &QAction::triggered, this, &MainWindow::resetDesktopSlot);
315 
316  mInteractorStyleActionGroup = mServices->view()->getInteractorStyleActionGroup();
317 
318  // cross-connect save patient to save session
319  connect(mServices->session().get(), &SessionStorageService::isSaving, this, &MainWindow::saveDesktopSlot);
320 }
321 
322 
324 {
325  this->updateWindowTitle();
326 }
327 
328 void MainWindow::updateWindowTitle()
329 {
330  QString profileName = mServices->state()->getApplicationStateName();
331  QString versionName = mServices->state()->getVersionName();
332 
333  QString activePatientFolder = mServices->patient()->getActivePatientFolder();
334  if (activePatientFolder.endsWith('/'))
335  activePatientFolder.chop(1);
336  QString patientName;
337 
338  if (!activePatientFolder.isEmpty())
339  {
340  QFileInfo info(activePatientFolder);
341  patientName = info.completeBaseName();
342  }
343 
344  QString format("%1 %2 - %3 - %4 (not approved for medical use)");
345  QString title = format
346  .arg(qApp->applicationDisplayName())
347  .arg(versionName)
348  .arg(profileName)
349  .arg(patientName);
350  this->setWindowTitle(title);
351 }
352 
354 {
355  Desktop desktop = mServices->state()->getActiveDesktop();
356 
357  mDockWidgets->restoreFrom(desktop);
358  mServices->view()->setActiveLayout(desktop.mLayoutUid, 0);
359  mServices->view()->setActiveLayout(desktop.mSecondaryLayoutUid, 1);
360  mServices->patient()->autoSave();
361 
362  // moved to help plugin:
363 // // set initial focus to mainwindow in order to view it in the documentation
364 // // this is most important when starting up.
365 // QTimer::singleShot(0, this, SLOT(setFocus())); // avoid loops etc by send async event.
366 
367 //#ifdef CX_APPLE
368 // // HACK
369 // // Toolbars are not correctly refreshed on mac 10.8,
370 // // Cause is related to QVTKWidget (removing it removes the problem)
371 // // The following "force refresh by resize" solves repaint, but
372 // // inactive toolbars are still partly clickable.
373 // QSize size = this->size();
374 // this->resize(size.width()-1, size.height());
375 // this->resize(size);
376 //#endif
377 }
378 
380 {
381  Desktop desktop;
382  desktop.mMainWindowState = this->saveState();
383  desktop.mLayoutUid = mServices->view()->getActiveLayout(0);
384  desktop.mSecondaryLayoutUid = mServices->view()->getActiveLayout(1);
385  mServices->state()->saveDesktop(desktop);
386 
387  // save to settings file in addition
388  settings()->setValue("mainWindow/geometry", saveGeometry());
389  settings()->setValue("mainWindow/windowState", saveState());
390  settings()->sync();
391 }
392 
394 {
395  mServices->state()->resetDesktop();
397 }
398 
400 {
401  mDockWidgets->showWidget("Help");
402 }
403 
405 {
406  this->setWindowState(this->windowState() ^ Qt::WindowFullScreen);
407 
408  settings()->setValue("gui/fullscreen", (this->windowState() & Qt::WindowFullScreen)!=0);
409 }
410 
411 void MainWindow::createActionForWidgetInSeparateWindow(QWidget* widget)
412 {
413  QString uid = widget->objectName();
414  if(mSecondaryMainWindows.find(uid) == mSecondaryMainWindows.end())
415  {
416  SecondaryMainWindow* secondaryMainWindow = new SecondaryMainWindow(this, widget);
417  QAction* action = new QAction(widget->windowTitle(), this);
418 
419  mSecondaryMainWindows[uid] = secondaryMainWindow;
420  mSecondaryMainWindowsActions[uid] = action;
421 
422  connect(action, &QAction::triggered, secondaryMainWindow, &QWidget::show);
423 
424  mFileMenu->addAction(action);
425  }
426 }
427 
429 {
430  if (!mControlPanel)
431  {
432  TrackPadWidget* trackPadWidget = new TrackPadWidget(mServices->view(), this);
433  mControlPanel = new SecondaryMainWindow(this, trackPadWidget);
434  }
435  mControlPanel->show();
436 }
437 
439 {
440  if (!mSecondaryViewLayoutWindow)
441  mSecondaryViewLayoutWindow = new SecondaryViewLayoutWindow(this);
442  mSecondaryViewLayoutWindow->tryShowOnSecondaryScreen();
443 }
444 
446 {
447  this->updateWindowTitle();
448 }
449 
450 void MainWindow::createMenus()
451 {
452 #ifdef CX_LINUX
453  // shortcuts defined on actions in the global menubar is not reachable on Qt5+Ubuntu14.04,
454  // solve by reverting to old style.
455  // This will create a double menubar: remove by autohiding menubar or using
456  // sudo apt-get autoremove appmenu-gtk appmenu-gtk3 appmenu-qt
457  // and reboot
458  this->menuBar()->setNativeMenuBar(false);
459 #endif
460  mFileMenu = new QMenu(tr("File"), this);
461  mWorkflowMenu = new QMenu(tr("Workflow"), this);
462  mToolMenu = new QMenu(tr("Tracking"), this);
463  mLayoutMenu = new QMenu(tr("Layouts"), this);
464  mNavigationMenu = new QMenu(tr("Navigation"), this);
465  mHelpMenu = new QMenu(tr("Help"), this);
466 
467  // File
468  mFileMenu->addAction(mPreferencesAction);
469  this->menuBar()->addMenu(mFileMenu);
470  mFileMenu->addAction(mActions->getAction("NewPatient"));
471  mFileMenu->addAction(mActions->getAction("SaveFile"));
472  mFileMenu->addAction(mActions->getAction("LoadFile"));
473  mFileMenu->addAction(mActions->getAction("LoadFileCopy"));
474  mFileMenu->addAction(mActions->getAction("ClearPatient"));
475  mFileMenu->addSeparator();
476  mFileMenu->addAction(mActions->getAction("ExportPatient"));
477  mFileMenu->addAction(mActions->getAction("ImportData"));
478  mFileMenu->addSeparator();
479  mFileMenu->addAction(mFullScreenAction);
480  mFileMenu->addAction(mActions->getAction("StartLogConsole"));
481  mFileMenu->addAction(mActions->getAction("ShootScreen"));
482  mFileMenu->addAction(mActions->getAction("ShootWindow"));
483  mFileMenu->addAction(mActions->getAction("RecordFullscreen"));
484  mFileMenu->addSeparator();
485  mFileMenu->addAction(mShowControlPanelAction);
486  mFileMenu->addAction(mSecondaryViewLayoutWindowAction);
487 
488  mFileMenu->addAction(mQuitAction);
489 
490  //workflow
491  this->menuBar()->addMenu(mWorkflowMenu);
492  QList<QAction*> actions = mServices->state()->getWorkflowActions()->actions();
493  for (int i=0; i<actions.size(); ++i)
494  {
495  mWorkflowMenu->addAction(actions[i]);
496  }
497 
498  mWorkflowMenu->addSeparator();
499  mWorkflowMenu->addAction(mSaveDesktopAction);
500  mWorkflowMenu->addAction(mResetDesktopAction);
501 
502  //tool
503  this->menuBar()->addMenu(mToolMenu);
504  mToolMenu->addAction(mActions->getAction("ConfigureTools"));
505  mToolMenu->addAction(mActions->getAction("InitializeTools"));
506  mToolMenu->addAction(mActions->getAction("TrackingTools"));
507  mToolMenu->addSeparator();
508  mToolMenu->addAction(mActions->getAction("StartStreaming"));
509  mToolMenu->addSeparator();
510 
511  //layout
512  this->menuBar()->addMenu(mLayoutMenu);
513  mLayoutInteractor->connectToMenu(mLayoutMenu);
514 
515  this->menuBar()->addMenu(mNavigationMenu);
516  mNavigationMenu->addAction(mActions->getAction("CenterToImageCenter"));
517  mNavigationMenu->addAction(mActions->getAction("CenterToTooltip"));
518  mNavigationMenu->addAction(mActions->getAction("ShowPointPicker"));
519  mNavigationMenu->addSeparator();
520  mNavigationMenu->addActions(mInteractorStyleActionGroup->actions());
521 
522  mHelpMenuAction = this->menuBar()->addMenu(mHelpMenu);
523  mHelpMenu->addAction(mAboutAction);
524  mHelpMenu->addAction(mActions->getAction("GotoDocumentation"));
525  mHelpMenu->addAction(mShowContextSensitiveHelpAction);
526 }
527 
528 void MainWindow::createToolBars()
529 {
530  mWorkflowToolBar = this->registerToolBar("Workflow");
531  QList<QAction*> actions = mServices->state()->getWorkflowActions()->actions();
532  for (int i=0; i<actions.size(); ++i)
533  mWorkflowToolBar->addAction(actions[i]);
534 
535  mDataToolBar = this->registerToolBar("Data");
536  mDataToolBar->addAction(mActions->getAction("NewPatient"));
537  mDataToolBar->addAction(mActions->getAction("LoadFile"));
538  mDataToolBar->addAction(mActions->getAction("SaveFile"));
539  mDataToolBar->addAction(mActions->getAction("ImportData"));
540 
541  mToolToolBar = this->registerToolBar("Tools");
542  mToolToolBar->addAction(mActions->getAction("TrackingTools"));
543  mToolToolBar->addAction(mActions->getAction("StartStreaming"));
544 
545  mNavigationToolBar = this->registerToolBar("Navigation");
546  mNavigationToolBar->addAction(mActions->getAction("CenterToImageCenter"));
547  mNavigationToolBar->addAction(mActions->getAction("CenterToTooltip"));
548  mNavigationToolBar->addAction(mActions->getAction("ShowPointPicker"));
549 
550  mInteractorStyleToolBar = this->registerToolBar("InteractorStyle");
551  mInteractorStyleToolBar->addActions(mInteractorStyleActionGroup->actions());
552 
553  mDesktopToolBar = this->registerToolBar("Desktop");
554  mDesktopToolBar->addAction(mSaveDesktopAction);
555  mDesktopToolBar->addAction(mResetDesktopAction);
556 
557  mScreenshotToolBar = this->registerToolBar("Screenshot");
558  mScreenshotToolBar->addAction(mActions->getAction("ShootScreen"));
559  mScreenshotToolBar->addAction(mActions->getAction("RecordFullscreen"));
560 
561  QToolBar* camera3DViewToolBar = this->registerToolBar("Camera 3D Views");
562  camera3DViewToolBar->addActions(mStandard3DViewActions->actions());
563 
564  QToolBar* samplerWidgetToolBar = this->registerToolBar("Sampler");
565  samplerWidgetToolBar->addWidget(new SamplerWidget(mServices->tracking(), mServices->patient(), mServices->spaceProvider(), this));
566 
567  QToolBar* toolOffsetToolBar = this->registerToolBar("Tool Offset");
569  SpinBoxAndSliderGroupWidget* offsetWidget = new SpinBoxAndSliderGroupWidget(this, offset);
570  offsetWidget->showLabel(false);
571  toolOffsetToolBar->addWidget(offsetWidget);
572 
573  QToolBar* helpToolBar = this->registerToolBar("Help");
574  helpToolBar->addAction(mShowContextSensitiveHelpAction);
575 }
576 
577 QToolBar* MainWindow::registerToolBar(QString name, QString groupname)
578 {
579  QToolBar* toolbar = new QToolBar(name);
580  toolbar->setObjectName(QString(name).remove(" ")+"ToolBar");
581  mDockWidgets->registerToolBar(toolbar, groupname);
582  return toolbar;
583 }
584 
586 {
587  QString doc_path = DataLocations::getDocPath();
588  QString appName = qApp->applicationDisplayName();
589  QString url_website = DataLocations::getWebsiteURL();
590  QString url_license = QString("file://%1/License.txt").arg(doc_path);
591  QString url_config = QString("file://%1/cxConfigDescription.txt").arg(doc_path);
592 
593  QString text(""
594  "<h2>%1</h2>"
595  "<h4>%2</h4>"
596  "<p>A Research Platform for Image-Guided Therapy<p>"
597  "<p>%1 is NOT approved for medical use.<p>"
598  ""
599  "<p><a href=%3> website </a><p>"
600  "<p><a href=%4> license </a><p>"
601  "<p><a href=%5> configuration </a><p>");
602 
603  QMessageBox::about(this, tr("About %1").arg(appName), text
604  .arg(appName)
605  .arg(CustusX_VERSION_STRING)
606  .arg(url_website)
607  .arg(url_license)
608  .arg(url_config)
609  );
610 }
611 
613 {
614  PreferencesDialog prefDialog(mServices->view(), mServices->patient(), mServices->state(), mServices->tracking(), this);
615  prefDialog.exec();
616 }
617 
618 void MainWindow::closeEvent(QCloseEvent *event)
619 {
620  QMainWindow::closeEvent(event);
621  qApp->quit();
622 }
623 
624 QDockWidget* MainWindow::addAsDockWidget(QWidget* widget, QString groupname)
625 {
626  QDockWidget* dw = mDockWidgets->addAsDockWidget(widget, groupname);
627  return dw;
628 
629 }
630 
631 }//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)
boost::shared_ptr< class CameraControl > CameraControlPtr
Statusbar with extended functionality.
Definition: cxStatusBar.h:91
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)
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...
Composite widget for scalar data manipulation.
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)
QString mLayoutUid
virtual ~MainWindow()
virtual std::vector< QToolBar * > createToolBars() const
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.
Namespace for all CustusX production code.