Salome HOME
Exlude the user input during process events by application (Bug #325).
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportGeomObjectOp.cxx
index c3d9488f872559c42382f29a59116dbb60f7d20b..a454cd985c7b5d30393d8eaf06fa7ac81aa6b2d0 100644 (file)
@@ -41,6 +41,7 @@
 #include <LightApp_UpdateFlags.h>
 
 #include <SUIT_Desktop.h>
+#include <SUIT_MessageBox.h>
 
 #include <QDialog>
 
@@ -210,14 +211,14 @@ bool HYDROGUI_ImportGeomObjectOp::processApply( int& theUpdateFlags,
 
       if ( anObjectToEdit.IsNull() ) {
         if ( myOpType == ImportCreatedAsObstacle || myOpType == ImportSelectedAsObstacle ) {
-          anObject = 
-            Handle(HYDROData_Obstacle)::DownCast( doc()->CreateObject(KIND_OBSTACLE) );
+          anObject = doc()->CreateObject( KIND_OBSTACLE );
           Handle(HYDROData_Obstacle) anObstacle = Handle(HYDROData_Obstacle)::DownCast( anObject );
           anObstacle->SetFillingColor( HYDROData_Obstacle::DefaultFillingColor() );
           anObstacle->SetBorderColor( HYDROData_Obstacle::DefaultBorderColor() );
         } else if ( myOpType == ImportSelectedAsPolyline ) {
-          anObject = 
-            Handle(HYDROData_PolylineXY)::DownCast( doc()->CreateObject(KIND_POLYLINEXY) );
+          anObject = doc()->CreateObject( KIND_POLYLINEXY );
+          Handle(HYDROData_PolylineXY) aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( anObject );
+          aPolylineObj->SetWireColor( HYDROData_PolylineXY::DefaultWireColor() );
         }
       } else {
         anObject = anObjectToEdit;
@@ -242,14 +243,26 @@ bool HYDROGUI_ImportGeomObjectOp::processApply( int& theUpdateFlags,
         anIsOk = true;
       } else if ( myOpType == ImportSelectedAsPolyline ) {
         Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( anObject );
-        // TODO ISSUE #228: set the shape ("aShape") to the polyline
-        // anIsOk = aPolyline->setShape( aShape );
+        anIsOk = aPolyline->ImportShape( aShape );
+
+        /* TODO: check it before start operation
+        if ( anIsOk && !aPolyline->IsEditable() )
+        {
+          anIsOk = SUIT_MessageBox::question( module()->getApp()->desktop(),
+                                              tr( "POLYLINE_IS_UNRECOGNIZED_TLT" ),
+                                              tr( "POLYLINE_IS_UNRECOGNIZED_MSG" ),
+                                              QMessageBox::Yes | QMessageBox::No,
+                                              QMessageBox::No ) == QMessageBox::Yes;
+          setPrintErrorMessage( anIsOk );
+        }
+        */
       }
 
       // Check operation status
       if ( anIsOk ) {
         anObject->Update();
-        theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+        module()->setIsToUpdate( anObject );
+        theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
       }
     }
   }