7 #include "visuVTKAdaptor/SImageSeries.hpp" 9 #include <fwData/Boolean.hpp> 10 #include <fwData/Material.hpp> 11 #include <fwData/Reconstruction.hpp> 13 #include <fwMedData/ImageSeries.hpp> 15 #include <fwServices/macros.hpp> 16 #include <fwServices/op/Add.hpp> 19 #include <vtkPolyDataMapper.h> 23 static const ::fwServices::IService::KeyType s_IMAGE_SERIES_INOUT =
"imageSeries";
24 static const ::fwServices::IService::KeyType s_TF_INOUT =
"tf";
29 SImageSeries::SImageSeries() noexcept :
30 m_allowAlphaInTF(false),
31 m_interpolation(false),
32 m_3dModeEnabled( ::
boost::logic::indeterminate ),
33 m_sliceMode(SNegatoMPR::THREE_SLICES)
40 SImageSeries::~SImageSeries() noexcept
50 const ConfigType config = this->
getConfigTree().get_child(
"config.<xmlattr>");
52 if (config.count(
"mode"))
54 std::string value = config.get<std::string>(
"mode");
55 std::transform(value.begin(), value.end(), value.begin(), tolower);
56 SLM_ASSERT(
"Bad value '" + value +
"' for attribute mode, it should either be '2d' or '3d'.",
57 value ==
"3d" || value ==
"2d");
60 if (config.count(
"slices"))
62 const std::string value = config.get<std::string>(
"slices");
78 SLM_FATAL(
"'slice' value must be '0', '1' or '3', actual: " + value);
82 const std::string orientation = config.get<std::string>(
"sliceIndex",
"axial");
83 if(orientation ==
"axial" )
87 else if(orientation ==
"frontal" )
91 else if(orientation ==
"sagittal" )
96 const std::string tfalpha = config.get<std::string>(
"tfalpha",
"no");
97 SLM_ASSERT(
"'tfalpha' value must be 'yes' or 'no', actual: " + tfalpha, tfalpha ==
"yes" || tfalpha ==
"no");
98 this->setAllowAlphaInTF(tfalpha ==
"yes");
100 const std::string interpolation = config.get<std::string>(
"interpolation",
"off");
101 SLM_ASSERT(
"'interpolation' value must be 'on' or 'off', actual: " + interpolation,
102 interpolation ==
"on" || interpolation ==
"off");
103 this->setInterpolation(interpolation ==
"yes");
105 this->setVtkImageSourceId( config.get<std::string>(
"vtkimagesource",
""));
120 ::fwMedData::ImageSeries::sptr series = this->getInOut< ::fwMedData::ImageSeries >(s_IMAGE_SERIES_INOUT);
125 auto negato = this->registerService< ::visuVTKAdaptor::SNegatoMPR>(
"::visuVTKAdaptor::SNegatoMPR");
128 ::fwData::Image::sptr image = series->getImage();
129 negato->registerInOut(image, SNegatoMPR::s_IMAGE_INOUT,
true);
131 ::fwData::TransferFunction::sptr tf = this->getInOut< ::fwData::TransferFunction >(s_TF_INOUT);
134 negato->registerInOut(tf, SNegatoMPR::s_TF_INOUT,
false);
145 negato->setAllowAlphaInTF(m_allowAlphaInTF);
146 negato->setInterpolation(m_interpolation);
147 negato->setVtkImageSourceId(m_imageSourceId);
162 if(m_sliceMode != sliceMode)
164 m_sliceMode = sliceMode;
179 return m_3dModeEnabled;
186 m_3dModeEnabled = enabled;
This class is a helper to define the connections of a service and its data.
void set3dMode(bool enabled)
Defines 3D mode.
virtual VISUVTKADAPTOR_API KeyConnectionsMap getAutoConnections() const override
Returns proposals to connect service slots to associated object signals, this method is used for obj/...
#define OSLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
The namespace visuVTKAdaptor contains the list of adaptors available for the generic scene...
This adaptor shows ImageSeries. Creates an adaptor for the image in the series.
FWRENDERVTK_API void configureParams()
Parse the xml configuration for renderer, picker and transform.
VISUVTKADAPTOR_API void updating() override
Creates and starts image adaptor. Redraw all (stop then restart sub services).
VISUVTKADAPTOR_API void starting() override
Calls doUpdate()
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.
VISUVTKADAPTOR_API void stopping() override
Stops and unregister image subservice.
#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...
#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.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_MODIFIED_SIG
Key in m_signals map 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).
SNegatoMPR::SliceMode getSliceMode()
Gets adaptor slice mode (NO_SLICE, ONE_SLICE, THREE_SLICES)
VISUVTKADAPTOR_API void configuring() override
Configure the adaptor.
::boost::logic::tribool is3dModeEnabled()
Returns true if 3d mode is enabled, false if it is not and indeterminate if it is not defined...
static FWSERVICES_APIconst::fwCom::Slots::SlotKeyType s_UPDATE_SLOT
Slot to call start method.
void setSliceMode(SNegatoMPR::SliceMode sliceMode)
Sets adaptor slice mode (NO_SLICE, ONE_SLICE, THREE_SLICES)
Base class for VTK adaptors.
FWSERVICES_API ConfigType getConfigTree() const
Return the configuration, in an boost property tree.