Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
parameter-aimed-point.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-aimed-point.hh"
28 #include <cassert>
29 #include <cstring>
30 using namespace std;
31 //******************************************************************************
33  CParameter(ANbRef)
34 {
35  reinit();
36 }
37 //******************************************************************************
39  CParameter (AParam),
40  FLWAimedPoint(AParam.FLWAimedPoint),
41  FLGAimedPoint(AParam.FLGAimedPoint)
42 {
44 }
45 //******************************************************************************
47 {}
48 //******************************************************************************
50 { return new CParameterAimedPoint(*this); }
51 //******************************************************************************
52 void CParameterAimedPoint::save(ostream& AStream)
53 { AStream<<(*this); }
54 //------------------------------------------------------------------------------
55 void CParameterAimedPoint::load(istream& AStream)
56 { AStream>>(*this); }
57 //------------------------------------------------------------------------------
59 {
60  FLWAimedPoint = DEFAULT_AIMED_POINT_LINE_WIDTH;
61  FLGAimedPoint = DEFAULT_AIMED_POINT_LENGTH;
64 
66 }
67 //******************************************************************************
68 ostream& operator<<(ostream& AStream,
69  const CParameterAimedPoint & AParameter)
70 {
71  AStream<<"CParameterAimedPoint:"<<endl;
72 
73  AStream<<" LineWidth: "<<AParameter.FLWAimedPoint<<endl;
74 
75  AStream<<" Length: "<<AParameter.FLGAimedPoint<<endl;
76 
77  AStream<<" Color: "<<AParameter.FCLAimedPoint[0]<<" "
78  <<AParameter.FCLAimedPoint[1]<<" "<<AParameter.FCLAimedPoint[2]<<endl;
79 
80  AStream<<endl;
81 
82  return AStream;
83 }
84 //------------------------------------------------------------------------------
85 istream& operator>>(istream& AStream,
86  CParameterAimedPoint & AParameter)
87 {
88  char tmp[256];
89 
90  AStream>>tmp; assert ( !strcmp(tmp, "CParameterAimedPoint:") );
91 
92  AStream>>tmp; assert ( !strcmp(tmp, "LineWidth:") );
93  AStream>>AParameter.FLWAimedPoint;
94 
95  AStream>>tmp; assert ( !strcmp(tmp, "Length:") );
96  AStream>>AParameter.FLGAimedPoint;
97 
98  AStream>>tmp; assert ( !strcmp(tmp, "Color:") );
99  AStream>>AParameter.FCLAimedPoint[0]>>AParameter.FCLAimedPoint[1]
100  >>AParameter.FCLAimedPoint[2];
101 
102  AParameter.putAllNeedToUpdate();
103 
104  return AStream;
105 }
106 //******************************************************************************
108 { return FLWAimedPoint; }
110 {
111  if ( FLWAimedPoint!=AValue )
112  {
114  FLWAimedPoint= AValue;
115  }
116 }
117 //******************************************************************************
119 { return FLGAimedPoint; }
121 {
122  if ( FLGAimedPoint!=AValue )
123  {
125  FLGAimedPoint= AValue;
126  }
127 }
128 //******************************************************************************
130 {
131  assert(0<=AIndice && AIndice<=2);
132  return FCLAimedPoint[AIndice];
133 }
134 void CParameterAimedPoint::setCLAimedPoint(int AIndice, float AValue)
135 {
136  assert(0<=AIndice && AIndice<=2);
137  if ( FCLAimedPoint[AIndice]!=AValue )
138  {
140  FCLAimedPoint[AIndice]= AValue;
141  }
142 }
144 { return FCLAimedPoint; }
145 void CParameterAimedPoint::setCLAimedPoint(float AValue0, float AValue1, float AValue2)
146 {
147  if ( FCLAimedPoint[0]!=AValue0 ||
148  FCLAimedPoint[1]!=AValue1 ||
149  FCLAimedPoint[2]!=AValue2 )
150  {
152  FCLAimedPoint[0]= AValue0;
153  FCLAimedPoint[1]= AValue1;
154  FCLAimedPoint[2]= AValue2;
155  }
156 }
157 void CParameterAimedPoint::setCLAimedPoint(const float ATab[3])
158 { setCLAimedPoint(ATab[0],ATab[1],ATab[2]); }
159 //******************************************************************************
161 { return PARAMETER_AIMED_POINT; }
162 //******************************************************************************