ADDED allow pin conversion to be edited in Pin Table.

Added a De Morgan column.
This commit is contained in:
Jeff Young 2022-03-25 14:56:51 +00:00
parent 2681ad6cfc
commit e6c2b12ddf
5 changed files with 1149 additions and 1075 deletions

View File

@ -38,7 +38,10 @@
#include <wx/tokenzr.h>
#include <string_utils.h>
#define UNITS_ALL "ALL"
#define UNITS_ALL _( "ALL" )
#define DEMORGAN_ALL _( "ALL" )
#define DEMORGAN_STD _( "Standard" )
#define DEMORGAN_ALT _( "Alternate" )
class PIN_TABLE_DATA_MODEL : public wxGridTableBase
{
@ -85,6 +88,7 @@ public:
case COL_POSY: return _( "Y Position" );
case COL_VISIBLE: return _( "Visible" );
case COL_UNIT: return _( "Unit" );
case COL_DEMORGAN: return _( "De Morgan" );
default: wxFAIL; return wxEmptyString;
}
}
@ -112,7 +116,9 @@ public:
switch( aCol )
{
case COL_PIN_COUNT: val << pins.size(); break;
case COL_PIN_COUNT:
val << pins.size();
break;
case COL_NUMBER:
val = pin->GetNumber();
break;
@ -153,6 +159,20 @@ public:
else
val = UNITS_ALL;
break;
case COL_DEMORGAN:
switch( pin->GetConvert() )
{
case LIB_ITEM::LIB_CONVERT::BASE:
val = DEMORGAN_STD;
break;
case LIB_ITEM::LIB_CONVERT::DEMORGAN:
val = DEMORGAN_ALT;
break;
default:
val = DEMORGAN_ALL;
break;
}
break;
default:
wxFAIL;
break;
@ -234,7 +254,7 @@ public:
while( i < pins.size() )
{
auto pin = pins.back();
LIB_PIN* pin = pins.back();
m_pinTable->RemovePin( pin );
pins.pop_back();
}
@ -310,7 +330,7 @@ public:
}
else
{
for( auto i = 1; i <= pin->GetParent()->GetUnitCount(); i++ )
for( int i = 1; i <= pin->GetParent()->GetUnitCount(); i++ )
{
if( aValue == LIB_SYMBOL::SubReference( i, false ) )
{
@ -320,6 +340,16 @@ public:
}
}
break;
case COL_DEMORGAN:
if( aValue == DEMORGAN_STD )
pin->SetConvert( 1 );
else if( aValue == DEMORGAN_ALT )
pin->SetConvert( 2 );
else
pin->SetConvert( 0 );
break;
default:
wxFAIL;
break;
@ -382,6 +412,7 @@ public:
res = cmp( ValueFromString( units, lhStr ), ValueFromString( units, rhStr ) );
break;
case COL_VISIBLE:
case COL_DEMORGAN:
default:
res = cmp( StrNumCmp( lhStr, rhStr ), 0 );
break;
@ -396,7 +427,7 @@ public:
{
// Commit any pending in-place edits before the row gets moved out from under
// the editor.
if( auto grid = dynamic_cast<WX_GRID*>( GetView() ) )
if( WX_GRID* grid = dynamic_cast<WX_GRID*>( GetView() ) )
grid->CommitPendingChanges( true );
wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, m_rows.size() );
@ -554,7 +585,7 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent,
m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) );
// Show/hide columns according to the user's preference
auto cfg = parent->GetSettings();
SYMBOL_EDITOR_SETTINGS* cfg = parent->GetSettings();
m_columnsShown = cfg->m_PinTableVisibleColumns;
m_grid->ShowHideColumns( m_columnsShown );
@ -590,16 +621,22 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent,
attr = new wxGridCellAttr;
wxArrayString unitNames;
unitNames.push_back( _("ALL") );
unitNames.push_back( UNITS_ALL );
for( auto i = 1; i <= aSymbol->GetUnitCount(); i++ )
{
for( int 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;
wxArrayString demorganNames;
demorganNames.push_back( DEMORGAN_ALL );
demorganNames.push_back( DEMORGAN_STD );
demorganNames.push_back( DEMORGAN_ALT );
attr->SetEditor( new GRID_CELL_COMBOBOX( demorganNames ) );
m_grid->SetColAttr( COL_DEMORGAN, attr );
attr = new wxGridCellAttr;
attr->SetRenderer( new wxGridCellBoolRenderer() );
attr->SetEditor( new wxGridCellBoolEditor() );
@ -645,7 +682,7 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent,
DIALOG_LIB_EDIT_PIN_TABLE::~DIALOG_LIB_EDIT_PIN_TABLE()
{
auto cfg = m_editFrame->GetSettings();
SYMBOL_EDITOR_SETTINGS* cfg = m_editFrame->GetSettings();
cfg->m_PinTableVisibleColumns = m_grid->GetShownColumns().ToStdString();
// Disconnect Events
@ -660,7 +697,7 @@ DIALOG_LIB_EDIT_PIN_TABLE::~DIALOG_LIB_EDIT_PIN_TABLE()
// This is our copy of the pins. If they were transferred to the part on an OK, then
// m_pins will already be empty.
for( auto pin : m_pins )
for( LIB_PIN* pin : m_pins )
delete pin;
}
@ -674,13 +711,14 @@ 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_editFrame->GetShowDeMorgan() )
m_grid->ShowCol( COL_DEMORGAN );
else
m_grid->HideCol( COL_DEMORGAN );
if( m_cbGroup->GetValue() )
m_grid->ShowCol( COL_PIN_COUNT );
@ -801,7 +839,7 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnDeleteRow( wxCommandEvent& event )
LIB_PINS removedRow = m_dataModel->RemoveRow( curRow );
for( auto pin : removedRow )
for( LIB_PIN* pin : removedRow )
m_pins.erase( std::find( m_pins.begin(), m_pins.end(), pin ) );
curRow = std::min( curRow, m_grid->GetNumberRows() - 1 );
@ -890,7 +928,7 @@ void DIALOG_LIB_EDIT_PIN_TABLE::adjustGridColumns()
void DIALOG_LIB_EDIT_PIN_TABLE::OnSize( wxSizeEvent& event )
{
auto new_size = event.GetSize();
wxSize new_size = event.GetSize();
if( m_initialized && m_size != new_size )
{

View File

@ -41,6 +41,7 @@ enum COL_ORDER
COL_POSY,
COL_VISIBLE,
COL_UNIT,
COL_DEMORGAN,
COL_COUNT // keep as last
};

View File

@ -18,10 +18,47 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent
wxBoxSizer* top_sizer;
top_sizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizer7;
bSizer7 = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bPinNumbersSizer;
bPinNumbersSizer = new wxBoxSizer( wxHORIZONTAL );
m_staticTextPinNumbers = new wxStaticText( this, wxID_ANY, _("Pin numbers:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextPinNumbers->Wrap( -1 );
bPinNumbersSizer->Add( m_staticTextPinNumbers, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_pin_numbers_summary = new wxStaticText( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
m_pin_numbers_summary->Wrap( -1 );
bPinNumbersSizer->Add( m_pin_numbers_summary, 1, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
bSizer7->Add( bPinNumbersSizer, 1, wxEXPAND, 5 );
wxBoxSizer* bPinCountSizer;
bPinCountSizer = new wxBoxSizer( wxHORIZONTAL );
m_staticTextPinCount = new wxStaticText( this, wxID_ANY, _("Pin count:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextPinCount->Wrap( -1 );
bPinCountSizer->Add( m_staticTextPinCount, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 10 );
m_pin_count = new wxStaticText( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
m_pin_count->Wrap( -1 );
bPinCountSizer->Add( m_pin_count, 1, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
bSizer7->Add( bPinCountSizer, 0, wxRIGHT|wxLEFT, 10 );
top_sizer->Add( bSizer7, 0, wxEXPAND|wxTOP|wxLEFT, 10 );
wxBoxSizer* bSizer8;
bSizer8 = new wxBoxSizer( wxVERTICAL );
m_grid = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxSize( 800,400 ), 0 );
// Grid
m_grid->CreateGrid( 5, 13 );
m_grid->CreateGrid( 5, 14 );
m_grid->EnableEditing( true );
m_grid->EnableGridLines( true );
m_grid->EnableDragGridSize( false );
@ -57,6 +94,7 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent
m_grid->SetColLabelValue( 10, _("Y Position") );
m_grid->SetColLabelValue( 11, _("Visible") );
m_grid->SetColLabelValue( 12, _("Unit") );
m_grid->SetColLabelValue( 13, _("De Morgan") );
m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Rows
@ -70,7 +108,10 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent
m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
m_grid->SetMinSize( wxSize( 690,200 ) );
top_sizer->Add( m_grid, 1, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 15 );
bSizer8->Add( m_grid, 1, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 10 );
top_sizer->Add( bSizer8, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizer2;
bSizer2 = new wxBoxSizer( wxHORIZONTAL );
@ -99,34 +140,6 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent
wxBoxSizer* bSizer3;
bSizer3 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bPinNumbersSizer;
bPinNumbersSizer = new wxBoxSizer( wxHORIZONTAL );
m_staticTextPinNumbers = new wxStaticText( this, wxID_ANY, _("Pin numbers:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextPinNumbers->Wrap( -1 );
bPinNumbersSizer->Add( m_staticTextPinNumbers, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 10 );
m_pin_numbers_summary = new wxStaticText( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
m_pin_numbers_summary->Wrap( -1 );
bPinNumbersSizer->Add( m_pin_numbers_summary, 1, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
bSizer3->Add( bPinNumbersSizer, 1, wxEXPAND, 5 );
wxBoxSizer* bPinCountSizer;
bPinCountSizer = new wxBoxSizer( wxHORIZONTAL );
m_staticTextPinCount = new wxStaticText( this, wxID_ANY, _("Pin count:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextPinCount->Wrap( -1 );
bPinCountSizer->Add( m_staticTextPinCount, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 10 );
m_pin_count = new wxStaticText( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
m_pin_count->Wrap( -1 );
bPinCountSizer->Add( m_pin_count, 1, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
bSizer3->Add( bPinCountSizer, 1, wxEXPAND, 5 );
wxBoxSizer* bDuplicatePinSizer;
bDuplicatePinSizer = new wxBoxSizer( wxHORIZONTAL );
@ -139,7 +152,7 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent
bDuplicatePinSizer->Add( m_duplicate_pins, 1, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
bSizer3->Add( bDuplicatePinSizer, 1, wxBOTTOM|wxEXPAND, 5 );
bSizer3->Add( bDuplicatePinSizer, 1, wxEXPAND, 5 );
bSizer2->Add( bSizer3, 1, wxEXPAND, 5 );
@ -157,7 +170,7 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent
bSizer2->Add( m_Buttons, 0, wxEXPAND|wxALL, 5 );
top_sizer->Add( bSizer2, 0, wxLEFT|wxEXPAND, 5 );
top_sizer->Add( bSizer2, 0, wxLEFT|wxEXPAND, 10 );
this->SetSizer( top_sizer );

File diff suppressed because it is too large Load Diff

View File

@ -13,12 +13,14 @@
class WX_GRID;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/font.h>
#include <wx/sizer.h>
#include <wx/grid.h>
#include <wx/gdicmn.h>
#include <wx/bmpbuttn.h>
#include <wx/bitmap.h>
#include <wx/image.h>
@ -26,8 +28,6 @@ class WX_GRID;
#include <wx/button.h>
#include <wx/statline.h>
#include <wx/checkbox.h>
#include <wx/stattext.h>
#include <wx/sizer.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
@ -41,6 +41,10 @@ class DIALOG_LIB_EDIT_PIN_TABLE_BASE : public DIALOG_SHIM
private:
protected:
wxStaticText* m_staticTextPinNumbers;
wxStaticText* m_pin_numbers_summary;
wxStaticText* m_staticTextPinCount;
wxStaticText* m_pin_count;
WX_GRID* m_grid;
wxBitmapButton* m_addButton;
wxBitmapButton* m_deleteButton;
@ -48,10 +52,6 @@ class DIALOG_LIB_EDIT_PIN_TABLE_BASE : public DIALOG_SHIM
wxCheckBox* m_cbGroup;
wxBitmapButton* m_refreshButton;
wxStaticLine* m_staticline2;
wxStaticText* m_staticTextPinNumbers;
wxStaticText* m_pin_numbers_summary;
wxStaticText* m_staticTextPinCount;
wxStaticText* m_pin_count;
wxStaticText* m_staticTextDuplicatePins;
wxStaticText* m_duplicate_pins;
wxStdDialogButtonSizer* m_Buttons;