Commit 1ecea828 authored by stambaughw's avatar stambaughw
Browse files

Initial ground work for zoom improvements and minor build updates.

parent a64f1567
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -5,6 +5,18 @@ 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.


2008-Dec-18 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++all
  * Virtualize DrawFrame class methods required to eliminate compiling
    drawframe.cpp multiple times depending on the application being built.
  * Move zoom.cpp and drawframe.cpp to common library and update CMake files.
  * drawpanel.cpp - Extracted mouse wheel events out of mouse event handler,
    generate commands for mouse wheel events, and moved panning from DrawFrame
    class into DrawPanel class.
  * Initial ground work for new zoom implementation.


2008-Dec-15 UPDATE Dick Hollenbeck <dick@softplc.com>
2008-Dec-15 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
================================================================================
++gerbview
++gerbview
+3 −1
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@ set(COMMON_SRCS
    dcsvg.cpp
    dcsvg.cpp
    displlst.cpp
    displlst.cpp
    dlist.cpp
    dlist.cpp
    drawframe.cpp
    drawpanel.cpp
    drawpanel.cpp
    drawtxt.cpp
    drawtxt.cpp
    edaappl.cpp
    edaappl.cpp
@@ -34,6 +35,7 @@ set(COMMON_SRCS
    toolbars.cpp
    toolbars.cpp
    trigo.cpp
    trigo.cpp
    worksheet.cpp
    worksheet.cpp
    wxwineda.cpp)
    wxwineda.cpp
    zoom.cpp)


add_library(common ${COMMON_SRCS})
add_library(common ${COMMON_SRCS})
+15 −137
Original line number Original line Diff line number Diff line
@@ -7,32 +7,13 @@
#endif
#endif


#include "fctsys.h"
#include "fctsys.h"

#include "common.h"
#include "common.h"

#ifdef PCBNEW
#include "pcbnew.h"
#endif

#ifdef EESCHEMA
#include "program.h"
#include "libcmp.h"
#include "general.h"
#endif

#ifdef CVPCB
#include "pcbnew.h"
#include "cvpcb.h"
#endif

#include <wx/fontdlg.h>

#include "bitmaps.h"
#include "bitmaps.h"

#include "macros.h"
#include "protos.h"

#include "id.h"
#include "id.h"


#include <wx/fontdlg.h>



/*******************************************************/
/*******************************************************/
/* Constructeur de WinEDA_DrawFrame: la fenetre generale */
/* Constructeur de WinEDA_DrawFrame: la fenetre generale */
@@ -72,8 +53,7 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype,
    m_InternalUnits = EESCHEMA_INTERNAL_UNIT;
    m_InternalUnits = EESCHEMA_INTERNAL_UNIT;
    if( ( m_Ident == PCB_FRAME ) || ( m_Ident == GERBER_FRAME )
    if( ( m_Ident == PCB_FRAME ) || ( m_Ident == GERBER_FRAME )
        || ( m_Ident == CVPCB_DISPLAY_FRAME )
        || ( m_Ident == CVPCB_DISPLAY_FRAME )
       || (m_Ident == MODULE_EDITOR_FRAME)
        || ( m_Ident == MODULE_EDITOR_FRAME ) )
        )
        m_InternalUnits = PCB_INTERNAL_UNIT;
        m_InternalUnits = PCB_INTERNAL_UNIT;


    minsize.x = 470;
    minsize.x = 470;
@@ -104,9 +84,11 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype,


    if( m_Ident != DISPLAY3D_FRAME )
    if( m_Ident != DISPLAY3D_FRAME )
    {
    {
        DrawPanel = new WinEDA_DrawPanel( this, -1, wxPoint( 0, 0 ), m_FrameSize );
        DrawPanel = new WinEDA_DrawPanel( this, -1, wxPoint( 0, 0 ),
                                          m_FrameSize );
        MsgPanel  = new WinEDA_MsgPanel( this, -1, wxPoint( 0, m_FrameSize.y ),
        MsgPanel  = new WinEDA_MsgPanel( this, -1, wxPoint( 0, m_FrameSize.y ),
                                        wxSize( m_FrameSize.x, m_MsgFrameHeight ) );
                                         wxSize( m_FrameSize.x,
                                                 m_MsgFrameHeight ) );
        MsgPanel->SetBackgroundColour( wxColour( ColorRefs[LIGHTGRAY].m_Red,
        MsgPanel->SetBackgroundColour( wxColour( ColorRefs[LIGHTGRAY].m_Red,
                                                 ColorRefs[LIGHTGRAY].m_Green,
                                                 ColorRefs[LIGHTGRAY].m_Green,
                                                 ColorRefs[LIGHTGRAY].m_Blue ) );
                                                 ColorRefs[LIGHTGRAY].m_Blue ) );
@@ -500,8 +482,6 @@ void WinEDA_DrawFrame::SetToolID( int id, int new_cursor_id,
 *  Met a jour seulement les variables message et  curseur
 *  Met a jour seulement les variables message et  curseur
 */
 */
{
{
    bool redraw = false;

    // Change Cursor
    // Change Cursor
    if( DrawPanel )
    if( DrawPanel )
    {
    {
@@ -514,16 +494,6 @@ void WinEDA_DrawFrame::SetToolID( int id, int new_cursor_id,
    if( id < 0 )
    if( id < 0 )
        return;
        return;


#ifdef PCBNEW
    // handle color changes for transitions in and out of ID_TRACK_BUTT
    if( ( m_ID_current_state==ID_TRACK_BUTT && id!=ID_TRACK_BUTT )
     || ( m_ID_current_state!=ID_TRACK_BUTT && id==ID_TRACK_BUTT ) )
    {
        if( DisplayOpt.ContrastModeDisplay )
            redraw = true;
    }
#endif

    // Old Tool Inactif ou ID_NO_SELECT_BUTT actif si pas de nouveau Tool
    // Old Tool Inactif ou ID_NO_SELECT_BUTT actif si pas de nouveau Tool
    if( m_ID_current_state )
    if( m_ID_current_state )
    {
    {
@@ -560,11 +530,6 @@ void WinEDA_DrawFrame::SetToolID( int id, int new_cursor_id,
        m_VToolBar->ToggleTool( ID_NO_SELECT_BUTT, TRUE );
        m_VToolBar->ToggleTool( ID_NO_SELECT_BUTT, TRUE );


    m_ID_current_state = id;
    m_ID_current_state = id;

    // must do this after the tool has been set, otherwise pad::Draw() does
    // not show proper color when DisplayOpt.ContrastModeDisplay is true.
    if( redraw )
        ReDrawPanel();
}
}




@@ -634,24 +599,6 @@ void WinEDA_DrawFrame::OnZoom( int zoom_type )
        Zoom_Automatique( FALSE );
        Zoom_Automatique( FALSE );
        break;
        break;


    case ID_ZOOM_PANNING_UP:
        OnPanning( ID_ZOOM_PANNING_UP );
        break;

    case ID_ZOOM_PANNING_DOWN:
        OnPanning( ID_ZOOM_PANNING_DOWN );
        break;

    case ID_ZOOM_PANNING_LEFT:
        OnPanning( ID_ZOOM_PANNING_LEFT );
        DrawPanel->CursorOn( NULL );
        break;

    case ID_ZOOM_PANNING_RIGHT:
        OnPanning( ID_ZOOM_PANNING_RIGHT );
        break;


    default:
    default:
        wxMessageBox( wxT( "WinEDA_DrawFrame::OnZoom switch Error" ) );
        wxMessageBox( wxT( "WinEDA_DrawFrame::OnZoom switch Error" ) );
        break;
        break;
@@ -661,59 +608,6 @@ void WinEDA_DrawFrame::OnZoom( int zoom_type )
}
}




/**********************************************/
void WinEDA_DrawFrame::OnPanning( int direction )
/**********************************************/

/* 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;

    int        delta;
    wxClientDC dc( DrawPanel );

    int        x, y;


    DrawPanel->PrepareGraphicContext( &dc );
    DrawPanel->GetViewStart( &x, &y );  // x and y are in scroll unit, not in pixels
    delta = DrawPanel->m_ScrollButt_unit;

    switch( direction )
    {
    case ID_ZOOM_PANNING_UP:
        y -= delta;
        break;

    case ID_ZOOM_PANNING_DOWN:
        y += delta;
        break;

    case ID_ZOOM_PANNING_LEFT:
        x -= delta;
        break;

    case ID_ZOOM_PANNING_RIGHT:
        x += delta;
        break;

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

    DrawPanel->Scroll( x, y );

    /* Place le curseur souris sur le curseur SCHEMA*/
    DrawPanel->MouseToCursorSchema();
}


/*****************************/
/*****************************/
/* default virtual fonctions */
/* default virtual fonctions */
/*****************************/
/*****************************/
@@ -874,12 +768,14 @@ void WinEDA_DrawFrame::SetLanguage( wxCommandEvent& event )
}
}




/***********************************************/
/*
void WinEDA_DrawFrame::Affiche_Status_Box()
 * Update the status bar information.
/***********************************************/
 *

 * The base method updates the absolute and relative cooridinates and the
/* Routine d'affichage du zoom et des coord curseur.
 * zoom information.  If you override this virtual method, make sure to call
 * this subclassed method.
 */
 */
void WinEDA_DrawFrame::Affiche_Status_Box()
{
{
    wxString        Line;
    wxString        Line;
    int             dx, dy;
    int             dx, dy;
@@ -908,22 +804,4 @@ void WinEDA_DrawFrame::Affiche_Status_Box()
                 To_User_Unit( g_UnitMetric, dy, m_InternalUnits ) );
                 To_User_Unit( g_UnitMetric, dy, m_InternalUnits ) );


    SetStatusText( Line, 3 );
    SetStatusText( Line, 3 );

#ifdef PCBNEW
    if( DisplayOpt.DisplayPolarCood )  /* Display coordonnee polaire */
    {
        double theta, ro;
        if( (dx == 0) && (dy == 0) )
            theta = 0.0;
        else
            theta = atan2( (double) -dy, (double) dx );
        theta = theta * 180 / M_PI;

        ro = sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) );
        Line.Printf( g_UnitMetric ? wxT( "Ro %.3f Th %.1f" ) : wxT( "Ro %.4f Th %.1f" ),
                     To_User_Unit( g_UnitMetric, (int) round( ro ), m_InternalUnits ),
                     theta );
        SetStatusText( Line, 0 );
    }
#endif
}
}
+78 −24
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ static bool s_IgnoreNextLeftButtonRelease = false;
// Events used by WinEDA_DrawPanel
// Events used by WinEDA_DrawPanel
BEGIN_EVENT_TABLE( WinEDA_DrawPanel, wxScrolledWindow )
BEGIN_EVENT_TABLE( WinEDA_DrawPanel, wxScrolledWindow )
    EVT_LEAVE_WINDOW( WinEDA_DrawPanel::OnMouseLeaving )
    EVT_LEAVE_WINDOW( WinEDA_DrawPanel::OnMouseLeaving )
    EVT_MOUSEWHEEL( WinEDA_DrawPanel::OnMouseWheel )
    EVT_MOUSE_EVENTS( WinEDA_DrawPanel::OnMouseEvent )
    EVT_MOUSE_EVENTS( WinEDA_DrawPanel::OnMouseEvent )
    EVT_CHAR( WinEDA_DrawPanel::OnKeyEvent )
    EVT_CHAR( WinEDA_DrawPanel::OnKeyEvent )
    EVT_CHAR_HOOK( WinEDA_DrawPanel::OnKeyEvent )
    EVT_CHAR_HOOK( WinEDA_DrawPanel::OnKeyEvent )
@@ -42,6 +43,7 @@ BEGIN_EVENT_TABLE( WinEDA_DrawPanel, wxScrolledWindow )
                    WinEDA_DrawPanel::Process_Popup_Zoom )
                    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 )
END_EVENT_TABLE()
END_EVENT_TABLE()


/************************************************************************/
/************************************************************************/
@@ -899,6 +901,47 @@ void WinEDA_DrawPanel::OnMouseLeaving( wxMouseEvent& event )
}
}




/*
 * Handle mouse wheel events.
 *
 * The mouse wheel is used to provide support for zooming and panning.  This
 * is accomplished by converting mouse wheel events in psuedo menu command
 * events.
 */
void WinEDA_DrawPanel::OnMouseWheel( wxMouseEvent& event )
{
    if( event.GetWheelRotation() == 0 )
    {
        event.Skip();
        return;
    }

    wxCommandEvent cmd(  wxEVT_COMMAND_MENU_SELECTED );
    cmd.SetEventObject( this );

    // This is a zoom in ou out command
    if( event.GetWheelRotation() > 0 )
    {
        if( event.ShiftDown() && !event.ControlDown() )
            cmd.SetId( ID_PAN_UP );
        else if( event.ControlDown() && !event.ShiftDown() )
            cmd.SetId( ID_PAN_LEFT );
        else
            cmd.SetId( ID_POPUP_ZOOM_IN );
    }
    else if ( event.GetWheelRotation() < 0 )
    {
        if( event.ShiftDown() && !event.ControlDown() )
            cmd.SetId( ID_PAN_DOWN );
        else if( event.ControlDown() && !event.ShiftDown() )
            cmd.SetId( ID_PAN_RIGHT );
        else
            cmd.SetId( ID_POPUP_ZOOM_OUT );
    }

    GetEventHandler()->ProcessEvent( cmd );
}

/******************************************************/
/******************************************************/
void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
/*******************************************************/
/*******************************************************/
@@ -932,30 +975,6 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
    else
    else
        return;
        return;


    // Mouse Wheel is a zoom command:
    if( event.m_wheelRotation )
    {
        // This is a zoom in ou out command
        if( event.GetWheelRotation() > 0 )
        {
            if( event.ShiftDown() )
                localkey = EDA_PANNING_UP_KEY;
            else if( event.ControlDown() )
                localkey = EDA_PANNING_LEFT_KEY;
            else
                localkey = EDA_ZOOM_IN_FROM_MOUSE;
        }
        else
        {
            if( event.ShiftDown() )
                localkey = EDA_PANNING_DOWN_KEY;
            else if( event.ControlDown() )
                localkey = EDA_PANNING_RIGHT_KEY;
            else
                localkey = EDA_ZOOM_OUT_FROM_MOUSE;
        }
    }

    if( !event.IsButton() && !event.Moving()
    if( !event.IsButton() && !event.Moving()
        && !event.Dragging() && !localkey )
        && !event.Dragging() && !localkey )
    {
    {
@@ -1283,3 +1302,38 @@ void WinEDA_DrawPanel::OnKeyEvent( wxKeyEvent& event )
    event.Skip();   // Allow menu shortcut processing
    event.Skip();   // Allow menu shortcut processing
#endif
#endif
}
}

void WinEDA_DrawPanel::OnPan( wxCommandEvent& event )
{
    int        x, y;
    wxClientDC dc( this );

    PrepareGraphicContext( &dc );
    GetViewStart( &x, &y );       // x and y are in scroll units, not in pixels

    switch( event.GetId() )
    {
    case ID_PAN_UP:
        y -= m_ScrollButt_unit;
        break;

    case ID_PAN_DOWN:
        y += m_ScrollButt_unit;
        break;

    case ID_PAN_LEFT:
        x -= m_ScrollButt_unit;
        break;

    case ID_PAN_RIGHT:
        x += m_ScrollButt_unit;
        break;

    default:
        wxLogDebug( wxT( "Unknown ID %d in WinEDA_DrawPanel::OnPan()." ),
                    event.GetId() );
    }

    Scroll( x, y );
    MouseToCursorSchema();
}
+7 −0
Original line number Original line Diff line number Diff line
@@ -527,6 +527,10 @@ bool WinEDA_App::SetLanguage( bool first_time )
    m_Locale = new wxLocale();
    m_Locale = new wxLocale();
    m_Locale->Init( m_LanguageId );
    m_Locale->Init( m_LanguageId );
    dic_path = ReturnKicadDatasPath() + BaseDictionaryPath;
    dic_path = ReturnKicadDatasPath() + BaseDictionaryPath;

    wxLogDebug( wxT( "Adding prefix <" ) + dic_path +
                wxT( "> to language lookup path." ) );

    m_Locale->AddCatalogLookupPathPrefix( dic_path );
    m_Locale->AddCatalogLookupPathPrefix( dic_path );


    if( !first_time )
    if( !first_time )
@@ -554,6 +558,9 @@ void WinEDA_App::SetLanguageIdentifier( int menu_id )
{
{
    unsigned int ii;
    unsigned int ii;


    wxLogDebug( wxT( "Select language ID %d from %d possible languages." ),
                menu_id, LANGUAGE_DESCR_COUNT );

    for( ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ )
    for( ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ )
    {
    {
        if( menu_id == s_Language_List[ii].m_KI_Lang_Identifier )
        if( menu_id == s_Language_List[ii].m_KI_Lang_Identifier )
Loading