Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
controler-gmap-views.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 "controler-gmap.hh"
26 #include "g-map-vertex.hh"
27 
28 #include "view-precompile.hh"
29 #include "view-precompile-ortho.hh"
31 
33 #include "precompile-axis.hh"
34 #include "precompile-dart.hh"
35 #include "precompile-face.hh"
36 #include "precompile-grid.hh"
39 #include "precompile-preview.hh"
40 #include "precompile-sew.hh"
41 #include "precompile-vertex.hh"
42 
43 #ifdef MODULE_SPAMOD
44 #include "precompile-spamod.hh"
45 #endif // MODULE_SPAMOD
46 
47 using namespace std;
48 using namespace GMap3d;
49 //******************************************************************************
51 {
52  assert( AViewId<FViews.size() );
53 
54  if ( FViews[AViewId]==NULL ) return;
55 
56  CPrecompilePreview * precompile =
57  static_cast<CPrecompilePreview *>(FViews[AViewId]->
58  findPrecompile(PRECOMPILE_PREVIEW));
59 
60  if ( precompile!=NULL )
61  {
62  precompile->enable();
63  precompile->setCurrentMode(FCurrentMode);
64 
65  // On fixe le paramètre FParameterObjectPosition du précompile
66  // (permet d'avoir un paramètre différent pour chaque objet).
67  int index = FCurrentMode - MODE_CREATION_POLYGON;
68  if ( index>=0 && index<NB_PREDEFINED_OBJECTS )
69  precompile->setPosition(FParameterObjectPosition[index]);
70  }
71 }
72 //******************************************************************************
74 {
75  assert( AViewId<FViews.size() );
76 
77  if ( FViews[AViewId]==NULL ) return;
78 
79  CPrecompile * precompile =
80  FViews[AViewId]->findPrecompile(PRECOMPILE_PREVIEW);
81 
82  if ( precompile!=NULL ) precompile->disable();
83 }
84 //******************************************************************************
86 {
87  assert( AViewId<FViews.size() );
88 
89  if ( FViews[AViewId]==NULL ) return;
90 
91  CPrecompileObjectTransformation * precompile =
92  static_cast<CPrecompileObjectTransformation *>(FViews[AViewId]->
93  findPrecompile(PRECOMPILE_OBJECT_TRANSFORMATION));
94 
95  if ( precompile!=NULL )
96  {
97  precompile->enable();
98  precompile->setCurrentMode(FCurrentMode);
99  }
100 }
101 //******************************************************************************
103 {
104  assert( AViewId<FViews.size() );
105 
106  if ( FViews[AViewId]==NULL ) return;
107 
108  CPrecompile * precompile =
109  FViews[AViewId]->findPrecompile(PRECOMPILE_OBJECT_TRANSFORMATION);
110 
111  if ( precompile!=NULL ) precompile->disable();
112 }
113 //******************************************************************************
115 {
116  assert( AViewId<FViews.size() );
117 
120 
121  CControler::viewUpdate(AViewId);
122 }
123 //******************************************************************************
124 TCoordinate CControlerGMap::getMapBurstCoef(int ADim) const
125 { return FMap->getBurstCoef(ADim); }
126 //******************************************************************************
127 void CControlerGMap::setMapBurstCoef(int ADim, TCoordinate ACoef)
128 {
129  if ( ACoef!=FMap->getBurstCoef(ADim) )
130  {
131  FMap->setBurstCoef(ADim, ACoef);
132  if ( FParameterGMapVertex->getMapEmbedding()!=NULL )
133  FParameterGMapVertex->getMapEmbedding()->setBurstCoef(ADim, ACoef);
134  setModelChanged();
135  }
136 }
137 //******************************************************************************
138 void CControlerGMap::setMapBurstCoefs(TCoordinate ACoef0, TCoordinate ACoef1,
139  TCoordinate ACoef2,TCoordinate ACoef3)
140 {
141  if ( ACoef0!=FMap->getBurstCoef(0) || ACoef1!=FMap->getBurstCoef(1) ||
142  ACoef2!=FMap->getBurstCoef(2) || ACoef3!=FMap->getBurstCoef(3) )
143  {
144  FMap->setBurstCoef(0, ACoef0);
145  FMap->setBurstCoef(1, ACoef1);
146  FMap->setBurstCoef(2, ACoef2);
147  FMap->setBurstCoef(3, ACoef3);
148  if ( FParameterGMapVertex->getMapEmbedding()!=NULL )
149  {
150  FParameterGMapVertex->getMapEmbedding()->setBurstCoef(0, ACoef0);
151  FParameterGMapVertex->getMapEmbedding()->setBurstCoef(1, ACoef1);
152  FParameterGMapVertex->getMapEmbedding()->setBurstCoef(2, ACoef2);
153  FParameterGMapVertex->getMapEmbedding()->setBurstCoef(3, ACoef3);
154  }
155  setModelChanged();
156  }
157 }
158 //******************************************************************************
159 void CControlerGMap::setBurstMethod(TBurstMethod AMethod)
160 {
161  FParameterGMapVertex->setBurstMethod(AMethod);
162 }
163 //------------------------------------------------------------------------------
164 TBurstMethod CControlerGMap::getBurstMethod() const
165 {
166  return FParameterGMapVertex->getBurstMethod();
167 }
168 //******************************************************************************
170 {
171  assert( getParameterGMapVertex()!=NULL );
173 }
174 //------------------------------------------------------------------------------
176 {
177  assert( getParameterGMapVertex()!=NULL );
179 }
180 //------------------------------------------------------------------------------
182 {
183  assert( getParameterGMapVertex()!=NULL );
185 }
186 //------------------------------------------------------------------------------
188 {
190  else setModelBlocked();
191 }
192 //******************************************************************************
194 {
195  assert( getParameterGMapVertex()!=NULL );
197 }
198 //------------------------------------------------------------------------------
200 {
201  assert( getParameterGMapVertex()!=NULL );
203 }
204 //------------------------------------------------------------------------------
206 {
207  assert( getParameterGMapVertex()!=NULL );
209 }
210 //------------------------------------------------------------------------------
212 {
214  else setModeSimplification();
215 }
216 //******************************************************************************