#include <ModelAPI_Session.h>
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_Tools.h>
+#include <Model_Validator.h>
#include <GeomDataAPI_Point.h>
#include <GeomDataAPI_Point2D.h>
#include <TDF_AttributeIterator.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDF_RelocationTable.hxx>
+#include <TColStd_HArray1OfByte.hxx>
#include <string>
static const int kFlagInHistory = 0;
// 1 - is displayed or not
static const int kFlagDisplayed = 1;
+// 2 - is deleted (for results) or not
+static const int kFlagDeleted = 2;
// invalid data
const static std::shared_ptr<ModelAPI_Data> kInvalid(new Model_Data());
// set or get the default flags
if (!myLab.FindAttribute(TDataStd_BooleanArray::GetID(), myFlags)) {
// set default values if not found
- myFlags = TDataStd_BooleanArray::Set(myLab, 0, 1);
+ myFlags = TDataStd_BooleanArray::Set(myLab, 0, 2);
myFlags->SetValue(kFlagInHistory, Standard_True); // is in history by default is true
myFlags->SetValue(kFlagDisplayed, Standard_True); // is displayed by default is true
+ myFlags->SetValue(kFlagDeleted, Standard_False); // is deleted by default is false
+ } else if (myFlags->Length() != 3) { // for old formats support
+ Standard_Boolean aFlag0 = myFlags->Upper() >= 0 ? myFlags->Value(0) : Standard_True;
+ Standard_Boolean aFlag1 = myFlags->Upper() >= 1 ? myFlags->Value(1) : Standard_True;
+ Standard_Boolean aFlag2 = myFlags->Upper() >= 2 ? myFlags->Value(2) : Standard_True;
+ Handle(TColStd_HArray1OfByte) aNewArray = new TColStd_HArray1OfByte(0, 2);
+ myFlags->SetInternalArray(aNewArray);
+ myFlags->SetValue(0, aFlag0);
+ myFlags->SetValue(1, aFlag1);
+ myFlags->SetValue(2, aFlag2);
}
}
anAttr = new Model_AttributeInteger(anAttrLab);
} else if (theAttrType == ModelAPI_AttributeDouble::typeId()) {
Model_AttributeDouble* anAttribute = new Model_AttributeDouble(anAttrLab);
- TDF_Label anExpressionLab = anAttrLab.FindChild(anAttrLab.NbChildren() + 1);
+ TDF_Label anExpressionLab = anAttrLab.FindChild(1);
anAttribute->myExpression.reset(new Model_Expression(anExpressionLab));
anAttribute->myIsInitialized = anAttribute->myIsInitialized && anAttribute->myExpression->isInitialized();
anAttr = anAttribute;
else if (theAttrType == GeomData_Point::typeId()) {
GeomData_Point* anAttribute = new GeomData_Point(anAttrLab);
for (int aComponent = 0; aComponent < GeomData_Point::NUM_COMPONENTS; ++aComponent) {
- TDF_Label anExpressionLab = anAttrLab.FindChild(anAttrLab.NbChildren() + 1);
+ TDF_Label anExpressionLab = anAttrLab.FindChild(aComponent + 1);
anAttribute->myExpression[aComponent].reset(new Model_Expression(anExpressionLab));
anAttribute->myIsInitialized = anAttribute->myIsInitialized && anAttribute->myExpression[aComponent]->isInitialized();
}
} else if (theAttrType == GeomData_Point2D::typeId()) {
GeomData_Point2D* anAttribute = new GeomData_Point2D(anAttrLab);
for (int aComponent = 0; aComponent < GeomData_Point2D::NUM_COMPONENTS; ++aComponent) {
- TDF_Label anExpressionLab = anAttrLab.FindChild(anAttrLab.NbChildren() + 1);
+ TDF_Label anExpressionLab = anAttrLab.FindChild(aComponent + 1);
anAttribute->myExpression[aComponent].reset(new Model_Expression(anExpressionLab));
anAttribute->myIsInitialized = anAttribute->myIsInitialized && anAttribute->myExpression[aComponent]->isInitialized();
}
void Model_Data::execState(const ModelAPI_ExecState theState)
{
if (theState != ModelAPI_StateNothing) {
- stateArray(myLab)->SetValue(STATE_INDEX_STATE, (int)theState);
+ if (stateArray(myLab)->Value(STATE_INDEX_STATE) != (int)theState) {
+ stateArray(myLab)->SetValue(STATE_INDEX_STATE, (int)theState);
+ }
+ // send signal even if the new value corresponds to the one in data model: undo issue 980
+ static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED);
+ ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent, false);
}
}
Events_Error::send(theError);
}
TDataStd_AsciiString::Set(myLab, theError.c_str());
+ static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED);
+ ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent, false);
+}
+
+void Model_Data::eraseErrorString()
+{
+ myLab.ForgetAttribute(TDataStd_AsciiString::GetID());
}
std::string Model_Data::error() const
return;
myRefsToMe.insert(theFeature->data()->attribute(theAttrID));
- if (theApplyConcealment &&
+ if (theApplyConcealment && theFeature->isStable() &&
ModelAPI_Session::get()->validators()->isConcealed(theFeature->getKind(), theAttrID)) {
std::shared_ptr<ModelAPI_Result> aRes =
std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
// thus, no concealment references anymore => make not-concealed
std::shared_ptr<ModelAPI_Result> aRes =
std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
- if (aRes.get()) {
+ if (aRes.get() && aRes->isConcealed()) {
aRes->setIsConcealed(false);
static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
ModelAPI_EventCreator::get()->sendUpdated(aRes, anEvent);
}
}
-#include <Model_Validator.h>
-
std::set<std::string> set_union(const std::set<std::string>& theLeft,
const std::set<std::string>& theRight)
{
return myFlags->SetValue(kFlagInHistory, theFlag);
}
+bool Model_Data::isDeleted()
+{
+ return myFlags->Value(kFlagDeleted) == Standard_True;
+}
+
+void Model_Data::setIsDeleted(const bool theFlag)
+{
+ return myFlags->SetValue(kFlagDeleted, theFlag);
+}
+
bool Model_Data::isDisplayed()
{
if (!myObject.get() || !myObject->document().get() || // object is in valid
return kInvalid;
}
-bool Model_Data::isOwner(ModelAPI_Object* theOwner)
+std::shared_ptr<ModelAPI_Object> Model_Data::owner()
{
- return theOwner == myObject.get();
+ return myObject;
}