]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasMultipleVolumeRendererManagerData.cxx
de064e339aff011d3c87fdcbb66aa2a9b05cd896
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxMaracasMultipleVolumeRendererManagerData.cxx
1
2 #include "wxMaracasMultipleVolumeRendererManagerData.h"
3
4 /********************************************************************************************
5 ** Start of data viewmanagerData
6 *********************************************************************************************/
7
8 wxMaracasMultipleVolumeRendererManagerData::wxMaracasMultipleVolumeRendererManagerData(vtkImageData* vol, std::string dataname){
9
10         _vol = vol;     
11         _dataname = dataname;
12         
13         _tfun = vtkPiecewiseFunction::New();
14         _ctfun = vtkColorTransferFunction::New();   
15
16         _volumePlanes  = vtkPlanes::New();
17         _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
18         _volumeMapper = vtkVolumeRayCastMapper::New();  
19         _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
20         _volumeMapper->SetClippingPlanes( _volumePlanes );
21         _volumeMapper->AutoAdjustSampleDistancesOn();
22         _volumeProperty = vtkVolumeProperty::New();     
23         _volumeProperty->SetInterpolationTypeToLinear();
24         _volumeProperty->ShadeOn();
25         _volumeProperty->DisableGradientOpacityOn();    
26         _volumeProperty->SetColor(_ctfun);
27         _volumeProperty->SetScalarOpacity(_tfun );
28
29         _newvol = vtkVolume::New();
30         _newvol->SetMapper(_volumeMapper );
31         _newvol->SetProperty(_volumeProperty );
32         _volumeMapper->SetInput( _vol );
33         _volumeMapper->Update();
34         _newvol->Update();
35 }
36
37
38 wxMaracasMultipleVolumeRendererManagerData::~wxMaracasMultipleVolumeRendererManagerData(){
39         
40         _tfun->Delete();
41         _ctfun->Delete();
42         _volumePlanes->Delete();
43         _compositeFunction->Delete();
44         _volumeMapper->Delete();
45         _volumeProperty->Delete();
46         _newvol->Delete();
47         
48 }
49 /**
50 **      Set Volume Color
51 **/
52 void wxMaracasMultipleVolumeRendererManagerData::setVolumeColor(std::vector<double>& greylevelcolors,
53                                                                 std::vector<double>& red,
54                                                                 std::vector<double>& green,
55                                                                 std::vector<double>& blue)
56 {       
57         
58         _ctfun->RemoveAllPoints();
59         for(int i = 0; i < greylevelcolors.size();i++){
60                 _ctfun->AddRGBPoint(greylevelcolors[i], red[i],green[i], blue[i]);
61         //                      std::cout<<"transfer color function "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
62         }               
63         _newvol->Update();      
64 }
65                                 
66 /**
67 **      Volume Opacity
68 **/
69 void wxMaracasMultipleVolumeRendererManagerData::setVolumeOpacity(std::vector<double> greylevel,std::vector<double> value){
70                 
71         _tfun->RemoveAllPoints();
72         for(int i = 0; i < greylevel.size();i++){
73                 _tfun->AddPoint(greylevel[i], value[i]);
74 //                      std::cout<<"transfer function "<<greylevel[i]<<" "<< value[i]<<std::endl;
75         }
76     _newvol->Update();
77 }
78
79 /**
80 **      Check if the variables are setted correctly
81 **/
82 void wxMaracasMultipleVolumeRendererManagerData::checkInvariant(){
83
84 }
85 /**
86 **      get the prop3D 
87 **/
88 vtkProp3D* wxMaracasMultipleVolumeRendererManagerData::getProp3D(){
89         return this->_newvol;
90 }
91 /**
92 **      return the id from the daat
93 **/
94 int wxMaracasMultipleVolumeRendererManagerData::getId(){
95         return _id;
96 }
97 /**
98 **      set data id
99 **/
100 void wxMaracasMultipleVolumeRendererManagerData::setId(int propid){
101         _id = propid;
102 }
103
104 /**
105 **      Get the filanme
106 **/
107 std::string wxMaracasMultipleVolumeRendererManagerData::getDataname(){
108         return _dataname;
109 }
110 /**
111 ** Set the filanme
112 **/
113 void wxMaracasMultipleVolumeRendererManagerData::setDataname(std::string dataname){
114         _dataname = dataname;
115 }
116