]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkBaseData.cxx
#3155 creaMaracasVisu Feature New Normal - ViewerPlane ComplexBox
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / vtkBaseData.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
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
8 #
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.
15 #
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
20 #  liability.
21 #
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 # ------------------------------------------------------------------------ */
25
26 #include "vtkBaseData.h"
27
28 //-------------------------------------------------------------------
29 vtkBaseData::vtkBaseData()
30 {
31         _z              = 0;
32         _t              = 0;
33         _marImageData   = 0;
34         _interpolate    = true;
35         _fixAxis2D              = false;
36         _opacityAxis    = 0.5;
37         _observable     = vtkObject::New();
38 }
39
40 //-------------------------------------------------------------------
41 vtkBaseData::~vtkBaseData()
42 {
43 }
44
45 //-------------------------------------------------------------------
46 void vtkBaseData::SetMarImageData(marImageData *marimagedata)
47 {
48         _marImageData = marimagedata;
49         //Configure();
50 }
51
52 //-------------------------------------------------------------------
53 vtkImageData* vtkBaseData::GetImageData()
54 {
55         if(_marImageData)
56         {
57                 return _marImageData->GetImageDataT(_t);
58         }else{
59                 return 0;
60         }
61         
62 }
63
64 //-------------------------------------------------------------------
65 marImageData* vtkBaseData::GetMarImageData()
66 {
67         return _marImageData;
68 }
69
70 //-------------------------------------------------------------------
71
72 void vtkBaseData::Configure()  // virtual
73 {
74         vtkImageData* imageData = _marImageData->GetImageData();
75         if(imageData !=NULL)
76         {
77                 double range[2];
78                 imageData->GetScalarRange(range);
79                 if (range[1]<20000){
80                         //EED Borrame 
81                         //_imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow( (range[1]-range[0])/2 );
82                         //_imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel( (range[1]+range[0])/4 );
83                         SetColorWindow( (range[1]-range[0])/2 );
84                         SetColorLevel( (range[1]+range[0])/4 );
85                 } else {
86                         //EED Borrame
87                         //_imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow( 1000 );
88                         //_imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel( 500 );
89                         SetColorWindow( 1000 );
90                         SetColorLevel( 500 );
91
92                 } // range
93         }       // img
94 }
95
96 //-------------------------------------------------------------------
97 void vtkBaseData::SetZ(double z)
98 {
99
100         //int maxZ;
101
102 //      int dim[3];
103 //      _marImageData->GetDimensions(dim);
104 //      maxZ=dim[2];
105
106         int ext[6];
107         double *origin;
108         
109         
110         vtkImageData* img = _marImageData->GetImageData();
111         if(img!=NULL){
112                 /*img->GetWholeExtent(ext);
113                 maxZ=ext[5]-ext[4]+1;
114
115                 if (z>=maxZ)
116                 {
117                         //z=maxZ-1;
118                 }
119                 if (z<=0)
120                 {
121                         z=0;
122                 }
123
124                 _z=z;*/
125                 img->GetExtent(ext);
126                 origin = img->GetOrigin();
127                 if (z > ext[5])
128                 {
129                         z = ext[5] + origin[2];
130                 }
131                 if (z < ext[4])
132                 {
133                         z = ext[4] + origin[2];
134                 }
135
136                 _z=z;
137                 _observable->InvokeEvent(3);    
138         }
139 }
140
141 //-------------------------------------------------------------------
142 double vtkBaseData::GetZ()
143 {
144         return _z;
145 }
146
147 //-------------------------------------------------------------------
148 int vtkBaseData::GetT()
149 {
150         return _t;
151 }
152
153 //-------------------------------------------------------------------
154 void vtkBaseData::SetT(double t)
155 {
156         int maxT = _marImageData->GetMaxT();
157         if (t>=maxT)
158         {
159                 t=maxT-1;
160         }
161         if (t<=0)
162         {
163                 t=0;
164         }
165         _t=(int)t;
166 }
167
168 //-------------------------------------------------------------------
169 void vtkBaseData::SetColorWindow(double colorWindow)
170 {
171         _colorWindow = colorWindow;
172 }
173
174 //-------------------------------------------------------------------
175 void vtkBaseData::SetColorLevel(double colorLevel)      
176 {
177         _colorLevel=colorLevel;
178 }
179
180 //-------------------------------------------------------------------
181 double vtkBaseData::GetColorWindow()    
182 {
183         return _colorWindow;
184 }
185
186 //-------------------------------------------------------------------
187 double vtkBaseData::GetColorLevel()     
188 {
189         return _colorLevel;
190 }
191
192
193 //-------------------------------------------------------------------
194 void vtkBaseData::AddObserver(int eventNumber, vtkCommand *observer)
195 {
196         _observable->AddObserver( eventNumber , observer );
197         //Configure();
198 }
199
200 //-------------------------------------------------------------------
201 bool vtkBaseData::GetInterpolate()      
202 {
203         return _interpolate;
204 }
205
206 //-------------------------------------------------------------------
207 void vtkBaseData::SetInterpolate(bool value)    
208 {
209         _interpolate = value;
210 }
211
212 //-------------------------------------------------------------------
213 bool vtkBaseData::GetFixAxis2D()        
214 {
215         return _fixAxis2D;
216 }
217
218 //-------------------------------------------------------------------
219 void vtkBaseData::SetFixAxis2D(bool value)      
220 {
221         _fixAxis2D = value;
222 }
223
224 //-------------------------------------------------------------------
225 double vtkBaseData::GetOpacityAxis()    
226 {
227         return _opacityAxis;
228 }
229
230 //-------------------------------------------------------------------
231 void vtkBaseData::SetOpacityAxis(double value)  
232 {
233         _opacityAxis = value;
234 }