From e033e394e70cd41cfdef5a94ece78c93b216eb18 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 20 Feb 2020 21:29:21 +0000 Subject: [PATCH] Add visibility flags for sheet names and sheet filenames. --- eeschema/dialogs/dialog_sch_sheet_props.cpp | 15 +- eeschema/dialogs/dialog_sch_sheet_props.h | 2 - .../dialogs/dialog_sch_sheet_props_base.cpp | 89 ++-- .../dialogs/dialog_sch_sheet_props_base.fbp | 423 ++++++++---------- .../dialogs/dialog_sch_sheet_props_base.h | 5 +- eeschema/sch_edit_frame.h | 6 - eeschema/sch_legacy_plugin.cpp | 45 +- eeschema/sch_painter.cpp | 38 +- eeschema/sch_sheet.cpp | 118 ++--- eeschema/sch_sheet.h | 23 +- eeschema/sheet.cpp | 9 +- 11 files changed, 362 insertions(+), 411 deletions(-) diff --git a/eeschema/dialogs/dialog_sch_sheet_props.cpp b/eeschema/dialogs/dialog_sch_sheet_props.cpp index fa80589c24..ab8195d3f2 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props.cpp +++ b/eeschema/dialogs/dialog_sch_sheet_props.cpp @@ -50,9 +50,13 @@ DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( SCH_EDIT_FRAME* parent, SCH_SHEE m_tabOrder = { m_textFileName, m_browseButton, - m_textSheetName, + m_filenameVisible, m_filenameSizeCtrl, + + m_textSheetName, m_sheetnameSizeCtrl, + m_sheetnameVisible, + m_sdbSizer1OK, m_sdbSizer1Cancel }; @@ -84,14 +88,14 @@ bool DIALOG_SCH_SHEET_PROPS::TransferDataToWindow() fname.Replace( wxT("/"), wxT("\\") ); #endif m_textFileName->SetValue( fname ); + m_filenameVisible->SetValue( m_sheet->GetShowFileName() ); m_textSheetName->SetValue( m_sheet->GetName() ); + m_sheetnameVisible->SetValue( m_sheet->GetShowSheetName() ); m_filenameTextSize.SetValue( m_sheet->GetFileNameSize() ); m_sheetnameTextSize.SetValue( m_sheet->GetSheetNameSize() ); - m_textCtrlTimeStamp->SetValue( m_sheet->m_Uuid.AsString() ); - return true; } @@ -118,6 +122,11 @@ bool DIALOG_SCH_SHEET_PROPS::TransferDataFromWindow() return false; } + m_sheet->SetShowFileName( m_filenameVisible->GetValue() ); + m_sheet->SetFileNameSize( m_filenameTextSize.GetValue() ); + m_sheet->SetShowSheetName( m_sheetnameVisible->GetValue() ); + m_sheet->SetSheetNameSize( m_sheetnameTextSize.GetValue() ); + return true; } diff --git a/eeschema/dialogs/dialog_sch_sheet_props.h b/eeschema/dialogs/dialog_sch_sheet_props.h index 6feaaf317d..2fbc6a6bbe 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props.h +++ b/eeschema/dialogs/dialog_sch_sheet_props.h @@ -52,8 +52,6 @@ public: const wxString GetFileName(); wxString GetSheetName() { return m_textSheetName->GetValue(); } - int GetFileNameTextSize() { return m_filenameTextSize.GetValue(); } - int GetSheetNameTextSize() { return m_sheetnameTextSize.GetValue(); } }; #endif // __dialog_sch_sheet_props__ diff --git a/eeschema/dialogs/dialog_sch_sheet_props_base.cpp b/eeschema/dialogs/dialog_sch_sheet_props_base.cpp index d407a6ba49..4187d726ce 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props_base.cpp +++ b/eeschema/dialogs/dialog_sch_sheet_props_base.cpp @@ -23,100 +23,87 @@ DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWi wxBoxSizer* bupperSizer; bupperSizer = new wxBoxSizer( wxVERTICAL ); - wxFlexGridSizer* fgSizer1; - fgSizer1 = new wxFlexGridSizer( 0, 7, 0, 0 ); - fgSizer1->AddGrowableCol( 1 ); - fgSizer1->SetFlexibleDirection( wxBOTH ); - fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + wxBoxSizer* bSizer3; + bSizer3 = new wxBoxSizer( wxHORIZONTAL ); m_filenameLabel = new wxStaticText( this, wxID_ANY, _("&File name:"), wxDefaultPosition, wxDefaultSize, 0 ); m_filenameLabel->Wrap( -1 ); - fgSizer1->Add( m_filenameLabel, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + bSizer3->Add( m_filenameLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_textFileName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_textFileName->SetMinSize( wxSize( 240,-1 ) ); + m_textFileName->SetMinSize( wxSize( 360,-1 ) ); - fgSizer1->Add( m_textFileName, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM, 5 ); + bSizer3->Add( m_textFileName, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); m_browseButton = new wxBitmapButton( this, ID_BUTTON_BROWSE_SHEET, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_browseButton->SetMinSize( wxSize( 30,28 ) ); - fgSizer1->Add( m_browseButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 2 ); + bSizer3->Add( m_browseButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - fgSizer1->Add( 0, 0, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT, 10 ); + bupperSizer->Add( bSizer3, 0, wxEXPAND, 5 ); + + wxBoxSizer* bSizer4; + bSizer4 = new wxBoxSizer( wxHORIZONTAL ); + + m_filenameVisible = new wxCheckBox( this, wxID_ANY, _("Visible"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer4->Add( m_filenameVisible, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 36 ); m_filenameSizeLabel = new wxStaticText( this, wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 ); m_filenameSizeLabel->Wrap( -1 ); - fgSizer1->Add( m_filenameSizeLabel, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + bSizer4->Add( m_filenameSizeLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); m_filenameSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer1->Add( m_filenameSizeCtrl, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5 ); + bSizer4->Add( m_filenameSizeCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_filenameSizeUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); m_filenameSizeUnits->Wrap( -1 ); - fgSizer1->Add( m_filenameSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + bSizer4->Add( m_filenameSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + + + bupperSizer->Add( bSizer4, 0, wxEXPAND, 5 ); + + + bupperSizer->Add( 0, 15, 0, wxEXPAND, 5 ); + + wxBoxSizer* bSizer5; + bSizer5 = new wxBoxSizer( wxHORIZONTAL ); m_sheetnameLabel = new wxStaticText( this, wxID_ANY, _("&Sheet name:"), wxDefaultPosition, wxDefaultSize, 0 ); m_sheetnameLabel->Wrap( -1 ); - fgSizer1->Add( m_sheetnameLabel, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + bSizer5->Add( m_sheetnameLabel, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); m_textSheetName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer1->Add( m_textSheetName, 5, wxEXPAND|wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 ); + bSizer5->Add( m_textSheetName, 5, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); - fgSizer1->Add( 0, 0, 0, wxALIGN_CENTER_VERTICAL|wxALL, 10 ); + bupperSizer->Add( bSizer5, 0, wxEXPAND, 5 ); + wxBoxSizer* bSizer6; + bSizer6 = new wxBoxSizer( wxHORIZONTAL ); - fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); + m_sheetnameVisible = new wxCheckBox( this, wxID_ANY, _("Visible"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer6->Add( m_sheetnameVisible, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 36 ); m_sheetnameSizeLabel = new wxStaticText( this, wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 ); m_sheetnameSizeLabel->Wrap( -1 ); - fgSizer1->Add( m_sheetnameSizeLabel, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + bSizer6->Add( m_sheetnameSizeLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); m_sheetnameSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer1->Add( m_sheetnameSizeCtrl, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5 ); + bSizer6->Add( m_sheetnameSizeCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_sheetnameSizeUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); m_sheetnameSizeUnits->Wrap( -1 ); - fgSizer1->Add( m_sheetnameSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + bSizer6->Add( m_sheetnameSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - fgSizer1->Add( 0, 0, 1, wxEXPAND|wxTOP|wxBOTTOM, 5 ); + bupperSizer->Add( bSizer6, 0, wxEXPAND, 5 ); - fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); - - m_staticTextTimeStamp = new wxStaticText( this, wxID_ANY, _("Unique timestamp:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextTimeStamp->Wrap( -1 ); - fgSizer1->Add( m_staticTextTimeStamp, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - - m_textCtrlTimeStamp = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); - fgSizer1->Add( m_textCtrlTimeStamp, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); - - - bupperSizer->Add( fgSizer1, 1, wxALL|wxEXPAND, 5 ); - - - mainSizer->Add( bupperSizer, 0, wxEXPAND|wxTOP, 5 ); + mainSizer->Add( bupperSizer, 0, wxEXPAND|wxALL, 5 ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - mainSizer->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + mainSizer->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); m_sdbSizer1 = new wxStdDialogButtonSizer(); m_sdbSizer1OK = new wxButton( this, wxID_OK ); diff --git a/eeschema/dialogs/dialog_sch_sheet_props_base.fbp b/eeschema/dialogs/dialog_sch_sheet_props_base.fbp index dd318761e7..c8153ae249 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props_base.fbp +++ b/eeschema/dialogs/dialog_sch_sheet_props_base.fbp @@ -60,7 +60,7 @@ none 5 - wxEXPAND|wxTOP + wxEXPAND|wxALL 0 @@ -69,23 +69,16 @@ none 5 - wxALL|wxEXPAND - 1 - - 7 - wxBOTH - 1 - - 0 + wxEXPAND + 0 + - fgSizer1 - wxFLEX_GROWMODE_SPECIFIED + bSizer3 + wxHORIZONTAL none - 0 - 0 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxALL|wxALIGN_CENTER_VERTICAL 0 1 @@ -146,8 +139,8 @@ 5 - wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM - 0 + wxALL|wxALIGN_CENTER_VERTICAL + 1 1 1 @@ -182,7 +175,7 @@ 0 0 - 240,-1 + 360,-1 1 m_textFileName 1 @@ -209,8 +202,8 @@ - 2 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT 0 1 @@ -281,19 +274,84 @@ OnBrowseClicked + + + + 5 + wxEXPAND + 0 + + + bSizer4 + wxHORIZONTAL + none - 10 - wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT + 36 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT 0 - - 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Visible + + 0 + + + 0 + + 1 + m_filenameVisible + 1 + + protected - 0 + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT 0 1 @@ -354,7 +412,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM + wxALIGN_CENTER_VERTICAL 0 1 @@ -418,7 +476,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT 0 1 @@ -477,6 +535,27 @@ -1 + + + + 5 + wxEXPAND + 0 + + 15 + protected + 0 + + + + 5 + wxEXPAND + 0 + + + bSizer5 + wxHORIZONTAL + none 5 wxALIGN_CENTER_VERTICAL|wxALL @@ -540,7 +619,7 @@ 5 - wxEXPAND|wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL + wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT 5 1 @@ -602,29 +681,84 @@ + + + + 5 + wxEXPAND + 0 + + + bSizer6 + wxHORIZONTAL + none - 10 - wxALIGN_CENTER_VERTICAL|wxALL + 36 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT 0 - - 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Visible + + 0 + + + 0 + + 1 + m_sheetnameVisible + 1 + + protected - 0 + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT 0 1 @@ -685,7 +819,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM + wxALIGN_CENTER_VERTICAL 0 1 @@ -749,7 +883,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT 0 1 @@ -808,207 +942,12 @@ -1 - - 5 - wxEXPAND|wxTOP|wxBOTTOM - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxALL|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Unique timestamp: - 0 - - 0 - - - 0 - - 1 - m_staticTextTimeStamp - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxEXPAND|wxTOP|wxBOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - m_textCtrlTimeStamp - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_READONLY - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 + 10 wxEXPAND|wxTOP|wxRIGHT|wxLEFT 0 diff --git a/eeschema/dialogs/dialog_sch_sheet_props_base.h b/eeschema/dialogs/dialog_sch_sheet_props_base.h index d04172811c..b461630abe 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props_base.h +++ b/eeschema/dialogs/dialog_sch_sheet_props_base.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -50,16 +51,16 @@ class DIALOG_SCH_SHEET_PROPS_BASE : public DIALOG_SHIM wxStaticText* m_filenameLabel; wxTextCtrl* m_textFileName; wxBitmapButton* m_browseButton; + wxCheckBox* m_filenameVisible; wxStaticText* m_filenameSizeLabel; wxTextCtrl* m_filenameSizeCtrl; wxStaticText* m_filenameSizeUnits; wxStaticText* m_sheetnameLabel; wxTextCtrl* m_textSheetName; + wxCheckBox* m_sheetnameVisible; wxStaticText* m_sheetnameSizeLabel; wxTextCtrl* m_sheetnameSizeCtrl; wxStaticText* m_sheetnameSizeUnits; - wxStaticText* m_staticTextTimeStamp; - wxTextCtrl* m_textCtrlTimeStamp; wxStaticLine* m_staticline1; wxStdDialogButtonSizer* m_sdbSizer1; wxButton* m_sdbSizer1OK; diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 5aa861e44f..c4e4519546 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -726,12 +726,6 @@ private: */ void UpdateTitle(); - /** - * Perform all cleanup and normalization steps so that the whole schematic - * is in a good state. This should only be called when loading a file. - */ - void NormalizeSchematicOnFirstLoad( bool recalculateConnections ); - /** * Verify that \a aSheet will not cause a recursion error in \a aHierarchy. * diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index 6a12f481f0..9efa6ec861 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -993,19 +993,27 @@ SCH_SHEET* SCH_LEGACY_PLUGIN::loadSheet( LINE_READER& aReader ) wxString text; int size; int fieldId = parseInt( aReader, line, &line ); + bool visible = true; if( fieldId == 0 || fieldId == 1 ) // Sheet name and file name. { parseQuotedString( text, aReader, line, &line ); size = Mils2Iu( parseInt( aReader, line, &line ) ); + if( strCompare( "V", line, &line ) ) + visible = true; + else if( strCompare( "I", line, &line ) ) + visible = false; + if( fieldId == 0 ) { + sheet->SetShowSheetName( visible ); sheet->SetName( text ); sheet->SetSheetNameSize( size ); } else { + sheet->SetShowFileName( visible ); sheet->SetFileName( text ); sheet->SetFileNameSize( size ); } @@ -1027,27 +1035,12 @@ SCH_SHEET* SCH_LEGACY_PLUGIN::loadSheet( LINE_READER& aReader ) switch( parseChar( aReader, line, &line ) ) { - case 'I': - sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_INPUT ); - break; - - case 'O': - sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_OUTPUT ); - break; - - case 'B': - sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_BIDI ); - break; - - case 'T': - sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_TRISTATE ); - break; - - case 'U': - sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_UNSPECIFIED ); - break; - default: - SCH_PARSE_ERROR( "invalid sheet pin type", aReader, line ); + case 'I': sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_INPUT ); break; + case 'O': sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_OUTPUT ); break; + case 'B': sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_BIDI ); break; + case 'T': sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_TRISTATE ); break; + case 'U': sheetPin->SetShape( PINSHEETLABEL_SHAPE::PS_UNSPECIFIED ); break; + default: SCH_PARSE_ERROR( "invalid sheet pin type", aReader, line ); } switch( parseChar( aReader, line, &line ) ) @@ -2171,14 +2164,16 @@ void SCH_LEGACY_PLUGIN::saveSheet( SCH_SHEET* aSheet ) m_out->Print( 0, "U %s\n", TO_UTF8( aSheet->m_Uuid.AsString() ) ); if( !aSheet->GetName().IsEmpty() ) - m_out->Print( 0, "F0 %s %d\n", + m_out->Print( 0, "F0 %s %d %c\n", EscapedUTF8( aSheet->GetName() ).c_str(), - Iu2Mils( aSheet->GetSheetNameSize() ) ); + Iu2Mils( aSheet->GetSheetNameSize() ), + aSheet->GetShowSheetName() ? 'V' : 'I' ); if( !aSheet->GetFileName().IsEmpty() ) - m_out->Print( 0, "F1 %s %d\n", + m_out->Print( 0, "F1 %s %d %c\n", EscapedUTF8( aSheet->GetFileName() ).c_str(), - Iu2Mils( aSheet->GetFileNameSize() ) ); + Iu2Mils( aSheet->GetFileNameSize() ), + aSheet->GetShowFileName() ? 'V' : 'I' ); for( const SCH_SHEET_PIN* pin : aSheet->GetPins() ) { diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index b2219d36d9..b66c23e8a0 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -1609,28 +1609,36 @@ void SCH_PAINTER::draw( SCH_SHEET *aSheet, int aLayer ) } } - m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETNAME, drawingShadows ) ); + if( aSheet->GetShowSheetName() ) + { + wxString text = wxT( "Sheet: " ) + aSheet->GetName(); - auto text = wxT( "Sheet: " ) + aSheet->GetName(); + m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETNAME, drawingShadows ) ); + m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT ); + m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + int txtSize = aSheet->GetSheetNameSize(); + m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) ); + m_gal->SetFontBold( false ); + m_gal->SetFontItalic( false ); - auto txtSize = aSheet->GetSheetNameSize(); + strokeText( text, pos_sheetname, nameAngle ); + } - m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) ); - m_gal->SetFontBold( false ); - m_gal->SetFontItalic( false ); + if( aSheet->GetShowFileName() ) + { + wxString text = wxT( "File: " ) + aSheet->GetFileName(); - strokeText( text, pos_sheetname, nameAngle ); + m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETFILENAME, drawingShadows ) ); + m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP ); - txtSize = aSheet->GetFileNameSize(); - m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) ); - m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETFILENAME, drawingShadows ) ); - m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_TOP ); + int txtSize = aSheet->GetFileNameSize(); + m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) ); + m_gal->SetFontBold( false ); + m_gal->SetFontItalic( false ); - text = wxT( "File: " ) + aSheet->GetFileName(); - strokeText( text, pos_filename, nameAngle ); + strokeText( text, pos_filename, nameAngle ); + } } } diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 36f612e3e0..c65a6ab6a4 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -22,22 +22,15 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file sch_sheet.cpp - * @brief Implementation of SCH_SHEET class. - */ - #include #include #include #include -#include #include #include #include #include #include // for KiROUND - #include #include #include @@ -51,7 +44,9 @@ SCH_SHEET::SCH_SHEET( const wxPoint& pos ) : m_Layer = LAYER_SHEET; m_pos = pos; m_size = wxSize( Mils2iu( MIN_SHEET_WIDTH ), Mils2iu( MIN_SHEET_HEIGHT ) ); + m_showSheetName = true; m_sheetNameSize = GetDefaultTextSize(); + m_showFileName = true; m_fileNameSize = GetDefaultTextSize(); m_screen = NULL; m_name.Printf( wxT( "Sheet%s" ), m_Uuid.AsString() ); @@ -66,7 +61,9 @@ SCH_SHEET::SCH_SHEET( const SCH_SHEET& aSheet ) : m_size = aSheet.m_size; m_Layer = aSheet.m_Layer; const_cast( m_Uuid ) = aSheet.m_Uuid; + m_showSheetName = aSheet.m_showSheetName; m_sheetNameSize = aSheet.m_sheetNameSize; + m_showFileName = aSheet.m_showFileName; m_fileNameSize = aSheet.m_fileNameSize; m_screen = aSheet.m_screen; m_name = aSheet.m_name; @@ -162,7 +159,9 @@ void SCH_SHEET::SwapData( SCH_ITEM* aItem ) std::swap( m_pos, sheet->m_pos ); std::swap( m_size, sheet->m_size ); std::swap( m_name, sheet->m_name ); + std::swap( m_showSheetName, sheet->m_showSheetName ); std::swap( m_sheetNameSize, sheet->m_sheetNameSize ); + std::swap( m_showFileName, sheet->m_showFileName ); std::swap( m_fileNameSize, sheet->m_fileNameSize ); m_pins.swap( sheet->m_pins ); @@ -466,18 +465,24 @@ void SCH_SHEET::Print( wxDC* aDC, const wxPoint& aOffset ) name_orientation = TEXT_ANGLE_HORIZ; /* Draw text : SheetName */ - Text = wxT( "Sheet: " ) + m_name; - textSize = wxSize( m_sheetNameSize, m_sheetNameSize ); - textWidth = Clamp_Text_PenSize( lineWidth, textSize, false ); - GRText( aDC, pos_sheetname, GetLayerColor( LAYER_SHEETNAME ), Text, name_orientation, - textSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, textWidth, false, false ); + if( m_showSheetName ) + { + Text = wxT( "Sheet: " ) + m_name; + textSize = wxSize( m_sheetNameSize, m_sheetNameSize ); + textWidth = Clamp_Text_PenSize( lineWidth, textSize, false ); + GRText( aDC, pos_sheetname, GetLayerColor( LAYER_SHEETNAME ), Text, name_orientation, + textSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, textWidth, false, false ); + } /* Draw text : FileName */ - Text = wxT( "File: " ) + m_fileName; - textSize = wxSize( m_fileNameSize, m_fileNameSize ); - textWidth = Clamp_Text_PenSize( lineWidth, textSize, false ); - GRText( aDC, pos_filename, GetLayerColor( LAYER_SHEETFILENAME ), Text, name_orientation, - textSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, textWidth, false, false ); + if( m_showFileName ) + { + Text = wxT( "File: " ) + m_fileName; + textSize = wxSize( m_fileNameSize, m_fileNameSize ); + textWidth = Clamp_Text_PenSize( lineWidth, textSize, false ); + GRText( aDC, pos_filename, GetLayerColor( LAYER_SHEETFILENAME ), Text, name_orientation, + textSize, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, textWidth, false, false ); + } /* Draw text : SheetLabel */ for( SCH_SHEET_PIN* sheetPin : m_pins ) @@ -487,22 +492,30 @@ void SCH_SHEET::Print( wxDC* aDC, const wxPoint& aOffset ) const EDA_RECT SCH_SHEET::GetBoundingBox() const { - wxPoint end; + wxPoint end; EDA_RECT box( m_pos, m_size ); int lineWidth = GetPenSize(); + int textLength = 0; // Determine length of texts - wxString text = wxT( "Sheet: " ) + m_name; - int textlen = GraphicTextWidth( text, wxSize( m_sheetNameSize, m_sheetNameSize ), - false, false ); + if( m_showSheetName ) + { + wxString text = wxT( "Sheet: " ) + m_name; + int textlen = GraphicTextWidth( text, wxSize( m_sheetNameSize, m_sheetNameSize ), + false, false ); + textLength = std::max( textLength, textlen ); + } - text = wxT( "File: " ) + m_fileName; - int textlen2 = GraphicTextWidth( text, wxSize( m_fileNameSize, m_fileNameSize ), - false, false ); + if( m_showFileName ) + { + wxString text = wxT( "File: " ) + m_fileName; + int textlen = GraphicTextWidth( text, wxSize( m_fileNameSize, m_fileNameSize ), + false, false ); + textLength = std::max( textLength, textlen ); + } // Calculate bounding box X size: - textlen = std::max( textlen, textlen2 ); - end.x = std::max( m_size.x, textlen ); + end.x = std::max( m_size.x, textLength ); // Calculate bounding box pos: end.y = m_size.y; @@ -636,9 +649,7 @@ void SCH_SHEET::GetMsgPanelInfo( EDA_UNITS aUnits, MSG_PANEL_ITEMS& aList ) aList.push_back( MSG_PANEL_ITEM( _( "File Name" ), m_fileName, BROWN ) ); #if 0 // Set to 1 to display the sheet time stamp (mainly for test) - wxString msg; - msg.Printf( wxT( "%.8X" ), m_TimeStamp ); - aList.push_back( MSG_PANEL_ITEM( _( "Time Stamp" ), msg, BLUE ) ); + aList.push_back( MSG_PANEL_ITEM( _( "UUID" ), m_Uuid.AsString(), BLUE ) ); #endif } @@ -904,32 +915,39 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter ) name_orientation = TEXT_ANGLE_HORIZ; } - /* Draw texts: SheetName */ - Text = m_name; - size = wxSize( m_sheetNameSize, m_sheetNameSize ); - - //pos = m_pos; pos.y -= 4; - thickness = GetDefaultLineThickness(); - thickness = Clamp_Text_PenSize( thickness, size, false ); - - aPlotter->SetColor( GetLayerColor( LAYER_SHEETNAME ) ); - bool italic = false; - aPlotter->Text( pos_sheetname, txtcolor, wxT( "Sheet: " ) + Text, name_orientation, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, - thickness, italic, false ); + + /* Draw texts: SheetName */ + if( m_showSheetName ) + { + Text = m_name; + size = wxSize( m_sheetNameSize, m_sheetNameSize ); + + //pos = m_pos; pos.y -= 4; + thickness = GetDefaultLineThickness(); + thickness = Clamp_Text_PenSize( thickness, size, false ); + + aPlotter->SetColor( GetLayerColor( LAYER_SHEETNAME ) ); + + aPlotter->Text( pos_sheetname, txtcolor, wxT( "Sheet: " ) + Text, name_orientation, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, + thickness, false, false ); + } /*Draw texts : FileName */ - Text = GetFileName(); - size = wxSize( m_fileNameSize, m_fileNameSize ); - thickness = GetDefaultLineThickness(); - thickness = Clamp_Text_PenSize( thickness, size, false ); + if( m_showFileName ) + { + Text = GetFileName(); + size = wxSize( m_fileNameSize, m_fileNameSize ); + thickness = GetDefaultLineThickness(); + thickness = Clamp_Text_PenSize( thickness, size, false ); - aPlotter->SetColor( GetLayerColor( LAYER_SHEETFILENAME ) ); + aPlotter->SetColor( GetLayerColor( LAYER_SHEETFILENAME ) ); - aPlotter->Text( pos_filename, txtcolor, wxT( "File: " ) + Text, name_orientation, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, - thickness, italic, false ); + aPlotter->Text( pos_filename, txtcolor, wxT( "File: " ) + Text, name_orientation, size, + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, + thickness, italic, false ); + } aPlotter->SetColor( GetLayerColor( GetLayer() ) ); diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 643a911109..64f459d0ec 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -219,22 +219,17 @@ class SCH_SHEET : public SCH_ITEM /// The file name is also in the #SCH_SCREEN object associated with the sheet. It is /// also needed here for loading after reading the sheet description from file. wxString m_fileName; + bool m_showFileName; // Indicates filename should be drawn on schematic. + int m_fileNameSize; // The height of the text used to draw the file name. /// This is equivalent to the reference designator for components and is stored in F0 /// sheet pin in the schematic file. wxString m_name; + bool m_showSheetName; // Indicates sheet name should be drawn on schematic. + int m_sheetNameSize; // The height of the text used to draw the sheet name. - /// The height of the text used to draw the sheet name. - int m_sheetNameSize; - - /// The height of the text used to draw the file name. - int m_fileNameSize; - - /// The position of the sheet. - wxPoint m_pos; - - /// The size of the sheet. - wxSize m_size; + wxPoint m_pos; // The position of the sheet. + wxSize m_size; // The size of the sheet. public: SCH_SHEET( const wxPoint& pos = wxPoint( 0, 0 ) ); @@ -271,9 +266,15 @@ public: wxString GetName() const { return m_name; } void SetName( const wxString& aName ) { m_name = aName; } + bool GetShowSheetName() const { return m_showSheetName; } + void SetShowSheetName( bool show ) { m_showSheetName = show; } + int GetSheetNameSize() const { return m_sheetNameSize; } void SetSheetNameSize( int aSize ) { m_sheetNameSize = aSize; } + bool GetShowFileName() const { return m_showFileName; } + void SetShowFileName( bool show ) { m_showFileName = show; } + int GetFileNameSize() const { return m_fileNameSize; } void SetFileNameSize( int aSize ) { m_fileNameSize = aSize; } diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 87dd316ab7..1e6f1ec86e 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -600,9 +600,12 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy, // and can be not always undoable. // So prepare messages for user notifications: replaceMsg.Printf( _( "Change \"%s\" link from \"%s\" to \"%s\"?" ), - dlg.GetSheetName(), aSheet->GetFileName(), fileName.GetFullName() ); + dlg.GetSheetName(), + aSheet->GetFileName(), + fileName.GetFullName() ); newMsg.Printf( _( "Create new file \"%s\" with contents of \"%s\"?" ), - fileName.GetFullName(), aSheet->GetFileName() ); + fileName.GetFullName(), + aSheet->GetFileName() ); noUndoMsg = _( "This action cannot be undone." ); // We are always using here a case insensitive comparison @@ -741,9 +744,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy, tmpFn.Replace( "\\", "/" ); aSheet->SetFileName( tmpFn ); - aSheet->SetFileNameSize( dlg.GetFileNameTextSize() ); aSheet->SetName( dlg.GetSheetName() ); - aSheet->SetSheetNameSize( dlg.GetSheetNameTextSize() ); if( aSheet->GetName().IsEmpty() ) aSheet->SetName( wxString::Format( wxT( "Sheet%s" ), aSheet->m_Uuid.AsString() ) );