Salome HOME
refs #330 - Immersible zone can not be created without reason for it
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImmersibleZoneOp.cxx
index d59e7d102cbc9e29ab4cf17f422638fefe028469..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 ),
@@ -242,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(
@@ -249,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();
@@ -266,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()