Salome HOME
refs #207 - "Help" button doesn't work
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Operations.cxx
index 7bfd007155dd90a33403b0360baefe20032dc26f..7d8dba61d98a7e0d1969a6f99ff68b8967b64813 100644 (file)
@@ -27,6 +27,7 @@
 #include "HYDROGUI_ChannelOp.h"
 #include "HYDROGUI_DataModel.h"
 #include "HYDROGUI_DeleteOp.h"
+#include "HYDROGUI_DigueOp.h"
 #include "HYDROGUI_ExportImageOp.h"
 #include "HYDROGUI_ImportImageOp.h"
 #include "HYDROGUI_ImportBathymetryOp.h"
@@ -135,6 +136,9 @@ void HYDROGUI_Module::createActions()
   createAction( CreateChannelId, "CREATE_CHANNEL", "CREATE_CHANNEL_ICO" );
   createAction( EditChannelId, "EDIT_CHANNEL", "EDIT_CHANNEL_ICO" );
 
+  createAction( CreateDigueId, "CREATE_DIGUE", "CREATE_DIGUE_ICO" );
+  createAction( EditDigueId, "EDIT_DIGUE", "EDIT_DIGUE_ICO" );
+
   createAction( ImportObstacleFromFileId, "IMPORT_OBSTACLE_FROM_FILE", "IMPORT_OBSTACLE_FROM_FILE_ICO" );
   createAction( ImportGeomObjectId, "IMPORT_GEOM_OBJECT", "IMPORT_GEOM_OBJECT_ICO" );
   createAction( CreateBoxId, "CREATE_BOX", "CREATE_BOX_ICO" );
@@ -193,6 +197,7 @@ void HYDROGUI_Module::createMenus()
 
   int anArtificialMenuId = createMenu( tr( "MEN_DESK_ARTIFICIAL" ), aHydroId, -1 );
   createMenu( CreateChannelId, anArtificialMenuId, -1, -1 );
+  createMenu( CreateDigueId, anArtificialMenuId, -1, -1 );
 
   int aNaturalMenuId = createMenu( tr( "MEN_DESK_NATURAL" ), aHydroId, -1 );
   createMenu( CreateImmersibleZoneId, aNaturalMenuId, -1, -1 );
@@ -234,6 +239,7 @@ void HYDROGUI_Module::createToolbars()
 
   createTool( separator(), aToolBar );
   createTool( CreateChannelId, aToolBar );
+  createTool( CreateDigueId, aToolBar );
 
   createTool( separator(), aToolBar );
   createTool( CreateImmersibleZoneId, aToolBar );
@@ -423,6 +429,10 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case EditChannelId:
     anOp = new HYDROGUI_ChannelOp( aModule, theId == EditChannelId );
     break;
+  case CreateDigueId:
+  case EditDigueId:
+    anOp = new HYDROGUI_DigueOp( aModule, theId == EditDigueId );
+    break;
   case CreateCalculationId:
   case EditCalculationId:
     anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId );
@@ -534,8 +544,8 @@ bool HYDROGUI_Module::renameAllowed( const QString& theEntry ) const
 bool HYDROGUI_Module::renameObject( const QString& theEntry, const QString& theName )
 {
   Handle(HYDROData_Entity) anEntity = getDataModel()->objectByEntry( theEntry );
-  bool aRes = !anEntity.IsNull();
-  if ( aRes )
+  bool aRes = false;
+  if ( !anEntity.IsNull() )
   {
     HYDROGUI_DataModel* aModel = getDataModel();
     if( aModel )
@@ -544,10 +554,18 @@ bool HYDROGUI_Module::renameObject( const QString& theEntry, const QString& theN
       {
         // check that there are no other objects with the same name in the document
         Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( this, theName );
-        aRes = anObject.IsNull();
-        if ( aRes )
+        if ( anObject.IsNull() )
         {
-          aRes = aModel->rename( anEntity, theName );
+          SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
+          if ( anOp && anOp->inherits( "HYDROGUI_CalculationOp" ) )
+          {
+            anEntity->SetName( theName );
+            aRes = true;
+          }
+          else
+          {
+            aRes = aModel->rename( anEntity, theName );
+          }
         }
         else
         {