]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Check and if necessary dump the reference object to python.
authoradv <adv@opencascade.com>
Fri, 17 Jan 2014 08:06:12 +0000 (08:06 +0000)
committeradv <adv@opencascade.com>
Fri, 17 Jan 2014 08:06:12 +0000 (08:06 +0000)
src/HYDROData/HYDROData_Entity.cxx
src/HYDROData/HYDROData_Entity.h
src/HYDROData/HYDROData_Polyline3D.cxx

index af16992f00e20e3650b3aad5bf2602def70de7b9..f3f37eeb9f0fab5e5dde63df7420ea9eddaf7537 100644 (file)
@@ -499,38 +499,44 @@ void HYDROData_Entity::setPythonReferenceObject( MapOfTreatedObjects&
                                                  const Handle(HYDROData_Entity)& theRefObject,
                                                  const QString&                  theMethod ) const
 {
-  if ( theRefObject.IsNull() )
+  if ( !checkObjectPythonDefinition( theTreatedObjects, theScript, theRefObject ) )
     return;
 
+  QString aRefObjName = theRefObject->GetObjPyName();
+
+  QString anObjName = GetObjPyName();
+  theScript << QString( "%1.%2( %3 );" )
+               .arg( anObjName ).arg( theMethod ).arg( aRefObjName );
+}
+
+bool HYDROData_Entity::checkObjectPythonDefinition( MapOfTreatedObjects&            theTreatedObjects,
+                                                    QStringList&                    theScript,
+                                                    const Handle(HYDROData_Entity)& theRefObject ) const
+{
+  if ( theRefObject.IsNull() )
+    return false;
+
   QString aRefObjName = theRefObject->GetObjPyName();
   if ( aRefObjName.isEmpty() )
-    return;
+    return false;
 
-  bool anIsToSetObject = true;
+  if ( theTreatedObjects.contains( aRefObjName ) )
+    return true;
 
   // The definition of reference object must be dumped before this
-  if ( !theTreatedObjects.contains( aRefObjName ) )
-  {
-    // Write definition of reference polyline
-    QStringList aRefObjDump = theRefObject->DumpToPython( theTreatedObjects );
-    if ( ( anIsToSetObject = !aRefObjDump.isEmpty() ) )
-    {
-      QStringList aTmpList = theScript;
-      theScript = aRefObjDump;
+  QStringList aRefObjDump = theRefObject->DumpToPython( theTreatedObjects );
+  if ( aRefObjDump.isEmpty() )
+    return false;
 
-      theScript << QString( "" );
-      theScript << aTmpList;
+  QStringList aTmpList = theScript;
+  theScript = aRefObjDump;
 
-      theTreatedObjects.insert( aRefObjName, theRefObject );
-    }
-  }
+  theScript << QString( "" );
+  theScript << aTmpList;
 
-  if ( anIsToSetObject )
-  {
-    QString anObjName = GetObjPyName();
-    theScript << QString( "%1.%2( %3 );" )
-                 .arg( anObjName ).arg( theMethod ).arg( aRefObjName );
-  }
+  theTreatedObjects.insert( aRefObjName, theRefObject );
+
+  return true;
 }
 
 void HYDROData_Entity::setPythonObjectColor( QStringList&         theScript,
index 0f48dbbce666b42354d3b82a30198a3cefb1aaa5..1ac88c3fad0b4289d4be8df4240cedb3bef70f72 100644 (file)
@@ -333,6 +333,10 @@ protected:
                                  const Handle(HYDROData_Entity)& theRefObject,
                                  const QString&                  theMethod ) const;
 
+  bool checkObjectPythonDefinition( MapOfTreatedObjects&            theTreatedObjects,
+                                    QStringList&                    theScript,
+                                    const Handle(HYDROData_Entity)& theRefObject ) const;
+
   void setPythonObjectColor( QStringList&         theScript,
                              const QColor&        theColor,
                              const QColor&        theDefaultColor,
index c55cbe07fdce1370503544d9c5eb211e8e858b61..dd246a236cf10f997593f3f798c6311ee56f41e2 100644 (file)
@@ -44,7 +44,7 @@ QStringList HYDROData_Polyline3D::DumpToPython( MapOfTreatedObjects& theTreatedO
   {
     Handle(HYDROData_Profile) aProfile = 
       Handle(HYDROData_Profile)::DownCast( aRefProfileUZ->GetFatherObject() );
-    if ( !aProfile.IsNull() )
+    if ( checkObjectPythonDefinition( theTreatedObjects, aResList, aProfile ) )
     {
       QString aProfileName = aProfile->GetObjPyName();
       if ( !aProfileName.isEmpty() )
@@ -64,7 +64,7 @@ QStringList HYDROData_Polyline3D::DumpToPython( MapOfTreatedObjects& theTreatedO
       {
         Handle(HYDROData_Profile) aProfile = 
           Handle(HYDROData_Profile)::DownCast( aChildProfileUZ->GetFatherObject() );
-        if ( !aProfile.IsNull() )
+        if ( checkObjectPythonDefinition( theTreatedObjects, aResList, aProfile ) )
         {
           QString aProfileName = aProfile->GetObjPyName();
           if ( !aProfileName.isEmpty() )