Commit 9086e68d authored by dickelbeck's avatar dickelbeck
Browse files

specctra_export fix for pads with offsets

parent 708a394c
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -5,6 +5,15 @@ 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-Feb-20 UPDATE   Dick Hollenbeck <dick@softplc.com>
================================================================================
+pcbnew
    specctra_export.cpp fixed the offset problem with freerouter.net.
    http://tech.groups.yahoo.com/group/kicad-devel/message/1076


2008-Feb-19 UPDATE   Dick Hollenbeck <dick@softplc.com>
2008-Feb-19 UPDATE   Dick Hollenbeck <dick@softplc.com>
================================================================================
================================================================================
+pcbnew
+pcbnew
+59 −57
Original line number Original line Diff line number Diff line
@@ -298,17 +298,6 @@ static bool isKeepout( D_PAD* aPad )
}
}




/*
static int Pad_list_Sort_by_Shapes( const void* refptr, const void* objptr )
{
    const D_PAD* padref = *(D_PAD**)refptr;
    const D_PAD* padcmp = *(D_PAD**)objptr;

    return D_PAD::Compare( padref, padcmp );
}
*/


/**
/**
 * Function makePath
 * Function makePath
 * creates a PATH element with a single straight line, a pair of vertices.
 * creates a PATH element with a single straight line, a pair of vertices.
@@ -325,13 +314,13 @@ static PATH* makePath( const POINT& aStart, const POINT& aEnd, const std::string




/**
/**
 * Struct wxString_less_than_
 * Struct wxString_less_than
 * is used the std:set<> and std::map<> instantiations below.
 * is used by the std:set<> and std::map<> instantiations below.
 * See STRINGSET typedef and PINMAP typedef below.
 * See STRINGSET typedef and PINMAP typedef below.
 */
 */
struct wxString_less_than
struct wxString_less_than
{
{
    // a "less than" test on two wxStrings, by pointer.
    // a "less than" test on two wxStrings
    bool operator()( const wxString& s1, const wxString& s2) const
    bool operator()( const wxString& s1, const wxString& s2) const
    {
    {
        return s1.Cmp( s2 ) < 0;  // case specific wxString compare
        return s1.Cmp( s2 ) < 0;  // case specific wxString compare
@@ -356,9 +345,8 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
        aPad->IsOnLayer( COPPER_LAYER_N )
        aPad->IsOnLayer( COPPER_LAYER_N )
    };
    };


    // caller must do this screen before calling here.
    // caller must do these checks before calling here.
    wxASSERT( !isKeepout( aPad ) );
    wxASSERT( !isKeepout( aPad ) );

    wxASSERT( doLayer[0] || doLayer[1] );
    wxASSERT( doLayer[0] || doLayer[1] );


    PADSTACK*   padstack = new PADSTACK();
    PADSTACK*   padstack = new PADSTACK();
@@ -366,6 +354,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
    int         reportedLayers = 0;              // how many in reported padstack
    int         reportedLayers = 0;              // how many in reported padstack
    const char* layerName[NB_COPPER_LAYERS];
    const char* layerName[NB_COPPER_LAYERS];



    if( aPad->m_Attribut==PAD_SMD || aPad->m_Attribut==PAD_CONN )
    if( aPad->m_Attribut==PAD_SMD || aPad->m_Attribut==PAD_CONN )
    {
    {
        // PAD_SMD and PAD_CONN are reported on each layer for which
        // PAD_SMD and PAD_CONN are reported on each layer for which
@@ -400,7 +389,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
        */
        */


        reportedLayers = 1;
        reportedLayers = 1;
        layerName[0] = signal;
        layerName[0] = "signal";
        uniqifier = "[A]";        // A for all
        uniqifier = "[A]";        // A for all


#else
#else
@@ -415,6 +404,23 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
#endif
#endif
    }
    }


    POINT   dsnOffset;

    if( aPad->m_Offset.x || aPad->m_Offset.y )
    {
        char offsetTxt[32];

        wxPoint offset( aPad->m_Offset.x, aPad->m_Offset.y );

        dsnOffset = mapPt( offset );

        // using '(' or ')' would cause padstack name to be quote wrapped,
        // so use other brackets, and {} locks freerouter.
        sprintf( offsetTxt, "[%.6g,%.6g]", dsnOffset.x, dsnOffset.y );

        uniqifier += offsetTxt;
    }

    switch( aPad->m_PadShape )
    switch( aPad->m_PadShape )
    {
    {
    default:
    default:
@@ -432,11 +438,13 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )


                circle->SetLayerId( layerName[ndx] );
                circle->SetLayerId( layerName[ndx] );
                circle->SetDiameter( diameter );
                circle->SetDiameter( diameter );
                circle->SetVertex( dsnOffset );
            }
            }


            snprintf( name, sizeof(name), "Round%sPad_%.6g_mil",
            snprintf( name, sizeof(name), "Round%sPad_%.6g_mil",
                     uniqifier.c_str(), scale(aPad->m_Size.x) );
                     uniqifier.c_str(), scale(aPad->m_Size.x) );
            name[ sizeof(name)-1 ] = 0;
            name[ sizeof(name)-1 ] = 0;

            padstack->SetPadstackId( name );
            padstack->SetPadstackId( name );
        }
        }
        break;
        break;
@@ -449,6 +457,9 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
            POINT   lowerLeft( -dx, -dy );
            POINT   lowerLeft( -dx, -dy );
            POINT   upperRight( dx, dy );
            POINT   upperRight( dx, dy );


            lowerLeft  += dsnOffset;
            upperRight += dsnOffset;

            for( int ndx=0;  ndx<reportedLayers;  ++ndx )
            for( int ndx=0;  ndx<reportedLayers;  ++ndx )
            {
            {
                SHAPE*      shape = new SHAPE( padstack );
                SHAPE*      shape = new SHAPE( padstack );
@@ -474,29 +485,29 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
            double  dx = scale( aPad->m_Size.x ) / 2.0;
            double  dx = scale( aPad->m_Size.x ) / 2.0;
            double  dy = scale( aPad->m_Size.y ) / 2.0;
            double  dy = scale( aPad->m_Size.y ) / 2.0;
            double  dr = dx - dy;
            double  dr = dx - dy;
            double  radius;
            POINT   start;
            POINT   stop;


            if( dr >= 0 )       // oval is horizontal
            if( dr >= 0 )       // oval is horizontal
            {
            {
                double  radius = dy;
                radius = dy;


                for( int ndx=0;  ndx<reportedLayers;  ++ndx )
                start = POINT( -dr, 0.0 );
                {
                stop  = POINT(  dr, 0.0 );
                    SHAPE*  shape;
                    PATH*   path;
                    // see http://www.freerouting.net/usren/viewtopic.php?f=3&t=317#p408
                    shape = new SHAPE( padstack );
                    padstack->Append( shape );
                    path = makePath( POINT(-dr, 0.0), POINT(dr, 0.0), layerName[ndx] );
                    shape->SetShape( path );
                    path->aperture_width = 2.0 * radius;
                }
            }
            }
            else        // oval is vertical
            else        // oval is vertical
            {
            {
                double  radius = dx;
                radius = dx;

                dr = -dr;
                dr = -dr;


                start = POINT( 0.0, -dr );
                stop  = POINT( 0.0,  dr );
            }

            start += dsnOffset;
            stop  += dsnOffset;

            for( int ndx=0;  ndx<reportedLayers;  ++ndx )
            for( int ndx=0;  ndx<reportedLayers;  ++ndx )
            {
            {
                SHAPE*  shape;
                SHAPE*  shape;
@@ -504,11 +515,10 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
                // see http://www.freerouting.net/usren/viewtopic.php?f=3&t=317#p408
                // see http://www.freerouting.net/usren/viewtopic.php?f=3&t=317#p408
                shape = new SHAPE( padstack );
                shape = new SHAPE( padstack );
                padstack->Append( shape );
                padstack->Append( shape );
                    path = makePath( POINT(0.0, -dr), POINT(0.0, dr), layerName[ndx] );
                path = makePath( start, stop, layerName[ndx] );
                shape->SetShape( path );
                shape->SetShape( path );
                path->aperture_width = 2.0 * radius;
                path->aperture_width = 2.0 * radius;
            }
            }
            }


            snprintf( name, sizeof(name),  "Oval%sPad_%.6gx%.6g_mil",
            snprintf( name, sizeof(name),  "Oval%sPad_%.6gx%.6g_mil",
                     uniqifier.c_str(), scale(aPad->m_Size.x), scale(aPad->m_Size.y)  );
                     uniqifier.c_str(), scale(aPad->m_Size.x), scale(aPad->m_Size.y)  );
@@ -596,7 +606,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )
            {
            {
                pinmap[ padName ] = 0;
                pinmap[ padName ] = 0;
            }
            }
            else
            else    // pad name is a duplicate within this module
            {
            {
                char buf[32];
                char buf[32];


@@ -613,22 +623,14 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )


            pin->padstack_id = padstack->padstack_id;
            pin->padstack_id = padstack->padstack_id;


            wxPoint pos( pad->m_Pos0 );
            wxPoint offset( pad->m_Offset.x, pad->m_Offset.y );

            int angle = pad->m_Orient - aModule->m_Orient;   // tenths of degrees
            int angle = pad->m_Orient - aModule->m_Orient;   // tenths of degrees
            if( angle )
            if( angle )
            {
            {
                NORMALIZE_ANGLE_POS(angle);
                NORMALIZE_ANGLE_POS(angle);
                pin->SetRotation( angle / 10.0 );
                pin->SetRotation( angle / 10.0 );

                if( pad->m_Offset.x || pad->m_Offset.y )
                {
                    RotatePoint( &offset, angle );
                }
            }
            }


            pos += offset;
            wxPoint pos( pad->m_Pos0 );


            pin->SetVertex( mapPt( pos )  );
            pin->SetVertex( mapPt( pos )  );
        }
        }
+8 −7
Original line number Original line Diff line number Diff line
@@ -73,12 +73,13 @@ void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )


    fullFileName = EDA_FileSelector( _( "Merge Specctra Session file:" ),
    fullFileName = EDA_FileSelector( _( "Merge Specctra Session file:" ),
                            path,
                            path,
                          name,             // name.ext without path!
                            name,
                            sessionExt,
                            sessionExt,
                            mask,
                            mask,
                            this,
                            this,
                            wxFD_OPEN,
                            wxFD_OPEN,
                          FALSE );
                            FALSE
                            );


    if( fullFileName == wxEmptyString )
    if( fullFileName == wxEmptyString )
        return;
        return;