X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Data.cpp;h=2c973fa3f881e1c170c5fcd8db69860d42101d98;hb=baa32d4d231be0ed859fc32f1736afcbcfaa1f73;hp=504f310d75a53b7b38891b865bef520ee8a266dd;hpb=91968c131d13ed6e682b23f029f8bc441fc9e05d;p=modules%2Fshaper.git diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 504f310d7..2c973fa3f 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -33,14 +33,20 @@ #include #include #include -#include -#include #include // myLab contains: // TDataStd_Name - name of the object // TDataStd_Integer - state of the object execution +// TDataStd_BooleanArray - array of flags of this data: +// 0 - is in history or not +static const int kFlagInHistory = 0; +// 1 - is displayed or not +static const int kFlagDisplayed = 1; + +// invalid data +const static std::shared_ptr kInvalid(new Model_Data()); Model_Data::Model_Data() : mySendAttributeUpdated(true) { @@ -49,6 +55,13 @@ Model_Data::Model_Data() : mySendAttributeUpdated(true) void Model_Data::setLabel(TDF_Label theLab) { myLab = theLab; + // set or get the default flags + if (!myLab.FindAttribute(TDataStd_BooleanArray::GetID(), myFlags)) { + // set default values if not found + myFlags = TDataStd_BooleanArray::Set(myLab, 0, 1); + myFlags->SetValue(kFlagInHistory, Standard_True); // is in history by default is true + myFlags->SetValue(kFlagDisplayed, Standard_True); // is displayed by default is true + } } std::string Model_Data::name() @@ -372,18 +385,33 @@ void Model_Data::copyTo(std::shared_ptr theTarget) } } -const Standard_GUID kIsInHistory("9275e461-4aca-46c7-ad84-1efb569d8144"); - bool Model_Data::isInHistory() { - return !myLab.IsAttribute(kIsInHistory); + return myFlags->Value(kFlagInHistory) == Standard_True; } void Model_Data::setIsInHistory(const bool theFlag) { - if (theFlag) { // is in histiry true: default behavior, so, remove GUID - myLab.ForgetAttribute(kIsInHistory); - } else { // not standard behavior is defined by special GUID attribute - TDataStd_UAttribute::Set(myLab, kIsInHistory); + return myFlags->SetValue(kFlagInHistory, theFlag); +} + +bool Model_Data::isDisplayed() +{ + return myFlags->Value(kFlagDisplayed) == Standard_True; +} + +void Model_Data::setDisplayed(const bool theDisplay) +{ + if (theDisplay != isDisplayed()) { + myFlags->SetValue(kFlagDisplayed, theDisplay); + static Events_Loop* aLoop = Events_Loop::loop(); + static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); + static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get(); + aECreator->sendUpdated(myObject, EVENT_DISP); } } + +std::shared_ptr Model_Data::invalidPtr() +{ + return kInvalid; +}