7 #include "visuVTKAdaptor/SSliceFollowerCamera.hpp" 9 #include <fwCom/Slot.hpp> 10 #include <fwCom/Slot.hxx> 11 #include <fwCom/Slots.hpp> 12 #include <fwCom/Slots.hxx> 14 #include <fwDataTools/fieldHelper/MedicalImageHelpers.hpp> 16 #include <fwServices/macros.hpp> 19 #include <vtkCamera.h> 20 #include <vtkInteractorStyleImage.h> 22 #include <vtkMatrix4x4.h> 23 #include <vtkRenderer.h> 24 #include <vtkRenderWindowInteractor.h> 25 #include <vtkTransform.h> 32 static const ::fwCom::Slots::SlotKeyType s_UPDATE_SLICE_INDEX_SLOT =
"updateSliceIndex";
33 static const ::fwCom::Slots::SlotKeyType s_UPDATE_SLICE_TYPE_SLOT =
"updateSliceType";
35 static const ::fwServices::IService::KeyType s_IMAGE_INOUT =
"image";
39 SSliceFollowerCamera::SSliceFollowerCamera() noexcept :
42 newSlot(s_UPDATE_SLICE_INDEX_SLOT, &SSliceFollowerCamera::updateSliceIndex,
this);
43 newSlot(s_UPDATE_SLICE_TYPE_SLOT, &SSliceFollowerCamera::updateSliceType,
this);
48 SSliceFollowerCamera::~SSliceFollowerCamera() noexcept
58 const ConfigType config = this->
getConfigTree().get_child(
"config.<xmlattr>");
60 const std::string orientation = config.get<std::string>(
"sliceIndex",
"axial");
61 if(orientation ==
"axial" )
65 else if(orientation ==
"frontal" )
69 else if(orientation ==
"sagittal" )
81 ::fwData::Image::sptr image = this->getInOut< ::fwData::Image >(s_IMAGE_INOUT);
87 this->initializeCamera();
95 ::fwData::Image::sptr image = this->getInOut< ::fwData::Image >(s_IMAGE_INOUT);
99 this->initializeCamera();
111 void SSliceFollowerCamera::updateSliceIndex(
int ,
int ,
int )
113 this->updateCamera();
118 void SSliceFollowerCamera::updateSliceType(
int from,
int to)
128 this->initializeCamera();
134 void SSliceFollowerCamera::initializeCamera()
136 ::fwData::Image::sptr image = this->getInOut< ::fwData::Image >(s_IMAGE_INOUT);
143 const int orientationToAxe[3] = { 2, 2, 1 };
147 double size = imageSize[ orientation ];
149 double distance = (1.1 * size)
150 / ( std::tan( m_camera->GetViewAngle() * (vtkMath::Pi() / 180.0) ) );
152 m_camera->ParallelProjectionOn();
155 this->updateCamera(distance, size);
161 void SSliceFollowerCamera::updateCamera(
double distance,
double size)
169 double focalPoint[ 3 ];
170 double position[ 3 ];
172 std::copy(center, center+3, focalPoint);
178 distance = m_camera->GetDistance();
180 std::copy(focalPoint, focalPoint+3, position);
184 m_camera->SetParallelScale(.51*size);
185 m_camera->SetFocalPoint( focalPoint );
186 m_camera->SetPosition( position );
197 m_camera->OrthogonalizeViewUp();
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_SLICE_INDEX_MODIFIED_SIG
Type of signal when image's buffer is added.
This class is a helper to define the connections of a service and its data.
virtual VISUVTKADAPTOR_API KeyConnectionsMap getAutoConnections() const override
Returns proposals to connect service slots to associated object signals, this method is used for obj/...
VISUVTKADAPTOR_API void updating() override
Perform some computations according to object (this service is attached to) attribute values and its ...
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.
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 ...
VISUVTKADAPTOR_API void starting() override
Initialize the service activity.
Update the camera according to slice move.
FWSERVICES_API void unregisterServices(const std::string &_implType="")
Unregister all services linked to this service, optionally matches only a given type of services...
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
VISUVTKADAPTOR_API void configuring() override
Configure the service before starting. Apply the configuration to service.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_MODIFIED_SIG
Key in m_signals map of signal m_sigModified.
FWRENDERVTK_API void initialize()
Initialize the adaptor with the associated render service. (must be call in starting).
This class defines an image.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_SLICE_TYPE_MODIFIED_SIG
Type of signal when image's buffer is added.
static FWSERVICES_APIconst::fwCom::Slots::SlotKeyType s_UPDATE_SLOT
Slot to call start method.
Base class for VTK adaptors.
VISUVTKADAPTOR_API void stopping() override
Uninitialize the service activity. The stop() method is always invoked before destroying a service...
FWSERVICES_API ConfigType getConfigTree() const
Return the configuration, in an boost property tree.