Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
parameter-drawing.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-drawing.hh"
28 #include <cassert>
29 #include <cstring>
30 using namespace std;
31 //******************************************************************************
33  CParameter(ANbRef)
34 {
35  reinit();
36 }
37 //******************************************************************************
39  CParameter (AParam),
40  FDisplayLight(AParam.FDisplayLight)
41 {
42  setCLLight (AParam.getCLLight());
44 }
45 //******************************************************************************
47 {}
48 //******************************************************************************
50 { return new CParameterDrawing(*this); }
51 //******************************************************************************
52 void CParameterDrawing::save(ostream& AStream)
53 { AStream<<(*this); }
54 //------------------------------------------------------------------------------
55 void CParameterDrawing::load(istream& AStream)
56 { AStream>>(*this); }
57 //------------------------------------------------------------------------------
59 {
63 
67 
68  FDisplayLight = DEFAULT_DRAWING_DISPLAY_LIGHT;
69 
71 }
72 //******************************************************************************
73 ostream& operator<<(ostream& AStream, const CParameterDrawing & AParameter)
74 {
75  AStream<<"CParameterDrawing:"<<endl;
76 
77  AStream<<" LightColor: "<<AParameter.FCLLight[0]<<" "
78  <<AParameter.FCLLight[1]<<" "<<AParameter.FCLLight[2]<<endl;
79 
80  AStream<<" BackgroundColor: "<<AParameter.FCLBackground[0]<<" "
81  <<AParameter.FCLBackground[1]<<" "<<AParameter.FCLBackground[2]<<endl;
82 
83  AStream<<" DisplayLight: "<<AParameter.FDisplayLight<<endl;
84  AStream<<endl;
85 
86  return AStream;
87 }
88 //------------------------------------------------------------------------------
89 istream& operator>>(istream& AStream, CParameterDrawing & AParameter)
90 {
91  char tmp[256];
92 
93  AStream>>tmp; assert ( !strcmp(tmp, "CParameterDrawing:") );
94 
95  AStream>>tmp; assert ( !strcmp(tmp, "LightColor:") );
96  AStream>>AParameter.FCLLight[0]>>AParameter.FCLLight[1]
97  >>AParameter.FCLLight[2];
98 
99  AStream>>tmp; assert ( !strcmp(tmp, "BackgroundColor:") );
100  AStream>>AParameter.FCLBackground[0]>>AParameter.FCLBackground[1]
101  >>AParameter.FCLBackground[2];
102 
103  AStream>>tmp; assert ( !strcmp(tmp, "DisplayLight:") );
104  AStream>>AParameter.FDisplayLight;
105 
106  AParameter.putAllNeedToUpdate();
107 
108  return AStream;
109 }
110 //******************************************************************************
111 float CParameterDrawing::getCLLight(int AIndice) const
112 {
113  assert(0<=AIndice && AIndice<=2);
114  return FCLLight[AIndice];
115 }
116 void CParameterDrawing::setCLLight(int AIndice, float AValue)
117 {
118  assert(0<=AIndice && AIndice<=2);
119  FCLLight[AIndice]= AValue;
120 }
121 const float * CParameterDrawing::getCLLight() const
122 { return FCLLight; }
123 void CParameterDrawing::setCLLight(float AValue0, float AValue1, float AValue2)
124 {
125  FCLLight[0]= AValue0;
126  FCLLight[1]= AValue1;
127  FCLLight[2]= AValue2;
128 }
129 void CParameterDrawing::setCLLight(const float ATab[3])
130 { setCLLight(ATab[0],ATab[1],ATab[2]); }
131 
132 //******************************************************************************
133 float CParameterDrawing::getCLBackground(int AIndice) const
134 {
135  assert(0<=AIndice && AIndice<=2);
136  return FCLBackground[AIndice];
137 }
138 void CParameterDrawing::setCLBackground(int AIndice, float AValue)
139 {
140  assert(0<=AIndice && AIndice<=2);
141  FCLBackground[AIndice]= AValue;
142 }
144 { return FCLBackground; }
145 void CParameterDrawing::setCLBackground(float AValue0, float AValue1, float AValue2)
146 {
147  FCLBackground[0]= AValue0;
148  FCLBackground[1]= AValue1;
149  FCLBackground[2]= AValue2;
150 }
151 void CParameterDrawing::setCLBackground(const float ATab[3])
152 { setCLBackground(ATab[0],ATab[1],ATab[2]); }
153 
154 //******************************************************************************
156 { return FDisplayLight; }
157 //******************************************************************************
159 {
160  FDisplayLight= AValue;
161 }
162 //******************************************************************************
164 {
165  FDisplayLight= !FDisplayLight;
166 }
167 //******************************************************************************
169 { return PARAMETER_DRAWING; }
170 //******************************************************************************