Added visible column to pins table

Fixes https://gitlab.com/kicad/code/kicad/-/issues/6761
This commit is contained in:
Electro707 2021-01-14 21:03:51 +00:00 committed by Seth Hillbrand
parent 54cf67dad2
commit 1c42f95ab3
5 changed files with 50 additions and 7 deletions

View File

@ -59,6 +59,7 @@ public:
case COL_LENGTH: return _( "Length" ); case COL_LENGTH: return _( "Length" );
case COL_POSX: return _( "X Position" ); case COL_POSX: return _( "X Position" );
case COL_POSY: return _( "Y Position" ); case COL_POSY: return _( "Y Position" );
case COL_VISIBLE: return _( "Visible" );
default: wxFAIL; return wxEmptyString; default: wxFAIL; return wxEmptyString;
} }
} }
@ -117,6 +118,9 @@ public:
case COL_POSY: case COL_POSY:
val = StringFromValue( aUserUnits, pin->GetPosition().y ); val = StringFromValue( aUserUnits, pin->GetPosition().y );
break; break;
case COL_VISIBLE:
val = StringFromBool( pin->IsVisible() );
break;
default: default:
wxFAIL; wxFAIL;
break; break;
@ -197,7 +201,10 @@ public:
pin->SetPosition( wxPoint( pin->GetPosition().x, pin->SetPosition( wxPoint( pin->GetPosition().x,
ValueFromString( m_userUnits, aValue ) ) ); ValueFromString( m_userUnits, aValue ) ) );
break; break;
case COL_VISIBLE:
pin->SetVisible(BoolFromString( aValue ));
break;
default: default:
wxFAIL; wxFAIL;
break; break;
@ -260,6 +267,7 @@ public:
case COL_POSY: case COL_POSY:
res = cmp( ValueFromString( units, lhStr ), ValueFromString( units, rhStr ) ); res = cmp( ValueFromString( units, lhStr ), ValueFromString( units, rhStr ) );
break; break;
case COL_VISIBLE:
default: default:
res = cmp( StrNumCmp( lhStr, rhStr ), 0 ); res = cmp( StrNumCmp( lhStr, rhStr ), 0 );
break; break;
@ -379,6 +387,32 @@ private:
EDA_UNITS m_userUnits; EDA_UNITS m_userUnits;
bool m_edited; 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 ) ); orientationNames ) );
attr->SetEditor( new GRID_CELL_ICON_TEXT_POPUP( PinOrientationIcons(), orientationNames ) ); attr->SetEditor( new GRID_CELL_ICON_TEXT_POPUP( PinOrientationIcons(), orientationNames ) );
m_grid->SetColAttr( COL_ORIENTATION, attr ); 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+ /* Right-aligned position values look much better, but only MSW and GTK2+
* currently support righ-aligned textEditCtrls, so the text jumps on all * currently support righ-aligned textEditCtrls, so the text jumps on all

View File

@ -38,6 +38,7 @@ enum COL_ORDER
COL_LENGTH, COL_LENGTH,
COL_POSX, COL_POSX,
COL_POSY, COL_POSY,
COL_VISIBLE,
COL_COUNT // keep as last COL_COUNT // keep as last
}; };

View File

@ -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/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // 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 ); m_grid = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxSize( 800,400 ), 0 );
// Grid // Grid
m_grid->CreateGrid( 5, 10 ); m_grid->CreateGrid( 5, 11 );
m_grid->EnableEditing( true ); m_grid->EnableEditing( true );
m_grid->EnableGridLines( true ); m_grid->EnableGridLines( true );
m_grid->EnableDragGridSize( false ); 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( 7, 84 );
m_grid->SetColSize( 8, 84 ); m_grid->SetColSize( 8, 84 );
m_grid->SetColSize( 9, 84 ); m_grid->SetColSize( 9, 84 );
m_grid->SetColSize( 10, 84 );
m_grid->EnableDragColMove( false ); m_grid->EnableDragColMove( false );
m_grid->EnableDragColSize( true ); m_grid->EnableDragColSize( true );
m_grid->SetColLabelSize( 24 ); 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( 7, _("Length") );
m_grid->SetColLabelValue( 8, _("X Position") ); m_grid->SetColLabelValue( 8, _("X Position") );
m_grid->SetColLabelValue( 9, _("Y Position") ); m_grid->SetColLabelValue( 9, _("Y Position") );
m_grid->SetColLabelValue( 10, _("Visible") );
m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Rows // Rows

View File

@ -88,10 +88,10 @@
<property name="close_button">1</property> <property name="close_button">1</property>
<property name="col_label_horiz_alignment">wxALIGN_CENTER</property> <property name="col_label_horiz_alignment">wxALIGN_CENTER</property>
<property name="col_label_size">24</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;</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_vert_alignment">wxALIGN_CENTER</property> <property name="col_label_vert_alignment">wxALIGN_CENTER</property>
<property name="cols">10</property> <property name="cols">11</property>
<property name="column_sizes">66,84,140,140,100,110,110,84,84,84</property> <property name="column_sizes">66,84,140,140,100,110,110,84,84,84,84</property>
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>
<property name="default_pane">0</property> <property name="default_pane">0</property>

View File

@ -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/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!