Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
mitkPointSetVtkMapper3D.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 #include "mitkColorProperty.h"
15 #include "mitkDataNode.h"
16 #include "mitkPointSet.h"
17 #include "mitkProperties.h"
18 #include "mitkVtkPropRenderer.h"
19 
20 #include <vtkActor.h>
21 #include <vtkAppendPolyData.h>
22 #include <vtkCellArray.h>
23 #include <vtkConeSource.h>
24 #include <vtkCubeSource.h>
25 #include <vtkCylinderSource.h>
26 #include <vtkPolyDataAlgorithm.h>
27 #include <vtkPolyDataMapper.h>
28 #include <vtkPropAssembly.h>
29 #include <vtkProperty.h>
30 #include <vtkRenderer.h>
31 #include <vtkSphereSource.h>
32 #include <vtkTransform.h>
33 #include <vtkTransformPolyDataFilter.h>
34 #include <vtkTubeFilter.h>
35 #include <vtkVectorText.h>
36 
37 #include <cstdlib>
38 
39 #include <mitkPropertyObserver.h>
40 #include <vtk_glew.h>
41 
43 {
44  return static_cast<const mitk::PointSet *>(GetDataNode()->GetData());
45 }
46 
48  : m_vtkSelectedPointList(nullptr),
49  m_vtkUnselectedPointList(nullptr),
52  m_vtkTextList(nullptr),
55  m_PointSize(1.0),
56  m_ContourRadius(0.5)
57 {
58  // propassembly
59  m_PointsAssembly = vtkSmartPointer<vtkPropAssembly>::New();
60 
61  // creating actors to be able to set transform
62  m_SelectedActor = vtkSmartPointer<vtkActor>::New();
63  m_UnselectedActor = vtkSmartPointer<vtkActor>::New();
64  m_ContourActor = vtkSmartPointer<vtkActor>::New();
65 }
66 
68 {
69 }
70 
72 {
73  m_PointsAssembly->ReleaseGraphicsResources(renWin);
74 
75  m_SelectedActor->ReleaseGraphicsResources(renWin);
76  m_UnselectedActor->ReleaseGraphicsResources(renWin);
77  m_ContourActor->ReleaseGraphicsResources(renWin);
78 }
79 
81 {
82  m_PointsAssembly->ReleaseGraphicsResources(renderer->GetRenderWindow());
83 
84  m_SelectedActor->ReleaseGraphicsResources(renderer->GetRenderWindow());
85  m_UnselectedActor->ReleaseGraphicsResources(renderer->GetRenderWindow());
86  m_ContourActor->ReleaseGraphicsResources(renderer->GetRenderWindow());
87 }
88 
90 {
91  m_vtkSelectedPointList = vtkSmartPointer<vtkAppendPolyData>::New();
92  m_vtkUnselectedPointList = vtkSmartPointer<vtkAppendPolyData>::New();
93 
94  m_PointsAssembly->VisibilityOn();
95 
96  if (m_PointsAssembly->GetParts()->IsItemPresent(m_SelectedActor))
97  m_PointsAssembly->RemovePart(m_SelectedActor);
98  if (m_PointsAssembly->GetParts()->IsItemPresent(m_UnselectedActor))
100  if (m_PointsAssembly->GetParts()->IsItemPresent(m_ContourActor))
101  m_PointsAssembly->RemovePart(m_ContourActor);
102 
103  // exceptional displaying for PositionTracker -> MouseOrientationTool
104  int mapperID;
105  bool isInputDevice = false;
106  if (this->GetDataNode()->GetBoolProperty("inputdevice", isInputDevice) && isInputDevice)
107  {
108  if (this->GetDataNode()->GetIntProperty("BaseRendererMapperID", mapperID) && mapperID == BaseRenderer::Standard3D)
109  return; // The event for the PositionTracker came from the 3d widget and not needs to be displayed
110  }
111 
112  // get and update the PointSet
113  mitk::PointSet::Pointer input = const_cast<mitk::PointSet *>(this->GetInput());
114 
115  /* only update the input data, if the property tells us to */
116  bool update = true;
117  this->GetDataNode()->GetBoolProperty("updateDataOnRender", update);
118  if (update == true)
119  input->Update();
120 
121  int timestep = this->GetTimestep();
122 
123  mitk::PointSet::DataType::Pointer itkPointSet = input->GetPointSet(timestep);
124 
125  if (itkPointSet.GetPointer() == nullptr)
126  {
127  m_PointsAssembly->VisibilityOff();
128  return;
129  }
130 
131  // now fill selected and unselected pointList
132  // get size of Points in Property
133  m_PointSize = 2;
134  mitk::FloatProperty::Pointer pointSizeProp =
135  dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetProperty("pointsize"));
136  if (pointSizeProp.IsNotNull())
137  m_PointSize = pointSizeProp->GetValue();
138 
139  // get the property for creating a label onto every point only once
140  bool showLabel = true;
141  this->GetDataNode()->GetBoolProperty("show label", showLabel);
142  const char *pointLabel = nullptr;
143  if (showLabel)
144  {
145  if (dynamic_cast<mitk::StringProperty *>(this->GetDataNode()->GetPropertyList()->GetProperty("label")) != nullptr)
146  pointLabel =
147  dynamic_cast<mitk::StringProperty *>(this->GetDataNode()->GetPropertyList()->GetProperty("label"))->GetValue();
148  else
149  showLabel = false;
150  }
151 
152  // whether or not to creat a "contour" - connecting lines between all the points
153  int nbPoints = itkPointSet->GetPointData()->Size();
154  bool makeContour = false;
155  this->GetDataNode()->GetBoolProperty("show contour", makeContour);
156 
157  bool closeContour = false;
158  this->GetDataNode()->GetBoolProperty("close contour", closeContour);
159  int contourPointLimit = 0; // NO contour
160  if (makeContour)
161  {
162  if (closeContour)
163  contourPointLimit = nbPoints;
164  else
165  contourPointLimit = nbPoints - 1;
166  }
167 
168  // build list of all positions for later transform in one go
169  mitk::PointSet::PointsContainer::Iterator pointsIter;
170  int ptIdx;
171 
174  vtkSmartPointer<vtkPoints> localPoints = vtkSmartPointer<vtkPoints>::New();
175  m_WorldPositions = vtkSmartPointer<vtkPoints>::New();
176  m_PointConnections = vtkSmartPointer<vtkCellArray>::New(); // m_PointConnections between points
177  for (ptIdx = 0, pointsIter = itkPointSet->GetPoints()->Begin(); pointsIter != itkPointSet->GetPoints()->End();
178  pointsIter++, ptIdx++)
179  {
180  itk::Point<float> currentPoint = pointsIter->Value();
181  localPoints->InsertPoint(ptIdx, currentPoint[0], currentPoint[1], currentPoint[2]);
182 
183  if (makeContour && ptIdx < contourPointLimit)
184  {
185  vtkIdType cell[2] = {(ptIdx + 1) % nbPoints, ptIdx};
186  m_PointConnections->InsertNextCell(2, cell);
187  }
188  }
189 
190  vtkSmartPointer<vtkLinearTransform> vtktransform = this->GetDataNode()->GetVtkTransform(this->GetTimestep());
191  vtktransform->TransformPoints(localPoints, m_WorldPositions);
192 
193  // create contour
194  if (makeContour)
195  {
197  }
198 
199  // check if the list for the PointDataContainer is the same size as the PointsContainer. Is not, then the points were
200  // inserted manually and can not be visualized according to the PointData (selected/unselected)
201  bool pointDataBroken = (itkPointSet->GetPointData()->Size() != itkPointSet->GetPoints()->Size());
202 
203  // now add an object for each point in data
204  mitk::PointSet::PointDataContainer::Iterator pointDataIter = itkPointSet->GetPointData()->Begin();
205  for (ptIdx = 0; ptIdx < nbPoints; ++ptIdx) // pointDataIter moved at end of loop
206  {
207  double currentPoint[3];
208  m_WorldPositions->GetPoint(ptIdx, currentPoint);
209  vtkSmartPointer<vtkPolyDataAlgorithm> source;
210 
211  // check for the pointtype in data and decide which geom-object to take and then add to the selected or unselected
212  // list
213  int pointType;
214  if (itkPointSet->GetPointData()->size() == 0 || pointDataBroken)
215  pointType = mitk::PTUNDEFINED;
216  else
217  pointType = pointDataIter.Value().pointSpec;
218 
219  switch (pointType)
220  {
221  case mitk::PTUNDEFINED:
222  {
223  vtkSmartPointer<vtkSphereSource> sphere = vtkSmartPointer<vtkSphereSource>::New();
224  sphere->SetRadius(m_PointSize / 2.0f);
225  sphere->SetCenter(currentPoint);
226  // sphere->SetCenter(pointsIter.Value()[0],pointsIter.Value()[1],pointsIter.Value()[2]);
227 
228  // MouseOrientation Tool (PositionTracker)
229  if (isInputDevice)
230  {
231  sphere->SetThetaResolution(10);
232  sphere->SetPhiResolution(10);
233  }
234  else
235  {
236  sphere->SetThetaResolution(20);
237  sphere->SetPhiResolution(20);
238  }
239  source = sphere;
240  }
241  break;
242  case mitk::PTSTART:
243  {
244  vtkSmartPointer<vtkCubeSource> cube = vtkSmartPointer<vtkCubeSource>::New();
245  cube->SetXLength(m_PointSize / 2);
246  cube->SetYLength(m_PointSize / 2);
247  cube->SetZLength(m_PointSize / 2);
248  cube->SetCenter(currentPoint);
249  source = cube;
250  }
251  break;
252  case mitk::PTCORNER:
253  {
254  vtkSmartPointer<vtkConeSource> cone = vtkSmartPointer<vtkConeSource>::New();
255  cone->SetRadius(m_PointSize / 2.0f);
256  cone->SetCenter(currentPoint);
257  cone->SetResolution(20);
258  source = cone;
259  }
260  break;
261  case mitk::PTEDGE:
262  {
263  vtkSmartPointer<vtkCylinderSource> cylinder = vtkSmartPointer<vtkCylinderSource>::New();
264  cylinder->SetRadius(m_PointSize / 2.0f);
265  cylinder->SetCenter(currentPoint);
266  cylinder->SetResolution(20);
267  source = cylinder;
268  }
269  break;
270  case mitk::PTEND:
271  {
272  vtkSmartPointer<vtkSphereSource> sphere = vtkSmartPointer<vtkSphereSource>::New();
273  sphere->SetRadius(m_PointSize / 2.0f);
274  // no SetCenter?? this functionality should be explained!
275  // otherwise: join with default block!
276  sphere->SetThetaResolution(20);
277  sphere->SetPhiResolution(20);
278  source = sphere;
279  }
280  break;
281  default:
282  {
283  vtkSmartPointer<vtkSphereSource> sphere = vtkSmartPointer<vtkSphereSource>::New();
284  sphere->SetRadius(m_PointSize / 2.0f);
285  sphere->SetCenter(currentPoint);
286  sphere->SetThetaResolution(20);
287  sphere->SetPhiResolution(20);
288  source = sphere;
289  }
290  break;
291  }
292 
293  if (pointDataIter.Value().selected && !pointDataBroken)
294  {
295  m_vtkSelectedPointList->AddInputConnection(source->GetOutputPort());
297  }
298  else
299  {
300  m_vtkUnselectedPointList->AddInputConnection(source->GetOutputPort());
302  }
303  if (showLabel)
304  {
305  char buffer[20];
306  std::string l = pointLabel;
307  if (input->GetSize() > 1)
308  {
309  sprintf(buffer, "%d", ptIdx + 1);
310  l.append(buffer);
311  }
312  // Define the text for the label
313  vtkSmartPointer<vtkVectorText> label = vtkSmartPointer<vtkVectorText>::New();
314  label->SetText(l.c_str());
315 
316  //# Set up a transform to move the label to a new position.
317  vtkSmartPointer<vtkTransform> aLabelTransform = vtkSmartPointer<vtkTransform>::New();
318  aLabelTransform->Identity();
319  aLabelTransform->Translate(currentPoint[0] + 2, currentPoint[1] + 2, currentPoint[2]);
320  aLabelTransform->Scale(5.7, 5.7, 5.7);
321 
322  //# Move the label to a new position.
323  vtkSmartPointer<vtkTransformPolyDataFilter> labelTransform = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
324  labelTransform->SetTransform(aLabelTransform);
325  labelTransform->SetInputConnection(label->GetOutputPort());
326 
327  // add it to the wright PointList
328  if (pointType)
329  {
330  m_vtkSelectedPointList->AddInputConnection(labelTransform->GetOutputPort());
332  }
333  else
334  {
335  m_vtkUnselectedPointList->AddInputConnection(labelTransform->GetOutputPort());
337  }
338  }
339 
340  if (pointDataIter != itkPointSet->GetPointData()->End())
341  pointDataIter++;
342  } // end FOR
343 
344  // now according to number of elements added to selected or unselected, build up the rendering pipeline
345  if (m_NumberOfSelectedAdded > 0)
346  {
347  m_VtkSelectedPolyDataMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
348  m_VtkSelectedPolyDataMapper->SetInputConnection(m_vtkSelectedPointList->GetOutputPort());
349 
350  // create a new instance of the actor
351  m_SelectedActor = vtkSmartPointer<vtkActor>::New();
352 
355  }
356 
358  {
359  m_VtkUnselectedPolyDataMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
360  m_VtkUnselectedPolyDataMapper->SetInputConnection(m_vtkUnselectedPointList->GetOutputPort());
361 
362  // create a new instance of the actor
363  m_UnselectedActor = vtkSmartPointer<vtkActor>::New();
364 
367  }
368 }
369 
371 {
372  bool visible = true;
373  GetDataNode()->GetVisibility(visible, renderer, "visible");
374  if (!visible)
375  {
376  m_UnselectedActor->VisibilityOff();
377  m_SelectedActor->VisibilityOff();
378  m_ContourActor->VisibilityOff();
379  return;
380  }
381 
382  // create new vtk render objects (e.g. sphere for a point)
384  bool needGenerateData = ls->IsGenerateDataRequired(renderer, this, GetDataNode());
385 
386  if (!needGenerateData)
387  {
388  if (this->GetDataNode()->GetPropertyList()->GetMTime() > ls->GetLastGenerateDataTime() ||
389  this->GetDataNode()->GetPropertyList(renderer)->GetMTime() > ls->GetLastGenerateDataTime())
390  {
391  needGenerateData = true;
392  }
393  }
394 
395  if (needGenerateData)
396  {
397  this->CreateVTKRenderObjects();
399  }
400 
401  this->ApplyAllProperties(renderer, m_ContourActor);
402 
403  bool showPoints = true;
404  this->GetDataNode()->GetBoolProperty("show points", showPoints);
405 
406  m_UnselectedActor->SetVisibility(showPoints);
407  m_SelectedActor->SetVisibility(showPoints);
408 
409  if (false && dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetProperty("opacity")) != nullptr)
410  {
411  mitk::FloatProperty::Pointer pointOpacity =
412  dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetProperty("opacity"));
413  float opacity = pointOpacity->GetValue();
414  m_ContourActor->GetProperty()->SetOpacity(opacity);
415  m_UnselectedActor->GetProperty()->SetOpacity(opacity);
416  m_SelectedActor->GetProperty()->SetOpacity(opacity);
417  }
418 
419  bool showContour = false;
420  this->GetDataNode()->GetBoolProperty("show contour", showContour);
421  m_ContourActor->SetVisibility(showContour);
422 }
423 
425 {
426  m_PointsAssembly->VisibilityOff();
427 }
428 
430 {
431  return m_PointsAssembly;
432 }
433 
435 {
436 }
437 
439 {
441  // check for color props and use it for rendering of selected/unselected points and contour
442  // due to different params in VTK (double/float) we have to convert!
443 
444  // vars to convert to
445  double unselectedColor[4] = {1.0f, 1.0f, 0.0f, 1.0f}; // yellow
446  double selectedColor[4] = {1.0f, 0.0f, 0.0f, 1.0f}; // red
447  double contourColor[4] = {1.0f, 0.0f, 0.0f, 1.0f}; // red
448 
449  // different types for color!!!
450  mitk::Color tmpColor;
451  double opacity = 1.0;
452 
453  // check if there is an unselected property
454  if (dynamic_cast<mitk::ColorProperty *>(
455  this->GetDataNode()->GetPropertyList(renderer)->GetProperty("unselectedcolor")) != nullptr)
456  {
457  tmpColor = dynamic_cast<mitk::ColorProperty *>(
458  this->GetDataNode()->GetPropertyList(renderer)->GetProperty("unselectedcolor"))
459  ->GetValue();
460  unselectedColor[0] = tmpColor[0];
461  unselectedColor[1] = tmpColor[1];
462  unselectedColor[2] = tmpColor[2];
463  unselectedColor[3] = 1.0f;
464  }
465  else if (dynamic_cast<mitk::ColorProperty *>(
466  this->GetDataNode()->GetPropertyList(nullptr)->GetProperty("unselectedcolor")) != nullptr)
467  {
468  tmpColor =
469  dynamic_cast<mitk::ColorProperty *>(this->GetDataNode()->GetPropertyList(nullptr)->GetProperty("unselectedcolor"))
470  ->GetValue();
471  unselectedColor[0] = tmpColor[0];
472  unselectedColor[1] = tmpColor[1];
473  unselectedColor[2] = tmpColor[2];
474  unselectedColor[3] = 1.0f;
475  }
476  else
477  {
478  // check if the node has a color
479  float unselectedColorTMP[4] = {1.0f, 1.0f, 0.0f, 1.0f}; // yellow
480  m_DataNode->GetColor(unselectedColorTMP, nullptr);
481  unselectedColor[0] = unselectedColorTMP[0];
482  unselectedColor[1] = unselectedColorTMP[1];
483  unselectedColor[2] = unselectedColorTMP[2];
484  // unselectedColor[3] stays 1.0f
485  }
486 
487  // get selected property
488  if (dynamic_cast<mitk::ColorProperty *>(
489  this->GetDataNode()->GetPropertyList(renderer)->GetProperty("selectedcolor")) != nullptr)
490  {
491  tmpColor =
492  dynamic_cast<mitk::ColorProperty *>(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("selectedcolor"))
493  ->GetValue();
494  selectedColor[0] = tmpColor[0];
495  selectedColor[1] = tmpColor[1];
496  selectedColor[2] = tmpColor[2];
497  selectedColor[3] = 1.0f;
498  }
499  else if (dynamic_cast<mitk::ColorProperty *>(
500  this->GetDataNode()->GetPropertyList(nullptr)->GetProperty("selectedcolor")) != nullptr)
501  {
502  tmpColor =
503  dynamic_cast<mitk::ColorProperty *>(this->GetDataNode()->GetPropertyList(nullptr)->GetProperty("selectedcolor"))
504  ->GetValue();
505  selectedColor[0] = tmpColor[0];
506  selectedColor[1] = tmpColor[1];
507  selectedColor[2] = tmpColor[2];
508  selectedColor[3] = 1.0f;
509  }
510 
511  // get contour property
512  if (dynamic_cast<mitk::ColorProperty *>(
513  this->GetDataNode()->GetPropertyList(renderer)->GetProperty("contourcolor")) != nullptr)
514  {
515  tmpColor =
516  dynamic_cast<mitk::ColorProperty *>(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("contourcolor"))
517  ->GetValue();
518  contourColor[0] = tmpColor[0];
519  contourColor[1] = tmpColor[1];
520  contourColor[2] = tmpColor[2];
521  contourColor[3] = 1.0f;
522  }
523  else if (dynamic_cast<mitk::ColorProperty *>(
524  this->GetDataNode()->GetPropertyList(nullptr)->GetProperty("contourcolor")) != nullptr)
525  {
526  tmpColor =
527  dynamic_cast<mitk::ColorProperty *>(this->GetDataNode()->GetPropertyList(nullptr)->GetProperty("contourcolor"))
528  ->GetValue();
529  contourColor[0] = tmpColor[0];
530  contourColor[1] = tmpColor[1];
531  contourColor[2] = tmpColor[2];
532  contourColor[3] = 1.0f;
533  }
534 
535  if (dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("opacity")) !=
536  nullptr)
537  {
538  mitk::FloatProperty::Pointer pointOpacity =
539  dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("opacity"));
540  opacity = pointOpacity->GetValue();
541  }
542  else if (dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetPropertyList(nullptr)->GetProperty("opacity")) !=
543  nullptr)
544  {
545  mitk::FloatProperty::Pointer pointOpacity =
546  dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetPropertyList(nullptr)->GetProperty("opacity"));
547  opacity = pointOpacity->GetValue();
548  }
549  // finished color / opacity fishing!
550 
551  // check if a contour shall be drawn
552  bool showContour = false;
553  this->GetDataNode()->GetBoolProperty("show contour", showContour, renderer);
554  if (showContour && (m_ContourActor != nullptr))
555  {
557  m_ContourActor->GetProperty()->SetColor(contourColor);
558  m_ContourActor->GetProperty()->SetOpacity(opacity);
559  }
560 
561  m_SelectedActor->GetProperty()->SetColor(selectedColor);
562  m_SelectedActor->GetProperty()->SetOpacity(opacity);
563 
564  m_UnselectedActor->GetProperty()->SetColor(unselectedColor);
565  m_UnselectedActor->GetProperty()->SetOpacity(opacity);
566 }
567 
568 void mitk::PointSetVtkMapper3D::CreateContour(vtkPoints *points, vtkCellArray *m_PointConnections)
569 {
570  vtkSmartPointer<vtkAppendPolyData> vtkContourPolyData = vtkSmartPointer<vtkAppendPolyData>::New();
571  vtkSmartPointer<vtkPolyDataMapper> vtkContourPolyDataMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
572 
573  vtkSmartPointer<vtkPolyData> contour = vtkSmartPointer<vtkPolyData>::New();
574  contour->SetPoints(points);
575  contour->SetLines(m_PointConnections);
576 
577  vtkSmartPointer<vtkTubeFilter> tubeFilter = vtkSmartPointer<vtkTubeFilter>::New();
578  tubeFilter->SetNumberOfSides(12);
579  tubeFilter->SetInputData(contour);
580 
581  // check for property contoursize.
582  m_ContourRadius = 0.5;
583  mitk::FloatProperty::Pointer contourSizeProp =
584  dynamic_cast<mitk::FloatProperty *>(this->GetDataNode()->GetProperty("contoursize"));
585 
586  if (contourSizeProp.IsNotNull())
587  m_ContourRadius = contourSizeProp->GetValue();
588 
589  tubeFilter->SetRadius(m_ContourRadius);
590  tubeFilter->Update();
591 
592  // add to pipeline
593  vtkContourPolyData->AddInputConnection(tubeFilter->GetOutputPort());
594  vtkContourPolyDataMapper->SetInputConnection(vtkContourPolyData->GetOutputPort());
595 
596  m_ContourActor->SetMapper(vtkContourPolyDataMapper);
598 }
599 
601 {
602  node->AddProperty("line width", mitk::IntProperty::New(2), renderer, overwrite);
603  node->AddProperty("pointsize", mitk::FloatProperty::New(1.0), renderer, overwrite);
604  node->AddProperty("selectedcolor", mitk::ColorProperty::New(1.0f, 0.0f, 0.0f), renderer, overwrite); // red
605  node->AddProperty("color", mitk::ColorProperty::New(1.0f, 1.0f, 0.0f), renderer, overwrite); // yellow
606  node->AddProperty("opacity", mitk::FloatProperty::New(1.0f), renderer, overwrite);
607  node->AddProperty("show contour", mitk::BoolProperty::New(false), renderer, overwrite);
608  node->AddProperty("close contour", mitk::BoolProperty::New(false), renderer, overwrite);
609  node->AddProperty("contourcolor", mitk::ColorProperty::New(1.0f, 0.0f, 0.0f), renderer, overwrite);
610  node->AddProperty("contoursize", mitk::FloatProperty::New(0.5), renderer, overwrite);
611  node->AddProperty("show points", mitk::BoolProperty::New(true), renderer, overwrite);
612  node->AddProperty("updateDataOnRender", mitk::BoolProperty::New(true), renderer, overwrite);
613  Superclass::SetDefaultProperties(node, renderer, overwrite);
614 }
#define ls
Definition: MitkMCxyz.cpp:57
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...
vtkSmartPointer< vtkPropAssembly > m_PointsAssembly
L * GetLocalStorage(mitk::BaseRenderer *forRenderer)
Retrieves a LocalStorage for a specific BaseRenderer.
Base class for mapper specific rendering ressources.
Definition: mitkMapper.h:193
void ReleaseGraphicsResources(vtkWindow *renWin)
LocalStorageHandler< BaseLocalStorage > m_LSH
unsigned long GetMTime() const override
Get the timestamp of the last change of the map or the last change of one of the properties store in ...
bool IsGenerateDataRequired(mitk::BaseRenderer *renderer, mitk::Mapper *mapper, mitk::DataNode *dataNode) const
Definition: mitkMapper.cpp:119
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
void ResetMapper(BaseRenderer *renderer) override
Reset the mapper (i.e., make sure that nothing is displayed) if no valid data is present. In most cases the reimplemented function disables the according actors (toggling visibility off)
vtkSmartPointer< vtkPolyDataMapper > m_VtkUnselectedPolyDataMapper
static Pointer New()
Organizes the rendering process.
vtkSmartPointer< vtkActor > m_ContourActor
void ApplyColorAndOpacityProperties(mitk::BaseRenderer *renderer, vtkActor *actor) override
Apply color and opacity properties read from the PropertyList. Called by mapper subclasses.
virtual const mitk::PointSet * GetInput()
vtkSmartPointer< vtkAppendPolyData > m_vtkUnselectedPointList
bool GetBoolProperty(const char *propertyKey, bool &boolValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for bool properties (instances of BoolProperty)
vtkSmartPointer< vtkAppendPolyData > m_vtkTextList
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
virtual void ApplyAllProperties(mitk::BaseRenderer *renderer, vtkActor *actor)
virtual void CreateContour(vtkPoints *points, vtkCellArray *connections)
static Pointer New()
The ColorProperty class RGB color property.
vtkSmartPointer< vtkPolyDataMapper > m_VtkSelectedPolyDataMapper
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 ...
vtkSmartPointer< vtkActor > m_UnselectedActor
Data structure which stores a set of points. Superclass of mitk::Mesh.
Definition: mitkPointSet.h:75
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
vtkLinearTransform * GetVtkTransform(int t=0) const
Get the transformation applied prior to displaying the data as a vtkTransform.
itk::TimeStamp & GetLastGenerateDataTime()
Definition: mitkMapper.h:205
vtkSmartPointer< vtkPoints > m_WorldPositions
All point positions, already in world coordinates.
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
Generate the data needed for rendering into renderer.
static Pointer New()
mitk::PropertyList * GetPropertyList(const mitk::BaseRenderer *renderer=nullptr) const
Get the PropertyList of the renderer. If renderer is nullptr, the BaseRenderer-independent PropertyLi...
vtkRenderWindow * GetRenderWindow() const
Access the RenderWindow into which this renderer renders.
static Pointer New()
vtkSmartPointer< vtkActor > m_SelectedActor
const float selectedColor[]
int GetTimestep() const
Returns the current time step as calculated from the renderer.
Definition: mitkMapper.h:147
vtkSmartPointer< vtkAppendPolyData > m_vtkSelectedPointList
mitk::BaseProperty * GetProperty(const std::string &propertyKey) const
Get a property by its name.
Property for strings.
vtkSmartPointer< vtkCellArray > m_PointConnections
All connections between two points (used for contour drawing)
void UpdateVtkTransform(mitk::BaseRenderer *renderer) override
Set the vtkTransform of the m_Prop3D for the current time step of renderer.
vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64
static void SetDefaultProperties(DataNode *node, BaseRenderer *renderer=nullptr, bool overwrite=false)
Set default values of properties used by this mapper to node.
Definition: mitkMapper.cpp:143