X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FModel%2FModel_AttributeBoolean.cpp;h=666b8bb232cbfb5be1e174d33039a3de8f804bab;hb=10671023698288fff01b8717696d150419dc4475;hp=07c482b0741e5aa055866ff295f77a3cde81f79a;hpb=8ef37902d880bc2e74f2ae46880aaee1b4c19307;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeBoolean.cpp b/src/Model/Model_AttributeBoolean.cpp index 07c482b07..666b8bb23 100644 --- a/src/Model/Model_AttributeBoolean.cpp +++ b/src/Model/Model_AttributeBoolean.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: Model_AttributeBoolean.cpp // Created: 2 june 2014 // Author: Vitaly Smetannikov @@ -6,12 +8,12 @@ #include #include -using namespace std; - void Model_AttributeBoolean::setValue(bool theValue) { - Standard_Boolean aValue = theValue ? Standard_True : Standard_False; + Standard_Integer aValue = theValue ? 1 : 0; if (!myIsInitialized || myBool->Get() != aValue) { + if (myBool.IsNull()) + myBool = TDataStd_Integer::Set(myLab, 0); myBool->Set(aValue); owner()->data()->sendAttributeUpdated(this); } @@ -19,15 +21,17 @@ void Model_AttributeBoolean::setValue(bool theValue) bool Model_AttributeBoolean::value() { - return myBool->Get() == Standard_True; + return myIsInitialized && myBool->Get() == 1; } Model_AttributeBoolean::Model_AttributeBoolean(TDF_Label& theLabel) +{ + myLab = theLabel; + reinit(); +} + +void Model_AttributeBoolean::reinit() { // check the attribute could be already presented in this doc (after load document) - myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), myBool) == Standard_True; - if (!myIsInitialized) { - // create attribute: not initialized by value yet, just zero - myBool = TDataStd_Integer::Set(theLabel, 0); - } + myIsInitialized = myLab.FindAttribute(TDataStd_Integer::GetID(), myBool) == Standard_True; }