]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourPerpPlaneControler.cpp
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualContourPerpPlaneControler.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 "manualContourPerpPlaneControler.h"
27
28 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
31 manualContourPerpPlaneControler::manualContourPerpPlaneControler()
32 {
33         _flagMouseMove = true;
34 }
35 // ----------------------------------------------------------------------------
36 manualContourPerpPlaneControler::~manualContourPerpPlaneControler()
37 {
38 }
39 // ----------------------------------------------------------------------------
40 manualContourPerpPlaneControler * manualContourPerpPlaneControler :: Clone()  // virtual
41 {
42         manualContourPerpPlaneControler * clone = new manualContourPerpPlaneControler();
43         CopyAttributesTo(clone);
44         return clone;
45 }
46
47 // ---------------------------------------------------------------------------
48 void manualContourPerpPlaneControler::CopyAttributesTo( manualContourPerpPlaneControler * cloneObject)
49 {
50         // Fathers object
51         manualContourControler::CopyAttributesTo(cloneObject);
52
53         cloneObject->SetVtkMPRBaseData( this->GetVtkMPRBaseData() );
54         cloneObject->SetManualContour3VControler( this->GetManualContour3VControler() );
55         cloneObject->SetVtkInteractorStylePlane2D( this->GetVtkInteractorStylePlane2D() );
56 }
57
58 // ----------------------------------------------------------------------------
59 void manualContourPerpPlaneControler::SetVtkMPRBaseData(vtkMPRBaseData *vtkmprbasedata)
60 {
61         _vtkmprbasedata = vtkmprbasedata;
62 }
63
64 // ----------------------------------------------------------------------------
65 vtkMPRBaseData *manualContourPerpPlaneControler::GetVtkMPRBaseData()
66 {
67         return _vtkmprbasedata;
68 }
69
70
71 // ----------------------------------------------------------------------------
72 void manualContourPerpPlaneControler::InsertPoint(int x, int y, int z ) // virtual
73 {
74         manualContourControler::InsertPoint(  x,  y,  z );
75         _manualcontour3Vcontroler->InsertPoint_Others(0);
76 }
77 // ----------------------------------------------------------------------------
78 void manualContourPerpPlaneControler::AddPoint( int x, int y, int z )
79 {
80         manualContourControler::AddPoint(  x,  y,  z );
81         _manualcontour3Vcontroler->AddPoint_Others();
82 }
83 // ----------------------------------------------------------------------------
84 void manualContourPerpPlaneControler::DeleteActualMousePoint(int x, int y)
85 {
86         int id = GetManualViewBaseContour()->GetIdPoint ( x , y , GetZ() );
87         manualContourControler::DeleteActualMousePoint( x , y );
88         _manualcontour3Vcontroler->DeleteActualMousePoint_Others(id);
89 }
90 // ----------------------------------------------------------------------------
91 void manualContourPerpPlaneControler::MouseMove( int x, int y )
92 {
93         _flagMouseMove = true;
94         int ss =this->_vtkInteractorStyleBaseView->vtkInteractorStyle::GetState();
95         if ((this->GetState()!=7) && (ss!=1)){
96                 manualContourControler::MouseMove( x , y );
97                 int id = GetManualViewBaseContour()->GetIdPoint ( x , y , GetZ() );
98                 if (id!=-1)
99                 {
100                         _manualcontour3Vcontroler->MouseMove_Others(id);
101                         _flagMouseMove = false;
102                 }
103         }
104 }
105 // ----------------------------------------------------------------------------
106 void manualContourPerpPlaneControler::SetManualContour3VControler(manualContour3VControler *manualcontour3Vcontroler)
107 {
108         _manualcontour3Vcontroler = manualcontour3Vcontroler;
109 }
110 // ----------------------------------------------------------------------------
111 manualContour3VControler * manualContourPerpPlaneControler::GetManualContour3VControler()
112 {
113         return _manualcontour3Vcontroler;
114 }
115 // ----------------------------------------------------------------------------
116 bool manualContourPerpPlaneControler::OnChar() // virtual
117 {
118         if (manualContourControler::OnChar()==false )
119         {
120                 _manualcontour3Vcontroler->OnChar_Others();
121         }
122         return true;
123 }
124 // ----------------------------------------------------------------------------
125 bool manualContourPerpPlaneControler::OnMouseMove() //  virtual
126 {
127         manualContourControler::OnMouseMove();
128         return _flagMouseMove;
129 }
130 // ----------------------------------------------------------------------------
131 bool manualContourPerpPlaneControler::OnLeftDClick() //         virtual
132 {
133         manualContourControler::OnLeftDClick();
134         return _flagMouseDClick;
135 }
136 // ----------------------------------------------------------------------------
137 void manualContourPerpPlaneControler::ResetContour() // virtual
138 {
139         manualContourControler::ResetContour();
140         _manualcontour3Vcontroler->ResetContour_Others();
141 }
142
143 // ----------------------------------------------------------------------------
144 void manualContourPerpPlaneControler::MouseDLeft( int x, int y) // virtual
145 {
146         _flagMouseDClick=true;
147         manualContourControler::MouseDLeft(x,y);
148
149         if (GetManualViewBaseContour()->ifTouchContour(x,y,0)==true)
150         {
151                 _flagMouseDClick = false;
152                 _vtkinteractorstyleplane2D->OnLeftDClick();
153                 ResetOrientationPlane();
154                 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
155         }
156
157 //      int id=GetManualViewBaseContour()->GetIdPoint(x,y,GetZ());
158 //              if ( (GetState()==0) && (id!=-1) )
159 //      {
160 //              manualPoint *mp = this->GetManualContourModel()->GetManualPoint(id);
161 //              _vtkmprbasedata->SetX( mp->GetX() );
162 //              _vtkmprbasedata->SetY( mp->GetY() );
163 //              _vtkmprbasedata->SetZ( mp->GetZ() );
164 //              ResetOrientationPlane();
165 //              this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
166 //      }
167 }
168
169
170
171 // ----------------------------------------------------------------------------
172 void manualContourPerpPlaneControler::ResetOrientationPlane()
173 {
174         double p[3],rp[3],rn[3];
175         p[0] = _vtkmprbasedata->GetX(  );
176         p[1] = _vtkmprbasedata->GetY(  );
177         p[2] = _vtkmprbasedata->GetZ(  );
178         this->GetManualContourModel()->GetNearestPointAndNormal(p,rp,rn);
179
180         _vtkmprbasedata->SetNormal(rn[0],rn[1],rn[2]);
181 }
182
183 // ----------------------------------------------------------------------------
184 void manualContourPerpPlaneControler::SetVtkInteractorStylePlane2D(InteractorStyleMaracas *vtkinteractorstyleplane2D)
185 {
186         _vtkinteractorstyleplane2D = vtkinteractorstyleplane2D;
187 }
188 // ----------------------------------------------------------------------------
189 InteractorStyleMaracas * manualContourPerpPlaneControler::GetVtkInteractorStylePlane2D()
190 {
191         return _vtkinteractorstyleplane2D;
192 }
193