+ TDF_Label aLabel = myLab.FindChild( DataTag_Table );
+ Handle( TDataStd_NamedData ) aMap;
+ if( !aLabel.FindAttribute( TDataStd_NamedData::GetID(), aMap ) )
+ aMap = TDataStd_NamedData::Set( aLabel );
+ return aMap;
+}
+
+QString HYDROData_StricklerTable::GetAttrName() const
+{
+ Handle(TDataStd_AsciiString) aName;
+ if( myLab.FindChild( DataTag_AttrName ).FindAttribute(TDataStd_AsciiString::GetID(), aName)) {
+ TCollection_AsciiString aStr(aName->Get());
+ return QString(aStr.ToCString());
+ }
+ return QString();}
+
+bool HYDROData_StricklerTable::SetAttrName( const QString& theAttrName ) const
+{
+ HYDROData_Iterator anIt( HYDROData_Document::Document( myLab ), KIND_STRICKLER_TABLE );
+ for( ; anIt.More(); anIt.Next() )
+ {
+ Handle( HYDROData_StricklerTable ) aTable =
+ Handle( HYDROData_StricklerTable )::DownCast( anIt.Current() );
+ if( aTable->Label()==myLab )
+ continue;
+
+ if( theAttrName==aTable->GetAttrName() )
+ return false;
+ }
+
+ TDataStd_AsciiString::Set( myLab.FindChild( DataTag_AttrName ), HYDROData_Tool::toExtString( theAttrName ) );
+ return true;
+}
+
+QString HYDROData_StricklerTable::GetAttrValue( const QString& theType ) const
+{
+ Handle( TDataStd_NamedData ) aMap = Map();
+ TCollection_ExtendedString aType = HYDROData_Tool::toExtString( theType );
+ if( aMap->HasString( aType ) )
+ return HYDROData_Tool::toQString( aMap->GetString( aType ) );
+ else
+ return "";
+}
+
+void HYDROData_StricklerTable::SetAttrValue( const QString& theType, const QString& theAttrValue ) const
+{
+ Handle( TDataStd_NamedData ) aMap = Map();
+ TCollection_ExtendedString aType = HYDROData_Tool::toExtString( theType );
+ aMap->SetString( aType, HYDROData_Tool::toExtString( theAttrValue ) );
+}
+
+QString HYDROData_StricklerTable::GetType( const QString& theAttrValue ) const
+{
+ if( theAttrValue.isEmpty() )
+ return "";
+
+ Handle( TDataStd_NamedData ) aMap = Map();
+ TCollection_ExtendedString anAttrValue = HYDROData_Tool::toExtString( theAttrValue );
+ for( TDataStd_DataMapIteratorOfDataMapOfStringString it( aMap->GetStringsContainer() ); it.More(); it.Next() )
+ {
+ if( it.Value() == anAttrValue )
+ {
+ QString aType = HYDROData_Tool::toQString( it.Key() );
+ return aType;
+ }
+ }
+ return "";
+}
+
+QColor HYDROData_StricklerTable::GetColor( const QString& theType ) const
+{
+ Handle( TDataStd_NamedData ) aMap = Map();
+ TCollection_ExtendedString aType = HYDROData_Tool::toExtString( theType );
+ if( aMap->HasInteger( aType ) )
+ {
+ int aColorInt = aMap->GetInteger( aType );
+ int b = aColorInt % 256;
+ int g = (aColorInt>>8) % 256;
+ int r = (aColorInt>>16) % 256;
+ return QColor( r, g, b );
+ }
+ else
+ return QColor();
+}
+
+void HYDROData_StricklerTable::SetColor( const QString& theType, const QColor& theColor ) const
+{
+ Handle( TDataStd_NamedData ) aMap = Map();
+ TCollection_ExtendedString aType = HYDROData_Tool::toExtString( theType );
+ int r = theColor.red();
+ int g = theColor.green();
+ int b = theColor.blue();
+ int aColorInt = ( r<<16 ) + ( g<<8 ) + b;
+ aMap->SetInteger( aType, aColorInt );
+
+ // synchronize the color for the same type in other maps
+ HYDROData_Iterator anIt( HYDROData_Document::Document( myLab ), KIND_STRICKLER_TABLE );
+ for( ; anIt.More(); anIt.Next() )
+ {
+ Handle( HYDROData_StricklerTable ) aTable =
+ Handle( HYDROData_StricklerTable )::DownCast( anIt.Current() );
+ if( aTable->Label()==myLab )
+ continue;
+
+ if( aTable->HasType( theType ) )
+ aTable->Map()->SetInteger( aType, aColorInt );
+ }