1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #include "wxMaracasRenderImageTransformation.h"
27 #include "wxMaracasRendererView.h"
32 wxMaracasRenderImageTransformation::wxMaracasRenderImageTransformation(VolumeRendererManager* _vol, wxMaracasSurfaceRenderingManager* _surface1,
33 wxMaracasSurfaceRenderingManager* _surface2, wxMaracasSurfaceRenderingManager* _surface3, int id)
41 transformV = vtkTransform::New();
42 transformS1 = vtkTransform::New();
43 transformS2 = vtkTransform::New();
44 transformS3 = vtkTransform::New();
50 wxMaracasRenderImageTransformation::~wxMaracasRenderImageTransformation()
56 ** Transforms a volume by the given value for the X axis
58 void wxMaracasRenderImageTransformation::Translate(int tx, int ty, int tz, int rx, int ry, int rz, int sx, int sy, int sz)
60 //printf("wxMaracasRenderImageManagementPanel::Rotate float:scaleX = %f \n", tx);
61 //printf("wxMaracasRenderImageManagementPanel::Rotate float:scaleY = %f \n", ty);
62 //printf("wxMaracasRenderImageManagementPanel::Rotate float:scaleZ = %f \n", tz);
67 vol->getImageData()->GetSpacing(volspX, volspY, volspZ);
72 surface1->getImageData()->GetSpacing(surfspX, surfspY, surfspZ);
75 vol->getImageData()->GetExtent(ext);
77 transformV->Identity();
78 transformS1->Identity();
79 transformS2->Identity();
80 transformS3->Identity();
82 transformV->PostMultiply();
83 transformS1->PostMultiply();
84 transformS2->PostMultiply();
85 transformS3->PostMultiply();
87 printf("CPR: wxMaracasRenderImageTransformation::Translate-> %f\n", -(ext[1]-ext[0])*volspX );
88 printf("CPR: wxMaracasRenderImageTransformation::Translate-> %f\n", -(ext[3]-ext[2])*surfspY);
89 printf("CPR: wxMaracasRenderImageTransformation::Translate-> %f\n", -(ext[5]-ext[4])*surfspZ);
91 transformV ->Translate( -(ext[1]-ext[0])*volspX/2, -(ext[3]-ext[2])*volspY/2, -(ext[5]-ext[4])*volspZ/2 );
92 transformS1->Translate( -(ext[1]-ext[0])*surfspX/2, -(ext[3]-ext[2])*surfspY/2, -(ext[5]-ext[4])*surfspZ/2 );
93 transformS2->Translate( -(ext[1]-ext[0])*surfspX/2, -(ext[3]-ext[2])*surfspY/2, -(ext[5]-ext[4])*surfspZ/2 );
94 transformS3->Translate( -(ext[1]-ext[0])*surfspX/2, -(ext[3]-ext[2])*surfspY/2, -(ext[5]-ext[4])*surfspZ/2 );
96 transformV ->Scale( (sx/100.0), (sy/100.0), (sz/100.0) );
97 transformS1->Scale( (sx/100.0), (sy/100.0), (sz/100.0) );
98 transformS2->Scale( (sx/100.0), (sy/100.0), (sz/100.0) );
99 transformS3->Scale( (sx/100.0), (sy/100.0), (sz/100.0) );
101 transformV ->RotateX( rx );
102 transformS1->RotateX( rx );
103 transformS2->RotateX( rx );
104 transformS3->RotateX( rx );
106 transformV ->RotateY( ry );
107 transformS1->RotateY( ry );
108 transformS2->RotateY( ry );
109 transformS3->RotateY( ry );
111 transformV ->RotateZ( rz );
112 transformS1->RotateZ( rz );
113 transformS2->RotateZ( rz );
114 transformS3->RotateZ( rz );
116 transformV ->Translate( tx*volspX + (ext[1]-ext[0])*volspX/2, ty*volspY + (ext[3]-ext[2])*volspY/2, tz*volspZ + (ext[5]-ext[4])*volspZ/2 );
117 transformS1->Translate( tx*surfspX + (ext[1]-ext[0])*volspX/2, ty*surfspY + (ext[3]-ext[2])*volspY/2, tz*surfspZ + (ext[5]-ext[4])*volspZ/2 );
118 transformS2->Translate( tx*surfspX + (ext[1]-ext[0])*volspX/2, ty*surfspY + (ext[3]-ext[2])*volspY/2, tz*surfspZ + (ext[5]-ext[4])*volspZ/2 );
119 transformS3->Translate( tx*surfspX + (ext[1]-ext[0])*volspX/2, ty*surfspY + (ext[3]-ext[2])*volspY/2, tz*surfspZ + (ext[5]-ext[4])*volspZ/2 );
125 ** Updates each Matrix
127 void wxMaracasRenderImageTransformation::Refresh()throw(char*)
129 transformV->Update();
130 transformS1->Update();
131 transformS2->Update();
132 transformS3->Update();
134 vol->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
135 //vol->Update(propID);
137 surface1->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
138 //surface1->Update(propID);
140 surface2->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
141 //surface2->getRenderer()->Render();
143 surface3->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
144 //surface3->getRenderer()->Render();