7 #include "fwGui/GuiRegistry.hpp" 9 #include "fwGui/IMenuSrv.hpp" 10 #include "fwGui/IToolBarSrv.hpp" 12 #include <fwServices/macros.hpp> 13 #include <fwServices/op/Get.hpp> 15 #include <fwTools/fwID.hpp> 20 GuiRegistry::ContainerMapType GuiRegistry::m_globalSIDToFwContainer;
21 GuiRegistry::ContainerMapType GuiRegistry::m_globalWIDToFwContainer;
22 GuiRegistry::MenuBarMapType GuiRegistry::m_globalSIDToFwMenuBar;
23 GuiRegistry::ToolBarMapType GuiRegistry::m_globalSIDToFwToolBar;
24 GuiRegistry::MenuMapType GuiRegistry::m_globalSIDToFwMenu;
41 OSLM_ASSERT(
"A fwContainer with the sid "<<sid<<
" already exists in the SID container map.",
42 m_globalSIDToFwContainer.find(sid) == m_globalSIDToFwContainer.end());
43 m_globalSIDToFwContainer[sid] = container;
51 OSLM_INFO_IF(
"Service "<<sid <<
" does not exist.", !service_exists );
54 ::fwServices::IService::sptr service = ::fwServices::get( sid );
55 OSLM_ASSERT(
"Service "<<sid<<
" must be stopped before unregistering the container.", service->isStopped());
58 OSLM_ASSERT(
"No fwContainer with the sid "<<sid<<
" exists in the SID container map.",
59 m_globalSIDToFwContainer.find(sid) != m_globalSIDToFwContainer.end());
62 m_globalSIDToFwContainer.erase(sid);
74 return m_globalSIDToFwContainer[sid];
82 return m_globalSIDToFwContainer.find(sid) != m_globalSIDToFwContainer.end();
89 OSLM_ASSERT(
"A fwContainer with the wid "<<wid<<
" already exists in the WID container map.",
90 m_globalWIDToFwContainer.find(wid) == m_globalWIDToFwContainer.end());
91 m_globalWIDToFwContainer[wid] = container;
98 OSLM_ASSERT(
"No fwContainer with the wid "<<wid<<
" exists in the WID container map.",
99 m_globalWIDToFwContainer.find(wid) != m_globalWIDToFwContainer.end());
102 m_globalWIDToFwContainer.erase(wid);
114 return m_globalWIDToFwContainer[wid];
122 return m_globalWIDToFwContainer.find(wid) != m_globalWIDToFwContainer.end();
129 OSLM_ASSERT(
"A fwMenuBar with the sid "<<sid<<
" already exists in the SID menuBar map.",
130 m_globalSIDToFwMenuBar.find(sid) == m_globalSIDToFwMenuBar.end());
131 m_globalSIDToFwMenuBar[sid] = menuBar;
139 OSLM_INFO_IF(
"Service "<<sid <<
" does not exist.", !service_exists );
142 ::fwServices::IService::sptr service = ::fwServices::get( sid );
143 OSLM_ASSERT(
"Service "<<sid<<
" must be stopped before unregistering the menuBar.", service->isStopped());
146 OSLM_ASSERT(
"No fwMenuBar with the sid "<<sid<<
" exists in the SID menuBar map.",
147 m_globalSIDToFwMenuBar.find(sid) != m_globalSIDToFwMenuBar.end());
150 m_globalSIDToFwMenuBar.erase(sid);
157 OSLM_ASSERT(
"No fwMenuBar with the sid "<<sid<<
" exists in the SID menuBar map.",
158 m_globalSIDToFwMenuBar.find(sid) != m_globalSIDToFwMenuBar.end());
160 return m_globalSIDToFwMenuBar[sid];
167 OSLM_ASSERT(
"A fwToolBar with the sid "<<sid<<
" already exists in the SID toolBar map.",
168 m_globalSIDToFwToolBar.find(sid) == m_globalSIDToFwToolBar.end());
169 m_globalSIDToFwToolBar[sid] = toolBar;
177 OSLM_INFO_IF(
"Service "<<sid <<
" does not exist.", !service_exists );
180 ::fwServices::IService::sptr service = ::fwServices::get( sid );
181 OSLM_ASSERT(
"Service "<<sid<<
" must be stopped before unregistering the toolBar.", service->isStopped());
184 OSLM_ASSERT(
"No fwToolBar with the sid "<<sid<<
" exists in the SID toolBar map.",
185 m_globalSIDToFwToolBar.find(sid) != m_globalSIDToFwToolBar.end());
188 m_globalSIDToFwToolBar.erase(sid);
195 OSLM_ASSERT(
"No fwToolBar with the sid "<<sid<<
" exists in the SID toolBar map.",
196 m_globalSIDToFwToolBar.find(sid) != m_globalSIDToFwToolBar.end());
198 return m_globalSIDToFwToolBar[sid];
205 OSLM_ASSERT(
"A fwMenu with the "<<sid<<
" already exists in the SID menu map.",
206 m_globalSIDToFwMenu.find(sid) == m_globalSIDToFwMenu.end());
207 m_globalSIDToFwMenu[sid] = menu;
215 OSLM_INFO_IF(
"Service "<<sid <<
" does not exist.", !service_exists );
218 ::fwServices::IService::sptr service = ::fwServices::get( sid );
219 OSLM_ASSERT(
"Service "<<sid<<
" must be stopped before unregistering the menu.", service->isStopped());
222 OSLM_ASSERT(
"No fwMenu with the sid "<<sid<<
" exists in the SID menu map.",
223 m_globalSIDToFwMenu.find(sid) != m_globalSIDToFwMenu.end());
226 m_globalSIDToFwMenu.erase(sid);
233 OSLM_ASSERT(
"No fwMenu with the sid "<<sid<<
" exists in the SID menu map.",
234 m_globalSIDToFwMenu.find(sid) != m_globalSIDToFwMenu.end());
236 return m_globalSIDToFwMenu[sid];
246 OSLM_ASSERT(
"An action with the sid " << actionSid <<
" already exists for the parent " << parentSid,
258 OSLM_ASSERT(
"No action with the sid "<<actionSid<<
" exists in the SID action map.",
265 OSLM_INFO_IF(
"Service "<<actionSid <<
" does not exist.", !service_exists );
268 ::fwServices::IService::sptr service = ::fwServices::get( actionSid );
269 OSLM_WARN_IF(
"Service "<<actionSid<<
" must be stopped before unregistering the action.",
270 !service->isStopped());
277 ParentSidsType::iterator iter =
279 OSLM_ASSERT(
"The action with the sid "<<actionSid<<
" has no parent named "<< parentSid,
293 for(std::string parentSid : parentSids)
296 OSLM_INFO_IF(
"Service "<<parentSid <<
" does not exist.", !service_exists );
299 ::fwServices::IService::sptr service = ::fwServices::get( parentSid );
300 ::fwGui::IMenuSrv::sptr menuSrv = ::fwGui::IMenuSrv::dynamicCast(service);
301 ::fwGui::IToolBarSrv::sptr toolbarSrv = ::fwGui::IToolBarSrv::dynamicCast(service);
304 menuSrv->actionServiceStopping(actionSid);
308 toolbarSrv->actionServiceStopping(actionSid);
328 for(std::string parentSid : parentSids)
331 OSLM_INFO_IF(
"Service "<<parentSid <<
" does not exist.", !service_exists );
334 ::fwServices::IService::sptr service = ::fwServices::get( parentSid );
335 ::fwGui::IMenuSrv::sptr menuSrv = ::fwGui::IMenuSrv::dynamicCast(service);
336 ::fwGui::IToolBarSrv::sptr toolbarSrv = ::fwGui::IToolBarSrv::dynamicCast(service);
339 menuSrv->actionServiceStarting(actionSid);
343 toolbarSrv->actionServiceStarting(actionSid);
363 for(std::string parentSid : parentSids)
366 OSLM_INFO_IF(
"Service "<<parentSid <<
" does not exist.", !service_exists );
369 ::fwServices::IService::sptr service = ::fwServices::get( parentSid );
370 ::fwGui::IMenuSrv::sptr menuSrv = ::fwGui::IMenuSrv::dynamicCast(service);
371 ::fwGui::IToolBarSrv::sptr toolbarSrv = ::fwGui::IToolBarSrv::dynamicCast(service);
374 menuSrv->actionServiceSetActive(actionSid, isActive);
378 toolbarSrv->actionServiceSetActive(actionSid, isActive);
398 for(std::string parentSid : parentSids)
401 OSLM_INFO_IF(
"Service "<<parentSid <<
" does not exist.", !service_exists );
404 ::fwServices::IService::sptr service = ::fwServices::get( parentSid );
405 ::fwGui::IMenuSrv::sptr menuSrv = ::fwGui::IMenuSrv::dynamicCast(service);
406 ::fwGui::IToolBarSrv::sptr toolbarSrv = ::fwGui::IToolBarSrv::dynamicCast(service);
409 menuSrv->actionServiceSetExecutable(actionSid, isExecutable);
413 toolbarSrv->actionServiceSetExecutable(actionSid, isExecutable);
432 for(std::string parentSid : parentSids)
435 OSLM_INFO_IF(
"Service "<<parentSid <<
" does not exist.", !service_exists );
438 ::fwServices::IService::sptr service = ::fwServices::get( parentSid );
439 ::fwGui::IMenuSrv::sptr menuSrv = ::fwGui::IMenuSrv::dynamicCast(service);
440 ::fwGui::IToolBarSrv::sptr toolbarSrv = ::fwGui::IToolBarSrv::dynamicCast(service);
443 menuSrv->actionServiceSetVisible(actionSid, isVisible);
447 toolbarSrv->actionServiceSetVisible(actionSid, isVisible);
static FWGUI_API::fwGui::container::fwMenuBar::sptr getSIDMenuBar(std::string sid)
Returns fwMenuBar associate with service ID.
static FWGUI_API void registerSIDToolBar(std::string sid,::fwGui::container::fwToolBar::sptr toolBar)
Registers fwToolBar associate with service ID.
static FWGUI_API void unregisterActionSIDToParentSID(std::string actionSid, std::string parentSid)
Unregisters action sid associted with a parent sid.
static FWGUI_API::fwGui::container::fwContainer::sptr getWIDContainer(std::string wid)
Returns fwContainer associate with window ID, null if not found.
static FWGUI_API void registerSIDMenu(std::string sid,::fwGui::container::fwMenu::sptr menu)
Registers fwMenu associate with service ID.
static FWGUI_API void unregisterWIDContainer(std::string wid)
Unregisters container associate with window 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.
static FWGUI_API void unregisterSIDContainer(std::string sid)
Unregisters container associate with service ID.
static FWGUI_API void actionServiceSetExecutable(std::string actionSid, bool isExecutable)
Method called when the action service is executable or not. Call parent service actionServiceSetExecu...
static FWGUI_API void registerSIDContainer(std::string sid,::fwGui::container::fwContainer::sptr container)
Registers container associate with service ID.
#define OSLM_INFO_IF(message, cond)
static FWGUI_API void unregisterSIDToolBar(std::string sid)
Unregisters fwToolBar associate with service ID.
static FWGUI_API::fwGui::container::fwContainer::sptr getSIDContainer(std::string sid)
Returns fwContainer associate with service ID, null if not found.
static FWGUI_API::fwGui::container::fwMenu::sptr getSIDMenu(std::string sid)
Returns fwMenu associate with service ID.
static FWGUI_API bool hasWIDContainer(std::string wid)
Verifies if a WID exists in the global WID container.
static FWGUI_API void registerSIDMenuBar(std::string sid,::fwGui::container::fwMenuBar::sptr menuBar)
Registers fwMenuBar associate with service ID.
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 registerWIDContainer(std::string wid,::fwGui::container::fwContainer::sptr container)
Registers container associate with window ID.
static FWGUI_API void unregisterSIDMenu(std::string sid)
Unregisters fwMenu associate with service ID.
#define SLM_FATAL(message)
FWGUI_API GuiRegistry()
Constructor.
static FWGUI_API void actionServiceSetActive(std::string actionSid, bool isActive)
Method called when the action service is activated or not. Call parent service actionServiceSetActive...
static FWGUI_API void unregisterSIDMenuBar(std::string sid)
Unregisters fwMenuBar associate with service ID.
virtual FWGUI_API ~GuiRegistry()
Destructor. Do nothing.
static FWGUI_API::fwGui::container::fwToolBar::sptr getSIDToolBar(std::string sid)
Returns fwToolBar associate with service ID.
static FWGUI_API bool hasSIDContainer(std::string sid)
Verifies if a SID exists in the global SID container.
static FWGUI_API void actionServiceSetVisible(std::string actionSid, bool isVisible)
Method called when the action service is visible or not. Call parent service actionServiceSetVisible(...
#define OSLM_WARN_IF(message, cond)
static FWGUI_API void registerActionSIDToParentSID(std::string actionSid, std::string parentSid)
Registers action sid associted with a parent sid.
static ActionToParentMapType m_actionSIDToParentSID
Parent sid can be Menu sid or ToolBar sid.
static FWGUI_API void actionServiceStarting(std::string actionSid)
Method called when the action service is starting. Call parent service actionServiceStarting() method...