7 #include "visuVTKAdaptor/SImage3DCursor.hpp" 9 #include <fwCom/Slot.hxx> 10 #include <fwCom/Slots.hxx> 12 #include <fwData/Color.hpp> 13 #include <fwData/Float.hpp> 14 #include <fwData/Image.hpp> 16 #include <fwServices/macros.hpp> 19 #include <vtkPolyData.h> 20 #include <vtkPolyDataMapper.h> 21 #include <vtkProperty.h> 22 #include <vtkSphereSource.h> 23 #include <vtkTransform.h> 32 static const ::fwCom::Slots::SlotKeyType s_UPDATE_SLICE_INDEX_SLOT =
"updateSliceIndex";
33 static const ::fwCom::Slots::SlotKeyType s_UPDATE_SPHERE_SLOT =
"updateSphere";
35 static const ::fwServices::IService::KeyType s_IMAGE_INOUT =
"image";
39 SImage3DCursor::SImage3DCursor() noexcept
41 newSlot(s_UPDATE_SLICE_INDEX_SLOT, &SImage3DCursor::updateSliceIndex,
this);
42 newSlot(s_UPDATE_SPHERE_SLOT, &SImage3DCursor::updateSphere,
this);
47 SImage3DCursor::~SImage3DCursor() noexcept
52 void SImage3DCursor::setVisibility(
bool visibility )
54 m_cursorActor->SetVisibility(visibility);
72 m_cursorPolyData = vtkSmartPointer<vtkPolyData>::New();
73 m_cursorMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
74 m_cursorActor = vtkSmartPointer<vtkActor>::New();
76 ::fwData::Image::sptr img = this->getInOut< ::fwData::Image >(s_IMAGE_INOUT);
78 if ( img->getField(
"IMAGE3DCURSOR_RADIUS") && img->getField(
"IMAGE3DCURSOR_COLOR") )
80 ::fwData::Float::sptr radius = img->getField<
::fwData::Float >(
"IMAGE3DCURSOR_RADIUS");
83 this->buildPolyData(radius->value());
84 m_cursorActor->GetProperty()->SetColor( color->red(), color->green(), color->blue());
88 this->buildPolyData();
89 m_cursorActor->GetProperty()->SetColor(.1, .6, 1.);
92 m_cursorMapper->SetInputData( m_cursorPolyData );
93 m_cursorActor->SetMapper(m_cursorMapper);
109 m_cursorPolyData = 0;
118 ::fwData::Image::sptr image = this->getInOut< ::fwData::Image >(s_IMAGE_INOUT);
123 this->updateCursorPosition(center);
131 ::fwData::Image::sptr image = this->getInOut< ::fwData::Image >(s_IMAGE_INOUT);
137 void SImage3DCursor::updateSliceIndex(
int axial,
int frontal,
int sagittal)
143 int index[3] = {sagittal, frontal, axial};
146 this->updateCursorPosition(center);
152 void SImage3DCursor::updateSphere(::fwData::Color::sptr color,
float radius)
154 ::fwData::Image::sptr img = this->getInOut< ::fwData::Image >(s_IMAGE_INOUT);
156 m_cursorActor->GetProperty()->SetColor( color->red(), color->green(), color->blue());
157 this->buildPolyData(radius);
159 m_cursorMapper->SetInputData( m_cursorPolyData );
166 void SImage3DCursor::updateCursorPosition(
double world[3] )
168 m_cursorActor->SetPosition(world);
174 void SImage3DCursor::buildPolyData(
float radius)
177 vtkSmartPointer<vtkSphereSource> polySource = vtkSmartPointer<vtkSphereSource>::New();
178 polySource->SetCenter(0.0, 0.0, 0.0);
179 polySource->SetRadius(radius);
180 polySource->SetPhiResolution(8);
181 polySource->SetThetaResolution(8);
183 polySource->SetOutput(m_cursorPolyData);
184 polySource->Update();
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_SLICE_INDEX_MODIFIED_SIG
Type of signal when image's buffer is added.
virtual VISUVTKADAPTOR_API void starting() override
Initialize the service activity.
This class is a helper to define the connections of a service and its data.
FWRENDERVTK_API void addToRenderer(vtkProp *prop)
Adds the vtkProp to 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 ...
FWRENDERVTK_API void removeAllPropFromRenderer()
Removes all the vtkProp from the renderer.
FWDATA_API::fwData::Object::sptr getField(const FieldNameType &name,::fwData::Object::sptr defaultValue=::fwData::Object::sptr()) const
Returns a pointer of corresponding field (null if non exist).
Add a 3D spatial marker represented by a sphere that identify the intersection point of the selected ...
virtual VISUVTKADAPTOR_API void updating() override
Perform some computations according to object (this service is attached to) attribute values and its ...
FWRENDERVTK_API vtkTransform * getTransform()
Returns the transform used by this adaptor.
This class defines color object.
FWRENDERVTK_API SRender::VtkObjectIdType getTransformId() const
Returns the identifier of the transform used by this adaptor.
virtual VISUVTKADAPTOR_API KeyConnectionsMap getAutoConnections() const override
Returns proposals to connect service slots to associated object signals, this method is used for obj/...
virtual VISUVTKADAPTOR_API void configuring() override
Configure the service before starting. Apply the configuration to service.
FWRENDERVTK_API void initialize()
Initialize the adaptor with the associated render service. (must be call in starting).
virtual VISUVTKADAPTOR_API void swapping() override
Swap the service from associated object to another object.
This class contains an float value.
virtual VISUVTKADAPTOR_API void stopping() override
Uninitialize the service activity. The stop() method is always invoked before destroying a service...
Base class for VTK adaptors.