]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.cxx
v1.0.3 BUG 1404
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxMPRBaseData.cxx
1
2
3 #include <vtkPlanes.h>
4 #include <vtkProperty.h> 
5 #include <vtkPolyData.h> 
6 #include <vtkDataSet.h> 
7 #include <vtkCellArray.h>
8 #include <vtkTransform.h>
9 #include <vtkTransformFilter.h>
10 #include <vtkDataSetReader.h>
11
12 #include "wxMPRBaseData.h"
13 #include "pPlotter/HistogramDialog.h"
14
15
16 #ifdef _DEBUG
17 #define new DEBUG_NEW
18 #endif
19 //-------------------------------------------------------------------
20 //-------------------------------------------------------------------
21 //-------------------------------------------------------------------
22
23
24 //-------------------------------------------------------------------
25 //-------------------------------------------------------------------
26 //-------------------------------------------------------------------
27 vtkMPRBaseData::vtkMPRBaseData()
28 {
29   _x=0;
30   _y=0;
31   _z=0;
32   _x1 = 0;
33   _x2 = 0;
34   _y1 = 0;
35   _y2 = 0;
36   _z1 = 0;
37   _z2 = 0;
38   _transformOrientation = NULL;
39   _marImageData = NULL;
40 }
41 //-------------------------------------------------------------------
42 vtkMPRBaseData::~vtkMPRBaseData()
43 {
44         if (_marImageData)                      delete _marImageData;
45         if (_transformOrientation)      _transformOrientation ->Delete();
46 }
47 //-------------------------------------------------------------------
48 void vtkMPRBaseData::Configure()
49 {
50         vtkImageData* img = _marImageData->GetImageData();
51         if(img !=NULL){
52                 img->GetExtent (_x1,_x2,_y1,_y2,_z1,_z2);
53         //std::cout<<"vtkMPRBaseData::Configure() _x1= "<<_x1<<" _x2= "<<_x2<<" _y1= "<<_y1<<" _y2= "<<_y2<<" _z1= "<<_z1<<" _z2= "<<_z2<<std::endl;
54                 
55         }
56         if(_transformOrientation==NULL){
57                 _transformOrientation=vtkTransform::New();
58         }
59         _transformOrientation->Identity();
60 }
61 //-------------------------------------------------------------------
62 void vtkMPRBaseData::GetDimensionExtention(int *x1,int *x2,int *y1,int *y2,int *z1,int *z2)
63 {
64         *x1=_x1;
65         *x2=_x2;
66         *y1=_y1;
67         *y2=_y2;
68         *z1=_z1;
69         *z2=_z2;
70 }
71
72
73 //------------------------------------------------------------------------
74 int vtkMPRBaseData::GetMaxPositionX( )
75 {
76         return _x2;
77 }
78 //------------------------------------------------------------------------
79 int vtkMPRBaseData::GetMaxPositionY( )
80 {
81         return _y2;
82 }
83 //------------------------------------------------------------------------
84 int vtkMPRBaseData::GetMaxPositionZ( )
85 {
86         return _z2;
87 }
88 //-------------------------------------------------------------------
89 double vtkMPRBaseData::GetX()
90 {
91
92         return _x;
93 }
94 //-------------------------------------------------------------------
95 double  vtkMPRBaseData::GetY()
96 {
97         return _y;
98 }
99 //-------------------------------------------------------------------
100 /**
101 **      Calculates the value of the slider and the layer in the image that is spouse to show
102 **/
103 void vtkMPRBaseData::SetX(double x)
104 {
105         //int dim[3];
106         int ext[6];
107         double* origin;
108         vtkImageData* img = _marImageData->GetImageData();
109         if(img!=NULL){
110                 /*img->GetDimensions(dim);
111                 if (x<0)
112                 {
113                         x=0;
114                 }
115                 if (x>=dim[0])
116                 {
117                         x=dim[0]-1;
118                 }
119                 _x=x;*/
120                 img->GetExtent(ext);
121                 origin = img->GetOrigin();
122                 if (x < ext[0])
123                 {
124                         x=ext[0] + origin[0];
125                 }
126                 if (x > ext[1])
127                 {
128                         x=ext[1] + origin[0];
129                 }
130                 
131                 _x=x;
132         }
133 }
134 //-------------------------------------------------------------------
135 /**
136 **      Calculates the value of the slider and the layer in the image that is spouse to show
137 **/
138 void vtkMPRBaseData::SetY(double y)
139 {
140         //int dim[3];
141         int ext[6];
142         double* origin;
143         vtkImageData* img = _marImageData->GetImageData();
144         if(img!=NULL){
145                 /*img->GetDimensions(dim);
146                 if (y<0)
147                 {
148                         y=0;
149                 }
150                 if (y>=dim[1])
151                 {
152                         y=dim[1]-1;
153                 }
154                 _y=y;*/
155                 img->GetExtent(ext);
156                 origin = img->GetOrigin();
157                 if (y<ext[2])
158                 {
159                         y=ext[2] + origin[1];
160                 }
161                 if (y > ext[3])
162                 {
163                         y=ext[3] + origin[1];
164                 }
165                 _y=y;
166         }
167 }
168 //-------------------------------------------------------------------
169 vtkTransform *vtkMPRBaseData::GetTransformOrientation()
170 {       
171         return _transformOrientation; 
172 }
173 //-------------------------------------------------------------------
174 void vtkMPRBaseData::SetNormal(double nx, double ny, double nz)
175 {
176         double alfa = atan2(ny,nx) * 180.0 / 3.1416;
177         double beta = atan2( nz, sqrt( nx*nx + ny*ny )  ) * 180.0 / 3.1416;
178         _transformOrientation->Identity();              
179         _transformOrientation->RotateWXYZ(alfa,0,0,1);
180         _transformOrientation->RotateWXYZ(-beta,0,1,0);
181 }
182 //-------------------------------------------------------------------
183 void vtkMPRBaseData::InitTransformOrientation(vtkTransform *trans)
184 {
185         _transformOrientation->SetMatrix( trans->GetMatrix() );
186 }
187
188
189
190 //-------------------------------------------------------------------
191 //-------------------------------------------------------------------
192 //-------------------------------------------------------------------
193