From 4b628a3f834429f50617717653eb0ceea0d51bd8 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 12 Feb 2016 16:24:20 +0300 Subject: [PATCH] 2.11 Constraint with a point from the intersection between an outer edge and plane of sketch: Using AttributeSelection instead of AttrRef --- src/PartSet/PartSet_SketcherMgr.cpp | 5 ++++- src/SketchPlugin/SketchPlugin_IntersectionPoint.cpp | 10 +++++----- src/SketchPlugin/SketchPlugin_Validators.cpp | 10 +++++----- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index eba4621e3..eaefdeb4a 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -85,6 +85,8 @@ //#define DEBUG_CURSOR +//#define DEBUG_INTERSECTION_POINT + /// Returns list of unique objects by sum of objects from List1 and List2 /*QList getSumList(const QList& theList1, const QList& theList2) @@ -862,8 +864,9 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation) if (myPlaneFilter.IsNull()) myPlaneFilter = new ModuleBase_ShapeInPlaneFilter(); +#ifndef DEBUG_INTERSECTION_POINT myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter); - +#endif bool aHasPlane = false; std::shared_ptr aPln; if (aFOperation->isEditOperation()) { diff --git a/src/SketchPlugin/SketchPlugin_IntersectionPoint.cpp b/src/SketchPlugin/SketchPlugin_IntersectionPoint.cpp index 5c411427c..8310bccf6 100644 --- a/src/SketchPlugin/SketchPlugin_IntersectionPoint.cpp +++ b/src/SketchPlugin/SketchPlugin_IntersectionPoint.cpp @@ -6,7 +6,7 @@ #include "SketchPlugin_IntersectionPoint.h" -#include +#include #include #include @@ -19,7 +19,7 @@ SketchPlugin_IntersectionPoint::SketchPlugin_IntersectionPoint() void SketchPlugin_IntersectionPoint::initDerivedClassAttributes() { - data()->addAttribute(EXTERNAL_LINE_ID(), ModelAPI_AttributeRefAttr::typeId()); + data()->addAttribute(EXTERNAL_LINE_ID(), ModelAPI_AttributeSelection::typeId()); SketchPlugin_Point::initDerivedClassAttributes(); } @@ -50,9 +50,9 @@ void SketchPlugin_IntersectionPoint::attributeChanged(const std::string& theID) void SketchPlugin_IntersectionPoint::computePoint() { - AttributeRefAttrPtr aLineRefAttr = - std::dynamic_pointer_cast(attribute(EXTERNAL_LINE_ID())); - ResultPtr aLineResult = std::dynamic_pointer_cast(aLineRefAttr->object()); + AttributeSelectionPtr aLineAttr = + std::dynamic_pointer_cast(attribute(EXTERNAL_LINE_ID())); + ResultPtr aLineResult = std::dynamic_pointer_cast(aLineAttr->context()); if (!aLineResult) return; diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 13d7138e1..b07e90ac4 100755 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -692,12 +692,12 @@ bool SketchPlugin_IntersectionValidator::isValid(const AttributePtr& theAttribut const std::list& theArguments, std::string& theError) const { - if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) { + if (theAttribute->attributeType() != ModelAPI_AttributeSelection::typeId()) { theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed"; return false; } - AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(theAttribute); - ResultPtr aResult = std::dynamic_pointer_cast(aRefAttr->object()); + AttributeSelectionPtr anAttr = std::dynamic_pointer_cast(theAttribute); + ResultPtr aResult = std::dynamic_pointer_cast(anAttr->context()); if (!aResult) { theError = "The attribute " + theAttribute->id() + " should be an object"; return false; @@ -713,7 +713,7 @@ bool SketchPlugin_IntersectionValidator::isValid(const AttributePtr& theAttribut // find a sketch std::shared_ptr aSketch; - std::set aRefs = aRefAttr->owner()->data()->refsToMe(); + std::set aRefs = anAttr->owner()->data()->refsToMe(); std::set::const_iterator anIt = aRefs.begin(); for (; anIt != aRefs.end(); ++anIt) { CompositeFeaturePtr aComp = @@ -730,5 +730,5 @@ bool SketchPlugin_IntersectionValidator::isValid(const AttributePtr& theAttribut std::shared_ptr aPlane = aSketch->plane(); std::shared_ptr aNormal = aPlane->direction(); - return fabs(aNormal->dot(aLineDir)) > tolerance * tolerance; + return true;//fabs(aNormal->dot(aLineDir)) > tolerance * tolerance; } -- 2.39.2