Salome HOME
refs #330 - Immersible zone can not be created without reason for it
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImmersibleZoneOp.cxx
index 1dc958e499809d98bb9530fb42c3dc2723d92310..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 ),
@@ -85,9 +90,9 @@ void HYDROGUI_ImmersibleZoneOp::startOperation()
       if ( !aRefPolyline.IsNull() )
         aSelectedPolyline = aRefPolyline->GetName();
 
-      Handle(HYDROData_Bathymetry) aRefBathymetry = myEditedObject->GetBathymetry();
-      if ( !aRefBathymetry.IsNull() )
-        aSelectedBathymetry = aRefBathymetry->GetName();
+      Handle(HYDROData_IAltitudeObject) aRefAltitude = myEditedObject->GetAltitudeObject();
+      if ( !aRefAltitude.IsNull() )
+        aSelectedBathymetry = aRefAltitude->GetName();
     }
   }
 
@@ -221,7 +226,7 @@ bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags,
   }
 
   aZoneObj->SetPolyline( aZonePolyline );
-  aZoneObj->SetBathymetry( aZoneBathymetry );
+  aZoneObj->SetAltitudeObject( aZoneBathymetry );
   aZoneObj->Update();
 
   closePreview();
@@ -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()