]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.cxx
Bug #1373
[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 //-------------------------------------------------------------------
43 vtkMPRBaseData::~vtkMPRBaseData()
44 {
45         if (_marImageData)                      delete _marImageData;
46         if (_transformOrientation)      _transformOrientation ->Delete();
47 }
48
49 //-------------------------------------------------------------------
50 void vtkMPRBaseData::Configure()
51 {
52         //EED 03nov2012
53         vtkBaseData::Configure();
54         
55         vtkImageData* img = _marImageData->GetImageData();
56         if(img !=NULL)
57         {
58                 img->GetExtent (_x1,_x2,_y1,_y2,_z1,_z2);
59         //std::cout<<"vtkMPRBaseData::Configure() _x1= "<<_x1<<" _x2= "<<_x2<<" _y1= "<<_y1<<" _y2= "<<_y2<<" _z1= "<<_z1<<" _z2= "<<_z2<<std::endl;            
60         }
61         
62         if(_transformOrientation==NULL)
63         {
64                 _transformOrientation=vtkTransform::New();
65         }
66         
67         _transformOrientation->Identity();
68 }
69
70 //-------------------------------------------------------------------
71 void vtkMPRBaseData::GetDimensionExtention(int *x1,int *x2,int *y1,int *y2,int *z1,int *z2)
72 {
73         *x1=_x1;
74         *x2=_x2;
75         *y1=_y1;
76         *y2=_y2;
77         *z1=_z1;
78         *z2=_z2;
79 }
80
81
82 //------------------------------------------------------------------------
83 int vtkMPRBaseData::GetMaxPositionX( )
84 {
85         return _x2;
86 }
87 //------------------------------------------------------------------------
88 int vtkMPRBaseData::GetMaxPositionY( )
89 {
90         return _y2;
91 }
92 //------------------------------------------------------------------------
93 int vtkMPRBaseData::GetMaxPositionZ( )
94 {
95         return _z2;
96 }
97 //-------------------------------------------------------------------
98 double vtkMPRBaseData::GetX()
99 {
100
101         return _x;
102 }
103 //-------------------------------------------------------------------
104 double  vtkMPRBaseData::GetY()
105 {
106         return _y;
107 }
108 //-------------------------------------------------------------------
109 /**
110 **      Calculates the value of the slider and the layer in the image that is spouse to show
111 **/
112 void vtkMPRBaseData::SetX(double x)
113 {
114         //int dim[3];
115         int ext[6];
116         double* origin;
117         vtkImageData* img = _marImageData->GetImageData();
118         if(img!=NULL){
119                 /*img->GetDimensions(dim);
120                 if (x<0)
121                 {
122                         x=0;
123                 }
124                 if (x>=dim[0])
125                 {
126                         x=dim[0]-1;
127                 }
128                 _x=x;*/
129                 img->GetExtent(ext);
130                 origin = img->GetOrigin();
131                 if (x < ext[0])
132                 {
133                         x=ext[0] + origin[0];
134                 }
135                 if (x > ext[1])
136                 {
137                         x=ext[1] + origin[0];
138                 }
139                 
140                 _x=x;
141         }
142 }
143 //-------------------------------------------------------------------
144 /**
145 **      Calculates the value of the slider and the layer in the image that is spouse to show
146 **/
147 void vtkMPRBaseData::SetY(double y)
148 {
149         //int dim[3];
150         int ext[6];
151         double* origin;
152         vtkImageData* img = _marImageData->GetImageData();
153         if(img!=NULL){
154                 /*img->GetDimensions(dim);
155                 if (y<0)
156                 {
157                         y=0;
158                 }
159                 if (y>=dim[1])
160                 {
161                         y=dim[1]-1;
162                 }
163                 _y=y;*/
164                 img->GetExtent(ext);
165                 origin = img->GetOrigin();
166                 if (y<ext[2])
167                 {
168                         y=ext[2] + origin[1];
169                 }
170                 if (y > ext[3])
171                 {
172                         y=ext[3] + origin[1];
173                 }
174                 _y=y;
175         }
176 }
177 //-------------------------------------------------------------------
178 vtkTransform *vtkMPRBaseData::GetTransformOrientation()
179 {       
180         return _transformOrientation; 
181 }
182 //-------------------------------------------------------------------
183 void vtkMPRBaseData::SetNormal(double nx, double ny, double nz)
184 {
185         double alfa = atan2(ny,nx) * 180.0 / 3.1416;
186         double beta = atan2( nz, sqrt( nx*nx + ny*ny )  ) * 180.0 / 3.1416;
187         _transformOrientation->Identity();              
188         _transformOrientation->RotateWXYZ(alfa,0,0,1);
189         _transformOrientation->RotateWXYZ(-beta,0,1,0);
190 }
191 //-------------------------------------------------------------------
192 void vtkMPRBaseData::InitTransformOrientation(vtkTransform *trans)
193 {
194         _transformOrientation->SetMatrix( trans->GetMatrix() );
195 }
196
197
198
199 //-------------------------------------------------------------------
200 //-------------------------------------------------------------------
201 //-------------------------------------------------------------------
202