fw4spl
RendererService.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 "vtkCompositeMesh/config.hpp"
10 
11 #include <fwData/Image.hpp>
12 
13 #include <fwRender/IRender.hpp>
14 
15 #include <fwRenderVTK/IVtkRenderWindowInteractorManager.hpp>
16 
17 #include <boost/shared_array.hpp>
18 
19 #include <vtkCommand.h>
20 
21 // VTK
22 class vtkRenderer;
23 class vtkPolyDataNormals;
24 
25 namespace vtkCompositeMesh
26 {
27 
35 class VTKCOMPOSITEMESH_CLASS_API RendererService : public ::fwRender::IRender
36 {
37 public:
38 
40 
41  typedef ::boost::shared_array< double > SharedArray;
42 
43  VTKCOMPOSITEMESH_API static const ::fwCom::Slots::SlotKeyType s_UPDATE_CAM_POSITION_SLOT;
44  typedef ::fwCom::Slot<void (SharedArray, SharedArray, SharedArray)> UpdateCamPositionSlotType;
45 
47  VTKCOMPOSITEMESH_API static const ::fwCom::Slots::SlotKeyType s_UPDATE_PIPELINE_SLOT;
48  typedef ::fwCom::Slot<void ()> UpdatePipelineSlotType;
49 
50  VTKCOMPOSITEMESH_API static const ::fwCom::Signals::SignalKeyType s_CAM_UPDATED_SIG;
51  typedef ::fwCom::Signal< void (SharedArray, SharedArray, SharedArray) > CamUpdatedSignalType;
52 
56  VTKCOMPOSITEMESH_API RendererService() noexcept;
57 
61  VTKCOMPOSITEMESH_API virtual ~RendererService() noexcept;
62 
64  void notifyCamPositionUpdated();
65 
72  VTKCOMPOSITEMESH_API virtual KeyConnectionsType getObjSrvConnections() const override;
73 
74 protected:
75 
82  VTKCOMPOSITEMESH_API virtual void starting() override;
83 
93  VTKCOMPOSITEMESH_API virtual void configuring() override;
94 
100  VTKCOMPOSITEMESH_API virtual void stopping() override;
101 
108  VTKCOMPOSITEMESH_API virtual void updating() override;
109 
111  vtkRenderer* m_render;
112 
113 private:
114 
116  ::fwRenderVTK::IVtkRenderWindowInteractorManager::sptr m_interactorManager;
117 
119  void createAndAddActorToRender();
120 
122  void initVTKPipeline();
123 
125  void updateVTKPipeline();
126 
128  void updateCamPosition(SharedArray positionValue,
129  SharedArray focalValue,
130  SharedArray viewUpValue);
131 
133  void updatePipeline();
134 
136  vtkPolyDataNormals* m_normals;
137 
142  bool m_bPipelineIsInit;
143 
144  vtkCommand* m_loc;
145 
147  UpdateCamPositionSlotType::sptr m_slotUpdateCamPosition;
148 
150  UpdatePipelineSlotType::sptr m_slotUpdatePipeline;
151 
153  CamUpdatedSignalType::sptr m_sigCamUpdated;
154 
155 };
156 
157 }
Service rendering fwData::Mesh contained in a fwData::Composite using VTK.
Defines the service interface managing the rendering service for object.
Definition: IRender.hpp:36
The namespace vtkCompositeMesh contains a service which renders several meshes and store it on Compos...
static VTKCOMPOSITEMESH_APIconst::fwCom::Slots::SlotKeyType s_UPDATE_PIPELINE_SLOT
Slot to update pipeline.
::fwCom::helper::SigSlotConnection::KeyConnectionsType KeyConnectionsType
Returns proposals to connect service slots to associated object signals, this method is used for obj/...
Definition: IService.hpp:449
#define fwCoreServiceClassDefinitionsMacro(_classinfo_)
Generate common code for services classes.
The namespace fwRenderVTK contains classes for rendering with VTK.