7 #include "visuVTKAdaptor/SModelSeries.hpp" 9 #include "visuVTKAdaptor/SMesh.hpp" 10 #include "visuVTKAdaptor/SReconstruction.hpp" 11 #include "visuVTKAdaptor/STexture.hpp" 13 #include <fwCom/Signal.hpp> 14 #include <fwCom/Signal.hxx> 15 #include <fwCom/Slots.hpp> 16 #include <fwCom/Slots.hxx> 18 #include <fwData/Boolean.hpp> 19 #include <fwData/Material.hpp> 20 #include <fwData/Mesh.hpp> 21 #include <fwData/Reconstruction.hpp> 23 #include <fwMedData/ModelSeries.hpp> 25 #include <fwServices/macros.hpp> 26 #include <fwServices/op/Add.hpp> 29 #include <vtkPolyDataMapper.h> 36 const ::fwCom::Signals::SignalKeyType SModelSeries::s_TEXTURE_APPLIED_SIG =
"textureApplied";
39 const ::fwCom::Slots::SlotKeyType SModelSeries::s_UPDATE_NORMAL_MODE_SLOT =
"updateNormalMode";
40 const ::fwCom::Slots::SlotKeyType SModelSeries::s_SHOW_RECONSTRUCTIONS_SLOT =
"showReconstructions";
43 static const ::fwCom::Slots::SlotKeyType s_CHANGE_FIELD_SLOT =
"changeField";
45 static const ::fwServices::IService::KeyType s_MODEL_INPUT =
"model";
49 SModelSeries::SModelSeries() noexcept :
50 m_autoResetCamera(true)
52 m_clippingPlanes =
"";
54 m_sigTextureApplied = newSignal<TextureAppliedSignalType>(s_TEXTURE_APPLIED_SIG);
63 SModelSeries::~SModelSeries() noexcept
73 const ConfigType config = this->
getConfigTree().get_child(
"config.<xmlattr>");
75 this->setClippingPlanes( config.get<std::string>(
"clippingplanes",
"") );
77 const std::string autoresetcamera = config.get<std::string>(
"autoresetcamera",
"yes");
78 SLM_ASSERT(
"'autoresetcamera' must be 'yes' or 'no'", autoresetcamera ==
"yes" || autoresetcamera ==
"no");
79 m_autoResetCamera = (autoresetcamera ==
"yes");
81 if (config.count(
"texture"))
83 SLM_FATAL(
"'texture' is deprecated, you need to connect manually the SModelSeries::textureApplied signal to " 84 "the STexture::applyTexture slot.");
100 ::fwMedData::ModelSeries::csptr modelSeries = this->getInput< ::fwMedData::ModelSeries >(s_MODEL_INPUT);
101 SLM_ASSERT(
"Missing ModelSeries '" + s_MODEL_INPUT +
"'", modelSeries);
105 ::fwData::Boolean::csptr showField = modelSeries->getField<
::fwData::Boolean >(
"ShowReconstructions");
107 if (showField && showField->getValue() ==
false)
112 for( ::fwData::Reconstruction::sptr reconstruction : modelSeries->getReconstructionDB() )
115 auto adaptor = registerService< ::visuVTKAdaptor::SReconstruction >(
"::visuVTKAdaptor::SReconstruction");
116 adaptor->registerInput(reconstruction, SReconstruction::s_RECONSTRUCTION_INPUT,
true);
123 adaptor->setClippingPlanes( m_clippingPlanes );
124 adaptor->setAutoResetCamera(m_autoResetCamera);
126 adaptor->setForceHide( !showRec );
128 m_sigTextureApplied->asyncEmit(reconstruction->getMaterial());
146 for(
auto& wService : subServices)
148 auto service = wService.lock();
151 auto reconstructionAdaptor = ::visuVTKAdaptor::SReconstruction::dynamicCast(service);
152 if (reconstructionAdaptor && reconstructionAdaptor->getInput< ::
fwData::Object >(
153 SReconstruction::s_RECONSTRUCTION_INPUT)->
getID() == recID)
155 reconstructionAdaptor->updateNormalMode(mode);
166 ::fwMedData::ModelSeries::csptr modelSeries = this->getInput< ::fwMedData::ModelSeries >(s_MODEL_INPUT);
167 SLM_ASSERT(
"Missing ModelSeries '" + s_MODEL_INPUT +
"'", modelSeries);
170 for(
auto& wService : subServices)
172 auto service = wService.lock();
175 auto reconstructionAdaptor = ::visuVTKAdaptor::SReconstruction::dynamicCast(service);
176 if (reconstructionAdaptor)
178 reconstructionAdaptor->setForceHide( !show );
190 const auto modelSeries = this->getInput< ::fwMedData::ModelSeries >(s_MODEL_INPUT);
191 const bool show = modelSeries->getField(
"ShowReconstructions", ::fwData::Boolean::New(
true))->value();
194 for(
auto& wService : subServices)
196 auto service = wService.lock();
199 auto reconstructionAdaptor = ::visuVTKAdaptor::SReconstruction::dynamicCast(service);
200 if (reconstructionAdaptor)
202 reconstructionAdaptor->setForceHide( !show );
This class is a helper to define the connections of a service and its data.
FWCOM_API void disconnect()
Disconnect all registered connections and clear m_connections.
void showReconstructionsOnFieldChanged()
Slot: update all reconstructions visibility using "ShowReconstructions" field.
The namespace visuVTKAdaptor contains the list of adaptors available for the generic scene...
VISUVTKADAPTOR_API void updating() override
Perform some computations according to object (this service is attached to) attribute values and its ...
FWRENDERVTK_API void configureParams()
Parse the xml configuration for renderer, picker and transform.
const ServiceVector & getRegisteredServices() const
Get all subservices linked to this service.
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 ...
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_CHANGED_FIELDS_SIG
Type of signal m_sigModified.
FWRENDERVTK_API SRender::sptr getRenderService() const
Returd the associated render service.
FWRENDERVTK_API SRender::PickerIdType getPickerId() const
Gets the identifier of the picker used by this adaptor.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_ADDED_FIELDS_SIG
Type of signal m_sigModified.
#define SLM_FATAL(message)
FWSERVICES_API void unregisterServices(const std::string &_implType="")
Unregister all services linked to this service, optionally matches only a given type of services...
static FWMEDDATA_APIconst::fwCom::Signals::SignalKeyType s_RECONSTRUCTIONS_ADDED_SIG
Key in m_signals map of signal m_sigReconstructionsAdded.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
FWRENDERVTK_API SRender::VtkObjectIdType getTransformId() const
Returns the identifier of the transform used by this adaptor.
Base class for each data object.
void updateNormalMode(std::uint8_t mode, std::string recID)
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_MODIFIED_SIG
Key in m_signals map of signal m_sigModified.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_REMOVED_FIELDS_SIG
Type of signal m_sigModified.
FWRENDERVTK_API SRender::RendererIdType getRendererId() const
Returns the renderer identifier.
FWRENDERVTK_API void initialize()
Initialize the adaptor with the associated render service. (must be call in starting).
void showReconstructions(bool show)
Slot: show(or hide) reconstructions.
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 configuring() override
Configure the service before starting. Apply the configuration to service.
This adaptor shows ModelSeries. Creates adaptors for each reconstruction in model.
VISUVTKADAPTOR_API void starting() override
Initialize the service activity.
VISUVTKADAPTOR_API void stopping() override
Uninitialize the service activity. The stop() method is always invoked before destroying a service...
static FWSERVICES_APIconst::fwCom::Slots::SlotKeyType s_UPDATE_SLOT
Slot to call start method.
static FWMEDDATA_APIconst::fwCom::Signals::SignalKeyType s_RECONSTRUCTIONS_REMOVED_SIG
Key in m_signals map of signal m_sigReconstructionsRemoved.
Base class for VTK adaptors.
This class contains a boolean value.
FWSERVICES_API ConfigType getConfigTree() const
Return the configuration, in an boost property tree.