]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualLineControler.cpp
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualLineControler.cpp
1 #include "manualLineControler.h"
2
3 // ----------------------------------------------------------------------------
4 // ----------------------------------------------------------------------------
5 // ----------------------------------------------------------------------------
6
7 // AD:02-09
8
9 // _state = 0  // ..nothing..
10 // _state = 5  // move point
11 // _state = 6  // move all
12 // _state = 7  // Empty mouse drag
13
14 manualLineControler::manualLineControler()
15 {
16 }
17 // ----------------------------------------------------------------------------
18 manualLineControler::~manualLineControler()
19 {
20 }
21 // ----------------------------------------------------------------------------
22 manualLineControler * manualLineControler :: Clone()  // virtual 
23 {
24         manualLineControler * clone = new manualLineControler();
25         CopyAttributesTo(clone);
26         return clone;
27 }
28
29 // ---------------------------------------------------------------------------
30 void manualLineControler::CopyAttributesTo( manualLineControler * cloneObject)
31 {
32         // Fathers object
33         manualContourBaseControler::CopyAttributesTo(cloneObject);
34 }
35
36
37 // ----------------------------------------------------------------------------
38 void manualLineControler::MouseClickLeft(int x, int y){
39         int z = GetZ();
40         
41         if( IsEditable() )
42         {       // move control point
43           if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){
44                   bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);   
45                   SetState(5);
46           }
47         } //IsEditable
48         
49         // move contour
50         if ((GetState()==0) && (GetManualViewBaseContour()->GetPosibleSelected()==true))        { 
51                 GetManualViewBaseContour()->InitMove(x,y,z);
52                 SetState(6);
53         }
54         
55         // fist time create 2 control points and move a control point
56         int size=GetManualViewBaseContour()->GetNumberOfPoints();
57         if (GetState()==0) { 
58                 if (size==0){
59                         AddPoint(x,y,z); 
60                         AddPoint(x,y,z); 
61                         bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);     
62                         SetState(1);
63                 }
64         }
65         
66         
67 /*EED 21 Avril 2009             
68         if (GetState()==0) { 
69                 if (size==0){
70                         AddPoint(x,y,z); 
71                         AddPoint(x,y,z); 
72                 } else {
73                         SetPoint(0,x,y,z); 
74                         SetPoint(1,x,y,z); 
75                 }
76                 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);     
77                 SetState(5);
78         }
79 */
80         
81         GetManualViewBaseContour()->Refresh();
82 }
83 // ----------------------------------------------------------------------------
84
85 void manualLineControler::MouseMove(int x, int y) // virtual
86 {
87         int z=GetZ();
88
89         GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
90         GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
91
92         if (GetState()==1) { SetPoint( bakIdPoint , x , y ,z); }
93         if (GetState()==5) { SetPoint( bakIdPoint , x , y ,z); }
94         
95         if (GetState()==6)
96         {       
97                 GetManualViewBaseContour()->MoveContour(x,y,z);
98         }
99         GetManualViewBaseContour()->Refresh();
100 }
101
102
103 // ----------------------------------------------------------------------------
104 void manualLineControler::DeleteActualMousePoint(int x, int y)  // virtual
105
106 }
107 // ----------------------------------------------------------------------------
108
109 void manualLineControler::InitRoi(int ww, int hh, double porcentage)
110 {
111         int zz;
112         manualPoint *mp;
113
114         if (GetManualContourModel()->GetSizeLstPoints() ==0)
115         {
116                 zz = GetZ();
117                 AddPoint(0,0,zz);
118                 AddPoint(0,0,zz);
119         }
120
121         double pp1=porcentage;
122         double pp2=1-porcentage;
123
124         mp = GetManualContourModel()->GetManualPoint(0);
125         zz=(int)mp->GetZ();
126         mp->SetPoint(ww*pp2,hh*pp2,zz);
127
128         mp = GetManualContourModel()->GetManualPoint(1);
129         zz=(int)mp->GetZ();
130         mp->SetPoint(ww*pp2,hh*pp1,zz);
131
132         GetManualViewBaseContour() ->UpdateViewPoint(0);
133         GetManualViewBaseContour() ->UpdateViewPoint(1);
134
135         SetState(0);
136         GetManualViewBaseContour()->Refresh();  
137 }