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