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