fw4spl
SDynamicView.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
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 #pragma once
8 
9 #include "guiQt/config.hpp"
10 
11 #include <fwActivities/registry/Activities.hpp>
12 #include <fwActivities/registry/ActivityMsg.hpp>
13 
14 #include <fwCom/Signal.hpp>
15 #include <fwCom/Signals.hpp>
16 #include <fwCom/Slot.hpp>
17 #include <fwCom/Slots.hpp>
18 
19 #include <fwGui/view/IActivityView.hpp>
20 
21 #include <fwGuiQt/container/QtContainer.hpp>
22 
23 #include <fwMedData/ActivitySeries.hpp>
24 
25 #include <fwServices/IAppConfigManager.hpp>
26 
27 #include <fwTools/Failed.hpp>
28 
29 #include <QObject>
30 #include <QPointer>
31 
32 #include <map>
33 #include <set>
34 
35 class QTabWidget;
36 namespace fwData
37 {
38 class Composite;
39 }
40 namespace guiQt
41 {
42 namespace editor
43 {
44 
88 class GUIQT_CLASS_API SDynamicView : public QObject,
90 {
91 Q_OBJECT
92 
93 public:
94 
96 
98  GUIQT_API SDynamicView() noexcept;
99 
101 
102  GUIQT_API virtual ~SDynamicView() noexcept;
103 
104  typedef ::fwCom::Signal< void ( ::fwData::Object::sptr ) > ActivitySelectedSignalType;
105  GUIQT_API static const ::fwCom::Signals::SignalKeyType s_ACTIVITY_SELECTED_SIG;
106  typedef ::fwCom::Signal< void () > NothingSelectedSignalType;
107  GUIQT_API static const ::fwCom::Signals::SignalKeyType s_NOTHING_SELECTED_SIG;
108 protected:
109 
113  virtual void starting() override;
114 
118  virtual void stopping() override;
119 
124  virtual void updating() override;
125 
131  virtual void swapping() override;
132 
137  virtual void configuring() override;
138 
139  virtual void info( std::ostream& _sstream ) override;
140 
141 private:
142 
143  typedef std::set< std::string > ActivityIdType;
144 
145  struct SDynamicViewInfo
146  {
147  ::fwGuiQt::container::QtContainer::sptr container;
148  ::fwServices::IAppConfigManager::sptr helper;
149  std::string wid;
150  std::string title;
151  bool closable;
152  std::string icon;
153  std::string tooltip;
154  std::string tabID;
155  std::string viewConfigID;
156  ReplaceMapType replaceMap;
157  ::fwMedData::ActivitySeries::sptr activitySeries;
158  };
159 
160  typedef std::map< QWidget*, SDynamicViewInfo > SDynamicViewInfoMapType;
161 
165  void launchTab(SDynamicViewInfo& info);
166 
171  virtual void launchActivity(::fwMedData::ActivitySeries::sptr activitySeries) override;
172 
174  void createTab(::fwActivities::registry::ActivityMsg info);
175 
177  virtual void buildMainActivity();
178 
180  SDynamicViewInfo createViewInfo(::fwMedData::ActivitySeries::sptr activitySeries);
181 
187  void closeTab( int index, bool forceClose );
188 
189 protected Q_SLOTS:
190 
192  void closeTabSignal(int index);
193 
195  void changedTab(int index);
196 
197 private:
198 
199  std::map< std::string, unsigned int > m_titleToCount;
200  std::set< std::string > m_tabIDList;
201 
202  ActivityIdType m_activityIds;
203 
204  SDynamicViewInfoMapType m_dynamicInfoMap;
205  bool m_dynamicConfigStartStop;
206 
207  QPointer<QTabWidget> m_tabWidget;
208  QPointer<QWidget> m_currentWidget;
209 
210  ActivitySelectedSignalType::sptr m_sigActivitySelected;
211  NothingSelectedSignalType::sptr m_sigNothingSelected;
212 
213  bool m_mainActivityClosable;
214 };
215 
216 } //namespace editor
217 } // guiQt
This editor manages tabs containing activities.
Namespace containing fw4spl communication tools.
Definition: DumpEditor.hpp:30
STL namespace.
Activity information sent by signal to launch new activities in a tab.
Definition: ActivityMsg.hpp:25
#define fwCoreServiceClassDefinitionsMacro(_classinfo_)
Generate common code for services classes.
Contains the representation of the data objects used in the framework.
Defines the base class for services displaying activity view.
The namespace guiQt contains the basic services to build the application IHM with Qt...
Definition: Code.hpp:21