diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index 203df7be2e..c723c1b965 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -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; } /** diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index bef074f24c..8ec33244b8 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -2200,6 +2200,9 @@ SCH_COMPONENT* SCH_SEXPR_PARSER::parseSchematicSymbol() TRANSFORM transform; std::set 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( symbol->m_Uuid ) = KIID( FromUTF8() ); @@ -2510,6 +2518,9 @@ SCH_SHEET* SCH_SEXPR_PARSER::parseSheet() std::unique_ptr sheet = std::make_unique(); std::set 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( text.get() ) ); break; diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index 11f3e9af78..efc5fed865 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -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 ); diff --git a/eeschema/schematic.keywords b/eeschema/schematic.keywords index 0ffb5c1314..1f0053df5f 100644 --- a/eeschema/schematic.keywords +++ b/eeschema/schematic.keywords @@ -32,6 +32,7 @@ edge_clock_high effects end extends +fields_autoplaced fill font footprint