1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModelAPI_AttributeDocRef.cxx
5 // Author: Mikhail PONIKAROV
7 #include "Model_AttributeDocRef.h"
8 #include "Model_Application.h"
9 #include <ModelAPI_Feature.h>
10 #include <ModelAPI_Data.h>
14 void Model_AttributeDocRef::setValue(std::shared_ptr<ModelAPI_Document> theDoc)
16 if (myID->Get() != theDoc->id()) {
17 myID->Set(theDoc->id());
18 owner()->data()->sendAttributeUpdated(this);
22 std::shared_ptr<ModelAPI_Document> Model_AttributeDocRef::value()
24 return Model_Application::getApplication()->document(myID->Get());
27 int Model_AttributeDocRef::docId()
32 Model_AttributeDocRef::Model_AttributeDocRef(TDF_Label& theLabel)
34 myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), myID) == Standard_True;
35 if (!myIsInitialized) {
36 int aNewID = Model_Application::getApplication()->generateDocumentId();
37 myID = TDataStd_Integer::Set(theLabel, aNewID);