- else if (anEventID == Events_Loop::eventByName(EVENT_OBJECT_CREATED)) {
- PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
- PartSet_SketcherReentrantMgr* aReentrantMgr = aModule->sketchReentranceMgr();
- if (aReentrantMgr->isInternalEditActive()) {
- std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
- std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
- std::set<ObjectPtr> anObjects = aUpdMsg->objects();
- aReentrantMgr->appendCreatedObjects(anObjects);
+ else if (anEventID == ModelAPI_EventReentrantMessage::eventId() ||
+ anEventID == SketchPlugin_MacroArcReentrantMessage::eventId()) {
+ // the message is sent to sketcher reentrant manager only if the name of feature
+ // sender is equal to feature name of the current operation. E.g. Horizontal create operation
+ // is active. Sketch Line feature is changed, so execute is called, it will send message
+ // This Line's message should not be processed, as the reentrant operation is not for Line
+ // It is not enoght of kind, the name should be used, e.g. restarted Lines on auxiliary
+ // cirlce sometimes causes previous line change, kind the same, but feature line is different
+ std::wstring aCurrentFeatureName;
+ ModuleBase_Operation* anOperation =
+ XGUI_Tools::workshop(myWorkshop)->operationMgr()->currentOperation();
+ if (anOperation) {
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+ (anOperation);
+ if (aFOperation) {
+ FeaturePtr aFeature = aFOperation->feature();
+ // data valid is necessary if the feature has been already deleted
+ // (e.g. Esc of Lenght if lenght value is modified)
+ if (aFeature.get() && aFeature->data()->isValid())
+ aCurrentFeatureName = aFeature->data()->name();
+ }
+ }
+ if (theMessage->sender()) {
+ ModelAPI_Object* aSender = static_cast<ModelAPI_Object*>(theMessage->sender());
+ if (aSender) {
+ FeaturePtr aFeatureSender =
+ std::dynamic_pointer_cast<ModelAPI_Feature>(aSender->data()->owner());
+ if (aFeatureSender.get() && aFeatureSender->data()->name() == aCurrentFeatureName) {
+ PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+ PartSet_SketcherReentrantMgr* aReentrantMgr = aModule->sketchReentranceMgr();
+ aReentrantMgr->setReentrantMessage(theMessage);
+ }
+ }
+ }
+ }
+ else if (anEventID == Events_Loop::eventByName(EVENT_REMOVE_CONSTRAINTS)) {
+ std::shared_ptr<ModelAPI_CheckConstraintsMessage> aConstraintsMsg =
+ std::dynamic_pointer_cast<ModelAPI_CheckConstraintsMessage>(theMessage);
+ if (aConstraintsMsg.get()) {
+ myObjectsToRemove = aConstraintsMsg->constraints();
+
+ std::set<ObjectPtr>::const_iterator anIt = myObjectsToRemove.begin();
+
+ PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+
+ for (; anIt != myObjectsToRemove.end(); )
+ {
+ ObjectPtr anObject = *anIt;
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
+ std::string aType = aFeature->getKind();
+ if ((aType == SketchPlugin_ConstraintHorizontal::ID() ||
+ aType == SketchPlugin_ConstraintVertical::ID()) &&
+ !aModule->sketchReentranceMgr()->isLastAutoConstraint(*anIt))
+ anIt = myObjectsToRemove.erase(anIt);
+ else
+ anIt++;
+ }
+
+ if (myObjectsToRemove.empty())
+ return;
+
+ QTimer::singleShot(5, aModule, SLOT(onRemoveConflictingConstraints()));