1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Model_Data.hxx
4 // Created: 21 Mar 2014
5 // Author: Mikhail PONIKAROV
7 #include <Model_Data.h>
8 #include <Model_AttributeDocRef.h>
9 #include <Model_AttributeInteger.h>
10 #include <Model_AttributeDouble.h>
11 #include <Model_AttributeReference.h>
12 #include <Model_AttributeRefAttr.h>
13 #include <Model_AttributeRefList.h>
14 #include <Model_AttributeBoolean.h>
15 #include <Model_AttributeString.h>
16 #include <Model_AttributeSelection.h>
17 #include <Model_AttributeSelectionList.h>
18 #include <Model_AttributeIntArray.h>
19 #include <Model_Events.h>
20 #include <Model_Expression.h>
21 #include <ModelAPI_Feature.h>
22 #include <ModelAPI_Result.h>
23 #include <ModelAPI_ResultParameter.h>
24 #include <ModelAPI_Validator.h>
25 #include <ModelAPI_Session.h>
26 #include <ModelAPI_ResultPart.h>
27 #include <ModelAPI_Tools.h>
28 #include <Model_Validator.h>
30 #include <GeomDataAPI_Point.h>
31 #include <GeomDataAPI_Point2D.h>
33 #include <GeomData_Point.h>
34 #include <GeomData_Point2D.h>
35 #include <GeomData_Dir.h>
36 #include <Events_Loop.h>
37 #include <Events_Error.h>
39 #include <TDataStd_Name.hxx>
40 #include <TDataStd_AsciiString.hxx>
41 #include <TDataStd_IntegerArray.hxx>
42 #include <TDF_AttributeIterator.hxx>
43 #include <TDF_ChildIterator.hxx>
44 #include <TDF_RelocationTable.hxx>
45 #include <TColStd_HArray1OfByte.hxx>
50 // TDataStd_Name - name of the object
51 // TDataStd_IntegerArray - state of the object execution, transaction ID of update
52 // TDataStd_BooleanArray - array of flags of this data:
53 // 0 - is in history or not
54 static const int kFlagInHistory = 0;
55 // 1 - is displayed or not
56 static const int kFlagDisplayed = 1;
57 // 2 - is deleted (for results) or not
58 static const int kFlagDeleted = 2;
61 const static std::shared_ptr<ModelAPI_Data> kInvalid(new Model_Data());
63 Model_Data::Model_Data() : mySendAttributeUpdated(true)
67 void Model_Data::setLabel(TDF_Label theLab)
70 // set or get the default flags
71 if (!myLab.FindAttribute(TDataStd_BooleanArray::GetID(), myFlags)) {
72 // set default values if not found
73 myFlags = TDataStd_BooleanArray::Set(myLab, 0, 2);
74 myFlags->SetValue(kFlagInHistory, Standard_True); // is in history by default is true
75 myFlags->SetValue(kFlagDisplayed, Standard_True); // is displayed by default is true
76 myFlags->SetValue(kFlagDeleted, Standard_False); // is deleted by default is false
77 } else if (myFlags->Length() != 3) { // for old formats support
78 Standard_Boolean aFlag0 = myFlags->Upper() >= 0 ? myFlags->Value(0) : Standard_True;
79 Standard_Boolean aFlag1 = myFlags->Upper() >= 1 ? myFlags->Value(1) : Standard_True;
80 Standard_Boolean aFlag2 = myFlags->Upper() >= 2 ? myFlags->Value(2) : Standard_True;
81 Handle(TColStd_HArray1OfByte) aNewArray = new TColStd_HArray1OfByte(0, 2);
82 myFlags->SetInternalArray(aNewArray);
83 myFlags->SetValue(0, aFlag0);
84 myFlags->SetValue(1, aFlag1);
85 myFlags->SetValue(2, aFlag2);
89 std::string Model_Data::name()
91 Handle(TDataStd_Name) aName;
92 if (myLab.FindAttribute(TDataStd_Name::GetID(), aName))
93 return std::string(TCollection_AsciiString(aName->Get()).ToCString());
94 return ""; // not defined
97 void Model_Data::setName(const std::string& theName)
99 bool isModified = false;
100 std::string anOldName = name();
101 Handle(TDataStd_Name) aName;
102 if (!myLab.FindAttribute(TDataStd_Name::GetID(), aName)) {
103 TDataStd_Name::Set(myLab, theName.c_str());
106 isModified = !aName->Get().IsEqual(theName.c_str());
108 aName->Set(theName.c_str());
110 if (mySendAttributeUpdated && isModified)
111 ModelAPI_ObjectRenamedMessage::send(myObject, anOldName, theName, this);
114 AttributePtr Model_Data::addAttribute(const std::string& theID, const std::string theAttrType)
116 AttributePtr aResult;
117 TDF_Label anAttrLab = myLab.FindChild(myAttrs.size() + 1);
118 ModelAPI_Attribute* anAttr = 0;
119 if (theAttrType == ModelAPI_AttributeDocRef::typeId()) {
120 anAttr = new Model_AttributeDocRef(anAttrLab);
121 } else if (theAttrType == Model_AttributeInteger::typeId()) {
122 anAttr = new Model_AttributeInteger(anAttrLab);
123 } else if (theAttrType == ModelAPI_AttributeDouble::typeId()) {
124 Model_AttributeDouble* anAttribute = new Model_AttributeDouble(anAttrLab);
125 TDF_Label anExpressionLab = anAttrLab.FindChild(1);
126 anAttribute->myExpression.reset(new Model_Expression(anExpressionLab));
127 anAttribute->myIsInitialized = anAttribute->myIsInitialized && anAttribute->myExpression->isInitialized();
128 anAttr = anAttribute;
129 } else if (theAttrType == Model_AttributeBoolean::typeId()) {
130 anAttr = new Model_AttributeBoolean(anAttrLab);
131 } else if (theAttrType == Model_AttributeString::typeId()) {
132 anAttr = new Model_AttributeString(anAttrLab);
133 } else if (theAttrType == ModelAPI_AttributeReference::typeId()) {
134 anAttr = new Model_AttributeReference(anAttrLab);
135 } else if (theAttrType == ModelAPI_AttributeSelection::typeId()) {
136 anAttr = new Model_AttributeSelection(anAttrLab);
137 } else if (theAttrType == ModelAPI_AttributeSelectionList::typeId()) {
138 anAttr = new Model_AttributeSelectionList(anAttrLab);
139 } else if (theAttrType == ModelAPI_AttributeRefAttr::typeId()) {
140 anAttr = new Model_AttributeRefAttr(anAttrLab);
141 } else if (theAttrType == ModelAPI_AttributeRefList::typeId()) {
142 anAttr = new Model_AttributeRefList(anAttrLab);
143 } else if (theAttrType == ModelAPI_AttributeIntArray::typeId()) {
144 anAttr = new Model_AttributeIntArray(anAttrLab);
146 // create also GeomData attributes here because only here the OCAF structure is known
147 else if (theAttrType == GeomData_Point::typeId()) {
148 GeomData_Point* anAttribute = new GeomData_Point(anAttrLab);
149 for (int aComponent = 0; aComponent < GeomData_Point::NUM_COMPONENTS; ++aComponent) {
150 TDF_Label anExpressionLab = anAttrLab.FindChild(aComponent + 1);
151 anAttribute->myExpression[aComponent].reset(new Model_Expression(anExpressionLab));
152 anAttribute->myIsInitialized = anAttribute->myIsInitialized && anAttribute->myExpression[aComponent]->isInitialized();
154 anAttr = anAttribute;
155 } else if (theAttrType == GeomData_Dir::typeId()) {
156 anAttr = new GeomData_Dir(anAttrLab);
157 } else if (theAttrType == GeomData_Point2D::typeId()) {
158 GeomData_Point2D* anAttribute = new GeomData_Point2D(anAttrLab);
159 for (int aComponent = 0; aComponent < GeomData_Point2D::NUM_COMPONENTS; ++aComponent) {
160 TDF_Label anExpressionLab = anAttrLab.FindChild(aComponent + 1);
161 anAttribute->myExpression[aComponent].reset(new Model_Expression(anExpressionLab));
162 anAttribute->myIsInitialized = anAttribute->myIsInitialized && anAttribute->myExpression[aComponent]->isInitialized();
164 anAttr = anAttribute;
167 aResult = std::shared_ptr<ModelAPI_Attribute>(anAttr);
168 myAttrs[theID] = aResult;
169 anAttr->setObject(myObject);
170 anAttr->setID(theID);
172 Events_Error::send("Can not create unknown type of attribute " + theAttrType);
177 // macro for gthe generic returning of the attribute by the ID
178 #define GET_ATTRIBUTE_BY_ID(ATTR_TYPE, METHOD_NAME) \
179 std::shared_ptr<ATTR_TYPE> Model_Data::METHOD_NAME(const std::string& theID) { \
180 std::shared_ptr<ATTR_TYPE> aRes; \
181 std::map<std::string, AttributePtr >::iterator aFound = \
182 myAttrs.find(theID); \
183 if (aFound != myAttrs.end()) { \
184 aRes = std::dynamic_pointer_cast<ATTR_TYPE>(aFound->second); \
188 // implement nice getting methods for all ModelAPI attributes
189 GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeDocRef, document);
190 GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeDouble, real);
191 GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeInteger, integer);
192 GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeBoolean, boolean);
193 GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeString, string);
194 GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeReference, reference);
195 GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeSelection, selection);
196 GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeSelectionList, selectionList);
197 GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeRefAttr, refattr);
198 GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeRefList, reflist);
199 GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeIntArray, intArray);
201 std::shared_ptr<ModelAPI_Attribute> Model_Data::attribute(const std::string& theID)
203 std::shared_ptr<ModelAPI_Attribute> aResult;
204 if (myAttrs.find(theID) == myAttrs.end()) // no such attribute
206 return myAttrs[theID];
209 const std::string& Model_Data::id(const std::shared_ptr<ModelAPI_Attribute>& theAttr)
211 std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr =
213 for (; anAttr != myAttrs.end(); anAttr++) {
214 if (anAttr->second == theAttr)
215 return anAttr->first;
218 static std::string anEmpty;
222 bool Model_Data::isEqual(const std::shared_ptr<ModelAPI_Data>& theData)
224 std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(theData);
226 return myLab.IsEqual(aData->myLab) == Standard_True ;
230 bool Model_Data::isValid()
232 return !myLab.IsNull() && myLab.HasAttribute();
235 std::list<std::shared_ptr<ModelAPI_Attribute> > Model_Data::attributes(const std::string& theType)
237 std::list<std::shared_ptr<ModelAPI_Attribute> > aResult;
238 std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator anAttrsIter =
240 for (; anAttrsIter != myAttrs.end(); anAttrsIter++) {
241 if (theType.empty() || anAttrsIter->second->attributeType() == theType) {
242 aResult.push_back(anAttrsIter->second);
248 std::list<std::string> Model_Data::attributesIDs(const std::string& theType)
250 std::list<std::string> aResult;
251 std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator anAttrsIter =
253 for (; anAttrsIter != myAttrs.end(); anAttrsIter++) {
254 if (theType.empty() || anAttrsIter->second->attributeType() == theType) {
255 aResult.push_back(anAttrsIter->first);
261 void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr)
263 theAttr->setInitialized();
264 if (theAttr->isArgument()) {
265 static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
266 ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
267 if (mySendAttributeUpdated && myObject) {
268 myObject->attributeChanged(theAttr->id());
273 void Model_Data::blockSendAttributeUpdated(const bool theBlock)
275 mySendAttributeUpdated = !theBlock;
278 void Model_Data::erase()
281 myLab.ForgetAllAttributes();
284 // indexes in the state array
286 STATE_INDEX_STATE = 1, // the state type itself
287 STATE_INDEX_TRANSACTION = 2, // transaction ID
290 /// Returns the label array, initialises it by default values if not exists
291 static Handle(TDataStd_IntegerArray) stateArray(TDF_Label& theLab)
293 Handle(TDataStd_IntegerArray) aStateArray;
294 if (!theLab.FindAttribute(TDataStd_IntegerArray::GetID(), aStateArray)) {
295 aStateArray = TDataStd_IntegerArray::Set(theLab, 1, 2);
296 aStateArray->SetValue(STATE_INDEX_STATE, ModelAPI_StateMustBeUpdated); // default state
297 aStateArray->SetValue(STATE_INDEX_TRANSACTION, 0); // default transaction ID (not existing)
302 void Model_Data::execState(const ModelAPI_ExecState theState)
304 if (theState != ModelAPI_StateNothing) {
305 if (stateArray(myLab)->Value(STATE_INDEX_STATE) != (int)theState) {
306 stateArray(myLab)->SetValue(STATE_INDEX_STATE, (int)theState);
308 // send signal even if the new value corresponds to the one in data model: undo issue 980
309 static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED);
310 ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent, false);
314 ModelAPI_ExecState Model_Data::execState()
316 return ModelAPI_ExecState(stateArray(myLab)->Value(STATE_INDEX_STATE));
319 int Model_Data::updateID()
321 return stateArray(myLab)->Value(STATE_INDEX_TRANSACTION);
324 void Model_Data::setUpdateID(const int theID)
326 stateArray(myLab)->SetValue(STATE_INDEX_TRANSACTION, theID);
329 void Model_Data::setError(const std::string& theError, bool theSend)
331 execState(ModelAPI_StateExecFailed);
333 Events_Error::send(theError);
335 TDataStd_AsciiString::Set(myLab, theError.c_str());
336 static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED);
337 ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent, false);
340 void Model_Data::eraseErrorString()
342 myLab.ForgetAttribute(TDataStd_AsciiString::GetID());
345 std::string Model_Data::error() const
347 Handle(TDataStd_AsciiString) anErrorAttr;
348 if (myLab.FindAttribute(TDataStd_AsciiString::GetID(), anErrorAttr)) {
349 return std::string(anErrorAttr->Get().ToCString());
351 return std::string();
354 int Model_Data::featureId() const
356 return myLab.Father().Tag(); // tag of the feature label
359 void Model_Data::eraseBackReferences()
362 std::shared_ptr<ModelAPI_Result> aRes =
363 std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
365 aRes->setIsConcealed(false);
368 void Model_Data::removeBackReference(FeaturePtr theFeature, std::string theAttrID)
370 AttributePtr anAttribute = theFeature->data()->attribute(theAttrID);
371 if (myRefsToMe.find(anAttribute) == myRefsToMe.end())
374 myRefsToMe.erase(anAttribute);
376 // remove concealment immideately: on deselection it must be posible to reselect in GUI the same
377 if (ModelAPI_Session::get()->validators()->isConcealed(theFeature->getKind(), theAttrID)) {
378 updateConcealmentFlag();
382 void Model_Data::addBackReference(FeaturePtr theFeature, std::string theAttrID,
383 const bool theApplyConcealment)
385 // do not add the same attribute twice
386 AttributePtr anAttribute = theFeature->data()->attribute(theAttrID);
387 if (myRefsToMe.find(anAttribute) != myRefsToMe.end())
390 myRefsToMe.insert(theFeature->data()->attribute(theAttrID));
391 if (theApplyConcealment &&
392 ModelAPI_Session::get()->validators()->isConcealed(theFeature->getKind(), theAttrID)) {
393 std::shared_ptr<ModelAPI_Result> aRes =
394 std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
395 // the second condition is for history upper than concealment causer, so the feature result may
396 // be displayed and previewed; also for avoiding of quick show/hide on history
398 if (aRes && !theFeature->isDisabled()) {
399 aRes->setIsConcealed(true);
404 void Model_Data::updateConcealmentFlag()
406 std::set<AttributePtr>::iterator aRefsIter = myRefsToMe.begin();
407 for(; aRefsIter != myRefsToMe.end(); aRefsIter++) {
408 if (aRefsIter->get()) {
409 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRefsIter)->owner());
410 if (aFeature.get() && !aFeature->isDisabled()) {
411 if (ModelAPI_Session::get()->validators()->isConcealed(
412 aFeature->getKind(), (*aRefsIter)->id())) {
413 return; // it is still concealed, nothing to do
418 // thus, no concealment references anymore => make not-concealed
419 std::shared_ptr<ModelAPI_Result> aRes =
420 std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
421 if (aRes.get() && aRes->isConcealed()) {
422 aRes->setIsConcealed(false);
423 static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
424 ModelAPI_EventCreator::get()->sendUpdated(aRes, anEvent);
425 Events_Loop::loop()->flush(anEvent);
429 std::set<std::string> set_union(const std::set<std::string>& theLeft,
430 const std::set<std::string>& theRight)
432 std::set<std::string> aResult;
433 aResult.insert(theLeft.begin(), theLeft.end());
434 aResult.insert(theRight.begin(), theRight.end());
438 std::set<std::string> usedParameters(const AttributePointPtr& theAttribute)
440 std::set<std::string> anUsedParameters;
441 for (int aComponent = 0; aComponent < 3; ++aComponent)
442 anUsedParameters = set_union(anUsedParameters, theAttribute->usedParameters(aComponent));
443 return anUsedParameters;
446 std::set<std::string> usedParameters(const AttributePoint2DPtr& theAttribute)
448 std::set<std::string> anUsedParameters;
449 for (int aComponent = 0; aComponent < 2; ++aComponent)
450 anUsedParameters = set_union(anUsedParameters, theAttribute->usedParameters(aComponent));
451 return anUsedParameters;
454 std::list<ResultParameterPtr> findVariables(const std::set<std::string>& theParameters,
455 const DocumentPtr& theDocument)
457 std::list<ResultParameterPtr> aResult;
458 std::set<std::string>::const_iterator aParamIt = theParameters.cbegin();
459 for (; aParamIt != theParameters.cend(); ++aParamIt) {
460 const std::string& aName = *aParamIt;
462 ResultParameterPtr aParam;
463 if (ModelAPI_Tools::findVariable(aName, aValue, aParam, theDocument))
464 aResult.push_back(aParam);
469 void Model_Data::referencesToObjects(
470 std::list<std::pair<std::string, std::list<ObjectPtr> > >& theRefs)
472 static Model_ValidatorsFactory* aValidators =
473 static_cast<Model_ValidatorsFactory*>(ModelAPI_Session::get()->validators());
474 FeaturePtr aMyFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(myObject);
476 std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = myAttrs.begin();
477 std::list<ObjectPtr> aReferenced; // not inside of cycle to avoid excess memory management
478 for(; anAttr != myAttrs.end(); anAttr++) {
479 // skip not-case attributes, that really may refer to anything not-used (issue 671)
480 if (aMyFeature.get() && !aValidators->isCase(aMyFeature, anAttr->second->id()))
483 std::string aType = anAttr->second->attributeType();
484 if (aType == ModelAPI_AttributeReference::typeId()) { // reference to object
485 std::shared_ptr<ModelAPI_AttributeReference> aRef = std::dynamic_pointer_cast<
486 ModelAPI_AttributeReference>(anAttr->second);
487 aReferenced.push_back(aRef->value());
488 } else if (aType == ModelAPI_AttributeRefAttr::typeId()) { // reference to attribute or object
489 std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = std::dynamic_pointer_cast<
490 ModelAPI_AttributeRefAttr>(anAttr->second);
491 aReferenced.push_back(aRef->isObject() ? aRef->object() : aRef->attr()->owner());
492 } else if (aType == ModelAPI_AttributeRefList::typeId()) { // list of references
493 aReferenced = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttr->second)->list();
494 } else if (aType == ModelAPI_AttributeSelection::typeId()) { // selection attribute
495 std::shared_ptr<ModelAPI_AttributeSelection> aRef = std::dynamic_pointer_cast<
496 ModelAPI_AttributeSelection>(anAttr->second);
497 aReferenced.push_back(aRef->context());
498 } else if (aType == ModelAPI_AttributeSelectionList::typeId()) { // list of selection attributes
499 std::shared_ptr<ModelAPI_AttributeSelectionList> aRef = std::dynamic_pointer_cast<
500 ModelAPI_AttributeSelectionList>(anAttr->second);
501 for(int a = aRef->size() - 1; a >= 0; a--) {
502 aReferenced.push_back(aRef->value(a)->context());
504 } else if (aType == ModelAPI_AttributeDouble::typeId()) { // double attribute
505 AttributeDoublePtr anAttribute =
506 std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(anAttr->second);
507 std::set<std::string> anUsedParameters = anAttribute->usedParameters();
508 std::list<ResultParameterPtr> aParameters = findVariables(anUsedParameters, aMyFeature->document());
509 aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end());
510 } else if (aType == GeomDataAPI_Point::typeId()) { // point attribute
511 AttributePointPtr anAttribute =
512 std::dynamic_pointer_cast<GeomDataAPI_Point>(anAttr->second);
513 std::set<std::string> anUsedParameters = usedParameters(anAttribute);
514 std::list<ResultParameterPtr> aParameters = findVariables(anUsedParameters, aMyFeature->document());
515 aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end());
516 } else if (aType == GeomDataAPI_Point2D::typeId()) { // point attribute
517 AttributePoint2DPtr anAttribute =
518 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->second);
519 std::set<std::string> anUsedParameters = usedParameters(anAttribute);
520 std::list<ResultParameterPtr> aParameters = findVariables(anUsedParameters, aMyFeature->document());
521 aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end());
523 continue; // nothing to do, not reference
525 if (!aReferenced.empty()) {
526 theRefs.push_back(std::pair<std::string, std::list<ObjectPtr> >(anAttr->first, aReferenced));
532 /// makes copy of all attributes on the given label and all sub-labels
533 static void copyAttrs(TDF_Label theSource, TDF_Label theDestination) {
534 TDF_AttributeIterator anAttrIter(theSource);
535 for(; anAttrIter.More(); anAttrIter.Next()) {
536 Handle(TDF_Attribute) aTargetAttr;
537 if (!theDestination.FindAttribute(anAttrIter.Value()->ID(), aTargetAttr)) {
538 // create a new attribute if not yet exists in the destination
539 aTargetAttr = anAttrIter.Value()->NewEmpty();
540 theDestination.AddAttribute(aTargetAttr);
542 Handle(TDF_RelocationTable) aRelocTable = new TDF_RelocationTable(); // no relocation, empty map
543 anAttrIter.Value()->Paste(aTargetAttr, aRelocTable);
545 // copy the sub-labels content
546 TDF_ChildIterator aSubLabsIter(theSource);
547 for(; aSubLabsIter.More(); aSubLabsIter.Next()) {
548 copyAttrs(aSubLabsIter.Value(), theDestination.FindChild(aSubLabsIter.Value().Tag()));
552 void Model_Data::copyTo(std::shared_ptr<ModelAPI_Data> theTarget)
554 TDF_Label aTargetRoot = std::dynamic_pointer_cast<Model_Data>(theTarget)->label();
555 copyAttrs(myLab, aTargetRoot);
556 // make initialized the initialized attributes
557 std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator aMyIter = myAttrs.begin();
558 for(; aMyIter != myAttrs.end(); aMyIter++) {
559 if (aMyIter->second->isInitialized()) {
560 theTarget->attribute(aMyIter->first)->setInitialized();
565 bool Model_Data::isInHistory()
567 return myFlags->Value(kFlagInHistory) == Standard_True;
570 void Model_Data::setIsInHistory(const bool theFlag)
572 return myFlags->SetValue(kFlagInHistory, theFlag);
575 bool Model_Data::isDeleted()
577 return myFlags->Value(kFlagDeleted) == Standard_True;
580 void Model_Data::setIsDeleted(const bool theFlag)
582 return myFlags->SetValue(kFlagDeleted, theFlag);
585 bool Model_Data::isDisplayed()
587 if (!myObject.get() || !myObject->document().get() || // object is in valid
588 myFlags->Value(kFlagDisplayed) != Standard_True) // or it was not displayed before
590 if (myObject->document()->isActive()) // for active documents it must be ok anyway
592 // any object from the root document except part result may be displayed
593 if (myObject->document() == ModelAPI_Session::get()->moduleDocument() &&
594 myObject->groupName() != ModelAPI_ResultPart::group())
599 void Model_Data::setDisplayed(const bool theDisplay)
601 if (theDisplay != isDisplayed()) {
602 myFlags->SetValue(kFlagDisplayed, theDisplay);
603 static Events_Loop* aLoop = Events_Loop::loop();
604 static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
605 static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
606 aECreator->sendUpdated(myObject, EVENT_DISP);
610 std::shared_ptr<ModelAPI_Data> Model_Data::invalidPtr()
615 std::shared_ptr<ModelAPI_Data> Model_Data::invalidData()
620 std::shared_ptr<ModelAPI_Object> Model_Data::owner()