2 #ifndef VolumeRendererManagerData_H_
3 #define VolumeRendererManagerData_H_
5 #include "vtkCommand.h"
6 #include <vtkVolumeRayCastCompositeFunction.h>
8 #include <vtkVolumeMapper.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>
27 // Callback for moving the planes from the box widget to the mapper
28 class vtkBoxWidgetCallback : public vtkCommand
31 static vtkBoxWidgetCallback *New()
32 { return new vtkBoxWidgetCallback; }
33 virtual void Execute(vtkObject *caller, unsigned long, void*)
35 vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget*>(caller);
36 vtkPlanes *planes = vtkPlanes::New();
37 widget->GetPlanes(planes);
38 for(unsigned i = 0; i< VectorMapper.size(); i++){
39 VectorMapper[i]->SetClippingPlanes(planes);
43 void SetMapper(vtkAbstractMapper* m)
44 { if(VectorMapper.size() == 0){
45 VectorMapper.push_back(m);
51 void AddMapper(vtkAbstractMapper* m){
52 VectorMapper.push_back(m);
56 vtkBoxWidgetCallback()
59 vector< vtkAbstractMapper* > VectorMapper;
63 class VolumeRendererManagerData : public vtkObject{
66 VolumeRendererManagerData(vtkImageData* vol, std::string dataname="");
67 VolumeRendererManagerData(vtkImageData* vol, vtkRenderer* render, std::string dataname="");
68 VolumeRendererManagerData(vtkImageData* vol, bool usegpu);
71 ~VolumeRendererManagerData();
74 ** Check if the variables are setted correctly
76 void checkInvariant()throw (char *);
86 vtkProp3D* getProp3D();
89 ** return the id from the daat
96 void setId(int propid);
101 std::string getDataname();
106 void setDataname(std::string dataname);
111 void setVolumeColor(std::vector<double>& greylevel,
112 std::vector<double>& red,
113 std::vector<double>& green,
114 std::vector<double>& blue);
119 void setVolumeOpacity(std::vector<double> greylevel,std::vector<double> value);
123 void setVolumeOpacity(std::vector<double> greylevel,double value);
125 vtkPiecewiseFunction* GetTransferFunction(){
129 vtkColorTransferFunction* GetColorFunction(){
133 void changeCompositeMIPFunction(int function);
135 void SetLookupTable(vtkLookupTable* lookuptable);
137 void EnableBoundingBox(vtkRenderWindowInteractor* interactor);
138 void DisableBoundingBox();
141 changes the interoplation type of the volume
145 void changeInterpolationType(int type);
148 vtkGetMacro(BoxWidget, vtkBoxWidget*);
149 vtkSetMacro(BoxWidget, vtkBoxWidget*);
151 vtkGetMacro(VolumeMapper, vtkVolumeMapper*);
152 vtkSetMacro(VolumeMapper, vtkVolumeMapper*);
154 void SetColorTransferFunction(int i, vtkColorTransferFunction* colorf);
156 void SetIndependentComponents(bool independent);
159 * Prop 3D (data actor)
163 * Dataname given by the user (ex. filename)
165 std::string _dataname;
175 vtkVolumeRayCastCompositeFunction *_compositeFunction;
176 vtkPlanes *_volumePlanes;
178 vtkVolumeProperty *_volumeProperty;
180 vtkPiecewiseFunction* _tfun;
181 vtkColorTransferFunction* _ctfun;
182 vtkVolumeRayCastMIPFunction* _MIPFunction;
184 ** boxwidget to control the volume
186 vtkBoxWidget* BoxWidget;
187 vtkVolumeMapper *VolumeMapper;
189 void Initialize(vtkImageData* vol, std::string dataname, bool usegpu = false);
194 #endif /*VolumeRendererManagerData_H_*/