Commit 5c3b480a authored by dickelbeck's avatar dickelbeck
Browse files

center PCBNEW parts on screen when tracking clicks and parts from EESCHEMA

parent 6acce67a
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -20,6 +20,10 @@ email address.
    in PCBNEW when there is more than one click candidate at the same mouse
    or cursor coordinates.  COLLECTOR not committed yet.
  * More beautification.
  * The mouse click and part synchronization from EESCHEMA to PCBNEW would 
    track fine but would not always position the PCBNEW part on screen.  Now
    we center it unconditionally.  No change was made in the reverse direction
    since that code uses the long established Find support.
    

2007-Aug-14 UPDATE   Dick Hollenbeck <dick@softplc.com>
+7 −3
Original line number Diff line number Diff line
@@ -31,8 +31,10 @@ void RemoteCommand( const char* cmdline )
{
    char             line[1024];
    wxString         msg;
    char*            idcmd, * text;
    char*            idcmd;
    char*            text;
    WinEDA_PcbFrame* frame = EDA_Appl->m_PcbFrame;
    MODULE*          module;

    strncpy( line, cmdline, sizeof(line) - 1 );
    msg = CONV_FROM_UTF8( line );
@@ -48,7 +50,7 @@ void RemoteCommand( const char* cmdline )
    {
        msg    = CONV_FROM_UTF8( text );
        
        MODULE* module = ReturnModule( frame->m_Pcb, msg );
        module = ReturnModule( frame->m_Pcb, msg );
        
        msg.Printf( _( "Locate module %s %s" ), msg.GetData(),
                   module ? wxT( "Ok" ) : wxT( "not found" ) );
@@ -68,7 +70,6 @@ void RemoteCommand( const char* cmdline )
    if( idcmd && strcmp( idcmd, "$PIN:" ) == 0 )
    {
        wxString pinName, modName;
        MODULE*  module;
        D_PAD*   pad = NULL;
        int      netcode = -1;
        
@@ -112,6 +113,9 @@ void RemoteCommand( const char* cmdline )
            msg.Printf( _( "Locate Pin %s (module %s)" ), pinName.GetData(), modName.GetData() );
        frame->Affiche_Message( msg );
    }
        
    if( module )    // center the module on screen.
        frame->Recadre_Trace( false );
}


+376 −357
Original line number Diff line number Diff line
@@ -3,8 +3,8 @@
/************/

/*
	Fonctions de gestion du zoom, du pas de grille et du
	recadrage automatique
 *  Fonctions de gestion du zoom, du pas de grille et du
 *  recadrage automatique
 */

#include "fctsys.h"
@@ -40,15 +40,15 @@
/**************************************************/
void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse )
/**************************************************/
/* Calcule les offsets de trace.
	Les offsets sont ajusts a un multiple du pas de grille
	si ToMouse == TRUE, le curseur souris (curseur "systeme") est replace
	en position curseur graphique (curseur kicad)

	Note: Mac OS ** does not ** allow moving mouse cursor by program.
/* Calcule les offsets de trace.
 *  Les offsets sont ajusts a un multiple du pas de grille
 *  si ToMouse == TRUE, le curseur souris (curseur "systeme") est replace
 *  en position curseur graphique (curseur kicad)
 * 
 *  Note: Mac OS ** does not ** allow moving mouse cursor by program.
 */
{

    /* decalages a apporter au trace en coordonnees ecran */
    PutOnGrid( &m_CurrentScreen->m_Curseur );
    AdjustScrollBars();
@@ -60,15 +60,18 @@ void WinEDA_DrawFrame::Recadre_Trace(bool ToMouse)
        DrawPanel->MouseToCursorSchema();
}


/************************************************/
void WinEDA_DrawFrame::PutOnGrid( wxPoint* coord )
/************************************************/
/* retourne la valeur de la coordonnee coord sur le point de grille le plus proche */
{
    double ftmp;

    if( !m_CurrentScreen->m_UserGridIsON )
    {
        wxSize grid_size = m_CurrentScreen->GetGrid();
        
        ftmp     = (double) coord->x / grid_size.x;
        coord->x = ( (int) round( ftmp ) ) * grid_size.x;

@@ -79,22 +82,28 @@ double ftmp;
    {
        double pasx = m_CurrentScreen->m_UserGrid.x * m_InternalUnits;
        double pasy = m_CurrentScreen->m_UserGrid.y * m_InternalUnits;
        
        if( m_CurrentScreen->m_UserGridUnit != INCHES )
        {
		pasx /= 25.4; pasy /= 25.4;
            pasx /= 25.4; 
            pasy /= 25.4;
        }
        
        int    nn = (int) round( coord->x / pasx );
        coord->x = (int) round( pasx * nn );
        
        nn = (int) round( coord->y / pasy );
        coord->y = (int) round( pasy * nn );
    }
}


/**************************************************************/
void WinEDA_DrawFrame::Zoom_Automatique( bool move_mouse_cursor )
/**************************************************************/

/* Affiche le Schema au meilleur zoom au meilleur centrage pour le dessin
	de facon a avoir toute la feuille affichee a l'ecran
 *  de facon a avoir toute la feuille affichee a l'ecran
 */
{
    int bestzoom;
@@ -104,11 +113,13 @@ int bestzoom;
    Recadre_Trace( move_mouse_cursor );
}


/*************************************************/
void WinEDA_DrawFrame::Window_Zoom( EDA_Rect& Rect )
/*************************************************/

/* Compute the zoom factor and the new draw offset to draw the
	selected area (Rect) in full window screen
 *  selected area (Rect) in full window screen
 */
{
    int    ii, jj;
@@ -121,7 +132,8 @@ wxSize size;
    ii       = Rect.GetSize().x / size.x;
    jj       = Rect.GetSize().y / size.y;
    bestzoom = MAX( ii, jj );
	if ( bestzoom <= 0 ) bestzoom = 1;
    if( bestzoom <= 0 )
        bestzoom = 1;

    m_CurrentScreen->SetZoom( bestzoom );

@@ -129,11 +141,13 @@ wxSize size;
    Recadre_Trace( TRUE );
}


/*****************************************************************/
void WinEDA_DrawPanel::Process_Popup_Zoom( wxCommandEvent& event )
/*****************************************************************/

/* Gere les commandes de zoom appeles par le menu Popup
Toute autre commande est transmise a Parent->Process_Special_Functions(event)
 *  Toute autre commande est transmise a Parent->Process_Special_Functions(event)
 */
{
    int        id = event.GetId();
@@ -289,6 +303,7 @@ wxClientDC dc(this);
    m_Parent->Affiche_Status_Box();
}


class grid_list_struct
{
public:
@@ -301,8 +316,9 @@ public:
/*************************************************************/
void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
/*************************************************************/

/* add the zoom list menu the the MasterMenu.
	used in OnRightClick(wxMouseEvent& event)
 *  used in OnRightClick(wxMouseEvent& event)
 */
{
    int              zoom;
@@ -370,6 +386,7 @@ wxMenu * grid_choice = new wxMenu;
                               ID_POPUP_GRID_SELECT, _( "Grid Select" ), grid_select_xpm );

    grid = m_Parent->m_CurrentScreen->GetGrid();

    switch( m_Parent->m_Ident )
    {
    case MODULE_EDITOR_FRAME:
@@ -389,6 +406,7 @@ wxMenu * grid_choice = new wxMenu;
            if( grid.x == grid_list_pcb[ii].m_value )
                grid_choice->Check( grid_list_pcb[ii].m_id, TRUE );
        }

        break;

    case SCHEMATIC_FRAME:
@@ -403,6 +421,7 @@ wxMenu * grid_choice = new wxMenu;
            if( grid.x == grid_list_schematic[ii].m_value )
                grid_choice->Check( grid_list_schematic[ii].m_id, TRUE );
        }

        break;

    case VIEWER_FRAME:
@@ -414,13 +433,13 @@ wxMenu * grid_choice = new wxMenu;
}



/**********************************************************/
void WinEDA_DrawFrame::Process_Zoom( wxCommandEvent& event )
/**********************************************************/

/* fonction de traitement des boutons de Zoom.
	Appelle simplement la fonction de traitement du Zoom de la
	fenetre active.
 *  Appelle simplement la fonction de traitement du Zoom de la
 *  fenetre active.
 */
{
    int id = event.GetId();