//==================================================================================================
void FeaturesPlugin_BooleanFuse::initAttributes()
{
- data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId());
-
- data()->addAttribute(OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
- data()->addAttribute(TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
+ AttributeStringPtr aMethodAttr = std::dynamic_pointer_cast<ModelAPI_AttributeString>
+ (data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId())); // #1
+
+ data()->addAttribute(OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); // #2
+ data()->addAttribute(TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); // #3
+
+ AttributeBooleanPtr aREAttr = std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>
+ (data()->addAttribute(REMOVE_INTERSECTION_EDGES_ID(),
+ ModelAPI_AttributeBoolean::typeId())); // #4 ???
+
+ AttributeBooleanPtr aUseFuzzyAttr; // #5 ???
+ AttributeDoublePtr aValFuzzyAttr; // #6 ???
+
+ bool badOrder = false;
+ if (aMethodAttr->isInitialized()) { // restoring data from saved study
+ // It is a fix for 37570 Tuleap issue.
+ // We could have studies with aValFuzzyAttr at the 5th position instead of expected 6th.
+
+ // Fuzzy value (check, is it present at 5th label)
+ aValFuzzyAttr = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>
+ (data()->addAttribute(FUZZY_PARAM_ID(),
+ ModelAPI_AttributeDouble::typeId())); // #5
+ if (aValFuzzyAttr->isInitialized()) {
+ badOrder = true;
+ // bad order of attributes in saved study
+ // 4 - is fuzzy
+ // 5 - fuzzy value
+ // 6 - remove edges
+ aUseFuzzyAttr = std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>
+ (data()->addAttribute(FeaturesPlugin_Boolean::USE_FUZZY_ID(),
+ ModelAPI_AttributeBoolean::typeId(),
+ 4)); // #4
+ aREAttr = std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>
+ (data()->addAttribute(REMOVE_INTERSECTION_EDGES_ID(),
+ ModelAPI_AttributeBoolean::typeId(),
+ 6)); // #6
+ }
+ }
- data()->addAttribute(FeaturesPlugin_Boolean::USE_FUZZY_ID(), ModelAPI_AttributeBoolean::typeId());
- data()->addAttribute(FUZZY_PARAM_ID(), ModelAPI_AttributeDouble::typeId());
- boolean(USE_FUZZY_ID())->setValue(false); // Do NOT use the fuzzy parameter by default.
- real(FUZZY_PARAM_ID())->setValue(DEFAULT_FUZZY);
+ if (!badOrder) {
+ // good order of attributes
+ // 4 - remove edges
+ // 5 - is fuzzy
+ // 6 - fuzzy value
+
+ // Is fuzzy value
+ aUseFuzzyAttr = std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>
+ (data()->addAttribute(FeaturesPlugin_Boolean::USE_FUZZY_ID(),
+ ModelAPI_AttributeBoolean::typeId(),
+ 5)); // #5
+ // Fuzzy value
+ aValFuzzyAttr = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>
+ (data()->addAttribute(FUZZY_PARAM_ID(),
+ ModelAPI_AttributeDouble::typeId(),
+ 6)); // #6
+ }
- data()->addAttribute(REMOVE_INTERSECTION_EDGES_ID(), ModelAPI_AttributeBoolean::typeId());
+ if (!aUseFuzzyAttr->isInitialized())
+ aUseFuzzyAttr->setValue(false); // Do NOT use the fuzzy parameter by default.
+ if (!aValFuzzyAttr->isInitialized())
+ aValFuzzyAttr->setValue(DEFAULT_FUZZY);
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), OBJECT_LIST_ID());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TOOL_LIST_ID());
void SketchPlugin_Offset::initAttributes()
{
- data()->addAttribute(EDGES_ID(), ModelAPI_AttributeRefList::typeId());
- data()->addAttribute(VALUE_ID(), ModelAPI_AttributeDouble::typeId());
- data()->addAttribute(REVERSED_ID(), ModelAPI_AttributeBoolean::typeId());
+ AttributeRefListPtr anEdgesAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>
+ (data()->addAttribute(EDGES_ID(), ModelAPI_AttributeRefList::typeId())); // #1
+ data()->addAttribute(VALUE_ID(), ModelAPI_AttributeDouble::typeId()); // #2
+ data()->addAttribute(REVERSED_ID(), ModelAPI_AttributeBoolean::typeId()); // #3
- // Always initialize approximation to false by default for backward compatibility
- AttributeBooleanPtr approxAttr = std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(
- data()->addAttribute(APPROX_ID(), ModelAPI_AttributeBoolean::typeId()));
- approxAttr->setValue(false);
+ // SketchPlugin_Constraint::ENTITY_A() stores original entities
+
+ bool badOrder = false;
+ if (anEdgesAttr->isInitialized()) { // restoring data from saved study
+ AttributeRefListPtr entaAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>
+ (data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(),
+ ModelAPI_AttributeRefList::typeId())); // #4
+
+ badOrder = !entaAttr->isInitialized();
+ // we have not found AttributeRefList at 4th position,
+ // so, we suppose a study with wrong order of offset attributes
+ }
+
+ AttributeBooleanPtr approxAttr;
+ if (badOrder) {
+ // It is a fix for 37570 Tuleap issue.
+ // We could have studies with approxAttr at the 4th position.
+ // Using directly attribute index 4, we create approxAttr on label #4,
+ // otherwise (with default -1 index) it would be created on the next one.
+ approxAttr = std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>
+ (data()->addAttribute(APPROX_ID(),
+ ModelAPI_AttributeBoolean::typeId(),
+ 4)); // #4
+
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(),
+ ModelAPI_AttributeRefList::typeId(),
+ 5); // #5
+ }
- // store original entities
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefList::typeId());
// store offset entities
data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::typeId());
// store mapping between original entity and index of the corresponding offset entity
(data()->addAttribute(JOINT_ID(), ModelAPI_AttributeString::typeId()));
if (!aJointAttr->isInitialized())
aJointAttr->setValue(JOINT_KEEP_DISTANCE());
+
+ if (!badOrder) {
+ // Good place for approxAttr is here
+ approxAttr = std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>
+ (data()->addAttribute(APPROX_ID(), ModelAPI_AttributeBoolean::typeId()));
+ }
+
+ // Initialize approximation to false by default for backward compatibility
+ if (!approxAttr->isInitialized())
+ approxAttr->setValue(false);
}
void SketchPlugin_Offset::execute()