Salome HOME
Issue #1664 In the Sketcher, add the function Split a segment
[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     if (myBool.IsNull())
18       myBool = TDataStd_Integer::Set(myLab, 0);
19     myBool->Set(aValue);
20     owner()->data()->sendAttributeUpdated(this);
21   }
22 }
23
24 bool Model_AttributeBoolean::value()
25 {
26   return myIsInitialized && myBool->Get() == Standard_True ;
27 }
28
29 Model_AttributeBoolean::Model_AttributeBoolean(TDF_Label& theLabel)
30 {
31   myLab = theLabel;
32   // check the attribute could be already presented in this doc (after load document)
33   myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), myBool) == Standard_True;
34 }