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"
30 #include <vtkVolumeRayCastCompositeFunction.h>
31 #include <vtkPlanes.h>
32 #include <vtkVolumeMapper.h>
34 #include <vtkVolumeProperty.h>
35 #include <vtkVolume.h>
36 #include <vtkPiecewiseFunction.h>
37 #include <vtkColorTransferFunction.h>
38 #include <vtkImageData.h>
39 #include <vtkProp3D.h>
40 #include <vtkRenderer.h>
41 #include <vtkVolumeRayCastMIPFunction.h>
42 #include <vtkLookupTable.h>
43 #include <vtkBoxWidget.h>
44 #include <vtkAbstractMapper.h>
51 // Callback for moving the planes from the box widget to the mapper
52 class vtkBoxWidgetCallback : public vtkCommand
55 static vtkBoxWidgetCallback *New()
56 { return new vtkBoxWidgetCallback; }
57 virtual void Execute(vtkObject *caller, unsigned long, void*)
59 vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget*>(caller);
60 vtkPlanes *planes = vtkPlanes::New();
61 widget->GetPlanes(planes);
62 for(unsigned i = 0; i< VectorMapper.size(); i++){
63 VectorMapper[i]->SetClippingPlanes(planes);
67 void SetMapper(vtkAbstractMapper* m)
68 { if(VectorMapper.size() == 0){
69 VectorMapper.push_back(m);
75 void AddMapper(vtkAbstractMapper* m){
76 VectorMapper.push_back(m);
80 vtkBoxWidgetCallback()
83 vector< vtkAbstractMapper* > VectorMapper;
87 class VolumeRendererManagerData : public vtkObject{
90 VolumeRendererManagerData(vtkImageData* vol, std::string dataname="");
91 VolumeRendererManagerData(vtkImageData* vol, vtkRenderer* render, std::string dataname="");
92 VolumeRendererManagerData(vtkImageData* vol, bool usegpu);
95 ~VolumeRendererManagerData();
98 ** Check if the variables are setted correctly
100 void checkInvariant()throw (char *);
110 vtkProp3D* getProp3D();
113 ** return the id from the daat
120 void setId(int propid);
125 std::string getDataname();
130 void setDataname(std::string dataname);
135 void setVolumeColor(std::vector<double>& greylevel,
136 std::vector<double>& red,
137 std::vector<double>& green,
138 std::vector<double>& blue);
143 void setVolumeOpacity(std::vector<double> greylevel,std::vector<double> value);
147 void setVolumeOpacity(std::vector<double> greylevel,double value);
149 vtkPiecewiseFunction* GetTransferFunction(){
153 vtkColorTransferFunction* GetColorFunction(){
157 void changeCompositeMIPFunction(int function);
159 void SetLookupTable(vtkLookupTable* lookuptable);
161 void EnableBoundingBox(vtkRenderWindowInteractor* interactor);
162 void DisableBoundingBox();
165 changes the interoplation type of the volume
169 void changeInterpolationType(int type);
172 vtkGetMacro(BoxWidget, vtkBoxWidget*);
173 vtkSetMacro(BoxWidget, vtkBoxWidget*);
175 vtkGetMacro(VolumeMapper, vtkVolumeMapper*);
176 vtkSetMacro(VolumeMapper, vtkVolumeMapper*);
178 void SetColorTransferFunction(int i, vtkColorTransferFunction* colorf);
180 void SetIndependentComponents(bool independent);
183 * Prop 3D (data actor)
187 * Dataname given by the user (ex. filename)
189 std::string _dataname;
199 vtkVolumeRayCastCompositeFunction *_compositeFunction;
200 vtkPlanes *_volumePlanes;
202 vtkVolumeProperty *_volumeProperty;
204 vtkPiecewiseFunction *_tfun;
205 vtkColorTransferFunction *_ctfun;
206 vtkVolumeRayCastMIPFunction *_MIPFunction;
208 ** boxwidget to control the volume
210 vtkBoxWidget *BoxWidget;
211 vtkVolumeMapper *VolumeMapper;
213 void Initialize(vtkImageData* vol, std::string dataname, bool usegpu = false);
218 #endif /*VolumeRendererManagerData_H_*/