diff --git a/eeschema/autoplace_fields.cpp b/eeschema/autoplace_fields.cpp index 2bdd29ce03..1d0271821d 100644 --- a/eeschema/autoplace_fields.cpp +++ b/eeschema/autoplace_fields.cpp @@ -151,7 +151,7 @@ public: { SCH_FIELD* field = m_fields[field_idx]; - if( !field->IsVisible() ) + if( !field->IsVisible() || !field->CanAutoplace() ) continue; if( m_allow_rejustify ) @@ -205,10 +205,13 @@ protected: for( SCH_FIELD* field : visibleFields ) { - if( m_symbol->GetTransform().y1 ) - field->SetTextAngle( ANGLE_VERTICAL ); - else - field->SetTextAngle( ANGLE_HORIZONTAL ); + if( field->CanAutoplace() ) + { + if( m_symbol->GetTransform().y1 ) + field->SetTextAngle( ANGLE_VERTICAL ); + else + field->SetTextAngle( ANGLE_HORIZONTAL ); + } BOX2I bbox = field->GetBoundingBox(); int field_width = bbox.GetWidth(); diff --git a/eeschema/dialogs/dialog_field_properties.cpp b/eeschema/dialogs/dialog_field_properties.cpp index 6694315556..7abd0b8c49 100644 --- a/eeschema/dialogs/dialog_field_properties.cpp +++ b/eeschema/dialogs/dialog_field_properties.cpp @@ -332,6 +332,7 @@ bool DIALOG_FIELD_PROPERTIES::TransferDataToWindow() m_visible->SetValue( m_isVisible ); m_nameVisible->SetValue( m_isNameVisible ); + m_cbAllowAutoPlace->SetValue( m_allowAutoplace ); return true; } @@ -400,8 +401,9 @@ bool DIALOG_FIELD_PROPERTIES::TransferDataFromWindow() else m_verticalJustification = GR_TEXT_V_ALIGN_BOTTOM; - m_isVisible = m_visible->GetValue(); - m_isNameVisible = m_nameVisible->GetValue(); + m_isVisible = m_visible->GetValue(); + m_isNameVisible = m_nameVisible->GetValue(); + m_allowAutoplace = m_cbAllowAutoPlace->GetValue(); return true; } @@ -425,12 +427,16 @@ DIALOG_LIB_FIELD_PROPERTIES::DIALOG_LIB_FIELD_PROPERTIES( SCH_BASE_FRAME* aParen const LIB_FIELD* aField ) : DIALOG_FIELD_PROPERTIES( aParent, aTitle, aField ) { - m_fieldId = aField->GetId(); - m_isNameVisible = aField->IsNameShown(); + m_fieldId = aField->GetId(); + m_isNameVisible = aField->IsNameShown(); + m_allowAutoplace = aField->CanAutoplace(); if( m_fieldId == VALUE_FIELD ) m_text = UnescapeString( aField->GetText() ); + m_nameVisible->Show(); + m_cbAllowAutoPlace->Show(); + // When in the library editor, power symbols can be renamed. m_isPower = false; init(); @@ -453,6 +459,7 @@ void DIALOG_LIB_FIELD_PROPERTIES::UpdateField( LIB_FIELD* aField ) updateText( aField ); aField->SetNameShown( m_isNameVisible ); + aField->SetCanAutoplace( m_allowAutoplace ); aField->SetHorizJustify( EDA_TEXT::MapHorizJustify( m_horizontalJustification ) ); aField->SetVertJustify( EDA_TEXT::MapVertJustify( m_verticalJustification ) ); @@ -510,6 +517,7 @@ DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES( SCH_BASE_FRAME* aParen m_position = m_field->GetPosition(); m_isNameVisible = m_field->IsNameShown(); + m_allowAutoplace = m_field->CanAutoplace(); m_horizontalJustification = m_field->GetEffectiveHorizJustify(); m_verticalJustification = m_field->GetEffectiveVertJustify(); @@ -530,6 +538,9 @@ DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES( SCH_BASE_FRAME* aParen m_StyledTextCtrl->Bind( wxEVT_STC_CHARADDED, &DIALOG_SCH_FIELD_PROPERTIES::onScintillaCharAdded, this ); + m_nameVisible->Show(); + m_cbAllowAutoPlace->Show(); + init(); if( m_isSheetFilename ) @@ -672,6 +683,7 @@ void DIALOG_SCH_FIELD_PROPERTIES::UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH aField->SetFont( m_font ); aField->SetNameShown( m_isNameVisible ); + aField->SetCanAutoplace( m_allowAutoplace ); // Note that we must set justifications before we can ask if they're flipped. If the old // justification is center then it won't know (whereas if the new justification is center diff --git a/eeschema/dialogs/dialog_field_properties.h b/eeschema/dialogs/dialog_field_properties.h index 15507d6ef6..c42fada600 100644 --- a/eeschema/dialogs/dialog_field_properties.h +++ b/eeschema/dialogs/dialog_field_properties.h @@ -102,6 +102,7 @@ protected: GR_TEXT_H_ALIGN_T m_horizontalJustification; bool m_isVisible; bool m_isNameVisible; + bool m_allowAutoplace; bool m_firstFocus; diff --git a/eeschema/dialogs/dialog_field_properties_base.cpp b/eeschema/dialogs/dialog_field_properties_base.cpp index a8b48d4ee0..cb271b2ead 100644 --- a/eeschema/dialogs/dialog_field_properties_base.cpp +++ b/eeschema/dialogs/dialog_field_properties_base.cpp @@ -88,10 +88,18 @@ DIALOG_FIELD_PROPERTIES_BASE::DIALOG_FIELD_PROPERTIES_BASE( wxWindow* parent, wx bSizer9->Add( m_visible, 0, wxALIGN_LEFT|wxBOTTOM, 2 ); m_nameVisible = new wxCheckBox( this, wxID_ANY, _("Show field name"), wxDefaultPosition, wxDefaultSize, 0 ); + m_nameVisible->Hide(); m_nameVisible->SetToolTip( _("Show the field name in addtion to its value") ); bSizer9->Add( m_nameVisible, 0, wxLEFT, 5 ); + m_cbAllowAutoPlace = new wxCheckBox( this, wxID_ANY, _("Allow autoplacement"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbAllowAutoPlace->SetValue(true); + m_cbAllowAutoPlace->Hide(); + m_cbAllowAutoPlace->SetToolTip( _("Allow automatic placement of this field in the schematic") ); + + bSizer9->Add( m_cbAllowAutoPlace, 0, wxFIXED_MINSIZE, 5 ); + bPropertiesSizer->Add( bSizer9, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 ); diff --git a/eeschema/dialogs/dialog_field_properties_base.fbp b/eeschema/dialogs/dialog_field_properties_base.fbp index 8bbc6d70c1..5d34f443f5 100644 --- a/eeschema/dialogs/dialog_field_properties_base.fbp +++ b/eeschema/dialogs/dialog_field_properties_base.fbp @@ -527,7 +527,7 @@ 1 0 - 0 + 1 wxID_ANY Show field name @@ -560,6 +560,70 @@ + + 5 + wxFIXED_MINSIZE + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 1 + wxID_ANY + Allow autoplacement + + 0 + + + 0 + + 1 + m_cbAllowAutoPlace + 1 + + + protected + 1 + + Resizable + 0 + + + ; ; forward_declare + 0 + Allow automatic placement of this field in the schematic + + wxFILTER_NONE + wxDefaultValidator + + + + + + diff --git a/eeschema/dialogs/dialog_field_properties_base.h b/eeschema/dialogs/dialog_field_properties_base.h index 1706cb43a2..fe67ba0eba 100644 --- a/eeschema/dialogs/dialog_field_properties_base.h +++ b/eeschema/dialogs/dialog_field_properties_base.h @@ -53,6 +53,7 @@ class DIALOG_FIELD_PROPERTIES_BASE : public DIALOG_SHIM wxStaticText* m_note; wxCheckBox* m_visible; wxCheckBox* m_nameVisible; + wxCheckBox* m_cbAllowAutoPlace; wxStaticText* m_fontLabel; FONT_CHOICE* m_fontCtrl; BITMAP_BUTTON* m_separator1; diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index c82865bfeb..05a2d0abf3 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -71,11 +71,12 @@ LIB_FIELD::~LIB_FIELD() LIB_FIELD& LIB_FIELD::operator=( const LIB_FIELD& field ) { - m_id = field.m_id; - m_name = field.m_name; - m_parent = field.m_parent; - m_autoAdded = field.m_autoAdded; - m_showName = field.m_showName; + m_id = field.m_id; + m_name = field.m_name; + m_parent = field.m_parent; + m_autoAdded = field.m_autoAdded; + m_showName = field.m_showName; + m_allowAutoPlace = field.m_allowAutoPlace; SetText( field.GetText() ); SetAttributes( field ); @@ -101,8 +102,9 @@ void LIB_FIELD::Init( int aId ) if( aId == DATASHEET_FIELD || aId == FOOTPRINT_FIELD ) SetVisible( false ); - m_autoAdded = false; - m_showName = false; + m_autoAdded = false; + m_showName = false; + m_allowAutoPlace = true; } @@ -194,8 +196,9 @@ EDA_ITEM* LIB_FIELD::Clone() const void LIB_FIELD::Copy( LIB_FIELD* aTarget ) const { - aTarget->m_name = m_name; - aTarget->m_showName = m_showName; + aTarget->m_name = m_name; + aTarget->m_showName = m_showName; + aTarget->m_allowAutoPlace = m_allowAutoPlace; aTarget->CopyText( *this ); aTarget->SetAttributes( *this ); diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index 48c898ac5a..ad8e7f1b8f 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -181,6 +181,9 @@ public: bool IsNameShown() const { return m_showName; } void SetNameShown( bool aShown = true ) { m_showName = aShown; } + bool CanAutoplace() const { return m_allowAutoPlace; } + void SetCanAutoplace( bool aCanPlace ) { m_allowAutoPlace = aCanPlace; } + private: /** @@ -219,6 +222,7 @@ private: wxString m_name; ///< Name (not the field text value itself, that is #EDA_TEXT::m_Text) bool m_autoAdded; ///< Was this field automatically added to a LIB_SYMBOL? bool m_showName; ///< Render the field's name in addition to its value + bool m_allowAutoPlace; ///< This field can be autoplaced when converted to a SCH_FIELD }; #endif // CLASS_LIBENTRY_FIELDS_H diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 8424566723..f2a987704d 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -63,6 +63,7 @@ SCH_FIELD::SCH_FIELD( const VECTOR2I& aPos, int aFieldId, SCH_ITEM* aParent, m_id( 0 ), m_name( aName ), m_showName( false ), + m_allowAutoPlace( true ), m_renderCacheValid( false ) { SetTextPos( aPos ); @@ -75,9 +76,10 @@ SCH_FIELD::SCH_FIELD( const SCH_FIELD& aField ) : SCH_ITEM( aField ), EDA_TEXT( aField ) { - m_id = aField.m_id; - m_name = aField.m_name; - m_showName = aField.m_showName; + m_id = aField.m_id; + m_name = aField.m_name; + m_showName = aField.m_showName; + m_allowAutoPlace = aField.m_allowAutoPlace; m_renderCache.clear(); @@ -96,9 +98,10 @@ SCH_FIELD& SCH_FIELD::operator=( const SCH_FIELD& aField ) { EDA_TEXT::operator=( aField ); - m_id = aField.m_id; - m_name = aField.m_name; - m_showName = aField.m_showName; + m_id = aField.m_id; + m_name = aField.m_name; + m_showName = aField.m_showName; + m_allowAutoPlace = aField.m_allowAutoPlace; m_renderCache.clear(); @@ -368,6 +371,7 @@ void SCH_FIELD::ImportValues( const LIB_FIELD& aSource ) { SetAttributes( aSource ); SetNameShown( aSource.IsNameShown() ); + SetCanAutoplace( aSource.CanAutoplace() ); } @@ -380,6 +384,7 @@ void SCH_FIELD::SwapData( SCH_ITEM* aItem ) std::swap( m_layer, item->m_layer ); std::swap( m_showName, item->m_showName ); + std::swap( m_allowAutoPlace, item->m_allowAutoPlace ); SwapText( *item ); SwapAttributes( *item ); } diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index f805de7787..7b2bb3c197 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -139,6 +139,9 @@ public: bool IsNameShown() const { return m_showName; } void SetNameShown( bool aShown = true ) { m_showName = aShown; } + bool CanAutoplace() const { return m_allowAutoPlace; } + void SetCanAutoplace( bool aCanPlace ) { m_allowAutoPlace = aCanPlace; } + /** * @return true if the field is either empty or holds "~". */ @@ -234,6 +237,7 @@ private: wxString m_name; bool m_showName; ///< Render the field name in addition to its value + bool m_allowAutoPlace; ///< This field can be autoplaced mutable bool m_renderCacheValid; mutable VECTOR2I m_renderCachePos; diff --git a/eeschema/sch_file_versions.h b/eeschema/sch_file_versions.h index d4934ff909..19811aa035 100644 --- a/eeschema/sch_file_versions.h +++ b/eeschema/sch_file_versions.h @@ -83,5 +83,6 @@ //#define SEXPR_SCHEMATIC_FILE_VERSION 20220404 // Default schematic symbol instance data. //#define SEXPR_SCHEMATIC_FILE_VERSION 20220622 // New simulation model format. //#define SEXPR_SCHEMATIC_FILE_VERSION 20220820 // Fix broken default symbol instance data. -//#define SEXPR_SCHEMATIC_FILE_VERSION 20220822 // Hyperlinks in text objects -#define SEXPR_SCHEMATIC_FILE_VERSION 20220903 // Field name visibility +//#define SEXPR_SCHEMATIC_FILE_VERSION 20220822 // Hyperlinks in text objects +//#define SEXPR_SCHEMATIC_FILE_VERSION 20220903 // Field name visibility +#define SEXPR_SCHEMATIC_FILE_VERSION 20220904 // Do not autoplace field option \ No newline at end of file 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 405d0801c0..81a9f4f8a1 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_lib_plugin_cache.cpp @@ -402,6 +402,9 @@ void SCH_SEXPR_PLUGIN_CACHE::saveField( LIB_FIELD* aField, OUTPUTFORMATTER& aFor if( aField->IsNameShown() ) aFormatter.Print( aNestLevel, " (show_name)" ); + if( !aField->CanAutoplace() ) + aFormatter.Print( aNestLevel, " (do_not_autoplace)" ); + aField->Format( &aFormatter, aNestLevel, 0 ); aFormatter.Print( aNestLevel, "\n)\n" ); } diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index d571e40f2a..34a0aafeb0 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -800,8 +800,13 @@ LIB_FIELD* SCH_SEXPR_PARSER::parseProperty( std::unique_ptr& aSymbol NeedRIGHT(); break; + case T_do_not_autoplace: + field->SetCanAutoplace( false ); + NeedRIGHT(); + break; + default: - Expecting( "id, at, show_name, or effects" ); + Expecting( "id, at, show_name, do_not_autoplace, or effects" ); } } diff --git a/eeschema/schematic.keywords b/eeschema/schematic.keywords index a2000fc887..ee31ed1998 100644 --- a/eeschema/schematic.keywords +++ b/eeschema/schematic.keywords @@ -28,6 +28,7 @@ default_instance diameter diamond directive_label +do_not_autoplace dot edge_clock_high effects