00001 00002 // exotkParameter_Real.cxx 00004 // Copyright (C) 2001 Stephane Routelous 00005 // 00006 // This file is part of exoTK. 00007 // 00008 // exoTK is free software; you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation; either version 2 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // exoTK is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with exoTK; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 00029 #include <exotkParameter_Real.hxx> 00030 #include <stdlib.h> 00031 #include <stdio.h> 00032 #ifndef _Standard_TypeDef_HeaderFile 00033 #include <Standard_Real.hxx> 00034 #endif 00035 #ifndef _exotkUtils_HeaderFile 00036 #include <exotkUtils.hxx> 00037 #endif 00038 00039 // 00040 IMPLEMENT_STANDARD_HANDLE(exotkParameter_Real,exotkParameter_Root) 00041 IMPLEMENT_STANDARD_RTTI(exotkParameter_Real,exotkParameter_Root) 00042 // 00043 // Foreach ancestors, we add a IMPLEMENT_STANDARD_SUPERTYPE and 00044 // a IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY macro. 00045 // We must respect the order: from the direct ancestor class 00046 // to the base class. 00047 // 00048 00049 IMPLEMENT_STANDARD_TYPE(exotkParameter_Real) 00050 IMPLEMENT_STANDARD_SUPERTYPE(exotkParameter_Root) 00051 IMPLEMENT_STANDARD_SUPERTYPE(MMgt_TShared) 00052 IMPLEMENT_STANDARD_SUPERTYPE(Standard_Transient) 00053 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY() 00054 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(exotkParameter_Root) 00055 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(MMgt_TShared) 00056 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(Standard_Transient) 00057 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_END() 00058 IMPLEMENT_STANDARD_TYPE_END(exotkParameter_Real) 00059 00060 00061 //================================================================================== 00062 // Function name : exotkParameter_Real::exotkParameter_Real 00063 //================================================================================== 00064 // Written by : Stephane Routelous - 08/03/2001 01:02:58 00065 // Description : 00066 // Return type : 00067 //================================================================================== 00068 // Argument : const Standard_Real aValue 00069 exotkParameter_Real::exotkParameter_Real(const Standard_Real aValue) 00070 :myValue(aValue) 00071 { 00072 myType = exotkParameter_Type_Real; 00073 myLowerRealLimit = RealFirst(); 00074 myUpperRealLimit = RealLast(); 00075 char* S = new char[1024]; 00076 sprintf(S,"%e",myLowerRealLimit); 00077 myLowerLimit = TCollection_AsciiString(S); 00078 sprintf(S,"%e",myUpperRealLimit); 00079 myUpperLimit = TCollection_AsciiString(S); 00080 delete S; 00081 } 00082 00083 00084 //================================================================================== 00085 // Function name : exotkParameter_Real::~exotkParameter_Real 00086 //================================================================================== 00087 // Written by : Stephane Routelous - 08/03/2001 01:03:01 00088 // Description : 00089 // Return type : 00090 //================================================================================== 00091 exotkParameter_Real::~exotkParameter_Real() 00092 { 00093 00094 } 00095 00096 void exotkParameter_Real::DeepCopy(const Handle_exotkParameter_Root &aParameterToCopy) 00097 { 00098 exotkParameter_Root::DeepCopy(aParameterToCopy); 00099 if ( aParameterToCopy->IsKind(STANDARD_TYPE(exotkParameter_Real)) ) 00100 { 00101 Handle_exotkParameter_Real theRealToCopy = Handle_exotkParameter_Real::DownCast(aParameterToCopy); 00102 myValue = theRealToCopy->Value(); 00103 theRealToCopy->RealLimits(myLowerRealLimit,myUpperRealLimit); 00104 } 00105 } 00106 00107 //================================================================================== 00108 // Function name : exotkParameter_Real::SetValue 00109 //================================================================================== 00110 // Written by : Stephane Routelous - 08/03/2001 01:03:02 00111 // Description : 00112 // Return type : Standard_Boolean 00113 //================================================================================== 00114 // Argument : const Standard_Real aValue 00115 Standard_Boolean exotkParameter_Real::SetValue(const Standard_Real aValue) 00116 { 00117 if ( (aValue >= myLowerRealLimit ) && ( aValue <= myUpperRealLimit) ) 00118 { 00119 myValue = aValue; 00120 return Standard_True; 00121 } 00122 else 00123 return Standard_False; 00124 } 00125 00126 //================================================================================== 00127 // Function name : exotkParameter_Real::Value 00128 //================================================================================== 00129 // Written by : Stephane Routelous - 08/03/2001 01:03:05 00130 // Description : 00131 // Return type : Standard_Real 00132 //================================================================================== 00133 Standard_Real exotkParameter_Real::Value() const 00134 { 00135 return myValue; 00136 } 00137 00138 //================================================================================== 00139 // Function name : exotkParameter_Real::SetParameterAsString 00140 //================================================================================== 00141 // Written by : Stephane Routelous - 08/03/2001 01:03:06 00142 // Description : 00143 // Return type : Standard_Boolean 00144 //================================================================================== 00145 // Argument : const TCollection_AsciiString& aParameter 00146 Standard_Boolean exotkParameter_Real::SetParameterAsString(const TCollection_AsciiString& aParameter) 00147 { 00148 /* 00149 return SetValue( atof(aParameter.ToCString()) ); 00150 */ 00151 Standard_Real theRealValue; 00152 if (!exotkUtils::AsciiStringToReal(aParameter,theRealValue) ) 00153 { 00154 return Standard_False; 00155 } 00156 else 00157 { 00158 return SetValue(theRealValue); 00159 } 00160 00161 00162 } 00163 00164 //================================================================================== 00165 // Function name : exotkParameter_Real::ParameterAsString 00166 //================================================================================== 00167 // Written by : Stephane Routelous - 08/03/2001 01:03:09 00168 // Description : 00169 // Return type : TCollection_AsciiString 00170 //================================================================================== 00171 TCollection_AsciiString exotkParameter_Real::ParameterAsString() const 00172 { 00173 return TCollection_AsciiString(myValue); 00174 } 00175 00176 //================================================================================== 00177 // Function name : exotkParameter_Real::SetUpperRealLimit 00178 //================================================================================== 00179 // Written by : Stephane Routelous - 08/03/2001 01:03:10 00180 // Description : 00181 // Return type : void 00182 //================================================================================== 00183 // Argument : const Standard_Real aValue 00184 void exotkParameter_Real::SetUpperRealLimit(const Standard_Real aValue) 00185 { 00186 myUpperRealLimit = aValue; 00187 myUpperLimit = TCollection_AsciiString(myUpperRealLimit); 00188 } 00189 00190 //================================================================================== 00191 // Function name : exotkParameter_Real::SetLowerRealLimit 00192 //================================================================================== 00193 // Written by : Stephane Routelous - 08/03/2001 01:03:12 00194 // Description : 00195 // Return type : void 00196 //================================================================================== 00197 // Argument : const Standard_Real aValue 00198 void exotkParameter_Real::SetLowerRealLimit(const Standard_Real aValue) 00199 { 00200 myLowerRealLimit = aValue; 00201 myLowerLimit = TCollection_AsciiString(myLowerRealLimit); 00202 } 00203 00204 //================================================================================== 00205 // Function name : exotkParameter_Real::RealLimits 00206 //================================================================================== 00207 // Written by : Stephane Routelous - 08/03/2001 01:03:16 00208 // Description : 00209 // Return type : void 00210 //================================================================================== 00211 // Argument : Standard_Real& aLowerRealLimit 00212 // Argument : Standard_Real& anUpperRealLimit 00213 void exotkParameter_Real::RealLimits(Standard_Real& aLowerRealLimit,Standard_Real& anUpperRealLimit) 00214 { 00215 aLowerRealLimit = myLowerRealLimit; 00216 anUpperRealLimit = myUpperRealLimit; 00217 }
1.2.12 written by Dimitri van Heesch,
© 1997-2001