Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
parameter-sew.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-types.hh"
27 #include "parameter-sew.hh"
28 #include <cassert>
29 #include <cstring>
30 using namespace std;
31 using namespace GMap3d;
32 //******************************************************************************
33 CParameterSew::CParameterSew(int ANbRef) :
34  CParameter(ANbRef)
35 {
36  reinit();
37 }
38 //******************************************************************************
40  CParameter(AParam)
41 {
42  for (int i=0; i<4; ++i)
43  {
44  FLWSew[i] = AParam.FLWSew[i];
45  FSewPosCoef[i] = AParam.FSewPosCoef[i];
46  FDisplayAlpha[i] = AParam.FDisplayAlpha[i];
47  setCLSew(i, AParam.getCLSew(i));
48  }
49 }
50 //******************************************************************************
52 {}
53 //******************************************************************************
55 { return new CParameterSew(*this); }
56 //******************************************************************************
57 void CParameterSew::save(ostream& AStream)
58 { AStream<<(*this); }
59 //------------------------------------------------------------------------------
60 void CParameterSew::load(istream& AStream)
61 { AStream>>(*this); }
62 //------------------------------------------------------------------------------
64 {
65  FLWSew[0] = DEFAULT_SEW0_LINE_WIDTH;
66  FLWSew[1] = DEFAULT_SEW1_LINE_WIDTH;
67  FLWSew[2] = DEFAULT_SEW2_LINE_WIDTH;
68  FLWSew[3] = DEFAULT_SEW3_LINE_WIDTH;
69 
70  FSewPosCoef[0] = DEFAULT_SEW0_POSITION;
71  FSewPosCoef[1] = DEFAULT_SEW1_POSITION;
72  FSewPosCoef[2] = DEFAULT_SEW2_POSITION;
73  FSewPosCoef[3] = DEFAULT_SEW3_POSITION;
74 
75  FDisplayAlpha[0] = DEFAULT_SEW0_DISPLAY;
76  FDisplayAlpha[1] = DEFAULT_SEW1_DISPLAY;
77  FDisplayAlpha[2] = DEFAULT_SEW2_DISPLAY;
78  FDisplayAlpha[3] = DEFAULT_SEW3_DISPLAY;
79 
84 
86 }
87 //******************************************************************************
88 namespace GMap3d
89 {
90 //------------------------------------------------------------------------------
91 ostream& operator<<(ostream& AStream, const CParameterSew & AParameter)
92 {
93  AStream<<"CParameterSew:"<<endl;
94 
95  AStream<<" LineWidth0: "<<AParameter.FLWSew[0]<<endl;
96  AStream<<" LineWidth1: "<<AParameter.FLWSew[1]<<endl;
97  AStream<<" LineWidth2: "<<AParameter.FLWSew[2]<<endl;
98  AStream<<" LineWidth3: "<<AParameter.FLWSew[3]<<endl;
99 
100  AStream<<" PosCoef0: "<<AParameter.FSewPosCoef[0]<<endl;
101  AStream<<" PosCoef1: "<<AParameter.FSewPosCoef[1]<<endl;
102  AStream<<" PosCoef2: "<<AParameter.FSewPosCoef[2]<<endl;
103  AStream<<" PosCoef3: "<<AParameter.FSewPosCoef[3]<<endl;
104 
105  AStream<<" Display0: "<<AParameter.FDisplayAlpha[0]<<endl;
106  AStream<<" Display1: "<<AParameter.FDisplayAlpha[1]<<endl;
107  AStream<<" Display2: "<<AParameter.FDisplayAlpha[2]<<endl;
108  AStream<<" Display3: "<<AParameter.FDisplayAlpha[3]<<endl;
109 
110  AStream<<" Color0: "<<AParameter.FCLSew[0][0]<<" "
111  <<AParameter.FCLSew[0][1]<<" "<<AParameter.FCLSew[0][2]<<endl;
112  AStream<<" Color1: "<<AParameter.FCLSew[1][0]<<" "
113  <<AParameter.FCLSew[1][1]<<" "<<AParameter.FCLSew[1][2]<<endl;
114  AStream<<" Color2: "<<AParameter.FCLSew[2][0]<<" "
115  <<AParameter.FCLSew[2][1]<<" "<<AParameter.FCLSew[2][2]<<endl;
116  AStream<<" Color3: "<<AParameter.FCLSew[3][0]<<" "
117  <<AParameter.FCLSew[3][1]<<" "<<AParameter.FCLSew[3][2]<<endl;
118 
119  AStream<<endl;
120 
121  return AStream;
122 }
123 //------------------------------------------------------------------------------
124 istream& operator>>(istream& AStream, CParameterSew & AParameter)
125 {
126  char tmp[256];
127 
128  AStream>>tmp; assert ( !strcmp(tmp, "CParameterSew:") );
129 
130  AStream>>tmp; assert ( !strcmp(tmp, "LineWidth0:") );
131  AStream>>AParameter.FLWSew[0];
132  AStream>>tmp; assert ( !strcmp(tmp, "LineWidth1:") );
133  AStream>>AParameter.FLWSew[1];
134  AStream>>tmp; assert ( !strcmp(tmp, "LineWidth2:") );
135  AStream>>AParameter.FLWSew[2];
136  AStream>>tmp; assert ( !strcmp(tmp, "LineWidth3:") );
137  AStream>>AParameter.FLWSew[3];
138 
139  AStream>>tmp; assert ( !strcmp(tmp, "PosCoef0:") );
140  AStream>>AParameter.FSewPosCoef[0];
141  AStream>>tmp; assert ( !strcmp(tmp, "PosCoef1:") );
142  AStream>>AParameter.FSewPosCoef[1];
143  AStream>>tmp; assert ( !strcmp(tmp, "PosCoef2:") );
144  AStream>>AParameter.FSewPosCoef[2];
145  AStream>>tmp; assert ( !strcmp(tmp, "PosCoef3:") );
146  AStream>>AParameter.FSewPosCoef[3];
147 
148  AStream>>tmp; assert ( !strcmp(tmp, "Display0:") );
149  AStream>>AParameter.FDisplayAlpha[0];
150  AStream>>tmp; assert ( !strcmp(tmp, "Display1:") );
151  AStream>>AParameter.FDisplayAlpha[1];
152  AStream>>tmp; assert ( !strcmp(tmp, "Display2:") );
153  AStream>>AParameter.FDisplayAlpha[2];
154  AStream>>tmp; assert ( !strcmp(tmp, "Display3:") );
155  AStream>>AParameter.FDisplayAlpha[3];
156 
157  AStream>>tmp; assert ( !strcmp(tmp, "Color0:") );
158  AStream>>AParameter.FCLSew[0][0]>>AParameter.FCLSew[0][1]
159  >>AParameter.FCLSew[0][2];
160  AStream>>tmp; assert ( !strcmp(tmp, "Color1:") );
161  AStream>>AParameter.FCLSew[1][0]>>AParameter.FCLSew[1][1]
162  >>AParameter.FCLSew[1][2];
163  AStream>>tmp; assert ( !strcmp(tmp, "Color2:") );
164  AStream>>AParameter.FCLSew[2][0]>>AParameter.FCLSew[2][1]
165  >>AParameter.FCLSew[2][2];
166  AStream>>tmp; assert ( !strcmp(tmp, "Color3:") );
167  AStream>>AParameter.FCLSew[3][0]>>AParameter.FCLSew[3][1]
168  >>AParameter.FCLSew[3][2];
169 
170  AParameter.putAllNeedToUpdate();
171 
172  return AStream;
173 }
174 //------------------------------------------------------------------------------
175 } // namespace GMap3d
176 //******************************************************************************
177 int CParameterSew::getLWSew(int ADimension) const
178 {
179  assert(0<=ADimension && ADimension<=3);
180  return FLWSew[ADimension];
181 }
182 void CParameterSew::setLWSew(int ADimension, int AValue)
183 {
184  assert(0<=ADimension && ADimension<=3);
185  if (FLWSew[ADimension]!=AValue)
186  {
188  FLWSew[ADimension]= AValue;
189  }
190 }
191 //******************************************************************************
192 float CParameterSew::getSewPosCoef(int ADimension) const
193 {
194  assert(0<=ADimension && ADimension<=3);
195  return FSewPosCoef[ADimension];
196 }
197 void CParameterSew::setSewPosCoef(int ADimension, float AValue)
198 {
199  assert(0<=ADimension && ADimension<=3);
200  if (FSewPosCoef[ADimension]!=AValue)
201  {
203  FSewPosCoef[ADimension]= AValue;
204  }
205 }
206 //******************************************************************************
207 float CParameterSew::getCLSew(int ADimension, int AIndice) const
208 {
209  assert(0<=ADimension && ADimension<=3);
210  assert(0<=AIndice && AIndice<=2);
211  return FCLSew[ADimension][AIndice];
212 }
213 void CParameterSew::setCLSew(int ADimension, int AIndice, float AValue)
214 {
215  assert(0<=ADimension && ADimension<=3);
216  assert(0<=AIndice && AIndice<=2);
217  if (FCLSew[ADimension][AIndice]!=AValue)
218  {
220  FCLSew[ADimension][AIndice]= AValue;
221  }
222 }
223 const float * CParameterSew::getCLSew(int ADimension) const
224 {
225  assert(0<=ADimension && ADimension<=3);
226  return FCLSew[ADimension];
227 }
228 void CParameterSew::setCLSew(int ADimension, float AValue0,
229  float AValue1, float AValue2)
230 {
231  assert(0<=ADimension && ADimension<=3);
232  if ( FCLSew[ADimension][0]!=AValue0 ||
233  FCLSew[ADimension][1]!=AValue1 ||
234  FCLSew[ADimension][2]!=AValue2 )
235  {
237  FCLSew[ADimension][0]= AValue0;
238  FCLSew[ADimension][1]= AValue1;
239  FCLSew[ADimension][2]= AValue2;
240  }
241 }
242 void CParameterSew::setCLSew(int ADimension,const float ATab[3])
243 { setCLSew(ADimension,ATab[0],ATab[1],ATab[2]); }
244 //******************************************************************************
245 bool CParameterSew::getDisplayAlpha(int AIndex) const
246 {
247  assert(0<=AIndex && AIndex<=3);
248  return FDisplayAlpha[AIndex];
249 }
250 //******************************************************************************
251 void CParameterSew::setDisplayAlpha(int AIndex,bool AValue)
252 {
253  assert(0<=AIndex && AIndex<=3);
254  if ( FDisplayAlpha[AIndex]!=AValue)
255  {
257  FDisplayAlpha[AIndex]= AValue;
258  }
259 }
260 //******************************************************************************
262 {
263  assert(0<=AIndex && AIndex<=3);
265  FDisplayAlpha[AIndex]= !FDisplayAlpha[AIndex];
266 }
267 //******************************************************************************
269 { return PARAMETER_SEW; }
270 //******************************************************************************