QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theSelected.begin(),
aLast = theSelected.end();
QList<ModuleBase_ViewerPrsPtr>::const_iterator aSubIt;
+
+ std::set<std::shared_ptr<GeomAPI_Vertex> > aVerticesMap;
for (; anIt != aLast; anIt++) {
aSubIt = anIt;
aSubIt++;
- for (; aSubIt != aLast; aSubIt++) {
- if (isEqualVertices(*anIt, *aSubIt)) {
+ ModuleBase_ViewerPrsPtr aPrs = *anIt;
+ std::shared_ptr<GeomAPI_Vertex> aGeomPrsVertex = getPresentationVertex(aPrs);
+ if (aGeomPrsVertex.get()) {
+ const TopoDS_Vertex& aPrsVertex = aGeomPrsVertex->impl<TopoDS_Vertex>();
+ std::set<std::shared_ptr<GeomAPI_Vertex> >::const_iterator anIt = aVerticesMap.begin(),
+ aLast = aVerticesMap.end();
+ bool aFound = false;
+ for (; anIt != aLast && !aFound; anIt++) {
+ std::shared_ptr<GeomAPI_Vertex> aGeomVertex = *anIt;
+ const TopoDS_Vertex& aVertex = aGeomVertex->impl<TopoDS_Vertex>();
+ gp_Pnt aPoint1 = BRep_Tool::Pnt(aVertex);
+ gp_Pnt aPoint2 = BRep_Tool::Pnt(aPrsVertex);
+
+ std::shared_ptr<GeomAPI_Pnt> aPnt1 = std::shared_ptr<GeomAPI_Pnt>
+ (new GeomAPI_Pnt(aPoint1.X(), aPoint1.Y(), aPoint1.Z()));
+ std::shared_ptr<GeomAPI_Pnt> aPnt2 = std::shared_ptr<GeomAPI_Pnt>
+ (new GeomAPI_Pnt(aPoint2.X(), aPoint2.Y(), aPoint2.Z()));
+ aFound = aPnt1->isEqual(aPnt2);
+ }
+ if (aFound) {
aCandidatesToRemove.append(*aSubIt);
- break;
+ continue;
}
+ aVerticesMap.insert(aGeomPrsVertex);
}
}
QList<ModuleBase_ViewerPrsPtr>::const_iterator aRemIt = aCandidatesToRemove.begin(),
}
}
-bool ModuleBase_ISelection::isEqualVertices(const ModuleBase_ViewerPrsPtr thePrs1,
- const ModuleBase_ViewerPrsPtr thePrs2)
+std::shared_ptr<GeomAPI_Vertex> 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<GeomAPI_Pnt> aPnt1 = std::shared_ptr<GeomAPI_Pnt>
- (new GeomAPI_Pnt(aPoint1.X(), aPoint1.Y(), aPoint1.Z()));
- std::shared_ptr<GeomAPI_Pnt> aPnt2 = std::shared_ptr<GeomAPI_Pnt>
- (new GeomAPI_Pnt(aPoint2.X(), aPoint2.Y(), aPoint2.Z()));
- isEqual = aPnt1->isEqual(aPnt2);
+ std::shared_ptr<GeomAPI_Vertex> 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<GeomAPI_Vertex>(new GeomAPI_Vertex(aPoint.X(), aPoint.Y(),
+ aPoint.Z()));
}
}
}
-
- return isEqual;
+ return aGeomVertex;
}
+
#include <ModelAPI_Result.h>
#include <GeomAPI_Shape.h>
+#include <GeomAPI_Vertex.h>
#include <QModelIndexList>
#include <AIS_ListOfInteractive.hxx>
static MODULEBASE_EXPORT void filterSelectionOnEqualPoints
(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& 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<ModuleBase_ViewerPrs> thePrs1,
- const std::shared_ptr<ModuleBase_ViewerPrs> 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<GeomAPI_Vertex> getPresentationVertex(
+ const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
};
#endif
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;
QList<ModuleBase_ModelWidget*>::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) {
/// remove unused objects from the model attribute.
/// It should be performed before new attributes append.
- removeUnusedAttributeObjects(theValues);
+ bool isDone = removeUnusedAttributeObjects(theValues);
QList<ModuleBase_ViewerPrsPtr> anInvalidValues;
QList<ModuleBase_ViewerPrsPtr> anAttributeValues;
}
bool aHasInvalidValues = anInvalidValues.size() > 0;
- bool isDone = false;
for (anIt = theValues.begin(); anIt != aLast; anIt++) {
ModuleBase_ViewerPrsPtr aValue = *anIt;
bool aProcessed = false;
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;
}
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;
}
}
}
-void ModuleBase_WidgetMultiSelector::removeUnusedAttributeObjects
+bool ModuleBase_WidgetMultiSelector::removeUnusedAttributeObjects
(QList<ModuleBase_ViewerPrsPtr>& theValues)
{
+ bool isDone = false;
+
std::map<ObjectPtr, std::set<GeomShapePtr> > aGeomSelection = convertSelection(theValues);
DataPtr aData = myFeature->data();
AttributePtr anAttribute = aData->attribute(attributeID());
if (!aFound)
anIndicesToBeRemoved.insert(i);
}
+ isDone = anIndicesToBeRemoved.size() > 0;
aSelectionListAttr->remove(anIndicesToBeRemoved);
}
else if (aType == ModelAPI_AttributeRefList::typeId()) {
anIndicesToBeRemoved.insert(i);
}
}
+ isDone = anIndicesToBeRemoved.size() > 0;
aRefListAttr->remove(anIndicesToBeRemoved);
}
else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
if (!aFound)
anIndicesToBeRemoved.insert(i);
}
+ isDone = anIndicesToBeRemoved.size() > 0;
aRefAttrListAttr->remove(anIndicesToBeRemoved);
}
+
+ return isDone;
}
std::map<ObjectPtr, std::set<GeomShapePtr> > ModuleBase_WidgetMultiSelector::convertSelection
/// 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<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
+ /// \return true if at least one object is removed
+ virtual bool removeUnusedAttributeObjects(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
/// Converts viewer presentation selection list to objects and shapes map
/// \param theValues the wrapped selection values