From: vsv Date: Fri, 31 Jan 2020 12:05:58 +0000 (+0300) Subject: Issue #3135: Provide drag mode creation for ellipses and exclude splines X-Git-Tag: V9_5_0a1~45 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=582159075d570064f1e0e99e7a276fe124f5dc75;p=modules%2Fshaper.git Issue #3135: Provide drag mode creation for ellipses and exclude splines --- 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