fw4spl
SVolume.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 "visuVTKVRAdaptor/config.hpp"
10 
11 #include <fwData/Image.hpp>
12 
13 #include <fwDataTools/helper/MedicalImageAdaptor.hpp>
14 
15 #include <fwRenderVTK/IAdaptor.hpp>
16 #include <fwRenderVTK/SRender.hpp>
17 
18 class vtkSmartVolumeMapper;
19 class vtkBoxWidget2;
20 class vtkColorTransferFunction;
21 class vtkCommand;
22 class vtkPiecewiseFunction;
23 class vtkPlaneCollection;
24 class vtkVolume;
25 class vtkVolumeProperty;
26 
27 namespace visuVTKVRAdaptor
28 {
29 
67 class VISUVTKVRADAPTOR_CLASS_API SVolume : public ::fwDataTools::helper::MedicalImageAdaptor,
69 {
70 
71 public:
72 
74 
75  VISUVTKVRADAPTOR_API SVolume() noexcept;
76 
77  VISUVTKVRADAPTOR_API virtual ~SVolume() noexcept;
78 
79  static const ::fwServices::IService::KeyType s_IMAGE_INOUT;
80  static const ::fwServices::IService::KeyType s_TF_INOUT;
81 
82  VISUVTKVRADAPTOR_API void setClippingPlanesId( ::fwRenderVTK::SRender::VtkObjectIdType id );
83 
84  VISUVTKVRADAPTOR_API void setVtkClippingPlanes( vtkPlaneCollection* planes );
85 
93  VISUVTKVRADAPTOR_API virtual KeyConnectionsMap getAutoConnections() const override;
94 
96  VISUVTKVRADAPTOR_API void crop();
97 
99  VISUVTKVRADAPTOR_API void updateTransform();
100 
102  VISUVTKVRADAPTOR_API void updateCropBoxTransform();
103 
104 protected:
105 
106  VISUVTKVRADAPTOR_API void configuring() override;
107  VISUVTKVRADAPTOR_API void starting() override;
108  VISUVTKVRADAPTOR_API void stopping() override;
109  VISUVTKVRADAPTOR_API void updating() override;
110  VISUVTKVRADAPTOR_API void swapping(const KeyType& key) override;
111 
113  VISUVTKVRADAPTOR_API virtual void updateTFPoints() override;
114 
116  VISUVTKVRADAPTOR_API virtual void updateTFWindowing(double window, double level) override;
117 
119  void resetBoxWidget();
120 
122  void activateBoxClipping( bool activate );
123 
125  void show( bool isVisible );
126 
127  void buildPipeline();
128 
129  void updateImage( ::fwData::Image::sptr image );
130 
131  void updateVolumeTransferFunction( ::fwData::Image::sptr image );
132 
133  vtkPlaneCollection* m_clippingPlanes;
134 
135  ::fwRenderVTK::SRender::VtkObjectIdType m_clippingPlanesId;
136 
137  vtkSmartVolumeMapper* m_volumeMapper;
138  vtkVolumeProperty* m_volumeProperty;
139  vtkVolume* m_volume;
140 
141  vtkPiecewiseFunction* m_opacityTransferFunction;
142  vtkColorTransferFunction* m_colorTransferFunction;
143 
144  vtkCommand* m_abortCommand;
145 
146  vtkBoxWidget2* m_boxWidget;
147  vtkCommand* m_croppingCommand;
148  vtkCommand* m_transformCommand;
149 
151  bool m_croppingBoxDefaultState;
152 
154  std::string m_cropBoxTransformID;
155 
157  std::string m_blendMode;
158 
160  vtkTransform* m_cropBoxTransform;
161 
162 private:
163 
164  bool m_autoResetCamera;
165 
166  double m_reductionFactor;
167 };
168 
169 } //namespace visuVTKVRAdaptor
This class is a helper to define the connections of a service and its data.
Definition: IService.hpp:454
This adaptor displays a volume image.
Definition: SVolume.hpp:67
STL namespace.
Namespace fwServices is dedicated to (mimic) the dynamic affectation of methods to (pure data) object...
#define fwCoreServiceClassDefinitionsMacro(_classinfo_)
Generate common code for services classes.
The namespace fwRenderVTK contains classes for rendering with VTK.
Contains the representation of the data objects used in the framework.