Views Without Multi Widget

Jump to navigation Jump to search


In the past, BlueBerry-based MITK Views always had a hard dependency on the QmitkStdMultiWidget (the big widget with four render windows, in the center of the application). This dependency was partly due to API misuse but also due to the lack of a proper abstraction layer.

Recently, more use cases popped up which require a specialized render window editor. However the functionality offered by most MITK Views is tied to the QmitkStdMultiWidget although they would theoretically be functional in a much broader scope.

Recent Changes

To enable MITK Views to work together with an abstract render window editor, the work on bug #10963 has been merged into MITK master on 23.02.2012.

If you wrote your own MITK View it is likely that you will be affected by these changes. The changes make it necessary that you take one of two possible actions in order to keep your View working:

  1. In your plug-ins manifest_headers.cmake file, change the plug-in dependency org.mitk.gui.qt.common to org.mitk.gui.qt.common.legacy

<syntaxhighlight lang="cmake"> set(Require-Plugin org.mitk.gui.qt.common.legacy) </syntaxhighlight>

This will keep your plug-in functional for the time being. However, you should consider migrating your plug-in code to the new API (see below).

  1. Keep your plug-in dependencies as they are and fix your plug-in code. See the guideline below.

Fixing API usage

The most prominent change is that you should now inherit your View class from QmitkAbstractView instead of QmitkFunctionality and direct calls to a QmitkStdMultiWidget instance should be avoided.

<syntaxhighlight lang="cpp"> //#include <QmitkStdMultiWidget.h> <-- Remove this include //#include <QmitkFunctionality.h> <-- Remove this include

  1. include <QmitkAbstractView.h>

//class MyView : public QmitkFunctionality {...}; class MyView : public QmitkAbstractView {...}; </syntaxhighlight>

You must implement the method SetFocus(). Previously, an empty default implementation was provided by QmitkFunctionality which generally is not a good default.

<syntaxhighlight lang="cpp"> void SetFocus() {


} </syntaxhighlight>

You can have a look at a commit fixing the API issues for a very simple plug-in here:

API changes

The QmitkFunctionality API has been replaced by the one provided by QmitkAbstractView, mitk::IRenderWindowPart, and related interfaces.

QmitkFunctionality API Mapping

The following table maps the deprecated QmitkFunctionality API to the new API offered by QmitkAbstractView or related interfaces. If you are unsure about a method's usage, please consult its Doxygen documentation.

QmitkFunctionality QmitkAbstractView
void OnSelectionChanged(std::vector<mitk::DataNode*>) void OnSelectionChanged(berry::IWorkbenchPart::Pointer, const QList<mitk::DataNode::Pointer>&)
mitk::DataStorage::Pointer GetDefaultDataStorage() mitk::DataStorage::Pointer GetDataStorage()
bool IsActivated() X (remeber the state yourself by implementing the mitk::ILifecycleAwarePart interface)
QmitkStdMultiWidget* GetActiveStdMultiWidget(bool) mitk::IRenderWindowPart* GetRenderWindowPart(IRenderWindowPartStrategies)
m_Parent X (remember the parent yourself in CreateQtPartControl(QWidget*) )
bool IsExclusiveFunctionality() X (implement the mitk::IZombieViewPart interface to indicate special behavior)
void StdMultiWidgetAvailable(QmitkStdMultiWidget&) void RenderWindowPartActivated(mitk::IRenderWindowPart*)
void Visible() void Visible()
void Hidden() void Hidden()
void Deactivated() void ActivatedZombieView (berry::IWorkbenchPartReference::Pointer)

QmitkStdMultiWidget API Mapping

The direct usage of the QmitkStdMultiWidget API via an instance returned by QmitkFunctionality::GetActiveStdMultiWidget() is now deprecated. Use the table below to look up the corresponding methods offered by the new interfaces.

QmitkStdMultiWidget IRenderWindowPart ILinkedRenderWindowPart
GetTimeNavigationController() GetTimeNavigationController()
GetRenderWindow[X]() GetRenderWindow(const QString&)
GetCrossPosition() GetSelectedPosition()
MoveCrossToPosition(const mitk::Point3D&) SetSelectedPosition()
GetSlicesRotator() GetSlicesRotator()
GetSlicesSwiveller() GetSlicesSwiveller()
SetWidgetPlanesVisibility(bool) EnableSlicingPlanes(bool)
RequestUpdate() RequestUpdate()
ForceImmediateUpdate() ForceImmediateUpdate()
DisableColoredRectangles() EnableDecorations(false, QStringList(DECORATION_BORDER))
DisableDepartmentLogo() EnableDecorations(false, QStringList(DECORATION_LOGO))
DisableGradientBackground() EnableDecorations(false, QStringList(DECORATION_BACKGROUND))

Calls to the global mitk::RenderingManager instance should be replaced by calls to the mitk::IRenderingManager instance returned by the mitk::IRenderWindowPart::GetRenderingManager() method.

If a rendering update is requested from a QmitkAbstractView subclass, the request should be done by calling QmitkAbstractView::RequestRenderWindowUpdate().