Computer Assited Medical Intervention Tool Kit  version 4.1
Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
camitk::MainWindow Class Reference

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

#include <MainWindow.h>

Inherits QMainWindow.

Inherited by ImpMainWindow.

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 showViewer (Viewer *, bool)
 set the visibility for the given viewer (if it is in a dock) 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 const ViewergetCentralViewer () const
 the actual central viewer. 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...
 
bool removeViewer (Viewer *viewer)
 Remove the given viewer from the list of viewer. 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

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 providing a menubar, toolbar and statusbar (all hidden). It is the default main window for a application.

Create a class that inherits from MainWindow to get all the goodies of Core and add your own customization/UI. See applications for examples.

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, consoleWindow, consoleWindowTextEdit, camitk::InterfaceLogger::ERROR, camitk::Application::getAction(), camitk::Log::getLogger(), camitk::Action::getQAction(), camitk::InterfaceLogger::INFO, mainTitle, myProgressBar, showStatusBar(), camitk::InterfaceLogger::TRACE, and camitk::InterfaceLogger::WARNING.

◆ ~MainWindow()

MainWindow::~MainWindow ( )
override

destructor

References consoleWindow, and viewers.

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 camitk::Application::exec().

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

Reimplemented in ImpMainWindow.

References addViewer(), dockWidgetMap, and camitk::Viewer::getWidget().

Referenced by ActionStateMachine::initMainWindow().

◆ 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 at the appropriate time. This method connects the selectionChanged signal of the viewer to the refresh method. Before CamiTK 4.x this method was a public method.

References camitk::Viewer::getToolBar(), refresh(), and viewers.

Referenced by addDockViewer(), and setCentralViewer().

◆ closeEvent()

void MainWindow::closeEvent ( QCloseEvent *  event)
overrideprotected

overriden from QMainWindow, just connect to slotFileQuit

References camitk::Application::getAction(), camitk::Application::getName(), camitk::Application::getSettings(), 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()

const Viewer & MainWindow::getCentralViewer ( ) const
virtual

the actual central viewer.

Returns

References centralViewer.

◆ getConsoleVisibility()

bool MainWindow::getConsoleVisibility ( )

get the visibility state of the console (

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

References consoleWindow.

◆ getName()

QString MainWindow::getName ( ) const

Get the main window title.

References mainTitle.

Referenced by camitk::CamiTKLogger::getCamiTKAPIInformation().

◆ getProgressBar()

QProgressBar * MainWindow::getProgressBar ( )

◆ initSettings()

void MainWindow::initSettings ( )
protectedvirtual

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

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

Referenced by aboutToShow().

◆ 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, cerr, consoleWindowTextEdit, cout, camitk::ConsoleStream::free(), camitk::ConsoleStream::init(), and camitk::Core::version.

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

◆ 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::Viewer::refresh(), and viewers.

Referenced by addViewer(), camitk::Application::refresh(), removeViewer(), and show().

◆ refreshViewers()

void MainWindow::refreshViewers ( )

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

References camitk::Viewer::refresh(), and viewers.

◆ removeViewer()

bool MainWindow::removeViewer ( Viewer viewer)
protected

Remove the given viewer from the list of viewer.

Note
This tell all Component not to be visible anymore in this viewer instance, remove it from the list of viewers and delete it.
Parameters
viewerThe viewer to remove.
Returns
True if removing succeeded, false otherwise.

References camitk::Application::getAllComponents(), refresh(), camitk::Component::setVisibility(), and viewers.

Referenced by setCentralViewer().

◆ setCentralViewer()

void MainWindow::setCentralViewer ( Viewer theViewer)
virtual

set the central Viewer of the application.

Note that MainWindow takes ownership of the Viewer pointer and deletes it at the appropriate time. This method calls addViewer(...).

Reimplemented in ImpMainWindow.

References addViewer(), centralViewer, camitk::Viewer::getWidget(), and removeViewer().

Referenced by ActionStateMachine::initMainWindow().

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

References mainTitle.

Referenced by ImpMainWindow::updateActionStates().

◆ show

void MainWindow::show ( )
slot

inherited from QWidget, just to refresh all viewers

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

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

◆ showConsole()

void MainWindow::showConsole ( bool  show)

get the console window

References consoleWindow.

◆ showStatusBar()

void MainWindow::showStatusBar ( bool  b)

show the status bar (by default it is hidden)

Referenced by ActionStateMachine::initMainWindow(), and MainWindow().

◆ showViewer()

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

set the visibility for the given viewer (if it is in a dock)

References dockWidgetMap, and viewers.

Referenced by ImpMainWindow::ImpMainWindow().

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(), and setCentralViewer().

◆ cerr

ConsoleStream camitk::MainWindow::cerr
private

the error stream for the application console

Referenced by redirectToConsole().

◆ consoleWindow

QDockWidget* camitk::MainWindow::consoleWindow
private

console to display all messages

Referenced by getConsoleVisibility(), MainWindow(), show(), showConsole(), and ~MainWindow().

◆ consoleWindowTextEdit

QTextEdit* camitk::MainWindow::consoleWindowTextEdit
private

the QTextEdit part of the console dialog

Referenced by MainWindow(), and redirectToConsole().

◆ cout

ConsoleStream camitk::MainWindow::cout
private

the output stream for the application console

Referenced by redirectToConsole().

◆ dockWidgetMap

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

the map that gives the corresponding QDockWidget for a given Viewer

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

◆ mainTitle

QString camitk::MainWindow::mainTitle
private

the main part of the title

Referenced by getName(), MainWindow(), and setWindowSubtitle().

◆ myProgressBar

QProgressBar* camitk::MainWindow::myProgressBar
private

the progress bar (access through setProgress() method)

Referenced by getProgressBar(), and MainWindow().

◆ viewers

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

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