fw4spl
fwRenderQt/include/fwRenderQt/SRender.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 "fwRenderQt/config.hpp"
10 #include "fwRenderQt/data/Axis.hpp"
11 #include "fwRenderQt/data/Coord.hpp"
12 #include "fwRenderQt/data/Event.hpp"
13 #include "fwRenderQt/data/Viewport.hpp"
14 
15 #include <fwCom/helper/SigSlotConnection.hpp>
16 
17 #include <fwRender/IRender.hpp>
18 
19 #include <fwServices/helper/Config.hpp>
20 
21 #include <QGraphicsScene>
22 #include <QGraphicsView>
23 #include <QResizeEvent>
24 #include <Qt>
25 
26 #include <map>
27 
28 namespace fwRenderQt
29 {
30 // Not declared in the #include because of mutual inclusion.
31 class Scene2DGraphicsView;
32 
33 // Not declared in the #include because of mutual inclusion.
34 class IAdaptor;
35 
82 class FWRENDERQT_CLASS_API SRender : public ::fwRender::IRender
83 {
84 
85 public:
86 
88 
90  typedef std::string AdaptorIDType;
91 
93  typedef std::string ObjectIDType;
94 
96  typedef float AdaptorZValueType;
97 
100  FWRENDERQT_API SRender() noexcept;
101 
103  FWRENDERQT_API virtual ~SRender() noexcept;
104 
106  FWRENDERQT_API QGraphicsScene* getScene() const;
107 
109  FWRENDERQT_API Scene2DGraphicsView* getView() const;
110 
112  FWRENDERQT_API ::fwRenderQt::data::Viewport::sptr getViewport() const;
113 
115  FWRENDERQT_API ::fwRenderQt::data::Axis::sptr getAxis(const std::string& id) const;
116 
119  FWRENDERQT_API void dispatchInteraction(::fwRenderQt::data::Event& _event );
120 
122  FWRENDERQT_API ::fwRenderQt::data::Coord mapToScene( const ::fwRenderQt::data::Coord& coord ) const;
123 
125  FWRENDERQT_API Qt::AspectRatioMode getAspectRatioMode() const;
126 
128  FWRENDERQT_API void updateSceneSize( float ratioPercent = 0 );
129 
130 protected:
131 
133  FWRENDERQT_API void configuring() override;
134 
138  FWRENDERQT_API void starting() override;
139 
141  FWRENDERQT_API void updating() override;
142 
143  FWRENDERQT_API void swapping() override;
144 
146  FWRENDERQT_API void swapping(const KeyType& key) override;
147 
151  FWRENDERQT_API void stopping() override;
152 
153 private:
154 
156  typedef SPTR (::fwRuntime::ConfigurationElement) ConfigurationType;
157 
159  void startContext();
160 
162  void stopContext();
163 
165  void configureAxis ( ConfigurationType _conf );
166 
168  void configureViewport ( ConfigurationType _conf );
169 
171  void configureScene( ConfigurationType _conf );
172 
176  void configureAdaptor ( ConfigurationType _conf );
177 
178  typedef std::map< AdaptorZValueType, AdaptorIDType > ZValue2AdaptorID;
179 
181  ZValue2AdaptorID m_zValue2AdaptorID;
182 
183  std::map<std::string, ::fwRenderQt::data::Axis::sptr > m_axisMap;
184 
186  ConfigurationType m_sceneConfiguration;
187 
189  ::fwRenderQt::data::Coord m_sceneStart;
190 
192  ::fwRenderQt::data::Coord m_sceneWidth;
193 
195  QGraphicsScene* m_scene;
196 
198  Scene2DGraphicsView* m_view;
199 
200  ::fwRenderQt::data::Viewport::sptr m_viewport;
201 
203  bool m_antialiasing;
204 
206  std::string m_background;
207 
209  Qt::AspectRatioMode m_aspectRatioMode;
210 };
211 
212 } // namespace fwRenderQt
#define SPTR(_cls_)
std::string AdaptorIDType
A string type representing adaptors id.
STL namespace.
Defines the service interface managing the rendering service for object.
Definition: IRender.hpp:36
The namespace fwRuntime contains classes to manage bundle, configuration element, extension point in ...
std::string ObjectIDType
A string type representing objects id.
#define fwCoreServiceClassDefinitionsMacro(_classinfo_)
Generate common code for services classes.
The namespace fwRenderQt contains classes for rendering with Qt.
Definition: Axis.hpp:12
float AdaptorZValueType
A float type representing adaptors zValue.