diff --git a/Modules/Simulation/mitkSimulationVtkMapper2D.cpp b/Modules/Simulation/mitkSimulationVtkMapper2D.cpp index 5e85a9ef49..73e7c28bc1 100644 --- a/Modules/Simulation/mitkSimulationVtkMapper2D.cpp +++ b/Modules/Simulation/mitkSimulationVtkMapper2D.cpp @@ -1,87 +1,87 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkSimulation.h" #include "mitkSimulationVtkMapper2D.h" #include "mitkVtkSimulationPolyDataMapper2D.h" mitk::SimulationVtkMapper2D::LocalStorage::LocalStorage() : m_Actor(vtkSmartPointer::New()) { } mitk::SimulationVtkMapper2D::LocalStorage::~LocalStorage() { } void mitk::SimulationVtkMapper2D::SetDefaultProperties(DataNode* node, BaseRenderer* renderer, bool overwrite) { if (node != NULL) { node->AddProperty("Simulation.Visual.2D Rendering", BoolProperty::New(false), renderer, overwrite); Superclass::SetDefaultProperties(node, renderer, overwrite); } } mitk::SimulationVtkMapper2D::SimulationVtkMapper2D() { } mitk::SimulationVtkMapper2D::~SimulationVtkMapper2D() { } -void mitk::SimulationVtkMapper2D::ApplyColorAndOpacityProperties(vtkActor*, BaseRenderer*) +void mitk::SimulationVtkMapper2D::ApplyColorAndOpacityProperties(BaseRenderer*, vtkActor*) { } void mitk::SimulationVtkMapper2D::GenerateDataForRenderer(BaseRenderer* renderer) { DataNode* dataNode = this->GetDataNode(); if (dataNode == NULL) return; Simulation* simulation = dynamic_cast(dataNode->GetData()); if (simulation == NULL) return; LocalStorage* localStorage = m_LocalStorageHandler.GetLocalStorage(renderer); bool enabled = false; dataNode->GetBoolProperty("Simulation.Visual.2D Rendering", enabled, renderer); if (!enabled) { localStorage->m_Actor->SetMapper(NULL); return; } if (localStorage->m_Mapper == NULL) { localStorage->m_Mapper = vtkSmartPointer::New(); localStorage->m_Mapper->SetSimulation(simulation); } if (localStorage->m_Actor->GetMapper() == NULL) localStorage->m_Actor->SetMapper(localStorage->m_Mapper); } vtkProp* mitk::SimulationVtkMapper2D::GetVtkProp(BaseRenderer* renderer) { return m_LocalStorageHandler.GetLocalStorage(renderer)->m_Actor; } diff --git a/Modules/Simulation/mitkSimulationVtkMapper2D.h b/Modules/Simulation/mitkSimulationVtkMapper2D.h index 3aad719d42..098665d113 100644 --- a/Modules/Simulation/mitkSimulationVtkMapper2D.h +++ b/Modules/Simulation/mitkSimulationVtkMapper2D.h @@ -1,68 +1,68 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkSimulationVtkMapper2D_h #define mitkSimulationVtkMapper2D_h #include #include #include namespace mitk { class vtkSimulationPolyDataMapper2D; class MitkSimulation_EXPORT SimulationVtkMapper2D : public VtkMapper { class LocalStorage : public Mapper::BaseLocalStorage { public: LocalStorage(); ~LocalStorage(); vtkSmartPointer m_Mapper; vtkSmartPointer m_Actor; private: LocalStorage(const LocalStorage&); LocalStorage& operator=(const LocalStorage&); }; public: static void SetDefaultProperties(DataNode* node, BaseRenderer* renderer = NULL, bool overwrite = false); mitkClassMacro(SimulationVtkMapper2D, VtkMapper); itkFactorylessNewMacro(Self) itkCloneMacro(Self) - void ApplyColorAndOpacityProperties(vtkActor*, BaseRenderer*); + void ApplyColorAndOpacityProperties(BaseRenderer*, vtkActor*); vtkProp* GetVtkProp(BaseRenderer* renderer); protected: void GenerateDataForRenderer(BaseRenderer* renderer); private: SimulationVtkMapper2D(); ~SimulationVtkMapper2D(); SimulationVtkMapper2D(const Self&); Self& operator=(const Self&); LocalStorageHandler m_LocalStorageHandler; }; } #endif diff --git a/Modules/Simulation/mitkSimulationVtkMapper3D.cpp b/Modules/Simulation/mitkSimulationVtkMapper3D.cpp index be890eb41f..bb0013078c 100644 --- a/Modules/Simulation/mitkSimulationVtkMapper3D.cpp +++ b/Modules/Simulation/mitkSimulationVtkMapper3D.cpp @@ -1,164 +1,164 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkSetVtkRendererVisitor.h" #include "mitkSimulation.h" #include "mitkSimulationVtkMapper3D.h" #include "mitkVtkSimulationPolyDataMapper3D.h" #include #include mitk::SimulationVtkMapper3D::LocalStorage::LocalStorage() : m_Actor(vtkSmartPointer::New()) { } mitk::SimulationVtkMapper3D::LocalStorage::~LocalStorage() { } void mitk::SimulationVtkMapper3D::SetDefaultProperties(DataNode* node, BaseRenderer* renderer, bool overwrite) { if (node != NULL) { Simulation* simulation = dynamic_cast(node->GetData()); if (simulation != NULL) { sofa::simulation::Node::SPtr rootNode = simulation->GetRootNode(); sofa::component::visualmodel::VisualStyle::SPtr visualStyle; rootNode->get(visualStyle); if (!visualStyle) { visualStyle = sofa::core::objectmodel::New(); sofa::core::visual::DisplayFlags* displayFlags = visualStyle->displayFlags.beginEdit(); displayFlags->setShowVisualModels(); visualStyle->displayFlags.endEdit(); rootNode->addObject(visualStyle); } const sofa::core::visual::DisplayFlags& displayFlags = visualStyle->displayFlags.getValue(); node->AddProperty("Simulation.Behavior.Behavior Models", BoolProperty::New(displayFlags.getShowBehaviorModels()), renderer, overwrite); node->AddProperty("Simulation.Behavior.Force Fields", BoolProperty::New(displayFlags.getShowForceFields()), renderer, overwrite); node->AddProperty("Simulation.Behavior.Interactions", BoolProperty::New(displayFlags.getShowInteractionForceFields()), renderer, overwrite); node->AddProperty("Simulation.Collision.Bounding Trees", BoolProperty::New(displayFlags.getShowBoundingCollisionModels()), renderer, overwrite); node->AddProperty("Simulation.Collision.Collision Models", BoolProperty::New(displayFlags.getShowCollisionModels()), renderer, overwrite); node->AddProperty("Simulation.Mapping.Mechanical Mappings", BoolProperty::New(displayFlags.getShowMechanicalMappings()), renderer, overwrite); node->AddProperty("Simulation.Mapping.Visual Mappings", BoolProperty::New(displayFlags.getShowMappings()), renderer, overwrite); node->AddProperty("Simulation.Options.Normals", BoolProperty::New(displayFlags.getShowNormals()), renderer, overwrite); node->AddProperty("Simulation.Options.Wire Frame", BoolProperty::New(displayFlags.getShowWireFrame()), renderer, overwrite); node->AddProperty("Simulation.Visual.Visual Models", BoolProperty::New(displayFlags.getShowVisualModels() != sofa::core::visual::tristate::false_value), renderer, overwrite); } Superclass::SetDefaultProperties(node, renderer, overwrite); } } mitk::SimulationVtkMapper3D::SimulationVtkMapper3D() { } mitk::SimulationVtkMapper3D::~SimulationVtkMapper3D() { } -void mitk::SimulationVtkMapper3D::ApplyColorAndOpacityProperties(vtkActor*, BaseRenderer*) +void mitk::SimulationVtkMapper3D::ApplyColorAndOpacityProperties(BaseRenderer*, vtkActor*) { } void mitk::SimulationVtkMapper3D::ApplySimulationProperties(BaseRenderer* renderer) { DataNode* node = this->GetDataNode(); bool showBehaviorModels; bool showForceFields; bool showInteractionForceFields; bool showBoundingCollisionModels; bool showCollisionModels; bool showMechanicalMappings; bool showMappings; bool showNormals; bool showWireFrame; bool showVisualModels; node->GetBoolProperty("Simulation.Behavior.Behavior Models", showBehaviorModels, renderer); node->GetBoolProperty("Simulation.Behavior.Force Fields", showForceFields, renderer); node->GetBoolProperty("Simulation.Behavior.Interactions", showInteractionForceFields, renderer); node->GetBoolProperty("Simulation.Collision.Bounding Trees", showBoundingCollisionModels, renderer); node->GetBoolProperty("Simulation.Collision.Collision Models", showCollisionModels, renderer); node->GetBoolProperty("Simulation.Mapping.Mechanical Mappings", showMechanicalMappings, renderer); node->GetBoolProperty("Simulation.Mapping.Visual Mappings", showMappings, renderer); node->GetBoolProperty("Simulation.Options.Normals", showNormals, renderer); node->GetBoolProperty("Simulation.Options.Wire Frame", showWireFrame, renderer); node->GetBoolProperty("Simulation.Visual.Visual Models", showVisualModels, renderer); Simulation* simulation = static_cast(this->GetData()); sofa::component::visualmodel::VisualStyle::SPtr visualStyle; simulation->GetRootNode()->get(visualStyle); sofa::core::visual::DisplayFlags* displayFlags = visualStyle->displayFlags.beginEdit(); displayFlags->setShowBehaviorModels(showBehaviorModels); displayFlags->setShowForceFields(showForceFields); displayFlags->setShowInteractionForceFields(showInteractionForceFields); displayFlags->setShowBoundingCollisionModels(showBoundingCollisionModels); displayFlags->setShowCollisionModels(showCollisionModels); displayFlags->setShowMechanicalMappings(showMechanicalMappings); displayFlags->setShowMappings(showMappings); displayFlags->setShowNormals(showNormals); displayFlags->setShowWireFrame(showWireFrame); displayFlags->setShowVisualModels(showVisualModels); visualStyle->displayFlags.endEdit(); } void mitk::SimulationVtkMapper3D::GenerateDataForRenderer(BaseRenderer* renderer) { DataNode* dataNode = this->GetDataNode(); if (dataNode == NULL) return; Simulation* simulation = dynamic_cast(dataNode->GetData()); if (simulation == NULL) return; LocalStorage* localStorage = m_LocalStorageHandler.GetLocalStorage(renderer); if (localStorage->m_Mapper == NULL) { localStorage->m_Mapper = vtkSmartPointer::New(); localStorage->m_Mapper->SetSimulation(simulation); localStorage->m_Actor->SetMapper(localStorage->m_Mapper); SetVtkRendererVisitor setVtkRendererVisitor(renderer->GetVtkRenderer()); simulation->GetRootNode()->executeVisitor(&setVtkRendererVisitor); } this->ApplySimulationProperties(renderer); } vtkProp* mitk::SimulationVtkMapper3D::GetVtkProp(BaseRenderer* renderer) { return m_LocalStorageHandler.GetLocalStorage(renderer)->m_Actor; } diff --git a/Modules/Simulation/mitkSimulationVtkMapper3D.h b/Modules/Simulation/mitkSimulationVtkMapper3D.h index 7a95f442fb..b7a6d4fb6c 100644 --- a/Modules/Simulation/mitkSimulationVtkMapper3D.h +++ b/Modules/Simulation/mitkSimulationVtkMapper3D.h @@ -1,69 +1,69 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkSimulationVtkMapper3D_h #define mitkSimulationVtkMapper3D_h #include #include #include namespace mitk { class vtkSimulationPolyDataMapper3D; class MitkSimulation_EXPORT SimulationVtkMapper3D : public VtkMapper { class LocalStorage : public Mapper::BaseLocalStorage { public: LocalStorage(); ~LocalStorage(); vtkSmartPointer m_Mapper; vtkSmartPointer m_Actor; private: LocalStorage(const LocalStorage&); LocalStorage& operator=(const LocalStorage&); }; public: static void SetDefaultProperties(DataNode* node, BaseRenderer* renderer = NULL, bool overwrite = false); mitkClassMacro(SimulationVtkMapper3D, VtkMapper); itkFactorylessNewMacro(Self) itkCloneMacro(Self) - void ApplyColorAndOpacityProperties(vtkActor*, BaseRenderer*); + void ApplyColorAndOpacityProperties(BaseRenderer*, vtkActor*); void ApplySimulationProperties(BaseRenderer* renderer); vtkProp* GetVtkProp(BaseRenderer* renderer); protected: void GenerateDataForRenderer(BaseRenderer* renderer); private: SimulationVtkMapper3D(); ~SimulationVtkMapper3D(); SimulationVtkMapper3D(const Self&); Self& operator=(const Self&); LocalStorageHandler m_LocalStorageHandler; }; } #endif