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 "manualContour3VControler.h"
28 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
37 manualContour3VControler::manualContour3VControler(int type)
42 // _manViewBaseCont1 = NULL;
43 // _manViewBaseCont2 = NULL;
44 // _manViewBaseCont3 = NULL;
46 //----------------------------------------------------------------------------
47 manualContour3VControler::~manualContour3VControler()
51 // ----------------------------------------------------------------------------
52 manualContour3VControler * manualContour3VControler :: Clone() // virtual
54 manualContour3VControler * clone = new manualContour3VControler( this->GetType() );
55 CopyAttributesTo(clone);
59 // ---------------------------------------------------------------------------
60 void manualContour3VControler::CopyAttributesTo( manualContour3VControler * cloneObject)
63 manualContourControler::CopyAttributesTo(cloneObject);
65 cloneObject->SetVtkMPRBaseData( this->GetVtkMPRBaseData() );
67 // Remember to add ManualViewBaseContour with "AddManualViewBaseContour"
70 // ----------------------------------------------------------------------------
71 int manualContour3VControler::GetType()
76 // ----------------------------------------------------------------------------
77 void manualContour3VControler::AddPoint_Others()
79 manualViewBaseContour *mvbc;
80 int i,size=this->_lstManualViewBaseContour.size();
81 for ( i = 0 ; i < size ; i++ )
83 mvbc = _lstManualViewBaseContour[i];
88 // if (_manViewBaseCont1!=NULL){
89 // _manViewBaseCont1->AddPoint();
90 // _manViewBaseCont2->AddPoint();
91 // _manViewBaseCont3->AddPoint();
92 // this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
95 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
97 // ----------------------------------------------------------------------------
98 void manualContour3VControler::AddPoint( int x, int y, int z ) // virtual
101 z=(int)_vtkmprbasedata->GetZ();
102 if (GetManualContourModel()!=NULL){
106 GetManualViewBaseContour()->TransfromCoordViewWorld(xx,yy,zz,_type);
110 xx=_vtkmprbasedata->GetX();
115 yy=_vtkmprbasedata->GetY();
119 /*int id = */ GetManualContourModel()->AddPoint(xx,yy,zz); // JPRx
120 GetManualViewBaseContour()->AddPoint();
126 // ----------------------------------------------------------------------------
127 void manualContour3VControler::InsertPoint_Others(int id)
130 manualViewBaseContour *mvbc;
131 int i,size=this->_lstManualViewBaseContour.size();
132 for ( i = 0 ; i < size ; i++ )
134 mvbc = _lstManualViewBaseContour[i];
135 mvbc->InsertPoint(id);
139 if (_manViewBaseCont1!=NULL){
140 _manViewBaseCont1->InsertPoint(id);
141 _manViewBaseCont2->InsertPoint(id);
142 _manViewBaseCont3->InsertPoint(id);
143 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
147 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
150 // ----------------------------------------------------------------------------
151 void manualContour3VControler::InsertPoint(int x, int y, int z)
154 if (GetManualContourModel()!=NULL){
155 if (GetManualContourModel()->GetSizeLstPoints()>1){
156 z=(int)_vtkmprbasedata->GetZ();
160 GetManualViewBaseContour()->TransfromCoordViewWorld(xx,yy,zz,_type);
163 xx=_vtkmprbasedata->GetX();
168 yy=_vtkmprbasedata->GetY();
171 id = GetManualContourModel()->InsertPoint(xx,yy,zz);
173 GetManualViewBaseContour()->InsertPoint(id);
174 InsertPoint_Others(0);
181 // ----------------------------------------------------------------------------
185 void manualContour3VControler::SetModelView ( manualContourModel *manContModel,
186 manualViewBaseContour *manViewBaseCont0,
187 manualViewBaseContour *manViewBaseCont1,
188 manualViewBaseContour *manViewBaseCont2,
189 manualViewBaseContour *manViewBaseCont3)
191 manualContourControler::SetModelView(manContModel,manViewBaseCont0);
192 _manViewBaseCont1 = manViewBaseCont1;
193 _manViewBaseCont2 = manViewBaseCont2;
194 _manViewBaseCont3 = manViewBaseCont3;
198 // ----------------------------------------------------------------------------
199 void manualContour3VControler::AddManualViewBaseContour( manualViewBaseContour *manViewBaseCont )
201 _lstManualViewBaseContour.push_back( manViewBaseCont );
204 // ----------------------------------------------------------------------------
205 void manualContour3VControler::SetVtkMPRBaseData (vtkMPRBaseData *vtkmprbasedata )
207 _vtkmprbasedata=vtkmprbasedata;
209 // ----------------------------------------------------------------------------
210 vtkMPRBaseData *manualContour3VControler::GetVtkMPRBaseData()
212 return _vtkmprbasedata;
214 // ----------------------------------------------------------------------------
215 void manualContour3VControler::SetPoint( int id ,int x ,int y ,int z ) // virtual
217 z=(int)_vtkmprbasedata->GetZ();
218 if ((GetManualViewBaseContour()!=NULL) && (id>=0)){
222 GetManualViewBaseContour()->TransfromCoordViewWorld(xx,yy,zz,_type);
226 xx=_vtkmprbasedata->GetX();
230 yy=_vtkmprbasedata->GetY();
233 manualPoint *mp = GetManualContourModel()->GetManualPoint(id);
234 mp->SetPoint(xx,yy,zz);
238 // ----------------------------------------------------------------------------
239 void manualContour3VControler::DeleteActualMousePoint_Others(int id)
241 manualViewBaseContour *mvbc;
242 int i,size=this->_lstManualViewBaseContour.size();
243 for ( i = 0 ; i < size ; i++ )
245 mvbc = _lstManualViewBaseContour[i];
246 mvbc->DeletePoint(id);
251 if (_manViewBaseCont1!=NULL){
252 _manViewBaseCont1->DeletePoint(id);
253 _manViewBaseCont2->DeletePoint(id);
254 _manViewBaseCont3->DeletePoint(id);
256 _manViewBaseCont1->Refresh();
257 _manViewBaseCont2->Refresh();
258 _manViewBaseCont3->Refresh();
260 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
263 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
265 // ----------------------------------------------------------------------------
266 void manualContour3VControler::DeleteActualMousePoint(int x, int y)// virtual
268 int id=GetManualViewBaseContour()->GetIdPoint ( x , y , GetZ() );
270 manualContourBaseControler::DeleteActualMousePoint( x , y );
271 DeleteActualMousePoint_Others( id );
274 // ----------------------------------------------------------------------------
275 void manualContour3VControler::MouseMove_Others(int id) // virtual
277 manualViewBaseContour *mvbc;
278 int i,size=this->_lstManualViewBaseContour.size();
279 for ( i = 0 ; i < size ; i++ )
281 mvbc = _lstManualViewBaseContour[i];
282 mvbc->SelectAllPossibleSelected(false);
285 mvbc->SetPointPosibleSelected(id,true);
287 mvbc->SetPosibleSelected ( GetManualViewBaseContour()->GetPosibleSelected() );
293 if (_manViewBaseCont1!=NULL){
294 _manViewBaseCont1->SelectAllPossibleSelected(false);
295 _manViewBaseCont2->SelectAllPossibleSelected(false);
296 _manViewBaseCont3->SelectAllPossibleSelected(false);
298 _manViewBaseCont1->SetPointPosibleSelected(id,true);
299 _manViewBaseCont2->SetPointPosibleSelected(id,true);
300 _manViewBaseCont3->SetPointPosibleSelected(id,true);
302 _manViewBaseCont1->SetPosibleSelected ( GetManualViewBaseContour()->GetPosibleSelected() );
303 _manViewBaseCont2->SetPosibleSelected ( GetManualViewBaseContour()->GetPosibleSelected() );
304 _manViewBaseCont3->SetPosibleSelected ( GetManualViewBaseContour()->GetPosibleSelected() );
306 _manViewBaseCont1->Refresh();
307 _manViewBaseCont2->Refresh();
308 _manViewBaseCont3->Refresh();
310 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
313 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
317 // ----------------------------------------------------------------------------
318 void manualContour3VControler::MouseMove(int x, int y) // virtual
320 manualContourControler::MouseMove( x , y );
321 int id=GetManualViewBaseContour()->GetIdPoint(x,y,GetZ());
322 MouseMove_Others( id );
325 // ----------------------------------------------------------------------------
326 void manualContour3VControler::OnChar_Others()
328 manualViewBaseContour *mvbc;
329 int i,size=this->_lstManualViewBaseContour.size();
330 for ( i = 0 ; i < size ; i++ )
332 mvbc = _lstManualViewBaseContour[i];
337 _manViewBaseCont1->Refresh();
338 _manViewBaseCont2->Refresh();
339 _manViewBaseCont3->Refresh();
341 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
343 // ----------------------------------------------------------------------------
344 bool manualContour3VControler::OnChar()
346 manualContourControler::OnChar();
350 // ----------------------------------------------------------------------------
351 void manualContour3VControler::ResetContour() // virtual
353 manualContourControler::ResetContour();
354 ResetContour_Others();
357 // ----------------------------------------------------------------------------
358 void manualContour3VControler::ResetContour_Others()
360 manualViewBaseContour *mvbc;
361 int i,size=this->_lstManualViewBaseContour.size();
362 for ( i = 0 ; i < size ; i++ )
364 mvbc = _lstManualViewBaseContour[i];
365 mvbc->DeleteContour();
366 mvbc->CreateNewContour();
371 _manViewBaseCont1->DeleteContour();
372 _manViewBaseCont2->DeleteContour();
373 _manViewBaseCont3->DeleteContour();
374 _manViewBaseCont1->CreateNewContour();
375 _manViewBaseCont2->CreateNewContour();
376 _manViewBaseCont3->CreateNewContour();