void Model_Data::erase()
{
if (!myLab.IsNull()) {
- // remove in order to clear back references in other objects
- std::list<std::pair<std::string, std::list<ObjectPtr> > > aRefs;
- referencesToObjects(aRefs);
- std::list<std::pair<std::string, std::list<ObjectPtr> > >::iterator anAttrIter = aRefs.begin();
- for(; anAttrIter != aRefs.end(); anAttrIter++) {
- std::list<ObjectPtr>::iterator aReferenced = anAttrIter->second.begin();
- for(; aReferenced != anAttrIter->second.end(); aReferenced++) {
- if (aReferenced->get() && (*aReferenced)->data()->isValid()) {
- std::shared_ptr<Model_Data> aData =
- std::dynamic_pointer_cast<Model_Data>((*aReferenced)->data());
- aData->removeBackReference(myAttrs[anAttrIter->first]);
+ if (myLab.HasAttribute()) {
+ // remove in order to clear back references in other objects
+ std::list<std::pair<std::string, std::list<ObjectPtr> > > aRefs;
+ referencesToObjects(aRefs);
+ std::list<std::pair<std::string, std::list<ObjectPtr> > >::iterator anAttrIter = aRefs.begin();
+ for(; anAttrIter != aRefs.end(); anAttrIter++) {
+ std::list<ObjectPtr>::iterator aReferenced = anAttrIter->second.begin();
+ for(; aReferenced != anAttrIter->second.end(); aReferenced++) {
+ if (aReferenced->get() && (*aReferenced)->data()->isValid()) {
+ std::shared_ptr<Model_Data> aData =
+ std::dynamic_pointer_cast<Model_Data>((*aReferenced)->data());
+ aData->removeBackReference(myAttrs[anAttrIter->first]);
+ }
}
}
}
// redisplay also removed feature (used for sketch and AISObject)
ModelAPI_EventCreator::get()->sendUpdated(aFeature, aRedispEvent);
updateHistory(aFeature);
- // don't call this because it will ask the internal attributes
- //aFeature->erase();
+ aFeature->erase();
// unbind after the "erase" call: on abort sketch is removes sub-objects that corrupts aFIter
myFeatures.UnBind(aFIter.Key());
aLoop->registerListener(this, kOpStartEvent);
static const Events_ID kStabilityEvent = aLoop->eventByName(EVENT_STABILITY_CHANGED);
aLoop->registerListener(this, kStabilityEvent);
+ static const Events_ID kPreviewBlockedEvent = aLoop->eventByName(EVENT_PREVIEW_BLOCKED);
+ aLoop->registerListener(this, kPreviewBlockedEvent);
+ static const Events_ID kPreviewRequestedEvent = aLoop->eventByName(EVENT_PREVIEW_REQUESTED);
+ aLoop->registerListener(this, kPreviewRequestedEvent);
// Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
myIsParamUpdated = false;
myIsFinish = false;
myIsProcessed = false;
+ myIsPreviewBlocked = false;
}
bool Model_Update::addModified(FeaturePtr theFeature, FeaturePtr theReason) {
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);
+ static const Events_ID kPreviewBlockedEvent = aLoop->eventByName(EVENT_PREVIEW_BLOCKED);
+ static const Events_ID kPreviewRequestedEvent = aLoop->eventByName(EVENT_PREVIEW_REQUESTED);
+
#ifdef DEB_UPDATE
std::cout<<"****** Event "<<theMessage->eventID().eventText()<<std::endl;
#endif
updateStability(theMessage->sender());
return;
}
+ if (theMessage->eventID() == kPreviewBlockedEvent) {
+ myIsPreviewBlocked = true;
+ return;
+ }
+ if (theMessage->eventID() == kPreviewRequestedEvent) {
+ if (myIsPreviewBlocked) {
+ myIsPreviewBlocked = false;
+ processFeatures();
+ myIsPreviewBlocked = true;
+ }
+ return;
+ }
// creation is added to "update" to avoid recomputation twice: on create and immediately after on update
if (theMessage->eventID() == kCreatedEvent) {
std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aMsg =
}
} else if (theMessage->eventID() == kOpFinishEvent || theMessage->eventID() == kOpAbortEvent ||
theMessage->eventID() == kOpStartEvent) {
+ myIsPreviewBlocked = false;
if (theMessage->eventID() == kOpFinishEvent) {
myIsFinish = true;
void Model_Update::processFeatures()
{
- if (!myIsProcessed) { // perform update of everything if it is not performed right now
+ // perform update of everything if it is not performed right now or any preview is blocked
+ if (!myIsProcessed && !myIsPreviewBlocked) {
myIsProcessed = true;
#ifdef DEB_UPDATE
std::cout<<"****** Start processing"<<std::endl;
std::set<std::shared_ptr<ModelAPI_Feature> > myProcessOnFinish;
/// to avoid infinitive cycling: feature -> count of the processing periods during this update
std::map<std::shared_ptr<ModelAPI_Feature>, int > myProcessed;
+ /// if preview in hte property panel is blocked and any update is postponed until the end of operation
+ bool myIsPreviewBlocked;
public:
/// Is called only once, on startup of the application
void ModelAPI_CompositeFeature::erase()
{
// erase all sub-features
- for(int a = numberOfSubs(); a > 0; a--) {
- FeaturePtr aFeature = subFeature(a - 1);
- if (aFeature.get()) {
- // subs are referenced from sketch, but must be removed for sure, so not checkings
- aFeature->document()->removeFeature(aFeature);
+ if (data()->isValid()) {
+ for(int a = numberOfSubs(); a > 0; a--) {
+ FeaturePtr aFeature = subFeature(a - 1);
+ if (aFeature.get()) {
+ // subs are referenced from sketch, but must be removed for sure, so not checkings
+ aFeature->document()->removeFeature(aFeature);
+ }
}
}
ModelAPI_Feature::erase();