Salome HOME
Bug #334: Different behavior in Edit calculation case input panel.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_TranslateObstacleOp.cxx
index c677191061fc7962774eb52b7a77f51385d88828..952fe9fbdd908b91618c97751ae2687800e335b9 100644 (file)
@@ -28,6 +28,8 @@
 #include "HYDROGUI_Tool.h"
 #include "HYDROGUI_UpdateFlags.h"
 
+#include <HYDROData_ShapesTool.h>
+
 #include <LightApp_Application.h>
 #include <LightApp_SelectionMgr.h>
 #include <LightApp_UpdateFlags.h>
@@ -109,17 +111,16 @@ bool HYDROGUI_TranslateObstacleOp::processApply( int& theUpdateFlags,
     return false;
   }
 
-  // Get the translated shape
-  TopoDS_Shape aTranslatedShape = getTranslatedShape();
-  if ( aTranslatedShape.IsNull() ) {
-    return false;
-  }
-
   // Erase preview
   erasePreview();
 
-  // Set the translated shape to the obstacle
-  myEditedObject->SetShape3D( aTranslatedShape ); 
+  // Get the translated shape
+  double aDx = aPanel->getDx();
+  double aDy = aPanel->getDy();
+  double aDz = aPanel->getDz();
+
+  // Translate the obstacle
+  myEditedObject->Translate( aDx, aDy, aDz );
   myEditedObject->Update();
 
   module()->setIsToUpdate( myEditedObject );
@@ -132,9 +133,9 @@ bool HYDROGUI_TranslateObstacleOp::processApply( int& theUpdateFlags,
 
 void HYDROGUI_TranslateObstacleOp::createPreview()
 {
-  if ( myEditedObject.IsNull() ) {
+  HYDROGUI_TranslateObstacleDlg* aPanel = (HYDROGUI_TranslateObstacleDlg*)inputPanel();
+  if ( myEditedObject.IsNull() || !aPanel )
     return;
-  }
 
   // Create preview presentation if necessary
   if ( !myPreviewPrs ) {
@@ -154,11 +155,15 @@ void HYDROGUI_TranslateObstacleOp::createPreview()
     }
   }
   
-  // Get the translated shape
-  TopoDS_Shape aTranslatedShape = getTranslatedShape();
-
   // Set the translated shape to the preview presentation
-  if ( myPreviewPrs ) {
+  if ( myPreviewPrs )
+  {
+    double aDx = aPanel->getDx();
+    double aDy = aPanel->getDy();
+    double aDz = aPanel->getDz();
+    TopoDS_Shape anOriShape = myEditedObject->GetShape3D();
+
+    TopoDS_Shape aTranslatedShape = HYDROData_ShapesTool::Translated( anOriShape, aDx, aDy, aDz );
     myPreviewPrs->setShape( aTranslatedShape );
   }
 }