From: nds Date: Fri, 6 Nov 2015 16:14:03 +0000 (+0300) Subject: #816 In multi-rotation, be able to put the total angle or the step angle (Rotation... X-Git-Tag: V_2.0.0_alfa1~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5b6a4470eabae68a209dbec903a983d60efff2be;p=modules%2Fshaper.git #816 In multi-rotation, be able to put the total angle or the step angle (Rotation only) It must also be possible to enter the full angle value of the multi-rotation, with a toggle button defining the semantic of the angle value (either full rotation or between two consecutive repetitions). For consistency, it should be the same for multi-translation. --- diff --git a/src/SketchPlugin/SketchPlugin_MultiRotation.cpp b/src/SketchPlugin/SketchPlugin_MultiRotation.cpp index e58b5d267..9cd638ca6 100755 --- a/src/SketchPlugin/SketchPlugin_MultiRotation.cpp +++ b/src/SketchPlugin/SketchPlugin_MultiRotation.cpp @@ -68,7 +68,7 @@ void SketchPlugin_MultiRotation::execute() if (attribute(ANGLE_ID())->isInitialized() && !attribute(ANGLE_FULL_ID())->isInitialized()) { myBlockAngle = true; - SketchPlugin_Tools::updateAngleAttribute(attribute(ANGLE_ID()), attribute(ANGLE_FULL_ID()), + SketchPlugin_Tools::updateMultiAttribute(attribute(ANGLE_ID()), attribute(ANGLE_FULL_ID()), aNbCopies, true); myBlockAngle = false; } @@ -329,7 +329,7 @@ void SketchPlugin_MultiRotation::attributeChanged(const std::string& theID) int aNbCopies = integer(NUMBER_OF_OBJECTS_ID())->value() - 1; if (aNbCopies > 0) { myBlockAngle = true; - SketchPlugin_Tools::updateAngleAttribute(attribute(ANGLE_ID()), attribute(ANGLE_FULL_ID()), + SketchPlugin_Tools::updateMultiAttribute(attribute(ANGLE_ID()), attribute(ANGLE_FULL_ID()), aNbCopies, true); myBlockAngle = false; Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); @@ -339,27 +339,32 @@ void SketchPlugin_MultiRotation::attributeChanged(const std::string& theID) int aNbCopies = integer(NUMBER_OF_OBJECTS_ID())->value() - 1; if (aNbCopies > 0) { myBlockAngle = true; - SketchPlugin_Tools::updateAngleAttribute(attribute(ANGLE_FULL_ID()), attribute(ANGLE_ID()), + SketchPlugin_Tools::updateMultiAttribute(attribute(ANGLE_FULL_ID()), attribute(ANGLE_ID()), aNbCopies, false); myBlockAngle = false; Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); } } else if (theID == NUMBER_OF_OBJECTS_ID()) { - AttributeStringPtr aMethodTypeAttr = string(ANGLE_TYPE()); - std::string aMethodType = aMethodTypeAttr->value(); - int aNbCopies = integer(NUMBER_OF_OBJECTS_ID())->value() - 1; - if (aNbCopies > 0) { - myBlockAngle = true; - if (aMethodType == "SingleAngle") - SketchPlugin_Tools::updateAngleAttribute(attribute(ANGLE_ID()), attribute(ANGLE_FULL_ID()), - aNbCopies, true); - else - SketchPlugin_Tools::updateAngleAttribute(attribute(ANGLE_FULL_ID()), attribute(ANGLE_ID()), - aNbCopies, false); - - myBlockAngle = false; - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + if (attribute(NUMBER_OF_OBJECTS_ID())->isInitialized() && + attribute(ANGLE_FULL_ID())->isInitialized() && + attribute(ANGLE_ID())->isInitialized() && + attribute(ANGLE_TYPE())->isInitialized()) { + AttributeStringPtr aMethodTypeAttr = string(ANGLE_TYPE()); + std::string aMethodType = aMethodTypeAttr->value(); + int aNbCopies = integer(NUMBER_OF_OBJECTS_ID())->value() - 1; + if (aNbCopies > 0) { + myBlockAngle = true; + if (aMethodType == "SingleAngle") + SketchPlugin_Tools::updateMultiAttribute(attribute(ANGLE_ID()), attribute(ANGLE_FULL_ID()), + aNbCopies, true); + else { + SketchPlugin_Tools::updateMultiAttribute(attribute(ANGLE_FULL_ID()), attribute(ANGLE_ID()), + aNbCopies, false); + } + myBlockAngle = false; + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + } } } } diff --git a/src/SketchPlugin/SketchPlugin_Tools.cpp b/src/SketchPlugin/SketchPlugin_Tools.cpp index e73349ef3..f6ff15edb 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) return; AttributeDoublePtr aDoubleFirstAttr = std::dynamic_pointer_cast( @@ -115,10 +115,10 @@ 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); } } // namespace SketchPlugin_Tools diff --git a/src/SketchPlugin/SketchPlugin_Tools.h b/src/SketchPlugin/SketchPlugin_Tools.h index 79a4d62b8..17ab8b58f 100644 --- a/src/SketchPlugin/SketchPlugin_Tools.h +++ b/src/SketchPlugin/SketchPlugin_Tools.h @@ -29,16 +29,15 @@ void findCoincidences(const FeaturePtr theStartCoin, const std::string& theAttr, std::set& theList); -/// Changes the second attribute value to full or single angle. If it is corrected to full -/// value, the first angle is miltipied to the number of copies otherwise it is separated by it. +/// Changes the second attribute value to be multiplied or divided by the given value. /// \param theFirstAngleAttribute the source attribute /// \param theSecondAngleAttribute the changed attribute -/// \param theNumberOfCopies a value for modification -/// \param toFullAngle a type of modification -void updateAngleAttribute(const AttributePtr& theFirstAngleAttribute, +/// \param theValue a value for modification +/// \param toMultiply a type of modification +void updateMultiAttribute(const AttributePtr& theFirstAngleAttribute, const AttributePtr& theSecondAngleAttribute, - const int& theNumberOfCopies, - const bool toFullAngle); + const int& theValue, + const bool toMultiply); }; // namespace SketchPlugin_Tools