From: nds Date: Tue, 11 Apr 2017 10:10:15 +0000 (+0300) Subject: Issue #2123: Unexpected Sketcher behavior when creating Coincidence X-Git-Tag: V_2.7.0~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b57258dba9f8575728ecb92e48c07c9fd6652f9b;p=modules%2Fshaper.git Issue #2123: Unexpected Sketcher behavior when creating Coincidence --- diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index fe5bff496..ca6c1b1bc 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -86,6 +86,11 @@ void ModuleBase_IModule::launchOperation(const QString& theCmdId, QList aPreSelected = aSelection->getSelected(ModuleBase_ISelection::AllControls); + ModuleBase_OperationFeature* aCurOperation = dynamic_cast + (myWorkshop->currentOperation()); + QString anOperationKind = aCurOperation ? aCurOperation->getDescription()->operationId() : ""; + + bool isCommitted; if (!myWorkshop->canStartOperation(theCmdId, isCommitted)) return; @@ -101,7 +106,7 @@ void ModuleBase_IModule::launchOperation(const QString& theCmdId, if (aMessage.get()) { setReentrantPreSelection(aMessage); } - else + else if (anOperationKind == theCmdId) // restore of selection only if the kind is the same aFOperation->initSelection(aPreSelected); workshop()->processLaunchOperation(aFOperation); diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index f0be4ae9e..10042d488 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -386,7 +386,15 @@ void ModuleBase_ModelWidget::updateObject(ObjectPtr theObject) #ifdef DEBUG_WIDGET_INSTANCE qDebug("ModuleBase_ModelWidget::updateObject"); #endif - ModuleBase_Tools::flushUpdated(theObject); + ModuleBase_Tools::blockUpdateViewer(true); + // Fix the problem of not previewed results of constraints applied. Flush Create/Delete + // (for the sketch result) to start processing of the sketch in the solver. + // TODO: these flushes should be moved in a separate method provided by Model + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED)); + + ModuleBase_Tools::blockUpdateViewer(false); emit objectUpdated(); } } diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 963b53c62..2b14c2506 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -207,7 +207,7 @@ void PartSet_Module::storeSelection() // cash is used only to restore selection, so it should be filled in storeSelection and // after applying immediatelly cleared in restoreSelection myCurrentSelection.clear(); - sketchMgr()->storeSelection(false, myCurrentSelection); + sketchMgr()->storeSelection(PartSet_SketcherMgr::ST_SelectType, myCurrentSelection); } void PartSet_Module::restoreSelection() diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 774fc1fcb..2a5ed0d37 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -276,7 +276,7 @@ void PartSet_SketcherMgr::onBeforeValuesChangedInPropertyPanel() myModule->sketchReentranceMgr()->isInternalEditActive()) return; // it is necessary to save current selection in order to restore it after the values are modifed - storeSelection(false); + storeSelection(ST_SelectAndHighlightType); ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); @@ -358,7 +358,7 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE ModuleBase_ISelection* aSelect = aWorkshop->selection(); bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); - storeSelection(!aHasShift, myCurrentSelection); + storeSelection(aHasShift ? ST_SelectAndHighlightType : ST_HighlightType, myCurrentSelection); if (myCurrentSelection.empty()) { if (isSketchOpe && (!isSketcher)) @@ -1529,7 +1529,7 @@ void PartSet_SketcherMgr::getSelectionOwners(const FeaturePtr& theFeature, if (aResults.size() > 0) { ResultPtr aFirstResult = theFeature->firstResult(); if (aFirstResult.get() && aFirstResult->shape().get()) { - const TopoDS_Shape& aFirstShape = aFirstResult->shape()->impl(); + TopoDS_Shape aFirstShape = aFirstResult->shape()->impl(); isSameShape = aFirstShape.IsEqual(anInfo.myFirstResultShape); } } @@ -1700,7 +1700,7 @@ void PartSet_SketcherMgr::visualizeFeature(const FeaturePtr& theFeature, Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); } -void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly, +void PartSet_SketcherMgr::storeSelection(const SelectionType theType, PartSet_SketcherMgr::FeatureToSelectionMap& theCurrentSelection) { if (!myCurrentSketch.get()) @@ -1708,10 +1708,13 @@ void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly, ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); ModuleBase_ISelection* aSelect = aWorkshop->selection(); - QList aStoredPrs = aSelect->getHighlighted(); + QList aStoredPrs; + + if (theType == ST_HighlightType || theType == ST_SelectAndHighlightType) + aStoredPrs = aSelect->getHighlighted(); QList aFeatureList; - if (!theHighlightedOnly) { + if (theType == ST_SelectAndHighlightType || theType == ST_SelectType) { QList aSelected = aSelect->getSelected( ModuleBase_ISelection::AllControls); aStoredPrs.append(aSelected); diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index 5fb1931fd..648ed988b 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -231,12 +231,19 @@ public: /// \return boolean value bool isObjectOfSketch(const ObjectPtr& theObject) const; + /// Enumeration for selection mode used + enum SelectionType { + ST_HighlightType, /// Only highlighted objects + ST_SelectType, /// Only selected objects + ST_SelectAndHighlightType /// Both, highlighted and selected objects + }; + /// Saves the current selection in the viewer into an internal container /// It obtains the selected attributes. /// The highlighted objects can be processes as the selected ones /// \param theHighlightedOnly a boolean flag /// \param theCurrentSelection a container filled by the current selection - void storeSelection(const bool theHighlightedOnly, FeatureToSelectionMap& theCurrentSelection); + void storeSelection(const SelectionType theType, FeatureToSelectionMap& theCurrentSelection); /// Restores previously saved selection state /// \param theCurrentSelection a container filled by the current selection diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 91fddccd7..d1deff536 100755 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -140,10 +140,6 @@ std::shared_ptr SketchPlugin_Sketch::addFeature(std::string th // set as current also after it becomes sub to set correctly enabled for other sketch subs document()->setCurrentFeature(aNew, false); - static Events_Loop* aLoop = Events_Loop::loop(); - static Events_ID aDeleteEvent = aLoop->eventByName(EVENT_OBJECT_DELETED); - aLoop->flush(aDeleteEvent); - return aNew; }