]> Creatis software - creaMaracasVisu.git/blob - lib/Kernel/VTKObjects/VolumeRenderer/volumerenderermanager.h
bf7c6809ed1767b2011bbe59c38d9844c317bbf1
[creaMaracasVisu.git] / lib / Kernel / VTKObjects / VolumeRenderer / volumerenderermanager.h
1
2 /*=========================================================================
3
4   Program:   wxMaracas
5   Module:    $RCSfile: volumerenderermanager.h,v $
6   Language:  C++
7   Date:      $Date: 2011/10/05 16:27:04 $
8   Version:   $Revision: 1.2 $
9
10   Copyright: (c) 2002, 2003
11   License:
12
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notice for more information.
16
17 =========================================================================*/
18
19
20
21
22 #ifndef __VolumeRendererManagerH__
23 #define __VolumeRendererManagerH__
24
25 #include <iostream>
26 #include <vector>
27 #include <vtkMatrix4x4.h>
28
29 #include "volumerenderermanagerdata.h"
30
31
32 class VolumeRendererManager  {
33
34 public:
35         VolumeRendererManager();
36         ~VolumeRendererManager();
37
38         /**
39         **      Sets the renderer to manage the prop3D from the view
40         **/
41         void setRenderer(vtkRenderer*  renderer);
42
43         /**
44         **      Gets the renderer to manage the prop3D from the view
45         **/
46         vtkRenderer* getRenderer();
47
48         /**
49         **      Adds a volume
50         **/
51         int addVolume(int idTP, vtkImageData* img, std::string dataname) throw (char*);
52
53         /**
54         * @pre   The image can have one or multiple components per voxel, and volume rendering is performed seprately over the
55                  three of them. If the image has multiple components and the separate components flag is set to false, then
56                  the vtkImageAppendComponents is used to create a single image.
57         * @post  The volume rendering is performed over the image vol
58         * @param vtkImageData* the image volume
59         * @param bool independentcomponents, if the image has multiple components, the mapper will be created either for managing
60                         an rgb image plus a luminance channel (the luminance will be calculated using the luminance image filter)
61                         to control the opacity or to manage the multiple components in a single image
62         */
63         int addVolume(vtkImageData* img, vtkRenderWindowInteractor* interactor, bool independentcomponents = false);
64
65         /**
66         **      loads a prop3D from a nSTL file
67         **/
68         vtkProp3D* getVolume(std::string filename);
69
70         /**
71         **      loads a MHD file to convert it into an actor
72         **/
73         vtkImageData* getImageData(std::string filename);
74
75         /**
76         ** Gets image data asotiated with the rendering manager
77         **/
78         vtkImageData* getImageData();
79
80         /**
81         **      adds or removes an actor depending of the bool value
82         **/
83         void addRemoveActor(int propid, bool addremove) throw(char*);
84
85         /**
86         **      Check if the variables are setted correctly
87         **/
88         void checkInvariant()throw(char*);
89
90         /**
91         ** Set Volume Opacity
92         **/
93         void setVolumeOpacity(int propid, std::vector<double> greylevel,std::vector<double> value) throw(char*);
94         /**
95         **      Set Volume Color
96         **/
97         void setVolumeColor(int volid, std::vector<double> greylevel,
98                                                                         std::vector<double> red,
99                                                                         std::vector<double> green,
100                                                                         std::vector<double> blue)throw(char*);
101
102         /**
103         ** Given an id search the data in the vector
104         **/
105         VolumeRendererManagerData* getViewData(int id)throw(char*);
106
107         void changeCompositeMIPFunction(int id, int function) throw (char *);
108
109         /**
110         ** Deletes given actor
111         **/
112         void deleteActor(int volumeid)throw (char *);
113
114         /**
115         ** Updates given volume
116         **/
117         void Update(int propid);
118
119         vtkPiecewiseFunction* GetTransferFunction(int volumeid);
120         vtkColorTransferFunction* GetColorFunction(int volumeid);
121
122
123         /**
124           Changes the interpolation of the volume rendering.
125           type == 0 for linear interpolation
126           type == 1 for nearest interpolation
127           */
128         void changeInterpolationType(int type, int propid = -1);
129
130         /**
131           * Set the lookuptable to the volumes in memory
132           * if the id is set then it only changes the lookup table for a specific volume
133          */
134         void SetLookupTable(vtkLookupTable* lookup, int id = -1);
135
136         /**
137           * @returns all the props3D in this manager
138         */
139         vector< vtkProp3D* > getProps3D();
140
141         /**
142           *  @param std::vector<double> greylevel, the corresponding greylevel in the image
143           *  @param std::vector<double> value, the corresponding value for the opacity
144           *  @param int propid, the correspoding id, by default it applies the changes to the first volume in the array
145           */
146         void setVolumeOpacity(std::vector<double> greylevel, std::vector<double> value, int propid = -1);
147
148
149         void EnableBoundingBox(vtkRenderWindowInteractor* interactor, int propid = -1);
150
151         void DisableBoundingBox(int propid = -1);
152 private:
153         std::vector<VolumeRendererManagerData*> prop3Dvect;
154
155         vtkRenderer*  _renderer;
156         vtkImageData* image;
157
158         int _idCount;
159
160         /**
161           *  @pre the image is not null and has more than one scalar component
162           *  @post Each component in the image is separated to form a different image
163           *  @param vtkImageData* img, multiple component image i.e. an image of vectors like an rgb
164           *  @return vector<vtkImageData* > a vector of images, one for each component
165           */
166         void GetImages(vtkImageData* img, vector<vtkImageData* >& images);
167
168         /**
169           *  @pre the image is not null and has more than one scalar component
170           *  @post Each component in the image is put in a single image
171           *  @param vtkImageData* img, multiple component image i.e. an image of vectors like an rgb
172           *  @return vtkImageData* double type image
173           */
174         void GetImageDouble(vtkImageData* img, vtkImageData* imgdouble);
175
176
177
178 };
179
180 #endif