Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
parameter-preview.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-preview.hh"
28 #include <cassert>
29 #include <cstring>
30 using namespace std;
31 using namespace GMap3d;
32 //******************************************************************************
33 CParameterPreview::CParameterPreview(int ANbRef) :
34  CParameter(ANbRef)
35 {
36  reinit();
37 }
38 //******************************************************************************
41  CParameter (AParam),
42  FLWPreview (AParam.FLWPreview),
43  FLWPreviewPoint(AParam.FLWPreviewPoint)
44 {
45  setCLPreview (AParam.getCLPreview());
47 }
48 //******************************************************************************
50 {}
51 //******************************************************************************
53 { return new CParameterPreview(*this); }
54 //******************************************************************************
55 void CParameterPreview::save(ostream& AStream)
56 { AStream<<(*this); }
57 //------------------------------------------------------------------------------
58 void CParameterPreview::load(istream& AStream)
59 { AStream>>(*this); }
60 //------------------------------------------------------------------------------
62 {
63  FLWPreview = DEFAULT_PREVIEW_LINE_WIDTH;
64  FLWPreviewPoint = DEFAULT_PREVIEW_LINE_WIDTH_POINT;
69 
71 }
72 //******************************************************************************
73 namespace GMap3d
74 {
75 //------------------------------------------------------------------------------
76 ostream& operator<<(ostream& AStream, const CParameterPreview & AParameter)
77 {
78  AStream<<"CParameterPreview:"<<endl;
79 
80  AStream<<" LineWidth: "<<AParameter.FLWPreview<<endl;
81 
82  AStream<<" PointLineWidth: "<<AParameter.FLWPreviewPoint<<endl;
83 
84  AStream<<" Color: "<<AParameter.FCLPreview[0]<<" "
85  <<AParameter.FCLPreview[1]<<" "<<AParameter.FCLPreview[2]<<endl;
86 
87  AStream<<" ColorBad: "<<AParameter.FCLPreviewBad[0]<<" "
88  <<AParameter.FCLPreviewBad[1]<<" "<<AParameter.FCLPreviewBad[2]<<endl;
89 
90  AStream<<endl;
91 
92  return AStream;
93 }
94 //------------------------------------------------------------------------------
95 istream& operator>>(istream& AStream, CParameterPreview & AParameter)
96 {
97  char tmp[256];
98 
99  AStream>>tmp; assert ( !strcmp(tmp, "CParameterPreview:") );
100 
101  AStream>>tmp; assert ( !strcmp(tmp, "LineWidth:") );
102  AStream>>AParameter.FLWPreview;
103 
104  AStream>>tmp; assert ( !strcmp(tmp, "PointLineWidth:") );
105  AStream>>AParameter.FLWPreviewPoint;
106 
107  AStream>>tmp; assert ( !strcmp(tmp, "Color:") );
108  AStream>>AParameter.FCLPreview[0]>>AParameter.FCLPreview[1]
109  >>AParameter.FCLPreview[2];
110 
111  AStream>>tmp; assert ( !strcmp(tmp, "ColorBad:") );
112  AStream>>AParameter.FCLPreviewBad[0]>>AParameter.FCLPreviewBad[1]
113  >>AParameter.FCLPreviewBad[2];
114 
115  AParameter.putAllNeedToUpdate();
116 
117  return AStream;
118 }
119 //------------------------------------------------------------------------------
120 } // namespace GMap3d
121 //******************************************************************************
123 { return FLWPreview; }
125 {
126  if ( FLWPreview!=AValue )
127  {
129  FLWPreview= AValue;
130  }
131 }
132 //******************************************************************************
134 { return FLWPreviewPoint; }
136 {
137  if ( FLWPreviewPoint!=AValue )
138  {
140  FLWPreviewPoint = AValue;
141  }
142 }
143 //******************************************************************************
144 float CParameterPreview::getCLPreview(int AIndice) const
145 {
146  assert(0<=AIndice && AIndice<=2);
147  return FCLPreview[AIndice];
148 }
149 void CParameterPreview::setCLPreview(int AIndice, float AValue)
150 {
151  assert(0<=AIndice && AIndice<=2);
152  if ( FCLPreview[AIndice]!=AValue )
153  {
155  FCLPreview[AIndice]= AValue;
156  }
157 }
158 const float * CParameterPreview::getCLPreview() const
159 { return FCLPreview; }
160 void CParameterPreview::setCLPreview(float AValue0, float AValue1, float AValue2)
161 {
162  if ( FCLPreview[0]!=AValue0 ||
163  FCLPreview[1]!=AValue1 ||
164  FCLPreview[2]!=AValue2 )
165  {
167  FCLPreview[0]= AValue0;
168  FCLPreview[1]= AValue1;
169  FCLPreview[2]= AValue2;
170  }
171 }
172 void CParameterPreview::setCLPreview(const float ATab[3])
173 { setCLPreview(ATab[0],ATab[1],ATab[2]); }
174 //******************************************************************************
175 float CParameterPreview::getCLPreviewBad(int AIndice) const
176 {
177  assert(0<=AIndice && AIndice<=2);
178  return FCLPreviewBad[AIndice];
179 }
180 void CParameterPreview::setCLPreviewBad(int AIndice, float AValue)
181 {
182  assert(0<=AIndice && AIndice<=2);
183  if ( FCLPreviewBad[AIndice]!=AValue )
184  {
186  FCLPreviewBad[AIndice]= AValue;
187  }
188 }
190 { return FCLPreviewBad; }
191 void CParameterPreview::setCLPreviewBad(float AValue0, float AValue1, float AValue2)
192 {
193  if ( FCLPreviewBad[0]!=AValue0 ||
194  FCLPreviewBad[1]!=AValue1 ||
195  FCLPreviewBad[2]!=AValue2 )
196  {
198  FCLPreviewBad[0]= AValue0;
199  FCLPreviewBad[1]= AValue1;
200  FCLPreviewBad[2]= AValue2;
201  }
202 }
203 void CParameterPreview::setCLPreviewBad(const float ATab[3])
204 { setCLPreviewBad(ATab[0],ATab[1],ATab[2]); }
205 //******************************************************************************
207 { return PARAMETER_PREVIEW; }
208 //******************************************************************************