7 #include "visuVTKAdaptor/S2DWheel.hpp" 9 #include <fwCom/Signal.hxx> 10 #include <fwCom/Slot.hxx> 11 #include <fwCom/Slots.hxx> 13 #include <fwServices/macros.hpp> 15 #include <fwVtkIO/helper/vtkLambdaCommand.hpp> 17 #include <vtkRenderer.h> 18 #include <vtkRenderWindow.h> 25 static const ::fwCom::Signals::SignalKeyType s_WHEEL_UPDATED_SIG =
"wheelUpdated";
27 static const ::fwCom::Slots::SlotKeyType s_UPDATE_VISIBILITY_SLOT =
"updateVisibility";
35 m_wheelUpdatedSignal = newSignal<WheelUpdatedSignalType>(s_WHEEL_UPDATED_SIG);
37 newSlot(s_UPDATE_VISIBILITY_SLOT, &S2DWheel::updateVisibility,
this);
54 m_visible = config.get<
bool>(
"config.<xmlattr>.visible",
true);
65 wheelRepresentation->SetVisibility(m_visible);
66 m_wheelWidget->SetInteractor(this->
getRenderer()->GetRenderWindow()->GetInteractor());
67 m_wheelWidget->SetPriority(1.f);
68 m_wheelWidget->SetRepresentation(wheelRepresentation);
70 m_wheelWidget->SetWheelUpdateCallback([
this](
double cx,
double cy,
double o)
72 OSLM_DEBUG(
"Center : " <<
"(" << cx <<
", " << cy <<
"), Orientation : " << o);
73 this->m_wheelUpdatedSignal->asyncEmit(cx, cy, o);
76 m_resizeCallback = vtkSmartPointer< ::fwVtkIO::helper::vtkLambdaCommand >::New();
77 m_resizeCallback->SetCallback(
78 [
this](vtkObject*,
long unsigned int,
void* )
80 const int viewportWidth = this->
getRenderer()->GetRenderWindow()->GetSize()[0];
81 const int viewportHeight = this->
getRenderer()->GetRenderWindow()->GetSize()[1];
83 if(viewportHeight != 0 && viewportWidth != 0)
85 this->m_wheelWidget->GetRepresentation()->UpdateRepresentation();
90 this->
getRenderer()->GetRenderWindow()->AddObserver(vtkCommand::ModifiedEvent, m_resizeCallback);
100 m_wheelWidget->Off();
102 this->
getRenderer()->GetRenderWindow()->RemoveObserver(m_resizeCallback);
117 void S2DWheel::updateVisibility(
bool _isVisible)
119 m_visible = _isVisible;
120 this->m_wheelWidget->GetRepresentation()->SetVisibility(static_cast<int>(_isVisible));
static FWRENDERVTK_API fwVtkWheelRepresentation * New()
Calls the constructor. Initializes wheel geometry and actor.
VISUVTKADAPTOR_API S2DWheel() noexcept
Constructor. Does nothing.
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
virtual VISUVTKADAPTOR_API ~S2DWheel() noexcept
Destructor. Does nothing.
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.
virtual VISUVTKADAPTOR_API void stopping() override
Disables the widget.
virtual VISUVTKADAPTOR_API void updating() override
Does nothing.
FWRENDERVTK_API void initialize()
Initialize the adaptor with the associated render service. (must be call in starting).
virtual VISUVTKADAPTOR_API void configuring() override
Configure the service before starting. Apply the configuration to service.
Render a rotatable 2D wheel in screen-space.
Base class for VTK adaptors.
Representation of a wheel widget.
#define OSLM_DEBUG(message)
virtual VISUVTKADAPTOR_API void starting() override
Instantiates the widget and puts it in the scene.
FWSERVICES_API ConfigType getConfigTree() const
Return the configuration, in an boost property tree.