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;
}
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));
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));
+ }
}
}
}
}
}
-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<ModelAPI_AttributeDouble>(
AttributeDoublePtr aDoubleSecondAttr = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
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
const std::string& theAttr,
std::set<FeaturePtr>& 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