Viewer is an abstract class that is the base class for all viewers. More...
#include <Viewer.h>
Public Types | |
enum | ViewerType { EMBEDDED, DOCKED } |
Signals | |
void | selectionChanged () |
this signal is emitted when the current selection was changed by the viewer More... | |
Public Member Functions | |
QStringList | getComponents () |
get the list of Component class manages by this viewer (default is set to "Component", i.e. More... | |
QString | getDescription () const |
get the name of the viewer More... | |
QDockWidget * | getDockWidget () |
Get the QDockWidget* where this viewer is currently docked (or nullptr if it is not docked anywhere or if the viewer is of type EMBEDDED) More... | |
QLayout * | getEmbedder () |
Get the QLayout* where this viewer is currently embedded (or nullptr if it is not embedded anywhere or if the viewer is of type DOCKED) More... | |
virtual QPixmap | getIcon () |
get the viewer icon More... | |
virtual QMenu * | getMenu () |
get the viewer menu (returns nullptr by default, i.e. there are no default edit menu) More... | |
QString | getName () const |
get the name of the viewer More... | |
virtual QObject * | getPropertyObject () |
get the viewer property object (returns nullptr by default, i.e. there are no property to edit) More... | |
virtual QToolBar * | getToolBar () |
get the viewer toolbar (returns nullptr by default, i.e. there are no default toolbar) More... | |
bool | getToolBarVisibility () |
get the current value of the toolbar visibility More... | |
ViewerType | getType () |
get the viewer layout More... | |
Q_ENUM (ViewerType) Viewer(QString name | |
default constructor More... | |
virtual void | refresh (Viewer *whoIsAsking=nullptr)=0 |
refresh the view (can be interesting to know which other viewer is calling this) More... | |
bool | setDockWidget (QDockWidget *) |
If the viewer type is DOCKED, dock the widget inside the given dock widget (do nothing if the type is EMBEDDED or if the viewer has already been docked before) Note that once set, the dock widget cannot be modified. More... | |
bool | setEmbedder (QLayout *) |
If the viewer type is EMBEDDED, embed the viewer widget in the given layout (do nothing if the type is DOCKED) Note that you can call this method any time you want to move the viewer's widget to another layout (but there is only one embedder at a time) More... | |
void | setToolBarVisibility (bool) |
set the visibility of the toolbar in the main window (true by default). More... | |
void | setType (ViewerType) |
set the viewer layout (the type can be changed dynamically to fit the developer's purpose) More... | |
void | setVisible (bool) |
set the visibility of the viewer (show or hide its widget) More... | |
virtual | ~Viewer () override |
default destructor More... | |
Public Attributes | |
ViewerType | type = EMBEDDED) |
this viewer's layout More... | |
Protected Member Functions | |
void | clearSelection () |
clear the selection More... | |
virtual QWidget * | getWidget ()=0 |
get the viewer widget. More... | |
void | selectionChanged (Component *comp) |
the selection has changed to be just one comp More... | |
void | selectionChanged (ComponentList &compSet) |
The selection has changed to the given ComponentList. More... | |
void | setComponents (QStringList) |
set the list of component class names managed by this viewer More... | |
void | setDescription (QString) |
set the viewer's description More... | |
void | setIcon (QPixmap icon) |
set the default icon for the viewer extension More... | |
Private Attributes | |
QStringList | components |
list of Component class name managed by this viewer More... | |
QString | description |
description of the viewer More... | |
QDockWidget * | dockWidget |
if layout is of type DOCKED, then this is the widget where the viewer's widget is docked More... | |
ViewerDockStyle * | dockWidgetStyle |
the style for the dock widget More... | |
QLayout * | embedder |
if layout is of type EMBEDDED, this is the layout where the viewer's widget is embedded in More... | |
QPixmap | icon |
the Viewer pixmap icon More... | |
QString | name |
current viewer's name More... | |
bool | toolbarVisibility |
the current toolbar visibility More... | |
Viewer is an abstract class that is the base class for all viewers.
There are two types of viewers:
The type of a viewer can be changed at any time using setType(..). To define where is the viewer embedded or docked use setEmbedder(..) or setDockWidget(..)
A viewer can embed other viewers in its own widget. Example of viewer are: Explorer, PropertyExplorer, MedicalImageViewer (which embed the default InteractiveGeometryViewer and default InteractiveSliceViewers).
A viewer can be added to MainWindow either in the dock or the central viewer (depending on its type). MainWindow will include its menu in the "View" menu and its toolbar in the application toolbar.
The default viewed component are set so that the viewer is updated every time the current component selection is modified.
If your viewer does not view components (for instance, in the very rare/special case it views actions), then you need to call the setComponents(...) method with an empty list. An empty list means that this viewer is going to be also notified/refreshed every time the current selected action is changed (i.e., anytime an action is triggered)
In the scope of an Application, a viewer should be registered if you want to use it to display component facets. Registered viewers are going to be refreshed automatically when Application::refresh() is called or when a new top level component is opened/closed.
The viewer's icon is displayed inside the dock window.
Unregistered viewers are managed independently of the CamiTK Application logic. In this case it should be managed separately and it is not connected to the automatic refresh chain. This is a special (rare) use case. If you think this is what you need, then you will have to programmatically/specifically manage the content of the viewer and its refresh logic.
The viewer's property object can be used to manage the properties of the viewer (for instance background colors or other display options). (camitk-imp for instance presents the viewer properties in the setting dialog)
The viewer's menu should present the properties in a QMenu to enable the user to easily modify the viewer properties (camitk-imp for instance shows the viewer menus in the application "View" menu)
A viewer toolbar is meant to be displayed in the main window toolbar area when the viewer's widget is visible (in a Dock or as the central widget). The viewer toolbar is visible by default. If you don't want to show the viewer toolbar in your main window, even if the viewer's widget is visible, set its visibility to false.
In a viewer extension, the default behaviour is to have (at least) one instance of the new Viewer inheriting class. It is very easy to access this instance with Application::getViewer()
E.g. if FooBarViewer inherits from the Viewer class, then one default instance of the class, called "Foo Bar Viewer", is available when the extension is loaded.
To get the default FooBarViewer instance, use Application::getViewer("Foo Bar Viewer").
One simple way of checking that a viewer extension is available, is to check the return value of Application::getViewer(...), e.g. some code inside a MainWindow inherited class constructor:
camitk_extension(..)
macro of your extension's CMakeLists.txt
: It is very easy to create a new instance of a given viewer type (of a loaded viewer extension): just use the viewer extension factory. See Application::getNewViewer().
The following example creates a new instance of the InteractiveGeometryViewer
viewer called "My Extra 3D Viewer" and embed it in a specific layout:
The simplest way to create a new viewer extension is to run camitk-wizard to obtain a working skeleton. Feel free to check the two examples provided in the tutorial CEP (as well as the code of the viewer extensions provided by the SDK).
describes where this viewer should appear
|
overridevirtual |
default destructor
References description.
|
protected |
clear the selection
QStringList camitk::Viewer::getComponents | ( | ) |
get the list of Component class manages by this viewer (default is set to "Component", i.e.
all type of Component)
Referenced by camitk::Application::getViewers().
|
inline |
get the name of the viewer
References description.
Referenced by camitk::Application::registerViewer().
QDockWidget * camitk::Viewer::getDockWidget | ( | ) |
Get the QDockWidget* where this viewer is currently docked (or nullptr if it is not docked anywhere or if the viewer is of type EMBEDDED)
Referenced by ImageLutWidget::drawGraphics().
QLayout * camitk::Viewer::getEmbedder | ( | ) |
Get the QLayout* where this viewer is currently embedded (or nullptr if it is not embedded anywhere or if the viewer is of type DOCKED)
Referenced by ImpMainWindow::updateViewMenu().
|
virtual |
get the viewer icon
Referenced by ImpMainWindow::updateViewMenu().
|
inlinevirtual |
get the viewer menu (returns nullptr by default, i.e. there are no default edit menu)
Reimplemented in camitk::InteractiveViewer, MedicalImageViewer, and Explorer.
Referenced by ImpMainWindow::updateViewMenu().
|
inline |
get the name of the viewer
Referenced by FrameExplorer::add(), Explorer::add(), PropertyExplorer::clear(), camitk::Application::getViewerExtension(), PropertyExplorer::refresh(), camitk::Application::registerViewer(), Explorer::remove(), camitk::ImageComponent::setImageName(), camitk::ViewerExtension::setManagedMetaObject(), camitk::Application::unregisterAllViewers(), ImpMainWindow::updateViewMenu(), and camitk::viewerLessThan().
|
inlinevirtual |
get the viewer property object (returns nullptr by default, i.e. there are no property to edit)
Reimplemented in camitk::InteractiveViewer, MedicalImageViewer, and PropertyExplorer.
Referenced by ImpMainWindow::editSettings().
|
inlinevirtual |
get the viewer toolbar (returns nullptr by default, i.e. there are no default toolbar)
Reimplemented in camitk::InteractiveViewer, MedicalImageViewer, and BitmapViewer.
bool camitk::Viewer::getToolBarVisibility | ( | ) |
get the current value of the toolbar visibility
Viewer::ViewerType camitk::Viewer::getType | ( | ) |
get the viewer layout
Referenced by ImpMainWindow::updateViewMenu().
|
protectedpure virtual |
get the viewer widget.
this method is protected and to be redefined in the inheriting class.
Implemented in camitk::InteractiveViewer, MedicalImageViewer, ActionViewer, PropertyExplorer, Explorer, FrameExplorer, BitmapViewer, and ActionStateViewer.
camitk::Viewer::Q_ENUM | ( | ViewerType | ) |
default constructor
|
pure virtual |
refresh the view (can be interesting to know which other viewer is calling this)
Implemented in camitk::InteractiveViewer, PropertyExplorer, Explorer, and BitmapViewer.
|
signal |
this signal is emitted when the current selection was changed by the viewer
Referenced by MedicalImageViewer::getWidget(), and MedicalImageViewer::synchronizeSelection().
|
protected |
the selection has changed to be just one comp
|
protected |
The selection has changed to the given ComponentList.
This method updates the Component::selection and emit the modified signal. This method should be called by the inheriting class which can select Components (e.g.: Explorer).
|
protected |
set the list of component class names managed by this viewer
References camitk::Component::setSelected().
Referenced by ActionStateViewer::ActionStateViewer(), ActionViewer::ActionViewer(), BitmapViewer::BitmapViewer(), and InteractiveSliceViewer::InteractiveSliceViewer().
|
protected |
set the viewer's description
Referenced by ActionViewer::ActionViewer(), BitmapViewer::BitmapViewer(), Explorer::Explorer(), FrameExplorer::FrameExplorer(), InteractiveGeometryViewer::InteractiveGeometryViewer(), InteractiveSliceViewer::InteractiveSliceViewer(), MedicalImageViewer::MedicalImageViewer(), and PropertyExplorer::PropertyExplorer().
bool camitk::Viewer::setDockWidget | ( | QDockWidget * | dockWidget | ) |
If the viewer type is DOCKED, dock the widget inside the given dock widget (do nothing if the type is EMBEDDED or if the viewer has already been docked before) Note that once set, the dock widget cannot be modified.
The dock widget object's name, window title and icons are modified using the viewer's name and icon
bool camitk::Viewer::setEmbedder | ( | QLayout * | embedder | ) |
If the viewer type is EMBEDDED, embed the viewer widget in the given layout (do nothing if the type is DOCKED) Note that you can call this method any time you want to move the viewer's widget to another layout (but there is only one embedder at a time)
Referenced by camitk::MainWindow::addDockViewer(), and ReorientImage::initDialog().
|
protected |
set the default icon for the viewer extension
References camitk::Component::setSelected().
Referenced by ActionViewer::ActionViewer(), Explorer::Explorer(), FrameExplorer::FrameExplorer(), and PropertyExplorer::PropertyExplorer().
void camitk::Viewer::setToolBarVisibility | ( | bool | toolbarVisibility | ) |
set the visibility of the toolbar in the main window (true by default).
If the visibility is set to false, the next call to setCentralViewer(..) or addDockViwer(...) will remove it
Referenced by MedicalImageViewer::setToolbarAutoVisibility(), and MedicalImageViewer::updateLayout().
void camitk::Viewer::setType | ( | Viewer::ViewerType | type | ) |
set the viewer layout (the type can be changed dynamically to fit the developer's purpose)
void camitk::Viewer::setVisible | ( | bool | visible | ) |
set the visibility of the viewer (show or hide its widget)
|
private |
list of Component class name managed by this viewer
|
private |
description of the viewer
|
private |
if layout is of type DOCKED, then this is the widget where the viewer's widget is docked
|
private |
the style for the dock widget
|
private |
if layout is of type EMBEDDED, this is the layout where the viewer's widget is embedded in
|
private |
the Viewer pixmap icon
|
private |
current viewer's name
Referenced by InteractiveGeometryViewer::InteractiveGeometryViewer(), and InteractiveSliceViewer::InteractiveSliceViewer().
|
private |
the current toolbar visibility
ViewerType camitk::Viewer::type = EMBEDDED) |
this viewer's layout