Commit 4019284e authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Minor Pcbnew s-expression improvements.

* Put text effects on a single line.
* Remove size token when defining drill sizes.
* Don't save net in pad definition when pad has no connection.
parent e06ce757
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -344,12 +344,12 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
{
    if( !IsDefaultFormatting() )
    {
        aFormatter->Print( aNestLevel+1, "(effects\n" );
        aFormatter->Print( aNestLevel+1, "(effects" );

        if( ( m_Size.x != DEFAULT_SIZE_TEXT ) || ( m_Size.y != DEFAULT_SIZE_TEXT ) || m_Bold
          || m_Italic )
        {
            aFormatter->Print( aNestLevel+2, "(font" );
            aFormatter->Print( 0, " (font" );

            // Add font support here at some point in the future.

@@ -366,13 +366,13 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
            if( IsItalic() )
                aFormatter->Print( 0, " italic" );

            aFormatter->Print( 0, ")\n");
            aFormatter->Print( 0, ")");
        }

        if( m_Mirror || ( m_HJustify != GR_TEXT_HJUSTIFY_CENTER )
          || ( m_VJustify != GR_TEXT_VJUSTIFY_CENTER ) )
        {
            aFormatter->Print( aNestLevel+2, "(justify");
            aFormatter->Print( 0, " (justify");

            if( m_HJustify != GR_TEXT_HJUSTIFY_CENTER )
                aFormatter->Print( 0, (m_HJustify == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );
@@ -383,13 +383,13 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
            if( m_Mirror )
                aFormatter->Print( 0, " mirror" );

            aFormatter->Print( 0, ")\n" );
            aFormatter->Print( 0, ")" );
        }

        // As of now the only place this is used is in Eeschema to hide or show the text.
        if( m_Attributs )
            aFormatter->Print( aNestLevel+2, "hide\n" );
            aFormatter->Print( 0, " hide" );

        aFormatter->Print( aNestLevel+1, ")\n" );
        aFormatter->Print( 0, ")\n" );
    }
}
+11 −4
Original line number Diff line number Diff line
@@ -770,8 +770,11 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const
        if( aPad->GetDrillShape() == PAD_OVAL )
            m_out->Print( 0, " oval" );

        m_out->Print( 0,  " (size %s)", (sz.GetHeight() != sz.GetWidth()) ? FMT_IU( sz ).c_str() :
                      FMT_IU( sz.GetWidth() ).c_str() );
        if( sz.GetWidth() > 0 )
            m_out->Print( 0,  " %s", FMT_IU( sz.GetWidth() ).c_str() );

        if( sz.GetHeight() > 0  && sz.GetWidth() != sz.GetHeight() )
            m_out->Print( 0,  " %s", FMT_IU( sz.GetHeight() ).c_str() );

        if( (aPad->GetOffset().x != 0) || (aPad->GetOffset().y != 0) )
            m_out->Print( 0, " (offset %s)", FMT_IU( aPad->GetOffset() ).c_str() );
@@ -799,8 +802,12 @@ void PCB_IO::format( D_PAD* aPad, int aNestLevel ) const

    m_out->Print( 0, ")\n" );

    // Unconnected pad is default net so don't save it.
    if( aPad->GetNet() != 0 )
    {
        m_out->Print( aNestLevel+1, "(net %d %s)\n",
                      aPad->GetNet(), m_out->Quotew( aPad->GetNetname() ).c_str() );
    }

    if( aPad->GetDieLength() != 0 )
        m_out->Print( aNestLevel+1, "(die_length %s)\n",
+13 −11
Original line number Diff line number Diff line
@@ -2022,6 +2022,9 @@ D_PAD* PCB_PARSER::parseD_PAD() throw( IO_ERROR, PARSE_ERROR )

        case T_drill:
        {
            bool haveWidth = false;
            wxSize drillSize = pad->GetDrillSize();

            for( token = NextTok();  token != T_RIGHT;  token = NextTok() )
            {
                if( token == T_LEFT )
@@ -2033,23 +2036,21 @@ D_PAD* PCB_PARSER::parseD_PAD() throw( IO_ERROR, PARSE_ERROR )
                    pad->SetDrillShape( PAD_OVAL );
                    break;

                case T_size:
                case T_NUMBER:
                {
                    int width = parseBoardUnits( "drill width" );
                    int height = width;
                    token = NextTok();

                    if( token == T_NUMBER )
                    if( !haveWidth )
                    {
                        height = parseBoardUnits();
                        NeedRIGHT();
                        drillSize.SetWidth( parseBoardUnits() );

                        // If height is not defined the width and height are the same.
                        drillSize.SetHeight( drillSize.GetWidth() );
                        haveWidth = true;
                    }
                    else if( token != T_RIGHT )
                    else
                    {
                        Expecting( ") or number" );
                        drillSize.SetHeight( parseBoardUnits() );
                    }

                    pad->SetDrillSize( wxSize( width, height ) );
                    break;
                }

@@ -2064,6 +2065,7 @@ D_PAD* PCB_PARSER::parseD_PAD() throw( IO_ERROR, PARSE_ERROR )
                }
            }

            pad->SetDrillSize( drillSize );
            break;
        }