]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkBaseData.cxx
#3481 wxVtkBaseView_Info add events mouse observer
[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                    = 1.0;
37         _observable                     = vtkObject::New();
38         _cameraparallelScale    = 100.0;
39     _pointMouseX            = 0;
40     _pointMouseY            = 0;
41     _pointMouseZ            = 0;
42 }
43
44 //-------------------------------------------------------------------
45 vtkBaseData::~vtkBaseData()
46 {
47 }
48
49 //-------------------------------------------------------------------
50 void vtkBaseData::SetMarImageData(marImageData *marimagedata)
51 {
52         _marImageData = marimagedata;
53         //Configure();
54 }
55
56 //-------------------------------------------------------------------
57 vtkImageData* vtkBaseData::GetImageData()
58 {
59         if(_marImageData)
60         {
61                 return _marImageData->GetImageDataT(_t);
62         }else{
63                 return 0;
64         }
65         
66 }
67
68 //-------------------------------------------------------------------
69 marImageData* vtkBaseData::GetMarImageData()
70 {
71         return _marImageData;
72 }
73
74 //-------------------------------------------------------------------
75
76 void vtkBaseData::Configure()  // virtual
77 {
78         vtkImageData* imageData = _marImageData->GetImageData();
79         if(imageData !=NULL)
80         {
81                 double range[2];
82                 imageData->GetScalarRange(range);
83                 if (range[1]<20000){
84                         //EED Borrame 
85                         //_imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow( (range[1]-range[0])/2 );
86                         //_imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel( (range[1]+range[0])/4 );
87                         SetColorWindow( (range[1]-range[0])/2 );
88                         SetColorLevel( (range[1]+range[0])/4 );
89                 } else {
90                         //EED Borrame
91                         //_imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow( 1000 );
92                         //_imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel( 500 );
93                         SetColorWindow( 1000 );
94                         SetColorLevel( 500 );
95
96                 } // range
97         }       // img
98 }
99
100 //-------------------------------------------------------------------
101 void vtkBaseData::SetZ(double z)
102 {
103
104         //int maxZ;
105
106 //      int dim[3];
107 //      _marImageData->GetDimensions(dim);
108 //      maxZ=dim[2];
109
110         int ext[6];
111         double *origin;
112         
113         
114         vtkImageData* img = _marImageData->GetImageData();
115         if(img!=NULL){
116                 /*img->GetWholeExtent(ext);
117                 maxZ=ext[5]-ext[4]+1;
118
119                 if (z>=maxZ)
120                 {
121                         //z=maxZ-1;
122                 }
123                 if (z<=0)
124                 {
125                         z=0;
126                 }
127
128                 _z=z;*/
129                 img->GetExtent(ext);
130                 origin = img->GetOrigin();
131                 if (z > ext[5])
132                 {
133                         z = ext[5] + origin[2];
134                 }
135                 if (z < ext[4])
136                 {
137                         z = ext[4] + origin[2];
138                 }
139
140                 _z=z;
141                 _observable->InvokeEvent(3);    
142         }
143 }
144
145 //-------------------------------------------------------------------
146 double vtkBaseData::GetZ()
147 {
148         return _z;
149 }
150
151 //-------------------------------------------------------------------
152 int vtkBaseData::GetT()
153 {
154         return _t;
155 }
156
157 //-------------------------------------------------------------------
158 double vtkBaseData::GetX()  // virtual
159 {
160         return 0;
161 }
162 //-------------------------------------------------------------------
163 double vtkBaseData::GetY()  // virtual
164 {
165         return 0;
166 }
167
168
169 //-------------------------------------------------------------------
170 void vtkBaseData::SetT(double t)
171 {
172         int maxT = _marImageData->GetMaxT();
173         if (t>=maxT)
174         {
175                 t=maxT-1;
176         }
177         if (t<=0)
178         {
179                 t=0;
180         }
181         _t=(int)t;
182 }
183
184 //-------------------------------------------------------------------
185 void vtkBaseData::SetColorWindow(double colorWindow)
186 {
187         _colorWindow = colorWindow;
188 }
189
190 //-------------------------------------------------------------------
191 void vtkBaseData::SetColorLevel(double colorLevel)      
192 {
193         _colorLevel=colorLevel;
194 }
195
196 //-------------------------------------------------------------------
197 double vtkBaseData::GetColorWindow()    
198 {
199         return _colorWindow;
200 }
201
202 //-------------------------------------------------------------------
203 double vtkBaseData::GetColorLevel()     
204 {
205         return _colorLevel;
206 }
207
208
209 //-------------------------------------------------------------------
210 void vtkBaseData::AddObserver(int eventNumber, vtkCommand *observer)
211 {
212         _observable->AddObserver( eventNumber , observer );
213         //Configure();
214 }
215
216 //-------------------------------------------------------------------
217 bool vtkBaseData::GetInterpolate()      
218 {
219         return _interpolate;
220 }
221
222 //-------------------------------------------------------------------
223 void vtkBaseData::SetInterpolate(bool value)    
224 {
225         _interpolate = value;
226 }
227
228 //-------------------------------------------------------------------
229 bool vtkBaseData::GetFixAxis2D()        
230 {
231         return _fixAxis2D;
232 }
233
234 //-------------------------------------------------------------------
235 void vtkBaseData::SetFixAxis2D(bool value)      
236 {
237         _fixAxis2D = value;
238 }
239
240 //-------------------------------------------------------------------
241 double vtkBaseData::GetOpacityAxis()    
242 {
243         return _opacityAxis;
244 }
245
246 //-------------------------------------------------------------------
247 void vtkBaseData::SetOpacityAxis(double value)  
248 {
249         _opacityAxis = value;
250 }
251
252 //-------------------------------------------------------------------
253 double vtkBaseData::GetCameraParallelScale()
254 {
255         return _cameraparallelScale;
256 }
257
258 //-------------------------------------------------------------------
259 void vtkBaseData::SetCameraParallelScale(double value)
260 {
261         _cameraparallelScale=value;
262 }
263
264 //-------------------------------------------------------------------
265 void vtkBaseData::SetPointMouse(int x, int y , int z)
266 {
267     _pointMouseX = x;
268     _pointMouseY = y;
269     _pointMouseZ = z;
270 }
271
272 //-------------------------------------------------------------------
273 void vtkBaseData::GetPointMouse(int &x, int &y , int &z)
274 {
275     x = _pointMouseX;
276     y = _pointMouseY;
277     z = _pointMouseZ;
278 }
279