From 6fb4361dff859e6e0bf70b273e6da53c70afd49f Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 28 Aug 2015 22:33:18 +0300 Subject: [PATCH] It removes excessive code. The problem is Placement feature: it is not possible to select as the second face, a face on the object, which is used in the multi-selectio control. Also, the regression of the issue #359 is corrected[Axis with the same point on both ends] --- src/ModelAPI/ModelAPI_ShapeValidator.cpp | 19 +++++++++++--- src/PartSet/PartSet_Validators.cpp | 32 +----------------------- src/PartSet/PartSet_Validators.h | 6 ----- 3 files changed, 17 insertions(+), 40 deletions(-) diff --git a/src/ModelAPI/ModelAPI_ShapeValidator.cpp b/src/ModelAPI/ModelAPI_ShapeValidator.cpp index 1bd2e50c5..2348819b0 100644 --- a/src/ModelAPI/ModelAPI_ShapeValidator.cpp +++ b/src/ModelAPI/ModelAPI_ShapeValidator.cpp @@ -17,6 +17,11 @@ bool ModelAPI_ShapeValidator::isValid(const AttributePtr& theAttribute, AttributeSelectionPtr aSelectionAttribute = std::dynamic_pointer_cast(theAttribute); GeomShapePtr aShape = aSelectionAttribute->value(); + if (!aShape.get()) { + ResultPtr aResult = aSelectionAttribute->context(); + if (aResult.get()) + aShape = aResult->shape(); + } std::string aCurrentAttributeId = theAttribute->id(); // get all feature attributes @@ -28,11 +33,19 @@ bool ModelAPI_ShapeValidator::isValid(const AttributePtr& theAttribute, AttributePtr anAttribute = *anAttr; // take into concideration only other attributes if (anAttribute.get() != NULL && anAttribute->id() != aCurrentAttributeId) { - AttributeSelectionPtr aSelectionAttribute = + aSelectionAttribute = std::dynamic_pointer_cast(anAttribute); // the shape of the attribute should be not the same - if (aSelectionAttribute.get() != NULL && aShape->isEqual(aSelectionAttribute->value())) { - return false; + if (aSelectionAttribute.get() != NULL) { + GeomShapePtr anAttrShape = aSelectionAttribute->value(); + if (!anAttrShape.get()) { + ResultPtr aResult = aSelectionAttribute->context(); + if (aResult.get()) + anAttrShape = aResult->shape(); + } + if (aShape->isEqual(anAttrShape)) { + return false; + } } } } diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp index 4bb729366..8c5bd25ed 100755 --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -320,37 +320,7 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute } } } - return !featureHasReferences(theAttribute); -} - -bool PartSet_DifferentObjectsValidator::featureHasReferences(const AttributePtr& theAttribute) const -{ - std::list > > allRefs; - if (theAttribute->owner().get() && theAttribute->owner()->data()->isValid()) - theAttribute->owner()->data()->referencesToObjects(allRefs); - // collect object referenced by theAttribute - std::list* anAttrObjs = 0; - std::list > >::iterator aRefIter = allRefs.begin(); - for(; aRefIter != allRefs.end(); aRefIter++) { - if (theAttribute->id() == aRefIter->first) - anAttrObjs = &(aRefIter->second); - } - if (!anAttrObjs || anAttrObjs->empty()) - return false; // theAttribute does not references to anything - // check with all others - for(aRefIter = allRefs.begin(); aRefIter != allRefs.end(); aRefIter++) { - if (theAttribute->id() == aRefIter->first) - continue; // do not check with myself - std::list::iterator aReferenced = aRefIter->second.begin(); - for(; aReferenced != aRefIter->second.end(); aReferenced++) { - std::list::iterator aReferencedByMe = anAttrObjs->begin(); - for(; aReferencedByMe != anAttrObjs->end(); aReferencedByMe++) { - if (*aReferenced == *aReferencedByMe) // found same objects! - return true; - } - } - } - return false; + return true; } bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute, diff --git a/src/PartSet/PartSet_Validators.h b/src/PartSet/PartSet_Validators.h index de46a7660..6ba2896af 100644 --- a/src/PartSet/PartSet_Validators.h +++ b/src/PartSet/PartSet_Validators.h @@ -122,12 +122,6 @@ class PartSet_DifferentObjectsValidator : public ModelAPI_AttributeValidator virtual bool isValid(const AttributePtr& theAttribute, const std::list& theArguments, std::string& theError) const; - -protected: - //! Checks whethe other feature attributes has a reference to the given attribute - //! \param theAttribute a source attribute to find object - //! \return a boolean value - bool featureHasReferences(const AttributePtr& theAttribute) const; }; /** -- 2.39.2