From 6faf13efbe9419c551f37cf79f392d184fb9d98b Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 6 Feb 2015 13:14:06 +0300 Subject: [PATCH] Issue #377: Do not edit sketch by dragging when interaction style is not standard --- src/ModuleBase/ModuleBase_IViewer.h | 4 ++++ src/NewGeom/NewGeom_SalomeViewer.cpp | 10 +++++++++- src/NewGeom/NewGeom_SalomeViewer.h | 3 +++ src/PartSet/PartSet_SketcherMgr.cpp | 15 ++++++++++----- src/XGUI/XGUI_ViewerProxy.cpp | 11 +++++++++++ src/XGUI/XGUI_ViewerProxy.h | 4 ++++ 6 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/ModuleBase/ModuleBase_IViewer.h b/src/ModuleBase/ModuleBase_IViewer.h index ba7ee1b28..3cf3bc5ab 100644 --- a/src/ModuleBase/ModuleBase_IViewer.h +++ b/src/ModuleBase/ModuleBase_IViewer.h @@ -75,6 +75,10 @@ Q_OBJECT /// Update current viewer virtual void update() = 0; + /// Method returns True if the viewer can process editing objects + /// by mouse drugging. If this is impossible thet it has to return False. + virtual bool canDragByMouse() const { return true; } + signals: /// Signal emited when last view window is closed void lastViewClosed(); diff --git a/src/NewGeom/NewGeom_SalomeViewer.cpp b/src/NewGeom/NewGeom_SalomeViewer.cpp index 0613d6624..c3c887ae8 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.cpp +++ b/src/NewGeom/NewGeom_SalomeViewer.cpp @@ -153,11 +153,19 @@ void NewGeom_SalomeViewer::onMouseMove(SUIT_ViewWindow* theView, QMouseEvent* th { OCCViewer_ViewWindow* aViewWnd = dynamic_cast(theView); Handle(AIS_InteractiveContext) aContext = AISContext(); - if (aContext->HasDetected()) + if (aContext->HasDetected()) // Set focus to provide key events in the view aViewWnd->getViewPort()->setFocus(Qt::MouseFocusReason); emit mouseMove(myView, theEvent); } +//********************************************** +bool NewGeom_SalomeViewer::canDragByMouse() const +{ + OCCViewer_Viewer* aViewer = mySelector->viewer(); + return (aViewer->interactionStyle() != 0); +} + + //********************************************** void NewGeom_SalomeViewer::onKeyPress(SUIT_ViewWindow* theView, QKeyEvent* theEvent) { diff --git a/src/NewGeom/NewGeom_SalomeViewer.h b/src/NewGeom/NewGeom_SalomeViewer.h index 1809dd243..1d471d1dc 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.h +++ b/src/NewGeom/NewGeom_SalomeViewer.h @@ -113,6 +113,9 @@ Q_OBJECT /// Update current viewer virtual void update(); + /// Method returns True if the viewer can process editing objects + /// by mouse drugging. If this is impossible thet it has to return False. + virtual bool canDragByMouse() const; private slots: void onMousePress(SUIT_ViewWindow*, QMouseEvent*); diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 018001423..80fd683fe 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -143,7 +143,14 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE if (!(theEvent->buttons() & Qt::LeftButton)) return; + // Clear dragging mode + myIsDragging = false; + ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); + ModuleBase_IViewer* aViewer = aWorkshop->viewer(); + if (!aViewer->canDragByMouse()) + return; + ModuleBase_Operation* aOperation = aWorkshop->currentOperation(); if (aOperation && aOperation->isEditOperation()) { ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); @@ -154,9 +161,6 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE } } - // Clear dragging mode - myIsDragging = false; - // Use only for sketch operations if (aOperation && myCurrentSketch) { if (!PartSet_Tools::sketchPlane(myCurrentSketch)) @@ -176,7 +180,6 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE return; // MoveTo in order to highlight current object - ModuleBase_IViewer* aViewer = aWorkshop->viewer(); aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView()); // Remember highlighted objects for editing @@ -226,13 +229,15 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) { ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); + ModuleBase_IViewer* aViewer = aWorkshop->viewer(); + if (!aViewer->canDragByMouse()) + return; ModuleBase_Operation* aOp = aWorkshop->currentOperation(); if (aOp) { if (sketchOperationIdList().contains(aOp->id())) { get2dPoint(theWnd, theEvent, myClickedPoint); // Only for sketcher operations - ModuleBase_IViewer* aViewer = aWorkshop->viewer(); if (myIsDragging) { if (myDragDone) { //aOp->commit(); diff --git a/src/XGUI/XGUI_ViewerProxy.cpp b/src/XGUI/XGUI_ViewerProxy.cpp index a4a55cca5..ec7049618 100644 --- a/src/XGUI/XGUI_ViewerProxy.cpp +++ b/src/XGUI/XGUI_ViewerProxy.cpp @@ -263,3 +263,14 @@ void XGUI_ViewerProxy::update() { myWorkshop->displayer()->updateViewer(); } + +//*************************************** +bool XGUI_ViewerProxy::canDragByMouse() const +{ + if (myWorkshop->isSalomeMode()) { + ModuleBase_IViewer* aViewer = myWorkshop->salomeConnector()->viewer(); + return aViewer->canDragByMouse(); + } else { + return true; + } +} \ No newline at end of file diff --git a/src/XGUI/XGUI_ViewerProxy.h b/src/XGUI/XGUI_ViewerProxy.h index e0894ff0f..acd152d23 100644 --- a/src/XGUI/XGUI_ViewerProxy.h +++ b/src/XGUI/XGUI_ViewerProxy.h @@ -69,6 +69,10 @@ Q_OBJECT /// Update current viewer virtual void update(); + /// Method returns True if the viewer can process editing objects + /// by mouse drugging. If this is impossible thet it has to return False. + virtual bool canDragByMouse() const; + private slots: void onTryCloseView(AppElements_ViewWindow*); void onDeleteView(AppElements_ViewWindow*); -- 2.39.2