Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkSimulationVtkMapper2D.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 
17 #include "mitkSimulation.h"
20 
21 mitk::SimulationVtkMapper2D::LocalStorage::LocalStorage()
22  : m_Actor(vtkSmartPointer<vtkActor>::New())
23 {
24 }
25 
26 mitk::SimulationVtkMapper2D::LocalStorage::~LocalStorage()
27 {
28 }
29 
31 {
32  if (node != NULL)
33  {
34  node->AddProperty("Simulation.Visual.2D Rendering", BoolProperty::New(false), renderer, overwrite);
35  Superclass::SetDefaultProperties(node, renderer, overwrite);
36  }
37 }
38 
39 mitk::SimulationVtkMapper2D::SimulationVtkMapper2D()
40 {
41 }
42 
43 mitk::SimulationVtkMapper2D::~SimulationVtkMapper2D()
44 {
45 }
46 
48 {
49 }
50 
52 {
53  DataNode* dataNode = this->GetDataNode();
54 
55  if (dataNode == NULL)
56  return;
57 
58  Simulation* simulation = dynamic_cast<Simulation*>(dataNode->GetData());
59 
60  if (simulation == NULL)
61  return;
62 
63  LocalStorage* localStorage = m_LocalStorageHandler.GetLocalStorage(renderer);
64 
65  bool enabled = false;
66  dataNode->GetBoolProperty("Simulation.Visual.2D Rendering", enabled, renderer);
67 
68  if (!enabled)
69  {
70  localStorage->m_Actor->SetMapper(NULL);
71  return;
72  }
73 
74  if (localStorage->m_Mapper == NULL)
75  {
76  localStorage->m_Mapper = vtkSmartPointer<vtkSimulationPolyDataMapper2D>::New();
77  localStorage->m_Mapper->SetSimulation(simulation);
78  }
79 
80  if (localStorage->m_Actor->GetMapper() == NULL)
81  localStorage->m_Actor->SetMapper(localStorage->m_Mapper);
82 }
83 
85 {
86  return m_LocalStorageHandler.GetLocalStorage(renderer)->m_Actor;
87 }
void GenerateDataForRenderer(BaseRenderer *renderer) override
Generate the data needed for rendering into renderer.
void ApplyColorAndOpacityProperties(BaseRenderer *, vtkActor *) override
Apply color and opacity properties read from the PropertyList. Called by mapper subclasses.
Organizes the rendering process.
vtkProp * GetVtkProp(BaseRenderer *renderer) override
bool GetBoolProperty(const char *propertyKey, bool &boolValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for bool properties (instances of BoolProperty)
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
static Pointer New()
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 ...
static void SetDefaultProperties(DataNode *node, BaseRenderer *renderer=NULL, bool overwrite=false)
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.