Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
parameter-normal-vector.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"
28 #include <cassert>
29 #include <cstring>
30 using namespace std;
31 using namespace GMap3d;
32 //******************************************************************************
33 CParameterNormalVector::CParameterNormalVector(int ANbRef) :
34  CParameter(ANbRef)
35 {
36  reinit();
37 }
38 //******************************************************************************
41  CParameter (AParam),
42  FAll (AParam.FAll),
43  FLWNormalVector(AParam.FLWNormalVector),
44  FLGNormalVector(AParam.FLGNormalVector)
45 {
47 }
48 //******************************************************************************
50 {}
51 //******************************************************************************
53 { return new CParameterNormalVector(*this); }
54 //******************************************************************************
55 void CParameterNormalVector::save(ostream& AStream)
56 { AStream<<(*this); }
57 //------------------------------------------------------------------------------
58 void CParameterNormalVector::load(istream& AStream)
59 { AStream>>(*this); }
60 //------------------------------------------------------------------------------
62 {
64  FLWNormalVector = DEFAULT_NORMAL_VECTOR_LINE_WIDTH;
65  FLGNormalVector = DEFAULT_NORMAL_VECTOR_LENGTH;
69 
71 }
72 //******************************************************************************
73 namespace GMap3d
74 {
75 //------------------------------------------------------------------------------
76 ostream& operator<<(ostream& AStream, const CParameterNormalVector & AParameter)
77 {
78  AStream<<"CParameterNormalVector:"<<endl;
79 
80  AStream<<" DrawAll: "<<AParameter.FAll<<endl;
81 
82  AStream<<" LineWidth: "<<AParameter.FLWNormalVector<<endl;
83 
84  AStream<<" Length: "<<AParameter.FLGNormalVector<<endl;
85 
86  AStream<<" Color: "<<AParameter.FCLNormalVector[0]<<" "
87  <<AParameter.FCLNormalVector[1]<<" "<<AParameter.FCLNormalVector[2]<<endl;
88 
89  AStream<<endl;
90 
91  return AStream;
92 }
93 //------------------------------------------------------------------------------
94 istream& operator>>(istream& AStream, CParameterNormalVector & AParameter)
95 {
96  char tmp[256];
97 
98  AStream>>tmp; assert ( !strcmp(tmp, "CParameterNormalVector:") );
99 
100  AStream>>tmp; assert ( !strcmp(tmp, "DrawAll:") );
101  AStream>>AParameter.FAll;
102 
103  AStream>>tmp; assert ( !strcmp(tmp, "LineWidth:") );
104  AStream>>AParameter.FLWNormalVector;
105 
106  AStream>>tmp; assert ( !strcmp(tmp, "Length:") );
107  AStream>>AParameter.FLGNormalVector;
108 
109  AStream>>tmp; assert ( !strcmp(tmp, "Color:") );
110  AStream>>AParameter.FCLNormalVector[0]>>AParameter.FCLNormalVector[1]
111  >>AParameter.FCLNormalVector[2];
112 
113  AParameter.putAllNeedToUpdate();
114 
115  return AStream;
116 }
117 //------------------------------------------------------------------------------
118 } // namespace GMap3d
119 //******************************************************************************
121 { return FAll; }
122 //******************************************************************************
124 {
125  if (FAll != AShow)
126  {
128  FAll = AShow;
129  }
130 }
131 //******************************************************************************
133 { return FLWNormalVector; }
135 {
136  if ( FLWNormalVector!=AValue )
137  {
139  FLWNormalVector= AValue;
140  }
141 }
142 //******************************************************************************
144 { return FLGNormalVector; }
146 {
147  if ( FLGNormalVector!=AValue )
148  {
150  FLGNormalVector= AValue;
151  }
152 }
153 //******************************************************************************
155 {
156  assert(0<=AIndice && AIndice<=2);
157  return FCLNormalVector[AIndice];
158 }
159 void CParameterNormalVector::setCLNormalVector(int AIndice, float AValue)
160 {
161  assert(0<=AIndice && AIndice<=2);
162  if ( FCLNormalVector[AIndice]!=AValue )
163  {
165  FCLNormalVector[AIndice]= AValue;
166  }
167 }
169 { return FCLNormalVector; }
170 void CParameterNormalVector::setCLNormalVector(float AValue0, float AValue1,
171  float AValue2)
172 {
173  if ( FCLNormalVector[0]!=AValue0 ||
174  FCLNormalVector[1]!=AValue1 ||
175  FCLNormalVector[2]!=AValue2 )
176  {
178  FCLNormalVector[0]= AValue0;
179  FCLNormalVector[1]= AValue1;
180  FCLNormalVector[2]= AValue2;
181  }
182 }
184 { setCLNormalVector(ATab[0],ATab[1],ATab[2]); }
185 //******************************************************************************
187 { return PARAMETER_NORMAL_VECTOR; }
188 //******************************************************************************