7 #include "ctrlSelection/wrapper/SImageSignalForwarder.hpp" 9 #include <fwCom/Signal.hpp> 10 #include <fwCom/Signal.hxx> 11 #include <fwCom/Signals.hpp> 12 #include <fwCom/Slot.hpp> 13 #include <fwCom/Slot.hxx> 14 #include <fwCom/Slots.hpp> 15 #include <fwCom/Slots.hxx> 17 #include <fwData/Composite.hpp> 18 #include <fwData/Image.hpp> 20 #include <fwServices/macros.hpp> 22 #include <boost/regex.hpp> 29 static const ::fwCom::Slots::SlotKeyType s_FORWARD_MODIFIED_SLOT =
"forwardModified";
30 static const ::fwCom::Slots::SlotKeyType s_FORWARD_BUFFER_MODIFIED_SLOT =
"forwardBufferModified";
31 static const ::fwCom::Slots::SlotKeyType s_FORWARD_LANDMARK_ADDED_SLOT =
"forwardLandmarkAdded";
32 static const ::fwCom::Slots::SlotKeyType s_FORWARD_LANDMARK_REMOVED_SLOT =
"forwardLandmarkRemoved";
33 static const ::fwCom::Slots::SlotKeyType s_FORWARD_LANDMARK_DISPLAYED_SLOT =
"forwardLandmarkDisplayed";
34 static const ::fwCom::Slots::SlotKeyType s_FORWARD_DISTANCE_ADDED_SLOT =
"forwardDistanceAdded";
35 static const ::fwCom::Slots::SlotKeyType s_FORWARD_DISTANCE_REMOVED_SLOT =
"forwardDistanceRemoved";
36 static const ::fwCom::Slots::SlotKeyType s_FORWARD_DISTANCE_DISPLAYED_SLOT =
"forwardDistanceDisplayed";
37 static const ::fwCom::Slots::SlotKeyType s_FORWARD_SLICE_INDEX_MODIFIED_SLOT =
"forwardSliceIndexModified";
38 static const ::fwCom::Slots::SlotKeyType s_FORWARD_SLICE_TYPE_MODIFIED_SLOT =
"forwardSliceTypeModified";
39 static const ::fwCom::Slots::SlotKeyType s_FORWARD_VISIBILITY_MODIFIED_SLOT =
"forwardVisibilityModified";
40 static const ::fwCom::Slots::SlotKeyType s_FORWARD_TRANSPARENCY_MODIFIED_SLOT =
"forwardTransparencyModified";
41 static const ::fwCom::Slots::SlotKeyType s_FORWARD_ADDED_FIELDS_SLOT =
"forwardAddedFields";
42 static const ::fwCom::Slots::SlotKeyType s_FORWARD_CHANGED_FIELDS_SLOT =
"forwardChangedFields";
43 static const ::fwCom::Slots::SlotKeyType s_FORWARD_REMOVED_FIELDS_SLOT =
"forwardRemovedFields";
45 static const ::fwServices::IService::KeyType s_SOURCE_INPUT =
"source";
46 static const ::fwServices::IService::KeyType s_TARGET_INPUT =
"target";
48 SImageSignalForwarder::AvailableConnectionMapType SImageSignalForwarder::m_availableConnection;
57 SImageSignalForwarder::SImageSignalForwarder() noexcept
75 newSlot(s_FORWARD_MODIFIED_SLOT, &SImageSignalForwarder::forwardModified,
this);
76 newSlot(s_FORWARD_BUFFER_MODIFIED_SLOT, &SImageSignalForwarder::forwardBufferModified,
this);
77 newSlot(s_FORWARD_LANDMARK_ADDED_SLOT, &SImageSignalForwarder::forwardLandmarkAdded,
this);
78 newSlot(s_FORWARD_LANDMARK_REMOVED_SLOT, &SImageSignalForwarder::forwardLandmarkRemoved,
this);
79 newSlot(s_FORWARD_LANDMARK_DISPLAYED_SLOT, &SImageSignalForwarder::forwardLandmarkDisplayed,
this);
80 newSlot(s_FORWARD_DISTANCE_ADDED_SLOT, &SImageSignalForwarder::forwardDistanceAdded,
this);
81 newSlot(s_FORWARD_DISTANCE_REMOVED_SLOT, &SImageSignalForwarder::forwardDistanceRemoved,
this);
82 newSlot(s_FORWARD_DISTANCE_DISPLAYED_SLOT, &SImageSignalForwarder::forwardDistanceDisplayed,
this);
83 newSlot(s_FORWARD_SLICE_INDEX_MODIFIED_SLOT, &SImageSignalForwarder::forwardSliceIndexModified,
this);
84 newSlot(s_FORWARD_SLICE_TYPE_MODIFIED_SLOT, &SImageSignalForwarder::forwardSliceTypeModified,
this);
85 newSlot(s_FORWARD_VISIBILITY_MODIFIED_SLOT, &SImageSignalForwarder::forwardVisibilityModified,
this);
86 newSlot(s_FORWARD_TRANSPARENCY_MODIFIED_SLOT, &SImageSignalForwarder::forwardTransparencyModified,
this);
87 newSlot(s_FORWARD_ADDED_FIELDS_SLOT, &SImageSignalForwarder::forwardAddedFields,
this);
88 newSlot(s_FORWARD_CHANGED_FIELDS_SLOT, &SImageSignalForwarder::forwardChangedFields,
this);
89 newSlot(s_FORWARD_REMOVED_FIELDS_SLOT, &SImageSignalForwarder::forwardRemovedFields,
this);
94 SImageSignalForwarder::~SImageSignalForwarder() noexcept
102 std::vector< ::fwRuntime::ConfigurationElement::sptr > configs =
m_configuration->find(
"forward");
104 for (
auto cfg : configs)
106 std::string signal = cfg->getValue();
107 SLM_ASSERT(
"Signal '" + signal +
"' is unknown.",
108 m_availableConnection.find(signal) != m_availableConnection.end());
109 m_managedSignals.push_back(signal);
117 ::fwData::Image::csptr src = this->getInput< ::fwData::Image >(s_SOURCE_INPUT);
119 for (
auto signalKey: m_managedSignals)
121 m_connections.
connect(src, signalKey, this->getSptr(), m_availableConnection[signalKey]);
154 void SImageSignalForwarder::forwardModified()
156 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_TARGET_INPUT);
163 void SImageSignalForwarder::forwardBufferModified()
165 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_TARGET_INPUT);
174 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_TARGET_INPUT);
176 sig->asyncEmit(point);
183 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_TARGET_INPUT);
185 sig->asyncEmit(point);
190 void SImageSignalForwarder::forwardLandmarkDisplayed(
bool display)
192 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_TARGET_INPUT);
194 sig->asyncEmit(display);
201 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_TARGET_INPUT);
203 sig->asyncEmit(pointList);
210 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_TARGET_INPUT);
212 sig->asyncEmit(pointList);
217 void SImageSignalForwarder::forwardDistanceDisplayed(
bool display)
219 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_TARGET_INPUT);
221 sig->asyncEmit(display);
226 void SImageSignalForwarder::forwardSliceIndexModified(
int axial,
int frontal,
int sagittal)
228 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_TARGET_INPUT);
231 sig->asyncEmit(axial, frontal, sagittal);
236 void SImageSignalForwarder::forwardSliceTypeModified(
int from,
int to)
238 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_TARGET_INPUT);
241 sig->asyncEmit(from, to);
246 void SImageSignalForwarder::forwardVisibilityModified(
bool visibility)
248 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_TARGET_INPUT);
251 sig->asyncEmit(visibility);
256 void SImageSignalForwarder::forwardTransparencyModified()
258 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_TARGET_INPUT);
268 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_TARGET_INPUT);
270 sig->asyncEmit(objects);
278 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_TARGET_INPUT);
280 sig->asyncEmit(newObjects, oldObjects);
287 ::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_TARGET_INPUT);
289 sig->asyncEmit(objects);
virtual CTRLSELECTION_API void stopping() override
Implements stopping method derived from IService. Does nothing.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_SLICE_INDEX_MODIFIED_SIG
Type of signal when image's buffer is added.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_TRANSPARENCY_MODIFIED_SIG
Type of signal when image's buffer is added.
FWCOM_API void disconnect()
Disconnect all registered connections and clear m_connections.
This class define a 3D point.
virtual CTRLSELECTION_API void info(std::ostream &_sstream) override
Implements info method derived from IService. Print classname.
virtual CTRLSELECTION_API void configuring() override
Configures the service.
virtual CTRLSELECTION_API void updating() override
Implements updating method derived from IService. Does nothing.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_CHANGED_FIELDS_SIG
Type of signal m_sigModified.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_LANDMARK_DISPLAYED_SIG
Type of signal when image's buffer is added.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_LANDMARK_ADDED_SIG
Type of signal when image's buffer is added.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_ADDED_FIELDS_SIG
Type of signal m_sigModified.
The purpose of this service is to wrap messages incoming to the object to new messages.
std::map< std::string,::fwData::Object::sptr > FieldsContainerType
Type of signal m_sigModified.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_DISTANCE_ADDED_SIG
Type of signal when image's buffer is added.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_VISIBILITY_MODIFIED_SIG
Type of signal when image's buffer is added.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
::fwRuntime::ConfigurationElement::sptr m_configuration
Configuration element used to configure service internal state using a generic XML like structure TOD...
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_BUFFER_MODIFIED_SIG
Type of signal when image's buffer is added.
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.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_REMOVED_FIELDS_SIG
Type of signal m_sigModified.
This class defines an image.
virtual CTRLSELECTION_API void swapping() override
Implements swapping method derived from IService. Convert the image.
The namespace ctrlSelection contains several interfaces for manager, updater and wrapper.
virtual CTRLSELECTION_API void starting() override
Implements starting method derived from IService. Does nothing.
FWCOM_API void connect(const ::fwCom::HasSignals::csptr &hasSignals,::fwCom::Signals::SignalKeyType signalKey, const ::fwCom::HasSlots::csptr &hasSlots,::fwCom::Slots::SlotKeyType slotKey)
Connect signal to slot, and register this new connection in m_connections.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_SLICE_TYPE_MODIFIED_SIG
Type of signal when image's buffer is added.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_DISTANCE_REMOVED_SIG
Type of signal when image's buffer is added.
This service forwards signals from an image ti another.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_LANDMARK_REMOVED_SIG
Type of signal when image's buffer is added.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_DISTANCE_DISPLAYED_SIG
Type of signal when image's buffer is added.