Salome HOME
Merge remote-tracking branch 'remotes/origin/master'
[modules/shaper.git] / src / Model / Model_AttributeDouble.cpp
1 // File:        ModelAPI_AttributeDouble.cxx
2 // Created:     2 Apr 2014
3 // Author:      Mikhail PONIKAROV
4
5 #include "Model_AttributeDouble.h"
6 #include "Model_Events.h"
7 #include <Events_Loop.h>
8
9 using namespace std;
10
11 void Model_AttributeDouble::setValue(const double theValue)
12 {
13   if (myReal->Get() != theValue) {
14     myReal->Set(theValue);
15     static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
16     Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
17     Events_Loop::loop()->send(aMsg);
18   }
19 }
20
21 double Model_AttributeDouble::value()
22 {
23   return myReal->Get();
24 }
25
26 Model_AttributeDouble::Model_AttributeDouble(TDF_Label& theLabel)
27 {
28   // check the attribute could be already presented in this doc (after load document)
29   if (!theLabel.FindAttribute(TDataStd_Real::GetID(), myReal)) {
30     // create attribute: not initialized by value yet, just zero
31     myReal = TDataStd_Real::Set(theLabel, 0.);
32   }
33 }