Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
parameter-axis.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-axis.hh"
28 #include <cassert>
29 #include <cstring>
30 using namespace std;
31 //******************************************************************************
33  CParameter(ANbRef)
34 {
35  reinit();
36 }
37 //******************************************************************************
39  CParameter(AParam),
40  FLWAxis (AParam.FLWAxis),
41  FLGAxis (AParam.FLGAxis)
42 {
43  setCLAxisX(AParam.getCLAxisX());
44  setCLAxisY(AParam.getCLAxisY());
45  setCLAxisZ(AParam.getCLAxisZ());
46 }
47 //******************************************************************************
49 {}
50 //******************************************************************************
52 { return new CParameterAxis(*this); }
53 //******************************************************************************
54 void CParameterAxis::save(ostream& AStream)
55 { AStream<<(*this); }
56 //------------------------------------------------------------------------------
57 void CParameterAxis::load(istream& AStream)
58 { AStream>>(*this); }
59 //------------------------------------------------------------------------------
61 {
62  FLWAxis = DEFAULT_AXIS_LINE_WIDTH;
63  FLGAxis = DEFAULT_AXIS_LENGTH;
64 
68 
72 
76 
78 }
79 //******************************************************************************
80 ostream& operator<<(ostream& AStream, const CParameterAxis & AParameter)
81 {
82  AStream<<"CParameterAxis:"<<endl;
83 
84  AStream<<" LineWidth: "<<AParameter.FLWAxis<<endl;
85 
86  AStream<<" Length: "<<AParameter.FLGAxis<<endl;
87 
88  AStream<<" ColorX: "<<AParameter.FCLAxisX[0]<<" "
89  <<AParameter.FCLAxisX[1]<<" "<<AParameter.FCLAxisX[2]<<endl;
90 
91  AStream<<" ColorY: "<<AParameter.FCLAxisY[0]<<" "
92  <<AParameter.FCLAxisY[1]<<" "<<AParameter.FCLAxisY[2]<<endl;
93 
94  AStream<<" ColorZ: "<<AParameter.FCLAxisZ[0]<<" "
95  <<AParameter.FCLAxisZ[1]<<" "<<AParameter.FCLAxisZ[2]<<endl;
96 
97  AStream<<endl;
98 
99  return AStream;
100 }
101 //------------------------------------------------------------------------------
102 istream& operator>>(istream& AStream,
103  CParameterAxis & AParameter)
104 {
105  char tmp[256];
106 
107  AStream>>tmp; assert ( !strcmp(tmp, "CParameterAxis:") );
108 
109  AStream>>tmp; assert ( !strcmp(tmp, "LineWidth:") );
110  AStream>>AParameter.FLWAxis;
111 
112  AStream>>tmp; assert ( !strcmp(tmp, "Length:") );
113  AStream>>AParameter.FLGAxis;
114 
115  AStream>>tmp; assert ( !strcmp(tmp, "ColorX:") );
116  AStream>>AParameter.FCLAxisX[0]>>AParameter.FCLAxisX[1]
117  >>AParameter.FCLAxisX[2];
118 
119  AStream>>tmp; assert ( !strcmp(tmp, "ColorY:") );
120  AStream>>AParameter.FCLAxisY[0]>>AParameter.FCLAxisY[1]
121  >>AParameter.FCLAxisY[2];
122 
123  AStream>>tmp; assert ( !strcmp(tmp, "ColorZ:") );
124  AStream>>AParameter.FCLAxisZ[0]>>AParameter.FCLAxisZ[1]
125  >>AParameter.FCLAxisZ[2];
126 
127  AParameter.putAllNeedToUpdate();
128 
129  return AStream;
130 }
131 //******************************************************************************
133 { return FLWAxis; }
135 {
136  if ( FLWAxis!=AValue )
137  {
139  FLWAxis= AValue;
140  }
141 }
142 //******************************************************************************
144 { return FLGAxis; }
145 void CParameterAxis::setLGAxis(float AValue)
146 {
147  if ( FLGAxis!=AValue )
148  {
150  FLGAxis= AValue;
151  }
152 }
153 //******************************************************************************
154 float CParameterAxis::getCLAxisX(int AIndice) const
155 {
156  assert(0<=AIndice && AIndice<=2);
157  return FCLAxisX[AIndice];
158 }
159 void CParameterAxis::setCLAxisX(int AIndice, float AValue)
160 {
161  assert(0<=AIndice && AIndice<=2);
162  if ( FCLAxisX[AIndice]!=AValue )
163  {
165  FCLAxisX[AIndice]= AValue;
166  }
167 }
168 const float * CParameterAxis::getCLAxisX() const
169 { return FCLAxisX; }
170 void CParameterAxis::setCLAxisX(float AValue0, float AValue1, float AValue2)
171 {
172  if ( FCLAxisX[0]!=AValue0 ||
173  FCLAxisX[1]!=AValue1 ||
174  FCLAxisX[2]!=AValue2 )
175  {
177  FCLAxisX[0]= AValue0;
178  FCLAxisX[1]= AValue1;
179  FCLAxisX[2]= AValue2;
180  }
181 }
182 void CParameterAxis::setCLAxisX(const float ATab[3])
183 { setCLAxisX(ATab[0],ATab[1],ATab[2]); }
184 //******************************************************************************
185 float CParameterAxis::getCLAxisY(int AIndice) const
186 {
187  assert(0<=AIndice && AIndice<=2);
188  return FCLAxisY[AIndice];
189 }
190 void CParameterAxis::setCLAxisY(int AIndice, float AValue)
191 {
192  assert(0<=AIndice && AIndice<=2);
193  if ( FCLAxisY[AIndice]!=AValue )
194  {
196  FCLAxisY[AIndice]= AValue;
197  }
198 }
199 const float * CParameterAxis::getCLAxisY() const
200 { return FCLAxisY; }
201 void CParameterAxis::setCLAxisY(float AValue0, float AValue1, float AValue2)
202 {
203  if ( FCLAxisY[0]!=AValue0 ||
204  FCLAxisY[1]!=AValue1 ||
205  FCLAxisY[2]!=AValue2 )
206  {
208  FCLAxisY[0]= AValue0;
209  FCLAxisY[1]= AValue1;
210  FCLAxisY[2]= AValue2;
211  }
212 }
213 void CParameterAxis::setCLAxisY(const float ATab[3])
214 { setCLAxisY(ATab[0],ATab[1],ATab[2]); }
215 //******************************************************************************
216 float CParameterAxis::getCLAxisZ(int AIndice) const
217 {
218  assert(0<=AIndice && AIndice<=2);
219  return FCLAxisZ[AIndice];
220 }
221 void CParameterAxis::setCLAxisZ(int AIndice, float AValue)
222 {
223  assert(0<=AIndice && AIndice<=2);
224  if ( FCLAxisZ[AIndice]!=AValue )
225  {
227  FCLAxisZ[AIndice]= AValue;
228  }
229 }
230 const float * CParameterAxis::getCLAxisZ() const
231 { return FCLAxisZ; }
232 void CParameterAxis::setCLAxisZ(float AValue0, float AValue1, float AValue2)
233 {
234  if ( FCLAxisZ[0]!=AValue0 ||
235  FCLAxisZ[1]!=AValue1 ||
236  FCLAxisZ[2]!=AValue2 )
237  {
239  FCLAxisZ[0]= AValue0;
240  FCLAxisZ[1]= AValue1;
241  FCLAxisZ[2]= AValue2;
242  }
243 }
244 void CParameterAxis::setCLAxisZ(const float ATab[3])
245 { setCLAxisZ(ATab[0],ATab[1],ATab[2]); }
246 //******************************************************************************
248 { return PARAMETER_AXIS; }
249 //******************************************************************************