myIsParamUpdated = false;
myIsFinish = false;
myModification = 0;
+ myModificationInStartProcessing = 0;
}
void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessage)
if ((*anObjIter)->groupName() == ModelAPI_ResultParameter::group()) {
myIsParamUpdated = true;
}
+ if (myIsExecuted) // modifications from outside are with never IDs to take them into account in the current updates
+ myModification++;
// on undo/redo, abort do not update persisten features
FeaturePtr anUpdated = std::dynamic_pointer_cast<ModelAPI_Feature>(*anObjIter);
if (std::dynamic_pointer_cast<Model_Document>((*anObjIter)->document())->executeFeatures() ||
void Model_Update::processOperation(const bool theTotalUpdate, const bool theFinish)
{
- /* cancel hardcode due to issue 948
- if (theFinish) {
- // the hardcode (DBC asked): hide the sketch referenced by extrusion on apply
- std::set<std::shared_ptr<ModelAPI_Object> >::iterator aFIter;
- for(aFIter = myWaitForFinish.begin(); aFIter != myWaitForFinish.end(); aFIter++)
- {
- FeaturePtr aF = std::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter);
- if (aF && aF->data()->isValid() &&
- (aF->getKind() == "Extrusion" || aF->getKind() == "Revolution")) {
- AttributeSelectionListPtr aBase = aF->selectionList("base");
- if (aBase.get()) {
- for(int a = aBase->size() - 1; a >= 0; a--) {
- ResultPtr aSketchRes = aBase->value(a)->context();
- if (aSketchRes) {
- aSketchRes->setDisplayed(false);
- }
- }
- }
- }
- }
- } */
// perform update of everything if needed
if (!myIsExecuted) {
#ifdef DEB_UPDATE
std::cout<<"****** Start processing"<<std::endl;
#endif
myIsExecuted = true;
+ myModificationInStartProcessing = myModification;
bool isAutomaticChanged = false;
if (isAutomaticChanged) myIsAutomatic = false;
myIsExecuted = false;
+ // flush updates just before "myModification" increment: to distinguish
+ // updates by "execute" produced by this updater and other updates, coming outside,
+ // which are really important for "processEvent" of this updater
+ static Events_Loop* aLoop = Events_Loop::loop();
+ static const Events_ID kUpdatedEvent = aLoop->eventByName(EVENT_OBJECT_UPDATED);
+ aLoop->flush(kUpdatedEvent);
myModification++;
// flush to update display
- static Events_Loop* aLoop = Events_Loop::loop();
static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
aLoop->flush(EVENT_DISP);
#ifdef DEB_UPDATE
}
}
+bool Model_Update::isProcessed(const int theModificationID)
+{
+ return theModificationID >= myModificationInStartProcessing &&
+ theModificationID <= myModification;
+}
+
void Model_Update::updateFeature(FeaturePtr theFeature)
{
// check all features this feature depended on (recursive call of updateFeature)
// If automatice update is not needed and feature attributes were not updated right now,
// do not execute it and do not update arguments.
if (!myIsAutomatic &&
- (myUpdated.find(theFeature) == myUpdated.end() || myUpdated[theFeature] != myModification)
+ (myUpdated.find(theFeature) == myUpdated.end() || !isProcessed(myUpdated[theFeature]))
&& !aCompos.get()) {
// execute will be performed later, but some features may have not-result
// presentations, so call update for them (like coincidence in the sketcher)
if (aJustUpdated) {
// if preview is not needed, the created feature was not updated before, so, myModification is not actual for this
if (theFeature->isPreviewNeeded()) {
- aJustUpdated = myUpdated[theFeature] == myModification;
+ aJustUpdated = isProcessed(myUpdated[theFeature]);
}
}
std::map<std::shared_ptr<ModelAPI_Object>, int > myUpdated;
/// current id of modification inside of the current transaction
int myModification;
+ /// id of modification inside of the current transaction on start of processing
+ int myModificationInStartProcessing;
/// features that must be additionally processed after execution of finish operation
std::set<std::shared_ptr<ModelAPI_Object> > myWaitForFinish;
/// to know that all next updates are caused by this execution
std::shared_ptr<ModelAPI_Object> theArgument);
/// Updates the properties of object because of stability state changes
void updateStability(void* theSender);
+ /// Returns true if the feature is the given modification ID is processed in the current processOperation
+ bool isProcessed(const int theModificationID);
};
#endif
aNewFeatureB->attribute(aFeatAttributes[2 + (isStart[1] ? 0 : 1)]))->setValue(
aTangentPntB->x(), aTangentPntB->y());
aNewFeatureB->execute();
- // update fillet arc
+ // update fillet arc: make the arc correct for sure, so, it is not needed to process the "attribute updated"
+ // by arc; moreover, it may cause cyclicity in hte mechanism of updater
+ aNewArc->data()->blockSendAttributeUpdated(true);
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aNewArc->attribute(SketchPlugin_Arc::CENTER_ID()))->setValue(
aCenter->x(), aCenter->y());
aNewArc->attribute(SketchPlugin_Arc::START_ID()))->setValue(aTangentPntA->x(), aTangentPntA->y());
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aNewArc->attribute(SketchPlugin_Arc::END_ID()))->setValue(aTangentPntB->x(), aTangentPntB->y());
+ aNewArc->data()->blockSendAttributeUpdated(false);
aNewArc->execute();
if (needNewObjects) {