Commit 22c85e78 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

EAGLE_PLUGIN cu layer map fix

parent 1be0b66d
Loading
Loading
Loading
Loading
+28 −4
Original line number Diff line number Diff line
@@ -1158,6 +1158,10 @@ void EAGLE_PLUGIN::init( PROPERTIES* aProperties )
{
    m_hole_count = 0;

    // all cu layers are invalid until we see one in the <layers> section while board loading.
    for( unsigned i = 0;  i < DIM(m_cu_map);  ++i )
        m_cu_map[i] = -1;

    m_xpath->clear();
    m_pads_to_nets.clear();

@@ -1245,6 +1249,27 @@ void EAGLE_PLUGIN::loadLayerDefs( CPTREE& aLayers )
        }
    }

    // establish cu layer map:
    int ki_layer_count = 0;
    for( EITER it = cu.begin();  it != cu.end();  ++it,  ++ki_layer_count )
    {
        if( ki_layer_count == 0 )
            m_cu_map[it->number] = LAYER_N_FRONT;
        else if( ki_layer_count == int( cu.size()-1 ) )
            m_cu_map[it->number] = LAYER_N_BACK;
        else
            // some eagle boards do not have contiguous layer number sequences.
            m_cu_map[it->number] = cu.size() - 1 - ki_layer_count;
    }

#if 0 && defined(DEBUG)
    printf( "m_cu_map:\n" );
    for( unsigned i=0; i<DIM(m_cu_map);  ++i )
    {
        printf( "\t[%d]:%d\n", i, m_cu_map[i] );
    }
#endif

    m_board->SetCopperLayerCount( cu.size() );

    for( EITER it = cu.begin();  it != cu.end();  ++it )
@@ -2438,7 +2463,7 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals )
}


int EAGLE_PLUGIN::kicad_layer( int aEagleLayer )
int EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const
{
    /* will assume this is a valid mapping for all eagle boards until I get paid more:

@@ -2507,13 +2532,12 @@ int EAGLE_PLUGIN::kicad_layer( int aEagleLayer )

    */


    int kiLayer;

    // eagle copper layer:
    if( aEagleLayer >= 1 && aEagleLayer <= 16 )
    if( aEagleLayer >= 1 && aEagleLayer < int( DIM( m_cu_map ) ) )
    {
        kiLayer = LAYER_N_FRONT - ( aEagleLayer - 1 );
        return m_cu_map[aEagleLayer];
    }

    else
+3 −1
Original line number Diff line number Diff line
@@ -116,6 +116,8 @@ public:

private:

    int         m_cu_map[17];       ///< map eagle to kicad, cu layers only.

    ERULES*     m_rules;            ///< Eagle design rules.
    XPATH*      m_xpath;            ///< keeps track of what we are working on within
                                    ///< XML document during a Load().
@@ -149,7 +151,7 @@ private:
    wxSize  kicad_fontz( double d ) const;

    /// Convert an Eagle layer to a KiCad layer.
    static int kicad_layer( int aLayer );
    int     kicad_layer( int aLayer ) const;

    /// Convert a KiCad distance to an Eagle distance.
    double  eagle( BIU d ) const            { return mm_per_biu * d; }