fw4spl
SlideViewBuilder.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2016-2017.
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 #include "fwGuiQt/builder/SlideViewBuilder.hpp"
8 
9 #include "fwGuiQt/container/QtContainer.hpp"
10 #include <fwGuiQt/widget/SlideBar.hpp>
11 
12 #include <fwGui/registry/macros.hpp>
13 
14 #include <QWidget>
15 
16 fwGuiRegisterMacro( ::fwGui::builder::SlideViewBuilder, ::fwGui::builder::ISlideViewBuilder::REGISTRY_KEY);
17 
18 namespace fwGui
19 {
20 namespace builder
21 {
22 
23 //-----------------------------------------------------------------------------
24 
25 SlideViewBuilder::SlideViewBuilder(::fwGui::GuiBaseObject::Key key)
26 {
27 }
28 
29 //-----------------------------------------------------------------------------
30 
31 SlideViewBuilder::~SlideViewBuilder()
32 {
33 }
34 
35 //-----------------------------------------------------------------------------
36 
37 void SlideViewBuilder::createContainer( ::fwGui::container::fwContainer::sptr parent )
38 {
39  m_parent = ::fwGuiQt::container::QtContainer::dynamicCast(parent);
40  SLM_ASSERT("The parent container is not a QtContainer", m_parent);
41 
42  QWidget* qtParent = m_parent->getQtContainer();
43 
44  ::fwGuiQt::widget::SlideBar::Aligment align = ::fwGuiQt::widget::SlideBar::LEFT;
45  switch (m_aligment)
46  {
47  case ISlideViewBuilder::LEFT:
48  align = ::fwGuiQt::widget::SlideBar::LEFT;
49  break;
50  case ISlideViewBuilder::RIGHT:
51  align = ::fwGuiQt::widget::SlideBar::RIGHT;
52  break;
53  case ISlideViewBuilder::TOP:
54  align = ::fwGuiQt::widget::SlideBar::TOP;
55  break;
56  case ISlideViewBuilder::BOTTOM:
57  align = ::fwGuiQt::widget::SlideBar::BOTTOM;
58  break;
59  default:
60  SLM_ASSERT("Alignement not managed", false);
61  break;
62  }
63 
64  ::fwGuiQt::widget::SlideBar* slideBar = new ::fwGuiQt::widget::SlideBar(qtParent, align, m_size, m_opacity);
65  if (!m_styleSheet.empty())
66  {
67  slideBar->setStyleSheet(QString::fromStdString(m_styleSheet));
68  }
69 
70  ::fwGuiQt::container::QtContainer::sptr qtContainer = ::fwGuiQt::container::QtContainer::New();
71  qtContainer->setQtContainer(slideBar);
72 
73  m_container = qtContainer;
74 }
75 
76 //-----------------------------------------------------------------------------
77 
79 {
80  SLM_ASSERT("The Container is not initialized", m_container);
81 
82  m_container->destroyContainer();
83 }
84 
85 //-----------------------------------------------------------------------------
86 
87 } // namespace builder
88 } // namespace fwGui
The namespace fwGui contains the base interface for IHM services.
Definition: SJobBar.hpp:23
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
This class allows to display a slide widget. The slide widget can be displayed over all the applicati...
Definition: SlideBar.hpp:27
Defines the qt implementation of the slide view builder.
#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
virtual FWGUIQT_API void destroyContainer() override
Destroy local layout with sub containers.
virtual FWGUIQT_API void createContainer(::fwGui::container::fwContainer::sptr parent) override
Create the slide view container.