]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasRenderImageTransformation.cpp
*** empty log message ***
[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
16         transformV = vtkTransform::New();
17         transformS1 = vtkTransform::New();
18         transformS2 = vtkTransform::New();
19         transformS3 = vtkTransform::New();
20
21 }
22
23 /**
24 ** Class destructor
25 **/
26 wxMaracasRenderImageTransformation::~wxMaracasRenderImageTransformation()
27 {       
28         transformV->Identity();
29         transformS1->Identity();
30         transformS2->Identity();
31         transformS3->Identity();
32 }
33
34 /**
35 ** Transforms a volume by the given value for the X axis
36 **/
37 void wxMaracasRenderImageTransformation::Translate(int x, int y, int z)
38 {
39         transformV->Translate( x, y, z );
40         transformS1->Translate( x, y, z );
41         transformS2->Translate( x, y, z );
42         transformS3->Translate( x, y, z );
43
44         Refresh();
45 }
46
47 /**
48 ** Rotates a volume by the given degree for the X axis
49 **/
50 void wxMaracasRenderImageTransformation::Rotate(int x, int y, int z)
51 {
52         transformV->RotateX( x );
53         transformS1->RotateX( x );
54         transformS2->RotateX( x );
55         transformS3->RotateX( x );
56
57         transformV->RotateY( y );
58         transformS1->RotateY( y );
59         transformS2->RotateY( y );
60         transformS3->RotateY( y );
61
62         transformV->RotateZ( z );
63         transformS1->RotateZ( z );
64         transformS2->RotateZ( z );
65         transformS3->RotateZ( z );
66
67         Refresh();
68 }
69
70 /**
71 ** Scales a volume by the given value for the X axis
72 **/
73 void wxMaracasRenderImageTransformation::Scale(int x, int y, int z)
74 {
75         float resultX = x/100.0;
76         float resultY = y/100.0;
77         float resultZ = z/100.0;
78
79         //printf("wxMaracasRenderImageManagementPanel::Rotate int:scaleX = %d \n",x);
80         //printf("wxMaracasRenderImageManagementPanel::Rotate int:scaleY = %d \n", y);
81         //printf("wxMaracasRenderImageManagementPanel::Rotate int:scaleZ = %d \n", z);
82
83         //printf("wxMaracasRenderImageManagementPanel::Rotate float:scaleX = %f \n", resultX);
84         //printf("wxMaracasRenderImageManagementPanel::Rotate float:scaleY = %f \n", resultY);
85         //printf("wxMaracasRenderImageManagementPanel::Rotate float:scaleZ = %f \n", resultZ);
86
87         transformV->Scale( (x/100.0), (y/100.0), (z/100.0) );
88         transformS1->Scale( (x/100.0), (y/100.0), (z/100.0) );
89         transformS2->Scale( (x/100.0), (y/100.0), (z/100.0) );
90         transformS3->Scale( (x/100.0), (y/100.0), (z/100.0) );
91
92         Refresh();
93 }
94
95 /**
96 ** Updates each Matrix
97 **/
98 void wxMaracasRenderImageTransformation::Refresh()throw(char*)
99 {
100         transformV->Update();
101         transformS1->Update();
102         transformS2->Update();
103         transformS3->Update();
104
105         vol->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
106         //vol->getRenderer()->Render();
107
108         surface1->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
109         //surface1->getRenderer()->Render();
110
111         surface2->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
112         //surface2->getRenderer()->Render();
113
114         surface3->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
115         //surface3->getRenderer()->Render();
116 }