Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
parameter-face.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-face.hh"
28 #include <cassert>
29 #include <cstring>
30 using namespace std;
31 using namespace GMap3d;
32 //******************************************************************************
33 CParameterFace::CParameterFace(int ANbRef) :
34  CParameter(ANbRef)
35 {
36  reinit();
37 }
38 //******************************************************************************
40  CParameter (AParam),
41  FBLFace (AParam.FBLFace),
42  FRandomCLFace (AParam.FRandomCLFace),
43  FRandomCLVolume (AParam.FRandomCLVolume),
44  FRandomColorGeometry(AParam.FRandomColorGeometry)
45 
46 {
47  setCLFace(AParam.getCLFace());
48  setBLFace(AParam.getBLFace());
49 }
50 //******************************************************************************
52 {}
53 //******************************************************************************
55 { return new CParameterFace(*this); }
56 //******************************************************************************
57 void CParameterFace::save(ostream& AStream)
58 { AStream<<(*this); }
59 //------------------------------------------------------------------------------
60 void CParameterFace::load(istream& AStream)
61 { AStream>>(*this); }
62 //------------------------------------------------------------------------------
64 {
66  FBLFace = DEFAULT_FACE_TRANSPARENCY;
67  FRandomCLFace = DEFAULT_FACE_RANDOM_CL_FACE;
68  FRandomCLVolume = DEFAULT_FACE_RANDOM_CL_VOLUME;
69  FRandomColorGeometry = DEFAULT_FACE_RANDOM_GEOMETRY;
71 }
72 //******************************************************************************
73 namespace GMap3d
74 {
75 //------------------------------------------------------------------------------
76 ostream& operator<<(ostream& AStream, const CParameterFace & AParameter)
77 {
78  AStream<<"CParameterFace:"<<endl;
79 
80  AStream<<" Color: "<<AParameter.FCLFace[0]<<" "
81  <<AParameter.FCLFace[1]<<" "<<AParameter.FCLFace[2]<<endl;
82 
83  AStream<<" Transparency: "<<AParameter.FBLFace<<endl;
84 
85  AStream<<" RandomColorFace: "<<AParameter.FRandomCLFace<<endl;
86  AStream<<" RandomColorVolume: "<<AParameter.FRandomCLVolume<<endl;
87  AStream<<" RandomColorGeometry: "<<AParameter.FRandomColorGeometry<<endl;
88 
89  AStream<<endl;
90 
91  return AStream;
92 }
93 //------------------------------------------------------------------------------
94 istream& operator>>(istream& AStream, CParameterFace & AParameter)
95 {
96  char tmp[256];
97 
98  AStream>>tmp; assert ( !strcmp(tmp, "CParameterFace:") );
99 
100  AStream>>tmp; assert ( !strcmp(tmp, "Color:") );
101  AStream>>AParameter.FCLFace[0]>>AParameter.FCLFace[1]
102  >>AParameter.FCLFace[2];
103 
104  AStream>>tmp; assert ( !strcmp(tmp, "Transparency:") );
105  AStream>>AParameter.FBLFace;
106 
107  AStream>>tmp; assert ( !strcmp(tmp, "RandomColorFace:") );
108  AStream>>AParameter.FRandomCLFace;
109 
110  AStream>>tmp; assert ( !strcmp(tmp, "RandomColorVolume:") );
111  AStream>>AParameter.FRandomCLVolume;
112 
113  AStream>>tmp; assert ( !strcmp(tmp, "RandomColorGeometry:") );
114  AStream>>AParameter.FRandomColorGeometry;
115 
116  AParameter.putAllNeedToUpdate();
117 
118  return AStream;
119 }
120 //------------------------------------------------------------------------------
121 } // namespace GMap3d
122 //******************************************************************************
123 float CParameterFace::getCLFace(int AIndice) const
124 {
125  assert(0<=AIndice && AIndice<=2);
126  return FCLFace[AIndice];
127 }
128 void CParameterFace::setCLFace(int AIndice, float AValue)
129 {
130  assert(0<=AIndice && AIndice<=2);
131  if ( FCLFace[AIndice]!=AValue )
132  {
134  FCLFace[AIndice]= AValue;
135  }
136 }
137 const float * CParameterFace::getCLFace() const
138 { return FCLFace; }
139 void CParameterFace::setCLFace(float AValue0, float AValue1, float AValue2)
140 {
141  if ( FCLFace[0]!=AValue0 ||
142  FCLFace[1]!=AValue1 ||
143  FCLFace[2]!=AValue2 )
144  {
146  FCLFace[0]= AValue0;
147  FCLFace[1]= AValue1;
148  FCLFace[2]= AValue2;
149  }
150 }
151 void CParameterFace::setCLFace(const float ATab[3])
152 { setCLFace(ATab[0],ATab[1],ATab[2]); }
153 //******************************************************************************
155 { return FBLFace; }
156 void CParameterFace::setBLFace(float AValue)
157 {
158  if ( FBLFace!=AValue )
159  {
161  FBLFace = AValue;
162  }
163 }
164 //******************************************************************************
166 { return FRandomCLFace; }
167 
169 {
170  if ( FRandomCLFace!=AValue )
171  {
173  FRandomCLFace=AValue;
174  }
175 }
176 //******************************************************************************
178 { return FRandomCLVolume; }
179 
181 {
182  if ( FRandomCLVolume!=AValue )
183  {
185  FRandomCLVolume = AValue;
186  }
187 }
188 //******************************************************************************
190 { return FRandomColorGeometry; }
191 
193 {
194  if ( FRandomColorGeometry!=AValue )
195  {
197  FRandomColorGeometry = AValue;
198  }
199 }
200 //******************************************************************************
202 { return PARAMETER_FACE; }
203 //******************************************************************************