Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::PlanarRectangle Class Reference

Implementation of PlanarFigure representing an axis-aligned rectangle. More...

#include <mitkPlanarRectangle.h>

Inheritance diagram for mitk::PlanarRectangle:
Collaboration diagram for mitk::PlanarRectangle:

Public Member Functions

 mitkClassMacro (PlanarRectangle, PlanarFigure)
 
Pointer Clone () const
 
void PlaceFigure (const Point2D &point) override
 Places the rectangle at the given point, initializing all four corners. More...
 
unsigned int GetMinimumNumberOfControlPoints () const override
 Returns 4 – a rectangle requires exactly four control points. More...
 
unsigned int GetMaximumNumberOfControlPoints () const override
 Returns 4 – a rectangle requires exactly four control points. More...
 
bool SetControlPoint (unsigned int index, const Point2D &point, bool createIfDoesNotExist=false) override
 Sets a control point and updates adjacent corners to maintain the rectangle. More...
 
- Public Member Functions inherited from mitk::PlanarFigure
 mitkClassMacro (PlanarFigure, BaseData)
 
Pointer Clone () const
 
virtual void SetPlaneGeometry (mitk::PlaneGeometry *geometry)
 Sets the 2D geometry on which this figure will be placed. More...
 
virtual const PlaneGeometry * GetPlaneGeometry () const
 Returns (previously set) 2D geometry of this figure. More...
 
virtual bool IsClosed () const
 True if the planar figure is closed. More...
 
virtual bool IsPlaced () const
 True if the planar figure has been placed (and can be displayed/interacted with). More...
 
virtual bool AddControlPoint (const Point2D &point, int index=-1)
 Adds / inserts new control-points. More...
 
virtual bool SetCurrentControlPoint (const Point2D &point)
 Sets the position of the currently selected control point. More...
 
unsigned int GetNumberOfControlPoints () const
 Returns the current number of 2D control points defining this figure. More...
 
virtual bool SelectControlPoint (unsigned int index)
 Selects currently active control points. More...
 
virtual bool DeselectControlPoint ()
 Deselect control point; no control point active. More...
 
virtual int GetSelectedControlPoint () const
 Return currently selected control point. More...
 
Point2D GetControlPoint (unsigned int index) const
 Returns specified control point in 2D world coordinates. More...
 
virtual int GetControlPointForPolylinePoint (int indexOfPolylinePoint, int polyLineIndex) const
 Returns the id of the control-point that corresponds to the given polyline-point. More...
 
Point3D GetWorldControlPoint (unsigned int index) const
 Returns specified control point in world coordinates. More...
 
PolyLineType & GetPolyLine (unsigned int index)
 Returns the polyline representing the planar figure (mutable version). More...
 
const PolyLineType & GetPolyLine (unsigned int index) const
 Returns the polyline representing the planar figure (const version). More...
 
const PolyLineType & GetHelperPolyLine (unsigned int index, double mmPerDisplayUnit, unsigned int displayHeight)
 Returns a helper polyline that should be drawn at a fixed size regardless of zoom. More...
 
void SetPreviewControlPoint (const Point2D &point)
 Sets the position of the PreviewControlPoint. Automatically sets it visible. More...
 
void ResetPreviewContolPoint ()
 Marks the PreviewControlPoint as invisible. More...
 
bool IsPreviewControlPointVisible () const
 Returns whether or not the PreviewControlPoint is visible. More...
 
Point2D GetPreviewControlPoint () const
 Returns the coordinates of the PreviewControlPoint. More...
 
virtual unsigned int GetNumberOfFeatures () const
 Returns the number of features available for this PlanarFigure. More...
 
const char * GetFeatureName (unsigned int index) const
 Returns the name (identifier) of the specified feature. More...
 
const char * GetFeatureUnit (unsigned int index) const
 Returns the physical unit of the specified feature. More...
 
double GetQuantity (unsigned int index) const
 Returns the quantity of the specified feature. More...
 
bool IsFeatureActive (unsigned int index) const
 Returns whether the specified feature is active. More...
 
bool IsFeatureVisible (unsigned int index) const
 Returns whether the specified feature is set to visible. More...
 
void SetFeatureVisible (unsigned int index, bool visible)
 Sets the visibility of the specified feature for annotation display. More...
 
virtual void EvaluateFeatures ()
 Calculates quantities of all features of this planar figure. More...
 
void UpdateOutputInformation () override
 Inherited from BaseData. Updates geometry information. More...
 
void SetRequestedRegionToLargestPossibleRegion () override
 Inherited from BaseData. Sets the requested region to the largest possible. More...
 
bool RequestedRegionIsOutsideOfTheBufferedRegion () override
 Inherited from BaseData. Checks if the requested region is outside the buffered region. More...
 
bool VerifyRequestedRegion () override
 Inherited from BaseData. Verifies the requested region. More...
 
void SetRequestedRegion (const itk::DataObject *data) override
 Inherited from BaseData. Sets the requested region from another data object. More...
 
virtual unsigned short GetPolyLinesSize ()
 Returns the current number of polylines
More...
 
virtual unsigned short GetHelperPolyLinesSize () const
 Returns the current number of helperpolylines
More...
 
virtual bool IsHelperToBePainted (unsigned int index) const
 Returns whether a helper polyline should be painted or not. More...
 
virtual bool ResetOnPointSelect ()
 Returns true if the planar figure is reset to "add points" mode when a point is selected. More...
 
virtual bool ResetOnPointSelectNeeded () const
 
virtual void RemoveControlPoint (unsigned int index)
 Removes the control point at the given index. More...
 
virtual void RemoveLastControlPoint ()
 Removes the last control point from the figure. More...
 
virtual Point2D ApplyControlPointConstraints (unsigned int index, const Point2D &point)
 Applies spatial constraints to a control point position. More...
 
void ResetNumberOfControlPoints (int numberOfControlPoints)
 Resets the number of control points to the specified count. More...
 
- Public Member Functions inherited from mitk::BaseData
 mitkClassMacroItkParent (BaseData, itk::DataObject)
 
BaseProperty::ConstPointer GetConstProperty (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) const override
 Get a const property by its key. More...
 
std::vector< std::string > GetPropertyKeys (const std::string &contextName="", bool includeDefaultContext=false) const override
 Get all property keys stored in the property list. More...
 
std::vector< std::string > GetPropertyContextNames () const override
 Get the names of all property contexts. More...
 
BaseProperty * GetNonConstProperty (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) override
 Get a non-const property by its key. More...
 
void SetProperty (const std::string &propertyKey, BaseProperty *property, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
 Set a property in the property list. More...
 
void RemoveProperty (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
 Remove a property from the property list. More...
 
const mitk::TimeGeometry * GetTimeGeometry () const
 Return the TimeGeometry of the data as const pointer. More...
 
mitk::TimeGeometry * GetTimeGeometry ()
 Return the TimeGeometry of the data as non-const pointer. More...
 
const mitk::TimeGeometry * GetUpdatedTimeGeometry ()
 Return the TimeGeometry of the data after ensuring it is up-to-date. More...
 
virtual void Expand (unsigned int timeSteps)
 Expand the TimeGeometry to a number of time steps. More...
 
const mitk::BaseGeometry * GetUpdatedGeometry (int t=0)
 Return the BaseGeometry of the data at time step t after ensuring it is up-to-date. More...
 
mitk::BaseGeometry * GetGeometry (int t=0) const
 Return the BaseGeometry of the data at time step t as a non-const pointer. More...
 
void UpdateOutputInformation () override
 Update the information for this BaseData so that it can be used as an output of a BaseProcess. More...
 
void CopyInformation (const itk::DataObject *data) override
 Copy information from the specified data set. More...
 
virtual bool IsInitialized () const
 Check whether the data has been initialized. More...
 
virtual void Clear ()
 Reset the data object by calling ClearData() and InitializeEmpty(). More...
 
virtual bool IsEmptyTimeStep (unsigned int t) const
 Check whether the object contains data at the specified time step. More...
 
virtual bool IsEmpty () const
 Check whether the object contains data at any time step. More...
 
void ExecuteOperation (Operation *operation) override
 Execute an operation on this data object. More...
 
virtual void SetGeometry (BaseGeometry *aGeometry3D)
 Set the BaseGeometry of the data, which will be referenced (not copied!). More...
 
virtual void SetTimeGeometry (TimeGeometry *geometry)
 Set the TimeGeometry of the data, which will be referenced (not copied!). More...
 
virtual void SetClonedGeometry (const BaseGeometry *aGeometry3D)
 Set a clone of the provided geometry as the BaseGeometry of the data. More...
 
virtual void SetClonedTimeGeometry (const TimeGeometry *geometry)
 Set a clone of the provided TimeGeometry as the TimeGeometry of the data. More...
 
virtual void SetClonedGeometry (const BaseGeometry *aGeometry3D, unsigned int time)
 Set a clone of the provided geometry as the BaseGeometry of a given time step. More...
 
mitk::PropertyList::Pointer GetPropertyList () const
 Get the data's property list. More...
 
void SetPropertyList (PropertyList *propertyList)
 Set the data's property list, replacing the existing one. More...
 
mitk::BaseProperty::Pointer GetProperty (const char *propertyKey) const
 Get a property by its key from the PropertyList. More...
 
void SetProperty (const char *propertyKey, BaseProperty *property)
 Set a property in the PropertyList. More...
 
virtual void SetOrigin (const Point3D &origin)
 Convenience method for setting the origin of the BaseGeometry instances of all time steps. More...
 
itk::SmartPointer< mitk::BaseDataSource > GetSource () const
 Get the process object that generated this data object. More...
 
unsigned int GetTimeSteps () const
 Get the number of time steps from the TimeGeometry. More...
 
itk::ModifiedTimeType GetMTime () const override
 Get the modification time of this data object or its geometry, whichever was modified most recently. More...
 
void Graft (const DataObject *) override
 Graft data and information from another data object. More...
 
- Public Member Functions inherited from mitk::OperationActor
 itkTypeMacroNoParent (OperationActor) virtual ~OperationActor()
 
- Public Member Functions inherited from mitk::Identifiable
 Identifiable ()
 Default constructor. Generates a new random UID. More...
 
 Identifiable (const UIDType &uid)
 Construct with a pre-existing UID. More...
 
 Identifiable (const Identifiable &)=delete
 Copy construction is deleted to prevent UID duplication. More...
 
 Identifiable (Identifiable &&) noexcept
 Move constructor. Transfers ownership of the UID. More...
 
virtual ~Identifiable ()
 Virtual destructor. More...
 
Identifiable & operator= (const Identifiable &)=delete
 Copy assignment is deleted to prevent UID duplication. More...
 
Identifiable & operator= (Identifiable &&other) noexcept
 Move assignment operator. Transfers ownership of the UID. More...
 
virtual UIDType GetUID () const
 Get the unique identifier of this object. More...
 
UIDType GetRuntimeUID () const noexcept
 Get a runtime-unique ID for this object instance. More...
 
- Public Member Functions inherited from mitk::IPropertyOwner
 ~IPropertyOwner () override
 
virtual bool PropertyIsOwned (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) const
 Checks if a certain property exists. More...
 
- Public Member Functions inherited from mitk::IPropertyProvider
virtual ~IPropertyProvider ()
 Virtual destructor. More...
 

Static Public Member Functions

static Pointer New ()
 

Protected Member Functions

 PlanarRectangle ()
 
 PlanarRectangle (const Self &other)
 
 mitkCloneMacro (Self)
 
void GeneratePolyLine () override
 Generates the poly-line representation of the planar figure. More...
 
void GenerateHelperPolyLine (double mmPerDisplayUnit, unsigned int displayHeight) override
 Generates the poly-lines that should be drawn the same size regardless of zoom. More...
 
void EvaluateFeaturesInternal () override
 Calculates feature quantities of the planar figure. More...
 
void PrintSelf (std::ostream &os, itk::Indent indent) const override
 
bool Equals (const mitk::PlanarFigure &other) const override
 Compares this PlanarFigure with another for equality. More...
 
- Protected Member Functions inherited from mitk::PlanarFigure
 PlanarFigure ()
 
 PlanarFigure (const Self &other)
 
virtual unsigned int AddFeature (const char *featureName, const char *unitName)
 
void SetFeatureName (unsigned int index, const char *featureName)
 
void SetFeatureUnit (unsigned int index, const char *unitName)
 
void SetQuantity (unsigned int index, double quantity)
 
void ActivateFeature (unsigned int index)
 
void DeactivateFeature (unsigned int index)
 
void InitializeTimeGeometry (unsigned int timeSteps=1) override
 Initializes the TimeGeometry describing the (time-resolved) geometry of this figure. Note that each time step holds one PlaneGeometry. More...
 
void SetNumberOfPolyLines (unsigned int numberOfPolyLines)
 defines the number of PolyLines that will be available More...
 
void AppendPointToPolyLine (unsigned int index, PolyLineElement element)
 Append a point to the PolyLine # index. More...
 
void ClearPolyLines ()
 clears the list of PolyLines. Call before re-calculating a new Polyline. More...
 
void SetNumberOfHelperPolyLines (unsigned int numberOfHelperPolyLines)
 defines the number of HelperPolyLines that will be available More...
 
void AppendPointToHelperPolyLine (unsigned int index, PolyLineElement element)
 Append a point to the HelperPolyLine # index. More...
 
void ClearHelperPolyLines ()
 clears the list of HelperPolyLines. Call before re-calculating a new HelperPolyline. More...
 
void PrintSelf (std::ostream &os, itk::Indent indent) const override
 
- Protected Member Functions inherited from mitk::BaseData
 BaseData ()
 
 BaseData (const BaseData &other)
 
 ~BaseData () override
 
virtual void ClearData ()
 reset to non-initialized state, release memory More...
 
virtual void InitializeEmpty ()
 Pure virtual; Must be used in subclasses to get a data object to a valid state. Should at least create one empty object and call Superclass::InitializeTimeGeometry() to ensure an existing valid geometry. More...
 
void PrintSelf (std::ostream &os, itk::Indent indent) const override
 
- Protected Member Functions inherited from mitk::Identifiable
virtual void SetUID (const UIDType &uid)
 

Protected Attributes

const unsigned int FEATURE_ID_CIRCUMFERENCE
 
const unsigned int FEATURE_ID_AREA
 
- Protected Attributes inherited from mitk::PlanarFigure
ControlPointListType m_ControlPoints
 
unsigned int m_NumberOfControlPoints
 
int m_SelectedControlPoint
 
std::vector< PolyLineType > m_PolyLines
 
std::vector< PolyLineType > m_HelperPolyLines
 
BoolContainerType::Pointer m_HelperPolyLinesToBePainted
 
Point2D m_PreviewControlPoint
 
bool m_PreviewControlPointVisible
 
bool m_FigurePlaced
 
- Protected Attributes inherited from mitk::BaseData
bool m_LastRequestedRegionWasOutsideOfTheBufferedRegion
 
unsigned int m_SourceOutputIndexDuplicate
 
bool m_Initialized
 

Additional Inherited Members

- Public Types inherited from mitk::PlanarFigure
typedef Point2D PolyLineElement
 Type for individual elements of a polyline (2D points). More...
 
typedef itk::VectorContainer< unsigned long, bool > BoolContainerType
 Container type for boolean values, used for helper polyline paint flags. More...
 
typedef std::deque< Point2D > ControlPointListType
 Type for the list of control points defining the figure. More...
 
typedef std::vector< PolyLineElement > PolyLineType
 Type for a polyline (vector of 2D points). More...
 
- Public Types inherited from mitk::Identifiable
using UIDType = std::string
 Type alias for unique identifiers. More...
 

Detailed Description

Implementation of PlanarFigure representing an axis-aligned rectangle.

A rectangle defined by four control points (corners). When a control point is moved, the adjacent corners are updated to maintain the rectangular shape.

Provides two features:

  • FEATURE_ID_CIRCUMFERENCE: the rectangle perimeter
  • FEATURE_ID_AREA: the rectangle area
See also
PlanarFigure, PlanarPolygon, PlanarFigureMapper2D

Definition at line 36 of file mitkPlanarRectangle.h.

Constructor & Destructor Documentation

◆ PlanarRectangle() [1/2]

mitk::PlanarRectangle::PlanarRectangle ( )
protected

◆ PlanarRectangle() [2/2]

mitk::PlanarRectangle::PlanarRectangle ( const Self &  other)
protected

Member Function Documentation

◆ Clone()

Pointer mitk::PlanarRectangle::Clone ( ) const

◆ Equals()

bool mitk::PlanarRectangle::Equals ( const mitk::PlanarFigure &  other) const
overrideprotectedvirtual

Compares this PlanarFigure with another for equality.

Checks whether control points, features, and figure properties match. All subclasses should implement this method for their specific comparison logic.

Parameters
[in]otherThe PlanarFigure to compare with.
Returns
True if both figures are considered equal.

Reimplemented from mitk::PlanarFigure.

◆ EvaluateFeaturesInternal()

void mitk::PlanarRectangle::EvaluateFeaturesInternal ( )
overrideprotectedvirtual

Calculates feature quantities of the planar figure.

Implements mitk::PlanarFigure.

◆ GenerateHelperPolyLine()

void mitk::PlanarRectangle::GenerateHelperPolyLine ( double  mmPerDisplayUnit,
unsigned int  displayHeight 
)
overrideprotectedvirtual

Generates the poly-lines that should be drawn the same size regardless of zoom.

Implements mitk::PlanarFigure.

◆ GeneratePolyLine()

void mitk::PlanarRectangle::GeneratePolyLine ( )
overrideprotectedvirtual

Generates the poly-line representation of the planar figure.

Implements mitk::PlanarFigure.

◆ GetMaximumNumberOfControlPoints()

unsigned int mitk::PlanarRectangle::GetMaximumNumberOfControlPoints ( ) const
inlineoverridevirtual

Returns 4 – a rectangle requires exactly four control points.

Implements mitk::PlanarFigure.

Definition at line 54 of file mitkPlanarRectangle.h.

◆ GetMinimumNumberOfControlPoints()

unsigned int mitk::PlanarRectangle::GetMinimumNumberOfControlPoints ( ) const
inlineoverridevirtual

Returns 4 – a rectangle requires exactly four control points.

Implements mitk::PlanarFigure.

Definition at line 52 of file mitkPlanarRectangle.h.

◆ mitkClassMacro()

mitk::PlanarRectangle::mitkClassMacro ( PlanarRectangle  ,
PlanarFigure   
)

◆ mitkCloneMacro()

mitk::PlanarRectangle::mitkCloneMacro ( Self  )
protected

◆ New()

static Pointer mitk::PlanarRectangle::New ( )
static

◆ PlaceFigure()

void mitk::PlanarRectangle::PlaceFigure ( const Point2D &  point)
overridevirtual

Places the rectangle at the given point, initializing all four corners.

Parameters
[in]pointThe initial 2D placement position.

Reimplemented from mitk::PlanarFigure.

◆ PrintSelf()

void mitk::PlanarRectangle::PrintSelf ( std::ostream &  os,
itk::Indent  indent 
) const
overrideprotected

◆ SetControlPoint()

bool mitk::PlanarRectangle::SetControlPoint ( unsigned int  index,
const Point2D &  point,
bool  createIfDoesNotExist = false 
)
overridevirtual

Sets a control point and updates adjacent corners to maintain the rectangle.

Parameters
[in]indexZero-based index of the control point (corner).
[in]pointNew 2D coordinates.
[in]createIfDoesNotExistIf true, creates the point if missing.
Returns
True if the control point was set successfully.

Reimplemented from mitk::PlanarFigure.

Member Data Documentation

◆ FEATURE_ID_AREA

const unsigned int mitk::PlanarRectangle::FEATURE_ID_AREA
protected

Definition at line 84 of file mitkPlanarRectangle.h.

◆ FEATURE_ID_CIRCUMFERENCE

const unsigned int mitk::PlanarRectangle::FEATURE_ID_CIRCUMFERENCE
protected

Definition at line 83 of file mitkPlanarRectangle.h.


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