Computer Assited Medical Intervention Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Protected 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>

+ Inheritance diagram for camitk::MainWindow:

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.
virtual ~MainWindow ()
 destructor
virtual void aboutToShow ()
 this method is automatically called by Application before the first time show() is called.
subtitle, status bar message, progress bar state and console
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
Viewers
virtual bool addViewer (Viewer *)
 add a viewer (called by addDockViewer and setCentralViewer), returns true if not already added.
virtual void showViewer (Viewer *, bool)
 set the visibility for the given viewer (if it is in a dock)
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.

Protected Member Functions

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

Private Attributes

ConsoleStream cerr
 the error stream for the application console
QDialog * consoleWindow
 console to display all messages
QTextEdit * consoleWindowTextEdit
 the QTextEdit part of the console dialog
ConsoleStream cout
 the output stream for the application console
QString mainTitle
 the main part of the title
QProgressBar * myProgressBar
 the progress bar (access through setProgress() method)

Viewer and other things

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

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

camitk::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 consoleWindow, consoleWindowTextEdit, mainTitle, myProgressBar, and showStatusBar().

camitk::MainWindow::~MainWindow ( )
virtual

destructor

References consoleWindow, and viewers.

Member Function Documentation

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

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

bool camitk::MainWindow::addViewer ( Viewer theViewer)
virtual

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.

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

Referenced by addDockViewer(), and setCentralViewer().

void camitk::MainWindow::closeEvent ( QCloseEvent *  event)
protectedvirtual

overriden from QMainWindow, just connect to slotFileQuit

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

void camitk::MainWindow::dragEnterEvent ( QDragEnterEvent *  event)
protected

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

void camitk::MainWindow::dragLeaveEvent ( QDragLeaveEvent *  event)
protected

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

void camitk::MainWindow::dragMoveEvent ( QDragMoveEvent *  event)
protected

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

void camitk::MainWindow::dropEvent ( QDropEvent *  event)
protected

just call open with the dragged uri

References camitk::Application::open().

QProgressBar * camitk::MainWindow::getProgressBar ( )
void camitk::MainWindow::initSettings ( )
protectedvirtual

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

Reimplemented in ImpMainWindow.

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

Referenced by aboutToShow().

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

void camitk::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(), and show().

void camitk::MainWindow::refreshViewers ( )

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

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

void camitk::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(), and camitk::Viewer::getWidget().

Referenced by ActionStateMachine::initMainWindow().

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

void camitk::MainWindow::show ( )
slot

inherited from QWidget, just to refresh all viewers

References refresh().

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

void camitk::MainWindow::showConsole ( bool  show)

get the console window

References consoleWindow.

void camitk::MainWindow::showStatusBar ( bool  b)

show the status bar (by default it is hidden)

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

void camitk::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

ConsoleStream camitk::MainWindow::cerr
private

the error stream for the application console

Referenced by redirectToConsole().

QDialog* camitk::MainWindow::consoleWindow
private

console to display all messages

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

QTextEdit* camitk::MainWindow::consoleWindowTextEdit
private

the QTextEdit part of the console dialog

Referenced by MainWindow(), and redirectToConsole().

ConsoleStream camitk::MainWindow::cout
private

the output stream for the application console

Referenced by redirectToConsole().

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

the map that gives the corresponding QDockWidget for a given Viewer

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

QString camitk::MainWindow::mainTitle
private

the main part of the title

Referenced by MainWindow(), and setWindowSubtitle().

QProgressBar* camitk::MainWindow::myProgressBar
private

the progress bar (access through setProgress() method)

Referenced by getProgressBar(), and MainWindow().

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

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