From 1c4fdb35d274c6205676a78e58edc196c28e7c4f Mon Sep 17 00:00:00 2001 From: mpv Date: Mon, 17 Aug 2015 10:49:11 +0300 Subject: [PATCH] Support the temporary compatibility with old saved files to be able to check the currently opened issues. Will be removed later. --- src/Model/Model_Expression.cpp | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/Model/Model_Expression.cpp b/src/Model/Model_Expression.cpp index 1529d3bc0..d87020b64 100644 --- a/src/Model/Model_Expression.cpp +++ b/src/Model/Model_Expression.cpp @@ -11,13 +11,12 @@ #include #include +#include +#include + Model_Expression::Model_Expression(TDF_Label& theLabel) { myIsInitialized = true; - if (!theLabel.FindAttribute(TDataStd_Real::GetID(), myReal)) { - myReal = TDataStd_Real::Set(theLabel, 0.); - myIsInitialized = false; - } if (!theLabel.FindAttribute(TDataStd_Name::GetID(), myText)) { myText = TDataStd_Name::Set(theLabel, TCollection_ExtendedString()); myIsInitialized = false; @@ -30,6 +29,31 @@ Model_Expression::Model_Expression(TDF_Label& theLabel) myUsedParameters = TDataStd_ExtStringList::Set(theLabel); myIsInitialized = false; } + if (!theLabel.FindAttribute(TDataStd_Real::GetID(), myReal)) { + myReal = TDataStd_Real::Set(theLabel, 0.); + myIsInitialized = false; + // MPV: temporarily to support the previously saved files (to check and resolve bugs), to be removed + Handle(TDataStd_RealArray) anOldArray; + if (theLabel.Father().FindAttribute(TDataStd_RealArray::GetID(), anOldArray) == Standard_True) { + myReal->Set(anOldArray->Value(theLabel.Tag() - 1)); + myIsInitialized = true; + Handle(TDataStd_ExtStringArray) anOldExp; + if (theLabel.Father().FindAttribute(TDataStd_ExtStringArray::GetID(), anOldExp) == Standard_True) { + myText->Set(anOldExp->Value(theLabel.Tag() - 1)); + } + } else { + Handle(TDataStd_Real) anOldReal; + if (theLabel.Father().FindAttribute(TDataStd_Real::GetID(), anOldReal)) { + myIsInitialized = true; + myReal->Set(anOldReal->Get()); + Handle(TDataStd_Name) aText; + if (theLabel.Father().FindAttribute(TDataStd_Name::GetID(), aText)) { + myText->Set(aText->Get()); + } + } + } + + } } void Model_Expression::setValue(const double theValue) -- 2.39.2