9 #include "visuVTKAdaptor/SDistance.hpp" 11 #include <fwData/Material.hpp> 12 #include <fwData/PointList.hpp> 13 #include <fwData/Reconstruction.hpp> 15 #include <fwDataTools/fieldHelper/Image.hpp> 17 #include <fwServices/macros.hpp> 20 #include <vtkAxisActor2D.h> 21 #include <vtkCommand.h> 22 #include <vtkDistanceRepresentation2D.h> 23 #include <vtkHandleRepresentation.h> 24 #include <vtkLineSource.h> 25 #include <vtkPolyDataMapper.h> 26 #include <vtkProperty.h> 27 #include <vtkProperty2D.h> 28 #include <vtkRenderer.h> 29 #include <vtkTextProperty.h> 36 const ::fwServices::IService::KeyType SDistance::s_POINTLIST_INPUT =
"pointList";
38 SDistance::SDistance() noexcept :
39 m_distanceRepresentation( vtkDistanceRepresentation2D::New()),
40 m_lineActor(vtkActor::New()),
41 m_lineSource(vtkLineSource::New())
43 m_distanceRepresentation->InstantiateHandleRepresentation();
44 m_distanceRepresentation->SetLabelFormat(
"%-#6.3gmm");
46 m_lineSource->SetResolution(1);
47 vtkPolyDataMapper* lineMapper = vtkPolyDataMapper::New();
48 lineMapper->SetInputConnection(m_lineSource->GetOutputPort());
50 m_lineActor->SetMapper(lineMapper);
51 m_lineActor->GetProperty()->SetLineWidth(5.);
52 m_lineActor->GetProperty()->SetColor(1., 1., 0.);
53 m_lineActor->GetProperty()->SetOpacity(0.4);
56 m_distanceRepresentation->GetAxis()->GetProperty()->SetColor(1.0, 0.0, 1.);
57 m_distanceRepresentation->GetAxis()->SetTitlePosition(0.9);
67 SDistance::~SDistance() noexcept
69 m_lineSource->Delete();
70 m_lineActor->Delete();
71 m_distanceRepresentation->Delete();
78 SLM_ASSERT(
"newColor not instanced", newColor);
79 m_distanceRepresentation->GetAxis()->GetProperty()->SetColor(
80 newColor->red(), newColor->green(), newColor->blue() );
81 m_distanceRepresentation->GetAxis()->GetProperty()->SetOpacity(newColor->alpha() );
82 m_lineActor->GetProperty()->SetColor(newColor->red(), newColor->green(), newColor->blue());
83 m_lineActor->GetProperty()->SetOpacity( newColor->alpha() * 0.4);
85 m_distanceRepresentation->GetAxis()->GetTitleTextProperty()->SetColor(
86 newColor->red(), newColor->green(), newColor->blue() );
103 ::fwData::PointList::csptr ptList = this->getInput< ::fwData::PointList >(s_POINTLIST_INPUT);
105 m_point1 = ptList->getPoints().front();
106 m_point2 = ptList->getPoints().back();
116 ::fwData::Color::sptr color;
131 ::fwData::Point::csptr p1 = m_point1.lock();
132 ::fwData::Point::csptr p2 = m_point2.lock();
135 std::copy(p1->getCoord().begin(), (p1)->getCoord().end(), ps1 );
138 std::copy(p2->getCoord().begin(), (p2)->getCoord().end(), ps2 );
140 m_distanceRepresentation->GetPoint1Representation()->SetWorldPosition(ps1);
141 m_distanceRepresentation->GetPoint2Representation()->SetWorldPosition(ps2);
143 m_distanceRepresentation->SetPoint1DisplayPosition(ps1);
144 m_distanceRepresentation->SetPoint2DisplayPosition(ps2);
146 m_distanceRepresentation->BuildRepresentation();
148 m_lineSource->SetPoint1(ps1);
149 m_lineSource->SetPoint2(ps2);
VISUVTKADAPTOR_API void stopping() override
Uninitialize the service activity. The stop() method is always invoked before destroying a service...
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.
VISUVTKADAPTOR_API void updating() override
Perform some computations according to object (this service is attached to) attribute values and its ...
VISUVTKADAPTOR_API void starting() override
Initialize the service activity.
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.
Display the distance between the two points of the point list.
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.
This class defines color object.
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) ...
virtual VISUVTKADAPTOR_API KeyConnectionsMap getAutoConnections() const override
Returns proposals to connect service slots to associated object signals, this method is used for obj/...
This class defines a list of points.
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).
VISUVTKADAPTOR_API void setAxisColor(::fwData::Color::sptr newColor) noexcept
set Distance Axis color AND alpha
void disconnect()
Disconnect related Connection.
static FWSERVICES_APIconst::fwCom::Slots::SlotKeyType s_UPDATE_SLOT
Slot to call start method.
Base class for VTK adaptors.