Persist fields_autoplaced information.

Fixes https://gitlab.com/kicad/code/kicad/issues/8086
This commit is contained in:
Jeff Young 2021-04-02 17:08:13 +01:00
parent d3bf20e80b
commit ebfbe14185
4 changed files with 38 additions and 4 deletions

View File

@ -432,9 +432,7 @@ public:
*/
FIELDS_AUTOPLACED GetFieldsAutoplaced() const { return m_fieldsAutoplaced; }
/**
* Set fields automatically placed flag false.
*/
void SetFieldsAutoplaced() { m_fieldsAutoplaced = FIELDS_AUTOPLACED_AUTO; }
void ClearFieldsAutoplaced() { m_fieldsAutoplaced = FIELDS_AUTOPLACED_NO; }
/**

View File

@ -2200,6 +2200,9 @@ SCH_COMPONENT* SCH_SEXPR_PARSER::parseSchematicSymbol()
TRANSFORM transform;
std::set<int> fieldIDsRead;
// We'll reset this if we find a fields_autoplaced token
symbol->ClearFieldsAutoplaced();
m_fieldId = MANDATORY_FIELDS;
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
@ -2301,6 +2304,11 @@ SCH_COMPONENT* SCH_SEXPR_PARSER::parseSchematicSymbol()
NeedRIGHT();
break;
case T_fields_autoplaced:
symbol->SetFieldsAutoplaced();
NeedRIGHT();
break;
case T_uuid:
NeedSYMBOL();
const_cast<KIID&>( symbol->m_Uuid ) = KIID( FromUTF8() );
@ -2510,6 +2518,9 @@ SCH_SHEET* SCH_SEXPR_PARSER::parseSheet()
std::unique_ptr<SCH_SHEET> sheet = std::make_unique<SCH_SHEET>();
std::set<int> fieldIDsRead;
// We'll reset this if we find a fields_autoplaced token
sheet->ClearFieldsAutoplaced();
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{
if( token != T_LEFT )
@ -2534,6 +2545,11 @@ SCH_SHEET* SCH_SEXPR_PARSER::parseSheet()
break;
}
case T_fields_autoplaced:
sheet->SetFieldsAutoplaced();
NeedRIGHT();
break;
case T_stroke:
parseStroke( stroke );
sheet->SetBorderWidth( stroke.GetWidth() );
@ -2817,6 +2833,9 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText()
wxCHECK_MSG( false, nullptr, "Cannot parse " + GetTokenString( CurTok() ) + " as text." );
}
// We'll reset this if we find a fields_autoplaced token
text->ClearFieldsAutoplaced();
NeedSYMBOL();
text->SetText( FromUTF8() );
@ -2868,6 +2887,11 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText()
NeedRIGHT();
break;
case T_fields_autoplaced:
text->SetFieldsAutoplaced();
NeedRIGHT();
break;
case T_effects:
parseEDA_TEXT( static_cast<EDA_TEXT*>( text.get() ) );
break;

View File

@ -951,6 +951,9 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_COMPONENT* aSymbol, SCH_SHEET_PATH* aShee
m_out->Print( aNestLevel + 1, "(in_bom %s)", ( aSymbol->GetIncludeInBom() ) ? "yes" : "no" );
m_out->Print( 0, " (on_board %s)", ( aSymbol->GetIncludeOnBoard() ) ? "yes" : "no" );
if( aSymbol->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO )
m_out->Print( 0, " (fields_autoplaced)" );
m_out->Print( 0, "\n" );
m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aSymbol->m_Uuid.AsString() ) );
@ -1086,12 +1089,17 @@ void SCH_SEXPR_PLUGIN::saveSheet( SCH_SHEET* aSheet, int aNestLevel )
{
wxCHECK_RET( aSheet != nullptr && m_out != nullptr, "" );
m_out->Print( aNestLevel, "(sheet (at %s %s) (size %s %s)\n",
m_out->Print( aNestLevel, "(sheet (at %s %s) (size %s %s)",
FormatInternalUnits( aSheet->GetPosition().x ).c_str(),
FormatInternalUnits( aSheet->GetPosition().y ).c_str(),
FormatInternalUnits( aSheet->GetSize().GetWidth() ).c_str(),
FormatInternalUnits( aSheet->GetSize().GetHeight() ).c_str() );
if( aSheet->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO )
m_out->Print( 0, " (fields_autoplaced)" );
m_out->Print( 0, "\n" );
STROKE_PARAMS stroke( aSheet->GetBorderWidth(), PLOT_DASH_TYPE::SOLID,
aSheet->GetBorderColor() );
@ -1270,6 +1278,9 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel )
FormatAngle( aText->GetTextAngle() ).c_str() );
}
if( aText->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO )
m_out->Print( 0, " (fields_autoplaced)" );
m_out->Print( 0, "\n" );
aText->Format( m_out, aNestLevel, 0 );

View File

@ -32,6 +32,7 @@ edge_clock_high
effects
end
extends
fields_autoplaced
fill
font
footprint