Salome HOME
Merge branch 'master' into cgt/devCEA
[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 void Model_AttributeBoolean::setValue(bool theValue)
12 {
13   Standard_Integer aValue = theValue ? 1 : 0;
14   if (!myIsInitialized || myBool->Get() != aValue) {
15     if (myBool.IsNull())
16       myBool = TDataStd_Integer::Set(myLab, 0);
17     myBool->Set(aValue);
18     owner()->data()->sendAttributeUpdated(this);
19   }
20 }
21
22 bool Model_AttributeBoolean::value()
23 {
24   return myIsInitialized && myBool->Get() == 1;
25 }
26
27 Model_AttributeBoolean::Model_AttributeBoolean(TDF_Label& theLabel)
28 {
29   myLab = theLabel;
30   reinit();
31 }
32
33 void Model_AttributeBoolean::reinit()
34 {
35   // check the attribute could be already presented in this doc (after load document)
36   myIsInitialized = myLab.FindAttribute(TDataStd_Integer::GetID(), myBool) == Standard_True;
37 }