From 1c42f95ab3500cc41bad30d92d310f12a9509819 Mon Sep 17 00:00:00 2001 From: Electro707 Date: Thu, 14 Jan 2021 21:03:51 +0000 Subject: [PATCH] Added visible column to pins table Fixes https://gitlab.com/kicad/code/kicad/-/issues/6761 --- .../dialogs/dialog_lib_edit_pin_table.cpp | 42 ++++++++++++++++++- eeschema/dialogs/dialog_lib_edit_pin_table.h | 1 + .../dialog_lib_edit_pin_table_base.cpp | 6 ++- .../dialog_lib_edit_pin_table_base.fbp | 6 +-- .../dialogs/dialog_lib_edit_pin_table_base.h | 2 +- 5 files changed, 50 insertions(+), 7 deletions(-) diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp index b544341b2d..ff7a01dad3 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp @@ -59,6 +59,7 @@ public: case COL_LENGTH: return _( "Length" ); case COL_POSX: return _( "X Position" ); case COL_POSY: return _( "Y Position" ); + case COL_VISIBLE: return _( "Visible" ); default: wxFAIL; return wxEmptyString; } } @@ -117,6 +118,9 @@ public: case COL_POSY: val = StringFromValue( aUserUnits, pin->GetPosition().y ); break; + case COL_VISIBLE: + val = StringFromBool( pin->IsVisible() ); + break; default: wxFAIL; break; @@ -197,7 +201,10 @@ public: pin->SetPosition( wxPoint( pin->GetPosition().x, ValueFromString( m_userUnits, aValue ) ) ); break; - + + case COL_VISIBLE: + pin->SetVisible(BoolFromString( aValue )); + break; default: wxFAIL; break; @@ -260,6 +267,7 @@ public: case COL_POSY: res = cmp( ValueFromString( units, lhStr ), ValueFromString( units, rhStr ) ); break; + case COL_VISIBLE: default: res = cmp( StrNumCmp( lhStr, rhStr ), 0 ); break; @@ -379,6 +387,32 @@ private: EDA_UNITS m_userUnits; bool m_edited; + + static wxString StringFromBool( bool aValue ) + { + if( aValue ) + return wxT( "1" ); + else + return wxT( "0" ); + } + + static bool BoolFromString( wxString aValue ) + { + if( aValue == "1" ) + { + return true; + } + else if( aValue == "0" ) + { + return false; + } + else + { + wxFAIL_MSG( wxString::Format( "string \"%s\" can't be converted to boolean " + "correctly, it will have been perceived as FALSE", aValue ) ); + return false; + } + } }; @@ -429,6 +463,12 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( SYMBOL_EDIT_FRAME* parent, orientationNames ) ); attr->SetEditor( new GRID_CELL_ICON_TEXT_POPUP( PinOrientationIcons(), orientationNames ) ); m_grid->SetColAttr( COL_ORIENTATION, attr ); + + attr = new wxGridCellAttr; + attr->SetRenderer( new wxGridCellBoolRenderer() ); + attr->SetEditor( new wxGridCellBoolEditor() ); + attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + m_grid->SetColAttr( COL_VISIBLE, attr ); /* Right-aligned position values look much better, but only MSW and GTK2+ * currently support righ-aligned textEditCtrls, so the text jumps on all diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.h b/eeschema/dialogs/dialog_lib_edit_pin_table.h index eb20cd05b1..4110d10178 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.h +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.h @@ -38,6 +38,7 @@ enum COL_ORDER COL_LENGTH, COL_POSX, COL_POSY, + COL_VISIBLE, 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 77defd2a15..b3dfa6129e 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version Dec 21 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -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, 10 ); + m_grid->CreateGrid( 5, 11 ); m_grid->EnableEditing( true ); m_grid->EnableGridLines( true ); m_grid->EnableDragGridSize( false ); @@ -38,6 +38,7 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent m_grid->SetColSize( 7, 84 ); m_grid->SetColSize( 8, 84 ); m_grid->SetColSize( 9, 84 ); + m_grid->SetColSize( 10, 84 ); m_grid->EnableDragColMove( false ); m_grid->EnableDragColSize( true ); m_grid->SetColLabelSize( 24 ); @@ -51,6 +52,7 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent m_grid->SetColLabelValue( 7, _("Length") ); m_grid->SetColLabelValue( 8, _("X Position") ); m_grid->SetColLabelValue( 9, _("Y Position") ); + m_grid->SetColLabelValue( 10, _("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 a4c6b7aee2..c5eb2ec105 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" + "Number" "Name" "Electrical Type" "Graphic Style" "Orientation" "Number Text Size" "Name Text Size" "Length" "X Position" "Y Position" "Visible" wxALIGN_CENTER - 10 - 66,84,140,140,100,110,110,84,84,84 + 11 + 66,84,140,140,100,110,110,84,84,84,84 1 0 diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table_base.h b/eeschema/dialogs/dialog_lib_edit_pin_table_base.h index 972f2605b2..4723905a64 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table_base.h +++ b/eeschema/dialogs/dialog_lib_edit_pin_table_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version Dec 21 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE!