Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / Model / Model_AttributeBoolean.cpp
1 // File:        Model_AttributeBoolean.cpp
2 // Created:     2 june 2014
3 // Author:      Vitaly Smetannikov
4
5 #include "Model_AttributeBoolean.h"
6 #include <ModelAPI_Feature.h>
7 #include <ModelAPI_Data.h>
8
9 using namespace std;
10
11 void Model_AttributeBoolean::setValue(bool theValue)
12 {
13   Standard_Boolean aValue = theValue ? Standard_True : Standard_False;
14   if (!myIsInitialized || myBool->Get() != aValue) {
15     myBool->Set(aValue);
16     owner()->data()->sendAttributeUpdated(this);
17   }
18 }
19
20 bool Model_AttributeBoolean::value()
21 {
22   return myBool->Get() == Standard_True;
23 }
24
25 Model_AttributeBoolean::Model_AttributeBoolean(TDF_Label& theLabel)
26 {
27   // check the attribute could be already presented in this doc (after load document)
28   myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), myBool) == Standard_True;
29   if (!myIsInitialized) {
30     // create attribute: not initialized by value yet, just zero
31     myBool = TDataStd_Integer::Set(theLabel, 0);
32   }
33 }