Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkTextOverlay Class Reference

Overlay that displays a text string in a render window. More...

#include <QmitkTextOverlay.h>

Inheritance diagram for QmitkTextOverlay:
Collaboration diagram for QmitkTextOverlay:

Public Member Functions

 QmitkTextOverlay (const char *id)
 Constructor. Creates the internal QLabel widget. More...
 
 ~QmitkTextOverlay () override
 Destructor. Removes the property observer. More...
 
void GenerateData (mitk::PropertyList::Pointer pl) override
 Configures the text overlay from the given PropertyList. More...
 
QSize GetNeededSize () override
 Returns the minimum size needed to display the current text. More...
 
- Public Member Functions inherited from QmitkOverlay
 QmitkOverlay (const char *id)
 Constructor. More...
 
 ~QmitkOverlay () override
 Destructor. Deletes the internal widget unless it was set externally. More...
 
virtual void SetPosition (DisplayPosition pos)
 Sets the display position of this overlay. More...
 
virtual DisplayPosition GetPosition ()
 Returns the current display position. More...
 
virtual void SetLayer (unsigned int layer)
 Sets the stacking layer of this overlay. More...
 
virtual unsigned int GetLayer ()
 Returns the current stacking layer. More...
 
virtual QWidget * GetWidget ()
 Returns the internal QWidget representing this overlay. More...
 

Protected Member Functions

void UpdateFontProperties (mitk::PropertyList::Pointer pl)
 Applies font-related properties from the PropertyList to the QLabel. More...
 
void SetupCallback (mitk::BaseProperty::Pointer prop)
 Sets up an ITK observer on the given property to auto-update the text. More...
 
void UpdateDisplayedTextFromProperties ()
 Reads the current text from the property and updates the QLabel. More...
 
- Protected Member Functions inherited from QmitkOverlay
void AddDropShadow (QWidget *widget)
 Adds a drop shadow graphics effect to the given widget. More...
 

Protected Attributes

QLabel * m_Label
 QLabel internally representing the text overlay. More...
 
mitk::PropertyList::Pointer m_PropertyList
 Cached PropertyList for property lookups. More...
 
mitk::BaseProperty::Pointer m_ObservedProperty
 The observed property for automatic text updates. More...
 
unsigned long m_ObserverTag
 ITK observer tag for the property modification callback. More...
 
- Protected Attributes inherited from QmitkOverlay
const char * m_Id
 ID of the overlay, used as property key for lookups. More...
 
DisplayPosition m_Position
 Current display position of the overlay. More...
 
unsigned int m_Layer
 Stacking layer of the overlay. More...
 
QWidget * m_Widget
 Internal QWidget representing the overlay content. More...
 
bool m_WidgetIsCustom
 Flag indicating whether the widget was set externally (custom overlay). More...
 

Additional Inherited Members

- Public Types inherited from QmitkOverlay
enum  DisplayPosition {
  top_Left , top_Center , top_Right , middle_Left ,
  middle_Right , bottom_Left , bottom_Center , bottom_Right
}
 Enumeration of all possible display positions in a render window. More...
 

Detailed Description

Overlay that displays a text string in a render window.

A QmitkTextOverlay is a text-specific implementation of QmitkOverlay. It can be used whenever a simple text is to be rendered as an overlay in a QmitkRenderWindow.

Instead of a generic QWidget (as in QmitkOverlay), a QmitkTextOverlay is internally represented by a QLabel. You can access it via GetWidget().

Calling GenerateData(mitk::PropertyList::Pointer) will set up the text overlay. This includes setting the actual text (which must be stored as a StringProperty whose name matches the overlay's ID).

Example:

mitk::StringProperty::Pointer nameProp = mitk::StringProperty::New("overlay.text.patientName", "Max");
QmitkTextOverlay* nameOverlay = new QmitkTextOverlay("overlay.text.patientName");
Overlay that displays a text string in a render window.
QmitkTextOverlay(const char *id)
Constructor. Creates the internal QLabel widget.
static Pointer New()

The following additional properties customize the appearance:

  • overlay.color: Text color (mitk::ColorProperty)
  • overlay.fontSize: Font point size (mitk::IntProperty, default: 9)
  • overlay.kerning: Whether to use kerning (mitk::BoolProperty, default: true)
  • overlay.fontFamily: Font family name (mitk::StringProperty, default: "Verdana")

The overlay registers an observer on the text property so that the displayed text updates automatically when the property value changes.

See also
QmitkOverlay
QmitkScalarBarOverlay
QmitkOverlayController

Definition at line 61 of file QmitkTextOverlay.h.

Constructor & Destructor Documentation

◆ QmitkTextOverlay()

QmitkTextOverlay::QmitkTextOverlay ( const char *  id)

Constructor. Creates the internal QLabel widget.

Parameters
[in]idString identifier used to look up the text property by name.

◆ ~QmitkTextOverlay()

QmitkTextOverlay::~QmitkTextOverlay ( )
override

Destructor. Removes the property observer.

Member Function Documentation

◆ GenerateData()

void QmitkTextOverlay::GenerateData ( mitk::PropertyList::Pointer  pl)
overridevirtual

Configures the text overlay from the given PropertyList.

Reads font properties and the text string from the PropertyList. Sets up an observer for automatic text updates when the property changes.

Parameters
[in]plThe PropertyList containing overlay configuration properties.
Warning
No error is issued if the text property is not found; an empty string is shown.

Reimplemented from QmitkOverlay.

◆ GetNeededSize()

QSize QmitkTextOverlay::GetNeededSize ( )
overridevirtual

Returns the minimum size needed to display the current text.

Returns
The QSize computed from the font metrics and text content.

Implements QmitkOverlay.

◆ SetupCallback()

void QmitkTextOverlay::SetupCallback ( mitk::BaseProperty::Pointer  prop)
protected

Sets up an ITK observer on the given property to auto-update the text.

Parameters
[in]propThe property to observe for modifications.

◆ UpdateDisplayedTextFromProperties()

void QmitkTextOverlay::UpdateDisplayedTextFromProperties ( )
protected

Reads the current text from the property and updates the QLabel.

The text is read from the property identified by m_Id. If the property is not found, the label remains unchanged.

◆ UpdateFontProperties()

void QmitkTextOverlay::UpdateFontProperties ( mitk::PropertyList::Pointer  pl)
protected

Applies font-related properties from the PropertyList to the QLabel.

Reads color, font size, kerning, and font family properties and applies them. Missing properties are replaced with default values.

Parameters
[in]plThe PropertyList to read font properties from.

Member Data Documentation

◆ m_Label

QLabel* QmitkTextOverlay::m_Label
protected

QLabel internally representing the text overlay.

Definition at line 116 of file QmitkTextOverlay.h.

◆ m_ObservedProperty

mitk::BaseProperty::Pointer QmitkTextOverlay::m_ObservedProperty
protected

The observed property for automatic text updates.

Definition at line 122 of file QmitkTextOverlay.h.

◆ m_ObserverTag

unsigned long QmitkTextOverlay::m_ObserverTag
protected

ITK observer tag for the property modification callback.

Definition at line 125 of file QmitkTextOverlay.h.

◆ m_PropertyList

mitk::PropertyList::Pointer QmitkTextOverlay::m_PropertyList
protected

Cached PropertyList for property lookups.

Definition at line 119 of file QmitkTextOverlay.h.


The documentation for this class was generated from the following file: