]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourPerpPlaneControler.cpp
DFCH: imageUndoRedo + Manual Paint: It doesn't works :s :s
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualContourPerpPlaneControler.cpp
1 #include "manualContourPerpPlaneControler.h"
2
3 // ----------------------------------------------------------------------------
4 // ----------------------------------------------------------------------------
5 // ----------------------------------------------------------------------------
6 manualContourPerpPlaneControler::manualContourPerpPlaneControler()
7 {
8         _flagMouseMove = true;
9 }
10 // ----------------------------------------------------------------------------
11 manualContourPerpPlaneControler::~manualContourPerpPlaneControler()
12 {
13 }
14 // ----------------------------------------------------------------------------
15 manualContourPerpPlaneControler * manualContourPerpPlaneControler :: Clone()  // virtual
16 {
17         manualContourPerpPlaneControler * clone = new manualContourPerpPlaneControler();
18         CopyAttributesTo(clone);
19         return clone;
20 }
21
22 // ---------------------------------------------------------------------------
23 void manualContourPerpPlaneControler::CopyAttributesTo( manualContourPerpPlaneControler * cloneObject)
24 {
25         // Fathers object
26         manualContourControler::CopyAttributesTo(cloneObject);
27
28         cloneObject->SetVtkMPRBaseData( this->GetVtkMPRBaseData() );
29         cloneObject->SetManualContour3VControler( this->GetManualContour3VControler() );
30         cloneObject->SetVtkInteractorStylePlane2D( this->GetVtkInteractorStylePlane2D() );
31 }
32
33 // ----------------------------------------------------------------------------
34 void manualContourPerpPlaneControler::SetVtkMPRBaseData(vtkMPRBaseData *vtkmprbasedata)
35 {
36         _vtkmprbasedata = vtkmprbasedata;
37 }
38
39 // ----------------------------------------------------------------------------
40 vtkMPRBaseData *manualContourPerpPlaneControler::GetVtkMPRBaseData()
41 {
42         return _vtkmprbasedata;
43 }
44
45
46 // ----------------------------------------------------------------------------
47 void manualContourPerpPlaneControler::InsertPoint(int x, int y, int z ) // virtual
48 {
49         manualContourControler::InsertPoint(  x,  y,  z );
50         _manualcontour3Vcontroler->InsertPoint_Others(0);
51 }
52 // ----------------------------------------------------------------------------
53 void manualContourPerpPlaneControler::AddPoint( int x, int y, int z )
54 {
55         manualContourControler::AddPoint(  x,  y,  z );
56         _manualcontour3Vcontroler->AddPoint_Others();
57 }
58 // ----------------------------------------------------------------------------
59 void manualContourPerpPlaneControler::DeleteActualMousePoint(int x, int y)
60 {
61         int id = GetManualViewBaseContour()->GetIdPoint ( x , y , GetZ() );
62         manualContourControler::DeleteActualMousePoint( x , y );
63         _manualcontour3Vcontroler->DeleteActualMousePoint_Others(id);
64 }
65 // ----------------------------------------------------------------------------
66 void manualContourPerpPlaneControler::MouseMove( int x, int y )
67 {
68         _flagMouseMove = true;
69         int ss =this->_vtkInteractorStyleBaseView->vtkInteractorStyle::GetState();
70         if ((this->GetState()!=7) && (ss!=1)){
71                 manualContourControler::MouseMove( x , y );
72                 int id = GetManualViewBaseContour()->GetIdPoint ( x , y , GetZ() );
73                 if (id!=-1)
74                 {
75                         _manualcontour3Vcontroler->MouseMove_Others(id);
76                         _flagMouseMove = false;
77                 }
78         }
79 }
80 // ----------------------------------------------------------------------------
81 void manualContourPerpPlaneControler::SetManualContour3VControler(manualContour3VControler *manualcontour3Vcontroler)
82 {
83         _manualcontour3Vcontroler = manualcontour3Vcontroler;
84 }
85 // ----------------------------------------------------------------------------
86 manualContour3VControler * manualContourPerpPlaneControler::GetManualContour3VControler()
87 {
88         return _manualcontour3Vcontroler;
89 }
90 // ----------------------------------------------------------------------------
91 bool manualContourPerpPlaneControler::OnChar() // virtual
92 {
93         if (manualContourControler::OnChar()==false )
94         {
95                 _manualcontour3Vcontroler->OnChar_Others();
96         }
97         return true;
98 }
99 // ----------------------------------------------------------------------------
100 bool manualContourPerpPlaneControler::OnMouseMove() //  virtual
101 {
102         manualContourControler::OnMouseMove();
103         return _flagMouseMove;
104 }
105 // ----------------------------------------------------------------------------
106 bool manualContourPerpPlaneControler::OnLeftDClick() //         virtual
107 {
108         manualContourControler::OnLeftDClick();
109         return _flagMouseDClick;
110 }
111 // ----------------------------------------------------------------------------
112 void manualContourPerpPlaneControler::ResetContour() // virtual
113 {
114         manualContourControler::ResetContour();
115         _manualcontour3Vcontroler->ResetContour_Others();
116 }
117
118 // ----------------------------------------------------------------------------
119 void manualContourPerpPlaneControler::MouseDLeft( int x, int y) // virtual
120 {
121         _flagMouseDClick=true;
122         manualContourControler::MouseDLeft(x,y);
123
124         if (GetManualViewBaseContour()->ifTouchContour(x,y,0)==true)
125         {
126                 _flagMouseDClick = false;
127                 _vtkinteractorstyleplane2D->OnLeftDClick();
128                 ResetOrientationPlane();
129                 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
130         }
131
132 //      int id=GetManualViewBaseContour()->GetIdPoint(x,y,GetZ());
133 //              if ( (GetState()==0) && (id!=-1) )
134 //      {
135 //              manualPoint *mp = this->GetManualContourModel()->GetManualPoint(id);
136 //              _vtkmprbasedata->SetX( mp->GetX() );
137 //              _vtkmprbasedata->SetY( mp->GetY() );
138 //              _vtkmprbasedata->SetZ( mp->GetZ() );
139 //              ResetOrientationPlane();
140 //              this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
141 //      }
142 }
143
144
145
146 // ----------------------------------------------------------------------------
147 void manualContourPerpPlaneControler::ResetOrientationPlane()
148 {
149         double p[3],rp[3],rn[3];
150         p[0] = _vtkmprbasedata->GetX(  );
151         p[1] = _vtkmprbasedata->GetY(  );
152         p[2] = _vtkmprbasedata->GetZ(  );
153         this->GetManualContourModel()->GetNearestPointAndNormal(p,rp,rn);
154
155         _vtkmprbasedata->SetNormal(rn[0],rn[1],rn[2]);
156 }
157
158 // ----------------------------------------------------------------------------
159 void manualContourPerpPlaneControler::SetVtkInteractorStylePlane2D(InteractorStyleMaracas *vtkinteractorstyleplane2D)
160 {
161         _vtkinteractorstyleplane2D = vtkinteractorstyleplane2D;
162 }
163 // ----------------------------------------------------------------------------
164 InteractorStyleMaracas * manualContourPerpPlaneControler::GetVtkInteractorStylePlane2D()
165 {
166         return _vtkinteractorstyleplane2D;
167 }
168