X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_ISelection.cpp;h=1669c2381cea636b871832c37c1d69505faf146b;hb=1490e92974d2c0bdcdbecd6fa9388e31dccfa363;hp=72f1e4df8337efcd78e60bbe2f48409855b611e5;hpb=c3ae28ba30027cc4a6a757ef623f40adaae96ead;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_ISelection.cpp b/src/ModuleBase/ModuleBase_ISelection.cpp index 72f1e4df8..1669c2381 100644 --- a/src/ModuleBase/ModuleBase_ISelection.cpp +++ b/src/ModuleBase/ModuleBase_ISelection.cpp @@ -2,6 +2,8 @@ #include "ModuleBase_ISelection.h" +#include "ModuleBase_ViewerPrs.h" + #include #include #include @@ -9,58 +11,57 @@ #include //******************************************************************** -void ModuleBase_ISelection::appendSelected(const QList theValues, - QList& theValuesTo) +void ModuleBase_ISelection::appendSelected(const QList theValues, + QList& theValuesTo) { // collect the objects from the viewer QObjectPtrList anExistedObjects; - QList::const_iterator aPrsIt = theValuesTo.begin(), + QList::const_iterator aPrsIt = theValuesTo.begin(), aPrsLast = theValuesTo.end(); for (; aPrsIt != aPrsLast; aPrsIt++) { - if ((*aPrsIt).owner() && (*aPrsIt).object()) - anExistedObjects.push_back((*aPrsIt).object()); + if ((*aPrsIt)->owner() && (*aPrsIt)->object()) + anExistedObjects.push_back((*aPrsIt)->object()); } - QList::const_iterator anIt = theValues.begin(), + QList::const_iterator anIt = theValues.begin(), aLast = theValues.end(); for (; anIt != aLast; anIt++) { - ObjectPtr anObject = (*anIt).object(); + ObjectPtr anObject = (*anIt)->object(); if (anObject.get() != NULL && !anExistedObjects.contains(anObject)) { - theValuesTo.append(ModuleBase_ViewerPrs(anObject, TopoDS_Shape(), NULL)); + theValuesTo.append(std::shared_ptr( + new ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL))); } } } //******************************************************************** -ResultPtr ModuleBase_ISelection::getResult(const ModuleBase_ViewerPrs& thePrs) +ResultPtr ModuleBase_ISelection::getResult(const ModuleBase_ViewerPrsPtr& thePrs) { ResultPtr aResult; - if (!thePrs.owner().IsNull()) { - ObjectPtr anObject = getSelectableObject(thePrs.owner()); + if (thePrs->object().get()) + aResult = std::dynamic_pointer_cast(thePrs->object()); + else if (!thePrs->owner().IsNull()) { + ObjectPtr anObject = getSelectableObject(thePrs->owner()); aResult = std::dynamic_pointer_cast(anObject); } - else { - aResult = std::dynamic_pointer_cast(thePrs.object()); - } return aResult; } //******************************************************************** -GeomShapePtr ModuleBase_ISelection::getShape(const ModuleBase_ViewerPrs& thePrs) +GeomShapePtr ModuleBase_ISelection::getShape(const ModuleBase_ViewerPrsPtr& thePrs) { GeomShapePtr aShape; - const TopoDS_Shape& aTDSShape = thePrs.shape(); + const GeomShapePtr& aPrsShape = thePrs->shape(); // if only result is selected, an empty shape is set to the model - if (aTDSShape.IsNull()) { + if (!aPrsShape.get() || aPrsShape->isNull()) { } else { - aShape = GeomShapePtr(new GeomAPI_Shape()); - aShape->setImpl(new TopoDS_Shape(aTDSShape)); + aShape = aPrsShape; // If the result object is built on the same shape, the result shape here is empty one ResultPtr aResult = getResult(thePrs); if (aResult.get() && aShape->isEqual(aResult->shape())) @@ -70,14 +71,15 @@ GeomShapePtr ModuleBase_ISelection::getShape(const ModuleBase_ViewerPrs& thePrs) } //******************************************************************** -QList ModuleBase_ISelection::getViewerPrs(const QObjectPtrList& theObjects) +QList ModuleBase_ISelection::getViewerPrs(const QObjectPtrList& theObjects) { - QList aSelectedPrs; + QList aSelectedPrs; QObjectPtrList::const_iterator anIt = theObjects.begin(), aLast = theObjects.end(); for (; anIt != aLast; anIt++) { ObjectPtr anObject = *anIt; if (anObject.get() != NULL) { - aSelectedPrs.append(ModuleBase_ViewerPrs(anObject, TopoDS_Shape(), NULL)); + aSelectedPrs.append(std::shared_ptr( + new ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL))); } } return aSelectedPrs; @@ -85,12 +87,12 @@ QList ModuleBase_ISelection::getViewerPrs(const QObjectPtr //******************************************************************** void ModuleBase_ISelection::filterSelectionOnEqualPoints - (QList& theSelected) + (QList& theSelected) { - QList aCandidatesToRemove; - QList::const_iterator anIt = theSelected.begin(), + QList aCandidatesToRemove; + QList::const_iterator anIt = theSelected.begin(), aLast = theSelected.end(); - QList::const_iterator aSubIt; + QList::const_iterator aSubIt; for (; anIt != aLast; anIt++) { aSubIt = anIt; aSubIt++; @@ -101,19 +103,19 @@ void ModuleBase_ISelection::filterSelectionOnEqualPoints } } } - QList::const_iterator aRemIt = aCandidatesToRemove.begin(), + QList::const_iterator aRemIt = aCandidatesToRemove.begin(), aRemLast = aCandidatesToRemove.end(); for (; aRemIt != aRemLast; aRemIt++) { theSelected.removeAll(*aRemIt); } } -bool ModuleBase_ISelection::isEqualVertices(const ModuleBase_ViewerPrs thePrs1, - const ModuleBase_ViewerPrs thePrs2) +bool ModuleBase_ISelection::isEqualVertices(const ModuleBase_ViewerPrsPtr thePrs1, + const ModuleBase_ViewerPrsPtr thePrs2) { bool isEqual = false; - Handle(StdSelect_BRepOwner) anOwner1 = Handle(StdSelect_BRepOwner)::DownCast(thePrs1.owner()); - Handle(StdSelect_BRepOwner) anOwner2 = Handle(StdSelect_BRepOwner)::DownCast(thePrs2.owner()); + 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()) {