From 68e4044adda34b3229e2811ae005b22873cddf85 Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 29 Dec 2014 16:55:21 +0300 Subject: [PATCH] Disable selection in the viewer between mouse move and mouse release signals processing. Otherwise the viewer clears the current selection. --- src/PartSet/PartSet_SketcherMgr.cpp | 16 +++++++++------- src/PartSet/PartSet_SketcherMgr.h | 5 +++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index f2094b571..c8575ee0c 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -105,6 +105,8 @@ PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule) ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); ModuleBase_IViewer* aViewer = aWorkshop->viewer(); + myPreviousSelectionEnabled = aViewer->isSelectionEnabled(); + connect(aViewer, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)), this, SLOT(onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*))); @@ -179,6 +181,7 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE if (isSketcher) { myIsDragging = true; + get2dPoint(theWnd, theEvent, myCurX, myCurY); myDragDone = false; aWorkshop->viewer()->enableMultiselection(false); @@ -212,18 +215,12 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse // Only for sketcher operations ModuleBase_IViewer* aViewer = aWorkshop->viewer(); if (myIsDragging) { + aWorkshop->viewer()->enableSelection(myPreviousSelectionEnabled); myIsDragging = false; if (myDragDone) { aViewer->enableMultiselection(true); //aOp->commit(); myFeature2AttributeMap.clear(); - - // Reselect edited object - aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView()); - if (theEvent->modifiers() & Qt::ShiftModifier) - aViewer->AISContext()->ShiftSelect(); - else - aViewer->AISContext()->Select(); return; } } @@ -235,6 +232,11 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) { if (myIsDragging) { + // the selection should be switched off in order to do not deselect moved objects by the + // mouse release + ModuleBase_IViewer* aViewer = myModule->workshop()->viewer(); + aViewer->enableSelection(false); + ModuleBase_Operation* aOperation = myModule->workshop()->currentOperation(); if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID()) return; // No edit operation activated diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index 2f51af931..4ae85671c 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -65,8 +65,8 @@ private slots: void onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*); private: - /// Converts mouse position to 2d coordinates. - /// Member myCurrentSketch has to be correctly defined + /// Converts mouse position to 2d coordinates. + /// Member myCurrentSketch has to be correctly defined void get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent, double& theX, double& theY); @@ -108,6 +108,7 @@ private: private: PartSet_Module* myModule; + bool myPreviousSelectionEnabled; // the previous selection enabled state in the viewer bool myIsDragging; bool myDragDone; double myCurX, myCurY; -- 2.39.2