{
ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
- data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId());
+ AttributeDoublePtr aValueAttr = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>
+ (data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId()));
+
data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
aVerAttr->setIsArgument(false);
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VERSION_ID());
if (!aVerAttr->isInitialized()) {
- // this is a newly created feature (not read from file),
- // so, initialize the latest version
- aVerAttr->setValue(THE_VERSION_1);
+ if (aValueAttr->isInitialized()) {
+ // very old feature, read from file
+ aVerAttr->setValue(THE_VERSION_0);
+ }
+ else {
+ // this is a newly created feature (not read from file),
+ // so, initialize the latest version
+ aVerAttr->setValue(THE_VERSION_1);
+ }
}
}
if (!anAttrA->isInitialized() || !anAttrB->isInitialized())
return;
- AttributeIntegerPtr aVersion = integer(VERSION_ID());
- if (!aVersion->isInitialized() || aVersion->value() < THE_VERSION_1)
- updateVersion();
+ updateVersion();
AttributeDoublePtr anAttrValue = real(ANGLE_VALUE_ID());
if (!anAttrValue->isInitialized())
if (!sketch())
return thePrevious;
+ updateVersion();
+
AISObjectPtr anAIS = SketcherPrs_Factory::angleConstraint(this, sketch(),
thePrevious);
if (anAIS.get() && !thePrevious.get())
if (!aLineA || !aLineB)
return;
- AttributeIntegerPtr aVersion = integer(VERSION_ID());
- if (!aVersion->isInitialized() || aVersion->value() < THE_VERSION_1)
- updateVersion();
+ updateVersion();
if (theID == ENTITY_A() || theID == ENTITY_B() ||
theID == TYPE_ID() || theID == ANGLE_VALUE_ID()) {
void SketchPlugin_ConstraintAngle::updateVersion()
{
+ AttributeIntegerPtr aVersion = integer(VERSION_ID());
+ if (aVersion->isInitialized() && aVersion->value() > THE_VERSION_0)
+ return;
+
bool aWasBlocked = data()->blockSendAttributeUpdated(true);
// Calculate angle value by the old algorithm and