Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
parameter-vertex.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-vertex.hh"
28 #include <cassert>
29 #include <cstring>
30 using namespace std;
31 using namespace GMap3d;
32 //******************************************************************************
33 CParameterVertex::CParameterVertex(int ANbRef) :
34  CParameter(ANbRef)
35 {
36  reinit();
37 }
38 //******************************************************************************
40  CParameter(AParam),
41  FSVertex (AParam.FSVertex)
42 {
43  setCLVertex(AParam.getCLVertex());
44 }
45 //******************************************************************************
47 {}
48 //******************************************************************************
50 { return new CParameterVertex(*this); }
51 //******************************************************************************
52 void CParameterVertex::save(ostream& AStream)
53 { AStream<<(*this); }
54 //------------------------------------------------------------------------------
55 void CParameterVertex::load(istream& AStream)
56 { AStream>>(*this); }
57 //------------------------------------------------------------------------------
59 {
60  FSVertex = DEFAULT_VERTEX_SIZE;
62 
64 }
65 //******************************************************************************
66 namespace GMap3d
67 {
68 //------------------------------------------------------------------------------
69 ostream& operator<<(ostream& AStream, const CParameterVertex & AParameter)
70 {
71  AStream<<"CParameterVertex:"<<endl;
72 
73  AStream<<" Size: "<<AParameter.FSVertex<<endl;
74 
75  AStream<<" Color: "<<AParameter.FCLVertex[0]<<" "
76  <<AParameter.FCLVertex[1]<<" "<<AParameter.FCLVertex[2]<<endl;
77 
78  AStream<<endl;
79 
80  return AStream;
81 }
82 //------------------------------------------------------------------------------
83 istream& operator>>(istream& AStream, CParameterVertex & AParameter)
84 {
85  char tmp[256];
86 
87  AStream>>tmp; assert ( !strcmp(tmp, "CParameterVertex:") );
88 
89  AStream>>tmp; assert ( !strcmp(tmp, "Size:") );
90  AStream>>AParameter.FSVertex;
91 
92  AStream>>tmp; assert ( !strcmp(tmp, "Color:") );
93  AStream>>AParameter.FCLVertex[0]>>AParameter.FCLVertex[1]
94  >>AParameter.FCLVertex[2];
95 
96  AParameter.putAllNeedToUpdate();
97 
98  return AStream;
99 }
100 //------------------------------------------------------------------------------
101 } // namespace GMap3d
102 //******************************************************************************
104 { return FSVertex; }
106 {
107  if ( FSVertex!=AValue )
108  {
110  FSVertex= AValue;
111  }
112 }
113 //******************************************************************************
114 float CParameterVertex::getCLVertex(int AIndice) const
115 {
116  assert(0<=AIndice && AIndice<=2);
117  return FCLVertex[AIndice];
118 }
119 void CParameterVertex::setCLVertex(int AIndice, float AValue)
120 {
121  assert(0<=AIndice && AIndice<=2);
122  if ( FCLVertex[AIndice]!=AValue )
123  {
125  FCLVertex[AIndice]= AValue;
126  }
127 }
128 const float * CParameterVertex::getCLVertex() const
129 { return FCLVertex; }
130 void CParameterVertex::setCLVertex(float AValue0, float AValue1, float AValue2)
131 {
132  if ( FCLVertex[0]!=AValue0 ||
133  FCLVertex[1]!=AValue1 ||
134  FCLVertex[2]!=AValue2 )
135  {
137  FCLVertex[0]= AValue0;
138  FCLVertex[1]= AValue1;
139  FCLVertex[2]= AValue2;
140  }
141 }
142 void CParameterVertex::setCLVertex(const float ATab[3])
143 { setCLVertex(ATab[0],ATab[1],ATab[2]); }
144 //******************************************************************************
146 { return PARAMETER_VERTEX; }
147 //******************************************************************************