From a2cd3c1905a3a3c2fb96ceb8eaec1cc982a64c97 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 7 Nov 2018 18:44:12 +0300 Subject: [PATCH] 0030352: DRAW - Extending interface of ViewerTest_EventManager to process mouse button event (cherry picked from commit 41e01634af5fccd37fc86931dac6f5c5569a63da) (cherry picked from commit 7660866377b29c3cf6ca6aedde23ca57feb5158f) --- src/ViewerTest/ViewerTest_EventManager.hxx | 34 +++++++++++++++++++- src/ViewerTest/ViewerTest_ViewerCommands.cxx | 8 +++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/ViewerTest/ViewerTest_EventManager.hxx b/src/ViewerTest/ViewerTest_EventManager.hxx index 05352ce608..fcceda9139 100644 --- a/src/ViewerTest/ViewerTest_EventManager.hxx +++ b/src/ViewerTest/ViewerTest_EventManager.hxx @@ -31,7 +31,7 @@ class V3d_View; class ViewerTest_EventManager; DEFINE_STANDARD_HANDLE(ViewerTest_EventManager, Standard_Transient) -//! used to manage mouse event (move,select,shiftselect) +//! used to manage mouse event (move,press,release). There is an interface to select, shiftselect in view. //! By default the events are transmitted to interactive context. class ViewerTest_EventManager : public Standard_Transient { @@ -41,6 +41,38 @@ public: Standard_EXPORT ViewerTest_EventManager(const Handle(V3d_View)& aView, const Handle(AIS_InteractiveContext)& aCtx); + //! Processing key button pressed + //! \param buf_ret key button symbol + //! \return true if processed + Standard_EXPORT virtual Standard_Boolean ProcessKeyPress (const char* buf_ret) { (void)buf_ret; return Standard_False; } + + //! Processing mouse button pressed + //! \param theXPressed X pixel coordinate + //! \param theXPressed Y pixel coordinate + //! \param theIsShift state if the SHIFT key modifier is ON + //! \return true if processed + Standard_EXPORT virtual Standard_Boolean ProcessButton1Press (const Standard_Integer theXPressed, + const Standard_Integer theYPressed, + Standard_Boolean theIsShift) + { (void)theXPressed; (void)theYPressed; (void)theIsShift; return Standard_False; } + + //! Processing mouse button released + //! \param theXPressed X pixel coordinate + //! \param theXPressed Y pixel coordinate + //! \param theIsShift state if the SHIFT key modifier is ON + //! \return true if processed + Standard_EXPORT virtual Standard_Boolean ProcessButton1Release (const Standard_Integer theXPressed, + const Standard_Integer theYPressed, + Standard_Boolean theIsShift) + { (void)theXPressed; (void)theYPressed; (void)theIsShift; return Standard_False; } + + //! Processing mouse move over the viewer + //! \param theXPressed X pixel coordinate + //! \param theXPressed Y pixel coordinate + Standard_EXPORT virtual Standard_Boolean ProcessMouseMove (const Standard_Integer theXPressed, + const Standard_Integer theYPressed) + { (void)theXPressed; (void)theYPressed; return Standard_False; } + Standard_EXPORT virtual void MoveTo (const Standard_Integer xpix, const Standard_Integer ypix); Standard_EXPORT virtual void Select(); diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index 5ce04f23d7..9cf474884c 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -3380,6 +3380,8 @@ static LRESULT WINAPI AdvViewerWindowProc( HWND hwnd, break; case WM_LBUTTONUP: + ViewerTest::CurrentEventManager()->ProcessButton1Release (X_Motion, Y_Motion, (fwKeys & MK_SHIFT) != 0); + if (IsDragged && !DragFirst) { if (!GetActiveAISManipulator().IsNull()) @@ -3412,6 +3414,8 @@ static LRESULT WINAPI AdvViewerWindowProc( HWND hwnd, return ViewerWindowProc (hwnd, Msg, wParam, lParam); case WM_LBUTTONDOWN: + ViewerTest::CurrentEventManager()->ProcessButton1Press (LOWORD(lParam), HIWORD(lParam), (fwKeys & MK_SHIFT) != 0); + if (!GetActiveAISManipulator().IsNull()) { IsDragged = ( fwKeys == MK_LBUTTON ); @@ -3430,6 +3434,8 @@ static LRESULT WINAPI AdvViewerWindowProc( HWND hwnd, return ViewerWindowProc( hwnd, Msg, wParam, lParam ); case WM_MOUSEMOVE: + ViewerTest::CurrentEventManager()->ProcessMouseMove (LOWORD (lParam), HIWORD (lParam)); + if (IsDragged) { X_Motion = LOWORD (lParam); @@ -3556,6 +3562,8 @@ static LRESULT WINAPI ViewerWindowProc( HWND hwnd, { c[0] = '*'; } + ViewerTest::CurrentEventManager()->ProcessKeyPress (c); + VT_ProcessKeyPress (c); } break; -- 2.39.5