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 # ------------------------------------------------------------------------ */
27 #include <wx/tooltip.h>
28 #include <wx/config.h>
30 #include <iostream> // for std::cout
32 #include "wxMaracasRenderImageTransformation.h"
33 #include "wxMaracasRendererView.h"
38 wxMaracasRenderImageTransformation::wxMaracasRenderImageTransformation(VolumeRendererManager* _vol, wxMaracasSurfaceRenderingManager* _surface1,
39 wxMaracasSurfaceRenderingManager* _surface2, wxMaracasSurfaceRenderingManager* _surface3, int id)
47 transformV = vtkTransform::New();
48 transformS1 = vtkTransform::New();
49 transformS2 = vtkTransform::New();
50 transformS3 = vtkTransform::New();
56 wxMaracasRenderImageTransformation::~wxMaracasRenderImageTransformation()
62 ** Transforms a volume by the given value for the X axis
64 void wxMaracasRenderImageTransformation::Translate(int tx, int ty, int tz, int rx, int ry, int rz, int sx, int sy, int sz)
66 //printf("wxMaracasRenderImageManagementPanel::Rotate float:scaleX = %f \n", tx);
67 //printf("wxMaracasRenderImageManagementPanel::Rotate float:scaleY = %f \n", ty);
68 //printf("wxMaracasRenderImageManagementPanel::Rotate float:scaleZ = %f \n", tz);
73 vol->getImageData()->GetSpacing(volspX, volspY, volspZ);
78 surface1->getImageData()->GetSpacing(surfspX, surfspY, surfspZ);
81 vol->getImageData()->GetExtent(ext);
83 transformV->Identity();
84 transformS1->Identity();
85 transformS2->Identity();
86 transformS3->Identity();
88 transformV->PostMultiply();
89 transformS1->PostMultiply();
90 transformS2->PostMultiply();
91 transformS3->PostMultiply();
93 printf("CPR: wxMaracasRenderImageTransformation::Translate-> %f\n", -(ext[1]-ext[0])*volspX );
94 printf("CPR: wxMaracasRenderImageTransformation::Translate-> %f\n", -(ext[3]-ext[2])*surfspY);
95 printf("CPR: wxMaracasRenderImageTransformation::Translate-> %f\n", -(ext[5]-ext[4])*surfspZ);
97 transformV ->Translate( -(ext[1]-ext[0])*volspX/2, -(ext[3]-ext[2])*volspY/2, -(ext[5]-ext[4])*volspZ/2 );
98 transformS1->Translate( -(ext[1]-ext[0])*surfspX/2, -(ext[3]-ext[2])*surfspY/2, -(ext[5]-ext[4])*surfspZ/2 );
99 transformS2->Translate( -(ext[1]-ext[0])*surfspX/2, -(ext[3]-ext[2])*surfspY/2, -(ext[5]-ext[4])*surfspZ/2 );
100 transformS3->Translate( -(ext[1]-ext[0])*surfspX/2, -(ext[3]-ext[2])*surfspY/2, -(ext[5]-ext[4])*surfspZ/2 );
102 transformV ->Scale( (sx/100.0), (sy/100.0), (sz/100.0) );
103 transformS1->Scale( (sx/100.0), (sy/100.0), (sz/100.0) );
104 transformS2->Scale( (sx/100.0), (sy/100.0), (sz/100.0) );
105 transformS3->Scale( (sx/100.0), (sy/100.0), (sz/100.0) );
107 transformV ->RotateX( rx );
108 transformS1->RotateX( rx );
109 transformS2->RotateX( rx );
110 transformS3->RotateX( rx );
112 transformV ->RotateY( ry );
113 transformS1->RotateY( ry );
114 transformS2->RotateY( ry );
115 transformS3->RotateY( ry );
117 transformV ->RotateZ( rz );
118 transformS1->RotateZ( rz );
119 transformS2->RotateZ( rz );
120 transformS3->RotateZ( rz );
122 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 );
123 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 );
124 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 );
125 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 );
131 ** Updates each Matrix
133 void wxMaracasRenderImageTransformation::Refresh()throw(char*)
135 transformV->Update();
136 transformS1->Update();
137 transformS2->Update();
138 transformS3->Update();
140 vol->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
141 //vol->Update(propID);
143 surface1->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
144 //surface1->Update(propID);
146 surface2->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
147 //surface2->getRenderer()->Render();
149 surface3->getViewData(propID)->getProp3D()->SetUserMatrix(transformV->GetMatrix());
150 //surface3->getRenderer()->Render();