Computer Assited Medical Intervention Tool Kit  version 5.0
camitk::MainWindow Class Reference

This class is the base class for your application. It sets up the main window and creates a menubar, toolbar and statusbar (all hidden by default). More...

#include <MainWindow.h>

+ Inheritance diagram for camitk::MainWindow:
+ Collaboration diagram for camitk::MainWindow:

Public Slots

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

Public Member Functions

general
 MainWindow (QString title)
 Constructor, the window title can be changed here, it is inconsistent to use setWindowTitle(). More...
 
 ~MainWindow () override
 destructor More...
 
virtual void aboutToShow ()
 this method is automatically called by Application before the first time show() is called. More...
 
title, subtitle, status bar message, progress bar state and console
QString getName () const
 Get the main window title. More...
 
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. More...
 
QProgressBar * getProgressBar ()
 similar as statusBar() from QMainWindow but for the progress bar More...
 
void showStatusBar (bool)
 show the status bar (by default it is hidden) More...
 
virtual void redirectToConsole (bool)
 use or not the application console (redirect or not standard out/err streams) More...
 
void showConsole (bool)
 get the console window More...
 
bool getConsoleVisibility ()
 get the visibility state of the console ( More...
 
Viewers
virtual void showDockViewer (Viewer *, bool)
 set the visibility for the given docked viewer and its toolbar More...
 
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. More...
 
void refreshViewers ()
 Method uses to refresh all the viewer of the Main Window. More...
 
virtual void setCentralViewer (Viewer *)
 set the central Viewer of the application. More...
 
virtual ViewergetCentralViewer () const
 
virtual void showViewerToolbar (Viewer *theViewer, bool visible)
 Set the visibility of a viewer's toolbar. More...
 

Protected Member Functions

void closeEvent (QCloseEvent *) override
 overriden from QMainWindow, just connect to slotFileQuit More...
 
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 More...
 
void dragLeaveEvent (QDragLeaveEvent *event) override
 called when the mouse leaves the widgets area during a drag/drop operation More...
 
void dragMoveEvent (QDragMoveEvent *event) override
 called when the mouse moves inside the widgets area during a drag/drop operation More...
 
void dropEvent (QDropEvent *event) override
 just call open with the dragged uri More...
 

Protected Attributes

ViewercentralViewer
 The actual central Viewer. More...
 

Private Member Functions

virtual bool addViewer (Viewer *)
 Add a viewer (called by addDockViewer and setCentralViewer), returns true if not already added. More...
 

Private Attributes

QStackedLayout * centralLayout
 the central widget is a frame, its layout is a QStackedLayout so that it is possible to easily switch between viewers More...
 
ConsoleStream cerr
 the error stream for the application console More...
 
QDockWidget * consoleWindow
 console to display all messages More...
 
QTextEdit * consoleWindowTextEdit
 the QTextEdit part of the console dialog More...
 
ConsoleStream cout
 the output stream for the application console More...
 
QString mainTitle
 the main part of the title More...
 
QProgressBar * myProgressBar
 the progress bar (access through setProgress() method) More...
 

Viewer and other things

QList< Viewer * > viewers
 
QMap< Viewer *, QDockWidget * > dockWidgetMap
 the map that gives the corresponding QDockWidget for a given Viewer More...
 
virtual void initSettings ()
 init MainWindow specific settings (e.g. size, position) More...
 

Detailed Description

This class is the base class for your application. It sets up the main window and creates a menubar, toolbar 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

◆ ~MainWindow()

MainWindow::~MainWindow ( )
override

destructor

References camitk::refresh().

+ Here is the call graph for this function:

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.

Referenced by camitk::Application::exec().

+ Here is the caller graph for this function:

◆ 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) and therefore showViewerToolbar(..,true)

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

Reimplemented in ImpMainWindow.

References camitk::Viewer::setEmbedder().

Referenced by ActionStateMachine::initMainWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addViewer()

bool MainWindow::addViewer ( Viewer theViewer)
privatevirtual

Add a viewer (called by addDockViewer and setCentralViewer), returns true if not already added.

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

This method connects the selectionChanged signal of the viewer to the refresh method of MainWindow.

◆ closeEvent()

void MainWindow::closeEvent ( QCloseEvent *  event)
overrideprotected

overriden from QMainWindow, just connect to slotFileQuit

◆ 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

◆ getCentralViewer()

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

◆ getConsoleVisibility()

bool MainWindow::getConsoleVisibility ( )

get the visibility state of the console (

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

◆ 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(), camitk::Application::resetProgressBar(), camitk::Application::setProgressBarValue(), and camitk::Application::vtkProgressFunction().

+ Here is the caller graph for this function:

◆ initSettings()

void MainWindow::initSettings ( )
protectedvirtual

init MainWindow specific settings (e.g. size, position)

◆ redirectToConsole()

void MainWindow::redirectToConsole ( bool  visible)
virtual

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

Reimplemented in ImpMainWindow.

Referenced by ActionStateMachine::initMainWindow(), main(), and camitk::Application::setMainWindow().

+ Here is the caller graph for this function:

◆ refresh

void MainWindow::refresh ( )
virtualslot

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

Referenced by camitk::Application::refresh().

+ Here is the caller graph for this function:

◆ refreshViewers()

void MainWindow::refreshViewers ( )

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

◆ 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(..). This method calls showViewerToolbar(..,true)

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

Reimplemented in ImpMainWindow.

Referenced by ActionStateMachine::initMainWindow().

+ Here is the caller graph for this function:

◆ 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 ActionStateMachine::ActionStateMachine(), and ImpMainWindow::updateActionStates().

+ Here is the caller graph for this function:

◆ show

void MainWindow::show ( )
slot

inherited from QWidget, just to refresh all viewers

Referenced by camitk::Application::exec().

+ Here is the caller graph for this function:

◆ showConsole()

void MainWindow::showConsole ( bool  show)

get the console window

◆ showDockViewer()

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

set the visibility for the given docked viewer and its toolbar

Referenced by ImpMainWindow::ImpMainWindow().

+ Here is the caller graph for this function:

◆ showStatusBar()

void MainWindow::showStatusBar ( bool  b)

show the status bar (by default it is hidden)

Referenced by ActionStateMachine::initMainWindow().

+ Here is the caller graph for this function:

◆ showViewerToolbar()

void MainWindow::showViewerToolbar ( Viewer theViewer,
bool  visible 
)
virtual

Set the visibility of a viewer's toolbar.

This method respect the toolbar visibility property of the viewer.

Member Data Documentation

◆ centralLayout

QStackedLayout* camitk::MainWindow::centralLayout
private

the central widget is a frame, its layout is a QStackedLayout so that it is possible to easily switch between viewers

◆ 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 ImpMainWindow::updateViewMenu().

◆ cerr

ConsoleStream camitk::MainWindow::cerr
private

the error stream for the application console

◆ consoleWindow

QDockWidget* camitk::MainWindow::consoleWindow
private

console to display all messages

◆ consoleWindowTextEdit

QTextEdit* camitk::MainWindow::consoleWindowTextEdit
private

the QTextEdit part of the console dialog

◆ cout

ConsoleStream camitk::MainWindow::cout
private

the output stream for the application console

◆ dockWidgetMap

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

the map that gives the corresponding QDockWidget for a given Viewer

Referenced by ImpMainWindow::ImpMainWindow(), ImpMainWindow::resetWindows(), and ImpMainWindow::updateViewMenu().

◆ mainTitle

QString camitk::MainWindow::mainTitle
private

the main part of the title

◆ myProgressBar

QProgressBar* camitk::MainWindow::myProgressBar
private

the progress bar (access through setProgress() method)

◆ viewers

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

the set of viewers

Referenced by ImpMainWindow::editSettings(), and ImpMainWindow::updateViewMenu().


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