Salome HOME
refs #568: use ordered list view with selection synchronized with object browser...
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ChannelOp.cxx
index 7f96b26d3e29eb338db76904601c205260b5ac08..f00d5804c1d847b70661f8ba8f19570b55bd2550 100644 (file)
@@ -1,8 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
+// Copyright (C) 2014-2015  EDF-R&D
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
@@ -66,15 +62,17 @@ void HYDROGUI_ChannelOp::startOperation()
 
   aPanel->reset();
 
-  myEditedObject.Nullify();
+  if ( isApplyAndClose() )
+    myEditedObject.Nullify();
 
   QString aSelectedGuideLine, aSelectedProfile;
 
   QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_CHANNEL_NAME" ) );
   if ( myIsEdit )
   {
-    myEditedObject =
-      Handle(HYDROData_Channel)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+    if ( isApplyAndClose() )
+      myEditedObject =
+        Handle(HYDROData_Channel)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
     if ( !myEditedObject.IsNull() )
     {
       anObjectName = myEditedObject->GetName();
@@ -109,7 +107,7 @@ void HYDROGUI_ChannelOp::startOperation()
   }
 
   // collect information about existing profiles
-  QStringList aProfiles = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_PROFILE, true );
+  QStringList aProfiles = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_PROFILE, false );
 
   aPanel->setObjectName( anObjectName );
 
@@ -183,19 +181,33 @@ bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags,
 
   QString aGuideLineName = aPanel->getGuideLineName();
   QString aProfileName = aPanel->getProfileName();
-  if ( aGuideLineName.isEmpty() || aProfileName.isEmpty() )
+  /*if ( aGuideLineName.isEmpty() || aProfileName.isEmpty() )
   {
     myEditedObject->RemoveGuideLine();
     myEditedObject->RemoveProfile();
   }
-  else
+  else*/
   {
     Handle(HYDROData_Polyline3D) aGuideLine = Handle(HYDROData_Polyline3D)::DownCast(
       HYDROGUI_Tool::FindObjectByName( module(), aGuideLineName, KIND_POLYLINE ) );
+    if ( aGuideLine.IsNull() )
+    {
+      theErrorMsg = tr( "GUIDE_LINE_IS_NOT_SELECTED" );
+      return false;
+    }
+
+    myEditedObject->RemoveGuideLine();
     myEditedObject->SetGuideLine( aGuideLine );
 
     Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast(
       HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) );
+    if ( aProfile.IsNull() )
+    {
+      theErrorMsg = tr( "PROFILE_IS_NOT_SELECTED" );
+      return false;
+    }
+
+    myEditedObject->RemoveProfile();
     myEditedObject->SetProfile( aProfile );
   }