]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualRotationToolControler.cpp
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualRotationToolControler.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 "manualRotationToolControler.h"
27
28 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
31
32 // _state = 0  // ..nothing..
33 // _state = 5  // move point
34 // _state = 6  // move all
35 // _state = 7  // Empty mouse drag
36
37 manualRotationToolControler::manualRotationToolControler()
38 {
39
40 }
41
42 // ----------------------------------------------------------------------------
43 manualRotationToolControler::~manualRotationToolControler()
44 {
45
46 }
47
48 // ----------------------------------------------------------------------------
49 manualRotationToolControler * manualRotationToolControler :: Clone()  // virtual
50 {
51         manualRotationToolControler * clone = new manualRotationToolControler();
52         CopyAttributesTo(clone);
53         return clone;
54 }
55
56 // ---------------------------------------------------------------------------
57 void manualRotationToolControler::CopyAttributesTo( manualRotationToolControler * cloneObject)
58 {
59         // Fathers object
60         manualContourBaseControler::CopyAttributesTo(cloneObject);
61 }
62
63 // ----------------------------------------------------------------------------
64 void manualRotationToolControler::Configure() //virtual
65 {
66
67 }
68
69 // ----------------------------------------------------------------------------
70 void manualRotationToolControler::MouseClickLeft(int x, int y)
71 {
72         int z = GetZ();
73         
74         if( IsEditable() )
75         {       // move control point
76           if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){
77                   bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
78                   SetState(5);
79           }
80         }// IsEditable
81         
82         // move contour
83         if ((GetState()==0) && (GetManualViewBaseContour()->GetPosibleSelected()==true))        {
84                 GetManualViewBaseContour()->InitMove(x,y,z);
85                 SetState(6);
86         }
87         
88         // firstime create 3 control points and move one control point
89         int size=GetManualViewBaseContour()->GetNumberOfPoints();
90         if (GetState()==0) {
91                 if (size==0){
92                         AddPoint(x,y,z);
93                         AddPoint(x,y,z);
94                         bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
95                         AddPoint(x,y,z);
96                         SetState(1);
97                 }
98         }       
99         
100         GetManualViewBaseContour()->Refresh();
101 }
102
103 // ----------------------------------------------------------------------------
104 void manualRotationToolControler::MouseMove(int x, int y) // virtual
105 {
106         int z=GetZ();
107
108         GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
109         GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
110
111         if (GetState()==1){     SetPoint( bakIdPoint , x , y ,z); }
112         if (GetState()==5){     SetPoint( bakIdPoint , x , y ,z); }
113         
114         if (GetState()==6){
115                 GetManualViewBaseContour()->MoveContour(x,y,z);
116         }
117         GetManualViewBaseContour()->Refresh();
118 }
119
120 // ----------------------------------------------------------------------------
121 void manualRotationToolControler::DeleteActualMousePoint(int x, int y)  // virtual
122 {
123 }
124
125 // ----------------------------------------------------------------------------
126 void manualRotationToolControler::InitRoi(int ww, int hh, double porcentage)
127 {
128         int zz;
129         manualPoint *mp;
130
131         if (GetManualContourModel()->GetSizeLstPoints() ==0)
132         {
133                 zz = GetZ();
134                 AddPoint(0,0,zz);
135                 AddPoint(0,0,zz);
136                 AddPoint(0,0,zz);
137         }
138
139         double pp1=porcentage;
140         double pp2=1-porcentage;
141
142         mp = GetManualContourModel()->GetManualPoint(2);
143         zz=(int)mp->GetZ();
144         mp->SetPoint(ww*pp1,hh*pp1,zz);
145
146         mp = GetManualContourModel()->GetManualPoint(1);
147         zz=(int)mp->GetZ();
148         cout <<  ww*pp2 <<hh*pp1 << zz<<endl;
149         mp->SetPoint(ww*pp2,hh*pp1,zz);
150
151         mp = GetManualContourModel()->GetManualPoint(0);
152         zz=(int)mp->GetZ();
153         cout <<  ww*pp2 <<hh*pp2 << zz<<endl;
154         mp->SetPoint(ww*pp2,hh*pp2,zz);
155
156         GetManualViewBaseContour() ->UpdateViewPoint(0);
157         GetManualViewBaseContour() ->UpdateViewPoint(1);
158         GetManualViewBaseContour() ->UpdateViewPoint(2);
159
160         SetState(0);
161         GetManualViewBaseContour()->Refresh();
162 }