From 254dff281337886cbed6f8eeff7a023607bf36c0 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 15 Oct 2022 19:08:11 +0100 Subject: [PATCH] Add do_not_autoplace to schematic parser and printer. Fixes https://gitlab.com/kicad/code/kicad/issues/12657 --- eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp | 4 ++-- eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp | 7 ++++++- eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp | 5 ++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp index f7063c9110..7702bc272a 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp @@ -406,10 +406,10 @@ void SCH_SEXPR_PLUGIN_CACHE::saveField( LIB_FIELD* aField, OUTPUTFORMATTER& aFor aField->GetTextAngle().AsDegrees() ); if( aField->IsNameShown() ) - aFormatter.Print( aNestLevel, " (show_name)" ); + aFormatter.Print( 0, " (show_name)" ); if( !aField->CanAutoplace() ) - aFormatter.Print( aNestLevel, " (do_not_autoplace)" ); + aFormatter.Print( 0, " (do_not_autoplace)" ); aFormatter.Print( 0, "\n" ); aField->Format( &aFormatter, aNestLevel, 0 ); diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index 385e198c73..4aaed98293 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -1976,8 +1976,13 @@ SCH_FIELD* SCH_SEXPR_PARSER::parseSchField( SCH_ITEM* aParent ) NeedRIGHT(); break; + case T_do_not_autoplace: + field->SetCanAutoplace( false ); + NeedRIGHT(); + break; + default: - Expecting( "id, show_name, at or effects" ); + Expecting( "id, at, show_name, do_not_autoplace or effects" ); } } diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index a70088e86b..dca76d3a10 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -889,7 +889,10 @@ void SCH_SEXPR_PLUGIN::saveField( SCH_FIELD* aField, int aNestLevel ) EDA_UNIT_UTILS::FormatAngle( aField->GetTextAngle() ).c_str() ); if( aField->IsNameShown() ) - m_out->Print( aNestLevel, " (show_name)" ); + m_out->Print( 0, " (show_name)" ); + + if( !aField->CanAutoplace() ) + m_out->Print( 0, " (do_not_autoplace)" ); if( !aField->IsDefaultFormatting() || ( aField->GetTextHeight() != schIUScale.MilsToIU( DEFAULT_SIZE_TEXT ) ) )