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