Difference between revisions of "Views Without Multi Widget"
SaschaZelzer (talk | contribs) |
SaschaZelzer (talk | contribs) |
||
Line 77: | Line 77: | ||
| bool IsExclusiveFunctionality() | | bool IsExclusiveFunctionality() | ||
| x (implement the mitk::IZombieViewPart interface to indicate special behavior) | | x (implement the mitk::IZombieViewPart interface to indicate special behavior) | ||
− | | | + | |- |
− | + | | | |
− | |||
− | | | ||
| '''mitk::IRenderWindowPartListener''' | | '''mitk::IRenderWindowPartListener''' | ||
|- | |- | ||
| void StdMultiWidgetAvailable(QmitkStdMultiWidget&) | | void StdMultiWidgetAvailable(QmitkStdMultiWidget&) | ||
| void RenderWindowPartActivated(mitk::IRenderWindowPart*) | | void RenderWindowPartActivated(mitk::IRenderWindowPart*) | ||
− | | | + | |- |
− | + | | | |
− | |||
− | | | ||
| '''mitk::ILifecycleAwarePart''' | | '''mitk::ILifecycleAwarePart''' | ||
|- | |- | ||
| void Deactivated() | | void Deactivated() | ||
| void Deactivated() | | void Deactivated() | ||
− | | | + | |- |
− | + | | | |
− | |||
− | | | ||
| '''mitk::IZombieViewPart''' | | '''mitk::IZombieViewPart''' | ||
|- | |- |
Revision as of 20:27, 23 February 2012
Decoupling MITK Views from the QmitkStdMultiWidget
Motivation
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:
- 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
set(Require-Plugin org.mitk.gui.qt.common.legacy)
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).
- 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. You must also remove any QmitkStdMultiWidget.h include directives.
#!highlight cpp //#include <QmitkStdMultiWidget.h> <-- Remove this include //#include <QmitkFunctionality.h> <-- Remove this include #include <QmitkAbstractView.h> //class MyView : public QmitkFunctionality {...}; class MyView : public QmitkAbstractView {...};
You must implement the method SetFocus(). Previously, an empty default implementation was provided by QmitkFunctionality which generally is not a good default.
#!highlight cpp void SetFocus() { m_Controls->someWidget->setFocus(); }
API changes
The following tables map 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 reCreateWidget = true) | 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) |
mitk::IRenderWindowPartListener | |
void StdMultiWidgetAvailable(QmitkStdMultiWidget&) | void RenderWindowPartActivated(mitk::IRenderWindowPart*) |
mitk::ILifecycleAwarePart | |
void Deactivated() | void Deactivated() |
mitk::IZombieViewPart | |
void Deactivated() | void ActivatedZombieView(berry::IWorkbenchPartReference::Pointer) |
Calls to the global mitk::RenderingManager instance should be replaced by calls to the mitk::IRenderingManager instance returned by the mitk::IRenderWindowPart. Rendering update requests should be done by calling QmitkAbstractView::RequestRenderWindowUpdate().
#!highlight cpp // Get a mitk::IRenderingManager instance mitk::IRenderingManager* rendering manager = this->GetRenderWindowPart()->GetRenderingManager(); // Request an update of the currently active render windows this->RequestRenderWindowUpdate();