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;
+ }
}
}
if ( anObstacleToEdit.IsNull() ) {
anObstacle =
Handle(HYDROData_Obstacle)::DownCast( doc()->CreateObject(KIND_OBSTACLE) );
+
+ anObstacle->SetFillingColor( HYDROData_Obstacle::DefaultFillingColor() );
+ anObstacle->SetBorderColor( HYDROData_Obstacle::DefaultBorderColor() );
} else {
anObstacle = anObstacleToEdit;
}
anObstacle->SetName( anObstacleName );
}
+ anObstacleName.clear();
+
// Set shape
anObstacle->SetShape3D( aShape );
+ anObstacle->Update();
+
// Set operation status
anIsOk = true;
theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;