1 // File: ModelAPI_AttributeDocRef.cxx
3 // Author: Mikhail PONIKAROV
5 #include "Model_AttributeDocRef.h"
6 #include "Model_Application.h"
7 #include <ModelAPI_Feature.h>
8 #include <ModelAPI_Data.h>
12 void Model_AttributeDocRef::setValue(boost::shared_ptr<ModelAPI_Document> theDoc)
15 TCollection_ExtendedString aNewID(theDoc->id().c_str());
16 if (!myIsInitialized || myComment->Get() != aNewID) {
17 myComment->Set(TCollection_ExtendedString(theDoc->id().c_str()));
18 owner()->data()->sendAttributeUpdated(this);
22 boost::shared_ptr<ModelAPI_Document> Model_AttributeDocRef::value()
27 Model_AttributeDocRef::Model_AttributeDocRef(TDF_Label& theLabel)
29 myIsInitialized = theLabel.FindAttribute(TDataStd_Comment::GetID(), myComment) == Standard_True;
30 if (!myIsInitialized) {
31 // create attribute: not initialized by value yet, just empty string
32 myComment = TDataStd_Comment::Set(theLabel, "");
33 } else { // document was already referenced: try to set it as loaded by demand
34 Handle(Model_Application) anApp = Model_Application::getApplication();
35 string anID(TCollection_AsciiString(myComment->Get()).ToCString());
36 if (!anApp->hasDocument(anID)) {
37 anApp->setLoadByDemand(anID);