]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkBaseData.cxx
#2844 creaMaracasVisu Feature New Normal - ManualPaint_model box, Refresh TransferF...
[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
27 #include "vtkBaseData.h"
28
29
30
31 //-------------------------------------------------------------------
32 vtkBaseData::vtkBaseData()
33 {
34         _z              = 0;
35         _t              = 0;
36         _marImageData   = 0;
37         _interpolate    = true;
38         _observable     = vtkObject::New();
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 void vtkBaseData::SetT(double t)
156 {
157         int maxT = _marImageData->GetMaxT();
158         if (t>=maxT)
159         {
160                 t=maxT-1;
161         }
162         if (t<=0)
163         {
164                 t=0;
165         }
166         _t=(int)t;
167 }
168
169 //-------------------------------------------------------------------
170 void vtkBaseData::SetColorWindow(double colorWindow)
171 {
172         _colorWindow = colorWindow;
173 }
174
175 //-------------------------------------------------------------------
176 void vtkBaseData::SetColorLevel(double colorLevel)      
177 {
178         _colorLevel=colorLevel;
179 }
180
181 //-------------------------------------------------------------------
182 double vtkBaseData::GetColorWindow()    
183 {
184         return _colorWindow;
185 }
186
187 //-------------------------------------------------------------------
188 double vtkBaseData::GetColorLevel()     
189 {
190         return _colorLevel;
191 }
192
193
194 //-------------------------------------------------------------------
195 void vtkBaseData::AddObserver(int eventNumber, vtkCommand *observer)
196 {
197         _observable->AddObserver( eventNumber , observer );
198         //Configure();
199 }
200
201 //-------------------------------------------------------------------
202 bool vtkBaseData::GetInterpolate()      
203 {
204         return _interpolate;
205 }
206
207 //-------------------------------------------------------------------
208 void vtkBaseData::SetInterpolate(bool value)    
209 {
210         _interpolate = value;
211 }
212