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