From: nds Date: Mon, 25 Apr 2016 05:39:23 +0000 (+0300) Subject: Issue #1440 Crash when edit box with parameter: erase custom presentation if it is... X-Git-Tag: V_2.3.0~118 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b58a01d9feef4187f2be788f17b1ef60a91be6b8;p=modules%2Fshaper.git Issue #1440 Crash when edit box with parameter: erase custom presentation if it is empty --- diff --git a/src/PartSet/PartSet_CustomPrs.cpp b/src/PartSet/PartSet_CustomPrs.cpp index e5a52ac7e..8c268fd1d 100755 --- a/src/PartSet/PartSet_CustomPrs.cpp +++ b/src/PartSet/PartSet_CustomPrs.cpp @@ -97,19 +97,23 @@ bool PartSet_CustomPrs::displayPresentation( if (!myFeature.get()) return isModified; + QMap > 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& 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(PartSet_OperationPrs) anOperationPrs = Handle(PartSet_OperationPrs)::DownCast(anAISIO); - anOperationPrs->featureShapes().clear(); + anOperationPrs->shapesMap().Clear(); if (!anOperationPrs.IsNull()) anOperationPrs.Nullify(); myPresentations.remove(theFlag); diff --git a/src/PartSet/PartSet_OperationPrs.cpp b/src/PartSet/PartSet_OperationPrs.cpp index 7c0de6f90..7102e16c0 100755 --- a/src/PartSet/PartSet_OperationPrs.cpp +++ b/src/PartSet/PartSet_OperationPrs.cpp @@ -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 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& 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 >& theFeatureShapes, + ModuleBase_IWorkshop* theWorkshop, NCollection_DataMap& 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 >::const_iterator anIt = myFeatureShapes.begin(), - aLast = myFeatureShapes.end(); + QMap >::const_iterator anIt = theFeatureShapes.begin(), + aLast = theFeatureShapes.end(); for (; anIt != aLast; anIt++) { ObjectPtr anObject = anIt.key(); QList aShapes = anIt.value(); @@ -387,17 +384,18 @@ void PartSet_OperationPrs::fillShapeList(const QMapimpl() : 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(); - } + AISObjectPtr anAISPtr = aDisplayer->getAISObject(anObject); + if (anAISPtr.get()) + anIO = anAISPtr->impl(); theShapeToPrsMap.Bind(aShape, anIO); } } diff --git a/src/PartSet/PartSet_OperationPrs.h b/src/PartSet/PartSet_OperationPrs.h index 0c49300ef..cc1416451 100755 --- a/src/PartSet/PartSet_OperationPrs.h +++ b/src/PartSet/PartSet_OperationPrs.h @@ -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 >& featureShapes() { return myFeatureShapes; } + /// list of visualized shapes + /// \return a map of shapes + NCollection_DataMap& 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 >& theFeatureShapes, - NCollection_DataMap& theShapeToPrsMap); + static void fillShapeList(const QMap >& theFeatureShapes, + ModuleBase_IWorkshop* theWorkshop, + NCollection_DataMap& theShapeToPrsMap); private: NCollection_DataMap myShapeToPrsMap; /// list of visualized shapes - QMap > 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