fw4spl
vtkSimpleMesh/include/vtkSimpleMesh/SRenderer.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-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 #ifndef __VTKSIMPLEMESH_SRENDERER_HPP__
8 #define __VTKSIMPLEMESH_SRENDERER_HPP__
9 
10 #include "vtkSimpleMesh/config.hpp"
11 
12 #include <fwRender/IRender.hpp>
13 
14 #include <fwRenderVTK/IVtkRenderWindowInteractorManager.hpp>
15 
16 #include <boost/shared_array.hpp>
17 
18 #include <vtkCommand.h>
19 #include <vtkSmartPointer.h>
20 
21 // VTK
22 class vtkRenderer;
23 class vtkPolyData;
24 class vtkPolyDataMapper;
25 
26 namespace vtkSimpleMesh
27 {
28 
57 class VTKSIMPLEMESH_CLASS_API SRenderer : public fwRender::IRender
58 {
59 public:
60 
62 
63  typedef ::boost::shared_array< double > SharedArray;
64 
65  VTKSIMPLEMESH_API static const ::fwCom::Slots::SlotKeyType s_UPDATE_CAM_POSITION_SLOT;
66  VTKSIMPLEMESH_API static const ::fwCom::Slots::SlotKeyType s_INIT_PIPELINE_SLOT;
67  VTKSIMPLEMESH_API static const ::fwCom::Slots::SlotKeyType s_UPDATE_PIPELINE_SLOT;
68 
69  VTKSIMPLEMESH_API static const ::fwCom::Signals::SignalKeyType s_CAM_UPDATED_SIG;
70  typedef ::fwCom::Signal< void (SharedArray, SharedArray, SharedArray) > CamUpdatedSignalType;
71 
75  VTKSIMPLEMESH_API SRenderer() noexcept;
76 
80  VTKSIMPLEMESH_API virtual ~SRenderer() noexcept;
81 
83  void notifyCamPositionUpdated();
84 
92  VTKSIMPLEMESH_API virtual KeyConnectionsMap getAutoConnections() const override;
93 
94 protected:
95 
102  VTKSIMPLEMESH_API virtual void starting() override;
103 
107  VTKSIMPLEMESH_API virtual void configuring() override;
108 
114  VTKSIMPLEMESH_API virtual void stopping() override;
115 
122  VTKSIMPLEMESH_API virtual void updating() override;
123 
125  vtkRenderer* m_render;
126 
127 private:
128 
130  ::fwRenderVTK::IVtkRenderWindowInteractorManager::sptr m_interactorManager;
131 
133  void initVTKPipeline();
134 
139  void updateVTKPipeline(bool resetCamera = true);
140 
142  void updateCamPosition(SharedArray positionValue,
143  SharedArray focalValue,
144  SharedArray viewUpValue);
145 
147  void initPipeline();
148 
150  void updatePipeline();
151 
156  bool m_bPipelineIsInit;
157 
158  vtkCommand* m_loc;
159 
161  CamUpdatedSignalType::sptr m_sigCamUpdated;
162 
164  vtkSmartPointer<vtkPolyData> m_vtkPolyData;
165 
167  vtkSmartPointer<vtkPolyDataMapper> m_mapper;
168 
170  ::fwCore::HiResTimer m_hiResTimer;
171 };
172 
173 }
174 
175 #endif /* __VTKSIMPLEMESH_SRENDERER_HPP__ */
Service rendering a fwData::Mesh using VTK.
This class is a helper to define the connections of a service and its data.
Definition: IService.hpp:454
This namespace fwCore provides common foundations for FW4SPL.
Definition: BaseObject.hpp:16
Defines the service interface managing the rendering service for object.
Definition: IRender.hpp:36
The namespace vtkSimpleMesh contains a service which renders one mesh (fwData::Mesh).
#define fwCoreServiceClassDefinitionsMacro(_classinfo_)
Generate common code for services classes.
The namespace fwRenderVTK contains classes for rendering with VTK.