From: nds Date: Fri, 29 Apr 2016 08:58:01 +0000 (+0300) Subject: Issue #1037 : performance correction to process preselection, correction of shape... X-Git-Tag: V_2.3.0~66 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f519ab572101df2383fa6ad187465b8187005dea;p=modules%2Fshaper.git Issue #1037 : performance correction to process preselection, correction of shape multi selector to update argument presentation by list content change(for the case when result is not redisplayed) --- diff --git a/src/ModuleBase/ModuleBase_ISelection.cpp b/src/ModuleBase/ModuleBase_ISelection.cpp index 1669c2381..1e6a3e3c4 100644 --- a/src/ModuleBase/ModuleBase_ISelection.cpp +++ b/src/ModuleBase/ModuleBase_ISelection.cpp @@ -93,14 +93,35 @@ void ModuleBase_ISelection::filterSelectionOnEqualPoints QList::const_iterator anIt = theSelected.begin(), aLast = theSelected.end(); QList::const_iterator aSubIt; + + std::set > aVerticesMap; for (; anIt != aLast; anIt++) { aSubIt = anIt; aSubIt++; - for (; aSubIt != aLast; aSubIt++) { - if (isEqualVertices(*anIt, *aSubIt)) { + ModuleBase_ViewerPrsPtr aPrs = *anIt; + std::shared_ptr aGeomPrsVertex = getPresentationVertex(aPrs); + if (aGeomPrsVertex.get()) { + const TopoDS_Vertex& aPrsVertex = aGeomPrsVertex->impl(); + std::set >::const_iterator anIt = aVerticesMap.begin(), + aLast = aVerticesMap.end(); + bool aFound = false; + for (; anIt != aLast && !aFound; anIt++) { + std::shared_ptr aGeomVertex = *anIt; + const TopoDS_Vertex& aVertex = aGeomVertex->impl(); + gp_Pnt aPoint1 = BRep_Tool::Pnt(aVertex); + gp_Pnt aPoint2 = BRep_Tool::Pnt(aPrsVertex); + + std::shared_ptr aPnt1 = std::shared_ptr + (new GeomAPI_Pnt(aPoint1.X(), aPoint1.Y(), aPoint1.Z())); + std::shared_ptr aPnt2 = std::shared_ptr + (new GeomAPI_Pnt(aPoint2.X(), aPoint2.Y(), aPoint2.Z())); + aFound = aPnt1->isEqual(aPnt2); + } + if (aFound) { aCandidatesToRemove.append(*aSubIt); - break; + continue; } + aVerticesMap.insert(aGeomPrsVertex); } } QList::const_iterator aRemIt = aCandidatesToRemove.begin(), @@ -110,34 +131,23 @@ void ModuleBase_ISelection::filterSelectionOnEqualPoints } } -bool ModuleBase_ISelection::isEqualVertices(const ModuleBase_ViewerPrsPtr thePrs1, - const ModuleBase_ViewerPrsPtr thePrs2) +std::shared_ptr ModuleBase_ISelection::getPresentationVertex( + const ModuleBase_ViewerPrsPtr& thePrs) { - bool isEqual = false; - Handle(StdSelect_BRepOwner) anOwner1 = Handle(StdSelect_BRepOwner)::DownCast(thePrs1->owner()); - Handle(StdSelect_BRepOwner) anOwner2 = Handle(StdSelect_BRepOwner)::DownCast(thePrs2->owner()); - - if (!anOwner1.IsNull() && anOwner1->HasShape() && - !anOwner2.IsNull() && anOwner2->HasShape()) { - const TopoDS_Shape& aShape1 = anOwner1->Shape(); - const TopoDS_Shape& aShape2 = anOwner2->Shape(); - //TopAbs_ShapeEnum aShapeType = aShape.ShapeType(); - if (aShape1.ShapeType() == TopAbs_VERTEX && - aShape2.ShapeType() == TopAbs_VERTEX) { - const TopoDS_Vertex& aVertex1 = TopoDS::Vertex(aShape1); - const TopoDS_Vertex& aVertex2 = TopoDS::Vertex(aShape2); - if (!aVertex1.IsNull() && !aVertex2.IsNull()) { - gp_Pnt aPoint1 = BRep_Tool::Pnt(aVertex1); - gp_Pnt aPoint2 = BRep_Tool::Pnt(aVertex2); - - std::shared_ptr aPnt1 = std::shared_ptr - (new GeomAPI_Pnt(aPoint1.X(), aPoint1.Y(), aPoint1.Z())); - std::shared_ptr aPnt2 = std::shared_ptr - (new GeomAPI_Pnt(aPoint2.X(), aPoint2.Y(), aPoint2.Z())); - isEqual = aPnt1->isEqual(aPnt2); + std::shared_ptr aGeomVertex; + Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(thePrs->owner()); + + if (!anOwner.IsNull() && anOwner->HasShape()) { + const TopoDS_Shape& aShape = anOwner->Shape(); + if (aShape.ShapeType() == TopAbs_VERTEX) { + const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape); + if (!aVertex.IsNull()) { + gp_Pnt aPoint = BRep_Tool::Pnt(aVertex); + aGeomVertex = std::shared_ptr(new GeomAPI_Vertex(aPoint.X(), aPoint.Y(), + aPoint.Z())); } } } - - return isEqual; + return aGeomVertex; } + diff --git a/src/ModuleBase/ModuleBase_ISelection.h b/src/ModuleBase/ModuleBase_ISelection.h index 510ec76de..abc994373 100644 --- a/src/ModuleBase/ModuleBase_ISelection.h +++ b/src/ModuleBase/ModuleBase_ISelection.h @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -106,11 +107,11 @@ class ModuleBase_ISelection static MODULEBASE_EXPORT void filterSelectionOnEqualPoints (QList>& theSelected); private: - /// Returns true if the presentations have an owner with a vertex and these vertices are equal. - /// \param thePrs1 the first viewer selected presentation - /// \param thePrs2 the second viewer selected presentation - static bool isEqualVertices(const std::shared_ptr thePrs1, - const std::shared_ptr thePrs2); + /// Find vertex shape build by a Brep owner of the presentation if it exists + /// \param thePrs a viewer presentation + /// \return GeomAPI wrap of vertex + static std::shared_ptr getPresentationVertex( + const std::shared_ptr& thePrs); }; #endif diff --git a/src/ModuleBase/ModuleBase_OperationFeature.cpp b/src/ModuleBase/ModuleBase_OperationFeature.cpp index 2508ac0c1..e2f2dd680 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.cpp +++ b/src/ModuleBase/ModuleBase_OperationFeature.cpp @@ -339,8 +339,6 @@ ModuleBase_ModelWidget* ModuleBase_OperationFeature::activateByPreselection( ModuleBase_ModelWidget* aWidget = 0; if (myPreSelection.empty()) return aWidget; - // equal vertices should not be used here - ModuleBase_ISelection::filterSelectionOnEqualPoints(myPreSelection); ModuleBase_IPropertyPanel* aPropertyPanel = propertyPanel(); ModuleBase_ModelWidget* aFilledWgt = 0; @@ -349,6 +347,9 @@ ModuleBase_ModelWidget* ModuleBase_OperationFeature::activateByPreselection( QList::const_iterator aWIt; ModuleBase_ModelWidget* aWgt = 0; if (!aWidgets.empty()) { + // equal vertices should not be used here + ModuleBase_ISelection::filterSelectionOnEqualPoints(myPreSelection); + if (!theGreedAttributeId.empty()) { // set preselection to greed widget for (aWIt = aWidgets.constBegin(); aWIt != aWidgets.constEnd(); ++aWIt) { diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index fa5d77675..180f0ee8b 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -228,7 +228,7 @@ bool ModuleBase_WidgetMultiSelector::setSelection(QList /// remove unused objects from the model attribute. /// It should be performed before new attributes append. - removeUnusedAttributeObjects(theValues); + bool isDone = removeUnusedAttributeObjects(theValues); QList anInvalidValues; QList anAttributeValues; @@ -248,7 +248,6 @@ bool ModuleBase_WidgetMultiSelector::setSelection(QList } bool aHasInvalidValues = anInvalidValues.size() > 0; - bool isDone = false; for (anIt = theValues.begin(); anIt != aLast; anIt++) { ModuleBase_ViewerPrsPtr aValue = *anIt; bool aProcessed = false; @@ -274,6 +273,10 @@ bool ModuleBase_WidgetMultiSelector::setSelection(QList if (!anInvalidValues.empty()) theValues.append(anInvalidValues); + if (isDone) // may be the feature's result is not displayed, but attributes should be + myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeArguments, + true);/// hope that something is redisplayed by object updated + return isDone; } @@ -348,6 +351,10 @@ bool ModuleBase_WidgetMultiSelector::processDelete() restoreValue(); myWorkshop->setSelected(getAttributeSelection()); + + // may be the feature's result is not displayed, but attributes should be + myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeArguments, + true); /// hope that something is redisplayed by object updated } return aDone; } @@ -602,9 +609,11 @@ void ModuleBase_WidgetMultiSelector::convertIndicesToViewerSelection(std::set& theValues) { + bool isDone = false; + std::map > aGeomSelection = convertSelection(theValues); DataPtr aData = myFeature->data(); AttributePtr anAttribute = aData->attribute(attributeID()); @@ -620,6 +629,7 @@ void ModuleBase_WidgetMultiSelector::removeUnusedAttributeObjects if (!aFound) anIndicesToBeRemoved.insert(i); } + isDone = anIndicesToBeRemoved.size() > 0; aSelectionListAttr->remove(anIndicesToBeRemoved); } else if (aType == ModelAPI_AttributeRefList::typeId()) { @@ -632,6 +642,7 @@ void ModuleBase_WidgetMultiSelector::removeUnusedAttributeObjects anIndicesToBeRemoved.insert(i); } } + isDone = anIndicesToBeRemoved.size() > 0; aRefListAttr->remove(anIndicesToBeRemoved); } else if (aType == ModelAPI_AttributeRefAttrList::typeId()) { @@ -660,8 +671,11 @@ void ModuleBase_WidgetMultiSelector::removeUnusedAttributeObjects if (!aFound) anIndicesToBeRemoved.insert(i); } + isDone = anIndicesToBeRemoved.size() > 0; aRefAttrListAttr->remove(anIndicesToBeRemoved); } + + return isDone; } std::map > ModuleBase_WidgetMultiSelector::convertSelection diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index 6a0c9e37c..1fbc337c9 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -148,7 +148,8 @@ protected: /// Iterates throgh the model attribute list and remove elements which do not present in the list /// \param theValues the wrapped selection values - virtual void removeUnusedAttributeObjects(QList>& theValues); + /// \return true if at least one object is removed + virtual bool removeUnusedAttributeObjects(QList>& theValues); /// Converts viewer presentation selection list to objects and shapes map /// \param theValues the wrapped selection values