From 838bd7292c6b45dffe71db4324614abb57ae631c Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 26 Sep 2022 20:25:18 +0100 Subject: [PATCH] Default intersheet ref field visibility to off, and show warning when user tries to edit via Symbol Properties or Field Propeties. --- eeschema/dialogs/dialog_field_properties.cpp | 12 ++++++++++++ eeschema/dialogs/dialog_label_properties.cpp | 13 +++++++++++++ eeschema/files-io.cpp | 2 +- eeschema/sch_edit_frame.cpp | 11 ++++++++--- eeschema/sch_edit_frame.h | 2 +- eeschema/sch_label.cpp | 2 +- 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/eeschema/dialogs/dialog_field_properties.cpp b/eeschema/dialogs/dialog_field_properties.cpp index 2f9f141974..2c803b19b0 100644 --- a/eeschema/dialogs/dialog_field_properties.cpp +++ b/eeschema/dialogs/dialog_field_properties.cpp @@ -662,6 +662,18 @@ void DIALOG_SCH_FIELD_PROPERTIES::UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH else if( fieldType == FOOTPRINT_FIELD ) symbol->SetFootprint( m_text ); } + else if( parent && parent->Type() == SCH_GLOBAL_LABEL_T ) + { + if( fieldType == 0 ) + { + if( m_visible->GetValue() != parent->Schematic()->Settings().m_IntersheetRefsShow ) + { + DisplayInfoMessage( this, _( "Intersheet reference visibility is " + "controlled globally from " + "Schematic Setup > General > Formatting" ) ); + } + } + } bool positioningModified = false; diff --git a/eeschema/dialogs/dialog_label_properties.cpp b/eeschema/dialogs/dialog_label_properties.cpp index 4d0c8d87b0..e2fa523c6a 100644 --- a/eeschema/dialogs/dialog_label_properties.cpp +++ b/eeschema/dialogs/dialog_label_properties.cpp @@ -450,11 +450,24 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataFromWindow() field.Offset( m_currentLabel->GetPosition() ); if( field.GetCanonicalName() == wxT( "Netclass" ) ) + { field.SetLayer( LAYER_NETCLASS_REFS ); + } else if( field.GetCanonicalName() == wxT( "Intersheetrefs" ) ) + { + if( field.IsVisible() != m_Parent->Schematic().Settings().m_IntersheetRefsShow ) + { + DisplayInfoMessage( this, _( "Intersheet reference visibility is " + "controlled globally from " + "Schematic Setup > General > Formatting" ) ); + } + field.SetLayer( LAYER_INTERSHEET_REFS ); + } else + { field.SetLayer( LAYER_FIELDS ); + } } if( positioningChanged( m_fields, m_currentLabel->GetFields() ) ) diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 8de99599cb..8ef3e83fb7 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -485,7 +485,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in initScreenZoom(); SetSheetNumberAndCount(); - RecomputeIntersheetRefs(); + RecomputeIntersheetRefs( true ); GetCurrentSheet().UpdateAllScreenReferences(); // re-create junctions if needed. Eeschema optimizes wires by merging diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 48ce1c0fd4..4b53c2c4af 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1533,7 +1533,7 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_CLEANUP_FLAGS aCleanupFlags ) } -void SCH_EDIT_FRAME::RecomputeIntersheetRefs() +void SCH_EDIT_FRAME::RecomputeIntersheetRefs( bool autoplaceUninitialized ) { std::map>& pageRefsMap = Schematic().GetPageRefsMap(); @@ -1579,10 +1579,15 @@ void SCH_EDIT_FRAME::RecomputeIntersheetRefs() for( SCH_GLOBALLABEL* globalLabel : globalLabels ) { - globalLabel->GetFields()[0].SetVisible( show ); + std::vector& fields = globalLabel->GetFields(); + + fields[0].SetVisible( show ); if( show ) { + if( fields.size() == 1 && fields[0].GetTextPos() == globalLabel->GetPosition() ) + globalLabel->AutoplaceFields( GetScreen(), false ); + GetScreen()->Update( globalLabel ); GetCanvas()->GetView()->Update( globalLabel ); } @@ -1593,7 +1598,7 @@ void SCH_EDIT_FRAME::RecomputeIntersheetRefs() void SCH_EDIT_FRAME::ShowAllIntersheetRefs( bool aShow ) { if( aShow ) - RecomputeIntersheetRefs(); + RecomputeIntersheetRefs( true ); GetCanvas()->GetView()->SetLayerVisible( LAYER_INTERSHEET_REFS, aShow ); } diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 9fc6b7d2c1..d08038e1e1 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -804,7 +804,7 @@ public: * Update the schematic's page reference map for all global labels, and refresh the labels * so that they are redrawn with up-to-date references. */ - void RecomputeIntersheetRefs(); + void RecomputeIntersheetRefs( bool autoplaceUninitialized = false ); void ShowAllIntersheetRefs( bool aShow ); diff --git a/eeschema/sch_label.cpp b/eeschema/sch_label.cpp index e7bc812229..3bf24d98bd 100644 --- a/eeschema/sch_label.cpp +++ b/eeschema/sch_label.cpp @@ -1233,7 +1233,7 @@ SCH_GLOBALLABEL::SCH_GLOBALLABEL( const VECTOR2I& pos, const wxString& text ) : m_fields.emplace_back( SCH_FIELD( pos, 0, this, _( "Sheet References" ) ) ); m_fields[0].SetText( wxT( "${INTERSHEET_REFS}" ) ); - m_fields[0].SetVisible( true ); + m_fields[0].SetVisible( false ); m_fields[0].SetLayer( LAYER_INTERSHEET_REFS ); m_fields[0].SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); }