Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
parameter-grid.cc
Go to the documentation of this file.
1 /*
2  * lib-controler : Un contrôleur générique de scène 3D.
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
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-types.hh"
27 #include "parameter-grid.hh"
28 #include <cassert>
29 #include <cstring>
30 using namespace std;
31 //******************************************************************************
33  CParameter(ANbRef)
34 {
35  reinit();
36 }
37 //******************************************************************************
39  CParameter (AParam),
40  FLWGrid (AParam.FLWGrid),
41  FLGGrid (AParam.FLGGrid),
42  FDisplayGridXY (AParam.FDisplayGridXY),
43  FDisplayGridYZ (AParam.FDisplayGridYZ),
44  FDisplayGridXZ (AParam.FDisplayGridXZ),
45  FDisplayPositiveGridX(AParam.FDisplayPositiveGridX),
46  FDisplayPositiveGridY(AParam.FDisplayPositiveGridY),
47  FDisplayPositiveGridZ(AParam.FDisplayPositiveGridZ)
48 {
49  setCLGrid(AParam.getCLGrid());
50 }
51 //******************************************************************************
53 {}
54 //******************************************************************************
56 { return new CParameterGrid(*this); }
57 //******************************************************************************
58 void CParameterGrid::save(ostream& AStream)
59 { AStream<<(*this); }
60 //------------------------------------------------------------------------------
61 void CParameterGrid::load(istream& AStream)
62 { AStream>>(*this); }
63 //------------------------------------------------------------------------------
65 {
66  FLWGrid = DEFAULT_GRID_LINE_WIDTH;
67  FLGGrid = DEFAULT_GRID_SIZE;
68  FDisplayGridXY = DEFAULT_GRID_DISPLAY_XY;
69  FDisplayGridYZ = DEFAULT_GRID_DISPLAY_YZ;
70  FDisplayGridXZ = DEFAULT_GRID_DISPLAY_XZ;
71  FDisplayPositiveGridX = DEFAULT_GRID_POSITIVE_X;
72  FDisplayPositiveGridY = DEFAULT_GRID_POSITIVE_Y;
73  FDisplayPositiveGridZ = DEFAULT_GRID_POSITIVE_Z;
75 
77 }
78 //******************************************************************************
79 ostream& operator<<(ostream& AStream,
80  const CParameterGrid & AParameter)
81 {
82  AStream<<"CParameterGrid:"<<endl;
83 
84  AStream<<" LineWidth: "<<AParameter.FLWGrid<<endl;
85 
86  AStream<<" Length: "<<AParameter.FLGGrid<<endl;
87 
88  AStream<<" DisplayXY: "<<AParameter.FDisplayGridXY<<endl;
89  AStream<<" DisplayYZ: "<<AParameter.FDisplayGridYZ<<endl;
90  AStream<<" DisplayXZ: "<<AParameter.FDisplayGridXZ<<endl;
91 
92  AStream<<" PositiveX: "<<AParameter.FDisplayPositiveGridX<<endl;
93  AStream<<" PositiveY: "<<AParameter.FDisplayPositiveGridY<<endl;
94  AStream<<" PositiveZ: "<<AParameter.FDisplayPositiveGridZ<<endl;
95 
96  AStream<<" Color: "<<AParameter.FCLGrid[0]<<" "
97  <<AParameter.FCLGrid[1]<<" "<<AParameter.FCLGrid[2]<<endl;
98 
99  AStream<<endl;
100 
101  return AStream;
102 }
103 //------------------------------------------------------------------------------
104 istream& operator>>(istream& AStream,
105  CParameterGrid & AParameter)
106 {
107  char tmp[256];
108 
109  AStream>>tmp; assert ( !strcmp(tmp, "CParameterGrid:") );
110 
111  AStream>>tmp; assert ( !strcmp(tmp, "LineWidth:") );
112  AStream>>AParameter.FLWGrid;
113 
114  AStream>>tmp; assert ( !strcmp(tmp, "Length:") );
115  AStream>>AParameter.FLGGrid;
116 
117  AStream>>tmp; assert ( !strcmp(tmp, "DisplayXY:") );
118  AStream>>AParameter.FDisplayGridXY;
119  AStream>>tmp; assert ( !strcmp(tmp, "DisplayYZ:") );
120  AStream>>AParameter.FDisplayGridYZ;
121  AStream>>tmp; assert ( !strcmp(tmp, "DisplayXZ:") );
122  AStream>>AParameter.FDisplayGridXZ;
123 
124  AStream>>tmp; assert ( !strcmp(tmp, "PositiveX:") );
125  AStream>>AParameter.FDisplayPositiveGridX;
126  AStream>>tmp; assert ( !strcmp(tmp, "PositiveY:") );
127  AStream>>AParameter.FDisplayPositiveGridY;
128  AStream>>tmp; assert ( !strcmp(tmp, "PositiveZ:") );
129  AStream>>AParameter.FDisplayPositiveGridZ;
130 
131  AStream>>tmp; assert ( !strcmp(tmp, "Color:") );
132  AStream>>AParameter.FCLGrid[0]>>AParameter.FCLGrid[1]
133  >>AParameter.FCLGrid[2];
134 
135  AParameter.putAllNeedToUpdate();
136 
137  return AStream;
138 }
139 //******************************************************************************
141 { return FLWGrid; }
143 {
144  if (FLWGrid!=AValue)
145  {
147  FLWGrid= AValue;
148  }
149 }
150 //******************************************************************************
152 { return FLGGrid; }
154 {
155  if (FLGGrid!=AValue)
156  {
158  FLGGrid= AValue;
159  }
160 }
161 //******************************************************************************
162 float CParameterGrid::getCLGrid(int AIndice) const
163 {
164  assert(0<=AIndice && AIndice<=2);
165  return FCLGrid[AIndice];
166 }
167 void CParameterGrid::setCLGrid(int AIndice, float AValue)
168 {
169  assert(0<=AIndice && AIndice<=2);
170  if (FCLGrid[AIndice]!=AValue)
171  {
173  FCLGrid[AIndice]= AValue;
174  }
175 }
176 const float * CParameterGrid::getCLGrid() const
177 { return FCLGrid; }
178 void CParameterGrid::setCLGrid(float AValue0, float AValue1, float AValue2)
179 {
180  if ( FCLGrid[0]!=AValue0 ||
181  FCLGrid[1]!=AValue1 ||
182  FCLGrid[2]!=AValue2 )
183  {
185  FCLGrid[0]= AValue0;
186  FCLGrid[1]= AValue1;
187  FCLGrid[2]= AValue2;
188  }
189 }
190 void CParameterGrid::setCLGrid(const float ATab[3])
191 { setCLGrid(ATab[0],ATab[1],ATab[2]); }
192 //******************************************************************************
194 { return FDisplayGridXY; }
195 //******************************************************************************
197 {
198  if (FDisplayGridXY!=AValue)
199  {
201  FDisplayGridXY= AValue;
202  }
203 }
204 //******************************************************************************
206 {
208  FDisplayGridXY= !FDisplayGridXY;
209 }
210 
211 //******************************************************************************
213 { return FDisplayGridYZ; }
214 //******************************************************************************
216 {
217  if (FDisplayGridYZ!=AValue)
218  {
220  FDisplayGridYZ= AValue;
221  }
222 }
223 //******************************************************************************
225 {
227  FDisplayGridYZ= !FDisplayGridYZ;
228 }
229 
230 //******************************************************************************
232 { return FDisplayGridXZ; }
233 //******************************************************************************
235 {
236  if (FDisplayGridXZ!=AValue)
237  {
239  FDisplayGridXZ= AValue;
240  }
241 }
242 //******************************************************************************
244 {
246  FDisplayGridXZ= !FDisplayGridXZ;
247 }
248 
249 //******************************************************************************
251 { return FDisplayPositiveGridX; }
252 //******************************************************************************
254 {
255  if (FDisplayPositiveGridX!=AValue)
256  {
258  FDisplayPositiveGridX= AValue;
259  }
260 }
261 //******************************************************************************
263 {
265  FDisplayPositiveGridX= !FDisplayPositiveGridX;
266 }
267 
268 //******************************************************************************
270 { return FDisplayPositiveGridY; }
271 //******************************************************************************
273 {
274  if (FDisplayPositiveGridY!=AValue)
275  {
277  FDisplayPositiveGridY= AValue;
278  }
279 }
280 //******************************************************************************
282 {
284  FDisplayPositiveGridY= !FDisplayPositiveGridY;
285 }
286 
287 //******************************************************************************
289 { return FDisplayPositiveGridZ; }
290 //******************************************************************************
292 {
293  if (FDisplayPositiveGridZ!=AValue)
294  {
296  FDisplayPositiveGridZ= AValue;
297  }
298 }
299 //******************************************************************************
301 {
303  FDisplayPositiveGridZ= !FDisplayPositiveGridZ;
304 }
305 //******************************************************************************
307 { return PARAMETER_GRID; }
308 //******************************************************************************