+ if (!myLab.IsNull())
+ myLab.ForgetAllAttributes();
+}
+
+void Model_Data::execState(const ModelAPI_ExecState theState)
+{
+ if (theState != ModelAPI_StateNothing)
+ TDataStd_Integer::Set(myLab, (int)theState);
+}
+
+ModelAPI_ExecState Model_Data::execState()
+{
+ Handle(TDataStd_Integer) aStateAttr;
+ if (myLab.FindAttribute(TDataStd_Integer::GetID(), aStateAttr)) {
+ return ModelAPI_ExecState(aStateAttr->Get());
+ }
+ return ModelAPI_StateMustBeUpdated; // default value
+}
+
+void Model_Data::setError(const std::string& theError)
+{
+ execState(ModelAPI_StateExecFailed);
+ Events_Error::send(theError);
+}
+
+int Model_Data::featureId() const
+{
+ return myLab.Father().Tag(); // tag of the feature label
+}
+
+void Model_Data::eraseBackReferences()
+{
+ myRefsToMe.clear();
+ std::shared_ptr<ModelAPI_Result> aRes =
+ std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
+ if (aRes)
+ aRes->setIsConcealed(false);
+}
+
+void Model_Data::addBackReference(FeaturePtr theFeature, std::string theAttrID)
+{
+ myRefsToMe.insert(theFeature->data()->attribute(theAttrID));
+ if (ModelAPI_Session::get()->validators()->isConcealed(theFeature->getKind(), theAttrID)) {
+ std::shared_ptr<ModelAPI_Result> aRes =
+ std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
+ if (aRes) {
+ aRes->setIsConcealed(true);
+ }
+ }
+}
+
+void Model_Data::referencesToObjects(
+ std::list<std::pair<std::string, std::list<ObjectPtr> > >& theRefs)
+{
+ std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = myAttrs.begin();
+ std::list<ObjectPtr> aReferenced; // not inside of cycle to avoid excess memory menagement
+ for(; anAttr != myAttrs.end(); anAttr++) {
+ std::string aType = anAttr->second->attributeType();
+ if (aType == ModelAPI_AttributeReference::type()) { // reference to object
+ std::shared_ptr<ModelAPI_AttributeReference> aRef = std::dynamic_pointer_cast<
+ ModelAPI_AttributeReference>(anAttr->second);
+ aReferenced.push_back(aRef->value());
+ } else if (aType == ModelAPI_AttributeRefAttr::type()) { // reference to attribute or object
+ std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = std::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(anAttr->second);
+ aReferenced.push_back(aRef->isObject() ? aRef->object() : aRef->attr()->owner());
+ } else if (aType == ModelAPI_AttributeRefList::type()) { // list of references
+ aReferenced = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttr->second)->list();
+ } else if (aType == ModelAPI_AttributeSelection::type()) { // selection attribute
+ std::shared_ptr<ModelAPI_AttributeSelection> aRef = std::dynamic_pointer_cast<
+ ModelAPI_AttributeSelection>(anAttr->second);
+ aReferenced.push_back(aRef->context());
+ } else if (aType == ModelAPI_AttributeSelectionList::type()) { // list of selection attributes
+ std::shared_ptr<ModelAPI_AttributeSelectionList> aRef = std::dynamic_pointer_cast<
+ ModelAPI_AttributeSelectionList>(anAttr->second);
+ for(int a = aRef->size() - 1; a >= 0; a--) {
+ aReferenced.push_back(aRef->value(a)->context());
+ }
+ } else
+ continue; // nothing to do, not reference
+
+ if (!aReferenced.empty()) {
+ theRefs.push_back(std::pair<std::string, std::list<ObjectPtr> >(anAttr->first, aReferenced));
+ aReferenced.clear();
+ }
+ }