]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Bug #119: create obstacles from several objects in GEOM is wrong.
authormzn <mzn@opencascade.com>
Thu, 21 Nov 2013 10:40:43 +0000 (10:40 +0000)
committermzn <mzn@opencascade.com>
Thu, 21 Nov 2013 10:40:43 +0000 (10:40 +0000)
src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx

index 6f771664c77dc88de9c4851591cf51cc62c274ba..4ba06589d180a3cce243b3e641ff58c3db810d2e 100644 (file)
@@ -122,31 +122,33 @@ bool HYDROGUI_ImportGeomObjectOp::processApply( int& theUpdateFlags,
   QString anObstacleName;
   Handle(HYDROData_Obstacle) anObstacleToEdit;  
 
-  // Get panel
-  HYDROGUI_ObstacleDlg* aPanel = ::qobject_cast<HYDROGUI_ObstacleDlg*>( inputPanel() );
-  if ( aPanel ) {
-    // Check obstacle name
-    anObstacleName = aPanel->getObstacleName().simplified();
-    if ( anObstacleName.isEmpty() ) {
-      theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
-      return false;
-    }
+  if ( myGeomObjects.count() == 1 ) {
+    // Get panel
+    HYDROGUI_ObstacleDlg* aPanel = ::qobject_cast<HYDROGUI_ObstacleDlg*>( inputPanel() );
+    if ( aPanel ) {
+      // Check obstacle name
+      anObstacleName = aPanel->getObstacleName().simplified();
+      if ( anObstacleName.isEmpty() ) {
+        theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
+        return false;
+      }
 
-    // Get obstacle to edit
-    QString anEditedName = aPanel->getEditedObstacleName().simplified();
+      // Get obstacle to edit
+      QString anEditedName = aPanel->getEditedObstacleName().simplified();
 
-    if ( !anEditedName.isEmpty() ) {
-      anObstacleToEdit = Handle(HYDROData_Obstacle)::DownCast(
-        HYDROGUI_Tool::FindObjectByName( module(), anEditedName, KIND_OBSTACLE ) );
+      if ( !anEditedName.isEmpty() ) {
+        anObstacleToEdit = Handle(HYDROData_Obstacle)::DownCast(
+          HYDROGUI_Tool::FindObjectByName( module(), anEditedName, KIND_OBSTACLE ) );
+      }
     }
-  }
 
-  if( anObstacleToEdit.IsNull() || anObstacleToEdit->GetName() != anObstacleName ) {
-    // check that there are no other objects with the same name in the document
-    Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObstacleName );
-    if( !anObject.IsNull() ) {
-      theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObstacleName );
-      return false;
+    if( anObstacleToEdit.IsNull() || anObstacleToEdit->GetName() != anObstacleName ) {
+      // check that there are no other objects with the same name in the document
+      Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObstacleName );
+      if( !anObject.IsNull() ) {
+        theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObstacleName );
+        return false;
+      }
     }
   }
 
@@ -179,6 +181,8 @@ bool HYDROGUI_ImportGeomObjectOp::processApply( int& theUpdateFlags,
           anObstacle->SetName( anObstacleName );
         }
 
+        anObstacleName.clear();
+
         // Set shape
         anObstacle->SetShape3D( aShape );