1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModelAPI_AttributeDouble.cxx
5 // Author: Mikhail PONIKAROV
7 #include "Model_AttributeDouble.h"
8 #include <ModelAPI_Feature.h>
9 #include <ModelAPI_Data.h>
11 #include <TCollection_AsciiString.hxx>
12 #include <TCollection_ExtendedString.hxx>
16 void Model_AttributeDouble::setValue(const double theValue)
18 if (!myIsInitialized || myReal->Get() != theValue) {
19 myReal->Set(theValue);
20 owner()->data()->sendAttributeUpdated(this);
24 double Model_AttributeDouble::value()
29 Model_AttributeDouble::Model_AttributeDouble(TDF_Label& theLabel)
31 // check the attribute could be already presented in this doc (after load document)
32 myIsInitialized = theLabel.FindAttribute(TDataStd_Real::GetID(), myReal) == Standard_True;
33 if (!myIsInitialized) {
34 // create attribute: not initialized by value yet, just zero
35 myReal = TDataStd_Real::Set(theLabel, 0.);
37 if (!theLabel.FindAttribute(TDataStd_Name::GetID(), myText)) {
38 myText = TDataStd_Name::Set(theLabel, TCollection_ExtendedString());
42 void Model_AttributeDouble::setText(const std::string& theValue)
44 TCollection_ExtendedString aValue(theValue.c_str());
45 if (myText->Get() != aValue) {
47 //owner()->data()->sendAttributeUpdated(this); ?
51 string Model_AttributeDouble::text()
53 return TCollection_AsciiString(myText->Get()).ToCString();