]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewRotationTool.cpp
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualViewRotationTool.cpp
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
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
8 #
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.
15 #
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
20 #  liability.
21 #
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 # ------------------------------------------------------------------------ */
25
26 #include "manualViewRotationTool.h"
27
28 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
31
32 manualViewRotationTool::manualViewRotationTool()
33 {       
34
35 }
36 // ----------------------------------------------------------------------------
37 manualViewRotationTool::~manualViewRotationTool()
38 {
39
40 }
41
42 // ----------------------------------------------------------------------------
43 manualViewRotationTool * manualViewRotationTool :: Clone()
44 {
45         manualViewRotationTool * clone = new manualViewRotationTool();
46         CopyAttributesTo(clone);
47         return clone;
48 }
49
50 // ---------------------------------------------------------------------------
51 void manualViewRotationTool::CopyAttributesTo( manualViewRotationTool * cloneObject)
52 {
53         manualViewBaseContour::CopyAttributesTo(cloneObject);
54 }
55
56 // ----------------------------------------------------------------------------
57 int manualViewRotationTool::GetType() // virtual
58 {
59         return 8;
60 }
61
62 // ----------------------------------------------------------------------------
63 void manualViewRotationTool::GetMinMax(double &minX,double &minY, double &maxX, double &maxY)
64 {
65         manualPoint     *mpA,*mpB;
66     unsigned int  np;
67         double radio;
68         double difX,difY;
69     np  = GetNumberOfPoints( );
70         
71         if (np==3)
72         {
73                 mpA             = _manContModel->GetManualPoint(0);
74                 mpB             = _manContModel->GetManualPoint(1);
75                 difX    = mpA->GetX() - mpB->GetX();
76                 difY    = mpA->GetY() - mpB->GetY();
77                 radio   = sqrt( difX*difX + difY*difY );
78                 minX=mpA->GetX()-radio;
79                 minY=mpA->GetY()-radio;
80                 maxX=mpA->GetX()+radio;
81                 maxY=mpA->GetY()+radio;
82         } 
83         else 
84         {
85                 minX=0;
86                 maxX=0;
87                 minY=0;
88                 maxY=0;
89         }
90 }
91
92 // ----------------------------------------------------------------------------
93
94 void manualViewRotationTool::InitMove(int x, int y, int z)  // virtual
95 {
96         manualPoint *mp;
97         double XX=x;
98         double YY=y;
99         double ZZ=z;
100         TransfromCoordViewWorld(XX,YY,ZZ);
101
102         if (_manContModel->GetSizeLstPoints()==3)
103         {
104                 mp = _manContModel->GetManualPoint(0);
105                 _dp0[0]= mp->GetX() - XX;
106                 _dp0[1]= mp->GetY() - YY;
107                 _dp0[2]= mp->GetZ();
108
109                 mp = _manContModel->GetManualPoint(1);
110                 _dp1[0]= mp->GetX() - XX;
111                 _dp1[1]= mp->GetY() - YY;
112                 _dp1[2]= mp->GetZ();
113
114                 mp = _manContModel->GetManualPoint(2);
115                 _dp2[0]= mp->GetX() - XX;
116                 _dp2[1]= mp->GetY() - YY;
117                 _dp2[2]= mp->GetZ();
118
119         }
120 }
121
122 // ----------------------------------------------------------------------------
123 void manualViewRotationTool::MoveContour(int x, int y, int z) // virtual
124 {
125         manualPoint *mp;
126         double XX=x;
127         double YY=y;
128         double ZZ=z;
129         TransfromCoordViewWorld(XX,YY,ZZ);
130
131         mp = _manContModel->GetManualPoint(0);
132         mp->SetPoint(_dp0[0]+XX,_dp0[1]+YY,_dp0[2]);
133
134         mp = _manContModel->GetManualPoint(1);
135         mp->SetPoint(_dp1[0]+XX,_dp1[1]+YY,_dp0[2]);
136
137         mp = _manContModel->GetManualPoint(2);
138         mp->SetPoint(_dp2[0]+XX,_dp2[1]+YY,_dp0[2]);
139
140         UpdateViewPoint(0);
141         UpdateViewPoint(1);
142         UpdateViewPoint(2);
143 }