]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasRenderImageTransformation.cpp
e2dad9083971c7133493d83373ae27261262034b
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxMaracasRenderImageTransformation.cpp
1 #include "wxMaracasRenderImageTransformation.h"
2
3 /**
4 ** Class constructor
5 **/
6 wxMaracasRenderImageTransformation::wxMaracasRenderImageTransformation(wxMaracasMultipleVolumeRendererManager* _vol, wxMaracasSurfaceRenderingManager* _surface1, 
7                                                                                                                                                  wxMaracasSurfaceRenderingManager* _surface2, wxMaracasSurfaceRenderingManager* _surface3, int id)
8 {
9         vol = _vol;
10         surface1 = _surface1;
11         surface2 = _surface2;
12         surface3 = _surface3;
13         
14         propID = id;
15         transformV = vtkTransform::New();
16         transformS1 = vtkTransform::New();
17         transformS2 = vtkTransform::New();
18         transformS3 = vtkTransform::New();
19
20 }
21
22 /**
23 ** Class destructor
24 **/
25 wxMaracasRenderImageTransformation::~wxMaracasRenderImageTransformation()
26 {       
27         
28 }
29
30 /**
31 ** Transforms a volume by the given value for the X axis
32 **/
33 void wxMaracasRenderImageTransformation::Translate(int tx, int ty, int tz, int rx, int ry, int rz, int sx, int sy, int sz)
34 {
35         //printf("wxMaracasRenderImageManagementPanel::Rotate float:scaleX = %f \n", tx);
36         //printf("wxMaracasRenderImageManagementPanel::Rotate float:scaleY = %f \n", ty);
37         //printf("wxMaracasRenderImageManagementPanel::Rotate float:scaleZ = %f \n", tz);
38
39         double volspX;
40         double volspY;
41         double volspZ;
42         vol->getImageData()->GetSpacing(volspX, volspY, volspZ);
43
44         double surfspX;
45         double surfspY;
46         double surfspZ;
47         surface1->getImageData()->GetSpacing(surfspX, surfspY, surfspZ);
48
49         transformV->Identity();
50         transformS1->Identity();
51         transformS2->Identity();
52         transformS3->Identity();
53
54         transformV->Translate( tx*volspX, ty*volspY, tz*volspZ );
55         transformS1->Translate( tx*surfspX, ty*surfspY, tz*surfspZ );
56         transformS2->Translate( tx*surfspX, ty*surfspY, tz*surfspZ );
57         transformS3->Translate( tx*surfspX, ty*surfspY, tz*surfspZ );
58
59         transformV->RotateX( rx*volspX );
60         transformS1->RotateX( rx*surfspX );
61         transformS2->RotateX( rx*surfspX );
62         transformS3->RotateX( rx*surfspX );
63
64         transformV->RotateY( ry*volspY );
65         transformS1->RotateY( ry*surfspY );
66         transformS2->RotateY( ry*surfspY );
67         transformS3->RotateY( ry*surfspY );
68
69         transformV->RotateZ( rz*volspZ );
70         transformS1->RotateZ( rz*surfspZ );
71         transformS2->RotateZ( rz*surfspZ );
72         transformS3->RotateZ( rz*surfspZ );
73
74         transformV->Scale( (sx/100.0), (sy/100.0), (sz/100.0) );
75         transformS1->Scale( (sx/100.0), (sy/100.0), (sz/100.0) );
76         transformS2->Scale( (sx/100.0), (sy/100.0), (sz/100.0) );
77         transformS3->Scale( (sx/100.0), (sy/100.0), (sz/100.0) );
78
79         Refresh();
80 }
81
82
83 /**
84 ** Updates each Matrix
85 **/
86 void wxMaracasRenderImageTransformation::Refresh()throw(char*)
87 {
88         transformV->Update();
89         transformS1->Update();
90         transformS2->Update();
91         transformS3->Update();
92
93         vol->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
94         //vol->getRenderer()->Render();
95
96         surface1->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
97         //surface1->getRenderer()->Render();
98
99         surface2->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
100         //surface2->getRenderer()->Render();
101
102         surface3->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
103         //surface3->getRenderer()->Render();
104 }