Medical Imaging Interaction Toolkit  2025.12.02
Medical Imaging Interaction Toolkit
mitkPlanarFigureMapper2D.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkPlanarFigureMapper2D_h
14 #define mitkPlanarFigureMapper2D_h
15 
16 #include "mitkCommon.h"
17 #include "mitkMapper.h"
18 #include "mitkPlanarFigure.h"
21 #include "vtkNew.h"
22 #include "vtkPen.h"
23 
24 class vtkContext2D;
25 
26 namespace mitk
27 {
28  class BaseRenderer;
29  class Contour;
30 
109  {
110  public:
112 
113  itkFactorylessNewMacro(Self);
114 
115  itkCloneMacro(Self);
116 
121 
122  static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer = nullptr, bool overwrite = false);
123 
127  void ApplyColorAndOpacityProperties(mitk::BaseRenderer *renderer, vtkActor *actor = nullptr) override;
128 
129  protected:
131  {
132  PF_DEFAULT = 0,
133  PF_HOVER = 1,
134  PF_SELECTED = 2,
135 
136  PF_COUNT = 3 // helper variable
137  };
138 
140 
142 
154  void RenderLines(const PlanarFigureDisplayMode lineDisplayMode,
155  mitk::PlanarFigure *planarFigure,
156  mitk::Point2D &anchorPoint,
157  const mitk::PlaneGeometry *planarFigurePlaneGeometry,
158  const mitk::PlaneGeometry *rendererPlaneGeometry,
159  const mitk::BaseRenderer *renderer,
160  vtkContext2D* context2D);
161 
165  void RenderQuantities(const mitk::PlanarFigure *planarFigure,
166  mitk::BaseRenderer *renderer,
167  const mitk::Point2D anchorPoint,
168  double &annotationOffset,
169  float globalOpacity,
170  const PlanarFigureDisplayMode lineDisplayMode,
171  vtkContext2D* context2D);
172 
177  const std::string name,
178  const mitk::Point2D anchorPoint,
179  float globalOpacity,
180  const PlanarFigureDisplayMode lineDisplayMode,
181  double &annotationOffset,
182  vtkContext2D* context2D);
183 
187  void RenderControlPoints(const mitk::PlanarFigure *planarFigure,
188  const PlanarFigureDisplayMode lineDisplayMode,
189  const mitk::PlaneGeometry *planarFigurePlaneGeometry,
190  const mitk::PlaneGeometry *rendererPlaneGeometry,
191  mitk::BaseRenderer *renderer,
192  vtkContext2D* context2D);
193 
195  mitk::Point2D &displayPoint,
196  const mitk::PlaneGeometry *objectGeometry,
197  const mitk::PlaneGeometry *,
198  const mitk::BaseRenderer *renderer);
199 
200  void DrawMarker(const mitk::Point2D &point,
201  float *lineColor,
202  float lineOpacity,
203  float *markerColor,
204  float markerOpacity,
205  float lineWidth,
207  const mitk::PlaneGeometry *objectGeometry,
208  const mitk::PlaneGeometry *rendererGeometry,
209  const mitk::BaseRenderer *renderer,
210  vtkContext2D* context2D);
211 
216  bool closed,
217  Point2D &anchorPoint,
218  const PlaneGeometry *planarFigurePlaneGeometry,
219  const PlaneGeometry *rendererPlaneGeometry,
220  const mitk::BaseRenderer *renderer,
221  vtkContext2D* context2D);
222 
228  Point2D &anchorPoint,
229  const PlaneGeometry *planarFigurePlaneGeometry,
230  const PlaneGeometry *rendererPlaneGeometry,
231  const mitk::BaseRenderer *renderer,
232  vtkContext2D* context2D);
233 
239  Point2D &anchorPoint,
240  const PlaneGeometry *planarFigurePlaneGeometry,
241  const PlaneGeometry *rendererPlaneGeometry,
242  const mitk::BaseRenderer *renderer,
243  vtkContext2D* context2D);
244 
246 
248 
249  void SetColorProperty(float property[3][3], PlanarFigureDisplayMode mode, float red, float green, float blue)
250  {
251  property[mode][0] = red;
252  property[mode][1] = green;
253  property[mode][2] = blue;
254  }
255 
256  void SetFloatProperty(float *property, PlanarFigureDisplayMode mode, float value) { property[mode] = value; }
265 
267 
268  private:
269 
270  bool m_IsSelected;
271  bool m_IsHovering;
272  bool m_DrawOutline;
273  bool m_DrawQuantities;
274  bool m_DrawShadow;
275  bool m_DrawControlPoints;
276  bool m_DrawName;
277  bool m_DrawDashed;
278  bool m_DrawHelperDashed;
279  bool m_AnnotationsShadow;
280 
281  std::string m_AnnotationFontFamily;
282  bool m_DrawAnnotationBold;
283  bool m_DrawAnnotationItalic;
284  int m_AnnotationSize;
285 
286  // the width of the shadow is defined as 'm_LineWidth * m_ShadowWidthFactor'
287  float m_LineWidth;
288  float m_ShadowWidthFactor;
289  float m_OutlineWidth;
290  float m_HelperlineWidth;
291  // float m_PointWidth;
292 
293  float m_DevicePixelRatio;
294 
296 
297  float m_LineColor[3][3];
298  float m_LineOpacity[3];
299  float m_OutlineColor[3][3];
300  float m_OutlineOpacity[3];
301  float m_HelperlineColor[3][3];
302  float m_HelperlineOpacity[3];
303  float m_MarkerlineColor[3][3];
304  float m_MarkerlineOpacity[3];
305  float m_MarkerColor[3][3];
306  float m_MarkerOpacity[3];
307  float m_AnnotationColor[3][3];
308 
309  // Bool flag that represents whether or not the DataNode has been modified.
310  bool m_NodeModified;
311 
312  // Observer-tag for listening to itk::ModifiedEvents on the DataNode
313  unsigned long m_NodeModifiedObserverTag;
314 
315  // Bool flag that indicates if a node modified observer was added
316  bool m_NodeModifiedObserverAdded;
317 
318  bool m_Initialized;
319 
321  };
322 
323 } // namespace mitk
324 
325 #endif
#define MITKPLANARFIGURE_EXPORT
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64
Base class of all mappers, Vtk as well as OpenGL mappers.
Definition: mitkMapper.h:47
OpenGL-based mapper to render display sub-class instances of mitk::PlanarFigure.
void InitializePlanarFigurePropertiesFromDataNode(const mitk::DataNode *node)
void SetFloatProperty(float *property, PlanarFigureDisplayMode mode, float value)
void TransformObjectToDisplay(const mitk::Point2D &point2D, mitk::Point2D &displayPoint, const mitk::PlaneGeometry *objectGeometry, const mitk::PlaneGeometry *, const mitk::BaseRenderer *renderer)
void ApplyColorAndOpacityProperties(mitk::BaseRenderer *renderer, vtkActor *actor=nullptr) override
Apply color and opacity properties read from the PropertyList. The actor is not used in the GLMappers...
void DrawHelperLines(mitk::PlanarFigure *figure, Point2D &anchorPoint, const PlaneGeometry *planarFigurePlaneGeometry, const PlaneGeometry *rendererPlaneGeometry, const mitk::BaseRenderer *renderer, vtkContext2D *context2D)
Internally used by RenderLines() to draw the helperlines using PaintPolyLine().
void PaintPolyLine(const PlanarFigure::PolyLineType &vertices, bool closed, Point2D &anchorPoint, const PlaneGeometry *planarFigurePlaneGeometry, const PlaneGeometry *rendererPlaneGeometry, const mitk::BaseRenderer *renderer, vtkContext2D *context2D)
Actually paints the polyline defined by the figure.
void RenderAnnotations(mitk::BaseRenderer *renderer, const std::string name, const mitk::Point2D anchorPoint, float globalOpacity, const PlanarFigureDisplayMode lineDisplayMode, double &annotationOffset, vtkContext2D *context2D)
Renders the text annotations.
void MitkRender(mitk::BaseRenderer *renderer, mitk::VtkPropRenderer::RenderType type) override
void InitializeDefaultPlanarFigureProperties()
void RenderControlPoints(const mitk::PlanarFigure *planarFigure, const PlanarFigureDisplayMode lineDisplayMode, const mitk::PlaneGeometry *planarFigurePlaneGeometry, const mitk::PlaneGeometry *rendererPlaneGeometry, mitk::BaseRenderer *renderer, vtkContext2D *context2D)
Renders the control-points.
void OnNodeModified()
Callback that sets m_NodeModified to true.
void DrawMainLines(mitk::PlanarFigure *figure, Point2D &anchorPoint, const PlaneGeometry *planarFigurePlaneGeometry, const PlaneGeometry *rendererPlaneGeometry, const mitk::BaseRenderer *renderer, vtkContext2D *context2D)
Internally used by RenderLines() to draw the mainlines using PaintPolyLine().
void Initialize(mitk::BaseRenderer *renderer)
void DrawMarker(const mitk::Point2D &point, float *lineColor, float lineOpacity, float *markerColor, float markerOpacity, float lineWidth, PlanarFigureControlPointStyleProperty::Shape shape, const mitk::PlaneGeometry *objectGeometry, const mitk::PlaneGeometry *rendererGeometry, const mitk::BaseRenderer *renderer, vtkContext2D *context2D)
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
void SetColorProperty(float property[3][3], PlanarFigureDisplayMode mode, float red, float green, float blue)
void RenderQuantities(const mitk::PlanarFigure *planarFigure, mitk::BaseRenderer *renderer, const mitk::Point2D anchorPoint, double &annotationOffset, float globalOpacity, const PlanarFigureDisplayMode lineDisplayMode, vtkContext2D *context2D)
Renders the quantities of the figure below the text annotations.
mitkClassMacro(PlanarFigureMapper2D, Mapper)
void RenderLines(const PlanarFigureDisplayMode lineDisplayMode, mitk::PlanarFigure *planarFigure, mitk::Point2D &anchorPoint, const mitk::PlaneGeometry *planarFigurePlaneGeometry, const mitk::PlaneGeometry *rendererPlaneGeometry, const mitk::BaseRenderer *renderer, vtkContext2D *context2D)
Renders all the lines defined by the PlanarFigure.
Base-class for geometric planar (2D) figures, such as lines, circles, rectangles, polygons,...
std::vector< PolyLineElement > PolyLineType
Describes a two-dimensional, rectangular plane.
Find image slices visible on a given plane.