00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "controler-gmap-types.hh"
00026 #include "parameters-gmap-default-values.hh"
00027 #include "parameter-face.hh"
00028 #include <cassert>
00029 #include <cstring>
00030 using namespace std;
00031 using namespace GMap3d;
00032
00033 CParameterFace::CParameterFace(int ANbRef) :
00034 CParameter(ANbRef)
00035 {
00036 reinit();
00037 }
00038
00039 CParameterFace::CParameterFace(const CParameterFace & AParam) :
00040 CParameter (AParam),
00041 FBLFace (AParam.FBLFace),
00042 FRandomCLFace (AParam.FRandomCLFace),
00043 FRandomCLVolume (AParam.FRandomCLVolume),
00044 FRandomColorGeometry(AParam.FRandomColorGeometry)
00045
00046 {
00047 setCLFace(AParam.getCLFace());
00048 setBLFace(AParam.getBLFace());
00049 }
00050
00051 CParameterFace::~CParameterFace()
00052 {}
00053
00054 CParameter * CParameterFace::copy() const
00055 { return new CParameterFace(*this); }
00056
00057 void CParameterFace::save(ostream& AStream)
00058 { AStream<<(*this); }
00059
00060 void CParameterFace::load(istream& AStream)
00061 { AStream>>(*this); }
00062
00063 void CParameterFace::reinit()
00064 {
00065 setCLFace(DEFAULT_FACE_COLOR_0,DEFAULT_FACE_COLOR_1,DEFAULT_FACE_COLOR_2);
00066 FBLFace = DEFAULT_FACE_TRANSPARENCY;
00067 FRandomCLFace = DEFAULT_FACE_RANDOM_CL_FACE;
00068 FRandomCLVolume = DEFAULT_FACE_RANDOM_CL_VOLUME;
00069 FRandomColorGeometry = DEFAULT_FACE_RANDOM_GEOMETRY;
00070 putAllNeedToUpdate();
00071 }
00072
00073 namespace GMap3d
00074 {
00075
00076 ostream& operator<<(ostream& AStream, const CParameterFace & AParameter)
00077 {
00078 AStream<<"CParameterFace:"<<endl;
00079
00080 AStream<<" Color: "<<AParameter.FCLFace[0]<<" "
00081 <<AParameter.FCLFace[1]<<" "<<AParameter.FCLFace[2]<<endl;
00082
00083 AStream<<" Transparency: "<<AParameter.FBLFace<<endl;
00084
00085 AStream<<" RandomColorFace: "<<AParameter.FRandomCLFace<<endl;
00086 AStream<<" RandomColorVolume: "<<AParameter.FRandomCLVolume<<endl;
00087 AStream<<" RandomColorGeometry: "<<AParameter.FRandomColorGeometry<<endl;
00088
00089 AStream<<endl;
00090
00091 return AStream;
00092 }
00093
00094 istream& operator>>(istream& AStream, CParameterFace & AParameter)
00095 {
00096 char tmp[256];
00097
00098 AStream>>tmp; assert ( !strcmp(tmp, "CParameterFace:") );
00099
00100 AStream>>tmp; assert ( !strcmp(tmp, "Color:") );
00101 AStream>>AParameter.FCLFace[0]>>AParameter.FCLFace[1]
00102 >>AParameter.FCLFace[2];
00103
00104 AStream>>tmp; assert ( !strcmp(tmp, "Transparency:") );
00105 AStream>>AParameter.FBLFace;
00106
00107 AStream>>tmp; assert ( !strcmp(tmp, "RandomColorFace:") );
00108 AStream>>AParameter.FRandomCLFace;
00109
00110 AStream>>tmp; assert ( !strcmp(tmp, "RandomColorVolume:") );
00111 AStream>>AParameter.FRandomCLVolume;
00112
00113 AStream>>tmp; assert ( !strcmp(tmp, "RandomColorGeometry:") );
00114 AStream>>AParameter.FRandomColorGeometry;
00115
00116 AParameter.putAllNeedToUpdate();
00117
00118 return AStream;
00119 }
00120
00121 }
00122
00123 float CParameterFace::getCLFace(int AIndice) const
00124 {
00125 assert(0<=AIndice && AIndice<=2);
00126 return FCLFace[AIndice];
00127 }
00128 void CParameterFace::setCLFace(int AIndice, float AValue)
00129 {
00130 assert(0<=AIndice && AIndice<=2);
00131 if ( FCLFace[AIndice]!=AValue )
00132 {
00133 putAllNeedToUpdate();
00134 FCLFace[AIndice]= AValue;
00135 }
00136 }
00137 const float * CParameterFace::getCLFace() const
00138 { return FCLFace; }
00139 void CParameterFace::setCLFace(float AValue0, float AValue1, float AValue2)
00140 {
00141 if ( FCLFace[0]!=AValue0 ||
00142 FCLFace[1]!=AValue1 ||
00143 FCLFace[2]!=AValue2 )
00144 {
00145 putAllNeedToUpdate();
00146 FCLFace[0]= AValue0;
00147 FCLFace[1]= AValue1;
00148 FCLFace[2]= AValue2;
00149 }
00150 }
00151 void CParameterFace::setCLFace(const float ATab[3])
00152 { setCLFace(ATab[0],ATab[1],ATab[2]); }
00153
00154 float CParameterFace::getBLFace() const
00155 { return FBLFace; }
00156 void CParameterFace::setBLFace(float AValue)
00157 {
00158 if ( FBLFace!=AValue )
00159 {
00160 putAllNeedToUpdate();
00161 FBLFace = AValue;
00162 }
00163 }
00164
00165 bool CParameterFace::getRandomCLFace() const
00166 { return FRandomCLFace; }
00167
00168 void CParameterFace::setRandomCLFace(bool AValue)
00169 {
00170 if ( FRandomCLFace!=AValue )
00171 {
00172 putAllNeedToUpdate();
00173 FRandomCLFace=AValue;
00174 }
00175 }
00176
00177 bool CParameterFace::getRandomCLVolume() const
00178 { return FRandomCLVolume; }
00179
00180 void CParameterFace::setRandomCLVolume(bool AValue)
00181 {
00182 if ( FRandomCLVolume!=AValue )
00183 {
00184 putAllNeedToUpdate();
00185 FRandomCLVolume = AValue;
00186 }
00187 }
00188
00189 bool CParameterFace::getRandomColorGeometry() const
00190 { return FRandomColorGeometry; }
00191
00192 void CParameterFace::setRandomColorGeometry(bool AValue)
00193 {
00194 if ( FRandomColorGeometry!=AValue )
00195 {
00196 putAllNeedToUpdate();
00197 FRandomColorGeometry = AValue;
00198 }
00199 }
00200
00201 int CParameterFace::getType() const
00202 { return PARAMETER_FACE; }
00203