Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef MITK_PLANAR_FIGURE_MAPPER_2D_H_
18 #define MITK_PLANAR_FIGURE_MAPPER_2D_H_
19 
20 #include "mitkCommon.h"
21 #include "mitkGLMapper.h"
22 #include "mitkPlanarFigure.h"
25 
26 namespace mitk
27 {
28  class BaseRenderer;
29  class Contour;
30  class TextOverlay2D;
31 
110  {
111  public:
113 
114  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
115 
116 
119  virtual void Paint(BaseRenderer *renderer) override;
120 
121  static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer = NULL, bool overwrite = false);
122 
123  protected:
125  {
126  PF_DEFAULT = 0,
127  PF_HOVER = 1,
128  PF_SELECTED = 2,
129 
130  PF_COUNT = 3 // helper variable
131  };
132 
134 
135  virtual ~PlanarFigureMapper2D();
136 
148  void RenderLines(const PlanarFigureDisplayMode lineDisplayMode,
149  mitk::PlanarFigure *planarFigure,
150  mitk::Point2D &anchorPoint,
151  const mitk::PlaneGeometry *planarFigurePlaneGeometry,
152  const mitk::PlaneGeometry *rendererPlaneGeometry,
153  const mitk::BaseRenderer *renderer);
154 
158  void RenderQuantities(const mitk::PlanarFigure *planarFigure,
159  mitk::BaseRenderer *renderer,
160  const mitk::Point2D anchorPoint,
161  double &annotationOffset,
162  float globalOpacity,
163  const PlanarFigureDisplayMode lineDisplayMode);
164 
168  void RenderAnnotations(mitk::BaseRenderer *renderer,
169  const std::string name,
170  const mitk::Point2D anchorPoint,
171  float globalOpacity,
172  const PlanarFigureDisplayMode lineDisplayMode,
173  double &annotationOffset);
174 
178  void RenderControlPoints(const mitk::PlanarFigure *planarFigure,
179  const PlanarFigureDisplayMode lineDisplayMode,
180  const mitk::PlaneGeometry *planarFigurePlaneGeometry,
181  const mitk::PlaneGeometry *rendererPlaneGeometry,
182  mitk::BaseRenderer *renderer);
183 
184  void TransformObjectToDisplay(const mitk::Point2D &point2D,
185  mitk::Point2D &displayPoint,
186  const mitk::PlaneGeometry *objectGeometry,
187  const mitk::PlaneGeometry *,
188  const mitk::BaseRenderer *renderer);
189 
190  void DrawMarker(const mitk::Point2D &point,
191  float *lineColor,
192  float lineOpacity,
193  float *markerColor,
194  float markerOpacity,
195  float lineWidth,
197  const mitk::PlaneGeometry *objectGeometry,
198  const mitk::PlaneGeometry *rendererGeometry,
199  const mitk::BaseRenderer *renderer);
200 
204  void PaintPolyLine(const mitk::PlanarFigure::PolyLineType vertices,
205  bool closed,
206  Point2D &anchorPoint,
207  const PlaneGeometry *planarFigurePlaneGeometry,
208  const PlaneGeometry *rendererPlaneGeometry,
209  const mitk::BaseRenderer *renderer);
210 
215  void DrawMainLines(mitk::PlanarFigure *figure,
216  Point2D &anchorPoint,
217  const PlaneGeometry *planarFigurePlaneGeometry,
218  const PlaneGeometry *rendererPlaneGeometry,
219  const mitk::BaseRenderer *renderer);
220 
225  void DrawHelperLines(mitk::PlanarFigure *figure,
226  Point2D &anchorPoint,
227  const PlaneGeometry *planarFigurePlaneGeometry,
228  const PlaneGeometry *rendererPlaneGeometry,
229  const mitk::BaseRenderer *renderer);
230 
231  void InitializeDefaultPlanarFigureProperties();
232 
233  void InitializePlanarFigurePropertiesFromDataNode(const mitk::DataNode *node);
234 
235  void SetColorProperty(float property[3][3], PlanarFigureDisplayMode mode, float red, float green, float blue)
236  {
237  property[mode][0] = red;
238  property[mode][1] = green;
239  property[mode][2] = blue;
240  }
241 
242  void SetFloatProperty(float *property, PlanarFigureDisplayMode mode, float value) { property[mode] = value; }
250  void OnNodeModified();
251 
252  private:
253  bool m_IsSelected;
254  bool m_IsHovering;
255  bool m_DrawOutline;
256  bool m_DrawQuantities;
257  bool m_DrawShadow;
258  bool m_DrawControlPoints;
259  bool m_DrawName;
260  bool m_DrawDashed;
261  bool m_DrawHelperDashed;
262  bool m_AnnotationsShadow;
263 
264  std::string m_AnnotationFontFamily;
265  bool m_DrawAnnotationBold;
266  bool m_DrawAnnotationItalic;
267  int m_AnnotationSize;
268 
269  // the width of the shadow is defined as 'm_LineWidth * m_ShadowWidthFactor'
270  float m_LineWidth;
271  float m_ShadowWidthFactor;
272  float m_OutlineWidth;
273  float m_HelperlineWidth;
274  // float m_PointWidth;
275 
276  float m_DevicePixelRatio;
277 
279 
280  float m_LineColor[3][3];
281  float m_LineOpacity[3];
282  float m_OutlineColor[3][3];
283  float m_OutlineOpacity[3];
284  float m_HelperlineColor[3][3];
285  float m_HelperlineOpacity[3];
286  float m_MarkerlineColor[3][3];
287  float m_MarkerlineOpacity[3];
288  float m_MarkerColor[3][3];
289  float m_MarkerOpacity[3];
290  float m_AnnotationColor[3][3];
291 
292  // Bool flag that represents whether or not the DataNode has been modified.
293  bool m_NodeModified;
294 
295  // Observer-tag for listening to itk::ModifiedEvents on the DataNode
296  unsigned long m_NodeModifiedObserverTag;
297 
298  // Bool flag that indicates if a node modified observer was added
299  bool m_NodeModifiedObserverAdded;
300 
301  itk::SmartPointer<mitk::TextOverlay2D> m_AnnotationOverlay;
302  itk::SmartPointer<mitk::TextOverlay2D> m_QuantityOverlay;
303  };
304 
305 } // namespace mitk
306 
307 #endif /* MITK_PLANAR_FIGURE_MAPPER_2D_H_ */
Organizes the rendering process.
Base class of all OpenGL-based mappers.
Definition: mitkGLMapper.h:45
DataCollection - Class to facilitate loading/accessing structured data.
Base class of all mappers, Vtk as well as OpenGL mappers.
Definition: mitkMapper.h:54
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:44
#define MITKPLANARFIGURE_EXPORT
Base-class for geometric planar (2D) figures, such as lines, circles, rectangles, polygons...
std::vector< PolyLineElement > PolyLineType
void SetFloatProperty(float *property, PlanarFigureDisplayMode mode, float value)
Describes a two-dimensional, rectangular plane.
OpenGL-based mapper to render display sub-class instances of mitk::PlanarFigure.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66
void SetColorProperty(float property[3][3], PlanarFigureDisplayMode mode, float red, float green, float blue)