1 // File: ModelAPI_AttributeReference.cxx
3 // Author: Mikhail PONIKAROV
5 #include "Model_AttributeReference.h"
6 #include "Model_Application.h"
7 #include "Model_Events.h"
8 #include "Model_Data.h"
9 #include <ModelAPI_Feature.h>
13 void Model_AttributeReference::setValue(ObjectPtr theObject)
15 if (!myIsInitialized || value() != theObject) {
16 boost::shared_ptr<Model_Data> aData =
17 boost::dynamic_pointer_cast<Model_Data>(theObject->data());
19 boost::shared_ptr<Model_Data> aMyData =
20 boost::dynamic_pointer_cast<Model_Data>(owner()->data());
21 myRef = TDF_Reference::Set(aMyData->label(), aData->label().Father());
23 myRef->Set(aData->label());
25 owner()->data()->sendAttributeUpdated(this);
29 ObjectPtr Model_AttributeReference::value()
31 if (!myRef.IsNull()) {
32 boost::shared_ptr<Model_Document> aDoc =
33 boost::dynamic_pointer_cast<Model_Document>(owner()->document());
35 TDF_Label aRefLab = myRef->Get();
36 return aDoc->object(aRefLab);
43 Model_AttributeReference::Model_AttributeReference(TDF_Label& theLabel)
45 // not initialized by value yet: attribute is not set to the label!
46 myIsInitialized = theLabel.FindAttribute(TDF_Reference::GetID(), myRef) == Standard_True;