From 582159075d570064f1e0e99e7a276fe124f5dc75 Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 31 Jan 2020 15:05:58 +0300 Subject: [PATCH] Issue #3135: Provide drag mode creation for ellipses and exclude splines --- src/PartSet/PartSet_SketcherMgr.cpp | 29 ++++++++++++++++++++++++----- src/PartSet/PartSet_SketcherMgr.h | 3 +++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index bdcee2a51..bcf6db4be 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -349,16 +349,35 @@ void PartSet_SketcherMgr::onAfterValuesChangedInPropertyPanel() } */ +bool PartSet_SketcherMgr::isDragModeCreation() const +{ + ModuleBase_Operation* aOp = getCurrentOperation(); + if (!aOp) + return false; + bool aUserPref = Config_PropManager::boolean(SKETCH_TAB_NAME, "create_by_dragging"); + if (!aUserPref) + return false; + QString aId = aOp->id(); + // Acceptable features; + QStringList aList; + aList << "SketchLine" << "SketchMacroCircle" << "SketchMacroArc" << + "SketchMacroEllipse" << "SketchMacroEllipticArc" << "SketchRectangle"; + return aList.contains(aId); +} + static bool MyModeByDrag = false; static bool MyMultiselectionState = true; void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) { - MyModeByDrag = Config_PropManager::boolean(SKETCH_TAB_NAME, "create_by_dragging"); + MyModeByDrag = isDragModeCreation(); // Clear dragging mode myIsDragging = false; + myMousePoint.setX(theEvent->x()); + myMousePoint.setY(theEvent->y()); + if (myModule->sketchReentranceMgr()->processMousePressed(theWnd, theEvent)) return; //get2dPoint(theWnd, theEvent, myClickedPoint); @@ -406,8 +425,6 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE // Ignore creation sketch operation if ((!isSketcher) && (!isEditing)) { if (MyModeByDrag) { - myMousePoint.setX(theEvent->x()); - myMousePoint.setX(theEvent->y()); ModuleBase_ModelWidget* anActiveWidget = getActiveWidget(); PartSet_MouseProcessor* aProcessor = dynamic_cast(anActiveWidget); if (aProcessor) { @@ -579,11 +596,13 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse if (aOpId == "Sketch") return; QPoint aPnt(theEvent->x(), theEvent->y()); - if (aPnt == myMousePoint) { + anActiveWidget = getActiveWidget(); + if ((aPnt == myMousePoint) && anActiveWidget) { aOp->abort(); return; } - if ((aOpId != "SketchMacroArc") && (!isEditing)) { + bool aCanRestart = !anActiveWidget && !isEditing; + if (aCanRestart) { module()->launchOperation(aOpId, true); } } diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index ab56be3a8..033c123af 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -469,6 +469,9 @@ private: void visualizeFeature(const FeaturePtr& theFeature, const bool isEditOperation, const bool isToDisplay, const bool isFlushRedisplay = true); + /// Returns true if current mode of objects creation is by drag mouse + bool isDragModeCreation() const; + private: /// Updates selection priority of the presentation /// \param theObject object to find a presentation which will be corrected -- 2.39.2