fw4spl
ISlideViewBuilder.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2016.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 
8 #include "fwGui/builder/ISlideViewBuilder.hpp"
9 
10 #include <boost/lexical_cast.hpp>
11 
12 namespace fwGui
13 {
14 namespace builder
15 {
16 
17 const ISlideViewBuilder::RegistryKeyType ISlideViewBuilder::REGISTRY_KEY = "::fwGui::SlideViewBuilder";
18 
19 //-----------------------------------------------------------------------------
20 
22  m_size(200),
23  m_opacity(1.),
24  m_aligment(LEFT)
25 {
26 }
27 
28 //-----------------------------------------------------------------------------
29 
31 {
32 }
33 
34 //-----------------------------------------------------------------------------
35 
36 void ISlideViewBuilder::initialize( ::fwRuntime::ConfigurationElement::sptr configuration)
37 {
38  SLM_ASSERT("Bad configuration name " + configuration->getName() + ", must be 'slideView'",
39  configuration->getName() == "slideView");
40 
41 
42  if (configuration->hasAttribute("align"))
43  {
44  std::string aligment = configuration->getExistingAttributeValue("align");
45  if (aligment == "top")
46  {
47  m_aligment = TOP;
48  }
49  else if (aligment == "bottom")
50  {
51  m_aligment = BOTTOM;
52  }
53  else if (aligment == "right")
54  {
55  m_aligment = RIGHT;
56  }
57  else if (aligment == "left")
58  {
59  m_aligment = LEFT;
60  }
61  else
62  {
63  SLM_FATAL("Wrong value '"+ aligment +"' for 'align' attribute (require top, bottom, right or left)");
64  }
65  }
66 
67  if (configuration->hasAttribute("opacity"))
68  {
69  std::string opacity = configuration->getExistingAttributeValue("opacity");
70  m_opacity = std::stod(opacity);
71  SLM_ASSERT("Opacity must be in [0 - 1]; actual: " + opacity, m_opacity >= 0. && m_opacity <= 1.);
72  }
73 
74  if (configuration->hasAttribute("size"))
75  {
76  std::string size = configuration->getExistingAttributeValue("size");
77  m_size = std::stoi(size);
78  SLM_ASSERT("Size must not be negative", m_size >= 0.);
79  }
80 
81  ::fwRuntime::ConfigurationElement::csptr styleCfg = configuration->findConfigurationElement("styleSheet");
82  if (styleCfg)
83  {
84  m_styleSheet = styleCfg->getValue();
85  }
86 }
87 
88 //-----------------------------------------------------------------------------
89 
90 ::fwGui::container::fwContainer::sptr ISlideViewBuilder::getContainer() const
91 {
92  return m_container;
93 }
94 
95 //-----------------------------------------------------------------------------
96 
97 } // namespace builder
98 } // namespace fwGui
The namespace fwGui contains the base interface for IHM services.
Definition: SJobBar.hpp:23
virtual FWGUI_API::fwGui::container::fwContainer::sptr getContainer() const
Returns the builded tool bar.
virtual FWGUI_API void initialize(::fwRuntime::ConfigurationElement::sptr configuration)
Initialize the tool bar.
#define SLM_FATAL(message)
Definition: spyLog.hpp:283
virtual FWGUI_API ~ISlideViewBuilder()
Destructor. Do nothing.
#define SLM_ASSERT(message, cond)
work like &#39;assert&#39; from &#39;cassert&#39;, with in addition a message logged by spylog (with FATAL loglevel) ...
Definition: spyLog.hpp:308
FWGUI_API ISlideViewBuilder()
Constructor. Do nothing.