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.
This commit is contained in:
Wayne Stambaugh 2012-06-23 21:19:41 -04:00
parent e06ce757b7
commit 4019284e66
3 changed files with 31 additions and 22 deletions

View File

@ -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" );
}
}

View File

@ -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",

View File

@ -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( !haveWidth )
{
drillSize.SetWidth( parseBoardUnits() );
if( token == T_NUMBER )
{
height = parseBoardUnits();
NeedRIGHT();
// 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;
}