7 #include "fwGui/IToolBarSrv.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 IToolBarSrv::IToolBarSrv() :
31 IToolBarSrv::~IToolBarSrv()
39 m_registrar = ::fwGui::registrar::ToolBarRegistrar::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() );
57 std::vector < ConfigurationType > vectLayoutMng = vectGui.at(0)->find(
"layout");
58 SLM_ASSERT(
"layout section is mandatory.", !vectLayoutMng.empty() );
60 if(!vectLayoutMng.empty())
62 m_layoutConfig = vectLayoutMng.at(0);
63 this->initializeLayoutManager(m_layoutConfig);
65 if (m_layoutConfig->hasAttribute(
"hideAction"))
67 std::string hideActions = m_layoutConfig->getAttributeValue(
"hideActions");
68 SLM_ASSERT(
"'hideActions' attribute value must be 'true' or 'false'",
69 hideActions ==
"true" || hideActions ==
"false");
70 m_hideActions = (hideActions ==
"true");
80 ::fwGui::container::fwToolBar::sptr toolBar = m_registrar->getParent();
81 std::vector< ::fwGui::IMenuItemCallback::sptr > callbacks = m_registrar->getCallbacks();
83 SLM_ASSERT(
"Parent toolBar is unknown.", toolBar);
84 m_layoutManager->setCallbacks(callbacks);
88 m_layoutManager->createLayout(toolBar);
91 m_registrar->manage(m_layoutManager->getMenuItems());
92 m_registrar->manage(m_layoutManager->getMenus());
93 m_registrar->manage(m_layoutManager->getContainers());
100 m_registrar->unmanage();
104 m_layoutManager->destroyLayout();
112 ::fwGui::container::fwMenuItem::sptr menuItem = m_registrar->getFwMenuItem(actionSrvSID,
113 m_layoutManager->getMenuItems());
119 m_layoutManager->menuItemSetVisible(menuItem,
false);
126 m_layoutManager->menuItemSetEnabled(menuItem,
false);
135 ::fwGui::container::fwMenuItem::sptr menuItem = m_registrar->getFwMenuItem(actionSrvSID,
136 m_layoutManager->getMenuItems());
142 m_layoutManager->menuItemSetVisible(menuItem,
true);
147 ::fwServices::IService::sptr service = ::fwServices::get( actionSrvSID );
148 ::fwGui::IActionSrv::sptr actionSrv = ::fwGui::IActionSrv::dynamicCast(service);
152 m_layoutManager->menuItemSetEnabled(menuItem, actionSrv->getIsExecutable());
153 m_layoutManager->menuItemSetChecked(menuItem, actionSrv->getIsActive());
154 m_layoutManager->menuItemSetVisible(menuItem, actionSrv->isVisible());
163 ::fwGui::container::fwMenuItem::sptr menuItem = m_registrar->getFwMenuItem(actionSrvSID,
164 m_layoutManager->getMenuItems());
168 m_layoutManager->menuItemSetChecked(menuItem, isActive);
176 ::fwGui::container::fwMenuItem::sptr menuItem = m_registrar->getFwMenuItem(actionSrvSID,
177 m_layoutManager->getMenuItems());
181 m_layoutManager->menuItemSetEnabled(menuItem, isExecutable);
189 ::fwGui::container::fwMenuItem::sptr menuItem = m_registrar->getFwMenuItem(actionSrvSID,
190 m_layoutManager->getMenuItems());
194 m_layoutManager->menuItemSetVisible(menuItem, isVisible);
200 void IToolBarSrv::initializeLayoutManager(ConfigurationType layoutConfig)
202 OSLM_ASSERT(
"Bad configuration name "<<layoutConfig->getName()<<
", must be layout",
203 layoutConfig->getName() ==
"layout");
205 ::fwGui::GuiBaseObject::sptr guiObj = ::fwGui::factory::New(
206 ::fwGui::layoutManager::IToolBarLayoutManager::REGISTRY_KEY);
207 m_layoutManager = ::fwGui::layoutManager::IToolBarLayoutManager::dynamicCast(guiObj);
208 OSLM_ASSERT(
"ClassFactoryRegistry failed for class "<< ::fwGui::layoutManager::IToolBarLayoutManager::REGISTRY_KEY,
211 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.