From 796586e4f6328e1fe90a94586a3ad401b4d77650 Mon Sep 17 00:00:00 2001 From: Artem Zhidkov Date: Fri, 3 Jul 2020 11:38:10 +0300 Subject: [PATCH] Task #3231: Sketcher Offset of a curve Decline offset if duplicated entities are selected. --- src/Model/Model_AttributeIntArray.cpp | 2 +- src/SketchPlugin/SketchPlugin_Validators.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Model/Model_AttributeIntArray.cpp b/src/Model/Model_AttributeIntArray.cpp index 82ea6415e..4f4b6b7d0 100644 --- a/src/Model/Model_AttributeIntArray.cpp +++ b/src/Model/Model_AttributeIntArray.cpp @@ -74,7 +74,7 @@ void Model_AttributeIntArray::setValue(const int theIndex, const int theValue, bool sendUpdated) { - if (myArray->Value(theIndex) != theValue) { + if (!isInitialized() || myArray->Value(theIndex) != theValue) { setInitialized(); myArray->SetValue(theIndex, theValue); if (sendUpdated) diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index beaef63a7..4ddedd519 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -519,6 +519,7 @@ bool SketchPlugin_CopyValidator::isValid(const AttributePtr& theAttribute, FeaturePtr aFeature = std::dynamic_pointer_cast(theAttribute->owner()); AttributeRefListPtr aSelAttr = std::dynamic_pointer_cast(theAttribute); + std::set aSelected; AttributeRefListPtr aRefListOfInitial = std::dynamic_pointer_cast( aFeature->attribute(SketchPlugin_Constraint::ENTITY_A())); @@ -530,6 +531,12 @@ bool SketchPlugin_CopyValidator::isValid(const AttributePtr& theAttribute, std::list::iterator anObjIter; for(int anInd = 0; anInd < aSelAttr->size(); anInd++) { ObjectPtr aSelObject = aSelAttr->object(anInd); + if (aSelected.find(aSelObject) != aSelected.end()) { + theError = "Error: An object selected twice"; + return false; + } + aSelected.insert(aSelObject); + anObjIter = anInitialObjects.begin(); for (; anObjIter != anInitialObjects.end(); anObjIter++) if (aSelObject == *anObjIter) -- 2.39.2