Computer Assisted Medical Intervention Tool Kit  version 6.0
Loading...
Searching...
No Matches
camitk::MainWindow Class Reference

This class is the base class for your application. More...

#include <MainWindow.h>

Public Slots

Refresh and show
virtual void refresh ()
void show ()
 inherited from QWidget, just to refresh all viewers

Public Member Functions

general
 MainWindow (QString title)
 Constructor, the window title can be changed here, it is inconsistent to use setWindowTitle().
 ~MainWindow () override
 destructor
virtual void aboutToShow ()
 this method is automatically called by Application before the first time show() is called.
title, subtitle, status bar message, progress bar state and console
QString getName () const
 Get the main window title.
void setWindowSubtitle (QString)
 The subtitle is situated at the end of the title, on the title bar, is helps for example showing which file is currently selected.
QProgressBar * getProgressBar ()
 similar as statusBar() from QMainWindow but for the progress bar
void showStatusBar (bool)
 show the status bar (by default it is hidden)
virtual void redirectToConsole (bool)
 use or not the application console (redirect or not standard out/err streams)
void showConsole (bool)
 get the console window
bool getConsoleVisibility ()
 get the visibility state of the console (
Initialize and save settings
virtual void initSettings ()
void saveSettings ()
 Save MainWindow's settings into Application::settings.
Viewers
virtual void showDockViewer (Viewer *, bool)
 set the visibility for the given docked viewer
virtual void addDockViewer (Qt::DockWidgetArea, Viewer *)
 add a Viewer to the application as a docking widget and specify where it has to be docked Note that MainWindow takes ownership of the Viewer pointer and deletes it at the appropriate time.
void refreshViewers ()
 Method uses to refresh all the viewer of the Main Window.
virtual void setCentralViewer (Viewer *)
 set the central Viewer of the application.
virtual ViewergetCentralViewer () const

Protected Member Functions

void closeEvent (QCloseEvent *) override
 overriden from QMainWindow, just connect to slotFileQuit
void dragEnterEvent (QDragEnterEvent *event) override
 called when a drag event started on the main window, accept drag only if file is MIME type text/uri-list
void dragLeaveEvent (QDragLeaveEvent *event) override
 called when the mouse leaves the widgets area during a drag/drop operation
void dragMoveEvent (QDragMoveEvent *event) override
 called when the mouse moves inside the widgets area during a drag/drop operation
void dropEvent (QDropEvent *event) override
 just call open with the dragged uri

Protected Attributes

ViewercentralViewer
 The actual central Viewer.
Viewer and other things
QList< Viewer * > viewers
QMap< Viewer *, QDockWidget * > dockWidgetMap
 the map that gives the corresponding QDockWidget for a given Viewer

Detailed Description

This class is the base class for your application.

It sets up the main window and creates a menubar and statusbar (all hidden by default).

It is the default main window for a application.

Create a class that inherits from MainWindow to get all the goodies of CamiTK and add your own customization/UI.

See tutorials applications for examples.

The central widget's layout is a QStackedLayout: when new central viewers are added, the previous central viewer is hidden, not destroyed.

Constructor & Destructor Documentation

◆ MainWindow()

MainWindow::MainWindow ( QString title)

Constructor, the window title can be changed here, it is inconsistent to use setWindowTitle().

If you like to dynamically add some information to the window title, please use setWindowSubtitle() instead.

See also
setWindowSubtitle
Parameters
titlemain window title

References centralViewer, camitk::InterfaceLogger::ERROR, camitk::Application::getAction(), camitk::Log::getLogger(), camitk::Action::getQAction(), camitk::InterfaceLogger::INFO, showStatusBar(), camitk::InterfaceLogger::TRACE, and camitk::InterfaceLogger::WARNING.

Referenced by ImpMainWindow::ImpMainWindow().

◆ ~MainWindow()

MainWindow::~MainWindow ( )
override

destructor

References dockWidgetMap.

Member Function Documentation

◆ aboutToShow()

void MainWindow::aboutToShow ( )
virtual

this method is automatically called by Application before the first time show() is called.

This method calls initSettings().

Reimplemented in ImpMainWindow.

References initSettings().

Referenced by ImpMainWindow::aboutToShow().

◆ addDockViewer()

void MainWindow::addDockViewer ( Qt::DockWidgetArea dockingArea,
Viewer * theViewer )
virtual

add a Viewer to the application as a docking widget and specify where it has to be docked Note that MainWindow takes ownership of the Viewer pointer and deletes it at the appropriate time.

This method calls addViewer(...). This method calls showDockViewer(..,true)

Note
MainWindow takes ownership of the viewer pointer and deletes it when it is itself destroyed.

Reimplemented in ImpMainWindow.

References dockWidgetMap, camitk::Viewer::setDockWidget(), and showDockViewer().

Referenced by ImpMainWindow::addDockViewer().

◆ closeEvent()

void MainWindow::closeEvent ( QCloseEvent * event)
overrideprotected

overriden from QMainWindow, just connect to slotFileQuit

References camitk::Application::getAction(), saveSettings(), and camitk::Action::SUCCESS.

◆ dragEnterEvent()

void MainWindow::dragEnterEvent ( QDragEnterEvent * event)
overrideprotected

called when a drag event started on the main window, accept drag only if file is MIME type text/uri-list

◆ dragLeaveEvent()

void MainWindow::dragLeaveEvent ( QDragLeaveEvent * event)
overrideprotected

called when the mouse leaves the widgets area during a drag/drop operation

◆ dragMoveEvent()

void MainWindow::dragMoveEvent ( QDragMoveEvent * event)
overrideprotected

called when the mouse moves inside the widgets area during a drag/drop operation

◆ dropEvent()

void MainWindow::dropEvent ( QDropEvent * event)
overrideprotected

just call open with the dragged uri

References camitk::Application::open().

◆ getCentralViewer()

Viewer * MainWindow::getCentralViewer ( ) const
virtual
Returns
the current central viewer.

References centralViewer.

◆ getConsoleVisibility()

bool MainWindow::getConsoleVisibility ( )

get the visibility state of the console (

Returns
true if and only if the console is currently visible)

Referenced by ToggleConsoleAction::apply().

◆ getName()

QString MainWindow::getName ( ) const

Get the main window title.

◆ getProgressBar()

QProgressBar * MainWindow::getProgressBar ( )

similar as statusBar() from QMainWindow but for the progress bar

Referenced by ImpMainWindow::openDataDirectory().

◆ initSettings()

void MainWindow::initSettings ( )
virtual

◆ redirectToConsole()

void MainWindow::redirectToConsole ( bool visible)
virtual

use or not the application console (redirect or not standard out/err streams)

Reimplemented in ImpMainWindow.

References CAMITK_INFO, and camitk::Core::version().

Referenced by main(), and ImpMainWindow::redirectToConsole().

◆ refresh

void MainWindow::refresh ( )
virtualslot

this slot is connected to all the viewers selectionChanged() signal, this will call the refresh method of all viewers

References camitk::Application::getTriggeredAction(), and viewers.

Referenced by ImpMainWindow::refresh(), and show().

◆ refreshViewers()

void MainWindow::refreshViewers ( )

Method uses to refresh all the viewer of the Main Window.

References viewers.

◆ saveSettings()

void MainWindow::saveSettings ( )

Save MainWindow's settings into Application::settings.

References camitk::Application::getName(), and camitk::Application::getSettings().

Referenced by closeEvent(), and camitk::Application::saveWorkspace().

◆ setCentralViewer()

void MainWindow::setCentralViewer ( Viewer * theViewer)
virtual

set the central Viewer of the application.

The central viewer has a specific behaviour in a MainWindow. It uses a QStackWidget to keep all the central viewer that are used. When a new central viewers is set, the previous central viewer (i.e., its widget) is hidden but not destroyed.

This method calls addViewer(..).

Note
MainWindow takes ownership of the viewer pointer and deletes it when it is itself destroyed.

Reimplemented in ImpMainWindow.

References centralViewer, camitk::Application::getName(), camitk::Application::getSettings(), camitk::Application::getViewer(), and camitk::Application::registerViewer().

Referenced by BitmapViewer::getToolBar(), initSettings(), and ImpMainWindow::setCentralViewer().

◆ setWindowSubtitle()

void MainWindow::setWindowSubtitle ( QString subtitle)

The subtitle is situated at the end of the title, on the title bar, is helps for example showing which file is currently selected.

It appears between brackets "[ ... ]"

Note
the main title is set to Core::version(), you can change the title part (i.e. the part of the title bar before the subtitle), by calling setWindowTitle(...)

Referenced by ImpMainWindow::updateActionStates().

◆ show

void MainWindow::show ( )
slot

inherited from QWidget, just to refresh all viewers

References camitk::Application::getAction(), camitk::Action::getQAction(), and refresh().

Referenced by showConsole().

◆ showConsole()

void MainWindow::showConsole ( bool show)

get the console window

References show().

Referenced by ToggleConsoleAction::apply().

◆ showDockViewer()

void MainWindow::showDockViewer ( Viewer * theViewer,
bool visible )
virtual

set the visibility for the given docked viewer

References dockWidgetMap.

Referenced by addDockViewer(), and ImpMainWindow::ImpMainWindow().

◆ showStatusBar()

void MainWindow::showStatusBar ( bool b)

show the status bar (by default it is hidden)

Referenced by MainWindow(), and ImpMainWindow::showStatusBar().

Member Data Documentation

◆ centralViewer

Viewer* camitk::MainWindow::centralViewer
protected

The actual central Viewer.

Note
MainWindow, like QMainWindow with its central widget contains an unique central viewer.

Referenced by getCentralViewer(), MainWindow(), setCentralViewer(), and ImpMainWindow::updateViewMenu().

◆ dockWidgetMap

QMap<Viewer*, QDockWidget*> camitk::MainWindow::dockWidgetMap
protected

◆ viewers

QList<Viewer*> camitk::MainWindow::viewers
protected

The documentation for this class was generated from the following files: