8 #include "visuVTKAdaptor/SOrientationMarker.hpp" 10 #include <fwRuntime/operations.hpp> 12 #include <fwServices/macros.hpp> 15 #include <vtkAxesActor.h> 16 #include <vtkCubeSource.h> 17 #include <vtkGenericDataObjectReader.h> 18 #include <vtkOrientationMarkerWidget.h> 19 #include <vtkPolyData.h> 20 #include <vtkPolyDataMapper.h> 21 #include <vtkRenderer.h> 22 #include <vtkSmartPointer.h> 23 #include <vtkTransform.h> 32 SOrientationMarker::SOrientationMarker() :
39 void SOrientationMarker::starting()
43 auto filePath = ::fwRuntime::getBundleResourceFilePath(
"visuVTKAdaptor",
"human.vtk");
45 vtkSmartPointer< vtkGenericDataObjectReader > reader = vtkSmartPointer< vtkGenericDataObjectReader >::New();
46 reader->SetFileName( filePath.string().c_str() );
48 vtkDataObject* obj = reader->GetOutput();
49 vtkPolyData* mesh = vtkPolyData::SafeDownCast(obj);
51 SLM_WARN_IF(
"Orientation marker load failed", !obj);
53 vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
54 mapper->SetInputData(mesh);
56 vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
57 actor->SetMapper(mapper);
59 m_widget = vtkSmartPointer<vtkOrientationMarkerWidget>::New();
60 m_widget->SetOrientationMarker( actor );
61 m_widget->SetInteractor( this->getInteractor() );
63 if(m_hAlign ==
"left")
65 m_widget->SetViewport( 0.0, 0.0, 0.1, 0.1 );
67 else if(m_hAlign ==
"right")
69 m_widget->SetViewport( 0.9, 0.0, 1, 0.1 );
72 m_widget->SetEnabled( 1 );
73 m_widget->InteractiveOff();
74 this->setVtkPipelineModified();
75 this->requestRender();
80 void SOrientationMarker::stopping()
82 this->removeAllPropFromRenderer();
88 void SOrientationMarker::configuring()
90 this->configureParams();
92 const ConfigType config = this->
getConfigTree().get_child(
"config.<xmlattr>");
94 m_hAlign = config.get<std::string>(
"hAlign",
"left");
95 SLM_ASSERT(
"'hAlign' value must be 'left' or 'right'", m_hAlign ==
"left" || m_hAlign ==
"right");
The namespace visuVTKAdaptor contains the list of adaptors available for the generic scene...
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
Adaptor used to display an orientationMarker in a generic scene.
FWGUI_API void initialize()
Initialize managers.
Base class for VTK adaptors.
#define SLM_WARN_IF(message, cond)
FWSERVICES_API ConfigType getConfigTree() const
Return the configuration, in an boost property tree.