myTextArray->SetValue(2, aZ);
owner()->data()->sendAttributeUpdated(this);
// Send it to evaluator to convert into the double and store in the attribute
- static Events_ID anId = ModelAPI_AttributeEvalMessage::eventId();
- std::shared_ptr<ModelAPI_AttributeEvalMessage> aMessage =
- std::shared_ptr<ModelAPI_AttributeEvalMessage>(new ModelAPI_AttributeEvalMessage(anId, this));
- aMessage->setAttribute(owner()->data()->attribute(id())); // to get shared pointer to this
- Events_Loop::loop()->send(aMessage);
+ ModelAPI_AttributeEvalMessage::send(owner()->data()->attribute(id()), this);
}
}
myTextArray->SetValue(1, aY);
owner()->data()->sendAttributeUpdated(this);
// Send it to evaluator to convert into the double and store in the attribute
- static Events_ID anId = ModelAPI_AttributeEvalMessage::eventId();
- std::shared_ptr<ModelAPI_AttributeEvalMessage> aMessage =
- std::shared_ptr<ModelAPI_AttributeEvalMessage>(new ModelAPI_AttributeEvalMessage(anId, this));
- aMessage->setAttribute(owner()->data()->attribute(id())); // to get shared pointer to this
- Events_Loop::loop()->send(aMessage);
+ ModelAPI_AttributeEvalMessage::send(owner()->data()->attribute(id()), this);
}
}
if (myText->Get() != aValue) {
myText->Set(aValue);
owner()->data()->sendAttributeUpdated(this);
+
// Send it to evaluator to convert into the double and store in the attribute
- static Events_ID anId = ModelAPI_AttributeEvalMessage::eventId();
- std::shared_ptr<ModelAPI_AttributeEvalMessage> aMessage =
- std::shared_ptr<ModelAPI_AttributeEvalMessage>(new ModelAPI_AttributeEvalMessage(anId, this));
- aMessage->setAttribute(owner()->data()->attribute(id())); // to get shared pointer to this
- Events_Loop::loop()->send(aMessage);
+ ModelAPI_AttributeEvalMessage::send(owner()->data()->attribute(id()), this);
}
}
Config_Prop::Boolean, "false");
myIsAutomatic =
Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
+ myIsParamUpdated = false;
}
void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessage)
if (!std::dynamic_pointer_cast<ModelAPI_Result>(*anObjIter).get()) {
isOnlyResults = false;
}
+ if ((*anObjIter)->groupName() == ModelAPI_ResultParameter::group()) {
+ myIsParamUpdated = true;
+ }
// created objects are always must be up to date (python box feature)
// and updated not in internal uptation chain
if (theMessage->eventID() == kCreatedEvent) {
}
myJustCreated.clear();
myJustUpdated.clear();
+ myIsParamUpdated = false;
}
}
AttributeDoublePtr aDouble =
std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(*aDoubleIter);
if (aDouble.get() && !aDouble->text().empty()) {
+ if (myIsParamUpdated) {
+ ModelAPI_AttributeEvalMessage::send(aDouble, this);
+ }
if (aDouble->expressionInvalid()) {
aState = ModelAPI_StateInvalidArgument;
}
AttributePointPtr aPointAttribute =
std::dynamic_pointer_cast<GeomDataAPI_Point>(*anIter);
if (aPointAttribute.get()) {
+ if (myIsParamUpdated) {
+ ModelAPI_AttributeEvalMessage::send(aPointAttribute, this);
+ }
if ((!aPointAttribute->textX().empty() && aPointAttribute->expressionInvalid(0)) ||
(!aPointAttribute->textY().empty() && aPointAttribute->expressionInvalid(1)) ||
(!aPointAttribute->textZ().empty() && aPointAttribute->expressionInvalid(2)))
AttributePoint2DPtr aPoint2DAttribute =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIter);
if (aPoint2DAttribute.get()) {
+ if (myIsParamUpdated) {
+ ModelAPI_AttributeEvalMessage::send(aPoint2DAttribute, this);
+ }
if ((!aPoint2DAttribute->textX().empty() && aPoint2DAttribute->expressionInvalid(0)) ||
(!aPoint2DAttribute->textY().empty() && aPoint2DAttribute->expressionInvalid(1)))
aState = ModelAPI_StateInvalidArgument;
bool myIsExecuted;
/// to know execute or not automatically all update
bool myIsAutomatic;
+ /// to know that some parameter was changed during this operation
+ bool myIsParamUpdated;
public:
/// Is called only once, on startup of the application
AttributePtr myAttribute;
public:
- /// Creates an empty message
- MODELAPI_EXPORT ModelAPI_AttributeEvalMessage(const Events_ID theID, const void* theSender = 0);
- /// The virtual destructor
- MODELAPI_EXPORT virtual ~ModelAPI_AttributeEvalMessage();
/// Static. Returns EventID of the message.
- MODELAPI_EXPORT static Events_ID eventId()
+ MODELAPI_EXPORT static Events_ID& eventId()
{
static const char * MY_ATTRIBUTE_EVALUATION_EVENT_ID("AttributeEvaluationRequest");
- return Events_Loop::eventByName(MY_ATTRIBUTE_EVALUATION_EVENT_ID);
+ static Events_ID anId = Events_Loop::eventByName(MY_ATTRIBUTE_EVALUATION_EVENT_ID);
+ return anId;
+ }
+
+ /// usefull method that creates and sends the AttributeEvalMessage event
+ MODELAPI_EXPORT static void send(AttributePtr theAttribute, const void* theSender)
+ {
+ std::shared_ptr<ModelAPI_AttributeEvalMessage> aMessage =
+ std::shared_ptr<ModelAPI_AttributeEvalMessage>(
+ new ModelAPI_AttributeEvalMessage(eventId(), theSender));
+ aMessage->setAttribute(theAttribute);
+ Events_Loop::loop()->send(aMessage);
}
+ /// Creates an empty message
+ MODELAPI_EXPORT ModelAPI_AttributeEvalMessage(const Events_ID theID, const void* theSender = 0);
+ /// The virtual destructor
+ MODELAPI_EXPORT virtual ~ModelAPI_AttributeEvalMessage();
+
/// Returns a document stored in the message
MODELAPI_EXPORT AttributePtr attribute() const;
- /// Sets a document to the message
- MODELAPI_EXPORT void setAttribute(AttributePtr theDocument);
+ /// Sets an attribute to the message
+ MODELAPI_EXPORT void setAttribute(AttributePtr theAttribute);
};
#endif