]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualCircleControler.cpp
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualCircleControler.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 "manualCircleControler.h"
27
28 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
31
32 // EED08
33
34 // _state = 0  // ..nothing..
35 // _state = 5  // move point
36 // _state = 6  // move all
37 // _state = 7  // Empty mouse drag
38
39 manualCircleControler::manualCircleControler()
40 {
41 }
42 // ----------------------------------------------------------------------------
43 manualCircleControler::~manualCircleControler()
44 {
45 }
46 // ----------------------------------------------------------------------------
47 manualCircleControler * manualCircleControler :: Clone()  // virtual
48 {
49         manualCircleControler * clone = new manualCircleControler();
50         CopyAttributesTo(clone);
51         return clone;
52 }
53
54 // ---------------------------------------------------------------------------
55 void manualCircleControler::CopyAttributesTo( manualCircleControler * cloneObject)
56 {
57         // Fathers object
58         manualContourBaseControler::CopyAttributesTo(cloneObject);
59 }
60
61 // ----------------------------------------------------------------------------
62 void manualCircleControler::Configure() //virtual
63 {
64 //      this->GetManualContourModel()->SetNumberOfPointsSpline(5);
65 }
66
67 // ----------------------------------------------------------------------------
68 void manualCircleControler::MouseClickLeft(int x, int y){
69         int z = GetZ();
70         
71         if( IsEditable() )
72         {       // move control point
73           if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){
74                   bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
75                   SetState(5);
76           }
77         }// IsEditable
78         
79         // move contour
80         if ((GetState()==0) && (GetManualViewBaseContour()->GetPosibleSelected()==true))        {
81                 GetManualViewBaseContour()->InitMove(x,y,z);
82                 SetState(6);
83         }
84         
85         // firstime create 2 control points and move one control point
86         int size=GetManualViewBaseContour()->GetNumberOfPoints();
87         if (GetState()==0) {
88                 if (size==0){
89                         AddPoint(x,y,z);
90                         AddPoint(x,y,z);
91                         bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
92                         SetState(1);
93                 }
94         }       
95         
96 /*EED 21 Avril 2009     
97         if (GetState()==0) {
98                 if (size==0){
99                         AddPoint(x,y,z);
100                         AddPoint(x,y,z);
101                 } else {
102                         SetPoint(0,x,y,z);
103                         SetPoint(1,x,y,z);
104                 }
105                 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
106                 SetState(5);
107         }
108 */
109         
110         GetManualViewBaseContour()->Refresh();
111 }
112 // ----------------------------------------------------------------------------
113
114 void manualCircleControler::MouseMove(int x, int y) // virtual
115 {
116         int z=GetZ();
117 //      this->_vtkInteractorStyleBaseView->
118
119         GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
120         GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
121
122         if (GetState()==1){     SetPoint( bakIdPoint , x , y ,z); }
123         if (GetState()==5){     SetPoint( bakIdPoint , x , y ,z); }
124         
125         if (GetState()==6){
126                 GetManualViewBaseContour()->MoveContour(x,y,z);
127         }
128         GetManualViewBaseContour()->Refresh();
129 }
130
131
132 // ----------------------------------------------------------------------------
133 void manualCircleControler::DeleteActualMousePoint(int x, int y)  // virtual
134 {
135 }
136 // ----------------------------------------------------------------------------
137
138 void manualCircleControler::InitRoi(int ww, int hh, double porcentage)
139 {
140         int zz;
141         manualPoint *mp;
142
143         if (GetManualContourModel()->GetSizeLstPoints() ==0)
144         {
145                 zz = GetZ();
146                 AddPoint(0,0,zz);
147                 AddPoint(0,0,zz);
148 //              AddPoint(0,0,zz);
149 //              AddPoint(0,0,zz);
150         }
151
152         double pp1=porcentage;
153         double pp2=1-porcentage;
154
155 //      mp = GetManualContourModel()->GetManualPoint(2);
156 //      zz=(int)mp->GetZ();
157 //      mp->SetPoint(ww*pp1,hh*pp1,zz);
158
159         mp = GetManualContourModel()->GetManualPoint(1);
160         zz=(int)mp->GetZ();
161         mp->SetPoint(ww*pp2,hh*pp1,zz);
162
163         mp = GetManualContourModel()->GetManualPoint(0);
164         zz=(int)mp->GetZ();
165         mp->SetPoint(ww*pp2,hh*pp2,zz);
166
167 //      mp = GetManualContourModel()->GetManualPoint(3);
168 //      zz=(int)mp->GetZ();
169 //      mp->SetPoint(ww*pp1,hh*pp2,zz);
170
171         GetManualViewBaseContour() ->UpdateViewPoint(0);
172         GetManualViewBaseContour() ->UpdateViewPoint(1);
173 //      GetManualViewBaseContour() ->UpdateViewPoint(2);
174 //      GetManualViewBaseContour() ->UpdateViewPoint(3);
175
176         SetState(0);
177         GetManualViewBaseContour()->Refresh();
178 }
179
180 // ----------------------------------------------------------------------------
181 /*
182 void manualCircleControler::SetRoi(int x1, int y1,int x2, int y2)
183 {
184         manualPoint *mp;
185         InitRoi( 0 , 0 , 0.2 );
186         mp = GetManualContourModel()->GetManualPoint(2);
187         mp->SetPointX(x1);
188         mp->SetPointY(y1);
189
190         mp = GetManualContourModel()->GetManualPoint(1);
191         mp->SetPointX(x2);
192         mp->SetPointY(y1);
193
194         mp = GetManualContourModel()->GetManualPoint(0);
195         mp->SetPointX(x2);
196         mp->SetPointY(y2);
197
198         mp = GetManualContourModel()->GetManualPoint(3);
199         mp->SetPointX(x1);
200         mp->SetPointY(y2);
201
202         GetManualViewBaseContour() ->UpdateViewPoint(0);
203         GetManualViewBaseContour() ->UpdateViewPoint(1);
204         GetManualViewBaseContour() ->UpdateViewPoint(2);
205         GetManualViewBaseContour() ->UpdateViewPoint(3);
206 }
207 */