36 #include "boost/bind.hpp" 82 mFullScreenAction(NULL),
83 mStandard3DViewActions(new QActionGroup(this)),
88 this->setObjectName(
"main_window");
93 this->setCentralWidget(mServices->view()->createLayoutWidget(
this, 0));
97 this->createActions();
99 this->createToolBars();
100 this->setStatusBar(
new StatusBar(mServices->tracking(), mServices->view(), mServices->video()));
108 this->updateWindowTitle();
110 this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
112 this->addAsDockWidget(
new PlaybackWidget(mServices->tracking(), mServices->video(), mServices->patient(),
this),
"Browsing");
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");
119 this->addAsDockWidget(
new StreamPropertiesWidget(mServices->patient(), mServices->view(),
this),
"Properties");
120 this->addAsDockWidget(
new TrackPadWidget(mServices->view(),
this),
"Utility");
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");
126 this->addAsDockWidget(
new FrameTreeWidget(mServices->patient(),
this),
"Browsing");
127 this->addAsDockWidget(
new ToolManagerWidget(mServices->tracking(),
this),
"Debugging");
132 this->addAsDockWidget(
new BrowserWidget(
this, mServices),
"Browsing");
137 this->setupGUIExtenders();
141 popupMenu->setTitle(
"Window");
142 this->menuBar()->insertMenu(mHelpMenuAction, popupMenu);
143 this->menuBar()->setVisible(
settings()->value(
"Gui/showMenuBar").toBool());
153 if (restoreGeometry(
settings()->value(
"mainWindow/geometry").toByteArray()))
159 this->showMaximized();
162 if (
settings()->value(
"gui/fullscreen").toBool())
164 this->setWindowState(this->windowState() | Qt::WindowFullScreen);
170 QMainWindow::changeEvent(event);
172 if (event->type() == QEvent::WindowStateChange)
174 if (mFullScreenAction)
175 mFullScreenAction->setChecked(this->windowState() & Qt::WindowFullScreen);
179 void MainWindow::setupGUIExtenders()
187 mServiceListener->open();
192 std::vector<GUIExtenderService::CategorizedWidget> widgets = service->
createWidgets();
193 for (
unsigned j = 0; j < widgets.size(); ++j)
195 if(!widgets[j].mPlaceInSeparateWindow)
196 mDockWidgets->
addAsDockWidget(widgets[j].mWidget, widgets[j].mCategory, service);
198 this->createActionForWidgetInSeparateWindow(widgets[j].mWidget);
202 for(
unsigned j = 0; j < toolBars.size(); ++j)
220 this->focusInsideDockWidget(sender());
225 this->focusInsideDockWidget(now);
228 void MainWindow::focusInsideDockWidget(QObject *dockWidget)
241 QDockWidget* dw =
dynamic_cast<QDockWidget*
>(dockWidget);
244 if (dw->parent()!=
this)
246 QScrollArea* sa =
dynamic_cast<QScrollArea*
>(dw->widget());
257 QTimer::singleShot(0, sa->widget(), SLOT(setFocus()));
262 mServices->view()->deactivateLayout();
264 mServiceListener.reset();
272 void MainWindow::createActions()
276 mStandard3DViewActions = cameraControl->createStandard3DViewActions();
278 mShowContextSensitiveHelpAction =
new QAction(QIcon(
":/icons/open_icon_library/help-contents-5.png"),
279 "Context-sensitive help",
this);
282 mShowControlPanelAction =
new QAction(
"Show Control Panel",
this);
284 mSecondaryViewLayoutWindowAction =
new QAction(
"Show Secondary View Layout Window",
this);
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"));
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);
301 mQuitAction =
new QAction(tr(
"&Quit"),
this);
302 mQuitAction->setShortcut(tr(
"Ctrl+Q"));
303 mQuitAction->setStatusTip(tr(
"Exit the application"));
307 connect(mQuitAction, &QAction::triggered, qApp, &QApplication::quit);
309 mSaveDesktopAction =
new QAction(QIcon(
":/icons/workflow_state_save.png"), tr(
"Save desktop"),
this);
310 mSaveDesktopAction->setToolTip(
"Save desktop for workflow step");
312 mResetDesktopAction =
new QAction(QIcon(
":/icons/workflow_state_revert.png"), tr(
"Reset desktop"),
this);
313 mResetDesktopAction->setToolTip(
"Reset desktop for workflow step");
316 mInteractorStyleActionGroup = mServices->view()->getInteractorStyleActionGroup();
325 this->updateWindowTitle();
328 void MainWindow::updateWindowTitle()
330 QString profileName = mServices->state()->getApplicationStateName();
331 QString versionName = mServices->state()->getVersionName();
333 QString activePatientFolder = mServices->patient()->getActivePatientFolder();
334 if (activePatientFolder.endsWith(
'/'))
335 activePatientFolder.chop(1);
338 if (!activePatientFolder.isEmpty())
340 QFileInfo info(activePatientFolder);
341 patientName = info.completeBaseName();
344 QString format(
"%1 %2 - %3 - %4 (not approved for medical use)");
345 QString title = format
346 .arg(qApp->applicationDisplayName())
350 this->setWindowTitle(title);
355 Desktop desktop = mServices->state()->getActiveDesktop();
358 mServices->view()->setActiveLayout(desktop.
mLayoutUid, 0);
360 mServices->patient()->autoSave();
383 desktop.
mLayoutUid = mServices->view()->getActiveLayout(0);
385 mServices->state()->saveDesktop(desktop);
395 mServices->state()->resetDesktop();
406 this->setWindowState(this->windowState() ^ Qt::WindowFullScreen);
408 settings()->
setValue(
"gui/fullscreen", (this->windowState() & Qt::WindowFullScreen)!=0);
411 void MainWindow::createActionForWidgetInSeparateWindow(QWidget* widget)
413 QString uid = widget->objectName();
414 if(mSecondaryMainWindows.find(uid) == mSecondaryMainWindows.end())
417 QAction* action =
new QAction(widget->windowTitle(),
this);
419 mSecondaryMainWindows[uid] = secondaryMainWindow;
420 mSecondaryMainWindowsActions[uid] = action;
422 connect(action, &QAction::triggered, secondaryMainWindow, &QWidget::show);
424 mFileMenu->addAction(action);
435 mControlPanel->show();
440 if (!mSecondaryViewLayoutWindow)
442 mSecondaryViewLayoutWindow->tryShowOnSecondaryScreen();
447 this->updateWindowTitle();
450 void MainWindow::createMenus()
458 this->menuBar()->setNativeMenuBar(
false);
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);
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);
488 mFileMenu->addAction(mQuitAction);
491 this->menuBar()->addMenu(mWorkflowMenu);
492 QList<QAction*> actions = mServices->state()->getWorkflowActions()->actions();
493 for (
int i=0; i<actions.size(); ++i)
495 mWorkflowMenu->addAction(actions[i]);
498 mWorkflowMenu->addSeparator();
499 mWorkflowMenu->addAction(mSaveDesktopAction);
500 mWorkflowMenu->addAction(mResetDesktopAction);
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();
512 this->menuBar()->addMenu(mLayoutMenu);
513 mLayoutInteractor->connectToMenu(mLayoutMenu);
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());
522 mHelpMenuAction = this->menuBar()->addMenu(mHelpMenu);
523 mHelpMenu->addAction(mAboutAction);
524 mHelpMenu->addAction(mActions->
getAction(
"GotoDocumentation"));
525 mHelpMenu->addAction(mShowContextSensitiveHelpAction);
528 void MainWindow::createToolBars()
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]);
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"));
541 mToolToolBar = this->registerToolBar(
"Tools");
542 mToolToolBar->addAction(mActions->
getAction(
"TrackingTools"));
543 mToolToolBar->addAction(mActions->
getAction(
"StartStreaming"));
545 mNavigationToolBar = this->registerToolBar(
"Navigation");
546 mNavigationToolBar->addAction(mActions->
getAction(
"CenterToImageCenter"));
547 mNavigationToolBar->addAction(mActions->
getAction(
"CenterToTooltip"));
548 mNavigationToolBar->addAction(mActions->
getAction(
"ShowPointPicker"));
550 mInteractorStyleToolBar = this->registerToolBar(
"InteractorStyle");
551 mInteractorStyleToolBar->addActions(mInteractorStyleActionGroup->actions());
553 mDesktopToolBar = this->registerToolBar(
"Desktop");
554 mDesktopToolBar->addAction(mSaveDesktopAction);
555 mDesktopToolBar->addAction(mResetDesktopAction);
557 mScreenshotToolBar = this->registerToolBar(
"Screenshot");
558 mScreenshotToolBar->addAction(mActions->
getAction(
"ShootScreen"));
559 mScreenshotToolBar->addAction(mActions->
getAction(
"RecordFullscreen"));
561 QToolBar* camera3DViewToolBar = this->registerToolBar(
"Camera 3D Views");
562 camera3DViewToolBar->addActions(mStandard3DViewActions->actions());
564 QToolBar* samplerWidgetToolBar = this->registerToolBar(
"Sampler");
565 samplerWidgetToolBar->addWidget(
new SamplerWidget(mServices->tracking(), mServices->patient(), mServices->spaceProvider(),
this));
567 QToolBar* toolOffsetToolBar = this->registerToolBar(
"Tool Offset");
571 toolOffsetToolBar->addWidget(offsetWidget);
573 QToolBar* helpToolBar = this->registerToolBar(
"Help");
574 helpToolBar->addAction(mShowContextSensitiveHelpAction);
577 QToolBar* MainWindow::registerToolBar(QString name, QString groupname)
579 QToolBar* toolbar =
new QToolBar(name);
580 toolbar->setObjectName(QString(name).
remove(
" ")+
"ToolBar");
588 QString appName = qApp->applicationDisplayName();
590 QString url_license = QString(
"file://%1/License.txt").arg(doc_path);
591 QString url_config = QString(
"file://%1/cxConfigDescription.txt").arg(doc_path);
596 "<p>A Research Platform for Image-Guided Therapy<p>" 597 "<p>%1 is NOT approved for medical use.<p>" 599 "<p><a href=%3> website </a><p>" 600 "<p><a href=%4> license </a><p>" 601 "<p><a href=%5> configuration </a><p>");
603 QMessageBox::about(
this, tr(
"About %1").arg(appName), text
605 .arg(CustusX_VERSION_STRING)
614 PreferencesDialog prefDialog(mServices->view(), mServices->patient(), mServices->state(), mServices->tracking(),
this);
618 void MainWindow::closeEvent(QCloseEvent *event)
620 QMainWindow::closeEvent(event);
624 QDockWidget* MainWindow::addAsDockWidget(QWidget* widget, QString groupname)
void registerToolBar(QToolBar *toolbar, QString groupname="Toolbars")
void dockWidgetVisibilityChanged(bool val)
virtual QMenu * createPopupMenu()
void changeEvent(QEvent *event)
boost::shared_ptr< class CameraControl > CameraControlPtr
Statusbar with extended functionality.
void applicationStateChanged()
void showSecondaryViewLayoutWindowActionSlot()
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...
void onApplicationStateChangedSlot()
QMenu * createPopupMenu()
void setValue(const QString &key, const QVariant &value)
Experimental class for IPad usage.
void workflowStateAboutToChange()
void onGUIExtenderServiceAdded(GUIExtenderService *service)
void toggleFullScreenSlot()
void onGUIExtenderServiceRemoved(GUIExtenderService *service)
static QString getWebsiteURL()
QByteArray mMainWindowState
static LogicManager * getInstance()
void showWidget(QString name)
void onGUIExtenderServiceModified(GUIExtenderService *service)
boost::shared_ptr< class DoublePropertyBase > DoublePropertyBasePtr
void onShowContextSentitiveHelp()
Settings * settings()
Shortcut for accessing the settings instance.
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)
void owningServiceRemoved(QObject *service)
virtual std::vector< QToolBar * > createToolBars() const
QString mSecondaryLayoutUid
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
void isSaving(QDomElement &root)
xml storage is available
Namespace for all CustusX production code.