Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
controler-gmap-rounding.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 #ifdef MODULE_ROUNDING
26 //******************************************************************************
27 #include "controler-gmap.hh"
28 #include "g-map-vertex.hh"
29 #include "view-precompile.hh"
30 using namespace GMap3d;
31 //******************************************************************************
32 void CControlerGMap::modeRoundingReinitAllCoefs()
33 {
34  if (!areRoundingCoefsAllocated())
35  return;
36 
37  TCoordinate k0 =
39 
40  TCoordinate k1 =
42 
43  int selected = FMap->getNewMark();
44  FMap->negateMaskMark(selected);
45  FRounding->setRoundingCoefOfMarkedDarts(selected, 0, k0);
46  FRounding->setRoundingCoefOfMarkedDarts(selected, 1, k1);
47  FMap->negateMaskMark(selected);
48  FMap->freeMark(selected);
49 }
50 //******************************************************************************
51 void CControlerGMap::modeRoundingSetCoefOfMarkedDarts(int ADimension,
52  TCoordinate ACoef)
53 {
54  if (!areRoundingCoefsAllocated() || (ADimension!=0 && ADimension!=1))
55  return;
56 
57  FRounding->
58  setRoundingCoefOfMarkedDarts(getSelectionMark(), ADimension, ACoef);
59 }
60 //------------------------------------------------------------------------------
61 bool CControlerGMap::modeRoundingGetCoefOfMarkedDarts(int ADimension,
62  TCoordinate& ACoef)
63 {
64  if (!areRoundingCoefsAllocated() || (ADimension!=0 && ADimension!=1))
65  return false;
66 
67  return FRounding->getRoundingCoefOfMarkedDarts(getSelectionMark(),
68  ADimension, ACoef);
69 }
70 //------------------------------------------------------------------------------
71 TCoordinate CControlerGMap::modeRoundingSelectNextCoef(int ADimension)
72 {
73  if (!areRoundingCoefsAllocated() || (ADimension!=0 && ADimension!=1))
74  return false;
75 
76  int mark = getSelectionMark();
77 
78  TCoordinate coef = FRounding->selectNextRoundingCoef(mark, ADimension);
79 
80  CDart* last = getLastSelectedDart();
81  if (last != NULL && !FMap->isMarked(last, mark))
83 
85 
86  return coef;
87 }
88 //******************************************************************************
89 void CControlerGMap::modeRoundingBegin()
90 {
91  assert(! areRoundingCoefsAllocated());
92 
93  FRounding = new CRoundingInterface(FMap);
94  modeRoundingReinitAllCoefs();
95 }
96 //------------------------------------------------------------------------------
97 void CControlerGMap::modeRoundingEnd()
98 {
99  assert(areRoundingCoefsAllocated());
100 
101  delete FRounding;
102  FRounding = NULL;
103 }
104 //------------------------------------------------------------------------------
105 bool CControlerGMap::areRoundingCoefsAllocated() const
106 {
107  return FRounding != NULL;
108 }
109 //------------------------------------------------------------------------------
110 void CControlerGMap::modeRoundingOperationStart()
111 {
112  if ( FViews[FCurrentViewId]!=NULL )
114 }
115 //------------------------------------------------------------------------------
116 void CControlerGMap::modeRoundingOperationMove()
117 {
118 }
119 //------------------------------------------------------------------------------
120 void CControlerGMap::modeRoundingOperationStop()
121 {
122 }
123 //******************************************************************************
124 bool CControlerGMap::modeRoundingRoundVertices(bool ADig, bool /*ASurfacic*/)
125 {
126 #ifndef MODULE_ROUNDING
127  if (ASurfacic)
128  return false;
129 #endif // MODULE_ROUNDING
130  assert(areRoundingCoefsAllocated());
131 
133  return false;
134 
135  undoRedoPreSave();
136 
137  int selected = FMap->getNewMark();
138  FMap->markIncidentCells(ORBIT_23, getSelectionMark(), selected);
139 
140  int nb = FRounding->roundMarkedVertices(selected, ADig);
141 
142  FMap->unmarkAll(selected);
143  FMap->freeMark(selected);
144 
145  if (nb==0)
146  {
147  setMessage("No vertex rounded");
149  return false;
150  }
151 
153  setModelChanged();
154  setMessage(nb, nb==1 ? " vertex rounded" : " vertices rounded");
155  modeRoundingReinitAllCoefs();
156  return true;
157 }
158 //******************************************************************************
159 bool CControlerGMap::modeRoundingRoundEdges(bool A3D, bool ADig, bool ASetback,
160  bool /*ASurfacic*/)
161 {
162 #ifndef MODULE_ROUNDING
163  if (ASurfacic)
164  return false;
165 #endif // MODULE_ROUNDING
166  assert(areRoundingCoefsAllocated());
167 
169  return false;
170 
171  undoRedoPreSave();
172 
173  int selected = FMap->getNewMark();
174  FMap->markIncidentCells(ORBIT_EDGE, getSelectionMark(), selected);
175 
176  int nb = FRounding->roundMarkedEdges(selected, A3D, ADig, ASetback);
177 
178  FMap->unmarkAll(selected);
179  FMap->freeMark(selected);
180 
181  if (nb==0)
182  {
183  setMessage("No edge rounded");
185  return false;
186  }
187 
189  setModelChanged();
190  setMessage(nb, nb==1 ? " edge rounded" : " edges rounded");
191  modeRoundingReinitAllCoefs();
192  return true;
193 }
194 //******************************************************************************
195 #endif // MODULE_ROUNDING
196 //******************************************************************************