Moka controlers
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
parameter-object-scale.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 "transformation-matrix.hh"
28 #include "geometry.hh"
29 using namespace std;
30 using namespace GMap3d;
31 //******************************************************************************
32 CParameterObjectScale::CParameterObjectScale(int ANbRef) :
33  CParameter (ANbRef),
34  FScaleType (SCALE_POINT),
35  FCenter (ORIGIN),
36  FVector (OZ),
37  FCoef (CVertex(1.0,1.0,1.0)),
38  FPonderation(false),
39  FIsoScale (true)
40 {}
41 //******************************************************************************
44  CParameter (AParam),
45  FScaleType (AParam.FScaleType),
46  FCenter (AParam.FCenter),
47  FVector (AParam.FVector),
48  FCoef (AParam.FCoef),
49  FPonderation(AParam.FPonderation),
50  FIsoScale (AParam.FIsoScale)
51 {}
52 //******************************************************************************
54 {
55 }
56 //******************************************************************************
58 { return new CParameterObjectScale(*this); }
59 //******************************************************************************
60 void CParameterObjectScale::load(istream& /*AStream*/)
61 {}
62 //------------------------------------------------------------------------------
63 void CParameterObjectScale::save(ostream& /*AStream*/)
64 {}
65 //------------------------------------------------------------------------------
67 {}
68 //******************************************************************************
70 {
72 }
73 //******************************************************************************
75 {
76  if (FScaleType != AScaleType)
77  {
79  FScaleType = AScaleType;
80 
81  if ( AScaleType!=SCALE_POINT)
82  setIsoScale(true);
83  }
84 }
85 
87 {
88  return FScaleType;
89 }
90 //******************************************************************************
91 void CParameterObjectScale::setCenter(const CVertex & ACenter)
92 {
93  if (FCenter != ACenter)
94  {
96  FCenter = ACenter;
97  }
98 }
99 
101 {
102  return FCenter;
103 }
104 //******************************************************************************
105 void CParameterObjectScale::setVector(const CVertex & AVector)
106 {
107  if (FVector != AVector && !AVector.isNull())
108  {
110  FVector = AVector;
111  }
112 }
113 
115 {
116  return FVector;
117 }
118 //******************************************************************************
120 { return FIsoScale; }
121 
123 {
124  FIsoScale = AValue;
125  if ( AValue )
126  setIsoCoef(getCoef(0));
127 
128 }
129 //******************************************************************************
131 { FCoef.setXYZ(AValue,AValue,AValue); }
132 
134 {
135  assert( FCoef.getX()==FCoef.getY() && FCoef.getY()==FCoef.getZ() );
136 
137  return FCoef.getX();
138 }
139 
140 void CParameterObjectScale::setCoef(const CVertex & AValue)
141 { FCoef = AValue; }
142 
144 { return FCoef; }
145 
146 void CParameterObjectScale::setCoef(int ADim, float AValue)
147 {
148  switch (ADim)
149  {
150  case 0: setCoef(CVertex(AValue, getCoef(1), getCoef(2))); break;
151  case 1: setCoef(CVertex(getCoef(0), AValue, getCoef(2))); break;
152  case 2: setCoef(CVertex(getCoef(0), getCoef(1), AValue)); break;
153  }
154 }
155 
156 float CParameterObjectScale::getCoef(int ADim) const
157 {
158  assert(0 <= ADim && ADim < 3);
159  return FCoef.getCoord(ADim);
160 }
161 //******************************************************************************
163 {
164  if (FPonderation != AActive)
165  {
167  FPonderation = AActive;
168  }
169 }
170 
172 {
173  return FPonderation;
174 }
175 //******************************************************************************