]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #3135: Provide drag mode creation for ellipses and exclude splines
authorvsv <vsv@opencascade.com>
Fri, 31 Jan 2020 12:05:58 +0000 (15:05 +0300)
committervsv <vsv@opencascade.com>
Fri, 31 Jan 2020 12:06:29 +0000 (15:06 +0300)
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h

index bdcee2a518cd80cba123edbaeccc0b33c268663b..bcf6db4be9bedf1554dc90a14d4d49f0b548d4ee 100644 (file)
@@ -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<PartSet_MouseProcessor*>(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);
     }
   }
index ab56be3a8b01df0a739fb81aac082f4a67c885ae..033c123af6f6ecb278892017cfb558b7b23fc87f 100644 (file)
@@ -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