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