From: vsv Date: Mon, 12 Oct 2015 07:49:02 +0000 (+0300) Subject: Issue #1016: Hide selection rectangle on sketcher operation X-Git-Tag: V_1.4.0_demo2~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c485d6ab9a8494995405c80751e0e67712bd630c;p=modules%2Fshaper.git Issue #1016: Hide selection rectangle on sketcher operation --- diff --git a/src/ModuleBase/ModuleBase_IViewer.h b/src/ModuleBase/ModuleBase_IViewer.h index 7547d6c1f..3c8f67653 100644 --- a/src/ModuleBase/ModuleBase_IViewer.h +++ b/src/ModuleBase/ModuleBase_IViewer.h @@ -50,6 +50,9 @@ Q_OBJECT //! Returns true if multiselection is enabled virtual bool isMultiSelectionEnabled() const = 0; + //! Enable or disable draw mode in the viewer + virtual bool enableDrawMode(bool isEnabled) = 0; + //! Perfroms the fit all for the active view virtual void fitAll() = 0; diff --git a/src/NewGeom/NewGeom_SalomeViewer.cpp b/src/NewGeom/NewGeom_SalomeViewer.cpp index 636abd69f..d8415b447 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.cpp +++ b/src/NewGeom/NewGeom_SalomeViewer.cpp @@ -257,6 +257,7 @@ bool NewGeom_SalomeViewer::isSelectionEnabled() const { if (mySelector) return mySelector->viewer()->isSelectionEnabled(); + return false; } //********************************************** @@ -274,6 +275,15 @@ bool NewGeom_SalomeViewer::isMultiSelectionEnabled() const return false; } +//********************************************** +bool NewGeom_SalomeViewer::enableDrawMode(bool isEnabled) +{ + // TODO: Has to be replaced when SALOME patch become avialable + if (mySelector) + return mySelector->viewer()->enableDrawMode(isEnabled); + return false; +} + //********************************************** void NewGeom_SalomeViewer::fitAll() { diff --git a/src/NewGeom/NewGeom_SalomeViewer.h b/src/NewGeom/NewGeom_SalomeViewer.h index 0635c8989..ee250cae0 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.h +++ b/src/NewGeom/NewGeom_SalomeViewer.h @@ -91,6 +91,9 @@ Q_OBJECT //! Returns true if multiselection is enabled virtual bool isMultiSelectionEnabled() const; + //! Enable or disable draw mode in the viewer + virtual bool enableDrawMode(bool isEnabled); + //! Perfroms the fit all for the active view virtual void fitAll(); diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 2185f64fc..270877d4b 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -159,7 +159,7 @@ PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule) ModuleBase_IWorkshop* anIWorkshop = myModule->workshop(); ModuleBase_IViewer* aViewer = anIWorkshop->viewer(); - myPreviousSelectionEnabled = true;//aViewer->isSelectionEnabled(); + myPreviousDrawModeEnabled = true;//aViewer->isSelectionEnabled(); connect(aViewer, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)), this, SLOT(onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*))); @@ -341,7 +341,6 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); ModuleBase_IViewer* aViewer = aWorkshop->viewer(); - myPreviousSelectionEnabled = aViewer->isSelectionEnabled(); if (!aViewer->canDragByMouse()) return; @@ -402,6 +401,8 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE myIsDragging = true; get2dPoint(theWnd, theEvent, myCurrentPoint); myDragDone = false; + // TODO: Has to be uncommented when SALOME patch on draw mode become avialable + myPreviousDrawModeEnabled = aViewer->enableDrawMode(false); launchEditing(); if (aFeature.get() != NULL) { std::shared_ptr aSPFeature = @@ -421,6 +422,8 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE myIsDragging = true; get2dPoint(theWnd, theEvent, myCurrentPoint); myDragDone = false; + // TODO: Has to be uncommented when SALOME patch on draw mode become avialable + myPreviousDrawModeEnabled = aViewer->enableDrawMode(false); // This is necessary in order to finalize previous operation QApplication::processEvents(); @@ -458,7 +461,9 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse } } } - aWorkshop->viewer()->enableSelection(myPreviousSelectionEnabled); + // TODO: Has to be uncommented when SALOME patch on draw mode become avialable + aWorkshop->viewer()->enableDrawMode(myPreviousDrawModeEnabled); + //aWorkshop->viewer()->enableSelection(myPreviousDrawModeEnabled); myIsDragging = false; } @@ -498,8 +503,10 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve // 2. the enable selection in the viewer should be temporary switched off in order to ignore // mouse press signal in the viewer(it call Select for AIS context and the dragged objects are // deselected). This flag should be restored in the slot, processed the mouse release signal. - ModuleBase_IViewer* aViewer = myModule->workshop()->viewer(); - aViewer->enableSelection(false); + + // TODO: Has to be commented out when SALOME patch on draw mode become avialable + //ModuleBase_IViewer* aViewer = myModule->workshop()->viewer(); + //aViewer->enableSelection(false); ModuleBase_Operation* aCurrentOperation = getCurrentOperation(); if (!aCurrentOperation) diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index 94540d988..5e8a09597 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -294,7 +294,7 @@ private: private: PartSet_Module* myModule; - bool myPreviousSelectionEnabled; // the previous selection enabled state in the viewer + bool myPreviousDrawModeEnabled; // the previous selection enabled state in the viewer bool myIsDragging; bool myDragDone; bool myIsResetCurrentValue; /// the state that value in the property panel is reset diff --git a/src/XGUI/XGUI_ViewerProxy.cpp b/src/XGUI/XGUI_ViewerProxy.cpp index 293b9c063..955813a42 100644 --- a/src/XGUI/XGUI_ViewerProxy.cpp +++ b/src/XGUI/XGUI_ViewerProxy.cpp @@ -275,6 +275,16 @@ bool XGUI_ViewerProxy::isMultiSelectionEnabled() const } } +//*************************************** +bool XGUI_ViewerProxy::enableDrawMode(bool isEnabled) +{ + if (myWorkshop->isSalomeMode()) { + return myWorkshop->salomeConnector()->viewer()->enableDrawMode(isEnabled); + } else { + return myWorkshop->mainWindow()->viewer()->enableDrawMode(isEnabled); + } +} + //*************************************** void XGUI_ViewerProxy::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) { diff --git a/src/XGUI/XGUI_ViewerProxy.h b/src/XGUI/XGUI_ViewerProxy.h index 64bc12fb8..7362bbfa4 100644 --- a/src/XGUI/XGUI_ViewerProxy.h +++ b/src/XGUI/XGUI_ViewerProxy.h @@ -44,6 +44,9 @@ Q_OBJECT //! Returns true if multiselection is enabled virtual bool isMultiSelectionEnabled() const; + //! Enable or disable draw mode in the viewer + virtual bool enableDrawMode(bool isEnabled); + //! Sets the view projection /// \param theX the X projection value /// \param theY the Y projection value