Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
precompile-spamod.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_SPAMOD
26 //******************************************************************************
27 #include "controler-gmap-types.hh"
28 #include "precompile-spamod.hh"
29 #include "parameter-gmap-vertex.hh"
30 #include "parameter-spamod.hh"
31 #include "spamod-api.hh"
32 #include <cassert>
33 using namespace std;
34 using namespace GMap3d;
35 //******************************************************************************
36 CPrecompileSpamod::CPrecompileSpamod(CParameterGMapVertex * AParameterGMapV,
37  CParameterSpamod * AParameterSpamod) :
38  FParameterGMapV (AParameterGMapV),
39  FParameterSpamod (AParameterSpamod)
40 {
41  assert(FParameterGMapV != NULL);
42  assert(FParameterSpamod != NULL);
43 
44  FParameterGMapV->addPrecompileToUpdate(this);
45  FParameterSpamod->addPrecompileToUpdate(this);
46 }
47 //******************************************************************************
48 CPrecompileSpamod::CPrecompileSpamod(const CPrecompileSpamod & APrecompile) :
49  CPrecompile (APrecompile),
50  FParameterGMapV (APrecompile.FParameterGMapV),
51  FParameterSpamod (static_cast<CParameterSpamod*>
52  (APrecompile.FParameterSpamod->copy()))
53 {
54  assert(FParameterGMapV != NULL);
55  assert(FParameterSpamod != NULL);
56 
57  FParameterGMapV->addPrecompileToUpdate(this);
58  FParameterSpamod->addPrecompileToUpdate(this);
59 }
60 //******************************************************************************
61 CPrecompileSpamod::~CPrecompileSpamod()
62 {
63  FParameterGMapV->removePrecompileToUpdate(this);
64  FParameterSpamod->removePrecompileToUpdate(this);
65 }
66 //******************************************************************************
67 CPrecompile * CPrecompileSpamod::copy() const
68 { return new CPrecompileSpamod(*this); }
69 //******************************************************************************
70 void CPrecompileSpamod::setParameter(CParameter* AParameter)
71 {
72  switch (AParameter->getType())
73  {
75  setGMapVertex(static_cast<CParameterGMapVertex *>(AParameter));
76  break;
77  case PARAMETER_SPAMOD:
78  setParameterSpamod(static_cast<CParameterSpamod*>(AParameter));
79  break;
80  }
81 }
82 //******************************************************************************
83 CParameter* CPrecompileSpamod::getParameter() const
84 { return FParameterSpamod; }
85 //******************************************************************************
86 void CPrecompileSpamod::setGMapVertex(CParameterGMapVertex* AParameterGMapV)
87 {
88  assert(AParameterGMapV != NULL);
89  AParameterGMapV->addPrecompileToUpdate(this);
90  FParameterGMapV->removePrecompileToUpdate(this);
91  FParameterGMapV = AParameterGMapV;
92  setToUpdate();
93 }
94 //******************************************************************************
95 void CPrecompileSpamod::setParameterSpamod(CParameterSpamod* ASpamod)
96 {
97  assert(ASpamod != NULL);
98  ASpamod->addPrecompileToUpdate(this);
99  FParameterSpamod->removePrecompileToUpdate(this);
100  FParameterSpamod = ASpamod;
101  setToUpdate();
102 }
103 //******************************************************************************
104 TPrecompile CPrecompileSpamod::getType() const
105 { return PRECOMPILE_SPAMOD; }
106 //******************************************************************************
107 void CPrecompileSpamod::drawModel()
108 {
109  if (FParameterGMapV->getMap()->getFirstDart() == NULL ||
110  FParameterSpamod->getViewMode() == SPAMOD_NONE)
111  return;
112 
113  // cout << "calculs spamod <beg>" << endl;
114  FSpamodAPI = new CSpamodAPI((CGMap *) FParameterGMapV->getMap());
115 
116  // Récupération des paramètres :
117  for (int i=0; i<2; ++i)
118  FSpamodAPI->setEuclidianParam(i, FParameterSpamod->getEuclidianParam(i));
119 
120  for (int i=0; i<4; ++i)
121  FSpamodAPI->setAnalyticParam(i, FParameterSpamod->getAnalyticParam(i));
122 
123  for (int i=0; i<3; ++i)
124  FSpamodAPI->setVoxelParam(i, FParameterSpamod->getVoxelParam(i));
125 
126  for (int i=0; i<3; ++i)
127  FSpamodAPI->setK2Param(i, FParameterSpamod->getK2Param(i));
128 
129  // Affichage :
130 
131  FSpamodAPI->setViewMode(FParameterSpamod->getViewMode());
132  FSpamodAPI->drawMap();
133  FSpamodAPI->setViewMode(SPAMOD_NONE);
134 
135  delete FSpamodAPI;
136  // cout << "calculs spamod <end>" << endl;
137 }
138 //******************************************************************************
139 #endif // MODULE_SPAMOD
140 //******************************************************************************
141 
142