From 631d5155ef18c2c502559e3fc1bc97e3ba90dedd Mon Sep 17 00:00:00 2001 From: Kevin Lannen Date: Sun, 25 Apr 2021 11:41:20 -0600 Subject: [PATCH] Eeschema: Pin table support for multi unit symbols ADDED: Symbol editor pin table supports editing which unit each pin is displayed on Note: 6513 mentions being able to change the pin unit from the edit pin menu. This does not add that feature. Fixes: https://gitlab.com/kicad/code/kicad/-/issues/6513 Fixes: https://gitlab.com/kicad/code/kicad/-/issues/5470 --- .../dialogs/dialog_lib_edit_pin_table.cpp | 49 ++++++++++ eeschema/dialogs/dialog_lib_edit_pin_table.h | 1 + .../dialog_lib_edit_pin_table_base.cpp | 4 +- .../dialog_lib_edit_pin_table_base.fbp | 92 +++++++++---------- 4 files changed, 99 insertions(+), 47 deletions(-) diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp index b29166567d..1ad02998ad 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp @@ -31,10 +31,13 @@ #include #include #include +#include #include #include #include +#define UNITS_ALL "ALL" + class PIN_TABLE_DATA_MODEL : public wxGridTableBase { public: @@ -78,6 +81,7 @@ public: case COL_POSX: return _( "X Position" ); case COL_POSY: return _( "Y Position" ); case COL_VISIBLE: return _( "Visible" ); + case COL_UNIT: return _( "Unit" ); default: wxFAIL; return wxEmptyString; } } @@ -140,6 +144,12 @@ public: case COL_VISIBLE: val = StringFromBool( pin->IsVisible() ); break; + case COL_UNIT: + if( pin->GetUnit() ) + val = LIB_SYMBOL::SubReference( pin->GetUnit(), false ); + else + val = UNITS_ALL; + break; default: wxFAIL; break; @@ -225,6 +235,24 @@ public: case COL_VISIBLE: pin->SetVisible(BoolFromString( aValue )); break; + + case COL_UNIT: + if( aValue == UNITS_ALL ) + { + pin->SetUnit( 0 ); + } + else + { + for( auto i = 1; i <= pin->GetParent()->GetUnitCount(); i++ ) + { + if( aValue == LIB_SYMBOL::SubReference( i, false ) ) + { + pin->SetUnit( i ); + break; + } + } + } + break; default: wxFAIL; break; @@ -491,6 +519,18 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent, attr->SetEditor( new GRID_CELL_ICON_TEXT_POPUP( PinOrientationIcons(), orientationNames ) ); m_grid->SetColAttr( COL_ORIENTATION, attr ); + attr = new wxGridCellAttr; + wxArrayString unitNames; + unitNames.push_back( _("ALL") ); + + for( auto i = 1; i <= aSymbol->GetUnitCount(); i++ ) + { + unitNames.push_back( LIB_SYMBOL::SubReference( i, false ) ); + } + + attr->SetEditor( new GRID_CELL_COMBOBOX( unitNames ) ); + m_grid->SetColAttr( COL_UNIT, attr ); + attr = new wxGridCellAttr; attr->SetRenderer( new wxGridCellBoolRenderer() ); attr->SetEditor( new wxGridCellBoolEditor() ); @@ -564,6 +604,15 @@ bool DIALOG_LIB_EDIT_PIN_TABLE::TransferDataToWindow() m_dataModel->RebuildRows( m_pins, m_cbGroup->GetValue() ); + if( m_part->IsMulti() ) + { + m_grid->ShowCol( COL_UNIT ); + } + else + { + m_grid->HideCol( COL_UNIT ); + } + if( m_cbGroup->GetValue() ) m_grid->ShowCol( COL_PIN_COUNT ); else diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.h b/eeschema/dialogs/dialog_lib_edit_pin_table.h index 1b6329ddac..0f078d12a7 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.h +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.h @@ -40,6 +40,7 @@ enum COL_ORDER COL_POSX, COL_POSY, COL_VISIBLE, + COL_UNIT, 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 51bef20f50..deb38c700c 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp @@ -21,7 +21,7 @@ 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, 12 ); + m_grid->CreateGrid( 5, 13 ); m_grid->EnableEditing( true ); m_grid->EnableGridLines( true ); m_grid->EnableDragGridSize( false ); @@ -40,6 +40,7 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent m_grid->SetColSize( 9, 84 ); m_grid->SetColSize( 10, 84 ); m_grid->SetColSize( 11, 84 ); + m_grid->SetColSize( 12, 66 ); m_grid->EnableDragColMove( false ); m_grid->EnableDragColSize( true ); m_grid->SetColLabelSize( 24 ); @@ -55,6 +56,7 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent m_grid->SetColLabelValue( 9, _("X Position") ); m_grid->SetColLabelValue( 10, _("Y Position") ); m_grid->SetColLabelValue( 11, _("Visible") ); + m_grid->SetColLabelValue( 12, _("Unit") ); 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 d06b0a4369..663e55a571 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table_base.fbp @@ -55,16 +55,16 @@ OnClose OnUpdateUI - + top_sizer wxVERTICAL none - + 15 wxEXPAND|wxLEFT|wxRIGHT|wxTOP 1 - + 1 1 1 @@ -88,10 +88,10 @@ 1 wxALIGN_CENTER 24 - "Count" "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" "Unit" wxALIGN_CENTER - 12 - 60,66,84,140,140,100,110,110,84,84,84,84 + 13 + 60,66,84,140,140,100,110,110,84,84,84,84,66 1 0 @@ -150,20 +150,20 @@ OnSize - + 5 wxLEFT|wxEXPAND 0 - + bSizer2 wxHORIZONTAL none - + 5 wxALIGN_CENTER_VERTICAL|wxLEFT 0 - + 1 1 1 @@ -232,21 +232,21 @@ OnAddRow - + 5 wxEXPAND 0 - + 0 protected 20 - + 10 wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -315,11 +315,11 @@ OnDeleteRow - + 10 wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -373,11 +373,11 @@ - + 10 wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -438,11 +438,11 @@ OnRebuildRows - + 10 wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT 0 - + 1 1 1 @@ -511,11 +511,11 @@ OnRebuildRows - + 10 wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND 0 - + 1 1 1 @@ -569,29 +569,29 @@ - + 5 wxEXPAND 1 - + bSizer3 wxVERTICAL none - + 5 wxEXPAND 1 - + bPinNumbersSizer wxHORIZONTAL none - + 10 wxALIGN_CENTER_VERTICAL|wxLEFT 0 - + 1 1 1 @@ -648,11 +648,11 @@ -1 - + 5 wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 1 - + 1 1 1 @@ -711,20 +711,20 @@ - + 5 wxEXPAND 1 - + bPinCountSizer wxHORIZONTAL none - + 10 wxALIGN_CENTER_VERTICAL|wxLEFT 0 - + 1 1 1 @@ -781,11 +781,11 @@ -1 - + 5 wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 1 - + 1 1 1 @@ -844,20 +844,20 @@ - + 5 wxBOTTOM|wxEXPAND 1 - + bDuplicatePinSizer wxHORIZONTAL none - + 10 wxALIGN_CENTER_VERTICAL|wxLEFT 0 - + 1 1 1 @@ -914,11 +914,11 @@ -1 - + 5 wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 1 - + 1 1 1 @@ -979,21 +979,21 @@ - + 5 wxEXPAND 0 - + 0 protected 10 - + 5 wxEXPAND|wxALL 0 - + 0 1 0