Commit 4a489895 authored by stambaughw's avatar stambaughw
Browse files

More zoom clean ups and code cleaning.

parent 63724083
Loading
Loading
Loading
Loading
+5 −6
Original line number Original line Diff line number Diff line
@@ -27,8 +27,7 @@




BEGIN_EVENT_TABLE( WinEDA3D_DrawFrame, wxFrame )
BEGIN_EVENT_TABLE( WinEDA3D_DrawFrame, wxFrame )
    EVT_TOOL_RANGE( ID_ZOOM_IN_BUTT, ID_ZOOM_PAGE_BUTT,
    EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA3D_DrawFrame::Process_Zoom )
                    WinEDA3D_DrawFrame::Process_Zoom )
    EVT_TOOL_RANGE( ID_START_COMMAND_3D, ID_END_COMMAND_3D,
    EVT_TOOL_RANGE( ID_START_COMMAND_3D, ID_END_COMMAND_3D,
                    WinEDA3D_DrawFrame::Process_Special_Functions )
                    WinEDA3D_DrawFrame::Process_Special_Functions )
    EVT_MENU( wxID_EXIT, WinEDA3D_DrawFrame::Exit3DFrame )
    EVT_MENU( wxID_EXIT, WinEDA3D_DrawFrame::Exit3DFrame )
@@ -172,7 +171,7 @@ void WinEDA3D_DrawFrame::Process_Zoom( wxCommandEvent& event )


    switch( event.GetId() )
    switch( event.GetId() )
    {
    {
    case ID_ZOOM_PAGE_BUTT:
    case ID_ZOOM_PAGE:
        for( ii = 0; ii < 4; ii++ )
        for( ii = 0; ii < 4; ii++ )
            g_Parm_3D_Visu.m_Rot[ii] = 0.0;
            g_Parm_3D_Visu.m_Rot[ii] = 0.0;


@@ -181,17 +180,17 @@ void WinEDA3D_DrawFrame::Process_Zoom( wxCommandEvent& event )
        trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
        trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
        break;
        break;


    case ID_ZOOM_IN_BUTT:
    case ID_ZOOM_IN:
        g_Parm_3D_Visu.m_Zoom /= 1.2;
        g_Parm_3D_Visu.m_Zoom /= 1.2;
        if( g_Parm_3D_Visu.m_Zoom <= 0.01 )
        if( g_Parm_3D_Visu.m_Zoom <= 0.01 )
            g_Parm_3D_Visu.m_Zoom = 0.01;
            g_Parm_3D_Visu.m_Zoom = 0.01;
        break;
        break;


    case ID_ZOOM_OUT_BUTT:
    case ID_ZOOM_OUT:
        g_Parm_3D_Visu.m_Zoom *= 1.2;
        g_Parm_3D_Visu.m_Zoom *= 1.2;
        break;
        break;


    case ID_ZOOM_REDRAW_BUTT:
    case ID_ZOOM_REDRAW:
        break;
        break;


    default:
    default:
+4 −4
Original line number Original line Diff line number Diff line
@@ -39,16 +39,16 @@ void WinEDA3D_DrawFrame::ReCreateHToolbar()
#endif
#endif


    m_HToolBar->AddSeparator();
    m_HToolBar->AddSeparator();
    m_HToolBar->AddTool( ID_ZOOM_IN_BUTT, wxEmptyString, BITMAP( zoom_in_xpm ),
    m_HToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, BITMAP( zoom_in_xpm ),
                        _( "Zoom in" ) );
                        _( "Zoom in" ) );


    m_HToolBar->AddTool( ID_ZOOM_OUT_BUTT, wxEmptyString, BITMAP( zoom_out_xpm ),
    m_HToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, BITMAP( zoom_out_xpm ),
                        _( "Zoom out" ) );
                        _( "Zoom out" ) );


    m_HToolBar->AddTool( ID_ZOOM_REDRAW_BUTT, wxEmptyString, BITMAP( zoom_redraw_xpm ),
    m_HToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, BITMAP( zoom_redraw_xpm ),
                        _( "Redraw view" ) );
                        _( "Redraw view" ) );


    m_HToolBar->AddTool( ID_ZOOM_PAGE_BUTT, wxEmptyString, BITMAP( zoom_auto_xpm ),
    m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, BITMAP( zoom_auto_xpm ),
                        _( "Zoom auto" ) );
                        _( "Zoom auto" ) );


    m_HToolBar->AddSeparator();
    m_HToolBar->AddSeparator();
+15 −0
Original line number Original line Diff line number Diff line
@@ -5,6 +5,21 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
Please add newer entries at the top, list the date and your name with
email address.
email address.


2009-Jan-07 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++all
  * Don't pan or zoom on mouse wheel events when the cursor is not in the
    drawing area.
  * Reduce all zoom code to a single zoom command handler.
  * Eliminate redundant zoom command identifiers.
  * Move pop up zoom command handler from DrawPanel to DrawFrame.
  * Change hot key zoom handlers to use command events.
  * Added DrawFrame event table to replace COMMON_EVENTS_DRAWFRAME macro.
  * Added locale path relative to binary path for development purposes.
  * Minor code clean ups and duplicate header removal in files that were
    updated.


2009-Jan-04 UPDATE Dick Hollenbeck <dick@softplc.com>
2009-Jan-04 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
================================================================================
++all
++all
+9 −75
Original line number Original line Diff line number Diff line
@@ -15,6 +15,15 @@
#include <wx/fontdlg.h>
#include <wx/fontdlg.h>




BEGIN_EVENT_TABLE( WinEDA_DrawFrame, WinEDA_BasicFrame )
    EVT_MOUSEWHEEL( WinEDA_DrawFrame::OnMouseEvent )
    EVT_MENU_OPEN( WinEDA_DrawFrame::OnMenuOpen )
    EVT_ACTIVATE( WinEDA_DrawFrame::OnActivate )
    EVT_MENU_RANGE( ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE,
                    WinEDA_DrawFrame::OnZoom )
END_EVENT_TABLE()


/*******************************************************/
/*******************************************************/
/* Constructeur de WinEDA_DrawFrame: la fenetre generale */
/* Constructeur de WinEDA_DrawFrame: la fenetre generale */
/*******************************************************/
/*******************************************************/
@@ -533,81 +542,6 @@ void WinEDA_DrawFrame::SetToolID( int id, int new_cursor_id,
}
}




/********************************************/
void WinEDA_DrawFrame::OnZoom( int zoom_type )
/********************************************/

/* Fonction de traitement du zoom
 *  Modifie le facteur de zoom et reaffiche l'ecran
 *  Pour les commandes par menu Popup ou par le clavier, le curseur est
 *  replac� au centre de l'ecran
 */
{
    if( DrawPanel == NULL )
        return;

    BASE_SCREEN*    screen = GetBaseScreen();
    bool    move_mouse_cursor = FALSE;
    int     x, y;
    wxPoint old_pos;

    DrawPanel->GetViewStart( &x, &y );
    old_pos = GetBaseScreen()->m_Curseur;

    switch( zoom_type )
    {
    case ID_POPUP_ZOOM_IN:
    case ID_ZOOM_IN_KEY:
        move_mouse_cursor = TRUE;
        // fall thru

    case ID_ZOOM_IN_BUTT:
        if( zoom_type == ID_ZOOM_IN_BUTT )
            GetBaseScreen()->m_Curseur = DrawPanel->GetScreenCenterRealPosition();

        screen->SetPreviousZoom();

        Recadre_Trace( move_mouse_cursor );
        break;

    case ID_POPUP_ZOOM_OUT:
    case ID_ZOOM_OUT_KEY:
        move_mouse_cursor = TRUE;
        // fall thru

    case ID_ZOOM_OUT_BUTT:
        if( zoom_type == ID_ZOOM_OUT_BUTT )
            screen->m_Curseur = DrawPanel->GetScreenCenterRealPosition();
        screen->SetNextZoom();
        Recadre_Trace( move_mouse_cursor );
        break;

    case ID_POPUP_ZOOM_REDRAW:
    case ID_ZOOM_REDRAW_KEY:
    case ID_ZOOM_REDRAW_BUTT:
        DrawPanel->Refresh();
        break;

    case ID_POPUP_ZOOM_CENTER:
    case ID_ZOOM_CENTER_KEY:
        Recadre_Trace( TRUE );
        break;

    case ID_ZOOM_PAGE_BUTT:
    case ID_ZOOM_AUTO:
    case ID_POPUP_ZOOM_AUTO:
        Zoom_Automatique( FALSE );
        break;

    default:
        wxMessageBox( wxT( "WinEDA_DrawFrame::OnZoom switch Error" ) );
        break;
    }

    Affiche_Status_Box();
}


/*****************************/
/*****************************/
/* default virtual fonctions */
/* default virtual fonctions */
/*****************************/
/*****************************/
+23 −12
Original line number Original line Diff line number Diff line
@@ -33,8 +33,6 @@ BEGIN_EVENT_TABLE( WinEDA_DrawPanel, wxScrolledWindow )
    EVT_SCROLLWIN( WinEDA_DrawPanel::OnScroll )
    EVT_SCROLLWIN( WinEDA_DrawPanel::OnScroll )
    EVT_ACTIVATE( WinEDA_DrawPanel::OnActivate )
    EVT_ACTIVATE( WinEDA_DrawPanel::OnActivate )


    EVT_MENU_RANGE( ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE,
                    WinEDA_DrawPanel::Process_Popup_Zoom )
    EVT_MENU_RANGE( ID_POPUP_GRID_LEVEL_1000, ID_POPUP_GRID_USER,
    EVT_MENU_RANGE( ID_POPUP_GRID_LEVEL_1000, ID_POPUP_GRID_USER,
                    WinEDA_DrawPanel::OnPopupGridSelect )
                    WinEDA_DrawPanel::OnPopupGridSelect )
    EVT_MENU_RANGE( ID_PAN_UP, ID_PAN_RIGHT, WinEDA_DrawPanel::OnPan )
    EVT_MENU_RANGE( ID_PAN_UP, ID_PAN_RIGHT, WinEDA_DrawPanel::OnPan )
@@ -50,7 +48,6 @@ WinEDA_DrawPanel::WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id,
                      wxBORDER | wxNO_FULL_REPAINT_ON_RESIZE )
                      wxBORDER | wxNO_FULL_REPAINT_ON_RESIZE )
{
{
    m_Parent          = parent;
    m_Parent          = parent;
    m_Ident           = m_Parent->m_Ident;
    m_Scroll_unit     = 1;
    m_Scroll_unit     = 1;
    m_ScrollButt_unit = 40;
    m_ScrollButt_unit = 40;


@@ -902,10 +899,14 @@ void WinEDA_DrawPanel::OnMouseLeaving( wxMouseEvent& event )


    // Auto pan if mouse is leave working aera:
    // Auto pan if mouse is leave working aera:
    wxSize size = GetClientSize();
    wxSize size = GetClientSize();
    if( ( size.x < event.GetX() )

       || ( size.y < event.GetY() )
    if( ( size.x < event.GetX() ) || ( size.y < event.GetY() )
        || ( event.GetX() <= 0) || ( event.GetY() <= 0 ) )
        || ( event.GetX() <= 0) || ( event.GetY() <= 0 ) )
        m_Parent->OnZoom( ID_POPUP_ZOOM_CENTER );
    {
        wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_POPUP_ZOOM_CENTER );
        cmd.SetEventObject( this );
        GetEventHandler()->ProcessEvent( cmd );
    }
}
}




@@ -918,7 +919,14 @@ void WinEDA_DrawPanel::OnMouseLeaving( wxMouseEvent& event )
 */
 */
void WinEDA_DrawPanel::OnMouseWheel( wxMouseEvent& event )
void WinEDA_DrawPanel::OnMouseWheel( wxMouseEvent& event )
{
{
    if( event.GetWheelRotation() == 0 )
    wxRect rect = GetRect();

    wxLogDebug( wxT( "OnMouseWheel() cursor position: (%d, %d)." ),
                event.m_x, event.m_y );

    /* Ignore scroll events if the cursor is outside the drawing area. */
    if( event.GetWheelRotation() == 0 || !GetParent()->IsEnabled()
        || !rect.Contains( event.GetPosition() ) )
    {
    {
        event.Skip();
        event.Skip();
        return;
        return;
@@ -927,7 +935,7 @@ void WinEDA_DrawPanel::OnMouseWheel( wxMouseEvent& event )
    wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
    wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
    cmd.SetEventObject( this );
    cmd.SetEventObject( this );


    // This is a zoom in ou out command
    // This is a zoom in or out command
    if( event.GetWheelRotation() > 0 )
    if( event.GetWheelRotation() > 0 )
    {
    {
        if( event.ShiftDown() && !event.ControlDown() )
        if( event.ShiftDown() && !event.ControlDown() )
@@ -1073,8 +1081,11 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
    if( event.ButtonUp( 2 ) && (screen->BlockLocate.m_State == STATE_NO_BLOCK) )
    if( event.ButtonUp( 2 ) && (screen->BlockLocate.m_State == STATE_NO_BLOCK) )
    {
    {
        // The middle button has been relached, with no block command:
        // The middle button has been relached, with no block command:
        // We use it for a zoom center command
        // We use it for a zoom center at cursor position command
        g_KeyPressed = localkey = EDA_ZOOM_CENTER_FROM_MOUSE;
        wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED,
                            ID_POPUP_ZOOM_CENTER );
        cmd.SetEventObject( this );
        GetEventHandler()->ProcessEvent( cmd );
    }
    }




Loading