1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
26 #include "manualContourPerpPlaneControler.h"
28 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
31 manualContourPerpPlaneControler::manualContourPerpPlaneControler()
33 _flagMouseMove = true;
35 // ----------------------------------------------------------------------------
36 manualContourPerpPlaneControler::~manualContourPerpPlaneControler()
39 // ----------------------------------------------------------------------------
40 manualContourPerpPlaneControler * manualContourPerpPlaneControler :: Clone() // virtual
42 manualContourPerpPlaneControler * clone = new manualContourPerpPlaneControler();
43 CopyAttributesTo(clone);
47 // ---------------------------------------------------------------------------
48 void manualContourPerpPlaneControler::CopyAttributesTo( manualContourPerpPlaneControler * cloneObject)
51 manualContourControler::CopyAttributesTo(cloneObject);
53 cloneObject->SetVtkMPRBaseData( this->GetVtkMPRBaseData() );
54 cloneObject->SetManualContour3VControler( this->GetManualContour3VControler() );
55 cloneObject->SetVtkInteractorStylePlane2D( this->GetVtkInteractorStylePlane2D() );
58 // ----------------------------------------------------------------------------
59 void manualContourPerpPlaneControler::SetVtkMPRBaseData(vtkMPRBaseData *vtkmprbasedata)
61 _vtkmprbasedata = vtkmprbasedata;
64 // ----------------------------------------------------------------------------
65 vtkMPRBaseData *manualContourPerpPlaneControler::GetVtkMPRBaseData()
67 return _vtkmprbasedata;
71 // ----------------------------------------------------------------------------
72 void manualContourPerpPlaneControler::InsertPoint(int x, int y, int z ) // virtual
74 manualContourControler::InsertPoint( x, y, z );
75 _manualcontour3Vcontroler->InsertPoint_Others(0);
77 // ----------------------------------------------------------------------------
78 void manualContourPerpPlaneControler::AddPoint( int x, int y, int z )
80 manualContourControler::AddPoint( x, y, z );
81 _manualcontour3Vcontroler->AddPoint_Others();
83 // ----------------------------------------------------------------------------
84 void manualContourPerpPlaneControler::DeleteActualMousePoint(int x, int y)
86 int id = GetManualViewBaseContour()->GetIdPoint ( x , y , GetZ() );
87 manualContourControler::DeleteActualMousePoint( x , y );
88 _manualcontour3Vcontroler->DeleteActualMousePoint_Others(id);
90 // ----------------------------------------------------------------------------
91 void manualContourPerpPlaneControler::MouseMove( int x, int y )
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() );
100 _manualcontour3Vcontroler->MouseMove_Others(id);
101 _flagMouseMove = false;
105 // ----------------------------------------------------------------------------
106 void manualContourPerpPlaneControler::SetManualContour3VControler(manualContour3VControler *manualcontour3Vcontroler)
108 _manualcontour3Vcontroler = manualcontour3Vcontroler;
110 // ----------------------------------------------------------------------------
111 manualContour3VControler * manualContourPerpPlaneControler::GetManualContour3VControler()
113 return _manualcontour3Vcontroler;
115 // ----------------------------------------------------------------------------
116 bool manualContourPerpPlaneControler::OnChar() // virtual
118 if (manualContourControler::OnChar()==false )
120 _manualcontour3Vcontroler->OnChar_Others();
124 // ----------------------------------------------------------------------------
125 bool manualContourPerpPlaneControler::OnMouseMove() // virtual
127 manualContourControler::OnMouseMove();
128 return _flagMouseMove;
130 // ----------------------------------------------------------------------------
131 bool manualContourPerpPlaneControler::OnLeftDClick() // virtual
133 manualContourControler::OnLeftDClick();
134 return _flagMouseDClick;
136 // ----------------------------------------------------------------------------
137 void manualContourPerpPlaneControler::ResetContour() // virtual
139 manualContourControler::ResetContour();
140 _manualcontour3Vcontroler->ResetContour_Others();
143 // ----------------------------------------------------------------------------
144 void manualContourPerpPlaneControler::MouseDLeft( int x, int y) // virtual
146 _flagMouseDClick=true;
147 manualContourControler::MouseDLeft(x,y);
149 if (GetManualViewBaseContour()->ifTouchContour(x,y,0)==true)
151 _flagMouseDClick = false;
152 _vtkinteractorstyleplane2D->OnLeftDClick();
153 ResetOrientationPlane();
154 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
157 // int id=GetManualViewBaseContour()->GetIdPoint(x,y,GetZ());
158 // if ( (GetState()==0) && (id!=-1) )
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();
171 // ----------------------------------------------------------------------------
172 void manualContourPerpPlaneControler::ResetOrientationPlane()
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);
180 _vtkmprbasedata->SetNormal(rn[0],rn[1],rn[2]);
183 // ----------------------------------------------------------------------------
184 void manualContourPerpPlaneControler::SetVtkInteractorStylePlane2D(InteractorStyleMaracas *vtkinteractorstyleplane2D)
186 _vtkinteractorstyleplane2D = vtkinteractorstyleplane2D;
188 // ----------------------------------------------------------------------------
189 InteractorStyleMaracas * manualContourPerpPlaneControler::GetVtkInteractorStylePlane2D()
191 return _vtkinteractorstyleplane2D;