7 #include "visuVTKAdaptor/SMedical3DCamera.hpp" 9 #include <fwCom/Slot.hxx> 10 #include <fwCom/Slots.hxx> 12 #include <fwData/String.hpp> 13 #include <fwData/TransformationMatrix3D.hpp> 15 #include <fwServices/macros.hpp> 17 #include <boost/assign/list_of.hpp> 20 #include <vtkCamera.h> 21 #include <vtkInteractorStyleImage.h> 22 #include <vtkRenderer.h> 23 #include <vtkRenderWindowInteractor.h> 30 static const ::fwCom::Slots::SlotKeyType SET_AXIAL_SLOT =
"setAxial";
31 static const ::fwCom::Slots::SlotKeyType SET_SAGITTAL_SLOT =
"setSagittal";
32 static const ::fwCom::Slots::SlotKeyType SET_FRONTAL_SLOT =
"setFrontal";
34 std::map< std::string, ::fwDataTools::helper::MedicalImageAdaptor::Orientation >
35 SMedical3DCamera::m_orientationConversion = ::boost::assign::map_list_of
36 (std::string(
"axial"), Z_AXIS)
37 (std::string(
"frontal"), Y_AXIS)
38 (std::string(
"sagittal"), X_AXIS);
42 SMedical3DCamera::SMedical3DCamera() noexcept :
46 newSlot(SET_AXIAL_SLOT, &SMedical3DCamera::setAxialView,
this);
47 newSlot(SET_SAGITTAL_SLOT, &SMedical3DCamera::setSagittalView,
this);
48 newSlot(SET_FRONTAL_SLOT, &SMedical3DCamera::setFrontalView,
this);
53 SMedical3DCamera::~SMedical3DCamera() noexcept
63 const ConfigType config = this->
getConfigTree().get_child(
"config.<xmlattr>");
65 const std::string orientation = config.get<std::string>(
"sliceIndex",
"axial");
66 SLM_ASSERT(
"Unknown orientation", m_orientationConversion.find(orientation) != m_orientationConversion.end());
69 const std::string reset = config.get<std::string>(
"resetAtStart",
"no");
70 SLM_ASSERT(
"'resetAtStart' value must be 'yes' or 'no'", reset ==
"yes" || reset ==
"no");
71 m_resetAtStart = (reset ==
"yes");
104 void SMedical3DCamera::setSagittalView()
112 void SMedical3DCamera::setFrontalView()
120 void SMedical3DCamera::setAxialView()
128 void SMedical3DCamera::updateView()
132 this->resetAxialView();
136 this->resetFrontalView();
140 this->resetSagittalView();
146 void SMedical3DCamera::resetSagittalView()
148 m_camera->SetPosition(-1, 0, 0);
149 m_camera->SetFocalPoint(0, 0, 0);
150 m_camera->SetViewUp(0, 0, 1);
157 void SMedical3DCamera::resetFrontalView()
159 m_camera->SetPosition(0, -1, 0);
160 m_camera->SetFocalPoint(0, 0, 0);
161 m_camera->SetViewUp(0, 0, 1);
169 void SMedical3DCamera::resetAxialView()
171 m_camera->SetPosition(0, 0, -1);
172 m_camera->SetFocalPoint(0, 0, 0);
173 m_camera->SetViewUp(0, -1, 0);
FWRENDERVTK_API vtkRenderer * getRenderer()
Returns the renderer.
The namespace visuVTKAdaptor contains the list of adaptors available for the generic scene...
FWRENDERVTK_API void configureParams()
Parse the xml configuration for renderer, picker and transform.
VISUVTKADAPTOR_API void starting() override
Initialize the service activity.
FWRENDERVTK_API void requestRender()
notify a render request iff vtkPipeline is modified
FWRENDERVTK_API void setVtkPipelineModified()
End-user have to call this method when a vtk structure has been modified, thus a render request will ...
Update camera scene according to defined axes (axial, sagittal, frontal).
VISUVTKADAPTOR_API void configuring() override
Configure the service before starting. Apply the configuration to service.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
VISUVTKADAPTOR_API void stopping() override
Uninitialize the service activity. The stop() method is always invoked before destroying a service...
Base class for each data object.
FWRENDERVTK_API void initialize()
Initialize the adaptor with the associated render service. (must be call in starting).
VISUVTKADAPTOR_API void updating() override
Perform some computations according to object (this service is attached to) attribute values and its ...
Base class for VTK adaptors.
FWSERVICES_API ConfigType getConfigTree() const
Return the configuration, in an boost property tree.