else
{
Standard_Real aValue = TCollection_AsciiString( aValueStr ).RealValue();
- Set( aStr, aValue );
+ Set( QString( (QChar*)aStr.ToExtString(), aStr.Length() ), aValue );
}
}
}
return aRes;
}
-double HYDROData_StricklerTable::Get( const TCollection_ExtendedString& theType, double theDefault ) const
+double HYDROData_StricklerTable::Get( const QString& theType, double theDefault ) const
{
Handle( TDataStd_NamedData ) aMap = Map();
- if( aMap->HasReal( theType ) )
- return aMap->GetReal( theType );
+ TCollection_ExtendedString aType = toExtString( theType );
+ if( aMap->HasReal( aType ) )
+ return aMap->GetReal( aType );
else
return theDefault;
}
-void HYDROData_StricklerTable::Set( const TCollection_ExtendedString& theType, double theCoefficient )
+void HYDROData_StricklerTable::Set( const QString& theType, double theCoefficient )
{
Handle(TDataStd_NamedData) aMap = Map();
- aMap->SetReal( theType, theCoefficient );
+ aMap->SetReal( toExtString( theType ), theCoefficient );
}
-TColStd_SequenceOfExtendedString HYDROData_StricklerTable::GetTypes() const
+void HYDROData_StricklerTable::GetCoefficientRange( double& theMin, double& theMax ) const
{
- TColStd_SequenceOfExtendedString aSeq;
+ theMin = 0;
+ theMax = 0;
+
+ Handle(TDataStd_NamedData) aMap = Map();
+ Standard_Boolean isFirst = Standard_True;
+ for ( TDataStd_DataMapIteratorOfDataMapOfStringReal it( aMap->GetRealsContainer() ); it.More(); it.Next() ) {
+ Standard_Real aValue = it.Value();
+ if ( theMin == 0 || aValue < theMin ) {
+ theMin = aValue;
+ }
+ if ( theMax == 0 || aValue > theMax ) {
+ theMax = aValue;
+ }
+ }
+}
+
+QStringList HYDROData_StricklerTable::GetTypes() const
+{
+ QStringList aSeq;
Handle(TDataStd_NamedData) aMap = Map();
if ( !aMap.IsNull() )
{
for ( TDataStd_DataMapIteratorOfDataMapOfStringReal it( aMap->GetRealsContainer() ); it.More(); it.Next() )
- aSeq.Append( it.Key() );
+ aSeq.append( toQString( it.Key() ) );
}
return aSeq;
}
+bool HYDROData_StricklerTable::HasType( const TCollection_ExtendedString& theType ) const
+{
+ Handle(TDataStd_NamedData) aMap = Map();
+
+ return !aMap.IsNull() && aMap->HasReal( theType );
+}
+
void HYDROData_StricklerTable::Clear()
{
Handle(TDataStd_NamedData) aMap = Map();
aMap = TDataStd_NamedData::Set( aLabel );
return aMap;
}
+
+TCollection_ExtendedString HYDROData_StricklerTable::toExtString( const QString& theStr ) const
+{
+ TCollection_ExtendedString aRes;
+ if( !theStr.isEmpty() )
+ {
+ Standard_ExtString extStr = new Standard_ExtCharacter[ ( theStr.length() + 1 ) * 2 ];
+ memcpy( (void*)extStr, theStr.unicode(), theStr.length() * 2 );
+ ((short*)extStr)[theStr.length()] = '\0';
+
+ aRes = TCollection_ExtendedString( extStr );
+ delete [] extStr;
+ }
+ return aRes;
+}
+
+QString HYDROData_StricklerTable::toQString( const TCollection_ExtendedString& theStr ) const
+{
+ return QString( (QChar*)theStr.ToExtString(), theStr.Length() );
+}