7 #include "gui/action/SPushField.hpp" 9 #include <fwCom/Slots.hpp> 10 #include <fwCom/Slots.hxx> 12 #include <fwRuntime/ConfigurationElement.hpp> 13 #include <fwRuntime/EConfigurationElement.hpp> 15 #include <fwServices/macros.hpp> 16 #include <fwServices/registry/AppConfig.hpp> 17 #include <fwServices/registry/ObjectService.hpp> 19 #include <fwTools/fwID.hpp> 28 static const ::fwCom::Slots::SlotKeyType s_UPDATE_OBJECTS_SLOT =
"updateObject";
30 static const std::string s_SOURCE_KEY =
"source";
31 static const std::string s_DESTINATION_KEY =
"destination";
41 newSlot(s_UPDATE_OBJECTS_SLOT, &SPushField::updateObjects,
this);
56 const ConfigurationType pushCfg =
m_configuration->findConfigurationElement(
"push");
58 SLM_ASSERT(
"<push> tag must have one attribute 'field'.", pushCfg->hasAttribute(
"field"));
59 m_field = pushCfg->getAttributeValue(
"field");
67 this->updateObjects();
81 ::fwData::Object::sptr objectSrc = this->getInOut< ::fwData::Object >(s_SOURCE_KEY);
82 SLM_ASSERT( s_SOURCE_KEY +
" doesn't exist or is not a composite", objectSrc);
84 ::fwData::Object::sptr obj = objectSrc->getField(m_field);
86 SLM_WARN_IF(
"'" + m_field +
"' not found in object '" + objectSrc->getID() +
"'", obj ==
nullptr);
95 void SPushField::updateObjects()
97 ::fwData::Object::sptr objectSrc = this->getInOut< ::fwData::Object >(s_SOURCE_KEY);
98 SLM_ASSERT( s_SOURCE_KEY +
" doesn't exist or is not a composite", objectSrc);
100 const bool executable = (objectSrc->getField(m_field) !=
nullptr);
GUI_API SPushField() noexcept
Constructor. Do nothing.
This class is a helper to define the connections of a service and its data.
virtual FWGUI_API void setIsExecutable(bool isExecutable)
Set the action service executable or not.
FWGUI_API void actionServiceStarting()
Method called when the action service is starting.
The namespace gui contains the basic services to build the application IHM.
FWGUI_API void actionServiceStopping()
Method called when the action service is stopping.
Defines the service interface managing the menu items.
To add or remove an object in composite with specific key.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_ADDED_FIELDS_SIG
Type of signal m_sigModified.
FWSERVICES_API void setOutput(const ::fwServices::IService::KeyType &key, const ::fwData::Object::sptr &object, size_t index=0)
Register an output object at a given key in the OSR, replacing it if it already exists.
virtual void configuring() override
Configure the service.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
FWGUI_API void initialize()
Initialize the action.
virtual GUI_API KeyConnectionsMap getAutoConnections() const override
Returns proposals to connect service slots to associated object signals, this method is used for obj/...
::fwRuntime::ConfigurationElement::sptr m_configuration
Configuration element used to configure service internal state using a generic XML like structure TOD...
virtual void updating() override
Extract the object.
virtual GUI_API ~SPushField() noexcept
Destructor. Do nothing.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_REMOVED_FIELDS_SIG
Type of signal m_sigModified.
virtual void starting() override
Register the action and check if the action is executable.
virtual void stopping() override
Unregister the action.
#define SLM_WARN_IF(message, cond)