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