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
This commit is contained in:
Kevin Lannen 2021-04-21 22:50:14 -06:00 committed by Jeff Young
parent 08ca19f95d
commit 56794ab829
5 changed files with 50 additions and 25 deletions

View File

@ -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();
}

View File

@ -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
};

View File

@ -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

View File

@ -88,10 +88,10 @@
<property name="close_button">1</property>
<property name="col_label_horiz_alignment">wxALIGN_CENTER</property>
<property name="col_label_size">24</property>
<property name="col_label_values">&quot;Number&quot; &quot;Name&quot; &quot;Electrical Type&quot; &quot;Graphic Style&quot; &quot;Orientation&quot; &quot;Number Text Size&quot; &quot;Name Text Size&quot; &quot;Length&quot; &quot;X Position&quot; &quot;Y Position&quot; &quot;Visible&quot;</property>
<property name="col_label_values">&quot;Count&quot; &quot;Number&quot; &quot;Name&quot; &quot;Electrical Type&quot; &quot;Graphic Style&quot; &quot;Orientation&quot; &quot;Number Text Size&quot; &quot;Name Text Size&quot; &quot;Length&quot; &quot;X Position&quot; &quot;Y Position&quot; &quot;Visible&quot;</property>
<property name="col_label_vert_alignment">wxALIGN_CENTER</property>
<property name="cols">11</property>
<property name="column_sizes">66,84,140,140,100,110,110,84,84,84,84</property>
<property name="cols">12</property>
<property name="column_sizes">60,66,84,140,140,100,110,110,84,84,84,84</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>

View File

@ -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<wxString>( "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<bool>( "use_eeschema_color_settings",
&m_UseEeschemaColorSettings, true ) );