Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
operations-plating.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 {
33  bool res = false;
34 
37  {
38  CDart *d1, *d2;
39 
40  if (FMap->getMarkedCells(ORBIT_SELF, getSelectionMark(),
41  getLastSelectedDart(), &d2,&d1) != 2)
42  {
43  setMessage("Selection not correct: you need two darts");
44  return false;
45  }
46 
48 
49  if (FMap->intuitivePlate(d1,d2,
50  getParameterOperations()->getRotateCells(),
51  getParameterOperations()->getScaleCells(),
52  getParameterOperations()->getTranslateCells()))
53  {
57  setMessage("Cells plated");
58  res = true;
59  }
60  else
61  {
62  setMessage("Cells not possible to plate");
64  }
65  }
66 
67  return res;
68 }
69 //******************************************************************************
70 bool CControlerGMap::plate(int ADimension)
71 {
73  {
74  assert(ADimension>=0 && ADimension<3); // i!=3 !!!!
75 
76  CDart *d1, *d2;
77 
78  if (FMap->getMarkedCells(ORBIT_SELF, getSelectionMark(),
79  getLastSelectedDart(), &d2,&d1) != 2)
80  {
81  setMessage("Selection not correct: you need two darts");
82  return false;
83  }
84 
85  if (!FMap->canPlate(d1,d2))
86  {
87  setMessage(ADimension, "-cells impossible to plate");
88  return false;
89  }
90 
92  FMap->plate(d1,d2, ADimension,
93  getParameterOperations()->getRotateCells(),
94  getParameterOperations()->getScaleCells(),
95  getParameterOperations()->getTranslateCells());
98 
100  setMessage(ADimension, "-cells plated");
101  return true;
102  }
103 
104  return false;
105 }
106 //******************************************************************************
107 bool CControlerGMap::plateBorders(int ADimension)
108 {
111  {
112  assert(ADimension==1 || ADimension==2);
113 
114  CDart *d1, *d2;
115 
116  if (FMap->getMarkedCells(ORBIT_SELF, getSelectionMark(),
117  getLastSelectedDart(), &d2,&d1) != 2)
118  {
119  setMessage("Selection not correct: you need two darts");
120  return false;
121  }
122 
123  if (!FMap->canPlate(d1,d2))
124  {
125  setMessage(ADimension, "-borders impossible to plate");
126  return false;
127  }
128 
129  undoRedoPreSave();
130  FMap->borderPlate(d1,d2, ADimension,
131  getParameterOperations()->getRotateCells(),
132  getParameterOperations()->getScaleCells(),
133  getParameterOperations()->getTranslateCells());
136 
137  setModelChanged();
138  setMessage(ADimension, "-borders plated");
139  return true;
140  }
141 
142  return false;
143 }
144 //******************************************************************************