From 56794ab82937f0012b6c9bcfc953e2ccdb3a852a Mon Sep 17 00:00:00 2001 From: Kevin Lannen Date: Wed, 21 Apr 2021 22:50:14 -0600 Subject: [PATCH] Eeschema: Add pin count column to pin table ADDED: When the pin table is showing grouped pins, display a read-only column that displays the number of pins in each row. Fixes https://gitlab.com/kicad/code/kicad/-/issues/2416 --- .../dialogs/dialog_lib_edit_pin_table.cpp | 26 ++++++++++++- eeschema/dialogs/dialog_lib_edit_pin_table.h | 3 +- .../dialog_lib_edit_pin_table_base.cpp | 38 ++++++++++--------- .../dialog_lib_edit_pin_table_base.fbp | 6 +-- .../symbol_editor/symbol_editor_settings.cpp | 2 +- 5 files changed, 50 insertions(+), 25 deletions(-) diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp index 87f4c533eb..b29166567d 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp @@ -66,6 +66,7 @@ public: { switch( aCol ) { + case COL_PIN_COUNT: return _( "Count" ); case COL_NUMBER: return _( "Number" ); case COL_NAME: return _( "Name" ); case COL_TYPE: return _( "Electrical Type" ); @@ -104,6 +105,7 @@ public: switch( aCol ) { + case COL_PIN_COUNT: val << pins.size(); break; case COL_NUMBER: val = pin->GetNumber(); break; @@ -463,6 +465,10 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent, // Set special attributes wxGridCellAttr* attr; + attr = new wxGridCellAttr; + attr->SetReadOnly( true ); + m_grid->SetColAttr( COL_PIN_COUNT, attr ); + attr = new wxGridCellAttr; wxArrayString typeNames = PinTypeNames(); typeNames.push_back( INDETERMINATE_STATE ); @@ -558,6 +564,11 @@ bool DIALOG_LIB_EDIT_PIN_TABLE::TransferDataToWindow() m_dataModel->RebuildRows( m_pins, m_cbGroup->GetValue() ); + if( m_cbGroup->GetValue() ) + m_grid->ShowCol( COL_PIN_COUNT ); + else + m_grid->HideCol( COL_PIN_COUNT ); + updateSummary(); return true; @@ -635,8 +646,8 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnAddRow( wxCommandEvent& event ) m_dataModel->AppendRow( m_pins[ m_pins.size() - 1 ] ); - m_grid->MakeCellVisible( m_grid->GetNumberRows() - 1, 0 ); - m_grid->SetGridCursor( m_grid->GetNumberRows() - 1, 0 ); + m_grid->MakeCellVisible( m_grid->GetNumberRows() - 1, 1 ); + m_grid->SetGridCursor( m_grid->GetNumberRows() - 1, 1 ); m_grid->EnableCellEditControl( true ); m_grid->ShowCellEditControl(); @@ -687,6 +698,17 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnRebuildRows( wxCommandEvent& ) m_dataModel->RebuildRows( m_pins, m_cbGroup->GetValue() ); + if( m_cbGroup->GetValue() ) + { + m_grid->ShowCol( COL_PIN_COUNT ); + m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + } + else + { + m_grid->HideCol( COL_PIN_COUNT ); + } + + adjustGridColumns(); } diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.h b/eeschema/dialogs/dialog_lib_edit_pin_table.h index 56ca92364b..1b6329ddac 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.h +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.h @@ -28,6 +28,7 @@ enum COL_ORDER { + COL_PIN_COUNT, COL_NUMBER, COL_NAME, COL_TYPE, @@ -40,7 +41,7 @@ enum COL_ORDER COL_POSY, COL_VISIBLE, - COL_COUNT // keep as last + COL_COUNT // keep as last }; diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp index b91e728f7b..51bef20f50 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp @@ -21,38 +21,40 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent m_grid = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxSize( 800,400 ), 0 ); // Grid - m_grid->CreateGrid( 5, 11 ); + m_grid->CreateGrid( 5, 12 ); m_grid->EnableEditing( true ); m_grid->EnableGridLines( true ); m_grid->EnableDragGridSize( false ); m_grid->SetMargins( 0, 0 ); // Columns - m_grid->SetColSize( 0, 66 ); - m_grid->SetColSize( 1, 84 ); - m_grid->SetColSize( 2, 140 ); + m_grid->SetColSize( 0, 60 ); + m_grid->SetColSize( 1, 66 ); + m_grid->SetColSize( 2, 84 ); m_grid->SetColSize( 3, 140 ); - m_grid->SetColSize( 4, 100 ); - m_grid->SetColSize( 5, 110 ); + m_grid->SetColSize( 4, 140 ); + m_grid->SetColSize( 5, 100 ); m_grid->SetColSize( 6, 110 ); - m_grid->SetColSize( 7, 84 ); + m_grid->SetColSize( 7, 110 ); m_grid->SetColSize( 8, 84 ); m_grid->SetColSize( 9, 84 ); m_grid->SetColSize( 10, 84 ); + m_grid->SetColSize( 11, 84 ); m_grid->EnableDragColMove( false ); m_grid->EnableDragColSize( true ); m_grid->SetColLabelSize( 24 ); - m_grid->SetColLabelValue( 0, _("Number") ); - m_grid->SetColLabelValue( 1, _("Name") ); - m_grid->SetColLabelValue( 2, _("Electrical Type") ); - m_grid->SetColLabelValue( 3, _("Graphic Style") ); - m_grid->SetColLabelValue( 4, _("Orientation") ); - m_grid->SetColLabelValue( 5, _("Number Text Size") ); - m_grid->SetColLabelValue( 6, _("Name Text Size") ); - m_grid->SetColLabelValue( 7, _("Length") ); - m_grid->SetColLabelValue( 8, _("X Position") ); - m_grid->SetColLabelValue( 9, _("Y Position") ); - m_grid->SetColLabelValue( 10, _("Visible") ); + m_grid->SetColLabelValue( 0, _("Count") ); + m_grid->SetColLabelValue( 1, _("Number") ); + m_grid->SetColLabelValue( 2, _("Name") ); + m_grid->SetColLabelValue( 3, _("Electrical Type") ); + m_grid->SetColLabelValue( 4, _("Graphic Style") ); + m_grid->SetColLabelValue( 5, _("Orientation") ); + m_grid->SetColLabelValue( 6, _("Number Text Size") ); + m_grid->SetColLabelValue( 7, _("Name Text Size") ); + m_grid->SetColLabelValue( 8, _("Length") ); + m_grid->SetColLabelValue( 9, _("X Position") ); + m_grid->SetColLabelValue( 10, _("Y Position") ); + m_grid->SetColLabelValue( 11, _("Visible") ); m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); // Rows diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp b/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp index a835551ad6..d06b0a4369 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp @@ -88,10 +88,10 @@ 1 wxALIGN_CENTER 24 - "Number" "Name" "Electrical Type" "Graphic Style" "Orientation" "Number Text Size" "Name Text Size" "Length" "X Position" "Y Position" "Visible" + "Count" "Number" "Name" "Electrical Type" "Graphic Style" "Orientation" "Number Text Size" "Name Text Size" "Length" "X Position" "Y Position" "Visible" wxALIGN_CENTER - 11 - 66,84,140,140,100,110,110,84,84,84,84 + 12 + 60,66,84,140,140,100,110,110,84,84,84,84 1 0 diff --git a/eeschema/symbol_editor/symbol_editor_settings.cpp b/eeschema/symbol_editor/symbol_editor_settings.cpp index 43937bc372..8ba63eb4c6 100644 --- a/eeschema/symbol_editor/symbol_editor_settings.cpp +++ b/eeschema/symbol_editor/symbol_editor_settings.cpp @@ -77,7 +77,7 @@ SYMBOL_EDITOR_SETTINGS::SYMBOL_EDITOR_SETTINGS() : &m_EditSymbolVisibleColumns, "0 1 2 3 4 5 6 7" ) ); m_params.emplace_back( new PARAM( "pin_table_visible_columns", - &m_PinTableVisibleColumns, "0 1 2 3 4 8 9" ) ); + &m_PinTableVisibleColumns, "0 1 2 3 4 5 9 10" ) ); m_params.emplace_back( new PARAM( "use_eeschema_color_settings", &m_UseEeschemaColorSettings, true ) );