Viewer is an abstract class that is the base class for all viewers. More...
#include <Viewer.h>
Public Types | |
enum | ViewerType { EMBEDDED , DOCKED } |
describes where this viewer should appear More... | |
Signals | |
void | selectionChanged () |
this signal is emitted when the current selection was changed by the viewer More... | |
Public Member Functions | |
*get the list of Component class manages by this viewer *default is set to i e all type of Component *QStringList | getComponentClassNames () |
QString | getDescription () const |
get the name of the viewer More... | |
virtual 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... | |
virtual 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 PropertyObject * | 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... | |
virtual 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... | |
virtual 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... | |
virtual 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... | |
virtual 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... | |
virtual void | setVisible (bool) |
set the visibility of the viewer (show or hide its widget) More... | |
virtual | ~Viewer () override |
default destructor More... | |
Public Attributes | |
*get the list of Component class manages by this viewer *default is set to | Component |
ViewerType | type = EMBEDDED) |
this viewer's layout More... | |
Protected Member Functions | |
void | clearSelection () |
clear the selection More... | |
*set the list of component class names managed by this viewer *note Default is set to | Component (all type of components) */void setComponentClassNames(QStringList) |
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 | setDescription (QString) |
set the viewer's description More... | |
void | setIcon (QPixmap icon) |
set the default icon for the viewer extension 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 setComponentClassNames(...) 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
|
protected |
clear the selection
Referenced by camitk::InteractiveViewer::keyPressEvent().
|
protected |
QStringList camitk::Viewer::getComponentClassNames | ( | ) |
Referenced by camitk::Application::getViewers(), and camitk::MainWindow::refresh().
|
inline |
get the name of the viewer
References description.
Referenced by camitk::Application::registerViewer().
|
virtual |
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)
|
virtual |
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(), and camitk::ViewerDockStyle::ViewerDockStyle().
|
inlinevirtual |
get the viewer menu (returns nullptr by default, i.e. there are no default edit menu)
Reimplemented in MedicalImageViewer, Explorer, and camitk::InteractiveViewer.
Referenced by ImpMainWindow::updateViewMenu().
|
inline |
get the name of the viewer
Referenced by PropertyExplorer::refresh(), camitk::Application::registerViewer(), camitk::ViewerExtension::registerViewer(), camitk::MainWindow::setCentralViewer(), 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 PropertyExplorer, MedicalImageViewer, and camitk::InteractiveViewer.
Referenced by ImpMainWindow::editSettings(), and camitk::PersistenceManager::loadWorkspace().
|
inlinevirtual |
get the viewer toolbar (returns nullptr by default, i.e. there are no default toolbar)
Reimplemented in MedicalImageViewer, BitmapViewer, and camitk::InteractiveViewer.
|
virtual |
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 PropertyExplorer, MedicalImageViewer, FrameExplorer, Explorer, BitmapViewer, ActionViewer, camitk::InteractiveViewer, 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.
Referenced by camitk::MainWindow::refresh(), camitk::Component::refresh(), and camitk::MainWindow::refreshViewers().
|
signal |
this signal is emitted when the current selection was changed by the viewer
Referenced by MedicalImageViewer::getWidget(), camitk::InteractiveViewer::picked(), camitk::InteractiveViewer::sliderChanged(), and MedicalImageViewer::synchronizeSelection().
|
protected |
the selection has changed to be just one comp
References camitk::Component::setSelected().
|
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).
References camitk::Component::setSelected().
|
protected |
set the viewer's description
References description.
Referenced by ActionViewer::ActionViewer(), BitmapViewer::BitmapViewer(), Explorer::Explorer(), FrameExplorer::FrameExplorer(), InteractiveGeometryViewer::InteractiveGeometryViewer(), InteractiveSliceViewer::InteractiveSliceViewer(), MedicalImageViewer::MedicalImageViewer(), and PropertyExplorer::PropertyExplorer().
|
virtual |
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
References CAMITK_ERROR.
Referenced by camitk::MainWindow::addDockViewer().
|
virtual |
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)
References CAMITK_ERROR.
Referenced by camitk::MainWindow::setCentralViewer().
|
protected |
set the default icon for the viewer extension
Referenced by ActionViewer::ActionViewer(), Explorer::Explorer(), FrameExplorer::FrameExplorer(), and PropertyExplorer::PropertyExplorer().
|
virtual |
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 addDockViewer(...) will remove it
Reimplemented in MedicalImageViewer.
Referenced by ActionStateMachine::initMainWindow().
void camitk::Viewer::setType | ( | Viewer::ViewerType | type | ) |
set the viewer layout (the type can be changed dynamically to fit the developer's purpose)
|
virtual |
set the visibility of the viewer (show or hide its widget)
* get the list of Component class manages by this viewer* default is set to camitk::Viewer::Component |
ViewerType camitk::Viewer::type = EMBEDDED) |
this viewer's layout
Referenced by camitk::InteractiveViewer::InteractiveViewer().