Salome HOME
Issue #1424: Make impossible to create non-valid parameters more the a one
[modules/shaper.git] / src / ModuleBase / ModuleBase_ResultPrs.cpp
index 0a278d93aa5ccaa34cb0e2af30dae9a6758be1d5..310bb78f87cae91d1c6dd9f67bf5d880ae5bb289 100755 (executable)
@@ -7,11 +7,13 @@
 #include "ModuleBase_ResultPrs.h"
 #include "ModuleBase_Tools.h"
 
+#include <ModelAPI_Events.h>
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_ResultConstruction.h>
 #include <GeomAPI_PlanarEdges.h>
 
 #include <Events_Error.h>
+#include <Events_Loop.h>
 
 #include <BRep_Builder.hxx>
 #include <Prs3d_Drawer.hxx>
@@ -69,27 +71,26 @@ bool ModuleBase_ResultPrs::isValidShapeType(const TopAbs_ShapeEnum& theBaseType,
   return aValid;
 }
 
-
 void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
                                    const Handle(Prs3d_Presentation)& thePresentation, 
                                    const Standard_Integer theMode)
 {
   std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(myResult);
-  if (!aShapePtr) {
-    Events_Error::throwException("An empty AIS presentation: ModuleBase_ResultPrs");
-    return;
+  bool aReadyToDisplay = aShapePtr.get();
+  if (aReadyToDisplay) {
+    myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
+    if (!myOriginalShape.IsNull())
+      Set(myOriginalShape);
   }
+  // change deviation coefficient to provide more precise circle
+  ModuleBase_Tools::setDefaultDeviationCoefficient(Shape(), Attributes());
+  AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
 
-  myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
-  if (!myOriginalShape.IsNull()) {
-    Set(myOriginalShape);
-
-    // change deviation coefficient to provide more precise circle
-    ModuleBase_Tools::setDefaultDeviationCoefficient(myOriginalShape, Attributes());
-    AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
-  }
-  else
+  if (!aReadyToDisplay) {
     Events_Error::throwException("An empty AIS presentation: ModuleBase_ResultPrs");
+    static const Events_ID anEvent = Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION);
+    ModelAPI_EventCreator::get()->sendUpdated(myResult, anEvent);
+  }
 }
 
 void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,