Salome HOME
refs #330 - Immersible zone can not be created without reason for it
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImmersibleZoneOp.cxx
index aa0e89cfa1e7dc13975d0a416a0e2400caffd5b5..41f539a22719df812fd7cc1dceda33cad6e2351b 100644 (file)
 #include <LightApp_Application.h>
 #include <LightApp_UpdateFlags.h>
 
+#include <SUIT_MessageBox.h>
+#include <SUIT_Desktop.h>
+
 #include <TopoDS.hxx>
 #include <TopoDS_Wire.hxx>
 
+#include <QApplication>
+
 HYDROGUI_ImmersibleZoneOp::HYDROGUI_ImmersibleZoneOp( HYDROGUI_Module* theModule,
                                                       const bool theIsEdit )
 : HYDROGUI_Operation( theModule ),
@@ -229,7 +234,9 @@ bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags,
   if( !myIsEdit )
     module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aZoneObj, true );
 
-  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+  module()->setIsToUpdate( aZoneObj );
+
+  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
 
   return true;
 }
@@ -240,6 +247,7 @@ void HYDROGUI_ImmersibleZoneOp::onCreatePreview( const QString& thePolylineName
   if ( !aPanel )
     return;
 
+  QApplication::setOverrideCursor( Qt::WaitCursor );
   TopoDS_Shape aZoneShape;
 
   Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast(
@@ -247,6 +255,8 @@ void HYDROGUI_ImmersibleZoneOp::onCreatePreview( const QString& thePolylineName
   if ( !aPolyline.IsNull() )
   {
     aZoneShape = HYDROData_ImmersibleZone::generateTopShape( aPolyline );
+    if( aZoneShape.IsNull() )
+      printErrorMessage( tr( "ZONE_OBJECT_CANNOT_BE_CREATED" ) );
   }
 
   LightApp_Application* anApp = module()->getApp();
@@ -264,22 +274,24 @@ void HYDROGUI_ImmersibleZoneOp::onCreatePreview( const QString& thePolylineName
     }
   }
 
-  if ( !myViewManager || !myPreviewPrs )
-    return;
+  if ( myViewManager && myPreviewPrs )
+  {
+    QColor aFillingColor = HYDROData_ImmersibleZone::DefaultFillingColor();
+    QColor aBorderColor = HYDROData_ImmersibleZone::DefaultBorderColor();
+    if ( !myEditedObject.IsNull() ) {
+      aFillingColor = myEditedObject->GetFillingColor();
+      aBorderColor = myEditedObject->GetBorderColor();
+    }
 
-  QColor aFillingColor = HYDROData_ImmersibleZone::DefaultFillingColor();
-  QColor aBorderColor = HYDROData_ImmersibleZone::DefaultBorderColor();
-  if ( !myEditedObject.IsNull() ) {
-    aFillingColor = myEditedObject->GetFillingColor();
-    aBorderColor = myEditedObject->GetBorderColor();
+    myPreviewPrs->setFillingColor( aFillingColor, false, false );
+    myPreviewPrs->setBorderColor( aBorderColor, false, false );
+    TopoDS_Face aFace;
+    if( !aZoneShape.IsNull() )
+      aFace = TopoDS::Face( aZoneShape );
+    myPreviewPrs->setFace( aFace );
   }
 
-  myPreviewPrs->setFillingColor( aFillingColor, false, false );
-  myPreviewPrs->setBorderColor( aBorderColor, false, false );
-  TopoDS_Face aFace;
-  if( !aZoneShape.IsNull() )
-    aFace = TopoDS::Face( aZoneShape );
-  myPreviewPrs->setFace( aFace );
+  QApplication::restoreOverrideCursor();
 }
 
 void HYDROGUI_ImmersibleZoneOp::closePreview()