]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1440 Crash when edit box with parameter: erase custom presentation if it is...
authornds <nds@opencascade.com>
Mon, 25 Apr 2016 05:39:23 +0000 (08:39 +0300)
committernds <nds@opencascade.com>
Mon, 25 Apr 2016 05:39:23 +0000 (08:39 +0300)
src/PartSet/PartSet_CustomPrs.cpp
src/PartSet/PartSet_OperationPrs.cpp
src/PartSet/PartSet_OperationPrs.h

index e5a52ac7e3e548c387bb20c29e7856bf5aa72825..8c268fd1d2754375195ff041dc945ec1ea0031c9 100755 (executable)
@@ -97,19 +97,23 @@ bool PartSet_CustomPrs::displayPresentation(
   if (!myFeature.get())
     return isModified;
 
+  QMap<ObjectPtr, QList<GeomShapePtr> > aFeatureShapes;
   switch (theFlag) {
     case ModuleBase_IModule::CustomizeArguments:
-      PartSet_OperationPrs::getFeatureShapes(myFeature, myWorkshop, anOperationPrs->featureShapes());
+      PartSet_OperationPrs::getFeatureShapes(myFeature, myWorkshop, aFeatureShapes);
       break;
     case ModuleBase_IModule::CustomizeResults:
-      PartSet_OperationPrs::getResultShapes(myFeature, myWorkshop, anOperationPrs->featureShapes());
+      PartSet_OperationPrs::getResultShapes(myFeature, myWorkshop, aFeatureShapes);
       break;
     case ModuleBase_IModule::CustomizeHighlightedObjects:
-      PartSet_OperationPrs::getHighlightedShapes(myWorkshop, anOperationPrs->featureShapes());
+      PartSet_OperationPrs::getHighlightedShapes(myWorkshop, aFeatureShapes);
       break;
     default:
       return isModified;
   }
+  NCollection_DataMap<TopoDS_Shape, Handle_AIS_InteractiveObject>& aShapeMap =
+                                                                 anOperationPrs->shapesMap();
+  PartSet_OperationPrs::fillShapeList(aFeatureShapes, myWorkshop, aShapeMap);
 
   myPresentationIsEmpty = false;
   // redisplay AIS objects
@@ -170,7 +174,7 @@ void PartSet_CustomPrs::clearPresentation(const ModuleBase_IModule::ModuleBase_C
     Handle(AIS_InteractiveObject) anAISIO = aPresentation->impl<Handle(AIS_InteractiveObject)>();
     Handle(PartSet_OperationPrs) anOperationPrs = Handle(PartSet_OperationPrs)::DownCast(anAISIO);
 
-    anOperationPrs->featureShapes().clear();
+    anOperationPrs->shapesMap().Clear();
     if (!anOperationPrs.IsNull())
       anOperationPrs.Nullify();
     myPresentations.remove(theFlag);
index 7c0de6f9060688abfaf6136a1082482f27cec709..7102e16c03cce8ce8045d3722e2abfb0309affa5 100755 (executable)
@@ -69,7 +69,7 @@ PartSet_OperationPrs::PartSet_OperationPrs(ModuleBase_IWorkshop* theWorkshop)
 
 bool PartSet_OperationPrs::hasShapes()
 {
-  return !myFeatureShapes.empty();
+  return !myShapeToPrsMap.IsEmpty();
 }
 
 void PartSet_OperationPrs::setShapeColor(const Quantity_Color& theColor)
@@ -88,15 +88,7 @@ void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
 {
   SetColor(myShapeColor);
   thePresentation->Clear();
-
-  NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)> aShapeToPrsMap;
-  fillShapeList(myFeatureShapes, aShapeToPrsMap);
-
-  bool aReadyToDisplay = !aShapeToPrsMap.IsEmpty();
-  if (aReadyToDisplay) {
-    myShapeToPrsMap.Clear();
-    myShapeToPrsMap.Assign(aShapeToPrsMap);
-  }
+  bool aReadyToDisplay = !myShapeToPrsMap.IsEmpty();
 
   XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(myWorkshop)->displayer();
   Handle(Prs3d_Drawer) aDrawer = Attributes();
@@ -136,6 +128,11 @@ void PartSet_OperationPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a
   // the presentation is not used in the selection
 }
 
+NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)>& PartSet_OperationPrs::shapesMap()
+{
+  return myShapeToPrsMap;
+}
+
 bool isSubObject(const ObjectPtr& theObject, const FeaturePtr& theFeature)
 {
   bool isSub = false;
@@ -370,16 +367,16 @@ bool PartSet_OperationPrs::isSelectionAttribute(const AttributePtr& theAttribute
 }
 
 void PartSet_OperationPrs::fillShapeList(const QMap<ObjectPtr, QList<GeomShapePtr> >& theFeatureShapes,
+                            ModuleBase_IWorkshop* theWorkshop,
                             NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)>& theShapeToPrsMap)
 {
   theShapeToPrsMap.Clear();
 
-  XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(myWorkshop)->displayer();
-  Handle(Prs3d_Drawer) aDrawer = Attributes();
+  XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(theWorkshop)->displayer();
 
   // create presentations on the base of the shapes
-  QMap<ObjectPtr, QList<GeomShapePtr> >::const_iterator anIt = myFeatureShapes.begin(),
-                                                        aLast = myFeatureShapes.end();
+  QMap<ObjectPtr, QList<GeomShapePtr> >::const_iterator anIt = theFeatureShapes.begin(),
+                                                        aLast = theFeatureShapes.end();
   for (; anIt != aLast; anIt++) {
     ObjectPtr anObject = anIt.key();
     QList<GeomShapePtr> aShapes = anIt.value();
@@ -387,17 +384,18 @@ void PartSet_OperationPrs::fillShapeList(const QMap<ObjectPtr, QList<GeomShapePt
     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
+      // appendShapeIfVisible() on the step of filling theFeatureShapes 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();
+      if (aShape.IsNull())
+        continue;
+
       // 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)>();
-      }
+      AISObjectPtr anAISPtr = aDisplayer->getAISObject(anObject);
+      if (anAISPtr.get())
+        anIO = anAISPtr->impl<Handle(AIS_InteractiveObject)>();
       theShapeToPrsMap.Bind(aShape, anIO);
     }
   }
index 0c49300efa5bd241597d8bb7c66d963b7831766b..cc1416451b8e923a8f083b2d5d2e612d34035b9b 100755 (executable)
@@ -32,6 +32,7 @@
 DEFINE_STANDARD_HANDLE(PartSet_OperationPrs, ViewerData_AISShape)
 
 class XGUI_Displayer;
+class Handle_AIS_InteractiveObject;
 
 /**
 * \ingroup GUI
@@ -70,9 +71,9 @@ protected:
                                                 const Standard_Integer aMode) ;
 
 protected:
-  /// Returns map of feature shapes to be able to fill it outside this class, e.g. in friend
-  /// \return a map of object to shape
-  QMap<ObjectPtr, QList<GeomShapePtr> >& featureShapes() { return myFeatureShapes; }
+  /// list of visualized shapes
+  /// \return a map of shapes
+  NCollection_DataMap<TopoDS_Shape, Handle_AIS_InteractiveObject>& shapesMap();
 
 private:
   /// Fills the map by the feature object and shapes, which should be visuaziled
@@ -133,14 +134,13 @@ private:
   /// 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);
+  static void fillShapeList(const QMap<ObjectPtr, QList<GeomShapePtr> >& theFeatureShapes,
+          ModuleBase_IWorkshop* theWorkshop,
+          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
   Quantity_Color myShapeColor; /// color of feature depended shapes
   bool myUseAISWidth; /// flag if the width of a shape object should be used for the shape visualization