Commit 1d3f2d52 authored by charras's avatar charras
Browse files

Pcbnew : refinements for user grig

parent aee56a93
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -12,8 +12,7 @@ email address.
    This is mandatory in Pcbnew to handle metric user grids without error
    (was unusable before, using integer grid size).
    A lot of footprints uses not metric grid.
    TODO:
        more refinements for user grid (mainly in read/wrire config).
    refinements for user grid (mainly in read/write config).


2009-Feb-06 UPDATE Dick Hollenbeck <dick@softplc.com>
+9 −7
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
#include "base_struct.h"
#include "sch_item_struct.h"
#include "class_base_screen.h"
#include "id.h"

/* Implement wxSize array for grid list implementation. */
#include <wx/arrimpl.cpp>
@@ -356,7 +357,7 @@ void BASE_SCREEN::SetGrid( int id )
    m_Grid = m_GridList[0].m_Size;

    wxLogWarning( _( "Grid ID %d not in grid list, falling back to " \
                     "grid size( %f, %f )." ), id, m_Grid.x, m_Grid.y );
                     "grid size( %g, %g )." ), id, m_Grid.x, m_Grid.y );
}

void BASE_SCREEN::AddGrid( const GRID_TYPE& grid )
@@ -365,16 +366,17 @@ void BASE_SCREEN::AddGrid( const GRID_TYPE& grid )

    for( i = 0; i < m_GridList.GetCount(); i++ )
    {
        if( m_GridList[i].m_Size == grid.m_Size )
        if( m_GridList[i].m_Size == grid.m_Size &&
               grid.m_Id != ID_POPUP_GRID_USER)
        {
            wxLogDebug( wxT( "Discarding duplicate grid size( %d, %d )." ),
            wxLogDebug( wxT( "Discarding duplicate grid size( %g, %g )." ),
                        grid.m_Size.x, grid.m_Size.y );
            return;
        }
        if( m_GridList[i].m_Id == grid.m_Id )
        {
            wxLogDebug( wxT( "Changing grid ID %d from size( %d, %d ) to " \
                             "size( %d, %d )." ),
            wxLogDebug( wxT( "Changing grid ID %d from size( %g, %g ) to " \
                             "size( %g, %g )." ),
                        grid.m_Id, m_GridList[i].m_Size.x,
                        m_GridList[i].m_Size.y, grid.m_Size.x, grid.m_Size.y );
            m_GridList[i].m_Size = grid.m_Size;
@@ -418,8 +420,8 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, int units, int id )
        y = size.y;
    }

    new_size = wxRealPoint( x * (double) GetInternalUnits(),
                       y * (double) GetInternalUnits()  );
    new_size.x = x * GetInternalUnits();
    new_size.y = y * GetInternalUnits();

    new_grid.m_Id = id;
    new_grid.m_Size = new_size;
+0 −36
Original line number Diff line number Diff line
@@ -362,38 +362,6 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
            continue;
        }

        if( stricmp( Line, "UserGridSize" ) == 0 )
        {
            wxString msg;
            if( data )
            {
                msg = CONV_FROM_UTF8( data );
                msg.ToDouble( &g_UserGrid.x );
            }
            else
                continue;

            data = strtok( NULL, " =\n\r" );
            if( data )
            {
                msg = CONV_FROM_UTF8( data );
                msg.ToDouble( &g_UserGrid.y );
            }
            else
                g_UserGrid.y = g_UserGrid.x;

            data = strtok( NULL, " =\n\r" );
            if( data )
            {
                if( stricmp( data, "mm" ) == 0 )
                    g_UserGrid_Unit = MILLIMETRE;
                else
                    g_UserGrid_Unit = INCHES;
                GetScreen()->AddGrid( g_UserGrid, g_UserGrid_Unit,
                                      ID_POPUP_GRID_USER );
            }
            continue;
        }

        if( stricmp( Line, "DrawSegmWidth" ) == 0 )
        {
@@ -512,10 +480,6 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard )
    sprintf( text, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT );
    fprintf( aFile, text );

    sprintf( text, "UserGridSize %lf %lf %s\n", g_UserGrid.x, g_UserGrid.y,
             ( g_UserGrid_Unit == 0 ) ? "INCH" : "mm" );
    fprintf( aFile, text );

    fprintf( aFile, "ZoneGridSize %d\n", g_GridRoutingSize );

    fprintf( aFile, "Layers %d\n", aBoard->GetCopperLayerCount() );
+9 −20
Original line number Diff line number Diff line
@@ -19,8 +19,7 @@
#include "3d_viewer.h"

// Keys used in read/write config
#define MODEDIT_CURR_GRID_X wxT( "ModEditCurrGrid_X" )
#define MODEDIT_CURR_GRID_Y wxT( "ModEditCurrGrid_Y" )
#define MODEDIT_CURR_GRID wxT( "ModEditCurrGrid" )

/********************************/
/* class WinEDA_ModuleEditFrame */
@@ -188,23 +187,8 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
    GetScreen()->SetCurItem( NULL );
    GetSettings();

    wxRealPoint GridSize( 500, 500 );
    if( config )
    {
        double SizeX, SizeY;
        if( config->Read( MODEDIT_CURR_GRID_X, &SizeX )
            && config->Read( MODEDIT_CURR_GRID_Y, &SizeY ) )
        {
            GridSize.x = SizeX;
            GridSize.y = SizeY;
        }

    }

    GetScreen()->AddGrid( g_UserGrid, g_UserGrid_Unit, ID_POPUP_GRID_USER );

    GetScreen()->SetGrid( GridSize );

    SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
    ReCreateMenuBar();
    ReCreateHToolbar();
@@ -212,6 +196,13 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
    ReCreateVToolbar();
    ReCreateOptToolbar();

    if( config )
    {
        long gridselection = 1;
        config->Read( MODEDIT_CURR_GRID, &gridselection );
        GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + gridselection  );
    }

    if( DrawPanel )
        DrawPanel->m_Block_Enable = TRUE;
}
@@ -244,9 +235,7 @@ void WinEDA_ModuleEditFrame::OnCloseWindow( wxCloseEvent& Event )
    SaveSettings();
    if( config )
    {
        wxRealPoint GridSize = GetScreen()->GetGrid();
        config->Write( MODEDIT_CURR_GRID_X, GridSize.x );
        config->Write( MODEDIT_CURR_GRID_Y, GridSize.y );
        config->Write( MODEDIT_CURR_GRID, m_SelGridBox->GetSelection() );
    }
    Destroy();
}
+3 −28
Original line number Diff line number Diff line
@@ -719,31 +719,6 @@ static PARAM_CFG_INT WTraitSerigraphiePlotCfg
    1, 10000                    /* Min and max values*/
);

static PARAM_CFG_DOUBLE UserGrilleXCfg
(
    wxT( "UserGrX" ),           /* Keyword */
    &g_UserGrid.x,              /* Parameter address */
    0.01,                       /* Default value */
    0.0001, 100.0               /* Min and max values(inches)*/
);

static PARAM_CFG_DOUBLE UserGrilleYCfg
(
    wxT( "UserGrY" ),           /* Keyword */
    &g_UserGrid.y,              /* Parameter address */
    0.01,                       /* Default value */
    0.0001, 100.0               /* Min and max values (inches)*/
);

static PARAM_CFG_INT UserGrilleUnitCfg
(
    wxT( "UserGrU" ),               /* Keyword */
    &g_UserGrid_Unit,               /* Parameter address */
    1,                              /* Default value */
    0, 1                            /* Min and max values*/
);


static PARAM_CFG_INT TimeOutCfg     //Duree entre Sauvegardes auto en secondes
(
    INSETUP,
@@ -803,6 +778,9 @@ static PARAM_CFG_BOOL TwoSegmentTrackBuildCfg
    TRUE                            /* Default value */
);


/* parameters in this list will be saved on request (when saving config).
*/
PARAM_CFG_BASE* ParamCfgList[] =
{
    &UserLibDirBufCfg,
@@ -893,9 +871,6 @@ PARAM_CFG_BASE* ParamCfgList[] =
    &TexteSegmLargeurCfg,
    &ModuleSegmWidthCfg,
    &WTraitSerigraphiePlotCfg,
    &UserGrilleXCfg,
    &UserGrilleYCfg,
    &UserGrilleUnitCfg,
    &TimeOutCfg,
    &DisplPolairCfg,
    &CursorShapeCfg,
Loading