Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkPlanarFigureMapper2D.cpp
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 
18 
19 #include "mitkBaseRenderer.h"
20 #include "mitkColorProperty.h"
21 #include "mitkGL.h"
22 #include "mitkPlaneGeometry.h"
23 #include "mitkProperties.h"
24 
25 #include "mitkTextOverlay2D.h"
26 
27 #define _USE_MATH_DEFINES
28 #include <math.h>
29 
30 // offset which moves the planarfigures on top of the other content
31 // the crosshair is rendered into the z = 1 layer.
32 static const float PLANAR_OFFSET = 0.5f;
33 
35  : m_NodeModified(true), m_NodeModifiedObserverTag(0), m_NodeModifiedObserverAdded(false)
36 {
37  m_AnnotationOverlay = mitk::TextOverlay2D::New();
38  m_QuantityOverlay = mitk::TextOverlay2D::New();
39 
41 }
42 
44 {
45  if (m_NodeModifiedObserverAdded && GetDataNode() != NULL)
46  {
47  GetDataNode()->RemoveObserver(m_NodeModifiedObserverTag);
48  }
49 }
50 
52 {
53  bool visible = true;
54 
55  m_AnnotationOverlay->SetVisibility(false, renderer);
56 
57  m_QuantityOverlay->SetVisibility(false, renderer);
58 
59  GetDataNode()->GetVisibility(visible, renderer, "visible");
60  if (!visible)
61  return;
62 
63  // Get PlanarFigure from input
64  mitk::PlanarFigure *planarFigure =
65  const_cast<mitk::PlanarFigure *>(static_cast<const mitk::PlanarFigure *>(GetDataNode()->GetData()));
66 
67  // Check if PlanarFigure has already been placed; otherwise, do nothing
68  if (!planarFigure->IsPlaced())
69  {
70  return;
71  }
72 
73  // Get 2D geometry frame of PlanarFigure
74  const mitk::PlaneGeometry *planarFigurePlaneGeometry = planarFigure->GetPlaneGeometry();
75  if (planarFigurePlaneGeometry == NULL)
76  {
77  MITK_ERROR << "PlanarFigure does not have valid PlaneGeometry!";
78  return;
79  }
80 
81  // Get current world 2D geometry from renderer
82  const mitk::PlaneGeometry *rendererPlaneGeometry = renderer->GetCurrentWorldPlaneGeometry();
83 
84  // If the PlanarFigure geometry is a plane geometry, check if current
85  // world plane is parallel to and within the planar figure geometry bounds
86  // (otherwise, display nothing)
87 
88  if ((planarFigurePlaneGeometry != NULL) && (rendererPlaneGeometry != NULL))
89  {
90  double planeThickness = planarFigurePlaneGeometry->GetExtentInMM(2);
91  if (!planarFigurePlaneGeometry->IsParallel(rendererPlaneGeometry) ||
92  !(planarFigurePlaneGeometry->DistanceFromPlane(rendererPlaneGeometry) < planeThickness / 3.0))
93  {
94  // Planes are not parallel or renderer plane is not within PlanarFigure
95  // geometry bounds --> exit
96  return;
97  }
98  }
99  else
100  {
101  // Plane is not valid (curved reformations are not possible yet)
102  return;
103  }
104 
105  // Apply visual appearance properties from the PropertyList
106  ApplyColorAndOpacityProperties(renderer);
107 
108  // Enable line antialiasing
109  glEnable(GL_LINE_SMOOTH);
110  glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
111  glEnable(GL_DEPTH_TEST);
112 
113  // Get properties from node (if present)
114  const mitk::DataNode *node = this->GetDataNode();
115  this->InitializePlanarFigurePropertiesFromDataNode(node);
116 
117  PlanarFigureDisplayMode lineDisplayMode = PF_DEFAULT;
118 
119  if (m_IsSelected)
120  {
121  lineDisplayMode = PF_SELECTED;
122  }
123  else if (m_IsHovering)
124  {
125  lineDisplayMode = PF_HOVER;
126  }
127 
128  mitk::Point2D anchorPoint;
129  anchorPoint[0] = 0;
130  anchorPoint[1] = 1;
131 
132  // render the actual lines of the PlanarFigure
133  RenderLines(lineDisplayMode, planarFigure, anchorPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer);
134 
135  // position-offset of the annotations, is set in RenderAnnotations() and
136  // used in RenderQuantities()
137  double annotationOffset = 0.0;
138 
139  // Get Global Opacity
140  float globalOpacity = 1.0;
141  node->GetFloatProperty("opacity", globalOpacity);
142 
143  if (m_DrawControlPoints)
144  {
145  // draw the control-points
146  RenderControlPoints(planarFigure, lineDisplayMode, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer);
147  }
148 
149  // draw name near the anchor point (point located on the right)
150  const std::string name = node->GetName();
151  if (m_DrawName && !name.empty())
152  {
153  RenderAnnotations(renderer, name, anchorPoint, globalOpacity, lineDisplayMode, annotationOffset);
154  }
155 
156  // draw feature quantities (if requested) next to the anchor point,
157  // but under the name (that is where 'annotationOffset' is used)
158  if (m_DrawQuantities)
159  {
160  RenderQuantities(planarFigure, renderer, anchorPoint, annotationOffset, globalOpacity, lineDisplayMode);
161  }
162 
163  glLineWidth(1.0f);
164 }
165 
167  bool closed,
168  Point2D &anchorPoint,
169  const PlaneGeometry *planarFigurePlaneGeometry,
170  const PlaneGeometry *rendererPlaneGeometry,
171  const mitk::BaseRenderer *renderer)
172 {
173  mitk::Point2D rightMostPoint;
174  rightMostPoint.Fill(itk::NumericTraits<float>::min());
175 
176  // transform all vertices into Point2Ds in display-Coordinates and store them in vector
177  std::vector<mitk::Point2D> pointlist;
178  for (auto iter = vertices.cbegin(); iter != vertices.cend(); ++iter)
179  {
180  // Draw this 2D point as OpenGL vertex
181  mitk::Point2D displayPoint;
182  this->TransformObjectToDisplay(*iter, displayPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer);
183 
184  pointlist.push_back(displayPoint);
185 
186  if (displayPoint[0] > rightMostPoint[0])
187  rightMostPoint = displayPoint;
188  }
189 
190  // If the planarfigure is closed, we add the first control point again.
191  // Thus we can always use 'GL_LINE_STRIP' and get rid of strange flickering
192  // effect when using the MESA OpenGL library.
193  if (closed)
194  {
195  mitk::Point2D displayPoint;
196  this->TransformObjectToDisplay(
197  vertices.cbegin()[0], displayPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer);
198 
199  pointlist.push_back(displayPoint);
200  }
201 
202  // now paint all the points in one run
203 
204  glBegin(GL_LINE_STRIP);
205  for (auto pointIter = pointlist.cbegin(); pointIter != pointlist.cend(); pointIter++)
206  {
207  glVertex3f((*pointIter)[0], (*pointIter)[1], PLANAR_OFFSET);
208  }
209  glEnd();
210 
211  anchorPoint = rightMostPoint;
212 }
213 
215  Point2D &anchorPoint,
216  const PlaneGeometry *planarFigurePlaneGeometry,
217  const PlaneGeometry *rendererPlaneGeometry,
218  const mitk::BaseRenderer *renderer)
219 {
220  const auto numberOfPolyLines = figure->GetPolyLinesSize();
221  for (auto loop = 0; loop < numberOfPolyLines; ++loop)
222  {
223  const auto polyline = figure->GetPolyLine(loop);
224 
225  this->PaintPolyLine(
226  polyline, figure->IsClosed(), anchorPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer);
227  }
228 }
229 
231  Point2D &anchorPoint,
232  const PlaneGeometry *planarFigurePlaneGeometry,
233  const PlaneGeometry *rendererPlaneGeometry,
234  const mitk::BaseRenderer *renderer)
235 {
236  const auto numberOfHelperPolyLines = figure->GetHelperPolyLinesSize();
237 
238  // Draw helper objects
239  for (unsigned int loop = 0; loop < numberOfHelperPolyLines; ++loop)
240  {
241  const auto helperPolyLine =
242  figure->GetHelperPolyLine(loop, renderer->GetScaleFactorMMPerDisplayUnit(), renderer->GetViewportSize()[1]);
243 
244  // Check if the current helper objects is to be painted
245  if (!figure->IsHelperToBePainted(loop))
246  {
247  continue;
248  }
249 
250  // ... and once normally above the shadow.
251  this->PaintPolyLine(helperPolyLine, false, anchorPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer);
252  }
253 }
254 
256  mitk::Point2D &displayPoint,
257  const mitk::PlaneGeometry *objectGeometry,
258  const mitk::PlaneGeometry * /*rendererGeometry*/,
259  const mitk::BaseRenderer *renderer)
260 {
261  mitk::Point3D point3D;
262 
263  // Map circle point from local 2D geometry into 3D world space
264  objectGeometry->Map(point2D, point3D);
265 
266  // Project 3D world point onto display geometry
267  renderer->WorldToDisplay(point3D, displayPoint);
268 }
269 
271  float *lineColor,
272  float lineOpacity,
273  float *markerColor,
274  float markerOpacity,
275  float lineWidth,
277  const mitk::PlaneGeometry *objectGeometry,
278  const mitk::PlaneGeometry *rendererGeometry,
279  const mitk::BaseRenderer *renderer)
280 {
281  if (this->GetDataNode() != nullptr && this->GetDataNode()->GetDataInteractor().IsNull())
282  return;
283 
284  if (markerOpacity == 0 && lineOpacity == 0)
285  return;
286 
287  mitk::Point2D displayPoint;
288 
289  this->TransformObjectToDisplay(point, displayPoint, objectGeometry, rendererGeometry, renderer);
290 
291  glColor4f(markerColor[0], markerColor[1], markerColor[2], markerOpacity);
292  glLineWidth(lineWidth);
293 
294  switch (shape)
295  {
297  default:
298  {
299  // Paint filled square
300 
301  // Disable line antialiasing (does not look nice for squares)
302  glDisable(GL_LINE_SMOOTH);
303  if (markerOpacity > 0)
304  {
305  glRectf(displayPoint[0] - 4, displayPoint[1] - 4, displayPoint[0] + 4, displayPoint[1] + 4);
306  }
307  // Paint outline
308  glColor4f(lineColor[0], lineColor[1], lineColor[2], lineOpacity);
309  glBegin(GL_LINE_LOOP);
310  glVertex3f(displayPoint[0] - 4, displayPoint[1] - 4, PLANAR_OFFSET);
311  glVertex3f(displayPoint[0] - 4, displayPoint[1] + 4, PLANAR_OFFSET);
312  glVertex3f(displayPoint[0] + 4, displayPoint[1] + 4, PLANAR_OFFSET);
313  glVertex3f(displayPoint[0] + 4, displayPoint[1] - 4, PLANAR_OFFSET);
314  glEnd();
315  break;
316  }
317 
319  {
320  float radius = 4.0;
321 
322  if (markerOpacity > 0)
323  {
324  // Paint filled circle
325  glBegin(GL_POLYGON);
326  for (int angle = 0; angle < 8; ++angle)
327  {
328  float angleRad = angle * (float)3.14159 / 4.0;
329  float x = displayPoint[0] + radius * (float)cos(angleRad);
330  float y = displayPoint[1] + radius * (float)sin(angleRad);
331  glVertex3f(x, y, PLANAR_OFFSET);
332  }
333  glEnd();
334  }
335 
336  // Paint outline
337  glColor4f(lineColor[0], lineColor[1], lineColor[2], lineOpacity);
338  glBegin(GL_LINE_LOOP);
339  for (int angle = 0; angle < 8; ++angle)
340  {
341  float angleRad = angle * (float)3.14159 / 4.0;
342  float x = displayPoint[0] + radius * (float)cos(angleRad);
343  float y = displayPoint[1] + radius * (float)sin(angleRad);
344  glVertex3f(x, y, PLANAR_OFFSET);
345  }
346  glEnd();
347  break;
348  }
349 
350  } // end switch
351 }
352 
354 {
355  m_IsSelected = false;
356  m_IsHovering = false;
357  m_DrawOutline = false;
358  m_DrawQuantities = false;
359  m_DrawShadow = false;
360  m_DrawControlPoints = false;
361  m_DrawName = true;
362  m_DrawDashed = false;
363  m_DrawHelperDashed = false;
364  m_AnnotationsShadow = false;
365 
366  m_ShadowWidthFactor = 1.2;
367  m_LineWidth = 1.0;
368  m_OutlineWidth = 4.0;
369  m_HelperlineWidth = 2.0;
370 
371  m_DevicePixelRatio = 1.0;
372 
373  m_ControlPointShape = PlanarFigureControlPointStyleProperty::Square;
374 
375  this->SetColorProperty(m_LineColor, PF_DEFAULT, 1.0, 1.0, 1.0);
376  this->SetFloatProperty(m_LineOpacity, PF_DEFAULT, 1.0);
377  this->SetColorProperty(m_OutlineColor, PF_DEFAULT, 0.0, 0.0, 1.0);
378  this->SetFloatProperty(m_OutlineOpacity, PF_DEFAULT, 1.0);
379  this->SetColorProperty(m_HelperlineColor, PF_DEFAULT, 0.4, 0.8, 0.2);
380  this->SetFloatProperty(m_HelperlineOpacity, PF_DEFAULT, 0.4);
381  this->SetColorProperty(m_MarkerlineColor, PF_DEFAULT, 1.0, 1.0, 1.0);
382  this->SetFloatProperty(m_MarkerlineOpacity, PF_DEFAULT, 1.0);
383  this->SetColorProperty(m_MarkerColor, PF_DEFAULT, 1.0, 1.0, 1.0);
384  this->SetFloatProperty(m_MarkerOpacity, PF_DEFAULT, 0.0);
385  this->SetColorProperty(m_AnnotationColor, PF_DEFAULT, 1.0, 1.0, 1.0);
386 
387  this->SetColorProperty(m_LineColor, PF_HOVER, 1.0, 0.7, 0.0);
388  this->SetFloatProperty(m_LineOpacity, PF_HOVER, 1.0);
389  this->SetColorProperty(m_OutlineColor, PF_HOVER, 0.0, 0.0, 1.0);
390  this->SetFloatProperty(m_OutlineOpacity, PF_HOVER, 1.0);
391  this->SetColorProperty(m_HelperlineColor, PF_HOVER, 0.4, 0.8, 0.2);
392  this->SetFloatProperty(m_HelperlineOpacity, PF_HOVER, 0.4);
393  this->SetColorProperty(m_MarkerlineColor, PF_HOVER, 1.0, 1.0, 1.0);
394  this->SetFloatProperty(m_MarkerlineOpacity, PF_HOVER, 1.0);
395  this->SetColorProperty(m_MarkerColor, PF_HOVER, 1.0, 0.6, 0.0);
396  this->SetFloatProperty(m_MarkerOpacity, PF_HOVER, 0.2);
397  this->SetColorProperty(m_AnnotationColor, PF_HOVER, 1.0, 0.7, 0.0);
398 
399  this->SetColorProperty(m_LineColor, PF_SELECTED, 1.0, 0.0, 0.0);
400  this->SetFloatProperty(m_LineOpacity, PF_SELECTED, 1.0);
401  this->SetColorProperty(m_OutlineColor, PF_SELECTED, 0.0, 0.0, 1.0);
402  this->SetFloatProperty(m_OutlineOpacity, PF_SELECTED, 1.0);
403  this->SetColorProperty(m_HelperlineColor, PF_SELECTED, 0.4, 0.8, 0.2);
404  this->SetFloatProperty(m_HelperlineOpacity, PF_SELECTED, 0.4);
405  this->SetColorProperty(m_MarkerlineColor, PF_SELECTED, 1.0, 1.0, 1.0);
406  this->SetFloatProperty(m_MarkerlineOpacity, PF_SELECTED, 1.0);
407  this->SetColorProperty(m_MarkerColor, PF_SELECTED, 1.0, 0.6, 0.0);
408  this->SetFloatProperty(m_MarkerOpacity, PF_SELECTED, 1.0);
409  this->SetColorProperty(m_AnnotationColor, PF_SELECTED, 1.0, 0.0, 0.0);
410 }
411 
413 {
414  if (node == NULL)
415  {
416  return;
417  }
418 
419  // if we have not added an observer for ModifiedEvents on the DataNode,
420  // we add one now.
421  if (!m_NodeModifiedObserverAdded)
422  {
425  nodeModifiedCommand->SetCallbackFunction(this, &mitk::PlanarFigureMapper2D::OnNodeModified);
426  m_NodeModifiedObserverTag = node->AddObserver(itk::ModifiedEvent(), nodeModifiedCommand);
427  m_NodeModifiedObserverAdded = true;
428  }
429 
430  // If the DataNode has not been modified since the last execution of
431  // this method, we do not run it now.
432  if (!m_NodeModified)
433  return;
434 
435  // Mark the current properties as unmodified
436  m_NodeModified = false;
437 
438  // Get Global Opacity
439  float globalOpacity = 1.0;
440  node->GetFloatProperty("opacity", globalOpacity);
441 
442  node->GetBoolProperty("selected", m_IsSelected);
443  node->GetBoolProperty("planarfigure.ishovering", m_IsHovering);
444  node->GetBoolProperty("planarfigure.drawoutline", m_DrawOutline);
445  node->GetBoolProperty("planarfigure.drawshadow", m_DrawShadow);
446  node->GetBoolProperty("planarfigure.drawquantities", m_DrawQuantities);
447  node->GetBoolProperty("planarfigure.drawcontrolpoints", m_DrawControlPoints);
448  node->GetBoolProperty("planarfigure.drawname", m_DrawName);
449 
450  node->GetBoolProperty("planarfigure.drawdashed", m_DrawDashed);
451  node->GetBoolProperty("planarfigure.helperline.drawdashed", m_DrawHelperDashed);
452 
453  node->GetFloatProperty("planarfigure.line.width", m_LineWidth);
454  node->GetFloatProperty("planarfigure.shadow.widthmodifier", m_ShadowWidthFactor);
455  node->GetFloatProperty("planarfigure.outline.width", m_OutlineWidth);
456  node->GetFloatProperty("planarfigure.helperline.width", m_HelperlineWidth);
457 
458  node->GetFloatProperty("planarfigure.devicepixelratio", m_DevicePixelRatio);
459  node->GetStringProperty("planarfigure.annotations.font.family", m_AnnotationFontFamily);
460  node->GetBoolProperty("planarfigure.annotations.font.bold", m_DrawAnnotationBold);
461  node->GetBoolProperty("planarfigure.annotations.font.italic", m_DrawAnnotationItalic);
462  node->GetIntProperty("planarfigure.annotations.font.size", m_AnnotationSize);
463  if (!node->GetBoolProperty("planarfigure.annotations.shadow", m_AnnotationsShadow))
464  {
465  node->GetBoolProperty("planarfigure.drawshadow", m_AnnotationsShadow);
466  }
467 
469  dynamic_cast<PlanarFigureControlPointStyleProperty *>(node->GetProperty("planarfigure.controlpointshape"));
470  if (styleProperty.IsNotNull())
471  {
472  m_ControlPointShape = styleProperty->GetShape();
473  }
474 
475  // Set default color and opacity
476  // If property "planarfigure.default.*.color" exists, then use that color. Otherwise global "color" property is used.
477  if (!node->GetColor(m_LineColor[PF_DEFAULT], NULL, "planarfigure.default.line.color"))
478  {
479  node->GetColor(m_LineColor[PF_DEFAULT], NULL, "color");
480  }
481  node->GetFloatProperty("planarfigure.default.line.opacity", m_LineOpacity[PF_DEFAULT]);
482 
483  if (!node->GetColor(m_OutlineColor[PF_DEFAULT], NULL, "planarfigure.default.outline.color"))
484  {
485  node->GetColor(m_OutlineColor[PF_DEFAULT], NULL, "color");
486  }
487  node->GetFloatProperty("planarfigure.default.outline.opacity", m_OutlineOpacity[PF_DEFAULT]);
488 
489  if (!node->GetColor(m_HelperlineColor[PF_DEFAULT], NULL, "planarfigure.default.helperline.color"))
490  {
491  node->GetColor(m_HelperlineColor[PF_DEFAULT], NULL, "color");
492  }
493  node->GetFloatProperty("planarfigure.default.helperline.opacity", m_HelperlineOpacity[PF_DEFAULT]);
494 
495  node->GetColor(m_MarkerlineColor[PF_DEFAULT], NULL, "planarfigure.default.markerline.color");
496  node->GetFloatProperty("planarfigure.default.markerline.opacity", m_MarkerlineOpacity[PF_DEFAULT]);
497  node->GetColor(m_MarkerColor[PF_DEFAULT], NULL, "planarfigure.default.marker.color");
498  node->GetFloatProperty("planarfigure.default.marker.opacity", m_MarkerOpacity[PF_DEFAULT]);
499  if (!node->GetColor(m_AnnotationColor[PF_DEFAULT], NULL, "planarfigure.default.annotation.color"))
500  {
501  if (!node->GetColor(m_AnnotationColor[PF_DEFAULT], NULL, "planarfigure.default.line.color"))
502  {
503  node->GetColor(m_AnnotationColor[PF_DEFAULT], NULL, "color");
504  }
505  }
506 
507  // Set hover color and opacity
508  node->GetColor(m_LineColor[PF_HOVER], NULL, "planarfigure.hover.line.color");
509  node->GetFloatProperty("planarfigure.hover.line.opacity", m_LineOpacity[PF_HOVER]);
510  node->GetColor(m_OutlineColor[PF_HOVER], NULL, "planarfigure.hover.outline.color");
511  node->GetFloatProperty("planarfigure.hover.outline.opacity", m_OutlineOpacity[PF_HOVER]);
512  node->GetColor(m_HelperlineColor[PF_HOVER], NULL, "planarfigure.hover.helperline.color");
513  node->GetFloatProperty("planarfigure.hover.helperline.opacity", m_HelperlineOpacity[PF_HOVER]);
514  node->GetColor(m_MarkerlineColor[PF_HOVER], NULL, "planarfigure.hover.markerline.color");
515  node->GetFloatProperty("planarfigure.hover.markerline.opacity", m_MarkerlineOpacity[PF_HOVER]);
516  node->GetColor(m_MarkerColor[PF_HOVER], NULL, "planarfigure.hover.marker.color");
517  node->GetFloatProperty("planarfigure.hover.marker.opacity", m_MarkerOpacity[PF_HOVER]);
518  if (!node->GetColor(m_AnnotationColor[PF_HOVER], NULL, "planarfigure.hover.annotation.color"))
519  {
520  if (!node->GetColor(m_AnnotationColor[PF_HOVER], NULL, "planarfigure.hover.line.color"))
521  {
522  node->GetColor(m_AnnotationColor[PF_HOVER], NULL, "color");
523  }
524  }
525 
526  // Set selected color and opacity
527  node->GetColor(m_LineColor[PF_SELECTED], NULL, "planarfigure.selected.line.color");
528  node->GetFloatProperty("planarfigure.selected.line.opacity", m_LineOpacity[PF_SELECTED]);
529  node->GetColor(m_OutlineColor[PF_SELECTED], NULL, "planarfigure.selected.outline.color");
530  node->GetFloatProperty("planarfigure.selected.outline.opacity", m_OutlineOpacity[PF_SELECTED]);
531  node->GetColor(m_HelperlineColor[PF_SELECTED], NULL, "planarfigure.selected.helperline.color");
532  node->GetFloatProperty("planarfigure.selected.helperline.opacity", m_HelperlineOpacity[PF_SELECTED]);
533  node->GetColor(m_MarkerlineColor[PF_SELECTED], NULL, "planarfigure.selected.markerline.color");
534  node->GetFloatProperty("planarfigure.selected.markerline.opacity", m_MarkerlineOpacity[PF_SELECTED]);
535  node->GetColor(m_MarkerColor[PF_SELECTED], NULL, "planarfigure.selected.marker.color");
536  node->GetFloatProperty("planarfigure.selected.marker.opacity", m_MarkerOpacity[PF_SELECTED]);
537  if (!node->GetColor(m_AnnotationColor[PF_SELECTED], NULL, "planarfigure.selected.annotation.color"))
538  {
539  if (!node->GetColor(m_AnnotationColor[PF_SELECTED], NULL, "planarfigure.selected.line.color"))
540  {
541  node->GetColor(m_AnnotationColor[PF_SELECTED], NULL, "color");
542  }
543  }
544 
545  // adapt opacity values to global "opacity" property
546  for (unsigned int i = 0; i < PF_COUNT; ++i)
547  {
548  m_LineOpacity[i] *= globalOpacity;
549  m_OutlineOpacity[i] *= globalOpacity;
550  m_HelperlineOpacity[i] *= globalOpacity;
551  m_MarkerlineOpacity[i] *= globalOpacity;
552  m_MarkerOpacity[i] *= globalOpacity;
553  }
554 }
555 
557 {
558  m_NodeModified = true;
559 }
560 
562  mitk::BaseRenderer *renderer,
563  bool overwrite)
564 {
565  node->AddProperty("visible", mitk::BoolProperty::New(true), renderer, overwrite);
566 
567  // node->SetProperty("planarfigure.iseditable",mitk::BoolProperty::New(true));
568  node->AddProperty("planarfigure.isextendable", mitk::BoolProperty::New(false));
569  // node->AddProperty( "planarfigure.ishovering", mitk::BoolProperty::New(true) );
570  node->AddProperty("planarfigure.drawoutline", mitk::BoolProperty::New(false));
571  // node->AddProperty( "planarfigure.drawquantities", mitk::BoolProperty::New(true) );
572  node->AddProperty("planarfigure.drawshadow", mitk::BoolProperty::New(true));
573  node->AddProperty("planarfigure.drawcontrolpoints", mitk::BoolProperty::New(true));
574  node->AddProperty("planarfigure.drawname", mitk::BoolProperty::New(true));
575  node->AddProperty("planarfigure.drawdashed", mitk::BoolProperty::New(false));
576  node->AddProperty("planarfigure.helperline.drawdashed", mitk::BoolProperty::New(false));
577 
578  node->AddProperty("planarfigure.annotations.font.family", mitk::StringProperty::New("Arial"));
579  node->AddProperty("planarfigure.annotations.font.bold", mitk::BoolProperty::New(false));
580  node->AddProperty("planarfigure.annotations.font.italic", mitk::BoolProperty::New(false));
581  node->AddProperty("planarfigure.annotations.font.size", mitk::IntProperty::New(12));
582 
583  node->AddProperty("planarfigure.line.width", mitk::FloatProperty::New(2.0));
584  node->AddProperty("planarfigure.shadow.widthmodifier", mitk::FloatProperty::New(2.0));
585  node->AddProperty("planarfigure.outline.width", mitk::FloatProperty::New(2.0));
586  node->AddProperty("planarfigure.helperline.width", mitk::FloatProperty::New(1.0));
587 
588  node->AddProperty("planarfigure.default.line.opacity", mitk::FloatProperty::New(1.0));
589  node->AddProperty("planarfigure.default.outline.opacity", mitk::FloatProperty::New(1.0));
590  node->AddProperty("planarfigure.default.helperline.opacity", mitk::FloatProperty::New(1.0));
591  node->AddProperty("planarfigure.default.markerline.color", mitk::ColorProperty::New(1.0, 1.0, 1.0));
592  node->AddProperty("planarfigure.default.markerline.opacity", mitk::FloatProperty::New(1.0));
593  node->AddProperty("planarfigure.default.marker.color", mitk::ColorProperty::New(1.0, 1.0, 1.0));
594  node->AddProperty("planarfigure.default.marker.opacity", mitk::FloatProperty::New(1.0));
595 
596  node->AddProperty("planarfigure.hover.line.color", mitk::ColorProperty::New(0.0, 1.0, 0.0));
597  node->AddProperty("planarfigure.hover.line.opacity", mitk::FloatProperty::New(1.0));
598  node->AddProperty("planarfigure.hover.outline.color", mitk::ColorProperty::New(0.0, 1.0, 0.0));
599  node->AddProperty("planarfigure.hover.outline.opacity", mitk::FloatProperty::New(1.0));
600  node->AddProperty("planarfigure.hover.helperline.color", mitk::ColorProperty::New(0.0, 1.0, 0.0));
601  node->AddProperty("planarfigure.hover.helperline.opacity", mitk::FloatProperty::New(1.0));
602  node->AddProperty("planarfigure.hover.markerline.color", mitk::ColorProperty::New(0.0, 1.0, 0.0));
603  node->AddProperty("planarfigure.hover.markerline.opacity", mitk::FloatProperty::New(1.0));
604  node->AddProperty("planarfigure.hover.marker.color", mitk::ColorProperty::New(0.0, 1.0, 0.0));
605  node->AddProperty("planarfigure.hover.marker.opacity", mitk::FloatProperty::New(1.0));
606 
607  node->AddProperty("planarfigure.selected.line.color", mitk::ColorProperty::New(1.0, 0.0, 0.0));
608  node->AddProperty("planarfigure.selected.line.opacity", mitk::FloatProperty::New(1.0));
609  node->AddProperty("planarfigure.selected.outline.color", mitk::ColorProperty::New(1.0, 0.0, 0.0));
610  node->AddProperty("planarfigure.selected.outline.opacity", mitk::FloatProperty::New(1.0));
611  node->AddProperty("planarfigure.selected.helperline.color", mitk::ColorProperty::New(1.0, 0.0, 0.0));
612  node->AddProperty("planarfigure.selected.helperline.opacity", mitk::FloatProperty::New(1.0));
613  node->AddProperty("planarfigure.selected.markerline.color", mitk::ColorProperty::New(1.0, 0.0, 0.0));
614  node->AddProperty("planarfigure.selected.markerline.opacity", mitk::FloatProperty::New(1.0));
615  node->AddProperty("planarfigure.selected.marker.color", mitk::ColorProperty::New(1.0, 0.0, 0.0));
616  node->AddProperty("planarfigure.selected.marker.opacity", mitk::FloatProperty::New(1.0));
617 }
618 
620  const PlanarFigureDisplayMode lineDisplayMode,
621  const mitk::PlaneGeometry *planarFigurePlaneGeometry,
622  const mitk::PlaneGeometry *rendererPlaneGeometry,
623  mitk::BaseRenderer *renderer)
624 {
625  bool isEditable = true;
626  m_DataNode->GetBoolProperty("planarfigure.iseditable", isEditable);
627 
628  PlanarFigureDisplayMode pointDisplayMode = PF_DEFAULT;
629 
630  const unsigned int selectedControlPointsIdx = (unsigned int)planarFigure->GetSelectedControlPoint();
631  const unsigned int numberOfControlPoints = planarFigure->GetNumberOfControlPoints();
632  // Draw markers at control points (selected control point will be colored)
633  for (unsigned int i = 0; i < numberOfControlPoints; ++i)
634  {
635  // Only if planar figure is marked as editable: display markers (control points) in a
636  // different style if mouse is over them or they are selected
637  if (isEditable)
638  {
639  if (i == selectedControlPointsIdx)
640  {
641  pointDisplayMode = PF_SELECTED;
642  }
643  else if (m_IsHovering && isEditable)
644  {
645  pointDisplayMode = PF_HOVER;
646  }
647  }
648 
649  if (m_MarkerOpacity[pointDisplayMode] == 0 && m_MarkerlineOpacity[pointDisplayMode] == 0)
650  {
651  continue;
652  }
653 
654  if (m_DrawOutline)
655  {
656  // draw outlines for markers as well
657  // linewidth for the contour is only half, as full width looks
658  // much too thick!
659  this->DrawMarker(planarFigure->GetControlPoint(i),
660  m_OutlineColor[lineDisplayMode],
661  m_MarkerlineOpacity[pointDisplayMode],
662  m_OutlineColor[lineDisplayMode],
663  m_MarkerOpacity[pointDisplayMode],
664  m_OutlineWidth / 2,
665  m_ControlPointShape,
666  planarFigurePlaneGeometry,
667  rendererPlaneGeometry,
668  renderer);
669  }
670 
671  this->DrawMarker(planarFigure->GetControlPoint(i),
672  m_MarkerlineColor[pointDisplayMode],
673  m_MarkerlineOpacity[pointDisplayMode],
674  m_MarkerColor[pointDisplayMode],
675  m_MarkerOpacity[pointDisplayMode],
676  m_LineWidth,
677  m_ControlPointShape,
678  planarFigurePlaneGeometry,
679  rendererPlaneGeometry,
680  renderer);
681  }
682 
683  if (planarFigure->IsPreviewControlPointVisible())
684  {
685  this->DrawMarker(planarFigure->GetPreviewControlPoint(),
686  m_MarkerlineColor[PF_HOVER],
687  m_MarkerlineOpacity[PF_HOVER],
688  m_MarkerColor[PF_HOVER],
689  m_MarkerOpacity[PF_HOVER],
690  m_LineWidth,
691  m_ControlPointShape,
692  planarFigurePlaneGeometry,
693  rendererPlaneGeometry,
694  renderer);
695  }
696 }
697 
699  const std::string name,
700  const mitk::Point2D anchorPoint,
701  float globalOpacity,
702  const PlanarFigureDisplayMode lineDisplayMode,
703  double &annotationOffset)
704 {
705  if (anchorPoint[0] < mitk::eps || anchorPoint[1] < mitk::eps)
706  {
707  return;
708  }
709 
710  m_AnnotationOverlay->SetText(name);
711  m_AnnotationOverlay->SetColor(m_AnnotationColor[lineDisplayMode][0],
712  m_AnnotationColor[lineDisplayMode][1],
713  m_AnnotationColor[lineDisplayMode][2]);
714  m_AnnotationOverlay->SetOpacity(globalOpacity);
715  m_AnnotationOverlay->SetFontSize(m_AnnotationSize * m_DevicePixelRatio);
716  m_AnnotationOverlay->SetBoolProperty("drawShadow", m_AnnotationsShadow);
717  m_AnnotationOverlay->SetVisibility(true, renderer);
718  m_AnnotationOverlay->SetStringProperty("font.family", m_AnnotationFontFamily);
719  m_AnnotationOverlay->SetBoolProperty("font.bold", m_DrawAnnotationBold);
720  m_AnnotationOverlay->SetBoolProperty("font.italic", m_DrawAnnotationItalic);
721 
723  offset.Fill(5);
724 
725  mitk::Point2D scaledAnchorPoint;
726  scaledAnchorPoint[0] = anchorPoint[0] * m_DevicePixelRatio;
727  scaledAnchorPoint[1] = anchorPoint[1] * m_DevicePixelRatio;
728 
729  offset[0] = offset[0] * m_DevicePixelRatio;
730  offset[1] = offset[1] * m_DevicePixelRatio;
731 
732  m_AnnotationOverlay->SetPosition2D(scaledAnchorPoint);
733  m_AnnotationOverlay->SetOffsetVector(offset);
734 
735  m_AnnotationOverlay->Update(renderer);
736  m_AnnotationOverlay->Paint(renderer);
737  annotationOffset -= 15.0;
738  // annotationOffset -= m_AnnotationOverlay->GetBoundsOnDisplay( renderer ).Size[1];
739 }
740 
742  mitk::BaseRenderer *renderer,
743  const mitk::Point2D anchorPoint,
744  double &annotationOffset,
745  float globalOpacity,
746  const PlanarFigureDisplayMode lineDisplayMode)
747 {
748  if (anchorPoint[0] < mitk::eps || anchorPoint[1] < mitk::eps)
749  {
750  return;
751  }
752 
753  std::stringstream quantityString;
754  quantityString.setf(ios::fixed, ios::floatfield);
755  quantityString.precision(1);
756 
757  bool firstActiveFeature = true;
758  for (unsigned int i = 0; i < planarFigure->GetNumberOfFeatures(); ++i)
759  {
760  if (planarFigure->IsFeatureActive(i) && planarFigure->IsFeatureVisible(i))
761  {
762  if (!firstActiveFeature)
763  {
764  quantityString << " x ";
765  }
766  quantityString << planarFigure->GetQuantity(i) << " ";
767  quantityString << planarFigure->GetFeatureUnit(i);
768  firstActiveFeature = false;
769  }
770  }
771 
772  m_QuantityOverlay->SetColor(m_AnnotationColor[lineDisplayMode][0],
773  m_AnnotationColor[lineDisplayMode][1],
774  m_AnnotationColor[lineDisplayMode][2]);
775 
776  m_QuantityOverlay->SetOpacity(globalOpacity);
777  m_QuantityOverlay->SetFontSize(m_AnnotationSize * m_DevicePixelRatio);
778  m_QuantityOverlay->SetBoolProperty("drawShadow", m_DrawShadow);
779  m_QuantityOverlay->SetVisibility(true, renderer);
780 
781  m_AnnotationOverlay->SetStringProperty("font.family", m_AnnotationFontFamily);
782  m_AnnotationOverlay->SetBoolProperty("font.bold", m_DrawAnnotationBold);
783  m_AnnotationOverlay->SetBoolProperty("font.italic", m_DrawAnnotationItalic);
784 
785  m_QuantityOverlay->SetText(quantityString.str().c_str());
787  offset.Fill(5);
788  offset[1] += annotationOffset;
789 
790  mitk::Point2D scaledAnchorPoint;
791  scaledAnchorPoint[0] = anchorPoint[0] * m_DevicePixelRatio;
792  scaledAnchorPoint[1] = anchorPoint[1] * m_DevicePixelRatio;
793 
794  offset[0] = offset[0] * m_DevicePixelRatio;
795  offset[1] = offset[1] * m_DevicePixelRatio;
796 
797  m_QuantityOverlay->SetPosition2D(scaledAnchorPoint);
798  m_QuantityOverlay->SetOffsetVector(offset);
799 
800  m_QuantityOverlay->Update(renderer);
801  m_QuantityOverlay->Paint(renderer);
802  // annotationOffset -= m_QuantityOverlay->GetBoundsOnDisplay( renderer ).Size[1];
803  annotationOffset -= 15.0;
804 }
805 
807  mitk::PlanarFigure *planarFigure,
808  mitk::Point2D &anchorPoint,
809  const mitk::PlaneGeometry *planarFigurePlaneGeometry,
810  const mitk::PlaneGeometry *rendererPlaneGeometry,
811  const mitk::BaseRenderer *renderer)
812 {
813  glLineStipple(1, 0x00FF);
814 
815  // If we want to draw an outline, we do it here
816  if (m_DrawOutline)
817  {
818  const float *color = m_OutlineColor[lineDisplayMode];
819  const float opacity = m_OutlineOpacity[lineDisplayMode];
820 
821  // convert to a float array that also contains opacity, faster GL
822  float *colorVector = new float[4];
823  colorVector[0] = color[0];
824  colorVector[1] = color[1];
825  colorVector[2] = color[2];
826  colorVector[3] = opacity;
827 
828  // set the color and opacity here as it is common for all outlines
829  glColor4fv(colorVector);
830  glLineWidth(m_OutlineWidth);
831 
832  if (m_DrawDashed)
833  glEnable(GL_LINE_STIPPLE);
834  else
835  glDisable(GL_LINE_STIPPLE);
836 
837  // Draw the outline for all polylines if requested
838  this->DrawMainLines(planarFigure, anchorPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer);
839 
840  glLineWidth(m_HelperlineWidth);
841 
842  if (m_DrawHelperDashed)
843  glEnable(GL_LINE_STIPPLE);
844  else
845  glDisable(GL_LINE_STIPPLE);
846 
847  // Draw the outline for all helper objects if requested
848  this->DrawHelperLines(planarFigure, anchorPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer);
849 
850  // cleanup
851  delete[] colorVector;
852  }
853 
854  // If we want to draw a shadow, we do it here
855  if (m_DrawShadow)
856  {
857  // determine the shadow opacity
858  const float opacity = m_OutlineOpacity[lineDisplayMode];
859  float shadowOpacity = 0.0f;
860  if (opacity > 0.2f)
861  shadowOpacity = opacity - 0.2f;
862 
863  // convert to a float array that also contains opacity, faster GL
864  float *shadow = new float[4];
865  shadow[0] = 0;
866  shadow[1] = 0;
867  shadow[2] = 0;
868  shadow[3] = shadowOpacity;
869 
870  // set the color and opacity here as it is common for all shadows
871  glColor4fv(shadow);
872  glLineWidth(m_OutlineWidth * m_ShadowWidthFactor);
873 
874  if (m_DrawDashed)
875  glEnable(GL_LINE_STIPPLE);
876  else
877  glDisable(GL_LINE_STIPPLE);
878 
879  // Draw the outline for all polylines if requested
880  this->DrawMainLines(planarFigure, anchorPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer);
881 
882  glLineWidth(m_HelperlineWidth);
883 
884  if (m_DrawHelperDashed)
885  glEnable(GL_LINE_STIPPLE);
886  else
887  glDisable(GL_LINE_STIPPLE);
888 
889  // Draw the outline for all helper objects if requested
890  this->DrawHelperLines(planarFigure, anchorPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer);
891 
892  // cleanup
893  delete[] shadow;
894  }
895 
896  // set this in brackets to avoid duplicate variables in the same scope
897  {
898  const float *color = m_LineColor[lineDisplayMode];
899  const float opacity = m_LineOpacity[lineDisplayMode];
900 
901  // convert to a float array that also contains opacity, faster GL
902  float *colorVector = new float[4];
903  colorVector[0] = color[0];
904  colorVector[1] = color[1];
905  colorVector[2] = color[2];
906  colorVector[3] = opacity;
907 
908  // set the color and opacity here as it is common for all mainlines
909  glColor4fv(colorVector);
910  glLineWidth(m_LineWidth);
911 
912  if (m_DrawDashed)
913  glEnable(GL_LINE_STIPPLE);
914  else
915  glDisable(GL_LINE_STIPPLE);
916 
917  // Draw the main line for all polylines
918  this->DrawMainLines(planarFigure, anchorPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer);
919 
920  const float *helperColor = m_HelperlineColor[lineDisplayMode];
921  const float helperOpacity = m_HelperlineOpacity[lineDisplayMode];
922  // convert to a float array that also contains opacity, faster GL
923  float *helperColorVector = new float[4];
924  helperColorVector[0] = helperColor[0];
925  helperColorVector[1] = helperColor[1];
926  helperColorVector[2] = helperColor[2];
927  helperColorVector[3] = helperOpacity;
928 
929  // we only set the color for the helperlines as the linewidth is unchanged
930  glColor4fv(helperColorVector);
931 
932  glLineWidth(m_HelperlineWidth);
933 
934  if (m_DrawHelperDashed)
935  glEnable(GL_LINE_STIPPLE);
936  else
937  glDisable(GL_LINE_STIPPLE);
938 
939  // Draw helper objects
940  this->DrawHelperLines(planarFigure, anchorPoint, planarFigurePlaneGeometry, rendererPlaneGeometry, renderer);
941 
942  // cleanup
943  delete[] colorVector;
944  delete[] helperColorVector;
945  }
946 
947  if (m_DrawDashed || m_DrawHelperDashed)
948  glDisable(GL_LINE_STIPPLE);
949 }
virtual bool IsHelperToBePainted(unsigned int index) const
Returns whether a helper polyline should be painted or not.
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)
void PaintPolyLine(const mitk::PlanarFigure::PolyLineType vertices, bool closed, Point2D &anchorPoint, const PlaneGeometry *planarFigurePlaneGeometry, const PlaneGeometry *rendererPlaneGeometry, const mitk::BaseRenderer *renderer)
Actually paints the polyline defined by the figure.
itk::SmartPointer< Self > Pointer
double GetScaleFactorMMPerDisplayUnit() const
bool IsFeatureActive(unsigned int index) const
Returns true if the feature with the specified index exists and is active (an inactive feature may e...
void RenderLines(const PlanarFigureDisplayMode lineDisplayMode, mitk::PlanarFigure *planarFigure, mitk::Point2D &anchorPoint, const mitk::PlaneGeometry *planarFigurePlaneGeometry, const mitk::PlaneGeometry *rendererPlaneGeometry, const mitk::BaseRenderer *renderer)
Renders all the lines defined by the PlanarFigure.
bool IsFeatureVisible(unsigned int index) const
Returns true if the feature with the specified index exists and is set visible.
virtual bool Map(const mitk::Point3D &pt3d_mm, mitk::Point2D &pt2d_mm) const
Project a 3D point given in mm (pt3d_mm) onto the 2D geometry. The result is a 2D point in mm (pt2d_m...
void RenderQuantities(const mitk::PlanarFigure *planarFigure, mitk::BaseRenderer *renderer, const mitk::Point2D anchorPoint, double &annotationOffset, float globalOpacity, const PlanarFigureDisplayMode lineDisplayMode)
Renders the quantities of the figure below the text annotations.
#define MITK_ERROR
Definition: mitkLogMacros.h:24
bool GetIntProperty(const char *propertyKey, int &intValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for int properties (instances of IntProperty)
virtual int GetSelectedControlPoint() const
Return currently selected control point.
static Pointer New()
Organizes the rendering process.
bool GetName(std::string &nodeName, const mitk::BaseRenderer *renderer=nullptr, const char *propertyKey="name") const
Convenience access method for accessing the name of an object (instance of StringProperty with proper...
Definition: mitkDataNode.h:366
bool GetBoolProperty(const char *propertyKey, bool &boolValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for bool properties (instances of BoolProperty)
virtual unsigned int GetNumberOfFeatures() const
Returns the number of features available for this PlanarFigure (such as, radius, area, ...).
virtual unsigned short GetHelperPolyLinesSize() const
Returns the current number of helperpolylines.
virtual const PlaneGeometry * GetPlaneGeometry() const
Returns (previously set) 2D geometry of this figure.
virtual const PlaneGeometry * GetCurrentWorldPlaneGeometry()
Get the current 2D-worldgeometry (m_CurrentWorldPlaneGeometry) used for 2D-rendering.
double GetQuantity(unsigned int index) const
void RenderControlPoints(const mitk::PlanarFigure *planarFigure, const PlanarFigureDisplayMode lineDisplayMode, const mitk::PlaneGeometry *planarFigurePlaneGeometry, const mitk::PlaneGeometry *rendererPlaneGeometry, mitk::BaseRenderer *renderer)
Renders the control-points.
mitk::BaseProperty * GetProperty(const char *propertyKey, const mitk::BaseRenderer *renderer=nullptr) const
Get the property (instance of BaseProperty) with key propertyKey from the PropertyList of the rendere...
Point2D GetPreviewControlPoint() const
Returns the coordinates of the PreviewControlPoint.
const PolyLineType GetPolyLine(unsigned int index)
Returns the polyline representing the planar figure (for rendering, measurements, etc...
Defines the rendering style of control points for PlanarFigure objects.
ScalarType DistanceFromPlane(const Point3D &pt3d_mm) const
Distance of the point from the plane (bounding-box not considered)
bool GetStringProperty(const char *propertyKey, std::string &string, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for string properties (instances of StringProperty)
static Pointer New()
static Vector3D offset
void DrawMainLines(mitk::PlanarFigure *figure, Point2D &anchorPoint, const PlaneGeometry *planarFigurePlaneGeometry, const PlaneGeometry *rendererPlaneGeometry, const mitk::BaseRenderer *renderer)
Internally used by RenderLines() to draw the mainlines using PaintPolyLine().
void OnNodeModified()
Callback that sets m_NodeModified to true.
void WorldToDisplay(const Point3D &worldIndex, Point2D &displayPoint) const
This method converts a 3D world index to the display point using the geometry of the renderWindow...
void AddProperty(const char *propertyKey, BaseProperty *property, const mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
Add the property (instance of BaseProperty) if it does not exist (or always ifoverwrite istrue) with ...
bool IsParallel(const PlaneGeometry *plane) const
Returns whether the plane is parallel to another plane.
virtual bool IsClosed() const
True if the planar figure is closed.
bool GetFloatProperty(const char *propertyKey, float &floatValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for float properties (instances of FloatProperty)
virtual unsigned short GetPolyLinesSize()
Returns the current number of polylines.
void InitializePlanarFigurePropertiesFromDataNode(const mitk::DataNode *node)
void RenderAnnotations(mitk::BaseRenderer *renderer, const std::string name, const mitk::Point2D anchorPoint, float globalOpacity, const PlanarFigureDisplayMode lineDisplayMode, double &annotationOffset)
Renders the text annotations.
void DrawHelperLines(mitk::PlanarFigure *figure, Point2D &anchorPoint, const PlaneGeometry *planarFigurePlaneGeometry, const PlaneGeometry *rendererPlaneGeometry, const mitk::BaseRenderer *renderer)
Internally used by RenderLines() to draw the helperlines using PaintPolyLine().
const PolyLineType GetHelperPolyLine(unsigned int index, double mmPerDisplayUnit, unsigned int displayHeight)
Returns the polyline that should be drawn the same size at every scale (for text, angles...
virtual int * GetViewportSize() const
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
bool IsPreviewControlPointVisible() const
Returns whether or not the PreviewControlPoint is visible.
static Pointer New()
static T min(T x, T y)
Definition: svm.cpp:67
const char * GetFeatureUnit(unsigned int index) const
Returns the physical unit of the specified features.
static Pointer New()
Base-class for geometric planar (2D) figures, such as lines, circles, rectangles, polygons...
static Pointer New()
static const float PLANAR_OFFSET
Point2D GetControlPoint(unsigned int index) const
Returns specified control point in 2D world coordinates.
MITKCORE_EXPORT const ScalarType eps
std::vector< PolyLineElement > PolyLineType
void TransformObjectToDisplay(const mitk::Point2D &point2D, mitk::Point2D &displayPoint, const mitk::PlaneGeometry *objectGeometry, const mitk::PlaneGeometry *, const mitk::BaseRenderer *renderer)
Describes a two-dimensional, rectangular plane.
virtual bool IsPlaced() const
True if the planar figure has been placed (and can be displayed/interacted with). ...
ScalarType GetExtentInMM(int direction) const
Get the extent of the bounding-box in the specified direction in mm.
bool GetColor(float rgb[3], const mitk::BaseRenderer *renderer=nullptr, const char *propertyKey="color") const
Convenience access method for color properties (instances of ColorProperty)
unsigned int GetNumberOfControlPoints() const
Returns the current number of 2D control points defining this figure.
static Pointer New()
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66
virtual void Paint(BaseRenderer *renderer) override
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.