00001 /* 00002 * lib-controler-gmap : Le contrôleur de 3-G-cartes, surcouche de lib-controler. 00003 * Copyright (C) 2004, Moka Team, Université de Poitiers, Laboratoire SIC 00004 * http://www.sic.sp2mi.univ-poitiers.fr/ 00005 * Copyright (C) 2009, Guillaume Damiand, CNRS, LIRIS, 00006 * guillaume.damiand@liris.cnrs.fr, http://liris.cnrs.fr/ 00007 * 00008 * This file is part of lib-controler-gmap 00009 * 00010 * This program is free software: you can redistribute it and/or modify 00011 * it under the terms of the GNU Lesser General Public License as published by 00012 * the Free Software Foundation, either version 3 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public License 00021 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00022 */ 00023 00024 //****************************************************************************** 00025 #include "g-map-vertex.hh" 00026 #include "controler-gmap.hh" 00027 #include "operations.hh" 00028 #include "view-precompile.hh" 00029 00030 #include <cassert> 00031 using namespace std; 00032 using namespace GMap3d; 00033 //****************************************************************************** 00034 bool CControlerGMap::canApplyOperation(const COperation& AOperation) 00035 { 00036 bool res = 00037 !(FCurrentMode == MODE_TRANSLATION || 00038 FCurrentMode == MODE_ROTATION || 00039 FCurrentMode == MODE_SCALE); 00040 00041 // Pas d'undo-redo en mode arrondi : 00042 if (FCurrentMode == MODE_ROUNDING && 00043 AOperation.getType()==OPERATION_UNDO_REDO) 00044 res = false; 00045 00046 if (!res) 00047 setMessage("Opération possible uniquement en mode sélection"); 00048 00049 FCurrentOperation = AOperation; 00050 00051 return res; 00052 00053 // Autre manière de gérer le canApplyOperation 00054 // setMode(MODE_SELECTION); return true; 00055 } 00056 //****************************************************************************** 00057 bool CControlerGMap::applyOperation(const COperation& AOperation) 00058 { 00059 switch (AOperation.getType()) 00060 { 00061 case OPERATION_CREATE: 00062 { 00063 switch (AOperation.getSubType()) 00064 { 00065 case SUB_OPERATION_CREATE_POLYLINE: return createPolyline (); break; 00066 case SUB_OPERATION_CREATE_POLYGON : return createPolygon (); break; 00067 case SUB_OPERATION_CREATE_MESH : return createMesh (); break; 00068 case SUB_OPERATION_CREATE_SPHERE : return createSphere (); break; 00069 case SUB_OPERATION_CREATE_CYLINDER: return createCylinder (); break; 00070 case SUB_OPERATION_CREATE_PYRAMID : return createPyramid (); break; 00071 case SUB_OPERATION_CREATE_TORUS : return createTorus (); break; 00072 default: return false; 00073 } 00074 break; 00075 } 00076 case OPERATION_SEW: 00077 { 00078 switch (AOperation.getSubType()) 00079 { 00080 case SUB_OPERATION_INTUITIVE_TOPO: return intuitiveTopoSew(); break; 00081 case SUB_OPERATION_INTUITIVE_GEO : return intuitiveGeoSew (); break; 00082 case SUB_OPERATION_TOPO : 00083 return topoSew(AOperation.getDimension()); break; 00084 case SUB_OPERATION_GEO : 00085 return geoSew(AOperation.getDimension()); break; 00086 case SUB_OPERATION_TOPO_BORDERS : 00087 return topoSewBorders(AOperation.getDimension()); break; 00088 case SUB_OPERATION_GEO_BORDERS : 00089 return geoSewBorders(AOperation.getDimension()); break; 00090 default: return false; 00091 } 00092 break; 00093 } 00094 case OPERATION_PLATE: 00095 { 00096 switch (AOperation.getSubType()) 00097 { 00098 case SUB_OPERATION_INTUITIVE: 00099 return intuitivePlate(); break; 00100 case SUB_OPERATION_BORDERS: 00101 return plateBorders(AOperation.getDimension()); break; 00102 default: 00103 return plate(AOperation.getDimension()); break; 00104 } 00105 break; 00106 } 00107 default: return false; 00108 } 00109 00110 return false; 00111 } 00112 //****************************************************************************** 00113 int CControlerGMap::getNbDarts() const 00114 { return FNbDarts; } 00115 int CControlerGMap::getNbSelectedDarts() const 00116 { return FNbSelectedDarts; } 00117 int CControlerGMap::getNbVertices() const 00118 { return FNbVertices; } 00119 //******************************************************************************
1.5.8