7 #include "fwGui/IMenuSrv.hpp" 9 #include "fwGui/IActionSrv.hpp" 10 #include "fwGui/IMenuItemCallback.hpp" 12 #include <fwServices/macros.hpp> 13 #include <fwServices/op/Get.hpp> 14 #include <fwServices/registry/ActiveWorkers.hpp> 16 #include <fwThread/Worker.hpp> 17 #include <fwThread/Worker.hxx> 19 #include <fwTools/fwID.hpp> 24 IMenuSrv::IMenuSrv() :
39 m_registrar = ::fwGui::registrar::MenuRegistrar::New(this->getID());
41 std::vector < ConfigurationType > vectRegistrar = m_configuration->find(
"registry");
42 SLM_ASSERT(
"Registry section is mandatory.", !vectRegistrar.empty() );
44 if(!vectRegistrar.empty())
46 m_registrarConfig = vectRegistrar.at(0);
47 m_registrar->initialize(m_registrarConfig);
51 std::vector < ConfigurationType > vectGui = m_configuration->find(
"gui");
52 SLM_ASSERT(
"Gui section is mandatory.", !vectGui.empty() );
56 std::vector < ConfigurationType > vectLayoutMng = vectGui.at(0)->find(
"layout");
57 SLM_ASSERT(
"Layout section is mandatory.", !vectLayoutMng.empty() );
58 if(!vectLayoutMng.empty())
60 m_layoutConfig = vectLayoutMng.at(0);
61 this->initializeLayoutManager(m_layoutConfig);
63 if (m_layoutConfig->hasAttribute(
"hideAction"))
65 std::string hideActions = m_layoutConfig->getAttributeValue(
"hideActions");
66 SLM_ASSERT(
"'hideActions' attribute value must be 'true' or 'false'",
67 hideActions ==
"true" || hideActions ==
"false");
68 m_hideActions = (hideActions ==
"true");
78 ::fwGui::container::fwMenu::sptr menu = m_registrar->getParent();
79 std::vector< ::fwGui::IMenuItemCallback::sptr > callbacks = m_registrar->getCallbacks();
82 m_layoutManager->setCallbacks(callbacks);
86 m_layoutManager->createLayout(menu);
89 m_registrar->manage(m_layoutManager->getMenuItems());
90 m_registrar->manage(m_layoutManager->getMenus());
97 m_registrar->unmanage();
100 m_layoutManager->destroyLayout();
108 ::fwGui::container::fwMenuItem::sptr menuItem = m_registrar->getFwMenuItem(actionSrvSID,
109 m_layoutManager->getMenuItems());
115 m_layoutManager->menuItemSetVisible(menuItem,
false);
122 m_layoutManager->menuItemSetEnabled(menuItem,
false);
131 ::fwGui::container::fwMenuItem::sptr menuItem = m_registrar->getFwMenuItem(actionSrvSID,
132 m_layoutManager->getMenuItems());
138 m_layoutManager->menuItemSetVisible(menuItem,
true);
143 ::fwServices::IService::sptr service = ::fwServices::get( actionSrvSID );
144 ::fwGui::IActionSrv::sptr actionSrv = ::fwGui::IActionSrv::dynamicCast(service);
148 m_layoutManager->menuItemSetEnabled(menuItem, actionSrv->getIsExecutable());
149 m_layoutManager->menuItemSetChecked(menuItem, actionSrv->getIsActive());
150 m_layoutManager->menuItemSetVisible(menuItem, actionSrv->isVisible());
159 ::fwGui::container::fwMenuItem::sptr menuItem = m_registrar->getFwMenuItem(actionSrvSID,
160 m_layoutManager->getMenuItems());
164 m_layoutManager->menuItemSetChecked(menuItem, isActive);
172 ::fwGui::container::fwMenuItem::sptr menuItem = m_registrar->getFwMenuItem(actionSrvSID,
173 m_layoutManager->getMenuItems());
177 m_layoutManager->menuItemSetEnabled(menuItem, isExecutable);
185 ::fwGui::container::fwMenuItem::sptr menuItem = m_registrar->getFwMenuItem(actionSrvSID,
186 m_layoutManager->getMenuItems());
190 m_layoutManager->menuItemSetVisible(menuItem, isVisible);
196 void IMenuSrv::initializeLayoutManager(ConfigurationType layoutConfig)
198 OSLM_ASSERT(
"Bad configuration name "<<layoutConfig->getName()<<
", must be layout",
199 layoutConfig->getName() ==
"layout");
201 ::fwGui::GuiBaseObject::sptr guiObj = ::fwGui::factory::New(
202 ::fwGui::layoutManager::IMenuLayoutManager::REGISTRY_KEY);
203 m_layoutManager = ::fwGui::layoutManager::IMenuLayoutManager::dynamicCast(guiObj);
204 OSLM_ASSERT(
"ClassFactoryRegistry failed for class "<< ::fwGui::layoutManager::IMenuLayoutManager::REGISTRY_KEY,
207 m_layoutManager->initialize(layoutConfig);
#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_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
static FWSERVICES_API::fwThread::Worker::sptr getDefaultWorker()
Get the default registered worker.