]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
#1404 Random crash with Shaper: AIS presentations: operation prs, result sketch prs...
authornds <nds@opencascade.com>
Wed, 20 Apr 2016 14:37:21 +0000 (17:37 +0300)
committernds <nds@opencascade.com>
Wed, 20 Apr 2016 15:00:55 +0000 (18:00 +0300)
src/ModelAPI/ModelAPI_Events.h
src/ModuleBase/ModuleBase_ResultPrs.cpp
src/PartSet/PartSet_OperationPrs.cpp
src/PartSet/PartSet_OperationPrs.h
src/PartSet/PartSet_ResultSketchPrs.cpp
src/PartSet/PartSet_ResultSketchPrs.h
src/XGUI/XGUI_WorkshopListener.cpp
src/XGUI/XGUI_WorkshopListener.h

index 656ec109aeddf4735c8351b0d597ca0ec761cbbb..aee15049df32f206e15464d046517b684769cbdc 100644 (file)
@@ -48,6 +48,9 @@ static const char * EVENT_FEATURE_STATE_RESPONSE = "FeatureStateResponse";
 static const char * EVENT_UPDATE_VIEWER_BLOCKED = "UpdateViewerBlocked";
 static const char * EVENT_UPDATE_VIEWER_UNBLOCKED = "UpdateViewerUnblocked";
 
+static const char * EVENT_EMPTY_AIS_PRESENTATION = "EmptyAISPresentation";
+static const char * EVENT_EMPTY_OPERATION_PRESENTATION = "EmptyOperationPresentation";
+
 static const char * EVENT_PREVIEW_BLOCKED = "PreviewBlocked";
 static const char * EVENT_PREVIEW_REQUESTED = "PreviewRequested";
 
index 0a278d93aa5ccaa34cb0e2af30dae9a6758be1d5..726821ec193a0de02ad7784165f25e81495bafd0 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,24 @@ 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;
-  }
-
-  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);
+  if (aShapePtr.get()) {
+    myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
+    if (!myOriginalShape.IsNull())
+      Set(myOriginalShape);
   }
-  else
+  else {
     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);
+  }
+  // change deviation coefficient to provide more precise circle
+  ModuleBase_Tools::setDefaultDeviationCoefficient(Shape(), Attributes());
+  AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
 }
 
 void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
index 98bd33298ad97893bd67d675ac121f5379b88883..3858042e3c4524a7e506f33bda0d7ed4b7e41d86 100755 (executable)
@@ -18,6 +18,7 @@
 #include <ModuleBase_ModelWidget.h>
 #include <ModuleBase_ViewerPrs.h>
 
+#include <ModelAPI_Events.h>
 #include <ModelAPI_Result.h>
 #include <ModelAPI_Attribute.h>
 #include <ModelAPI_AttributeRefAttr.h>
@@ -30,6 +31,7 @@
 #include <ModelAPI_ResultCompSolid.h>
 
 #include <Events_Error.h>
+#include <Events_Loop.h>
 
 #include <GeomAPI_IPresentable.h>
 
@@ -77,49 +79,44 @@ void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
   SetColor(myShapeColor);
   thePresentation->Clear();
 
+  NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)> aShapeToPrsMap;
+  fillShapeList(myFeatureShapes, aShapeToPrsMap);
+
+  if (!aShapeToPrsMap.IsEmpty()) {
+    myShapeToPrsMap.Clear();
+    myShapeToPrsMap.Assign(aShapeToPrsMap);
+  }
   XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(myWorkshop)->displayer();
   Handle(Prs3d_Drawer) aDrawer = Attributes();
-
   // create presentations on the base of the shapes
-  bool anEmptyAIS = true;
-  QMap<ObjectPtr, QList<GeomShapePtr> >::const_iterator anIt = myFeatureShapes.begin(),
-                                                        aLast = myFeatureShapes.end();
-  for (; anIt != aLast; anIt++) {
-    ObjectPtr anObject = anIt.key();
-    QList<GeomShapePtr> aShapes = anIt.value();
-    QList<GeomShapePtr>::const_iterator aShIt = aShapes.begin(), aShLast = aShapes.end();
-    for (; aShIt != aShLast; aShIt++) {
-      GeomShapePtr aGeomShape = *aShIt;
-      // the shape should not be checked here on empty value because it should be checked in
-      // appendShapeIfVisible() on the step of filling myFeatureShapes list
-      // the reason is to avoid empty AIS object visualized in the viewer
-      //if (!aGeomShape.get()) continue;
-      TopoDS_Shape aShape = aGeomShape.get() ? aGeomShape->impl<TopoDS_Shape>() : TopoDS_Shape();
-      // change deviation coefficient to provide more precise circle
-      ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, aDrawer);
-
-      if (myUseAISWidth) {
-        AISObjectPtr anAISPtr = aDisplayer->getAISObject(anObject);
-        if (anAISPtr.get()) {
-          Handle(AIS_InteractiveObject) anIO = anAISPtr->impl<Handle(AIS_InteractiveObject)>();
-          if (!anIO.IsNull()) {
-            int aWidth = anIO->Width();
-            /// workaround for zero width. Else, there will be a crash
-            if (aWidth == 0) { // width returns of TSolid shape is zero
-              bool isDisplayed = !anIO->GetContext().IsNull();
-              aWidth = PartSet_Tools::getAISDefaultWidth();// default width value
-            }
-            setWidth(aDrawer, aWidth);
-          }
+  for(NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)>::Iterator anIter(myShapeToPrsMap);
+      anIter.More(); anIter.Next()) {
+    const TopoDS_Shape& aShape = anIter.Key();
+    // change deviation coefficient to provide more precise circle
+    ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, aDrawer);
+
+    if (myUseAISWidth) {
+      Handle(AIS_InteractiveObject) anIO = anIter.Value();
+      if (!anIO.IsNull()) {
+        int aWidth = anIO->Width();
+        /// workaround for zero width. Else, there will be a crash
+        if (aWidth == 0) { // width returns of TSolid shape is zero
+          bool isDisplayed = !anIO->GetContext().IsNull();
+          aWidth = PartSet_Tools::getAISDefaultWidth();// default width value
         }
+        setWidth(aDrawer, aWidth);
       }
-      StdPrs_WFDeflectionShape::Add(thePresentation, aShape, aDrawer);
-      if (anEmptyAIS)
-        anEmptyAIS = false;
     }
+    StdPrs_WFDeflectionShape::Add(thePresentation, aShape, aDrawer);
   }
-  if (anEmptyAIS)
+
+  if (myShapeToPrsMap.IsEmpty()) {
     Events_Error::throwException("An empty AIS presentation: PartSet_OperationPrs");
+
+    //std::shared_ptr<Events_Message> aMsg = std::shared_ptr<Events_Message>(
+    //            new Events_Message(Events_Loop::eventByName(EVENT_EMPTY_OPERATION_PRESENTATION)));
+    //Events_Loop::loop()->send(aMsg);
+  }
 }
 
 void PartSet_OperationPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
@@ -360,3 +357,37 @@ bool PartSet_OperationPrs::isSelectionAttribute(const AttributePtr& theAttribute
          anAttrType == ModelAPI_AttributeSelection::typeId() ||
          anAttrType == ModelAPI_AttributeReference::typeId();
 }
+
+void PartSet_OperationPrs::fillShapeList(const QMap<ObjectPtr, QList<GeomShapePtr> >& theFeatureShapes,
+                            NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)>& theShapeToPrsMap)
+{
+  theShapeToPrsMap.Clear();
+
+  XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(myWorkshop)->displayer();
+  Handle(Prs3d_Drawer) aDrawer = Attributes();
+
+  // create presentations on the base of the shapes
+  QMap<ObjectPtr, QList<GeomShapePtr> >::const_iterator anIt = myFeatureShapes.begin(),
+                                                        aLast = myFeatureShapes.end();
+  for (; anIt != aLast; anIt++) {
+    ObjectPtr anObject = anIt.key();
+    QList<GeomShapePtr> aShapes = anIt.value();
+    QList<GeomShapePtr>::const_iterator aShIt = aShapes.begin(), aShLast = aShapes.end();
+    for (; aShIt != aShLast; aShIt++) {
+      GeomShapePtr aGeomShape = *aShIt;
+      // the shape should not be checked here on empty value because it should be checked in
+      // appendShapeIfVisible() on the step of filling myFeatureShapes list
+      // the reason is to avoid empty AIS object visualized in the viewer
+      //if (!aGeomShape.get()) continue;
+      TopoDS_Shape aShape = aGeomShape.get() ? aGeomShape->impl<TopoDS_Shape>() : TopoDS_Shape();
+      // change deviation coefficient to provide more precise circle
+      Handle(AIS_InteractiveObject) anIO;
+      if (myUseAISWidth) {
+        AISObjectPtr anAISPtr = aDisplayer->getAISObject(anObject);
+        if (anAISPtr.get())
+          anIO = anAISPtr->impl<Handle(AIS_InteractiveObject)>();
+      }
+      theShapeToPrsMap.Bind(aShape, anIO);
+    }
+  }
+}
index 6ea0ac622a5a5ceb3cd0fba895b3d269ca4b79c7..0c49300efa5bd241597d8bb7c66d963b7831766b 100755 (executable)
@@ -22,6 +22,7 @@
 #include <Standard_DefineHandle.hxx>
 
 #include <Quantity_Color.hxx>
+#include <NCollection_List.hxx>
 
 #include <QMap>
 #include <QList>
@@ -129,7 +130,15 @@ private:
                                    GeomShapePtr theGeomShape,
                                    QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
 
+  /// Fills the list of shapes by map of model objects
+  /// \param theFeatureShape a container to find shapes
+  /// \param theShapesMap an out container
+  void fillShapeList(const QMap<ObjectPtr, QList<GeomShapePtr> >& theFeatureShapes,
+                     NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)>& theShapeToPrsMap);
+
 private:
+  NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)> myShapeToPrsMap; /// list of visualized shapes
+
   QMap<ObjectPtr, QList<GeomShapePtr> > myFeatureShapes; /// visualized shapes
 
   ModuleBase_IWorkshop* myWorkshop; /// current workshop
index ede7d144d93d8789e347d74cfc40f2f374ed4881..04d9318eabb70215e7688025b63059ad978b19ed 100755 (executable)
@@ -8,11 +8,13 @@
 #include "PartSet_Tools.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 <SketchPlugin_SketchEntity.h>
 
@@ -77,92 +79,39 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d)
 {
   thePresentation->Clear();
 
-  std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(myResult);
-  if (!aShapePtr) {
-    Events_Error::throwException("An empty AIS presentation: PartSet_ResultSketchPrs");
-    return;
-  }
+  TopoDS_Shape aResultShape;
+  TopoDS_Compound anAuxiliaryCompound;
+  NCollection_List<TopoDS_Shape> aFaceList;
+  fillShapes(aResultShape, anAuxiliaryCompound, mySketchFaceList);
 
-  setAuxiliaryPresentationStyle(false);
+  bool isEmptyPresentation = aResultShape.IsNull() && anAuxiliaryCompound.IsNull();
 
-  myFacesList.clear();
-  ResultConstructionPtr aConstruction = 
-    std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(myResult);
-  if (aConstruction.get()) {
-    int aFacesNum = aConstruction->facesNum();
-    for(int aFaceIndex = 0; aFaceIndex < aFacesNum; aFaceIndex++) {
-      myFacesList.push_back(aConstruction->face(aFaceIndex));
-    }
+  if (!aResultShape.IsNull()) {
+    myOriginalShape = aResultShape;
+    if (!myOriginalShape.IsNull())
+      Set(myOriginalShape);
   }
-  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
-    Events_Error::throwException("An empty AIS presentation: PartSet_ResultSketchPrs");
+  if (!anAuxiliaryCompound.IsNull())
+    myAuxiliaryCompound = anAuxiliaryCompound;
 
-  // visualize auxiliary shapes and sketch construction elements(point, center of a circle)
-  FeaturePtr aResultFeature = ModelAPI_Feature::feature(myResult);
-  CompositeFeaturePtr aSketchFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>
-                                                                          (aResultFeature);
-  std::list<ResultPtr> anAuxiliaryResults;
-  /// append auxiliary shapes
-  for (int i = 0; i < aSketchFeature->numberOfSubs(); i++) {
-    FeaturePtr aFeature = aSketchFeature->subFeature(i);
-    if (PartSet_Tools::isAuxiliarySketchEntity(aFeature)) {
-      std::list<ResultPtr> aResults = aFeature->results();
-      std::list<ResultPtr>::const_iterator aIt;
-      for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
-        ResultPtr aResult = *aIt;
-        if (aResult.get() && aResult->shape().get())
-          anAuxiliaryResults.push_back(aResult);
-      }
-    }
-    else {
-    /// append not-edges shapes, e.g. center of a circle, an arc, a point feature
-      const std::list<std::shared_ptr<ModelAPI_Result> >& aRes = aFeature->results();
-      std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter = aRes.cbegin();
-      for (; aResIter != aRes.cend(); aResIter++) {
-        std::shared_ptr<ModelAPI_ResultConstruction> aConstr = std::dynamic_pointer_cast<
-            ModelAPI_ResultConstruction>(*aResIter);
-        if (aConstr) {
-          std::shared_ptr<GeomAPI_Shape> aGeomShape = aConstr->shape();
-          if (aGeomShape.get()) {
-            const TopoDS_Shape& aShape = aGeomShape->impl<TopoDS_Shape>();
-            if (aShape.ShapeType() != TopAbs_EDGE)
-              anAuxiliaryResults.push_back(aConstr);
-          }
-        }
-      }
-    }
-  }
+  setAuxiliaryPresentationStyle(false);
 
-  if (anAuxiliaryResults.size() > 0) {
+    // change deviation coefficient to provide more precise circle
+  ModuleBase_Tools::setDefaultDeviationCoefficient(Shape(), Attributes());
+  AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
+
+  if (!myAuxiliaryCompound.IsNull()) {
     setAuxiliaryPresentationStyle(true);
 
-    BRep_Builder aBuilder;
-    TopoDS_Compound aComp;
-    aBuilder.MakeCompound(aComp);
-    std::list<ResultPtr>::const_iterator anIt = anAuxiliaryResults.begin(),
-                                         aLast = anAuxiliaryResults.end();
-    for (; anIt != aLast; anIt++) {
-      ResultPtr aResult = *anIt;
-      if (aResult.get()) {
-        GeomShapePtr aGeomShape = aResult->shape();
-        if (aGeomShape.get()) {
-          const TopoDS_Shape& aShape = aGeomShape->impl<TopoDS_Shape>();
-          if (!aShape.IsNull())
-            aBuilder.Add(aComp, aShape);
-        }
-      }
-    }
-    myAuxiliaryCompound = aComp;
     Handle(Prs3d_Drawer) aDrawer = Attributes();
-    StdPrs_WFDeflectionShape::Add(thePresentation, aComp, aDrawer);
+    StdPrs_WFDeflectionShape::Add(thePresentation, myAuxiliaryCompound, aDrawer);
+  }
+
+  if (isEmptyPresentation) {
+    Events_Error::throwException("An empty AIS presentation: PartSet_ResultSketchPrs");
+    static const Events_ID anEvent = Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION);
+    ModelAPI_EventCreator::get()->sendUpdated(myResult, anEvent);
   }
 }
 
@@ -201,9 +150,9 @@ void PartSet_ResultSketchPrs::ComputeSelection(const Handle(SelectMgr_Selection)
     TopoDS_Compound aComp;
     aBuilder.MakeCompound(aComp);
     aBuilder.Add(aComp, myOriginalShape);
-    std::list<std::shared_ptr<GeomAPI_Shape>>::const_iterator aIt;
-    for (aIt = myFacesList.cbegin(); aIt != myFacesList.cend(); ++aIt) {
-      TopoDS_Shape aFace = (*aIt)->impl<TopoDS_Shape>();
+    
+    for(NCollection_List<TopoDS_Shape>::Iterator anIt(mySketchFaceList); anIt.More(); anIt.Next()) {
+      const TopoDS_Shape& aFace = anIt.Value();
       aBuilder.Add(aComp, aFace);
       // for sketch presentation in the face mode wires should be selectable also
       // accoring to #1343 Improvement of Extrusion and Revolution operations
@@ -291,3 +240,82 @@ void PartSet_ResultSketchPrs::setAuxiliaryPresentationStyle(const bool isAuxilia
     aLineAspect->SetTypeOfLine(aType);
   }
 }
+
+void PartSet_ResultSketchPrs::fillShapes(TopoDS_Shape& theResultShape,
+                                         TopoDS_Compound& theAuxiliaryCompound,
+                                         NCollection_List<TopoDS_Shape>& theFaceList)
+{
+  //if (!aResultShape.IsNull() || !anAuxiliaryCompound.IsNull())
+  std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(myResult);
+  if (!aShapePtr)
+    return;
+
+  theFaceList.Clear();
+  ResultConstructionPtr aConstruction = 
+    std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(myResult);
+  if (aConstruction.get()) {
+    int aFacesNum = aConstruction->facesNum();
+    for(int aFaceIndex = 0; aFaceIndex < aFacesNum; aFaceIndex++) {
+      std::shared_ptr<GeomAPI_Face> aFaceShape = aConstruction->face(aFaceIndex);
+      if (aFaceShape.get()) {
+        TopoDS_Shape aFace = (aFaceShape)->impl<TopoDS_Shape>();
+        theFaceList.Append(aFace);
+      }
+    }
+  }
+  theResultShape = aShapePtr->impl<TopoDS_Shape>();
+
+  /// find auxiliary shapes
+  FeaturePtr aResultFeature = ModelAPI_Feature::feature(myResult);
+  CompositeFeaturePtr aSketchFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>
+                                                                          (aResultFeature);
+  std::list<ResultPtr> anAuxiliaryResults;
+  for (int i = 0; i < aSketchFeature->numberOfSubs(); i++) {
+    FeaturePtr aFeature = aSketchFeature->subFeature(i);
+    if (PartSet_Tools::isAuxiliarySketchEntity(aFeature)) {
+      std::list<ResultPtr> aResults = aFeature->results();
+      std::list<ResultPtr>::const_iterator aIt;
+      for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
+        ResultPtr aResult = *aIt;
+        if (aResult.get() && aResult->shape().get())
+          anAuxiliaryResults.push_back(aResult);
+      }
+    }
+    else {
+    /// append not-edges shapes, e.g. center of a circle, an arc, a point feature
+      const std::list<std::shared_ptr<ModelAPI_Result> >& aRes = aFeature->results();
+      std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter = aRes.cbegin();
+      for (; aResIter != aRes.cend(); aResIter++) {
+        std::shared_ptr<ModelAPI_ResultConstruction> aConstr = std::dynamic_pointer_cast<
+            ModelAPI_ResultConstruction>(*aResIter);
+        if (aConstr) {
+          std::shared_ptr<GeomAPI_Shape> aGeomShape = aConstr->shape();
+          if (aGeomShape.get()) {
+            const TopoDS_Shape& aShape = aGeomShape->impl<TopoDS_Shape>();
+            if (aShape.ShapeType() != TopAbs_EDGE)
+              anAuxiliaryResults.push_back(aConstr);
+          }
+        }
+      }
+    }
+  }
+
+  if (anAuxiliaryResults.size() > 0) {
+    BRep_Builder aBuilder;
+    //TopoDS_Compound aComp;
+    aBuilder.MakeCompound(theAuxiliaryCompound);
+    std::list<ResultPtr>::const_iterator anIt = anAuxiliaryResults.begin(),
+                                         aLast = anAuxiliaryResults.end();
+    for (; anIt != aLast; anIt++) {
+      ResultPtr aResult = *anIt;
+      if (aResult.get()) {
+        GeomShapePtr aGeomShape = aResult->shape();
+        if (aGeomShape.get()) {
+          const TopoDS_Shape& aShape = aGeomShape->impl<TopoDS_Shape>();
+          if (!aShape.IsNull())
+            aBuilder.Add(theAuxiliaryCompound, aShape);
+        }
+      }
+    }
+  }
+}
index d2861823d8156a9b0e0a33d14c0a6f46ba371be4..ce403d192c17513568ae34c585ccf0d6f9516649 100755 (executable)
@@ -57,6 +57,14 @@ private:
   /// \param isAuxiliary a boolean value if the properties are for auxiliary objects
   void setAuxiliaryPresentationStyle(const bool isAuxiliary);
 
+  /// Fills the containers by the current result
+  /// \param theResultShape contains a shape of the result, it will be set as a Shape of AIS_Shape
+  /// \param theAuxiliaryCompound a compound of auxiliary shapes
+  /// \param theFaceList a list of face shapes
+  void PartSet_ResultSketchPrs::fillShapes(TopoDS_Shape& aResultShape,
+                                         TopoDS_Compound& theAuxiliaryCompound,
+                                         NCollection_List<TopoDS_Shape>& theFaceList);
+
   /// Reference to result object
   ResultPtr myResult;
 
@@ -67,7 +75,8 @@ private:
   TopoDS_Compound myAuxiliaryCompound;
 
   /// List of faces
-  std::list<std::shared_ptr<GeomAPI_Shape> > myFacesList;
+  //std::list<std::shared_ptr<GeomAPI_Shape> > myFacesList;
+  NCollection_List<TopoDS_Shape> mySketchFaceList;
 };
 
 
index 79fb1f007313f952ad45671635b398d8ea8c6688..cd9e9482c72377bd3fd02e47939a112b4c2b2913 100755 (executable)
@@ -93,6 +93,8 @@ void XGUI_WorkshopListener::initializeEventListening()
 
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_EMPTY_OPERATION_PRESENTATION));
 }
 
 //******************************************************
@@ -128,6 +130,10 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr<Events_Message>&
     std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
         std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
     onFeatureRedisplayMsg(aUpdMsg);
+  } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION)) {
+    std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
+        std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
+    onFeatureEmptyPresentationMsg(aUpdMsg);
   }
   //Update property panel on corresponding message. If there is no current operation (no
   //property panel), or received message has different feature to the current - do nothing.
@@ -341,6 +347,8 @@ void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI
 
   bool isCustomized = customizeCurrentObject(anObjects, aRedisplayed);
   if (aRedisplayed || isCustomized) {
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION));
+
     //VSV FitAll updated viewer by it self
     if (aFirstVisualizedBody)
       myWorkshop->viewer()->fitAll();
@@ -348,6 +356,7 @@ void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI
       aDisplayer->updateViewer();
   }
 }
+
 //******************************************************
 void XGUI_WorkshopListener::onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
 {
@@ -411,6 +420,7 @@ void XGUI_WorkshopListener::onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_O
   //if (myObjectBrowser)
   //  myObjectBrowser->processEvent(theMsg);
   if (aDisplayed) {
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION));
     //VSV FitAll updated viewer by it self
     if (aFirstVisualizedBody)
       myWorkshop->viewer()->fitAll();
@@ -422,6 +432,34 @@ void XGUI_WorkshopListener::onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_O
   //}
 }
 
+//******************************************************
+void XGUI_WorkshopListener::onFeatureEmptyPresentationMsg(
+                                      const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
+{
+  std::set<ObjectPtr> anObjects = theMsg->objects();
+  std::set<ObjectPtr>::const_iterator aIt;
+#ifdef DEBUG_FEATURE_CREATED
+  QStringList anInfo;
+  for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
+    anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
+  }
+  QString anInfoStr = anInfo.join(";\t");
+  qDebug(QString("onFeatureEmptyPresentationMsg: %1, %2").arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
+#endif
+
+  XGUI_Workshop* aWorkshop = workshop();
+  XGUI_Displayer* aDisplayer = aWorkshop->displayer();
+
+  bool aRedisplayed = false;
+  for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
+    ObjectPtr anObject = *aIt;
+    aRedisplayed = aDisplayer->erase(anObject, false) || aRedisplayed;
+  }
+
+  if (aRedisplayed)
+    aDisplayer->updateViewer();
+}
+
 bool XGUI_WorkshopListener::event(QEvent * theEvent)
 {
   PostponeMessageQtEvent* aPostponedEv = dynamic_cast<PostponeMessageQtEvent*>(theEvent);
index 2567daffbd7d60875dbc580926a562a86e97b374..9601486f80e89b68f491539310f5f744f560478f 100755 (executable)
@@ -48,14 +48,18 @@ protected:
   bool event(QEvent * theEvent);
 
   /// Process feature update message
-  void onFeatureUpdatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& );
+  /// \param theMsg a message with a container of objects
+  void onFeatureUpdatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
 
   /// Process feature created message
-  void onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& );
+  /// \param theMsg a message with a container of objects
+  void onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
 
   /// Process feature redisplay message
-  void onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& );
+  /// \param theMsg a message with a container of objects
+  void onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
 
+  void onFeatureEmptyPresentationMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
   /// Displaus object and fit all viewer if the object is first (update viewer will not be called)
   /// Asks the module whether the object can be displayed
   /// \param theObj an object