7 #include "fwGui/registrar/ViewRegistrar.hpp" 9 #include "fwGui/GuiRegistry.hpp" 10 #include "fwGui/container/fwContainer.hpp" 11 #include "fwGui/container/fwMenuBar.hpp" 12 #include "fwGui/container/fwToolBar.hpp" 14 #include <fwServices/macros.hpp> 15 #include <fwServices/op/Get.hpp> 40 ::fwGui::container::fwContainer::sptr ViewRegistrar::getParent()
42 ::fwGui::container::fwContainer::sptr parentContainer;
43 if(!m_parentWid.empty())
46 OSLM_ASSERT(
"No fwContainer with the wid '"<< m_parentWid <<
"' exists in the WID container map.",
52 OSLM_ASSERT(
"No fwContainer with the sid '"<<
m_sid <<
"' exists in the SID container map.", parentContainer );
54 return parentContainer;
59 void ViewRegistrar::setParent(std::string wid)
61 OSLM_ASSERT(
"This method is available only if this container has a WID parent container", !m_parentWid.empty());
69 OSLM_ASSERT(
"Bad configuration name "<<configuration->getName()<<
", must be viewRegistrar",
70 configuration->getName() ==
"registry");
73 std::vector < ConfigurationType > vectParent = configuration->find(
"parent");
74 if(!vectParent.empty())
76 ConfigurationType parent = vectParent.at(0);
77 SLM_ASSERT(
"<parent> tag must have wid attribute", parent->hasAttribute(
"wid"));
78 m_parentWid = parent->getAttributeValue(
"wid");
82 unsigned int index = 0;
84 std::vector < ConfigurationType > vectViews = configuration->find(
"view");
85 std::vector < ConfigurationType > vectSlideViews = configuration->find(
"slideView");
86 std::copy(vectSlideViews.begin(), vectSlideViews.end(), std::back_inserter(vectViews));
88 for( ConfigurationType view : vectViews)
90 SLM_ASSERT(
"<view> tag must have sid or wid attribute",
91 view->hasAttribute(
"sid") || view->hasAttribute(
"wid"));
92 if(view->hasAttribute(
"sid"))
95 if(view->hasAttribute(
"start"))
97 std::string startValue = view->getAttributeValue(
"start");
98 SLM_ASSERT(
"Wrong value '"<< startValue <<
"' for 'start' attribute (require yes or no)",
99 startValue ==
"yes" || startValue ==
"no");
100 start = (startValue ==
"yes");
102 std::string sid = view->getAttributeValue(
"sid");
103 m_sids[sid] = SIDContainerMapType::mapped_type(index, start);
105 else if(view->hasAttribute(
"wid"))
107 std::string wid = view->getAttributeValue(
"wid");
114 std::vector < ConfigurationType > vectmenuBar = configuration->find(
"menuBar");
115 if(!vectmenuBar.empty())
117 ConfigurationType menuBarCfg = vectmenuBar.at(0);
118 if (menuBarCfg->hasAttribute(
"sid"))
121 if (menuBarCfg->hasAttribute(
"start"))
123 std::string startValue = menuBarCfg->getAttributeValue(
"start");
124 SLM_ASSERT(
"Wrong value '"<< startValue <<
"' for 'start' attribute (require yes or no)",
125 startValue ==
"yes" || startValue ==
"no");
126 start = (startValue ==
"yes");
128 std::string sid = menuBarCfg->getAttributeValue(
"sid");
134 std::vector < ConfigurationType > vectToolBar = configuration->find(
"toolBar");
135 if(!vectToolBar.empty())
137 ConfigurationType toolBarCfg = vectToolBar.at(0);
138 if (toolBarCfg->hasAttribute(
"sid"))
141 if (toolBarCfg->hasAttribute(
"start"))
143 std::string startValue = toolBarCfg->getAttributeValue(
"start");
144 SLM_ASSERT(
"Wrong value '"<< startValue <<
"' for 'start' attribute (require yes or no)",
145 startValue ==
"yes" || startValue ==
"no");
146 start = (startValue ==
"yes");
148 std::string sid = toolBarCfg->getAttributeValue(
"sid");
158 ::fwGui::container::fwContainer::sptr container;
159 for( SIDContainerMapType::value_type sid :
m_sids)
161 OSLM_ASSERT(
"Container index "<< sid.second.first <<
" is bigger than subViews size!",
162 sid.second.first < subViews.size());
163 container = subViews.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() );
175 for( WIDContainerMapType::value_type wid :
m_wids)
177 OSLM_ASSERT(
"Container index "<< wid.second <<
" is bigger than subViews size!", wid.second < subViews.size());
178 container = subViews.at( wid.second );
191 ::fwServices::IService::sptr service = ::fwServices::get(
m_menuBarSid.first );
204 ::fwServices::IService::sptr service = ::fwServices::get(
m_toolBarSid.first );
213 for( SIDContainerMapType::value_type sid :
m_sids)
215 if(sid.second.second)
218 ::fwServices::IService::sptr service = ::fwServices::get( sid.first );
225 for( WIDContainerMapType::value_type wid :
m_wids)
241 ::fwServices::IService::sptr service = ::fwServices::get(
m_toolBarSid.first );
258 ::fwServices::IService::sptr service = ::fwServices::get(
m_menuBarSid.first );
static FWGUI_API void registerSIDToolBar(std::string sid,::fwGui::container::fwToolBar::sptr toolBar)
Registers fwToolBar associate with service ID.
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 unregisterWIDContainer(std::string wid)
Unregisters container associate with window ID.
virtual FWGUI_API void unmanage()
Stopping view manager. All services managed in local subViews will be stopped.
#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.
SIDToolBarPairType m_toolBarSid
Tool bar service ID associate with this ViewRegistrar.
std::string m_sid
Main service ID associate with this ViewRegistrar.
static FWGUI_API void unregisterSIDContainer(std::string sid)
Unregisters container associate with service ID.
static FWGUI_API void registerSIDContainer(std::string sid,::fwGui::container::fwContainer::sptr container)
Registers container associate with service ID.
static FWGUI_API void unregisterSIDToolBar(std::string sid)
Unregisters fwToolBar associate with service ID.
SIDContainerMapType m_sids
All services ID managed and associated with pair containing: subViews index vector and boolean descri...
static FWGUI_API::fwGui::container::fwContainer::sptr getSIDContainer(std::string sid)
Returns fwContainer associate with service ID, null if not found.
static FWGUI_API void registerSIDMenuBar(std::string sid,::fwGui::container::fwMenuBar::sptr menuBar)
Registers fwMenuBar associate with service ID.
virtual FWGUI_API void unmanageMenuBar()
Stopping view manager. MenuBar service will be stopped.
static FWGUI_API void registerWIDContainer(std::string wid,::fwGui::container::fwContainer::sptr container)
Registers container associate with window ID.
FWGUI_API ViewRegistrar(const std::string &sid)
Constructor.
virtual FWGUI_API void manageMenuBar(std::shared_ptr< ::fwGui::container::fwMenuBar > menuBar)
Register menu bar. If start="yes" in configuration the menu bar services will be started.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
WIDContainerMapType m_wids
All windows containers ID managed (and associated with subViews index vector).
static FWGUI_API void unregisterSIDMenuBar(std::string sid)
Unregisters fwMenuBar associate with service ID.
#define SLM_TRACE(message)
virtual FWGUI_API ~ViewRegistrar()
Destructor. Do nothing.
SIDMenuBarPairType m_menuBarSid
Menu bar service ID associate with this ViewRegistrar.
virtual FWGUI_API void initialize(::fwRuntime::ConfigurationElement::sptr configuration)
Initialize managers.
virtual FWGUI_API void manage(std::vector< std::shared_ptr< ::fwGui::container::fwContainer > > subViews)
Starting view manager. All services managed in local subViews and with start="yes" in configuration w...
virtual FWGUI_API void unmanageToolBar()
Stopping view manager. ToolBar service will be stopped.
virtual FWGUI_API void manageToolBar(std::shared_ptr< ::fwGui::container::fwToolBar > toolBar)
Register tool bar. If start="yes" in configuration the tool bar services will be started.