Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
controler-gmap-operations.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 "operations.hh"
28 #include "view-precompile.hh"
29 
30 #include <cassert>
31 using namespace std;
32 using namespace GMap3d;
33 //******************************************************************************
35 isNonModifyingOperation(const COperation& AOperation) const
36 {
37  return
38  AOperation.getType()==OPERATION_SELECT ||
39  AOperation.getType()==OPERATION_DEFORM ||
40  AOperation.getType()==OPERATION_EXPORT ||
41  AOperation.getType()==OPERATION_FIND_MOTIF_OFF ||
42  AOperation.getType()==OPERATION_FIND_MOTIF_MOKA;
43 }
44 //------------------------------------------------------------------------------
46 isRemovalOperation(const COperation& AOperation) const
47 {
48  return
49  AOperation.getType()==OPERATION_MERGE ||
50  AOperation.getType()==OPERATION_MERGE_COLINEAR ||
56 }
57 //------------------------------------------------------------------------------
59 isContractionOperation(const COperation& AOperation) const
60 {
61  return
62  AOperation.getType()==OPERATION_CONTRACT ||
63  AOperation.getType()==OPERATION_DEL_FLAT_FACES ||
64  AOperation.getType()==OPERATION_DEL_FLAT_VOLUMES ||
65  AOperation.getType()==OPERATION_DEL_NULL_EDGE;
66 }
67 //******************************************************************************
69 {
70  // Pas d'opération en mode translation, rotation ou scale.
74  {
75  setMessage("Operation possible only in selection mode");
76  return false;
77  }
78 
79  // Pas d'undo-redo en mode arrondi :
80  if (FCurrentMode == MODE_ROUNDING &&
81  AOperation.getType()==OPERATION_UNDO_REDO)
82  {
83  setMessage("Undo/redo not possible in rounding mode");
84  return false;
85  }
86 
87  if (isModelBlocked()) return true;
88 
89  // In simplification mode, we can only apply non modifying operations,
90  // and removal operations (except the intuitive one which is not possible
91  // since we must know the dimension of removed cells)
92  if (/*isModelBlocked() ||*/ isModeSimplification())
93  {
94  if ( (!isNonModifyingOperation(AOperation) &&
95  !isRemovalOperation(AOperation)) ||
96  (AOperation.getSubType()==SUB_OPERATION_INTUITIVE_TOPO) )
97  {
98  setMessage("Operation not possible in bloc of simplification mode");
99  return false;
100  }
101  }
102 
103  FCurrentOperation = AOperation;
104 
105  return true;
106 
107  // Autre manière de gérer le canApplyOperation
108  // setMode(MODE_SELECTION); return true;
109 }
110 //******************************************************************************
112 {
113  switch (AOperation.getType())
114  {
115  case OPERATION_CREATE:
116  {
117  switch (AOperation.getSubType())
118  {
119  case SUB_OPERATION_CREATE_POLYLINE: return createPolyline (); break;
120  case SUB_OPERATION_CREATE_POLYGON : return createPolygon (); break;
121  case SUB_OPERATION_CREATE_MESH : return createMesh (); break;
122  case SUB_OPERATION_CREATE_SPHERE : return createSphere (); break;
123  case SUB_OPERATION_CREATE_CYLINDER: return createCylinder (); break;
124  case SUB_OPERATION_CREATE_PYRAMID : return createPyramid (); break;
125  case SUB_OPERATION_CREATE_TORUS : return createTorus (); break;
126  default: return false;
127  }
128  break;
129  }
130  case OPERATION_SEW:
131  {
132  switch (AOperation.getSubType())
133  {
134  case SUB_OPERATION_INTUITIVE_TOPO: return intuitiveTopoSew(); break;
135  case SUB_OPERATION_INTUITIVE_GEO : return intuitiveGeoSew (); break;
136  case SUB_OPERATION_TOPO :
137  return topoSew(AOperation.getDimension()); break;
138  case SUB_OPERATION_GEO :
139  return geoSew(AOperation.getDimension()); break;
141  return topoSewBorders(AOperation.getDimension()); break;
143  return geoSewBorders(AOperation.getDimension()); break;
144  default: return false;
145  }
146  break;
147  }
148  case OPERATION_PLATE:
149  {
150  switch (AOperation.getSubType())
151  {
153  return intuitivePlate(); break;
155  return plateBorders(AOperation.getDimension()); break;
156  default:
157  return plate(AOperation.getDimension()); break;
158  }
159  break;
160  }
161  default: return false;
162  }
163 
164  return false;
165 }
166 //******************************************************************************
168 { return FNbDarts; }
170 { return FNbSelectedDarts; }
172 { return FNbVertices; }
173 //******************************************************************************