aLoop->registerListener(this, kOpAbortEvent);
static const Events_ID kOpStartEvent = aLoop->eventByName("StartOperation");
aLoop->registerListener(this, kOpStartEvent);
+ static const Events_ID kStabilityEvent = aLoop->eventByName(EVENT_STABILITY_CHANGED);
+ aLoop->registerListener(this, kStabilityEvent);
+ /* not needed now with history line
Config_PropManager::registerProp("Model update", "automatic_rebuild", "Rebuild immediately",
- Config_Prop::Boolean, "false");
+ Config_Prop::Boolean, "false");*/
myIsAutomatic = true;
// Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
myIsParamUpdated = false;
static const Events_ID kOpFinishEvent = aLoop->eventByName("FinishOperation");
static const Events_ID kOpAbortEvent = aLoop->eventByName("AbortOperation");
static const Events_ID kOpStartEvent = aLoop->eventByName("StartOperation");
+ static const Events_ID kStabilityEvent = aLoop->eventByName(EVENT_STABILITY_CHANGED);
#ifdef DEB_UPDATE
std::cout<<"****** Event "<<theMessage->eventID().eventText()<<std::endl;
#endif
+ if (theMessage->eventID() == kStabilityEvent)
+ updateStability(theMessage->sender());
if (theMessage->eventID() == kChangedEvent) { // automatic and manual rebuild flag is changed
- bool aPropVal =
+ /*bool aPropVal =
Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
if (aPropVal != myIsAutomatic) { // something is changed
// myIsAutomatic = aPropVal;
if (myIsAutomatic) // higher level of automatization => to rebuild
processOperation(false);
- }
+ }*/
+ return;
} else if (theMessage->eventID() == kRebuildEvent) { // the rebuild command
processOperation(true);
} else if (theMessage->eventID() == kCreatedEvent || theMessage->eventID() == kUpdatedEvent ||
}
// for the current breaked, set iteration to this feature precisely
aBreaked->setCurrentBefore(theFeature);
- myModification++;
+ //myModification++;
}
// the iterator that contains breaked is found, so, nothing else is needed
return;
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;
}
}
}
- }
+ } */
// perform update of everything if needed
if (!myIsExecuted) {
#ifdef DEB_UPDATE
// check all features this feature depended on (recursive call of updateFeature)
static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
- if (theFeature->isDisabled())
+ if (theFeature->isDisabled()) {
+ // possibly sub-elements are not disabled?
+ CompositeFeaturePtr aCompos = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
+ if (aCompos)
+ iterateUpdate(aCompos);
return;
+ }
+
+ // do not execute the composite that contains the current
+ bool isPostponedMain = false;
+ CompositeFeaturePtr aMain = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
+ if (theFeature->getKind() == "ExtrusionSketch" && aMain.get()) {
+ CompositeFeaturePtr aCurrentOwner =
+ ModelAPI_Tools::compositeOwner(theFeature->document()->currentFeature(false));
+ isPostponedMain = aCurrentOwner.get() && aMain->isSub(aCurrentOwner);
+ }
#ifdef DEB_UPDATE
- //std::cout<<"Update Feature "<<theFeature->name()<<std::endl;
+ std::cout<<"Update Feature "<<theFeature->name()<<std::endl;
#endif
CompositeFeaturePtr aCompos = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
// If automatice update is not needed and feature attributes were not updated right now,
if (!iterateUpdate(aCompos))
return; // iteration was interrupted, so, interrupt the update of this feature (it will be done later)
// reupdate arguments of composite feature: it may be changed during subs execution
- if (theFeature->data()->execState() != ModelAPI_StateMustBeUpdated)
+
+ // issue 955: extrusion fuse sketch naming must be updated after the sketch update
+ // so, comment this: if (theFeature->data()->execState() != ModelAPI_StateMustBeUpdated)
updateArguments(theFeature);
}
// this checking must be after the composite feature sub-elements processing:
if (aJustUpdated) {
ModelAPI_ExecState aState = theFeature->data()->execState();
if (aFactory->validate(theFeature)) {
+ if (!isPostponedMain) {
+ #ifdef DEB_UPDATE
+ std::cout<<"Execute Feature "<<theFeature->name()<<std::endl;
+ #endif
+ executeFeature(theFeature);
+ }
+ } else {
#ifdef DEB_UPDATE
- std::cout<<"Execute Feature "<<theFeature->name()<<std::endl;
+ std::cout<<"Feature is not valid, erase results "<<theFeature->name()<<std::endl;
#endif
- executeFeature(theFeature);
- } else {
theFeature->eraseResults();
redisplayWithResults(theFeature, ModelAPI_StateInvalidArgument); // result also must be updated
}
} else { // preview is not needed => make state Done
if (theFeature->data()->execState() == ModelAPI_StateMustBeUpdated) {
theFeature->data()->execState(ModelAPI_StateDone);
- if (aJustUpdated) // store that it must be updated on finish
+ if (aJustUpdated) {// store that it must be updated on finish
myUpdated[theFeature] = myModification;
+ aFactory->validate(theFeature); // need to be validated to update the "Apply" state if not previewed
+ }
}
}
}
aState = ModelAPI_StateInvalidArgument;
}
} else if (aSel->isInvalid()) { // not needed to update, but invalid (stated previously)
- aState = ModelAPI_StateInvalidArgument;
+ if (isObligatory)
+ aState = ModelAPI_StateInvalidArgument;
}
}
}
aState = ModelAPI_StateInvalidArgument;
}
} else if (aSelAttr->isInvalid()) {
- aState = ModelAPI_StateInvalidArgument;
+ if (isObligatory)
+ aState = ModelAPI_StateInvalidArgument;
}
}
}
redisplayWithResults(theFeature, aState);
}
+void Model_Update::updateStability(void* theSender)
+{
+ ModelAPI_Object* aSender = static_cast<ModelAPI_Object*>(theSender);
+ if (aSender && aSender->document()) {
+ Model_Objects* aDocObjects =
+ std::dynamic_pointer_cast<Model_Document>(aSender->document())->objects();
+ if (aDocObjects) {
+ aDocObjects->synchronizeBackRefs();
+ }
+ }
+}
+
///////////////// Updated items iterator ////////////////////////
Model_Update::IterationItem::IterationItem(std::shared_ptr<ModelAPI_CompositeFeature> theFeature)
{
break;
}
} else if (mySub.get()) {
- mySub = myObjects->nextFeature(mySub);
+ while(mySub.get()) {
+ mySub = myObjects->nextFeature(mySub);
+ CompositeFeaturePtr anOwner = ModelAPI_Tools::compositeOwner(mySub);
+ // skip sub-objects, that are subs not only for this: sketch elements relatively to PartSet
+ if (!anOwner.get()) {
+ break;
+ }
+ }
}
}
}