Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkScalarBar Class Reference

A widget that draws a scale bar with subdivision lines for spatial reference. More...

#include <QmitkScalarBar.h>

Inheritance diagram for QmitkScalarBar:
Collaboration diagram for QmitkScalarBar:

Public Types

enum  alignment { vertical , horizontal }
 Orientation of the scalar bar. More...
 

Public Member Functions

 QmitkScalarBar (QWidget *parent=nullptr)
 Constructor. More...
 
 ~QmitkScalarBar () override
 Destructor. More...
 
virtual void SetScaleFactor (double scale)
 Sets the scale factor (mm per pixel) and resizes the bar accordingly. More...
 
virtual void SetAlignment (alignment align)
 Sets the orientation of the scalar bar. More...
 
void SetPen (const QPen &pen)
 Sets the pen used to draw the scalar bar lines. More...
 
void SetNumberOfSubdivisions (unsigned int subs)
 Sets the number of subdivision tick marks. More...
 
unsigned int GetNumberOfSubdivisions ()
 Returns the current number of subdivision tick marks. More...
 

Protected Member Functions

void paintEvent (QPaintEvent *event) override
 
void SetupGeometry (alignment align)
 
void CleanUpLines ()
 

Protected Attributes

alignment m_Alignment
 
double m_ScaleFactor
 
QLine * m_MainLine
 
std::vector< QLine * > m_SubDivisionLines
 
QPen m_Pen
 
unsigned int m_NumberOfSubDivisions
 

Detailed Description

A widget that draws a scale bar with subdivision lines for spatial reference.

The scalar bar can be oriented either vertically or horizontally. It automatically adapts its number of subdivisions and size based on the parent widget dimensions and the given scale factor (mm-per-pixel). The bar is drawn using a configurable QPen.

See also
QmitkScalarBarOverlay

Definition at line 32 of file QmitkScalarBar.h.

Member Enumeration Documentation

◆ alignment

Orientation of the scalar bar.

Enumerator
vertical 

Vertical orientation (default)

horizontal 

Horizontal orientation.

Definition at line 39 of file QmitkScalarBar.h.

Constructor & Destructor Documentation

◆ QmitkScalarBar()

QmitkScalarBar::QmitkScalarBar ( QWidget *  parent = nullptr)

Constructor.

Parameters
[in]parentOptional parent widget.

◆ ~QmitkScalarBar()

QmitkScalarBar::~QmitkScalarBar ( )
override

Destructor.

Member Function Documentation

◆ CleanUpLines()

void QmitkScalarBar::CleanUpLines ( )
protected

◆ GetNumberOfSubdivisions()

unsigned int QmitkScalarBar::GetNumberOfSubdivisions ( )

Returns the current number of subdivision tick marks.

Returns
The number of subdivisions.

◆ paintEvent()

void QmitkScalarBar::paintEvent ( QPaintEvent *  event)
overrideprotected

◆ SetAlignment()

virtual void QmitkScalarBar::SetAlignment ( alignment  align)
virtual

Sets the orientation of the scalar bar.

Parameters
[in]alignThe desired alignment (vertical or horizontal).

◆ SetNumberOfSubdivisions()

void QmitkScalarBar::SetNumberOfSubdivisions ( unsigned int  subs)

Sets the number of subdivision tick marks.

Parameters
[in]subsThe number of subdivisions.

◆ SetPen()

void QmitkScalarBar::SetPen ( const QPen &  pen)

Sets the pen used to draw the scalar bar lines.

Parameters
[in]penThe QPen to use for rendering.

◆ SetScaleFactor()

virtual void QmitkScalarBar::SetScaleFactor ( double  scale)
virtual

Sets the scale factor (mm per pixel) and resizes the bar accordingly.

The method dynamically adjusts the number of subdivisions and the widget size to fit within a reasonable proportion of the parent widget.

Parameters
[in]scaleThe scale factor in mm per pixel.

◆ SetupGeometry()

void QmitkScalarBar::SetupGeometry ( alignment  align)
protected

Member Data Documentation

◆ m_Alignment

alignment QmitkScalarBar::m_Alignment
protected

Definition at line 96 of file QmitkScalarBar.h.

◆ m_MainLine

QLine* QmitkScalarBar::m_MainLine
protected

Definition at line 100 of file QmitkScalarBar.h.

◆ m_NumberOfSubDivisions

unsigned int QmitkScalarBar::m_NumberOfSubDivisions
protected

Definition at line 106 of file QmitkScalarBar.h.

◆ m_Pen

QPen QmitkScalarBar::m_Pen
protected

Definition at line 104 of file QmitkScalarBar.h.

◆ m_ScaleFactor

double QmitkScalarBar::m_ScaleFactor
protected

Definition at line 98 of file QmitkScalarBar.h.

◆ m_SubDivisionLines

std::vector<QLine *> QmitkScalarBar::m_SubDivisionLines
protected

Definition at line 102 of file QmitkScalarBar.h.


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