}
-void PartSet_MenuMgr::onLineDetach(QAction* theAction)
+void addRefCoincidentFeatures(const std::set<AttributePtr>& theRefList,
+ std::shared_ptr<GeomAPI_Pnt2d>& theRefPnt,
+ QObjectPtrList& theOutList)
{
- int aId = theAction->data().toInt();
- FeaturePtr aLine = myCoinsideLines.at(aId);
- std::shared_ptr<GeomAPI_Pnt2d> aOrig = PartSet_Tools::getPoint(mySelectedFeature,
- SketchPlugin_ConstraintCoincidence::ENTITY_A());
- if (aOrig.get() == NULL)
- aOrig = PartSet_Tools::getPoint(mySelectedFeature,
- SketchPlugin_ConstraintCoincidence::ENTITY_B());
-
- gp_Pnt aOr = aOrig->impl<gp_Pnt>();
- const std::set<AttributePtr>& aRefsList = aLine->data()->refsToMe();
-
- QObjectPtrList aToDelFeatures;
std::set<AttributePtr>::const_iterator aIt;
- // Find all coincedences corresponded to the selected line in the selected point
- for (aIt = aRefsList.cbegin(); aIt != aRefsList.cend(); ++aIt) {
+ for (aIt = theRefList.cbegin(); aIt != theRefList.cend(); ++aIt) {
std::shared_ptr<ModelAPI_Attribute> aAttr = (*aIt);
FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
- std::shared_ptr<GeomAPI_Pnt2d> aPnt = PartSet_Tools::getPoint(aConstrFeature,
- SketchPlugin_ConstraintCoincidence::ENTITY_A());
- if (aPnt.get() == NULL)
- aPnt = PartSet_Tools::getPoint(aConstrFeature,
- SketchPlugin_ConstraintCoincidence::ENTITY_B());
+ std::shared_ptr<GeomAPI_Pnt2d> aPnt = PartSet_Tools::getCoincedencePoint(aConstrFeature);
if (aPnt.get() == NULL)
return;
gp_Pnt aP = aPnt->impl<gp_Pnt>();
- if (aOrig->isEqual(aPnt)) {
- aToDelFeatures.append(aConstrFeature);
- } else {
- aPnt = PartSet_Tools::getPoint(aConstrFeature,
- SketchPlugin_ConstraintCoincidence::ENTITY_B());
- if (aPnt.get() == NULL)
- return;
- aP = aPnt->impl<gp_Pnt>();
- if (aOrig->isEqual(aPnt)) {
- aToDelFeatures.append(aConstrFeature);
- break;
- }
- }
+ if (theRefPnt->isEqual(aPnt) && (!theOutList.contains(aConstrFeature))) {
+ theOutList.append(aConstrFeature);
+ }
}
}
+}
+
+void PartSet_MenuMgr::onLineDetach(QAction* theAction)
+{
+ int aId = theAction->data().toInt();
+ FeaturePtr aLine = myCoinsideLines.at(aId);
+ std::shared_ptr<GeomAPI_Pnt2d> aOrig = PartSet_Tools::getCoincedencePoint(mySelectedFeature);
+ if (!aOrig.get())
+ return;
+
+ const std::set<AttributePtr>& aRefsList = aLine->data()->refsToMe();
+
+ QObjectPtrList aToDelFeatures;
+
+ addRefCoincidentFeatures(aRefsList, aOrig, aToDelFeatures);
+
+ const std::list<ResultPtr>& aResults = aLine->results();
+ std::list<ResultPtr>::const_iterator aResIt;
+ for (aResIt = aResults.cbegin(); aResIt != aResults.cend(); aResIt++) {
+ ResultPtr aResult = (*aResIt);
+ const std::set<AttributePtr>& aRefList = aResult->data()->refsToMe();
+ addRefCoincidentFeatures(aRefList, aOrig, aToDelFeatures);
+ }
if (aToDelFeatures.size() > 0) {
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
XGUI_Workshop* aWorkshop = aConnector->workshop();
#include <ModelAPI_Session.h>
#include <ModelAPI_ResultConstruction.h>
+#include <SketcherPrs_Tools.h>
+
#include <XGUI_ModuleConnector.h>
#include <XGUI_Displayer.h>
#include <XGUI_Workshop.h>
if (!aPnt) return;
FeaturePtr aObj = ModelAPI_Feature::feature(aPnt->object());
if (!theList.contains(aObj)) {
- std::shared_ptr<GeomAPI_Pnt2d> aOrig = getPoint(theStartCoin, theAttr);
+ std::shared_ptr<GeomAPI_Pnt2d> aOrig = getCoincedencePoint(theStartCoin);
if (aOrig.get() == NULL)
return;
theList.append(aObj);
std::shared_ptr<ModelAPI_Attribute> aAttr = (*aIt);
FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
- std::shared_ptr<GeomAPI_Pnt2d> aPnt = getPoint(aConstrFeature, theAttr);
+ std::shared_ptr<GeomAPI_Pnt2d> aPnt = getCoincedencePoint(aConstrFeature);
if (aPnt.get() && aOrig->isEqual(aPnt)) {
findCoincidences(aConstrFeature, theList, SketchPlugin_ConstraintCoincidence::ENTITY_A());
findCoincidences(aConstrFeature, theList, SketchPlugin_ConstraintCoincidence::ENTITY_B());
}
}
+std::shared_ptr<GeomAPI_Pnt2d> PartSet_Tools::getCoincedencePoint(FeaturePtr theStartCoin)
+{
+ std::shared_ptr<GeomAPI_Pnt2d> aPnt = SketcherPrs_Tools::getPoint(theStartCoin.get(),
+ SketchPlugin_Constraint::ENTITY_A());
+ if (aPnt.get() == NULL)
+ aPnt = SketcherPrs_Tools::getPoint(theStartCoin.get(), SketchPlugin_Constraint::ENTITY_B());
+ return aPnt;
+}
+
AttributePtr PartSet_Tools::findAttributeBy2dPoint(ObjectPtr theObj,
const TopoDS_Shape theShape,
FeaturePtr theSketch)