Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
Medical Imaging Interaction Toolkit
Migration Guide from Overlays to the new Annotation concept

Table of Contents

How to adapt your code

All classes have been renamed from "Overlay" to "Annotation", e.g. the mitk::TextOverlay2D is now mitk::TextAnnotation2D. Most of the interface of mitk::Overlay remains unchanged in mitk::Annotation, but it is no longer registered at the mitk::OverlayManager. Instead, mitk::ManualPlacementAnnotationRenderer and mitk::LayoutAnnotationRenderer are used the register an annotation.

// Old Overlay registration:
overlayManager->AddOverlay(textOverlay3D.GetPointer(), renderer);
// New Annotation registration:

A single mitk::Annotation is no longer automatically registered in all available RenderWindows. Each mitk::Annotation is shown only once. The user is also responsible for the memory management. When a created mitk::Annotation has no more SmartPointer references, it disappears.

The Layouter concept was implemented in the mitk::LayoutAnnotationRenderer:

// Old way to layout an mitk::Overlay:
verlayManager->AddOverlay(textOverlay.GetPointer());
overlayManager->AddLayouter(
mitk::Overlay2DLayouter::CreateLayouter(mitk::Overlay2DLayouter::STANDARD_2D_TOPLEFT(), renderer2D).GetPointer());
overlayManager->SetLayouter(textOverlay.GetPointer(), mitk::Overlay2DLayouter::STANDARD_2D_TOPLEFT(), renderer2D);
// New way to layout an mitk::Annotation:
// The layouter gets parameters for margins and the priority for the placement in the RenderWindow corners.
mitk::LayoutAnnotationRenderer::AddAnnotation
static void AddAnnotation(Annotation *annotation, const std::string &rendererID, Alignment alignment=TopLeft, double marginX=5, double marginY=5, int priority=-1)
mitk::ManualPlacementAnnotationRenderer::AddAnnotation
static void AddAnnotation(Annotation *Annotation, const std::string &rendererID)
mitk::LayoutAnnotationRenderer::TopLeft
@ TopLeft
Definition: mitkLayoutAnnotationRenderer.h:41