fw4spl
DynamicView.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 <fwGui/view/IView.hpp>
15 
16 #include <fwGuiQt/container/QtContainer.hpp>
17 
18 #include <fwServices/IAppConfigManager.hpp>
19 
20 #include <fwTools/Failed.hpp>
21 
22 #include <QObject>
23 #include <QPointer>
24 
25 #include <map>
26 #include <set>
27 
28 class QTabWidget;
29 namespace fwData
30 {
31 class Composite;
32 }
33 namespace guiQt
34 {
35 namespace editor
36 {
37 
38 typedef const ::fwServices::IService::ConfigType ConfigType;
39 
40 struct AppConfig
41 {
42  typedef ::fwActivities::registry::ActivityAppConfigParam ParameterType;
43  typedef std::vector< ParameterType > ParametersType;
44 
45  AppConfig()
46  {
47  }
48  AppConfig(const ConfigType& config);
49 
50  std::string id;
51  std::string title;
52  std::string tabInfo;
53  bool closable;
54  ParametersType parameters;
55 };
56 
102 class GUIQT_CLASS_API DynamicView : public QObject,
103  public ::fwGui::view::IView
104 {
105 Q_OBJECT
106 
107 public:
108 
110 
112  GUIQT_API DynamicView() noexcept;
113 
115  GUIQT_API virtual ~DynamicView() noexcept;
116 
117 protected:
118 
122  virtual void starting() override;
123 
127  virtual void stopping() override;
128 
133  virtual void updating() override;
134 
140  virtual void swapping() override;
141 
146  virtual void configuring() override;
147 
148  virtual void info( std::ostream& _sstream ) override;
149 
150  typedef std::map< std::string, std::string> ReplaceMapType;
152  {
153  ::fwGuiQt::container::QtContainer::sptr container;
154  ::fwServices::IAppConfigManager::sptr helper;
155  std::string wid;
156  std::string title;
157  bool closable;
158  std::string icon;
159  std::string tooltip;
160  std::string tabID;
161  std::string viewConfigID;
162  ReplaceMapType replaceMap;
163  };
164 
165  typedef std::map< QWidget*, DynamicViewInfo > DynamicViewInfoMapType;
166 
170  void launchTab(DynamicViewInfo& info);
171 
173  void createTab(::fwActivities::registry::ActivityMsg info);
174 
178  DynamicViewInfo buildDynamicViewInfo(const AppConfig& appConfig);
179 
180  QPointer<QTabWidget> m_tabWidget;
181  QPointer<QWidget> m_currentWidget;
182 
183  std::map< std::string, unsigned int > m_titleToCount;
184  std::set< std::string > m_tabIDList;
185 
186  DynamicViewInfoMapType m_dynamicInfoMap;
187  bool m_dynamicConfigStartStop;
188 
189  AppConfig m_appConfig;
190 
191 protected Q_SLOTS:
192 
193  void closeTab( int index, bool forceClose );
194 
195  void closeTabSignal(int index);
196 
197  void changedTab(int index);
198 
199 };
200 
201 }//namespace editor
202 } // guiQt
STL namespace.
This editor manages tabs containing sub-configurations.
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.
The namespace guiQt contains the basic services to build the application IHM with Qt...
Definition: Code.hpp:21
Defines the service interface managing a view placed in main frame.
Definition: IView.hpp:23