]> Creatis software - creaMaracasVisu.git/blob - lib/Kernel/VTKObjects/VolumeRenderer/volumerenderermanagerdata.h
b65de9158db1289a4355a6124bf1943fbb1266e8
[creaMaracasVisu.git] / lib / Kernel / VTKObjects / VolumeRenderer / volumerenderermanagerdata.h
1
2 #ifndef VolumeRendererManagerData_H_
3 #define VolumeRendererManagerData_H_
4
5 #include "vtkCommand.h"
6 #include <vtkVolumeRayCastCompositeFunction.h>
7 #include <vtkPlanes.h>
8 #include <vtkVolumeMapper.h>
9 #include <vtkVolumeRayCastMapper.h>
10 #include <vtkVolumeProperty.h>
11 #include <vtkVolume.h>
12 #include <vtkPiecewiseFunction.h>
13 #include <vtkColorTransferFunction.h>
14 #include <vtkImageData.h>
15 #include <vtkProp3D.h>
16 #include <vtkRenderer.h>
17 #include <vtkVolumeRayCastMIPFunction.h>
18 #include <vtkLookupTable.h>
19 #include <vtkBoxWidget.h>
20 #include <vtkAbstractMapper.h>
21
22 #if (VTK_MAYOR_VERSION>=6 && VTK_MINOR_VERSION>=6)
23   #include <vtkGPUVolumeRayCastMapper.h>
24 #endif
25
26
27 #include <vector>
28
29
30 // Callback for moving the planes from the box widget to the mapper
31 class vtkBoxWidgetCallback : public vtkCommand
32 {
33 public:
34   static vtkBoxWidgetCallback *New()
35     { return new vtkBoxWidgetCallback; }
36   virtual void Execute(vtkObject *caller, unsigned long, void*)
37     {
38       vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget*>(caller);
39       if (this->Mapper)
40         {
41         vtkPlanes *planes = vtkPlanes::New();
42         widget->GetPlanes(planes);
43         this->Mapper->SetClippingPlanes(planes);
44         planes->Delete();
45         }
46     }
47   void SetMapper(vtkAbstractMapper* m)
48     { this->Mapper = m; }
49
50 protected:
51   vtkBoxWidgetCallback()
52     { this->Mapper = 0; }
53
54   //vtkVolumeRayCastMapper *Mapper;
55   vtkAbstractMapper *Mapper;
56 };
57
58
59 class VolumeRendererManagerData  : public vtkObject{
60
61 public:
62         VolumeRendererManagerData(vtkImageData* vol, std::string dataname="");
63         VolumeRendererManagerData(vtkImageData* vol, vtkRenderer* render, std::string dataname="");
64         VolumeRendererManagerData(vtkImageData* vol, bool usegpu, std::string dataname="");
65         ~VolumeRendererManagerData();
66
67         /**
68         **      Check if the variables are setted correctly
69         **/
70         void checkInvariant()throw (char *);
71
72         /**
73         ** Updates volume
74         **/
75         void Update();
76
77         /**
78         **      get the prop3D
79         **/
80         vtkProp3D* getProp3D();
81
82         /**
83         **      return the id from the daat
84         **/
85         int getId();
86
87         /**
88         **      set data id
89         **/
90         void setId(int propid);
91
92         /**
93         **      Get the filanme
94         **/
95     std::string getDataname();
96
97         /**
98         ** Set the filanme
99         **/
100     void setDataname(std::string dataname);
101
102         /**
103         **      Set Volume Color
104         **/
105         void setVolumeColor(std::vector<double>& greylevel,
106                                                                         std::vector<double>& red,
107                                                                         std::vector<double>& green,
108                                                                         std::vector<double>& blue);
109
110         /**
111         **      Volume Opacity
112         **/
113         void setVolumeOpacity(std::vector<double> greylevel,std::vector<double> value);
114         /**
115         **      Volume Opacity
116         **/
117         void setVolumeOpacity(std::vector<double> greylevel,double value);
118
119         vtkPiecewiseFunction* GetTransferFunction(){
120                 return _tfun;
121         }
122
123         vtkColorTransferFunction* GetColorFunction(){
124                 return _ctfun;
125         }
126
127         void changeCompositeMIPFunction(int function) throw (char *);
128
129         void SetLookupTable(vtkLookupTable* lookuptable);
130
131         void EnableBoundingBox(vtkRenderWindowInteractor* interactor);
132         void DisableBoundingBox();
133 protected:
134         /**
135          * Prop 3D (data actor)
136          */
137         vtkImageData* _vol;
138         /**
139          *  Dataname given by the user (ex. filename)
140          **/
141         std::string _dataname;
142
143
144 private:
145
146         /*
147          * id of the data
148          */
149         int _id;
150
151         vtkVolumeRayCastCompositeFunction       *_compositeFunction;
152         vtkPlanes                                                       *_volumePlanes;
153         vtkVolumeRayCastMapper                      *_volumeMapper;
154         
155         
156 #if (VTK_MAYOR_VERSION>=6 && VTK_MINOR_VERSION>=6)
157                 vtkGPUVolumeRayCastMapper           *_volumeMappergpu;
158 #else   
159                 vtkVolumeRayCastMapper                      *_volumeMappergpu;
160 #endif  
161         
162         
163         vtkVolumeProperty                                       *_volumeProperty;
164         vtkVolume                                                       *_newvol;
165         vtkPiecewiseFunction* _tfun;
166         vtkColorTransferFunction* _ctfun;
167         vtkVolumeRayCastMIPFunction* _MIPFunction;
168         /**
169         ** boxwidget to control the volume
170         **/
171         vtkBoxWidget* _boxWidgetS1;
172
173         void Initialize(vtkImageData* vol, std::string dataname, bool usegpu = false);
174
175
176 };
177
178 #endif /*VolumeRendererManagerData_H_*/