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 "controler-gmap.hh" 00026 #include "g-map-vertex.hh" 00027 00028 #include "view-precompile.hh" 00029 #include "view-precompile-ortho.hh" 00030 #include "view-precompile-perspective.hh" 00031 00032 #include "precompile-aimed-point.hh" 00033 #include "precompile-axis.hh" 00034 #include "precompile-dart.hh" 00035 #include "precompile-face.hh" 00036 #include "precompile-grid.hh" 00037 #include "precompile-normal-vector.hh" 00038 #include "precompile-object-transformation.hh" 00039 #include "precompile-preview.hh" 00040 #include "precompile-sew.hh" 00041 #include "precompile-vertex.hh" 00042 00043 #ifdef MODULE_SPAMOD 00044 #include "precompile-spamod.hh" 00045 #endif // MODULE_SPAMOD 00046 00047 using namespace std; 00048 using namespace GMap3d; 00049 //****************************************************************************** 00050 void CControlerGMap::viewEnablePreviewPrecompile(TViewId AViewId) 00051 { 00052 assert( AViewId<FViews.size() ); 00053 00054 if ( FViews[AViewId]==NULL ) return; 00055 00056 CPrecompilePreview * precompile = 00057 static_cast<CPrecompilePreview *>(FViews[AViewId]-> 00058 findPrecompile(PRECOMPILE_PREVIEW)); 00059 00060 if ( precompile!=NULL ) 00061 { 00062 precompile->enable(); 00063 precompile->setCurrentMode(FCurrentMode); 00064 00065 // On fixe le paramètre FParameterObjectPosition du précompile 00066 // (permet d'avoir un paramètre différent pour chaque objet). 00067 int index = FCurrentMode - MODE_CREATION_POLYGON; 00068 if ( index>=0 && index<NB_PREDEFINED_OBJECTS ) 00069 precompile->setPosition(FParameterObjectPosition[index]); 00070 } 00071 } 00072 //****************************************************************************** 00073 void CControlerGMap::viewDisablePreviewPrecompile(TViewId AViewId) 00074 { 00075 assert( AViewId<FViews.size() ); 00076 00077 if ( FViews[AViewId]==NULL ) return; 00078 00079 CPrecompile * precompile = 00080 FViews[AViewId]->findPrecompile(PRECOMPILE_PREVIEW); 00081 00082 if ( precompile!=NULL ) precompile->disable(); 00083 } 00084 //****************************************************************************** 00085 void CControlerGMap::viewEnableObjectTransformationPrecompile(TViewId AViewId) 00086 { 00087 assert( AViewId<FViews.size() ); 00088 00089 if ( FViews[AViewId]==NULL ) return; 00090 00091 CPrecompileObjectTransformation * precompile = 00092 static_cast<CPrecompileObjectTransformation *>(FViews[AViewId]-> 00093 findPrecompile(PRECOMPILE_OBJECT_TRANSFORMATION)); 00094 00095 if ( precompile!=NULL ) 00096 { 00097 precompile->enable(); 00098 precompile->setCurrentMode(FCurrentMode); 00099 } 00100 } 00101 //****************************************************************************** 00102 void CControlerGMap::viewDisableObjectTransformationPrecompile(TViewId AViewId) 00103 { 00104 assert( AViewId<FViews.size() ); 00105 00106 if ( FViews[AViewId]==NULL ) return; 00107 00108 CPrecompile * precompile = 00109 FViews[AViewId]->findPrecompile(PRECOMPILE_OBJECT_TRANSFORMATION); 00110 00111 if ( precompile!=NULL ) precompile->disable(); 00112 } 00113 //****************************************************************************** 00114 void CControlerGMap::viewUpdate(TViewId AViewId) 00115 { 00116 assert( AViewId<FViews.size() ); 00117 00118 updateModelIfNeeded (); 00119 updateSelectionIfNeeded(); 00120 00121 CControler::viewUpdate(AViewId); 00122 } 00123 //****************************************************************************** 00124 TCoordinate CControlerGMap::getMapBurstCoef(int ADim) const 00125 { return FMap->getBurstCoef(ADim); } 00126 //****************************************************************************** 00127 void CControlerGMap::setMapBurstCoef(int ADim, TCoordinate ACoef) 00128 { 00129 if ( ACoef!=FMap->getBurstCoef(ADim) ) 00130 { 00131 FMap->setBurstCoef(ADim, ACoef); 00132 setModelChanged(); 00133 } 00134 } 00135 //****************************************************************************** 00136 void CControlerGMap::setMapBurstCoefs(TCoordinate ACoef0, TCoordinate ACoef1, 00137 TCoordinate ACoef2,TCoordinate ACoef3) 00138 { 00139 if ( ACoef0!=FMap->getBurstCoef(0) || ACoef1!=FMap->getBurstCoef(1) || 00140 ACoef2!=FMap->getBurstCoef(2) || ACoef3!=FMap->getBurstCoef(3) ) 00141 { 00142 FMap->setBurstCoef(0, ACoef0); 00143 FMap->setBurstCoef(1, ACoef1); 00144 FMap->setBurstCoef(2, ACoef2); 00145 FMap->setBurstCoef(3, ACoef3); 00146 setModelChanged(); 00147 } 00148 } 00149 //****************************************************************************** 00150 void CControlerGMap::setBurstMethod(TBurstMethod AMethod) 00151 { 00152 FParameterGMapVertex->setBurstMethod(AMethod); 00153 } 00154 //------------------------------------------------------------------------------ 00155 TBurstMethod CControlerGMap::getBurstMethod() const 00156 { 00157 return FParameterGMapVertex->getBurstMethod(); 00158 } 00159 //****************************************************************************** 00160 bool CControlerGMap::isModelBlocked() const 00161 { 00162 assert( getParameterGMapVertex()!=NULL ); 00163 return getParameterGMapVertex()->getBlocked(); 00164 } 00165 //------------------------------------------------------------------------------ 00166 void CControlerGMap::setModelBlocked() 00167 { 00168 assert( getParameterGMapVertex()!=NULL ); 00169 getParameterGMapVertex()->setBlocked(); 00170 } 00171 //------------------------------------------------------------------------------ 00172 void CControlerGMap::unsetModelBlocked() 00173 { 00174 assert( getParameterGMapVertex()!=NULL ); 00175 getParameterGMapVertex()->unsetBlocked(); 00176 } 00177 //------------------------------------------------------------------------------ 00178 void CControlerGMap::toggleModelBlocked() 00179 { 00180 if ( isModelBlocked() ) unsetModelBlocked(); 00181 else setModelBlocked(); 00182 } 00183 //******************************************************************************
1.5.8