7 #include "fwGui/registrar/MenuRegistrar.hpp" 9 #include "fwGui/GuiRegistry.hpp" 10 #include "fwGui/IActionSrv.hpp" 12 #include <fwServices/macros.hpp> 13 #include <fwServices/op/Get.hpp> 15 #include <fwTools/fwID.hpp> 41 return ::fwGui::GuiRegistry::getSIDMenu(
m_sid);
47 std::vector< ::fwGui::container::fwMenuItem::sptr > menuItems)
50 ::fwGui::container::fwMenuItem::sptr menuItem = menuItems.at(
m_actionSids[actionSid].first );
58 OSLM_ASSERT(
"Bad configuration name "<<configuration->getName()<<
", must be registry",
59 configuration->getName() ==
"registry");
62 unsigned int index = 0;
65 std::vector < ConfigurationType > vectMenuItems = configuration->find(
"menuItem");
66 for( ConfigurationType menuItem : vectMenuItems)
68 SLM_ASSERT(
"<menuItem> tag must have sid attribute", menuItem->hasAttribute(
"sid"));
69 if(menuItem->hasAttribute(
"sid"))
72 if(menuItem->hasAttribute(
"start"))
74 std::string startValue = menuItem->getAttributeValue(
"start");
75 SLM_ASSERT(
"Wrong value '"<< startValue <<
"' for 'start' attribute (require yes or no)",
76 startValue ==
"yes" || startValue ==
"no");
77 start = (startValue ==
"yes");
79 std::string sid = menuItem->getAttributeValue(
"sid");
82 m_actionSids[sid] = SIDMenuMapType::mapped_type(index, start);
84 ::fwGui::ActionCallbackBase::sptr callback;
85 ::fwGui::GuiBaseObject::sptr guiObj = ::fwGui::factory::New(ActionCallbackBase::REGISTRY_KEY);
86 callback = ::fwGui::ActionCallbackBase::dynamicCast(guiObj);
87 OSLM_ASSERT(
"ClassFactoryRegistry failed for class "<< ::fwGui::ActionCallbackBase::REGISTRY_KEY, callback);
89 callback->setSID(sid);
97 std::vector < ConfigurationType > vectMenus = configuration->find(
"menu");
98 for( ConfigurationType menu : vectMenus)
100 SLM_ASSERT(
"<menu> tag must have sid attribute", menu->hasAttribute(
"sid"));
101 if(menu->hasAttribute(
"sid"))
104 if(menu->hasAttribute(
"start"))
106 std::string startValue = menu->getAttributeValue(
"start");
107 SLM_ASSERT(
"Wrong value '"<< startValue <<
"' for 'start' attribute (require yes or no)",
108 startValue ==
"yes" || startValue ==
"no");
109 start = (startValue ==
"yes");
111 std::string sid = menu->getAttributeValue(
"sid");
112 std::pair<int, bool> indexStart = std::make_pair( index, start);
125 ::fwGui::container::fwMenuItem::sptr menuItem;
128 OSLM_ASSERT(
"Container index "<< sid.second.first <<
" is bigger than subViews size!",
129 sid.second.first < menuItems.size());
130 menuItem = menuItems.at( sid.second.first );
132 if(sid.second.second)
135 ::fwServices::IService::sptr service = ::fwServices::get( sid.first );
136 OSLM_ASSERT(
"Service "<<sid.first <<
" must be stopped.", service->isStopped() );
158 ::fwGui::container::fwMenu::sptr menu;
159 for( SIDMenuMapType::value_type sid :
m_menuSids)
161 OSLM_ASSERT(
"Container index "<< sid.second.first <<
" is bigger than subViews size!",
162 sid.second.first < menus.size());
163 menu = menus.at( sid.second.first );
165 if(sid.second.second)
168 ::fwServices::IService::sptr service = ::fwServices::get( sid.first );
169 OSLM_ASSERT(
"Service "<<sid.first <<
" must be stopped.", service->isStopped() );
181 if(sid.second.second)
184 ::fwServices::IService::sptr service = ::fwServices::get( sid.first );
189 for( SIDMenuMapType::value_type sid :
m_menuSids)
191 if(sid.second.second)
194 ::fwServices::IService::sptr service = ::fwServices::get( sid.first );
205 SLM_WARN(
"TODO: MenuRegistrar::onItemAction not yet implemented");
static FWGUI_API void unregisterActionSIDToParentSID(std::string actionSid, std::string parentSid)
Unregisters action sid associted with a parent sid.
FWSERVICES_API::fwServices::IService::sptr get(::fwData::Object::sptr obj, std::string serviceType)
Get the first service of type serviceType which is attached to obj.
static FWGUI_API void registerSIDMenu(std::string sid,::fwGui::container::fwMenu::sptr menu)
Registers fwMenu associate with service ID.
#define OSLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
The namespace fwGui contains the base interface for IHM services.
#define SLM_WARN(message)
static FWGUI_API void actionServiceStopping(std::string actionSid)
Method called when the action service is stopping. Call parent service actionServiceStopping() method...
static FWGUI_API void unregisterSIDMenu(std::string sid)
Unregisters fwMenu associate with service ID.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
static FWGUI_API void registerActionSIDToParentSID(std::string actionSid, std::string parentSid)
Registers action sid associted with a parent sid.
static FWGUI_API void actionServiceStarting(std::string actionSid)
Method called when the action service is starting. Call parent service actionServiceStarting() method...