7 #include "gui/action/SModifyLayout.hpp" 9 #include <fwCore/base.hpp> 11 #include <fwGui/dialog/MessageDialog.hpp> 12 #include <fwGui/GuiRegistry.hpp> 13 #include <fwGui/IGuiContainerSrv.hpp> 15 #include <fwRuntime/Extension.hpp> 16 #include <fwRuntime/helper.hpp> 18 #include <fwServices/macros.hpp> 19 #include <fwServices/op/Get.hpp> 21 #include <fwTools/fwID.hpp> 62 _sstream <<
"Starter Action" << std::endl;
71 for(MoveSrvVectType::value_type elt : m_moveSrv )
73 std::string uid = elt.first;
74 std::string wid = elt.second;
76 ::fwServices::IService::sptr service = ::fwServices::get( uid );
78 ::fwGui::IGuiContainerSrv::sptr container = ::fwGui::IGuiContainerSrv::dynamicCast(service);
79 SLM_ASSERT(
"::fwGui::IGuiContainerSrv dynamicCast failed", container);
81 container->setParent(wid);
85 for(EnableSrvVectType::value_type elt : m_enableSrv )
87 std::string uid = elt.first;
88 bool isEnable = elt.second;
90 ::fwServices::IService::sptr service = ::fwServices::get( uid );
92 if(service->isStarted())
94 ::fwGui::IGuiContainerSrv::sptr containerSrv = ::fwGui::IGuiContainerSrv::dynamicCast(service);
97 containerSrv->getContainer()->setEnabled(isEnable);
99 ::fwGui::IActionSrv::sptr actionSrv = ::fwGui::IActionSrv::dynamicCast(service);
102 actionSrv->setIsExecutable(isEnable);
107 for(ShowSrvVectType::value_type elt : m_showSrvWid)
109 std::string wid = elt.first;
110 ::boost::logic::tribool
isVisible = elt.second;
112 OSLM_ASSERT(
"::fwGui::IGuiContainerSrv " << wid <<
" is unknown", container);
116 container->setVisible(
true);
120 container->setVisible(
false);
128 for(ShowSrvVectType::value_type elt : m_showSrvSid)
130 std::string uid = elt.first;
131 ::boost::logic::tribool
isVisible = elt.second;
133 ::fwServices::IService::sptr service = ::fwServices::get( uid );
135 ::fwGui::IGuiContainerSrv::sptr containerSrv = ::fwGui::IGuiContainerSrv::dynamicCast(service);
136 SLM_ASSERT(
"::fwGui::IGuiContainerSrv dynamicCast failed", containerSrv);
138 ::fwGui::container::fwContainer::sptr container = containerSrv->getContainer();
142 container->setVisible(
true);
146 container->setVisible(
false);
161 std::vector < ConfigurationType > vectConfig =
m_configuration->find(
"config");
162 if( !vectConfig.empty() )
164 ConfigurationType config = vectConfig.at(0);
165 for(ConfigurationType actionCfg : config->getElements() )
167 if(actionCfg->getName() ==
"move")
169 SLM_ASSERT(
"Attribute uid missing", actionCfg->hasAttribute(
"uid"));
170 std::string uuid = actionCfg->getExistingAttributeValue(
"uid");
171 SLM_ASSERT(
"Attribute wid missing", actionCfg->hasAttribute(
"wid"));
172 std::string wid = actionCfg->getExistingAttributeValue(
"wid");
174 m_moveSrv.push_back( std::make_pair(uuid, wid) );
176 else if(actionCfg->getName() ==
"show" 177 || actionCfg->getName() ==
"hide" 178 || actionCfg->getName() ==
"show_or_hide")
181 if (actionCfg->getName() ==
"show")
185 else if (actionCfg->getName() ==
"hide")
191 isVisible = ::boost::logic::indeterminate;
194 if(actionCfg->hasAttribute(
"wid"))
196 std::string wid = actionCfg->getExistingAttributeValue(
"wid");
197 m_showSrvWid.push_back( std::make_pair(wid, isVisible) );
199 else if(actionCfg->hasAttribute(
"sid"))
201 std::string sid = actionCfg->getExistingAttributeValue(
"sid");
202 m_showSrvSid.push_back( std::make_pair(sid, isVisible) );
206 SLM_ERROR(
"Attribute wid or sid missing");
209 else if(actionCfg->getName() ==
"enable" || actionCfg->getName() ==
"disable")
211 SLM_ASSERT(
"Attribute uid missing", actionCfg->hasAttribute(
"uid"));
212 std::string uuid = actionCfg->getExistingAttributeValue(
"uid");
213 bool isEnable = (actionCfg->getName() ==
"enable");
215 m_enableSrv.push_back( std::make_pair(uuid, isEnable) );
219 OSLM_FATAL(
"Invalid tag name "<<actionCfg->getName());
static FWGUI_API::fwGui::container::fwContainer::sptr getWIDContainer(std::string wid)
Returns fwContainer associate with window ID, null if not found.
virtual GUI_API ~SModifyLayout() noexcept
Destructor. Do nothing.
virtual GUI_API void starting() override
Initialize the service activity.
FWGUI_API void actionServiceStarting()
Method called when the action service is starting.
#define OSLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
#define SLM_TRACE_FUNC()
Trace contextual function signature.
The namespace gui contains the basic services to build the application IHM.
FWGUI_API bool isVisible() const
Returns true if action is visible.
FWGUI_API void actionServiceStopping()
Method called when the action service is stopping.
This action is used to modify the layout configuration.
FWGUI_API bool getIsActive() const
Return true if action service is active.
Defines the service interface managing the menu items.
#define SLM_ERROR(message)
virtual GUI_API void info(std::ostream &_sstream) override
This method gives information about the class. Do nothing.
GUI_API void configuring() override
This method is used to configure the service parameters: specifies which views to show/hide/mode...
#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.
::fwRuntime::ConfigurationElement::sptr m_configuration
Configuration element used to configure service internal state using a generic XML like structure TOD...
#define OSLM_FATAL(message)
GUI_API SModifyLayout() noexcept
Constructor. Do nothing.
virtual GUI_API void stopping() override
Uninitialize the service activity. The stop() method is always invoked before destroying a service...
GUI_API void updating() override
This method starts-updates or stops the specified services.