From 3486a146fbbe4d413923bf141b40df6232c1ad52 Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 7 Nov 2014 11:45:06 +0300 Subject: [PATCH] Issue #236: Buttons 'N' and 'P' change selection of object under cursor to Next or Previous --- src/XGUI/XGUI_Viewer.cpp | 18 +++++++++++++++++- src/XGUI/XGUI_Viewer.h | 6 +++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/XGUI/XGUI_Viewer.cpp b/src/XGUI/XGUI_Viewer.cpp index 3a8149615..47100f7c4 100644 --- a/src/XGUI/XGUI_Viewer.cpp +++ b/src/XGUI/XGUI_Viewer.cpp @@ -458,7 +458,7 @@ void XGUI_Viewer::addView(QMdiSubWindow* theView) SIGNAL(keyPress(XGUI_ViewWindow*, QKeyEvent*))); connect(aWindow, SIGNAL(keyReleased(XGUI_ViewWindow*, QKeyEvent*)), this, - SIGNAL(keyRelease(XGUI_ViewWindow*, QKeyEvent*))); + SLOT(onKeyRelease(XGUI_ViewWindow*, QKeyEvent*))); //connect(aWindow, SIGNAL(contextMenuRequested( QContextMenuEvent* )), // this, SLOT (onContextMenuRequested( QContextMenuEvent* ))); @@ -529,6 +529,8 @@ void XGUI_Viewer::onMouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent) Handle(V3d_View) aView3d = theWindow->viewPort()->getView(); if (!aView3d.IsNull()) { myAISContext->MoveTo(theEvent->x(), theEvent->y(), aView3d); + if (myAISContext->HasDetected()) + theWindow->viewPort()->setFocus(Qt::MouseFocusReason); } } @@ -607,6 +609,20 @@ void XGUI_Viewer::updateViewsDrawMode() const } } +//****************************************************** +void XGUI_Viewer::onKeyRelease(XGUI_ViewWindow* theView, QKeyEvent* theKey) +{ + Handle(V3d_View) aView = theView->viewPort()->getView(); + bool noModifiers = (theKey->modifiers() == Qt::NoModifier); + if ((theKey->key() == Qt::Key_N) && noModifiers) { + myAISContext->HilightNextDetected(aView); + } else if ((theKey->key() == Qt::Key_P) && noModifiers) { + myAISContext->HilightPreviousDetected(aView); + } else { + emit keyRelease(theView, theKey); + } +} + //****************************************************** //void XGUI_Viewer::onContextMenuRequested(QContextMenuEvent* theEvent) //{ diff --git a/src/XGUI/XGUI_Viewer.h b/src/XGUI/XGUI_Viewer.h index 2ae7cdd04..2cc4c02c0 100644 --- a/src/XGUI/XGUI_Viewer.h +++ b/src/XGUI/XGUI_Viewer.h @@ -182,6 +182,8 @@ signals: void onMousePressed(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent); //void onContextMenuRequested(QContextMenuEvent* theEvent); + void onKeyRelease(XGUI_ViewWindow* theView, QKeyEvent* theKey); + private: void addView(QMdiSubWindow* theView); @@ -193,7 +195,9 @@ signals: private: XGUI_MainWindow* myMainWindow; - Handle(V3d_Viewer) myV3dViewer;Handle(AIS_Trihedron) myTrihedron;Handle(AIS_InteractiveContext) myAISContext; + Handle(V3d_Viewer) myV3dViewer; + Handle(AIS_Trihedron) myTrihedron; + Handle(AIS_InteractiveContext) myAISContext; XGUI::InteractionStyle myInteractionStyle; -- 2.39.2