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