fw4spl
SImage.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 __VISUVTKADAPTOR_SIMAGE_HPP__
8 #define __VISUVTKADAPTOR_SIMAGE_HPP__
9 
10 #include "visuVTKAdaptor/config.hpp"
11 
12 #include <fwData/Image.hpp>
13 
14 #include <fwDataTools/helper/MedicalImageAdaptor.hpp>
15 
16 #include <fwRenderVTK/IAdaptor.hpp>
17 
18 #include <vtkSmartPointer.h>
19 
21 class vtkImageMapToColors;
22 class vtkImageData;
23 
24 namespace visuVTKAdaptor
25 {
26 
62 class VISUVTKADAPTOR_CLASS_API SImage : public ::fwDataTools::helper::MedicalImageAdaptor,
64 {
65 
66 public:
67 
69 
70  VISUVTKADAPTOR_API SImage() noexcept;
71 
72  VISUVTKADAPTOR_API virtual ~SImage() noexcept;
73 
74  static const ::fwServices::IService::KeyType s_IMAGE_INOUT;
75  static const ::fwServices::IService::KeyType s_TF_INOUT;
76 
77  //------------------------------------------------------------------------------
78 
79  void setVtkImageRegisterId(std::string id)
80  {
81  m_imageRegisterId = id;
82  }
83  //------------------------------------------------------------------------------
84 
85  void setVtkImageRegister(vtkObject* obj)
86  {
87  m_imageRegister = obj;
88  }
89  //------------------------------------------------------------------------------
90 
91  void setImageOpacity(double opacity)
92  {
93  m_imageOpacity = opacity;
94  }
95  //------------------------------------------------------------------------------
96 
97  void setAllowAlphaInTF(bool allow)
98  {
99  m_allowAlphaInTF = allow;
100  }
101 
102 protected:
103 
104  VISUVTKADAPTOR_API void configuring() override;
105  VISUVTKADAPTOR_API void starting() override;
106  VISUVTKADAPTOR_API void updating() override;
107  VISUVTKADAPTOR_API void stopping() override;
108  VISUVTKADAPTOR_API void swapping(const KeyType& key) override;
109 
119  VISUVTKADAPTOR_API virtual KeyConnectionsMap getAutoConnections() const override;
120 
121  virtual void buildPipeline();
122  virtual void destroyPipeline();
123 
124  void updateImage( ::fwData::Image::sptr image );
125 
127  void updateImageOpacity();
128  void updateImageTransferFunction();
129 
131  VISUVTKADAPTOR_API virtual void updateTFPoints() override;
132 
134  VISUVTKADAPTOR_API virtual void updateTFWindowing(double window, double level) override;
135 
136 private:
137 
138  std::string m_imageRegisterId;
139  vtkObject* m_imageRegister;
140 
141  int m_imagePortId;
142  double m_imageOpacity;
143  bool m_allowAlphaInTF;
144 
145  vtkSmartPointer< fwVtkWindowLevelLookupTable > m_lut;
146  vtkSmartPointer< vtkImageMapToColors > m_map2colors;
147  vtkSmartPointer< vtkImageData > m_imageData;
148 
149 };
150 
151 } //namespace visuVTKAdaptor
152 
153 #endif // __VISUVTKADAPTOR_SIMAGE_HPP__
Render an image on the generic scene.
Definition: SImage.hpp:62
This class is a helper to define the connections of a service and its data.
Definition: IService.hpp:454
The namespace visuVTKAdaptor contains the list of adaptors available for the generic scene...
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.
Reinplementation of vtkWindowLevelLookupTable : add specific out-of-bounds colors.