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( "" );
bool Export( const QString& theFileName );
double Get( const QString& theType, double theDefault ) const;
- void Set( const QString& theType, double theCoefficient );
+ void Set( const QString& theType, double theCoefficient );
+
+ QString GetAttrName() const;
+ bool SetAttrName( const QString& ) const;
+
+ QString GetAttrValue( const QString& theType ) const;
+ void SetAttrValue( const QString& theType, const QString& theAttrValue ) const;
+
+ QColor GetColor( const QString& theType ) const;
+ void SetColor( const QString& theType, const QColor& theColor ) const;
QStringList GetTypes() const;
context()->MoveTo( theViewX, theViewY, aView );
context()->Select();
}
+
+bool TestViewer::areScriptsEqual( const QString& theBaseName )
+{
+ QString anExpectedRefFilePath = qgetenv( "HYDRO_REFERENCE_DATA" );
+ anExpectedRefFilePath += "/" + theBaseName;
+
+ QString anActualFilePath = QDir::tempPath() + "/" + theBaseName;
+
+ QFile anExpected( anExpectedRefFilePath );
+ QFile anActual( anActualFilePath );
+ if( !anExpected.open( QFile::ReadOnly | QFile::Text ) ||
+ !anActual.open ( QFile::ReadOnly | QFile::Text ) )
+ return false;
+
+ const int aLinesToOmit = 20;
+ for( int i=0; i<aLinesToOmit; i++ )
+ anExpected.readLine();
+
+ bool isEqual = true;
+ while( !anExpected.atEnd() && isEqual )
+ {
+ QString anExpectedLine = QString::fromUtf8( anExpected.readLine() );
+ QString anActualLine = anActual.readLine();
+ isEqual = anExpectedLine == anActualLine;
+ }
+
+ if( isEqual )
+ isEqual = anActual.atEnd();
+
+ anExpected.close();
+ anActual.close();
+
+ return isEqual;
+}
static void select( int theViewX, int theViewY );
+ static bool areScriptsEqual( const QString& theBaseName );
+
private:
static OCCViewer_ViewManager* myViewManager;
static OCCViewer_ViewWindow* myViewWindow;
} \
} \
+#define CPPUNIT_ASSERT_SCRIPTS_EQUAL( theBaseName ) \
+ if( !TestViewer::areScriptsEqual( theBaseName ) ) \
+ CPPUNIT_FAIL( "Scripts are not equal" ); \
+
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+###
+### This file is generated automatically by SALOME v7.6.0 with dump python functionality
+###
+
+import sys
+import salome
+
+salome.salome_init()
+theStudy = salome.myStudy
+
+import salome_notebook
+notebook = salome_notebook.NoteBook(theStudy)
+sys.path.insert( 0, r'D:/asl/hydro/studies')
+
+###
+### HYDRO component
+###
+
+from HYDROPy import *
+from PyQt4.QtCore import *
+from PyQt4.QtGui import *
+
+hydro_doc = HYDROData_Document.Document( theStudy._get_StudyId() );
+
+hydro_doc.SetLocalCS( 0, 0 )
+
+ST = hydro_doc.CreateObject( KIND_STRICKLER_TABLE );
+ST.SetName( "ST" );
+
+ST.SetAttrName( "CODE_06" );
+
+ST.Set( u"Zones de champs, prairies, sans cultures", 20 );
+ST.SetAttrValue( u"Zones de champs, prairies, sans cultures", "511" );
+ST.SetColor( u"Zones de champs, prairies, sans cultures", QColor( 255, 0, 0 ) );
+
+ST.Set( u"Zones à faible urbanization (bourg)", 9 );
+ST.SetAttrValue( u"Zones à faible urbanization (bourg)", "" );
+ST.SetColor( u"Zones à faible urbanization (bourg)", QColor( 0, 0, 255 ) );
+
+ST.Set( u"Zones de champs cultivé à végétation haute", 12.5 );
+ST.SetAttrValue( u"Zones de champs cultivé à végétation haute", "" );
+ST.SetColor( u"Zones de champs cultivé à végétation haute", QColor( 0, 255, 0 ) );
+
+ST.Set( u"Canaux artificiels en béton", 65 );
+ST.SetAttrValue( u"Canaux artificiels en béton", "" );
+ST.SetColor( u"Canaux artificiels en béton", QColor( 136, 136, 136 ) );
+
+ST.Set( u"Canaux naturels", 35 );
+ST.SetAttrValue( u"Canaux naturels", "" );
+ST.SetColor( u"Canaux naturels", QColor( 255, 0, 255 ) );
+
+ST.Set( u"Zones à forte urbanization (agglomération)", 9 );
+ST.SetAttrValue( u"Zones à forte urbanization (agglomération)", "" );
+ST.SetColor( u"Zones à forte urbanization (agglomération)", QColor( 18, 52, 86 ) );
+
+ST.Set( u"Zones de champs cultivé à végétation basse", 17.5 );
+ST.SetAttrValue( u"Zones de champs cultivé à végétation basse", "512" );
+ST.SetColor( u"Zones de champs cultivé à végétation basse", QColor( 255, 255, 0 ) );
+
+ST.Set( u"Zones d'arbustes, de sous-bois", 10 );
+ST.SetAttrValue( u"Zones d'arbustes, de sous-bois", "" );
+ST.SetColor( u"Zones d'arbustes, de sous-bois", QColor( 0, 255, 255 ) );
+
+
+ST.Update();
+
#include <HYDROData_Iterator.h>
#include <HYDROData_StricklerTable.h>
#include <HYDROData_Tool.h>
+#include <TestViewer.h>
#include <QStringList>
#include <QColor>
#include <QDir>
void test_HYDROData_StricklerTable::test_dump_python()
{
- //TODO
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_StricklerTable) aTable =
+ Handle(HYDROData_StricklerTable)::DownCast( aDoc->CreateObject( KIND_STRICKLER_TABLE ) );
+ aTable->SetName( "ST" );
+ CPPUNIT_ASSERT_EQUAL( true, aTable->Import( DEF_STR_PATH ) );
+
+ QString aTmpPath = QDir::tempPath() + "/st_dump.py";
+ CPPUNIT_ASSERT_EQUAL( true, aDoc->DumpToPython( aTmpPath, false ) );
+
+ CPPUNIT_ASSERT_SCRIPTS_EQUAL( "st_dump.py" );
+
+ aDoc->Close();
}