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 "manualLineControler.h"
28 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
34 // _state = 0 // ..nothing..
35 // _state = 5 // move point
36 // _state = 6 // move all
37 // _state = 7 // Empty mouse drag
39 manualLineControler::manualLineControler()
42 // ----------------------------------------------------------------------------
43 manualLineControler::~manualLineControler()
46 // ----------------------------------------------------------------------------
47 manualLineControler * manualLineControler :: Clone() // virtual
49 manualLineControler * clone = new manualLineControler();
50 CopyAttributesTo(clone);
54 // ---------------------------------------------------------------------------
55 void manualLineControler::CopyAttributesTo( manualLineControler * cloneObject)
58 manualContourBaseControler::CopyAttributesTo(cloneObject);
62 // ----------------------------------------------------------------------------
63 void manualLineControler::MouseClickLeft(int x, int y){
67 { // move control point
68 if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){
69 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
75 if ((GetState()==0) && (GetManualViewBaseContour()->GetPosibleSelected()==true)) {
76 GetManualViewBaseContour()->InitMove(x,y,z);
80 // fist time create 2 control points and move a control point
81 int size=GetManualViewBaseContour()->GetNumberOfPoints();
86 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
101 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
106 GetManualViewBaseContour()->Refresh();
108 // ----------------------------------------------------------------------------
110 void manualLineControler::MouseMove(int x, int y) // virtual
114 GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
115 GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
117 if (GetState()==1) { SetPoint( bakIdPoint , x , y ,z); }
118 if (GetState()==5) { SetPoint( bakIdPoint , x , y ,z); }
122 GetManualViewBaseContour()->MoveContour(x,y,z);
124 GetManualViewBaseContour()->Refresh();
128 // ----------------------------------------------------------------------------
129 void manualLineControler::DeleteActualMousePoint(int x, int y) // virtual
132 // ----------------------------------------------------------------------------
134 void manualLineControler::InitRoi(int ww, int hh, double porcentage)
139 if (GetManualContourModel()->GetSizeLstPoints() ==0)
146 double pp1=porcentage;
147 double pp2=1-porcentage;
149 mp = GetManualContourModel()->GetManualPoint(0);
151 mp->SetPoint(ww*pp2,hh*pp2,zz);
153 mp = GetManualContourModel()->GetManualPoint(1);
155 mp->SetPoint(ww*pp2,hh*pp1,zz);
157 GetManualViewBaseContour() ->UpdateViewPoint(0);
158 GetManualViewBaseContour() ->UpdateViewPoint(1);
161 GetManualViewBaseContour()->Refresh();