From ecb167067ddfbaf01ceedb62f754e6ca7d2f7131 Mon Sep 17 00:00:00 2001 From: mzn Date: Thu, 21 Nov 2013 10:40:43 +0000 Subject: [PATCH] Bug #119: create obstacles from several objects in GEOM is wrong. --- src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx | 46 +++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx b/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx index 6f771664..4ba06589 100644 --- a/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx @@ -122,31 +122,33 @@ bool HYDROGUI_ImportGeomObjectOp::processApply( int& theUpdateFlags, QString anObstacleName; Handle(HYDROData_Obstacle) anObstacleToEdit; - // Get panel - HYDROGUI_ObstacleDlg* aPanel = ::qobject_cast( 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( 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 ); -- 2.39.2