From 6601495c58e5e7951f045b0cc74836a8ead97aed Mon Sep 17 00:00:00 2001 From: charras Date: Mon, 11 Jan 2010 14:44:49 +0000 Subject: [PATCH] Fixed mouse wheel not working if 3D frame under wxWidgets 2.9 --- 3d-viewer/3d_canvas.cpp | 101 +++++++++++++++++++--------------------- 3d-viewer/3d_viewer.h | 3 +- 2 files changed, 51 insertions(+), 53 deletions(-) diff --git a/3d-viewer/3d_canvas.cpp b/3d-viewer/3d_canvas.cpp index abc9b27577..62077e86e4 100644 --- a/3d-viewer/3d_canvas.cpp +++ b/3d-viewer/3d_canvas.cpp @@ -1,13 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: 3d_canvas.cpp ///////////////////////////////////////////////////////////////////////////// - - -#ifdef __GNUG__ -#pragma implementation -#pragma interface -#endif - #include "fctsys.h" #include "trigo.h" @@ -35,8 +28,13 @@ BEGIN_EVENT_TABLE( Pcb3D_GLCanvas, wxGLCanvas ) EVT_PAINT( Pcb3D_GLCanvas::OnPaint ) + // key event: EVT_CHAR( Pcb3D_GLCanvas::OnChar ) - EVT_MOUSE_EVENTS( Pcb3D_GLCanvas::OnMouseEvent ) + // mouse events + EVT_RIGHT_DOWN( Pcb3D_GLCanvas::OnRightClick ) + EVT_MOUSEWHEEL( Pcb3D_GLCanvas::OnMouseWheel ) + EVT_MOTION( Pcb3D_GLCanvas::OnMouseMove ) + // other events EVT_ERASE_BACKGROUND( Pcb3D_GLCanvas::OnEraseBackground ) EVT_MENU_RANGE( ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END, Pcb3D_GLCanvas::OnPopUpMenu ) @@ -205,60 +203,59 @@ void Pcb3D_GLCanvas::SetView3D( int keycode ) Refresh( FALSE ); } - -void Pcb3D_GLCanvas::OnMouseEvent( wxMouseEvent& event ) +void Pcb3D_GLCanvas::OnMouseWheel( wxMouseEvent& event ) { wxSize size( GetClientSize() ); - double spin_quat[4]; - - if( event.RightDown() ) + if( event.ShiftDown() ) { - OnRightClick( event ); return; - } - - if( event.m_wheelRotation ) - { - if( event.ShiftDown() ) + if( event.GetWheelRotation() < 0 ) { - if( event.GetWheelRotation() < 0 ) - { - /* up */ - SetView3D( WXK_UP ); - } - else - { - /* down */ - SetView3D( WXK_DOWN ); - } - } - else if( event.ControlDown() ) - { - if( event.GetWheelRotation() > 0 ) - { - /* right */ - SetView3D( WXK_RIGHT ); - } - else - { - /* left */ - SetView3D( WXK_LEFT ); - } + /* up */ + SetView3D( WXK_UP ); } else { - if( event.GetWheelRotation() > 0 ) - { - g_Parm_3D_Visu.m_Zoom /= 1.4; - if( g_Parm_3D_Visu.m_Zoom <= 0.01 ) - g_Parm_3D_Visu.m_Zoom = 0.01; - } - else - g_Parm_3D_Visu.m_Zoom *= 1.4; - DisplayStatus(); - Refresh( FALSE ); + /* down */ + SetView3D( WXK_DOWN ); } } + else if( event.ControlDown() ) + { + if( event.GetWheelRotation() > 0 ) + { + /* right */ + SetView3D( WXK_RIGHT ); + } + else + { + /* left */ + SetView3D( WXK_LEFT ); + } + } + else + { + if( event.GetWheelRotation() > 0 ) + { + g_Parm_3D_Visu.m_Zoom /= 1.4; + if( g_Parm_3D_Visu.m_Zoom <= 0.01 ) + g_Parm_3D_Visu.m_Zoom = 0.01; + } + else + g_Parm_3D_Visu.m_Zoom *= 1.4; + DisplayStatus(); + Refresh( FALSE ); + } + + g_Parm_3D_Visu.m_Beginx = event.GetX(); + g_Parm_3D_Visu.m_Beginy = event.GetY(); +} + + +void Pcb3D_GLCanvas::OnMouseMove( wxMouseEvent& event ) +{ + wxSize size( GetClientSize() ); + double spin_quat[4]; if( event.Dragging() ) { diff --git a/3d-viewer/3d_viewer.h b/3d-viewer/3d_viewer.h index f1d323ae1a..71fc9264cb 100644 --- a/3d-viewer/3d_viewer.h +++ b/3d-viewer/3d_viewer.h @@ -149,7 +149,8 @@ public: void OnPaint( wxPaintEvent& event ); void OnEraseBackground( wxEraseEvent& event ); void OnChar( wxKeyEvent& event ); - void OnMouseEvent( wxMouseEvent& event ); + void OnMouseWheel( wxMouseEvent& event ); + void OnMouseMove( wxMouseEvent& event ); void OnRightClick( wxMouseEvent& event ); void OnPopUpMenu( wxCommandEvent& event ); void TakeScreenshot( wxCommandEvent& event );