Commit 7c3f47ec authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

fixes for plugins

parent f80357cb
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -377,8 +377,8 @@ wxString BOARD::GetLayerName( int aLayerIndex, bool aTranslate ) const

// Default layer names are statically initialized,
// because we want the English name and the translation
// The English name is stored here, and to get the tranlation
// wxGetTranslation must be called explicitely
// The English name is stored here, and to get the translation
// wxGetTranslation must be called explicitly
static const wxChar * layer_FRONT_name  = _( "Front" );
static const wxChar * layer_INNER1_name = _( "Inner1" );
static const wxChar * layer_INNER2_name = _( "Inner2" );
+145 −133
Original line number Diff line number Diff line
@@ -1004,29 +1004,29 @@ void ERULES::parse( CPTREE& aRules )
{
    for( CITER it = aRules.begin();  it != aRules.end();  ++it )
    {
        if( it->first.compare( "param" ) )
        if( it->first != "param" )
            continue;

        CPTREE& attribs = it->second.get_child( "<xmlattr>" );

        const std::string& name = attribs.get<std::string>( "name" );

        if( !name.compare( "psElongationLong" ) )
        if( name == "psElongationLong" )
            psElongationLong = attribs.get<int>( "value" );
        else if( !name.compare( "psElongationOffset" ) )
        else if( name == "psElongationOffset" )
            psElongationOffset = attribs.get<int>( "value" );
        else if( !name.compare( "rvPadTop" ) )
        else if( name == "rvPadTop" )
            rvPadTop = attribs.get<double>( "value" );
        else if( !name.compare( "rlMinPadTop" ) )
        else if( name == "rlMinPadTop" )
            rlMinPadTop = parseEagle( attribs.get<std::string>( "value" ) );
        else if( !name.compare( "rlMaxPadTop" ) )
        else if( name == "rlMaxPadTop" )
            rlMaxPadTop = parseEagle( attribs.get<std::string>( "value" ) );

        else if( !name.compare( "rvViaOuter" ) )
        else if( name == "rvViaOuter" )
            rvViaOuter = attribs.get<double>( "value" );
        else if( !name.compare( "rlMinViaOuter" ) )
        else if( name == "rlMinViaOuter" )
            rlMinViaOuter = parseEagle( attribs.get<std::string>( "value" ) );
        else if( !name.compare( "rlMaxViaOuter" ) )
        else if( name == "rlMaxViaOuter" )
            rlMaxViaOuter = parseEagle( attribs.get<std::string>( "value" ) );
    }
}
@@ -1260,26 +1260,30 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
    // (polygon | wire | text | circle | rectangle | frame | hole)*
    for( CITER gr = aGraphics.begin();  gr != aGraphics.end();  ++gr )
    {
        if( !gr->first.compare( "wire" ) )
        if( gr->first == "wire" )
        {
            m_xpath->push( "wire" );
            EWIRE   w( gr->second );
            int     layer = kicad_layer( w.layer );

            if( layer != -1 )
            {
                DRAWSEGMENT* dseg = new DRAWSEGMENT( m_board );
                m_board->Add( dseg, ADD_APPEND );

                dseg->SetTimeStamp( timeStamp( gr->second ) );
            dseg->SetLayer( kicad_layer( w.layer ) );
                dseg->SetLayer( layer );
                dseg->SetStart( wxPoint( kicad_x( w.x1 ), kicad_y( w.y1 ) ) );
                dseg->SetEnd( wxPoint( kicad_x( w.x2 ), kicad_y( w.y2 ) ) );
                dseg->SetWidth( kicad( w.width ) );
            }
            m_xpath->pop();
        }

        else if( !gr->first.compare( "text" ) )
        else if( gr->first == "text" )
        {
#if defined(DEBUG)
            if( !gr->second.data().compare( "ATMEGA328" ) )
            if( gr->second.data() == "ATMEGA328" )
            {
                int breakhere = 1;
                (void) breakhere;
@@ -1289,6 +1293,8 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
            ETEXT   t( gr->second );
            int     layer = kicad_layer( t.layer );

            if( layer != -1 )       // supported layer
            {
                TEXTE_PCB* pcbtxt = new TEXTE_PCB( m_board );
                m_board->Add( pcbtxt, ADD_APPEND );

@@ -1367,29 +1373,34 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
                    pcbtxt->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
                    break;
                }
            }
            m_xpath->pop();
        }

        else if( !gr->first.compare( "circle" ) )
        else if( gr->first == "circle" )
        {
            m_xpath->push( "circle" );
            ECIRCLE c( gr->second );
            int     layer = kicad_layer( c.layer );

            if( layer != -1 )       // unsupported layer
            {
                DRAWSEGMENT* dseg = new DRAWSEGMENT( m_board );
                m_board->Add( dseg, ADD_APPEND );

                dseg->SetShape( S_CIRCLE );
                dseg->SetTimeStamp( timeStamp( gr->second ) );
            dseg->SetLayer( kicad_layer( c.layer ) );
                dseg->SetLayer( layer );
                dseg->SetStart( wxPoint( kicad_x( c.x ), kicad_y( c.y ) ) );
                dseg->SetEnd( wxPoint( kicad_x( c.x + c.radius ), kicad_y( c.y ) ) );
                dseg->SetWidth( kicad( c.width ) );
            }
            m_xpath->pop();
        }

        // This seems to be a simplified rectangular [copper] zone, cannot find any
        // net related info on it from the DTD.
        else if( !gr->first.compare( "rectangle" ) )
        else if( gr->first == "rectangle" )
        {
            m_xpath->push( "rectangle" );
            ERECT   r( gr->second );
@@ -1421,7 +1432,7 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
            m_xpath->pop();
        }

        else if( !gr->first.compare( "hole" ) )
        else if( gr->first == "hole" )
        {
            m_xpath->push( "hole" );
            EHOLE   e( gr->second );
@@ -1464,11 +1475,11 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
            m_xpath->pop();
        }

        else if( !gr->first.compare( "frame" ) )
        else if( gr->first == "frame" )
        {
            // picture this
        }
        else if( !gr->first.compare( "polygon" ) )
        else if( gr->first == "polygon" )
        {
            // could be on a copper layer, could be on another layer.
            // copper layer would be done using netCode=0 type of ZONE_CONTAINER.
@@ -1504,7 +1515,7 @@ void EAGLE_PLUGIN::loadLibraries( CPTREE& aLibs )
                const std::string& pack_name = package->second.get<std::string>( "<xmlattr>.name" );

    #if defined(DEBUG)
                if( !pack_name.compare( "TO220H" ) )
                if( pack_name == "TO220H" )
                {
                    int breakhere = 1;
                    (void) breakhere;
@@ -1552,7 +1563,7 @@ void EAGLE_PLUGIN::loadElements( CPTREE& aElements )

    for( CITER it = aElements.begin();  it != aElements.end();  ++it )
    {
        if( it->first.compare( "element" ) )
        if( it->first != "element" )
            continue;

        EELEMENT    e( it->second );
@@ -1563,14 +1574,6 @@ void EAGLE_PLUGIN::loadElements( CPTREE& aElements )

        m_xpath->Value( e.name.c_str() );

#if 1 && defined(DEBUG)
        if( !e.value.compare( "LP2985-33DBVR" ) )
        {
            int breakhere = 1;
            (void) breakhere;
        }
#endif

        std::string key = makeKey( e.library, e.package );

        MODULE_CITER mi = m_templates.find( key );
@@ -1584,7 +1587,7 @@ void EAGLE_PLUGIN::loadElements( CPTREE& aElements )
        }

#if defined(DEBUG)
        if( !e.name.compare( "IC3" ) )
        if( e.name == "ARM_C8" )
        {
            int breakhere = 1;
            (void) breakhere;
@@ -1624,17 +1627,17 @@ void EAGLE_PLUGIN::loadElements( CPTREE& aElements )
        // So the logic is a bit different than in packageText() and in plain text.
        for( CITER ait = it->second.begin();  ait != it->second.end();  ++ait )
        {
            if( ait->first.compare( "attribute" ) )
            if( ait->first != "attribute" )
                continue;

            EATTR   a( ait->second );

            if( !a.name.compare( "NAME" ) )
            if( a.name == "NAME" )
            {
                name = a;
                nameAttr = &name;
            }
            else if( !a.name.compare( "VALUE" ) )
            else if( a.name == "VALUE" )
            {
                value = a;
                valueAttr = &value;
@@ -1657,8 +1660,11 @@ void EAGLE_PLUGIN::orientModuleAndText( MODULE* m, const EELEMENT& e,
    {
        if( e.rot->mirror )
        {
            double orientation = e.rot->degrees + 180.0;
            m->SetOrientation( orientation * 10 );
            m->Flip( m->GetPosition() );
        }
        else
            m->SetOrientation( e.rot->degrees * 10 );
    }

@@ -1744,6 +1750,12 @@ void EAGLE_PLUGIN::orientModuleText( MODULE* m, const EELEMENT& e,
            txt->SetOrientation( sign * orient * 10 );
        }

        else
        {
            orient = 90 + degrees - m->GetOrientation() / 10;
            txt->SetOrientation( sign * orient * 10 );
        }

        switch( align )
        {
        case ETEXT::TOP_RIGHT:
@@ -1765,7 +1777,7 @@ void EAGLE_PLUGIN::orientModuleText( MODULE* m, const EELEMENT& e,
    {
        double degrees = ( txt->GetOrientation() + m->GetOrientation() ) / 10;

        // @todo there are a few more cases than theses to contend with:
        // @todo there are a few more cases than these to contend with:
        if( (!txt->IsMirrored() && ( abs( degrees ) == 180 || abs( degrees ) == 270 ))
         || ( txt->IsMirrored() && ( degrees == 360 ) ) )
        {
@@ -1791,28 +1803,28 @@ MODULE* EAGLE_PLUGIN::makeModule( CPTREE& aPackage, const std::string& aPkgName
    {
        CPTREE& t = it->second;

        if( it->first.compare( "wire" ) == 0 )
        if( it->first == "wire" )
            packageWire( m.get(), t );

        else if( !it->first.compare( "pad" ) )
        else if( it->first == "pad" )
            packagePad( m.get(), t );

        else if( !it->first.compare( "text" ) )
        else if( it->first == "text" )
            packageText( m.get(), t );

        else if( !it->first.compare( "rectangle" ) )
        else if( it->first == "rectangle" )
            packageRectangle( m.get(), t );

        else if( !it->first.compare( "polygon" ) )
        else if( it->first == "polygon" )
            packagePolygon( m.get(), t );

        else if( !it->first.compare( "circle" ) )
        else if( it->first == "circle" )
            packageCircle( m.get(), t );

        else if( !it->first.compare( "hole" ) )
        else if( it->first == "hole" )
            packageHole( m.get(), t );

        else if( !it->first.compare( "smd" ) )
        else if( it->first == "smd" )
            packageSMD( m.get(), t );
    }

@@ -1934,9 +1946,9 @@ void EAGLE_PLUGIN::packageText( MODULE* aModule, CPTREE& aTree ) const

    TEXTE_MODULE* txt;

    if( !t.text.compare( ">NAME" ) || !t.text.compare( ">name" ) )
    if( t.text == ">NAME" || t.text == ">name" )
        txt = &aModule->Reference();
    else if( !t.text.compare( ">VALUE" ) || !t.text.compare( ">value" ) )
    else if( t.text == ">VALUE" || t.text == ">value" )
        txt = &aModule->Value();
    else
    {
@@ -2096,7 +2108,7 @@ void EAGLE_PLUGIN::packagePolygon( MODULE* aModule, CPTREE& aTree ) const

        for( CITER vi = aTree.begin();  vi != aTree.end();  ++vi )
        {
            if( vi->first.compare( "vertex" ) ) // skip <xmlattr> node
            if( vi->first != "vertex" )     // skip <xmlattr> node
                continue;

            EVERTEX v( vi->second );
@@ -2245,7 +2257,7 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals )
        // (contactref | polygon | wire | via)*
        for( CITER it = net->second.begin();  it != net->second.end();  ++it )
        {
            if( !it->first.compare( "wire" ) )
            if( it->first == "wire" )
            {
                m_xpath->push( "wire" );
                EWIRE   w( it->second );
@@ -2274,7 +2286,7 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals )
                m_xpath->pop();
            }

            else if( !it->first.compare( "via" ) )
            else if( it->first == "via" )
            {
                m_xpath->push( "via" );
                EVIA    v( it->second );
@@ -2327,7 +2339,7 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals )
                m_xpath->pop();
            }

            else if( !it->first.compare( "contactref" ) )
            else if( it->first == "contactref" )
            {
                m_xpath->push( "contactref" );
                // <contactref element="RN1" pad="7"/>
@@ -2345,7 +2357,7 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals )
                m_xpath->pop();
            }

            else if( !it->first.compare( "polygon" ) )
            else if( it->first == "polygon" )
            {
                m_xpath->push( "polygon" );
                EPOLYGON p( it->second );
@@ -2367,7 +2379,7 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals )
                    bool first = true;
                    for( CITER vi = it->second.begin();  vi != it->second.end();  ++vi )
                    {
                        if( vi->first.compare( "vertex" ) ) // skip <xmlattr> node
                        if( vi->first != "vertex" )     // skip <xmlattr> node
                            continue;

                        EVERTEX v( vi->second );
+13 −3
Original line number Diff line number Diff line
@@ -523,10 +523,20 @@ void PCB_IO::format( EDGE_MODULE* aModuleDrawing, int aNestLevel ) const
        m_out->Print( aNestLevel, "(fp_poly (pts" );

        for( unsigned i = 0;  i < aModuleDrawing->GetPolyPoints().size();  ++i )
            m_out->Print( 0, " (xy %s)",
                          FMT_IU( aModuleDrawing->GetPolyPoints()[i] ).c_str() );
        {
            int nestLevel = 0;

        m_out->Print( 0, ")\n" );
            if( i && !(i%4) )   // newline every 4(pts)
            {
                nestLevel = aNestLevel + 1;
                m_out->Print( 0, "\n" );
            }

            m_out->Print( nestLevel, "%s(xy %s)",
                          nestLevel ? "" : " ",
                          FMT_IU( aModuleDrawing->GetPolyPoints()[i] ).c_str() );
        }
        m_out->Print( 0, ")" );
        break;

    case S_CURVE:   // Bezier curve
+5 −3
Original line number Diff line number Diff line
@@ -984,8 +984,10 @@ void PCB_PARSER::parseNETINFO_ITEM() throw( IO_ERROR, PARSE_ERROR )
                 wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as net." ) );

    int number = parseInt( "net number" );
    NeedSYMBOL();

    NeedSYMBOLorNUMBER();
    wxString name = FromUTF8();

    NeedRIGHT();

    // net 0 should be already in list, so store this net
@@ -1049,7 +1051,7 @@ void PCB_PARSER::parseNETCLASS() throw( IO_ERROR, PARSE_ERROR )
            break;

        case T_add_net:
            NeedSYMBOL();
            NeedSYMBOLorNUMBER();
            nc->Add( FromUTF8() );
            break;

@@ -2090,7 +2092,7 @@ D_PAD* PCB_PARSER::parseD_PAD() throw( IO_ERROR, PARSE_ERROR )

        case T_net:
            pad->SetNet( parseInt( "net number" ) );
            NeedSYMBOL();
            NeedSYMBOLorNUMBER();
            pad->SetNetname( FromUTF8() );
            NeedRIGHT();
            break;
+2 −2
Original line number Diff line number Diff line
@@ -524,9 +524,9 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
            snprintf( name, sizeof(name), "Trapz%sPad_%.6gx%.6g_%c%.6gx%c%.6g_um",
                     uniqifier.c_str(), IU2um( aPad->GetSize().x ), IU2um( aPad->GetSize().y ),
                     aPad->GetDelta().x < 0 ? 'n' : 'p',
                     abs( IU2um( aPad->GetDelta().x )),
                     std::abs( IU2um( aPad->GetDelta().x )),
                     aPad->GetDelta().y < 0 ? 'n' : 'p',
                     abs( IU2um( aPad->GetDelta().y ) )
                     std::abs( IU2um( aPad->GetDelta().y ) )
                     );
            name[ sizeof(name)-1 ] = 0;