X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_StricklerTable.cxx;h=1c51cf1e49f3849312becdd6ba28145b8894bb8b;hb=3ad1721baafb8864b968fe6ef6ab68ecf49a669e;hp=212f9543f51193b9919010ef3f4dc26ff63a3138;hpb=efaf298dce499879bcd94ea126314badda74f3b5;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_StricklerTable.cxx b/src/HYDROData/HYDROData_StricklerTable.cxx index 212f9543..1c51cf1e 100644 --- a/src/HYDROData/HYDROData_StricklerTable.cxx +++ b/src/HYDROData/HYDROData_StricklerTable.cxx @@ -18,6 +18,7 @@ #include #include +#include #include @@ -37,10 +38,10 @@ #include #include -IMPLEMENT_STANDARD_HANDLE( HYDROData_StricklerTable, HYDROData_Entity ) IMPLEMENT_STANDARD_RTTIEXT( HYDROData_StricklerTable, HYDROData_Entity ) HYDROData_StricklerTable::HYDROData_StricklerTable() +: HYDROData_Entity( Geom_No ) { } @@ -201,24 +202,36 @@ void HYDROData_StricklerTable::Clear() aMap->ChangeReals( TDataStd_DataMapOfStringReal() ); } -QStringList HYDROData_StricklerTable::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const +QStringList HYDROData_StricklerTable::DumpToPython( const QString& thePyScriptPath, + MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); QString aPyName = GetObjPyName(); + QString anAttrName = GetAttrName(); + aResList << QString( "%1.SetAttrName( \"%2\" )" ).arg( aPyName ).arg( anAttrName ); + aResList << QString( "" ); Handle(TDataStd_NamedData) aMap = Map(); if( !aMap.IsNull() ) { for( TDataStd_DataMapIteratorOfDataMapOfStringReal it( aMap->GetRealsContainer() ); it.More(); it.Next() ) { - TCollection_ExtendedString aType = it.Key(); + QString aType = HYDROData_Tool::toQString( it.Key() ); Standard_Real aValue = it.Value(); - aResList << QString( "%1.Set( \"%2\", %3 );" ).arg( aPyName ).arg( QString( (QChar*)aType.ToExtString(), aType.Length() ) ).arg( aValue ); + aResList << QString( "%1.Set( u\"%2\", %3 )" ).arg( aPyName ).arg( aType ).arg( aValue ); + + QString anAttrValue = GetAttrValue( aType ); + aResList << QString( "%1.SetAttrValue( u\"%2\", \"%3\" )" ).arg( aPyName ).arg( aType ).arg( anAttrValue ); + + QColor aColor = GetColor( aType ); + aResList << QString( "%1.SetColor( u\"%2\", QColor( %3, %4, %5 ) )" ). + arg( aPyName ).arg( aType ).arg( aColor.red() ).arg( aColor.green() ).arg( aColor.blue() ); + aResList << QString(); } } aResList << QString( "" ); - aResList << QString( "%1.Update();" ).arg( aPyName ); + aResList << QString( "%1.Update()" ).arg( aPyName ); return aResList; } @@ -241,9 +254,22 @@ QString HYDROData_StricklerTable::GetAttrName() const } return QString();} -void HYDROData_StricklerTable::SetAttrName( const QString& theAttrName ) const +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 @@ -265,6 +291,9 @@ void HYDROData_StricklerTable::SetAttrValue( const QString& theType, const QStri 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() ) @@ -303,4 +332,17 @@ void HYDROData_StricklerTable::SetColor( const QString& theType, const QColor& t 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 ); + } }