SCH textboxes start/end -> at/size.
The at token can handle an angle; start/end does not. Fixes https://gitlab.com/kicad/code/kicad/issues/11252
This commit is contained in:
parent
343b2681d4
commit
47f4503564
|
@ -43,7 +43,8 @@
|
|||
//#define SEXPR_SYMBOL_LIB_FILE_VERSION 20211014 // Arc formatting.
|
||||
//#define SEXPR_SYMBOL_LIB_FILE_VERSION 20220101 // Class flags.
|
||||
//#define SEXPR_SYMBOL_LIB_FILE_VERSION 20220102 // Fonts.
|
||||
#define SEXPR_SYMBOL_LIB_FILE_VERSION 20220126 // Text boxes.
|
||||
//#define SEXPR_SYMBOL_LIB_FILE_VERSION 20220126 // Text boxes.
|
||||
#define SEXPR_SYMBOL_LIB_FILE_VERSION 20220328 // Text box start/end -> at/size.
|
||||
|
||||
|
||||
/**
|
||||
|
@ -75,4 +76,5 @@
|
|||
//#define SEXPR_SCHEMATIC_FILE_VERSION 20220103 // Label fields
|
||||
//#define SEXPR_SCHEMATIC_FILE_VERSION 20220104 // Fonts
|
||||
//#define SEXPR_SCHEMATIC_FILE_VERSION 20220124 // netclass_flag -> directive_label
|
||||
#define SEXPR_SCHEMATIC_FILE_VERSION 20220126 // Text boxes
|
||||
//#define SEXPR_SCHEMATIC_FILE_VERSION 20220126 // Text boxes
|
||||
#define SEXPR_SCHEMATIC_FILE_VERSION 20220328 // Text box start/end -> at/size
|
||||
|
|
|
@ -473,11 +473,15 @@ void SCH_SEXPR_PLUGIN_CACHE::saveTextBox( LIB_TEXTBOX* aTextBox, OUTPUTFORMATTER
|
|||
aTextBox->IsPrivate() ? " private" : "",
|
||||
aFormatter.Quotew( aTextBox->GetText() ).c_str() );
|
||||
|
||||
aFormatter.Print( aNestLevel + 1, "(start %s %s) (end %s %s)\n",
|
||||
FormatInternalUnits( aTextBox->GetStart().x ).c_str(),
|
||||
FormatInternalUnits( aTextBox->GetStart().y ).c_str(),
|
||||
FormatInternalUnits( aTextBox->GetEnd().x ).c_str(),
|
||||
FormatInternalUnits( aTextBox->GetEnd().y ).c_str() );
|
||||
VECTOR2I pos = aTextBox->GetStart();
|
||||
VECTOR2I size = aTextBox->GetEnd() - pos;
|
||||
|
||||
aFormatter.Print( aNestLevel + 1, "(at %s %s %s) (size %s %s)\n",
|
||||
FormatInternalUnits( pos.x ).c_str(),
|
||||
FormatInternalUnits( pos.y ).c_str(),
|
||||
FormatAngle( aTextBox->GetTextAngle() ).c_str(),
|
||||
FormatInternalUnits( size.x ).c_str(),
|
||||
FormatInternalUnits( size.y ).c_str() );
|
||||
|
||||
aTextBox->GetStroke().Format( &aFormatter, aNestLevel + 1 );
|
||||
aFormatter.Print( 0, "\n" );
|
||||
|
|
|
@ -1613,6 +1613,11 @@ LIB_TEXTBOX* SCH_SEXPR_PARSER::parseTextBox()
|
|||
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a text box." ) );
|
||||
|
||||
T token;
|
||||
VECTOR2I pos;
|
||||
VECTOR2I end;
|
||||
VECTOR2I size;
|
||||
bool foundEnd = false;
|
||||
bool foundSize = false;
|
||||
STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT );
|
||||
FILL_PARAMS fill;
|
||||
std::unique_ptr<LIB_TEXTBOX> textBox = std::make_unique<LIB_TEXTBOX>( nullptr );
|
||||
|
@ -1642,13 +1647,26 @@ LIB_TEXTBOX* SCH_SEXPR_PARSER::parseTextBox()
|
|||
|
||||
switch( token )
|
||||
{
|
||||
case T_start:
|
||||
textBox->SetPosition( parseXY() );
|
||||
case T_start: // Legacy token during 6.99 development; fails to handle angle
|
||||
pos = parseXY();
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
case T_end:
|
||||
textBox->SetEnd( parseXY() );
|
||||
case T_end: // Legacy token during 6.99 development; fails to handle angle
|
||||
end = parseXY();
|
||||
foundEnd = true;
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
case T_at:
|
||||
pos = parseXY();
|
||||
textBox->SetTextAngle( EDA_ANGLE( parseDouble( "textbox angle" ), DEGREES_T ) );
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
case T_size:
|
||||
size = parseXY();
|
||||
foundSize = true;
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
|
@ -1668,10 +1686,19 @@ LIB_TEXTBOX* SCH_SEXPR_PARSER::parseTextBox()
|
|||
break;
|
||||
|
||||
default:
|
||||
Expecting( "start, end, stroke, fill or effects" );
|
||||
Expecting( "at, size, stroke, fill or effects" );
|
||||
}
|
||||
}
|
||||
|
||||
textBox->SetPosition( pos );
|
||||
|
||||
if( foundEnd )
|
||||
textBox->SetEnd( end );
|
||||
else if( foundSize )
|
||||
textBox->SetEnd( pos + size );
|
||||
else
|
||||
Expecting( "size" );
|
||||
|
||||
return textBox.release();
|
||||
}
|
||||
|
||||
|
@ -3516,6 +3543,11 @@ SCH_TEXTBOX* SCH_SEXPR_PARSER::parseSchTextBox()
|
|||
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a text box." ) );
|
||||
|
||||
T token;
|
||||
VECTOR2I pos;
|
||||
VECTOR2I end;
|
||||
VECTOR2I size;
|
||||
bool foundEnd = false;
|
||||
bool foundSize = false;
|
||||
STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT );
|
||||
FILL_PARAMS fill;
|
||||
std::unique_ptr<SCH_TEXTBOX> textBox = std::make_unique<SCH_TEXTBOX>();
|
||||
|
@ -3533,13 +3565,26 @@ SCH_TEXTBOX* SCH_SEXPR_PARSER::parseSchTextBox()
|
|||
|
||||
switch( token )
|
||||
{
|
||||
case T_start:
|
||||
textBox->SetPosition( parseXY() );
|
||||
case T_start: // Legacy token during 6.99 development; fails to handle angle
|
||||
pos = parseXY();
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
case T_end:
|
||||
textBox->SetEnd( parseXY() );
|
||||
case T_end: // Legacy token during 6.99 development; fails to handle angle
|
||||
end = parseXY();
|
||||
foundEnd = true;
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
case T_at:
|
||||
pos = parseXY();
|
||||
textBox->SetTextAngle( EDA_ANGLE( parseDouble( "textbox angle" ), DEGREES_T ) );
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
case T_size:
|
||||
size = parseXY();
|
||||
foundSize = true;
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
|
@ -3565,10 +3610,19 @@ SCH_TEXTBOX* SCH_SEXPR_PARSER::parseSchTextBox()
|
|||
break;
|
||||
|
||||
default:
|
||||
Expecting( "start, end, stroke, fill or uuid" );
|
||||
Expecting( "at, size, stroke, fill, effects or uuid" );
|
||||
}
|
||||
}
|
||||
|
||||
textBox->SetPosition( pos );
|
||||
|
||||
if( foundEnd )
|
||||
textBox->SetEnd( end );
|
||||
else if( foundSize )
|
||||
textBox->SetEnd( pos + size );
|
||||
else
|
||||
Expecting( "size" );
|
||||
|
||||
return textBox.release();
|
||||
}
|
||||
|
||||
|
|
|
@ -1134,11 +1134,15 @@ void SCH_SEXPR_PLUGIN::saveTextBox( SCH_TEXTBOX* aTextBox, int aNestLevel )
|
|||
m_out->Print( aNestLevel, "(text_box %s\n",
|
||||
m_out->Quotew( aTextBox->GetText() ).c_str() );
|
||||
|
||||
m_out->Print( aNestLevel + 1, "(start %s %s) (end %s %s)\n",
|
||||
FormatInternalUnits( aTextBox->GetStart().x ).c_str(),
|
||||
FormatInternalUnits( aTextBox->GetStart().y ).c_str(),
|
||||
FormatInternalUnits( aTextBox->GetEnd().x ).c_str(),
|
||||
FormatInternalUnits( aTextBox->GetEnd().y ).c_str() );
|
||||
VECTOR2I pos = aTextBox->GetStart();
|
||||
VECTOR2I size = aTextBox->GetEnd() - pos;
|
||||
|
||||
m_out->Print( aNestLevel + 1, "(at %s %s %s) (size %s %s)\n",
|
||||
FormatInternalUnits( pos.x ).c_str(),
|
||||
FormatInternalUnits( pos.y ).c_str(),
|
||||
FormatAngle( aTextBox->GetTextAngle() ).c_str(),
|
||||
FormatInternalUnits( size.x ).c_str(),
|
||||
FormatInternalUnits( size.y ).c_str() );
|
||||
|
||||
aTextBox->GetStroke().Format( m_out, aNestLevel + 1 );
|
||||
m_out->Print( 0, "\n" );
|
||||
|
|
Loading…
Reference in New Issue