Salome HOME
Put groups to the separated plugin: Collection
[modules/shaper.git] / src / Model / Model_AttributeDocRef.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelAPI_AttributeDocRef.cxx
4 // Created:     2 Apr 2014
5 // Author:      Mikhail PONIKAROV
6
7 #include "Model_AttributeDocRef.h"
8 #include "Model_Application.h"
9 #include <ModelAPI_Feature.h>
10 #include <ModelAPI_Data.h>
11
12 void Model_AttributeDocRef::setValue(std::shared_ptr<ModelAPI_Document> theDoc)
13 {
14   if (myID->Get() != theDoc->id()) {
15     myID->Set(theDoc->id());
16     owner()->data()->sendAttributeUpdated(this);
17   }
18 }
19
20 std::shared_ptr<ModelAPI_Document> Model_AttributeDocRef::value()
21 {
22   return Model_Application::getApplication()->document(myID->Get());
23 }
24
25 int Model_AttributeDocRef::docId()
26 {
27   return myID->Get();
28 }
29
30 Model_AttributeDocRef::Model_AttributeDocRef(TDF_Label& theLabel)
31 {
32   myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), myID) == Standard_True;
33   if (!myIsInitialized) {
34     int aNewID = Model_Application::getApplication()->generateDocumentId();
35     myID = TDataStd_Integer::Set(theLabel, aNewID);
36   }
37 }
38
39 void Model_AttributeDocRef::reinit()
40 {
41   // myLab is unknown, nevertheless, lose of attribute DocRef for live feature seems impossible
42 }