]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracasRenderImageTransformation.cpp
587ace66686c7d1cdcad2e3c1c222427d227b50d
[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 ** Scales a volume by the given value for the X axis
85 *
86 void wxMaracasRenderImageTransformation::Scale(int x, int y, int z)
87 {
88         float resultX = x/100.0;
89         float resultY = y/100.0;
90         float resultZ = z/100.0;
91
92         //printf("wxMaracasRenderImageManagementPanel::Rotate int:scaleX = %d \n",x);
93         //printf("wxMaracasRenderImageManagementPanel::Rotate int:scaleY = %d \n", y);
94         //printf("wxMaracasRenderImageManagementPanel::Rotate int:scaleZ = %d \n", z);
95
96         Refresh();
97 }*/
98
99 /**
100 ** Updates each Matrix
101 **/
102 void wxMaracasRenderImageTransformation::Refresh()throw(char*)
103 {
104         transformV->Update();
105         transformS1->Update();
106         transformS2->Update();
107         transformS3->Update();
108
109         vol->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
110         //vol->getRenderer()->Render();
111
112         surface1->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
113         //surface1->getRenderer()->Render();
114
115         surface2->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
116         //surface2->getRenderer()->Render();
117
118         surface3->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
119         //surface3->getRenderer()->Render();
120 }