X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_Tools.cpp;h=a9aa9d90c9227f17193f72ea945b42141ec2fd42;hb=c7a5ff20294ae8270bfb9120b8887f0c9959d658;hp=e73349ef3486a0b58ed47779555dba6a4f34c659;hpb=ca6f311ba3e0cb7011ed452c0349f11827f13b56;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_Tools.cpp b/src/SketchPlugin/SketchPlugin_Tools.cpp index e73349ef3..a9aa9d90c 100644 --- a/src/SketchPlugin/SketchPlugin_Tools.cpp +++ b/src/SketchPlugin/SketchPlugin_Tools.cpp @@ -101,12 +101,12 @@ void findCoincidences(const FeaturePtr theStartCoin, } } -void updateAngleAttribute(const AttributePtr& theFirstAngleAttribute, +void updateMultiAttribute(const AttributePtr& theFirstAngleAttribute, const AttributePtr& theSecondAngleAttribute, - const int& theNumberOfCopies, - const bool toFullAngle) + const int& theValue, + const bool toMultiply) { - if (theNumberOfCopies == 0) + if (theValue == 0 || !theFirstAngleAttribute->isInitialized()) return; AttributeDoublePtr aDoubleFirstAttr = std::dynamic_pointer_cast( @@ -115,10 +115,43 @@ void updateAngleAttribute(const AttributePtr& theFirstAngleAttribute, AttributeDoublePtr aDoubleSecondAttr = std::dynamic_pointer_cast( theSecondAngleAttribute); - if (toFullAngle) - aDoubleSecondAttr->setValue(aValue*theNumberOfCopies); + if (toMultiply) + aDoubleSecondAttr->setValue(aValue*theValue); else - aDoubleSecondAttr->setValue(aValue/theNumberOfCopies); + aDoubleSecondAttr->setValue(aValue/theValue); +} + +void updateMultiAttribute(const AttributePtr& theFirstAttribute, + const AttributePtr& theSecondAttribute, + const AttributePtr& theModifiedAttribute, + const int& theValue, + const bool toMultiply) +{ + if (theValue == 0 || !theFirstAttribute->isInitialized() + || !theSecondAttribute->isInitialized()) + return; + + std::shared_ptr aFirstPoint = + std::dynamic_pointer_cast(theFirstAttribute); + std::shared_ptr aSecondPoint = + std::dynamic_pointer_cast(theSecondAttribute); + std::shared_ptr aModifiedPoint = + std::dynamic_pointer_cast(theModifiedAttribute); + + if (!aFirstPoint.get() || !aSecondPoint.get() || !aModifiedPoint.get()) + return; + + if (aFirstPoint->pnt()->isEqual(aSecondPoint->pnt())) + aModifiedPoint->setValue(aFirstPoint->pnt()); + else { + double aDx = aSecondPoint->x() - aFirstPoint->x(); + double aDy = aSecondPoint->y() - aFirstPoint->y(); + + double aX = toMultiply ? aDx * theValue : aDx / theValue; + double anY = toMultiply ? aDy * theValue : aDy / theValue; + + aModifiedPoint->setValue(aFirstPoint->x() + aX, aFirstPoint->y() + anY); + } } } // namespace SketchPlugin_Tools