Salome HOME
Create goups for stream.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Operations.cxx
index c9fca653e8d192a0afdbc41b1b52cd5b54ef2d62..d3a2d04ffb829f096f0e8f862ba440e795eb0983 100644 (file)
@@ -140,7 +140,8 @@ void HYDROGUI_Module::createActions()
   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( ImportGeomObjectAsObstacleId, "IMPORT_GEOM_OBJECT_AS_OBSTACLE", "IMPORT_GEOM_OBJECT_ICO" );
+  createAction( ImportGeomObjectAsPolylineId, "IMPORT_GEOM_OBJECT_AS_POLYLINE", "IMPORT_GEOM_OBJECT_ICO" );
   createAction( CreateBoxId, "CREATE_BOX", "CREATE_BOX_ICO" );
   createAction( CreateCylinderId, "CREATE_CYLINDER", "CREATE_CYLINDER_ICO" );
 
@@ -456,10 +457,13 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
     anOp = new HYDROGUI_ImportObstacleFromFileOp( aModule );
     break;
   case ImportCreatedPrimitiveId:
-    anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportCreated );
+    anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportCreatedAsObstacle );
     break;
-  case ImportGeomObjectId:
-    anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportSelected );
+  case ImportGeomObjectAsObstacleId:
+    anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportSelectedAsObstacle );
+    break;
+  case ImportGeomObjectAsPolylineId:
+    anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportSelectedAsPolyline );
     break;
   case CreateBoxId:
     application()->activateOperation( "Geometry", GEOMOp::OpBox );
@@ -490,7 +494,8 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
 
 bool HYDROGUI_Module::reusableOperation( const int id )
 {
-  if ( id == ImportGeomObjectId ) {
+  if ( id == ImportGeomObjectAsObstacleId ||
+       id == ImportGeomObjectAsPolylineId ) {
     return false;
   }
 
@@ -544,8 +549,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 )
@@ -554,10 +559,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
         {