if ( aRegion.IsNull() )
continue;
- QString aRegionName = aRegion->GetName();
-
- HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
- HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
- for ( ; aZonesIter.More(); aZonesIter.Next() )
- {
- Handle(HYDROData_Zone) aRegZone =
- Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() );
- if ( aRegZone.IsNull() )
- continue;
-
- // TODO
- }
+ theTreatedObjects.insert( aRegion->GetName(), aRegion );
+ QStringList aRegDump = aRegion->DumpToPython( theTreatedObjects );
+ aResList << aRegDump;
}
}
.arg( theColor.blue() ).arg( theColor.alpha() );
}
-
+void HYDROData_Entity::findPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects,
+ QStringList& theScript ) const
+{
+ Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
+ if ( aDocument.IsNull() )
+ return;
+
+ theScript << QString( "%1 = %2.FindObjectByName( \"%3\" );" ).arg( GetObjPyName() )
+ .arg( aDocument->GetDocPyName() )
+ .arg( GetName() );
+}
*/
HYDRODATA_EXPORT virtual void RemoveZLevel();
-
+ /**
+ Find the Python object in the document by the object name.
+ @param theTreatedObjects the map of treated objects
+ @param theScript the script
+ */
+ void findPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects,
+ QStringList& theScript ) const;
+
protected:
friend class HYDROData_Iterator;
* \param theDefColor default color to return if attribute has not been set before
*/
QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
-
-
+
protected:
/**
return aResShape;
}
+
+QStringList HYDROData_Region::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+{
+ QStringList aResList;
+
+ // Find region
+ findPythonReferenceObject( theTreatedObjects, aResList );
+
+ // Add zones
+ HYDROData_SequenceOfObjects aZones = GetZones();
+ HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
+ for ( ; aZonesIter.More(); aZonesIter.Next() ) {
+ Handle(HYDROData_Zone) aZone =
+ Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() );
+ if ( aZone.IsNull() ) {
+ continue;
+ }
+
+ // find zone
+ aZone->findPythonReferenceObject( theTreatedObjects, aResList );
+ theTreatedObjects.insert( aZone->GetName(), aZone );
+ // add zone
+ setPythonReferenceObject( theTreatedObjects, aResList, aZone, "AddZone" );
+ // set zone merge type
+ QString aMergeTypeStr;
+ HYDROData_Zone::MergeAltitudesType aMergeType = aZone->GetMergeType();
+ if ( aMergeType == HYDROData_Zone::Merge_ZMIN ) {
+ aMergeTypeStr = "HYDROData_Zone.Merge_ZMIN";
+ } else if ( aMergeType == HYDROData_Zone::Merge_ZMAX ) {
+ aMergeTypeStr = "HYDROData_Zone.Merge_ZMAX";
+ } else if ( aMergeType == HYDROData_Zone::Merge_Object ) {
+ aMergeTypeStr = "HYDROData_Zone.Merge_Object";
+ }
+
+ if ( !aMergeTypeStr.isEmpty() ) {
+ aResList << QString( "%1.SetMergeType( %2 )" ).arg( aZone->GetObjPyName() ).arg( aMergeTypeStr );
+ }
+ if ( aMergeType == HYDROData_Zone::Merge_Object ) {
+ Handle(HYDROData_IAltitudeObject) aMergeAltitude = aZone->GetMergeAltitude();
+ if ( !aMergeAltitude.IsNull() ) {
+ aMergeAltitude->findPythonReferenceObject( theTreatedObjects, aResList );
+ aResList << QString( "%1.SetMergeAltitude( %2 )" ).arg( aZone->GetObjPyName() )
+ .arg( aMergeAltitude->GetObjPyName() );
+ }
+ }
+ }
+
+ return aResList;
+}
\ No newline at end of file