Salome HOME
Merge branch 'SketchSolver'
[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 "Model_Events.h"
7 #include <Events_Loop.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 (myBool->Get() != aValue) {
15     myBool->Set(aValue);
16     static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
17     Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
18     Events_Loop::loop()->send(aMsg);
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   if (!theLabel.FindAttribute(TDataStd_Integer::GetID(), myBool)) {
31     // create attribute: not initialized by value yet, just zero
32     myBool = TDataStd_Integer::Set(theLabel, 0);
33   }
34 }