Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
operations-move-selection.cc
Go to the documentation of this file.
1 /*
2  * lib-controler-gmap : Le contrôleur de 3-G-cartes, surcouche de lib-controler.
3  * Copyright (C) 2004, Moka Team, Université de Poitiers, Laboratoire SIC
4  * http://www.sic.sp2mi.univ-poitiers.fr/
5  * Copyright (C) 2009, Guillaume Damiand, CNRS, LIRIS,
6  * guillaume.damiand@liris.cnrs.fr, http://liris.cnrs.fr/
7  *
8  * This file is part of lib-controler-gmap
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 //******************************************************************************
25 #include "g-map-vertex.hh"
26 #include "controler-gmap.hh"
27 #include <cassert>
28 
29 using namespace GMap3d;
30 //******************************************************************************
32 {
35  return false;
36 
37  bool ok =
38  getSelectionOrbit()==ORBIT_03 || getSelectionOrbit()==ORBIT_02 ||
39  getSelectionOrbit()==ORBIT_023 || getSelectionOrbit()==ORBIT_01 ||
40  getSelectionOrbit()==ORBIT_013 || getSelectionOrbit()==ORBIT_012;
41 
42  if (!ok)
43  {
44  setMessage("Selection orbit not correct");
45  return false;
46  }
47 
48  if (getLastSelectedDart()==NULL)
49  {
50  setMessage("No last selected dart");
51  return false;
52  }
53 
54  return true;
55 }
56 //******************************************************************************
58 {
59  if (!canExtendSelection())
60  return false;
61 
62  CDart* next = FMap->go(CGMapGeneric::Forward, getLastSelectedDart(),
64  selectDart(next);
65  setMessage("Forward selection done");
66  return true;
67 }
68 //******************************************************************************
70 {
71  if (!canExtendSelection())
72  return false;
73 
74  CDart* next = FMap->go(CGMapGeneric::Forward, getLastSelectedDart(),
76  selectDart(next);
77  setMessage("Forward deselection done");
78  return true;
79 }
80 //******************************************************************************
82 {
83  if (!canExtendSelection())
84  return false;
85 
86  CDart* next = FMap->go(CGMapGeneric::Backward, getLastSelectedDart(),
88  selectDart(next);
89  setMessage("Backward selection done");
90  return true;
91 }
92 //******************************************************************************
94 {
95  if (!canExtendSelection())
96  return false;
97 
98  CDart* next = FMap->go(CGMapGeneric::Backward, getLastSelectedDart(),
100  selectDart(next);
101  setMessage("Backward deselection done");
102  return true;
103 }
104 //******************************************************************************
106 {
107  if (!canExtendSelection())
108  return false;
109 
110  CDart* next = FMap->go(CGMapGeneric::Left, getLastSelectedDart(),
112  selectDart(next);
113  setMessage("Left selection done");
114  return true;
115 }
116 //******************************************************************************
118 {
119  if (!canExtendSelection())
120  return false;
121 
122  CDart* next = FMap->go(CGMapGeneric::Left, getLastSelectedDart(),
123  getSelectionOrbit(), getSelectionMark(), false);
124  selectDart(next);
125  setMessage("Left deselection done");
126  return true;
127 }
128 //******************************************************************************
130 {
131  if (!canExtendSelection())
132  return false;
133 
134  CDart* next = FMap->go(CGMapGeneric::Right, getLastSelectedDart(),
136  selectDart(next);
137  setMessage("Right selection done");
138  return true;
139 }
140 //******************************************************************************
142 {
143  if (!canExtendSelection())
144  return false;
145 
146  CDart* next = FMap->go(CGMapGeneric::Right, getLastSelectedDart(),
147  getSelectionOrbit(), getSelectionMark(), false);
148  selectDart(next);
149  setMessage("Right deselection done");
150  return true;
151 }
152 //******************************************************************************
154 {
155  if (!canExtendSelection())
156  return false;
157 
158  CDart* next = FMap->goAsFarAsPossible(CGMapGeneric::Forward,
161  getSelectionMark(), true);
162  selectDart(next);
163  setMessage("Forward selection done");
164  return true;
165 }
166 //******************************************************************************
168 {
169  if (!canExtendSelection())
170  return false;
171 
172  CDart* next = FMap->goAsFarAsPossible(CGMapGeneric::Forward,
175  getSelectionMark(), false);
176  selectDart(next);
177  setMessage("Forward deselection done");
178  return true;
179 }
180 //******************************************************************************
182 {
183  if (!canExtendSelection())
184  return false;
185 
186  CDart* next = FMap->goAsFarAsPossible(CGMapGeneric::Backward,
189  getSelectionMark(), true);
190  selectDart(next);
191  setMessage("Backward selection done");
192  return true;
193 }
194 //******************************************************************************
196 {
197  if (!canExtendSelection())
198  return false;
199 
200  CDart* next = FMap->goAsFarAsPossible(CGMapGeneric::Backward,
203  getSelectionMark(), false);
204  selectDart(next);
205  setMessage("Backward deselection done");
206  return true;
207 }
208 //******************************************************************************
210 {
211  if (!canExtendSelection())
212  return false;
213 
214  CDart* next = FMap->goAsFarAsPossible(CGMapGeneric::Left,
217  getSelectionMark(), true);
218  selectDart(next);
219  setMessage("Left selection done");
220  return true;
221 }
222 //******************************************************************************
224 {
225  if (!canExtendSelection())
226  return false;
227 
228  CDart* next = FMap->goAsFarAsPossible(CGMapGeneric::Left,
231  getSelectionMark(), false);
232  selectDart(next);
233  setMessage("Left deselection done");
234  return true;
235 }
236 //******************************************************************************
238 {
239  if (!canExtendSelection())
240  return false;
241 
242  CDart* next = FMap->goAsFarAsPossible(CGMapGeneric::Right,
245  getSelectionMark(), true);
246  selectDart(next);
247  setMessage("Right selection done");
248  return true;
249 }
250 //******************************************************************************
252 {
253  if (!canExtendSelection())
254  return false;
255 
256  CDart* next = FMap->goAsFarAsPossible(CGMapGeneric::Right,
259  getSelectionMark(), false);
260  selectDart(next);
261  setMessage("Right deselection done");
262  return true;
263 }
264 //******************************************************************************
265 bool CControlerGMap::goAlphai( unsigned int ADim )
266 {
267  assert( ADim<= 3);
268 
271  {
272  setMessage("Selecion mode not correct");
273  return false;
274  }
275 
276  if (getLastSelectedDart()==NULL)
277  {
278  setMessage("No last selected dart");
279  return false;
280  }
281 
282  if ( !FMap->isFree(getLastSelectedDart(),ADim) )
283  {
284  selectDart(FMap->alpha(getLastSelectedDart(),ADim));
285  setMessage("Selection by alpha", ADim, " done");
286  }
287  else
288  {
289  setMessage("Last selected dart is ", ADim, "-free");
290  return false;
291  }
292 
293  return true;
294 }
295 //------------------------------------------------------------------------------
297 { return goAlphai(0); }
298 //------------------------------------------------------------------------------
300 { return goAlphai(1); }
301 //------------------------------------------------------------------------------
303 { return goAlphai(2); }
304 //------------------------------------------------------------------------------
306 { return goAlphai(3); }
307 //******************************************************************************