1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #ifndef VolumeRendererManagerData_H_
27 #define VolumeRendererManagerData_H_
29 #include "vtkCommand.h"
31 #if (VTK_MAJOR_VERSION <= 7)
32 #include "vtkVolumeRayCastCompositeFunction.h"
33 #include "vtkVolumeRayCastMIPFunction.h"
39 #include <vtkPlanes.h>
40 #include <vtkVolumeMapper.h>
42 #include <vtkVolumeProperty.h>
43 #include <vtkVolume.h>
44 #include <vtkPiecewiseFunction.h>
45 #include <vtkColorTransferFunction.h>
46 #include <vtkImageData.h>
47 #include <vtkProp3D.h>
48 #include <vtkRenderer.h>
49 #include <vtkLookupTable.h>
50 #include <vtkBoxWidget.h>
51 #include <vtkAbstractMapper.h>
58 // Callback for moving the planes from the box widget to the mapper
59 class vtkBoxWidgetCallback : public vtkCommand
62 static vtkBoxWidgetCallback *New()
63 { return new vtkBoxWidgetCallback; }
64 virtual void Execute(vtkObject *caller, unsigned long, void*)
66 vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget*>(caller);
67 vtkPlanes *planes = vtkPlanes::New();
68 widget->GetPlanes(planes);
69 for(unsigned i = 0; i< VectorMapper.size(); i++){
70 VectorMapper[i]->SetClippingPlanes(planes);
74 void SetMapper(vtkAbstractMapper* m)
75 { if(VectorMapper.size() == 0){
76 VectorMapper.push_back(m);
82 void AddMapper(vtkAbstractMapper* m){
83 VectorMapper.push_back(m);
87 vtkBoxWidgetCallback()
90 vector< vtkAbstractMapper* > VectorMapper;
94 class VolumeRendererManagerData : public vtkObject{
97 VolumeRendererManagerData(vtkImageData* vol, std::string dataname="");
98 VolumeRendererManagerData(vtkImageData* vol, vtkRenderer* render, std::string dataname="");
99 VolumeRendererManagerData(vtkImageData* vol, bool usegpu);
102 ~VolumeRendererManagerData();
105 ** Check if the variables are setted correctly
107 void checkInvariant()throw (char *);
117 vtkProp3D* getProp3D();
120 ** return the id from the daat
127 void setId(int propid);
132 std::string getDataname();
137 void setDataname(std::string dataname);
142 void setVolumeColor(std::vector<double>& greylevel,
143 std::vector<double>& red,
144 std::vector<double>& green,
145 std::vector<double>& blue);
150 void setVolumeOpacity(std::vector<double> greylevel,std::vector<double> value);
154 void setVolumeOpacity(std::vector<double> greylevel,double value);
156 vtkPiecewiseFunction* GetTransferFunction(){
160 vtkColorTransferFunction* GetColorFunction(){
164 void changeCompositeMIPFunction(int function);
166 void SetLookupTable(vtkLookupTable* lookuptable);
168 void EnableBoundingBox(vtkRenderWindowInteractor* interactor);
169 void DisableBoundingBox();
172 changes the interoplation type of the volume
176 void changeInterpolationType(int type);
179 vtkGetMacro(BoxWidget, vtkBoxWidget*);
180 vtkSetMacro(BoxWidget, vtkBoxWidget*);
182 vtkGetMacro(VolumeMapper, vtkVolumeMapper*);
183 vtkSetMacro(VolumeMapper, vtkVolumeMapper*);
185 void SetColorTransferFunction(int i, vtkColorTransferFunction* colorf);
187 void SetIndependentComponents(bool independent);
190 * Prop 3D (data actor)
194 * Dataname given by the user (ex. filename)
196 std::string _dataname;
206 #if (VTK_MAJOR_VERSION <= 7)
207 vtkVolumeRayCastCompositeFunction *_compositeFunction;
208 vtkVolumeRayCastMIPFunction *_MIPFunction;
213 vtkPlanes *_volumePlanes;
214 vtkVolumeProperty *_volumeProperty;
216 vtkPiecewiseFunction *_tfun;
217 vtkColorTransferFunction *_ctfun;
219 ** boxwidget to control the volume
221 vtkBoxWidget *BoxWidget;
222 vtkVolumeMapper *VolumeMapper;
224 void Initialize(vtkImageData* vol, std::string dataname, bool usegpu = false);
229 #endif /*VolumeRendererManagerData_H_*/