ADDED alternate pin definitions and assignments.

Fixes https://gitlab.com/kicad/code/kicad/issues/2002
This commit is contained in:
Jeff Young 2020-08-21 16:54:24 +01:00
parent 7fc222db98
commit 97c34e2516
49 changed files with 2428 additions and 785 deletions

View File

@ -89,6 +89,8 @@ set( EESCHEMA_DLGS
dialogs/dialog_edit_sheet_pin.cpp dialogs/dialog_edit_sheet_pin.cpp
dialogs/dialog_sch_import_settings.cpp dialogs/dialog_sch_import_settings.cpp
dialogs/dialog_sch_import_settings_base.cpp dialogs/dialog_sch_import_settings_base.cpp
dialogs/dialog_sch_pin_table.cpp
dialogs/dialog_sch_pin_table_base.cpp
dialogs/dialog_sch_sheet_props.cpp dialogs/dialog_sch_sheet_props.cpp
dialogs/dialog_sch_sheet_props_base.cpp dialogs/dialog_sch_sheet_props_base.cpp
dialogs/dialog_schematic_find.cpp dialogs/dialog_schematic_find.cpp
@ -183,7 +185,6 @@ set( EESCHEMA_SRCS
netlist_object_list.cpp netlist_object_list.cpp
netlist_object.cpp netlist_object.cpp
pin_number.cpp pin_number.cpp
pin_shape.cpp
pin_type.cpp pin_type.cpp
plot_schematic_DXF.cpp plot_schematic_DXF.cpp
plot_schematic_HPGL.cpp plot_schematic_HPGL.cpp

View File

@ -232,9 +232,9 @@ protected:
/** /**
* Return the side that a pin is on. * Return the side that a pin is on.
*/ */
SIDE get_pin_side( LIB_PIN* aPin ) SIDE get_pin_side( SCH_PIN* aPin )
{ {
int pin_orient = aPin->PinDrawOrient( m_component->GetTransform() ); int pin_orient = aPin->GetLibPin()->PinDrawOrient( m_component->GetTransform() );
switch( pin_orient ) switch( pin_orient )
{ {
case PIN_RIGHT: return SIDE_LEFT; case PIN_RIGHT: return SIDE_LEFT;
@ -255,10 +255,7 @@ protected:
{ {
unsigned pin_count = 0; unsigned pin_count = 0;
std::vector<LIB_PIN*> pins; for( SCH_PIN* each_pin : m_component->GetPins() )
m_component->GetPins( pins );
for( LIB_PIN* each_pin : pins )
{ {
if( !each_pin->IsVisible() && !m_power_symbol ) if( !each_pin->IsVisible() && !m_power_symbol )
continue; continue;

View File

@ -468,14 +468,14 @@ void CONNECTION_GRAPH::updateItemConnectivity( const SCH_SHEET_PATH& aSheet,
{ {
SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item ); SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
// TODO(JE) right now this relies on GetSchPins() returning good SCH_PIN pointers // TODO(JE) right now this relies on GetPins() returning good SCH_PIN pointers
// that contain good LIB_PIN pointers. Since these get invalidated whenever the // that contain good LIB_PIN pointers. Since these get invalidated whenever the
// library component is refreshed, the current solution as of ed025972 is to just // library component is refreshed, the current solution as of ed025972 is to just
// rebuild the SCH_PIN list when the component is refreshed, and then re-run the // rebuild the SCH_PIN list when the component is refreshed, and then re-run the
// connectivity calculations. This is slow and should be improved before release. // connectivity calculations. This is slow and should be improved before release.
// See https://gitlab.com/kicad/code/kicad/issues/3784 // See https://gitlab.com/kicad/code/kicad/issues/3784
for( SCH_PIN* pin : component->GetSchPins( &aSheet ) ) for( SCH_PIN* pin : component->GetPins( &aSheet ) )
{ {
pin->InitializeConnection( aSheet, this ); pin->InitializeConnection( aSheet, this );

View File

@ -24,20 +24,11 @@
*/ */
#include <fctsys.h> #include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <kiway_express.h> #include <kiway_express.h>
#include <macros.h>
#include <eda_dde.h> #include <eda_dde.h>
#include <connection_graph.h> #include <connection_graph.h>
#include <sch_edit_frame.h>
#include <eeschema_settings.h>
#include <general.h>
#include <lib_item.h>
#include <lib_pin.h>
#include <sch_component.h> #include <sch_component.h>
#include <sch_sheet.h>
#include <sch_view.h>
#include <schematic.h> #include <schematic.h>
#include <reporter.h> #include <reporter.h>
#include <netlist_exporters/netlist_exporter_kicad.h> #include <netlist_exporters/netlist_exporter_kicad.h>
@ -57,7 +48,7 @@ SCH_ITEM* SCH_EDITOR_CONTROL::FindComponentAndItem( const wxString& aReference,
SCH_SHEET_PATH* sheetWithComponentFound = NULL; SCH_SHEET_PATH* sheetWithComponentFound = NULL;
SCH_COMPONENT* component = NULL; SCH_COMPONENT* component = NULL;
wxPoint pos; wxPoint pos;
LIB_PIN* pin = nullptr; SCH_PIN* pin = nullptr;
SCH_SHEET_LIST sheetList; SCH_SHEET_LIST sheetList;
SCH_ITEM* foundItem = nullptr; SCH_ITEM* foundItem = nullptr;
@ -72,28 +63,28 @@ SCH_ITEM* SCH_EDITOR_CONTROL::FindComponentAndItem( const wxString& aReference,
for( auto item : screen->Items().OfType( SCH_COMPONENT_T ) ) for( auto item : screen->Items().OfType( SCH_COMPONENT_T ) )
{ {
SCH_COMPONENT* pSch = static_cast<SCH_COMPONENT*>( item ); SCH_COMPONENT* candidate = static_cast<SCH_COMPONENT*>( item );
if( aReference.CmpNoCase( pSch->GetRef( &sheet ) ) == 0 ) if( aReference.CmpNoCase( candidate->GetRef( &sheet ) ) == 0 )
{ {
component = pSch; component = candidate;
sheetWithComponentFound = &sheet; sheetWithComponentFound = &sheet;
if( aSearchType == HIGHLIGHT_PIN ) if( aSearchType == HIGHLIGHT_PIN )
{ {
pos = pSch->GetPosition(); // temporary: will be changed if the pin is found. pos = component->GetPosition(); // temporary: will be changed if the pin is found.
pin = pSch->GetPin( aSearchText ); pin = component->GetPin( aSearchText );
if( pin ) if( pin )
{ {
pos += pin->GetPosition(); pos = pin->GetPosition();
foundItem = component; foundItem = component;
break; break;
} }
} }
else else
{ {
pos = pSch->GetPosition(); pos = component->GetPosition();
foundItem = component; foundItem = component;
break; break;
} }
@ -578,10 +569,10 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
break; break;
case MAIL_REANNOTATE: case MAIL_REANNOTATE:
{ //Reannotate the schematic as per the netlist. //Reannotate the schematic as per the netlist.
ReannotateFromPCBNew( this, payload ); ReannotateFromPCBNew( this, payload );
break; break;
}
default:; default:;
} }

View File

@ -108,7 +108,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
sbSizer4->Add( bButtonSize, 0, wxEXPAND|wxBOTTOM, 5 ); sbSizer4->Add( bButtonSize, 0, wxEXPAND|wxBOTTOM, 5 );
bSizerBasicPanel->Add( sbSizer4, 1, wxALL|wxEXPAND, 5 ); bSizerBasicPanel->Add( sbSizer4, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerMidBasicPanel; wxBoxSizer* bSizerMidBasicPanel;
bSizerMidBasicPanel = new wxBoxSizer( wxVERTICAL ); bSizerMidBasicPanel = new wxBoxSizer( wxVERTICAL );
@ -168,7 +168,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_AsConvertButt = new wxCheckBox( sbSizerSymbol->GetStaticBox(), wxID_ANY, _("Has alternate symbol (DeMorgan)"), wxDefaultPosition, wxDefaultSize, 0 ); m_AsConvertButt = new wxCheckBox( sbSizerSymbol->GetStaticBox(), wxID_ANY, _("Has alternate symbol (DeMorgan)"), wxDefaultPosition, wxDefaultSize, 0 );
m_AsConvertButt->SetToolTip( _("Check this option if the symbol has an alternate body style (De Morgan)") ); m_AsConvertButt->SetToolTip( _("Check this option if the symbol has an alternate body style (De Morgan)") );
sbSizerSymbol->Add( m_AsConvertButt, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); sbSizerSymbol->Add( m_AsConvertButt, 0, wxRIGHT|wxLEFT, 5 );
m_OptionPower = new wxCheckBox( sbSizerSymbol->GetStaticBox(), wxID_ANY, _("Define as power symbol"), wxDefaultPosition, wxDefaultSize, 0 ); m_OptionPower = new wxCheckBox( sbSizerSymbol->GetStaticBox(), wxID_ANY, _("Define as power symbol"), wxDefaultPosition, wxDefaultSize, 0 );
m_OptionPower->SetToolTip( _("Setting this option makes the symbol in question appear in the\n\"add power port\" dialog. It will lock the value text to protect it\nfrom editing in Eeschema. The symbol will not be included in\nthe BOM and cannot be assigned a footprint.") ); m_OptionPower->SetToolTip( _("Setting this option makes the symbol in question appear in the\n\"add power port\" dialog. It will lock the value text to protect it\nfrom editing in Eeschema. The symbol will not be included in\nthe BOM and cannot be assigned a footprint.") );
@ -205,13 +205,13 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
bSizerRightCol = new wxBoxSizer( wxVERTICAL ); bSizerRightCol = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* sbSizerPinTextOpts; wxStaticBoxSizer* sbSizerPinTextOpts;
sbSizerPinTextOpts = new wxStaticBoxSizer( new wxStaticBox( m_PanelBasic, wxID_ANY, _("Pin Texts Options:") ), wxVERTICAL ); sbSizerPinTextOpts = new wxStaticBoxSizer( new wxStaticBox( m_PanelBasic, wxID_ANY, _("Pin Text Options") ), wxVERTICAL );
m_ShowPinNumButt = new wxCheckBox( sbSizerPinTextOpts->GetStaticBox(), wxID_ANY, _("Show pin number"), wxDefaultPosition, wxDefaultSize, 0 ); m_ShowPinNumButt = new wxCheckBox( sbSizerPinTextOpts->GetStaticBox(), wxID_ANY, _("Show pin number"), wxDefaultPosition, wxDefaultSize, 0 );
m_ShowPinNumButt->SetValue(true); m_ShowPinNumButt->SetValue(true);
m_ShowPinNumButt->SetToolTip( _("Show or hide pin numbers") ); m_ShowPinNumButt->SetToolTip( _("Show or hide pin numbers") );
sbSizerPinTextOpts->Add( m_ShowPinNumButt, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); sbSizerPinTextOpts->Add( m_ShowPinNumButt, 0, wxRIGHT|wxLEFT, 5 );
m_ShowPinNameButt = new wxCheckBox( sbSizerPinTextOpts->GetStaticBox(), wxID_ANY, _("Show pin name"), wxDefaultPosition, wxDefaultSize, 0 ); m_ShowPinNameButt = new wxCheckBox( sbSizerPinTextOpts->GetStaticBox(), wxID_ANY, _("Show pin name"), wxDefaultPosition, wxDefaultSize, 0 );
m_ShowPinNameButt->SetValue(true); m_ShowPinNameButt->SetValue(true);
@ -226,7 +226,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_PinsNameInsideButt->SetValue(true); m_PinsNameInsideButt->SetValue(true);
m_PinsNameInsideButt->SetToolTip( _("Check this option to have pin names inside the body and pin number outside.\nIf not checked pins names and pins numbers are outside.") ); m_PinsNameInsideButt->SetToolTip( _("Check this option to have pin names inside the body and pin number outside.\nIf not checked pins names and pins numbers are outside.") );
sbSizerPinTextOpts->Add( m_PinsNameInsideButt, 0, wxALL, 5 ); sbSizerPinTextOpts->Add( m_PinsNameInsideButt, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerNameOffset; wxBoxSizer* bSizerNameOffset;
bSizerNameOffset = new wxBoxSizer( wxHORIZONTAL ); bSizerNameOffset = new wxBoxSizer( wxHORIZONTAL );
@ -235,7 +235,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_nameOffsetLabel->Wrap( -1 ); m_nameOffsetLabel->Wrap( -1 );
m_nameOffsetLabel->SetToolTip( _("Margin (in 0.001 inches) between a pin name position and the component body.\nA value from 10 to 40 is usually good.") ); m_nameOffsetLabel->SetToolTip( _("Margin (in 0.001 inches) between a pin name position and the component body.\nA value from 10 to 40 is usually good.") );
bSizerNameOffset->Add( m_nameOffsetLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 30 ); bSizerNameOffset->Add( m_nameOffsetLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 24 );
m_nameOffsetCtrl = new wxTextCtrl( sbSizerPinTextOpts->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_nameOffsetCtrl = new wxTextCtrl( sbSizerPinTextOpts->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerNameOffset->Add( m_nameOffsetCtrl, 1, wxLEFT|wxRIGHT, 5 ); bSizerNameOffset->Add( m_nameOffsetCtrl, 1, wxLEFT|wxRIGHT, 5 );
@ -245,10 +245,10 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
bSizerNameOffset->Add( m_nameOffsetUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); bSizerNameOffset->Add( m_nameOffsetUnits, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
sbSizerPinTextOpts->Add( bSizerNameOffset, 0, wxEXPAND, 5 ); sbSizerPinTextOpts->Add( bSizerNameOffset, 0, wxEXPAND|wxTOP, 3 );
sbSizerPinTextOpts->Add( 0, 0, 1, wxEXPAND, 5 ); sbSizerPinTextOpts->Add( 0, 0, 0, wxEXPAND, 5 );
bSizerRightCol->Add( sbSizerPinTextOpts, 1, wxEXPAND|wxALL, 5 ); bSizerRightCol->Add( sbSizerPinTextOpts, 1, wxEXPAND|wxALL, 5 );
@ -275,7 +275,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_staticTextFootprints->Wrap( -1 ); m_staticTextFootprints->Wrap( -1 );
m_staticTextFootprints->SetToolTip( _("A list of footprints names that can be used for this symbol.\nFootprints names can used wildcards like sm* to allow all footprints names starting by sm.") ); m_staticTextFootprints->SetToolTip( _("A list of footprints names that can be used for this symbol.\nFootprints names can used wildcards like sm* to allow all footprints names starting by sm.") );
bFpFilterLeftBoxSizer->Add( m_staticTextFootprints, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); bFpFilterLeftBoxSizer->Add( m_staticTextFootprints, 0, wxRIGHT|wxLEFT, 5 );
m_FootprintFilterListBox = new wxListBox( m_PanelFootprintFilter, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); m_FootprintFilterListBox = new wxListBox( m_PanelFootprintFilter, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
bFpFilterLeftBoxSizer->Add( m_FootprintFilterListBox, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); bFpFilterLeftBoxSizer->Add( m_FootprintFilterListBox, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );

View File

@ -187,7 +187,7 @@
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property> <property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="1"> <object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
@ -1165,7 +1165,7 @@
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property> <property name="flag">wxRIGHT|wxLEFT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxCheckBox" expanded="0"> <object class="wxCheckBox" expanded="0">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
@ -1508,7 +1508,7 @@
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="1"> <object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Pin Texts Options:</property> <property name="label">Pin Text Options</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">sbSizerPinTextOpts</property> <property name="name">sbSizerPinTextOpts</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
@ -1516,7 +1516,7 @@
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property> <property name="flag">wxRIGHT|wxLEFT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxCheckBox" expanded="0"> <object class="wxCheckBox" expanded="0">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
@ -1654,7 +1654,7 @@
</object> </object>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL</property> <property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxCheckBox" expanded="0"> <object class="wxCheckBox" expanded="0">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
@ -1717,8 +1717,8 @@
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">3</property>
<property name="flag">wxEXPAND</property> <property name="flag">wxEXPAND|wxTOP</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property> <property name="minimum_size"></property>
@ -1726,7 +1726,7 @@
<property name="orient">wxHORIZONTAL</property> <property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
<property name="border">30</property> <property name="border">24</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property> <property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxStaticText" expanded="0"> <object class="wxStaticText" expanded="0">
@ -1916,7 +1916,7 @@
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND</property> <property name="flag">wxEXPAND</property>
<property name="proportion">1</property> <property name="proportion">0</property>
<object class="spacer" expanded="0"> <object class="spacer" expanded="0">
<property name="height">0</property> <property name="height">0</property>
<property name="permission">protected</property> <property name="permission">protected</property>
@ -2003,7 +2003,7 @@
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property> <property name="flag">wxRIGHT|wxLEFT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxStaticText" expanded="1"> <object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>

View File

@ -39,6 +39,7 @@
#include <schematic.h> #include <schematic.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tool/actions.h> #include <tool/actions.h>
#include <dialog_sch_pin_table.h>
#ifdef KICAD_SPICE #ifdef KICAD_SPICE
#include <dialog_spice_model.h> #include <dialog_spice_model.h>
@ -301,6 +302,14 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnEditSpiceModel( wxCommandEvent& event
} }
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnEditPinTable( wxCommandEvent& event )
{
DIALOG_SCH_PIN_TABLE dialog( GetParent(), m_cmp );
dialog.ShowModal();
}
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCancelButtonClick( wxCommandEvent& event ) void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCancelButtonClick( wxCommandEvent& event )
{ {
// Running the Footprint Browser gums up the works and causes the automatic cancel // Running the Footprint Browser gums up the works and causes the automatic cancel

View File

@ -72,6 +72,7 @@ private:
void OnMoveDown( wxCommandEvent& event ) override; void OnMoveDown( wxCommandEvent& event ) override;
void OnBrowseLibrary( wxCommandEvent& event ) override; void OnBrowseLibrary( wxCommandEvent& event ) override;
void OnEditSpiceModel( wxCommandEvent& event ) override; void OnEditSpiceModel( wxCommandEvent& event ) override;
void OnEditPinTable( wxCommandEvent& event ) override;
void OnSizeGrid( wxSizeEvent& event ) override; void OnSizeGrid( wxSizeEvent& event ) override;
void OnGridCellChanging( wxGridEvent& event ); void OnGridCellChanging( wxGridEvent& event );
void OnUpdateUI( wxUpdateUIEvent& event ) override; void OnUpdateUI( wxUpdateUIEvent& event ) override;

View File

@ -209,9 +209,16 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE
wxBoxSizer* bSizerBottom; wxBoxSizer* bSizerBottom;
bSizerBottom = new wxBoxSizer( wxHORIZONTAL ); bSizerBottom = new wxBoxSizer( wxHORIZONTAL );
m_spiceFieldsButton = new wxButton( this, wxID_ANY, _("Edit Spice Model..."), wxDefaultPosition, wxDefaultSize, 0 ); m_spiceFieldsButton = new wxButton( this, wxID_ANY, _("Spice Model..."), wxDefaultPosition, wxDefaultSize, 0 );
m_spiceFieldsButton->SetMinSize( wxSize( 112,-1 ) );
bSizerBottom->Add( m_spiceFieldsButton, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 10 ); bSizerBottom->Add( m_spiceFieldsButton, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 10 );
m_pinTableButton = new wxButton( this, wxID_ANY, _("Pin Table..."), wxDefaultPosition, wxDefaultSize, 0 );
m_pinTableButton->SetMinSize( wxSize( 112,-1 ) );
bSizerBottom->Add( m_pinTableButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
bSizerBottom->Add( 10, 0, 1, wxEXPAND, 5 ); bSizerBottom->Add( 10, 0, 1, wxEXPAND, 5 );
@ -243,6 +250,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE
m_updateFieldValues->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::UpdateFieldsFromLibrary ), NULL, this ); m_updateFieldValues->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::UpdateFieldsFromLibrary ), NULL, this );
m_buttonBrowseLibrary->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnBrowseLibrary ), NULL, this ); m_buttonBrowseLibrary->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnBrowseLibrary ), NULL, this );
m_spiceFieldsButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnEditSpiceModel ), NULL, this ); m_spiceFieldsButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnEditSpiceModel ), NULL, this );
m_pinTableButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnEditPinTable ), NULL, this );
m_stdDialogButtonSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnCancelButtonClick ), NULL, this ); m_stdDialogButtonSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnCancelButtonClick ), NULL, this );
} }
@ -259,6 +267,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BAS
m_updateFieldValues->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::UpdateFieldsFromLibrary ), NULL, this ); m_updateFieldValues->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::UpdateFieldsFromLibrary ), NULL, this );
m_buttonBrowseLibrary->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnBrowseLibrary ), NULL, this ); m_buttonBrowseLibrary->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnBrowseLibrary ), NULL, this );
m_spiceFieldsButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnEditSpiceModel ), NULL, this ); m_spiceFieldsButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnEditSpiceModel ), NULL, this );
m_pinTableButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnEditPinTable ), NULL, this );
m_stdDialogButtonSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnCancelButtonClick ), NULL, this ); m_stdDialogButtonSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnCancelButtonClick ), NULL, this );
} }

View File

@ -1394,7 +1394,7 @@
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Edit Spice Model...</property> <property name="label">Spice Model...</property>
<property name="margins"></property> <property name="margins"></property>
<property name="markup">0</property> <property name="markup">0</property>
<property name="max_size"></property> <property name="max_size"></property>
@ -1402,7 +1402,7 @@
<property name="maximum_size"></property> <property name="maximum_size"></property>
<property name="min_size"></property> <property name="min_size"></property>
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size">112,-1</property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_spiceFieldsButton</property> <property name="name">m_spiceFieldsButton</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
@ -1430,6 +1430,79 @@
<event name="OnButtonClick">OnEditSpiceModel</event> <event name="OnButtonClick">OnEditSpiceModel</event>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Pin Table...</property>
<property name="margins"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">112,-1</property>
<property name="moveable">1</property>
<property name="name">m_pinTableButton</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnEditPinTable</event>
</object>
</object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND</property> <property name="flag">wxEXPAND</property>

View File

@ -63,6 +63,7 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE : public DIALOG_SHIM
wxRadioBox* m_rbMirror; wxRadioBox* m_rbMirror;
wxStaticLine* m_staticline1; wxStaticLine* m_staticline1;
wxButton* m_spiceFieldsButton; wxButton* m_spiceFieldsButton;
wxButton* m_pinTableButton;
wxStdDialogButtonSizer* m_stdDialogButtonSizer; wxStdDialogButtonSizer* m_stdDialogButtonSizer;
wxButton* m_stdDialogButtonSizerOK; wxButton* m_stdDialogButtonSizerOK;
wxButton* m_stdDialogButtonSizerCancel; wxButton* m_stdDialogButtonSizerCancel;
@ -78,6 +79,7 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE : public DIALOG_SHIM
virtual void UpdateFieldsFromLibrary( wxCommandEvent& event ) { event.Skip(); } virtual void UpdateFieldsFromLibrary( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBrowseLibrary( wxCommandEvent& event ) { event.Skip(); } virtual void OnBrowseLibrary( wxCommandEvent& event ) { event.Skip(); }
virtual void OnEditSpiceModel( wxCommandEvent& event ) { event.Skip(); } virtual void OnEditSpiceModel( wxCommandEvent& event ) { event.Skip(); }
virtual void OnEditPinTable( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnCancelButtonClick( wxCommandEvent& event ) { event.Skip(); }

View File

@ -25,30 +25,15 @@
#include "grid_tricks.h" #include "grid_tricks.h"
#include "lib_pin.h" #include "lib_pin.h"
#include "pin_number.h" #include "pin_number.h"
#include <base_units.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <confirm.h> #include <confirm.h>
#include <kicad_string.h>
#include <kiface_i.h>
#include <lib_edit_frame.h> #include <lib_edit_frame.h>
#include <libedit_settings.h> #include <libedit_settings.h>
#include <queue>
#include <widgets/grid_icon_text_helpers.h> #include <widgets/grid_icon_text_helpers.h>
#include <widgets/wx_grid.h> #include <widgets/wx_grid.h>
#include <wx/bmpcbox.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <settings/settings_manager.h> #include <settings/settings_manager.h>
static std::vector<BITMAP_DEF> g_typeIcons;
static wxArrayString g_typeNames;
static std::vector<BITMAP_DEF> g_shapeIcons;
static wxArrayString g_shapeNames;
static std::vector<BITMAP_DEF> g_orientationIcons;
static wxArrayString g_orientationNames;
class PIN_TABLE_DATA_MODEL : public wxGridTableBase class PIN_TABLE_DATA_MODEL : public wxGridTableBase
{ {
@ -117,14 +102,14 @@ public:
val = pin->GetName(); val = pin->GetName();
break; break;
case COL_TYPE: case COL_TYPE:
val = g_typeNames[static_cast<int>( pin->GetType() )]; val = PinTypeNames()[static_cast<int>( pin->GetType() )];
break; break;
case COL_SHAPE: case COL_SHAPE:
val = g_shapeNames[static_cast<int>( pin->GetShape() )]; val = PinShapeNames()[static_cast<int>( pin->GetShape() )];
break; break;
case COL_ORIENTATION: case COL_ORIENTATION:
if( LIB_PIN::GetOrientationIndex( pin->GetOrientation() ) >= 0 ) if( PinOrientationIndex( pin->GetOrientation() ) >= 0 )
val = g_orientationNames[ LIB_PIN::GetOrientationIndex( pin->GetOrientation() ) ]; val = PinOrientationNames()[ PinOrientationIndex( pin->GetOrientation() ) ];
break; break;
case COL_NUMBER_SIZE: case COL_NUMBER_SIZE:
val = StringFromValue( aUserUnits, pin->GetNumberTextSize(), true, true ); val = StringFromValue( aUserUnits, pin->GetNumberTextSize(), true, true );
@ -184,21 +169,20 @@ public:
break; break;
case COL_TYPE: case COL_TYPE:
if( g_typeNames.Index( aValue ) != wxNOT_FOUND ) if( PinTypeNames().Index( aValue ) != wxNOT_FOUND )
pin->SetType( (ELECTRICAL_PINTYPE) g_typeNames.Index( aValue ) ); pin->SetType( (ELECTRICAL_PINTYPE) PinTypeNames().Index( aValue ) );
break; break;
case COL_SHAPE: case COL_SHAPE:
if( g_shapeNames.Index( aValue ) != wxNOT_FOUND ) if( PinShapeNames().Index( aValue ) != wxNOT_FOUND )
pin->SetShape( (GRAPHIC_PINSHAPE) g_shapeNames.Index( aValue ) ); pin->SetShape( (GRAPHIC_PINSHAPE) PinShapeNames().Index( aValue ) );
break; break;
case COL_ORIENTATION: case COL_ORIENTATION:
if( g_orientationNames.Index( aValue ) != wxNOT_FOUND ) if( PinOrientationNames().Index( aValue ) != wxNOT_FOUND )
pin->SetOrientation( LIB_PIN::GetOrientationCode( pin->SetOrientation( PinOrientationCode( PinOrientationNames().Index( aValue ) ) );
g_orientationNames.Index( aValue ) ) );
break; break;
case COL_NUMBER_SIZE: case COL_NUMBER_SIZE:
@ -243,8 +227,8 @@ public:
return -1; return -1;
} }
static bool compare( static bool compare( const LIB_PINS& lhs, const LIB_PINS& rhs, int sortCol, bool ascending,
const LIB_PINS& lhs, const LIB_PINS& rhs, int sortCol, bool ascending, EDA_UNITS units ) EDA_UNITS units )
{ {
wxString lhStr = GetValue( lhs, sortCol, units ); wxString lhStr = GetValue( lhs, sortCol, units );
wxString rhStr = GetValue( rhs, sortCol, units ); wxString rhStr = GetValue( rhs, sortCol, units );
@ -262,12 +246,12 @@ public:
// N.B. To meet the iterator sort conditions, we cannot simply invert the truth // N.B. To meet the iterator sort conditions, we cannot simply invert the truth
// to get the opposite sort. i.e. ~(a<b) != (a>b) // to get the opposite sort. i.e. ~(a<b) != (a>b)
auto cmp = [ ascending ]( const auto a, const auto b ) auto cmp = [ ascending ]( const auto a, const auto b )
{ {
if( ascending ) if( ascending )
return a < b; return a < b;
else else
return b < a; return b < a;
}; };
switch( sortCol ) switch( sortCol )
{ {
@ -403,31 +387,6 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( LIB_EDIT_FRAME* parent, LI
m_editFrame( parent ), m_editFrame( parent ),
m_part( aPart ) m_part( aPart )
{ {
if( g_typeNames.empty())
{
for( unsigned i = 0; i < ELECTRICAL_PINTYPES_TOTAL; ++i )
g_typeIcons.push_back( ElectricalPinTypeGetBitmap( static_cast<ELECTRICAL_PINTYPE>( i ) ) );
for( unsigned i = 0; i < ELECTRICAL_PINTYPES_TOTAL; ++i )
g_typeNames.push_back( ElectricalPinTypeGetText( static_cast<ELECTRICAL_PINTYPE>( i ) ) );
g_typeNames.push_back( INDETERMINATE_STATE );
for( unsigned i = 0; i < GRAPHIC_PINSHAPES_TOTAL; ++i )
g_shapeIcons.push_back( PinShapeGetBitmap( static_cast<GRAPHIC_PINSHAPE>( i ) ) );
for( unsigned i = 0; i < GRAPHIC_PINSHAPES_TOTAL; ++i )
g_shapeNames.push_back( PinShapeGetText( static_cast<GRAPHIC_PINSHAPE>( i ) ) );
g_shapeNames.push_back( INDETERMINATE_STATE );
for( unsigned i = 0; i < LIB_PIN::GetOrientationNames().size(); ++i )
g_orientationIcons.push_back( LIB_PIN::GetOrientationSymbols()[ i ] );
g_orientationNames = LIB_PIN::GetOrientationNames();
g_orientationNames.push_back( INDETERMINATE_STATE );
}
m_dataModel = new PIN_TABLE_DATA_MODEL( GetUserUnits() ); m_dataModel = new PIN_TABLE_DATA_MODEL( GetUserUnits() );
// Save original columns widths so we can do proportional sizing. // Save original columns widths so we can do proportional sizing.
@ -450,18 +409,24 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( LIB_EDIT_FRAME* parent, LI
wxGridCellAttr* attr; wxGridCellAttr* attr;
attr = new wxGridCellAttr; attr = new wxGridCellAttr;
attr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( g_typeIcons, g_typeNames ) ); wxArrayString typeNames = PinTypeNames();
attr->SetEditor( new GRID_CELL_ICON_TEXT_POPUP( g_typeIcons, g_typeNames ) ); typeNames.push_back( INDETERMINATE_STATE );
attr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinTypeIcons(), typeNames ) );
attr->SetEditor( new GRID_CELL_ICON_TEXT_POPUP( PinTypeIcons(), typeNames ) );
m_grid->SetColAttr( COL_TYPE, attr ); m_grid->SetColAttr( COL_TYPE, attr );
attr = new wxGridCellAttr; attr = new wxGridCellAttr;
attr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( g_shapeIcons, g_shapeNames ) ); wxArrayString shapeNames = PinShapeNames();
attr->SetEditor( new GRID_CELL_ICON_TEXT_POPUP( g_shapeIcons, g_shapeNames ) ); shapeNames.push_back( INDETERMINATE_STATE );
attr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinShapeIcons(), shapeNames ) );
attr->SetEditor( new GRID_CELL_ICON_TEXT_POPUP( PinShapeIcons(), shapeNames ) );
m_grid->SetColAttr( COL_SHAPE, attr ); m_grid->SetColAttr( COL_SHAPE, attr );
attr = new wxGridCellAttr; attr = new wxGridCellAttr;
attr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( g_orientationIcons, g_orientationNames ) ); wxArrayString orientationNames = PinOrientationNames();
attr->SetEditor( new GRID_CELL_ICON_TEXT_POPUP( g_orientationIcons, g_orientationNames ) ); orientationNames.push_back( INDETERMINATE_STATE );
attr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinOrientationIcons(), orientationNames ) );
attr->SetEditor( new GRID_CELL_ICON_TEXT_POPUP( PinOrientationIcons(), orientationNames ) );
m_grid->SetColAttr( COL_ORIENTATION, attr ); m_grid->SetColAttr( COL_ORIENTATION, 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+

View File

@ -18,7 +18,7 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent
wxBoxSizer* top_sizer; wxBoxSizer* top_sizer;
top_sizer = new wxBoxSizer( wxVERTICAL ); top_sizer = new wxBoxSizer( wxVERTICAL );
m_grid = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 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, 10 );
@ -62,9 +62,9 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent
// Cell Defaults // Cell Defaults
m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
m_grid->SetMinSize( wxSize( 720,240 ) ); m_grid->SetMinSize( wxSize( 690,200 ) );
top_sizer->Add( m_grid, 1, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 10 ); top_sizer->Add( m_grid, 1, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 15 );
wxBoxSizer* bSizer2; wxBoxSizer* bSizer2;
bSizer2 = new wxBoxSizer( wxHORIZONTAL ); bSizer2 = new wxBoxSizer( wxHORIZONTAL );
@ -73,30 +73,33 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent
bSizer2->Add( m_addButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); bSizer2->Add( m_addButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
bSizer2->Add( 20, 0, 0, wxEXPAND, 5 ); bSizer2->Add( 20, 0, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
m_deleteButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_deleteButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
bSizer2->Add( m_deleteButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 10 ); bSizer2->Add( m_deleteButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 10 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
bSizer2->Add( m_staticline1, 0, wxEXPAND|wxALL, 5 ); bSizer2->Add( m_staticline1, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 );
m_cbGroup = new wxCheckBox( this, wxID_ANY, _("Group by name"), wxDefaultPosition, wxDefaultSize, 0 ); m_cbGroup = new wxCheckBox( this, wxID_ANY, _("Group by name"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer2->Add( m_cbGroup, 0, wxALIGN_CENTER_VERTICAL|wxALL, 10 ); bSizer2->Add( m_cbGroup, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 10 );
m_refreshButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_refreshButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
bSizer2->Add( m_refreshButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 10 ); bSizer2->Add( m_refreshButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 10 );
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL ); m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
bSizer2->Add( m_staticline2, 0, wxEXPAND | wxALL, 5 ); bSizer2->Add( m_staticline2, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 10 );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Pin numbers:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText1 = new wxStaticText( this, wxID_ANY, _("Pin numbers:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 ); m_staticText1->Wrap( -1 );
bSizer2->Add( m_staticText1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 10 ); bSizer2->Add( m_staticText1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 10 );
m_summary = new wxStaticText( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 ); m_summary = new wxStaticText( this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
m_summary->Wrap( -1 ); m_summary->Wrap( -1 );
bSizer2->Add( m_summary, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); bSizer2->Add( m_summary, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
bSizer2->Add( 10, 0, 0, wxEXPAND, 5 );
m_Buttons = new wxStdDialogButtonSizer(); m_Buttons = new wxStdDialogButtonSizer();
m_ButtonsOK = new wxButton( this, wxID_OK ); m_ButtonsOK = new wxButton( this, wxID_OK );
@ -105,10 +108,10 @@ DIALOG_LIB_EDIT_PIN_TABLE_BASE::DIALOG_LIB_EDIT_PIN_TABLE_BASE( wxWindow* parent
m_Buttons->AddButton( m_ButtonsCancel ); m_Buttons->AddButton( m_ButtonsCancel );
m_Buttons->Realize(); m_Buttons->Realize();
bSizer2->Add( m_Buttons, 0, wxEXPAND, 5 ); bSizer2->Add( m_Buttons, 0, wxEXPAND|wxALL, 5 );
top_sizer->Add( bSizer2, 0, wxEXPAND|wxLEFT, 5 ); top_sizer->Add( bSizer2, 0, wxLEFT|wxEXPAND, 5 );
this->SetSizer( top_sizer ); this->SetSizer( top_sizer );

View File

@ -61,7 +61,7 @@
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">10</property> <property name="border">15</property>
<property name="flag">wxEXPAND|wxLEFT|wxRIGHT|wxTOP</property> <property name="flag">wxEXPAND|wxLEFT|wxRIGHT|wxTOP</property>
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxGrid" expanded="1"> <object class="wxGrid" expanded="1">
@ -122,7 +122,7 @@
<property name="maximum_size"></property> <property name="maximum_size"></property>
<property name="min_size"></property> <property name="min_size"></property>
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size">720,240</property> <property name="minimum_size">690,200</property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_grid</property> <property name="name">m_grid</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
@ -139,7 +139,7 @@
<property name="row_sizes"></property> <property name="row_sizes"></property>
<property name="rows">5</property> <property name="rows">5</property>
<property name="show">1</property> <property name="show">1</property>
<property name="size"></property> <property name="size">800,400</property>
<property name="subclass">WX_GRID; widgets/wx_grid.h; forward_declare</property> <property name="subclass">WX_GRID; widgets/wx_grid.h; forward_declare</property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
@ -152,7 +152,7 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND|wxLEFT</property> <property name="flag">wxLEFT|wxEXPAND</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property> <property name="minimum_size"></property>
@ -202,7 +202,7 @@
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
<property name="min_size">22,22</property> <property name="min_size">-1,-1</property>
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size">-1,-1</property> <property name="minimum_size">-1,-1</property>
<property name="moveable">1</property> <property name="moveable">1</property>
@ -234,7 +234,7 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND</property> <property name="flag">wxEXPAND|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="spacer" expanded="1"> <object class="spacer" expanded="1">
<property name="height">0</property> <property name="height">0</property>
@ -316,8 +316,8 @@
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">10</property>
<property name="flag">wxEXPAND|wxALL</property> <property name="flag">wxALIGN_CENTER_VERTICAL|wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxStaticLine" expanded="1"> <object class="wxStaticLine" expanded="1">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
@ -375,7 +375,7 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">10</property> <property name="border">10</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property> <property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxCheckBox" expanded="1"> <object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
@ -512,8 +512,8 @@
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">10</property>
<property name="flag">wxEXPAND | wxALL</property> <property name="flag">wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxStaticLine" expanded="1"> <object class="wxStaticLine" expanded="1">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
@ -571,7 +571,7 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">10</property> <property name="border">10</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property> <property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxStaticText" expanded="1"> <object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
@ -632,7 +632,7 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property> <property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxStaticText" expanded="1"> <object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
@ -669,7 +669,7 @@
<property name="maximum_size"></property> <property name="maximum_size"></property>
<property name="min_size"></property> <property name="min_size"></property>
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size">-1,-1</property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_summary</property> <property name="name">m_summary</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
@ -695,6 +695,16 @@
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND</property> <property name="flag">wxEXPAND</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">10</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="1"> <object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property> <property name="Apply">0</property>
<property name="Cancel">1</property> <property name="Cancel">1</property>

View File

@ -32,6 +32,96 @@
#include <dialog_pin_properties.h> #include <dialog_pin_properties.h>
#include <confirm.h> #include <confirm.h>
#include <widgets/tab_traversal.h> #include <widgets/tab_traversal.h>
#include <widgets/wx_grid.h>
#include <grid_tricks.h>
#include <widgets/grid_icon_text_helpers.h>
class ALT_PIN_DATA_MODEL : public wxGridTableBase, public std::vector<LIB_PIN::ALT>
{
public:
ALT_PIN_DATA_MODEL( EDA_UNITS aUserUnits )
{
}
int GetNumberRows() override { return (int) size(); }
int GetNumberCols() override { return COL_COUNT; }
wxString GetColLabelValue( int aCol ) override
{
switch( aCol )
{
case COL_NAME: return _( "Alternate Pin Name" );
case COL_TYPE: return _( "Electrical Type" );
case COL_SHAPE: return _( "Graphic Style" );
default: wxFAIL; return wxEmptyString;
}
}
bool IsEmptyCell( int row, int col ) override
{
return false; // don't allow adjacent cell overflow, even if we are actually empty
}
wxString GetValue( int aRow, int aCol ) override
{
switch( aCol )
{
case COL_NAME: return at( aRow ).m_Name;
case COL_TYPE: return PinTypeNames()[static_cast<int>( at( aRow ).m_Type )];
case COL_SHAPE: return PinShapeNames()[static_cast<int>( at( aRow ).m_Shape )];
default: wxFAIL; return wxEmptyString;
}
}
void SetValue( int aRow, int aCol, const wxString &aValue ) override
{
switch( aCol )
{
case COL_NAME:
at( aRow ).m_Name = aValue;
break;
case COL_TYPE:
if( PinTypeNames().Index( aValue ) != wxNOT_FOUND )
at( aRow ).m_Type = (ELECTRICAL_PINTYPE) PinTypeNames().Index( aValue );
break;
case COL_SHAPE:
if( PinShapeNames().Index( aValue ) != wxNOT_FOUND )
at( aRow ).m_Shape = (GRAPHIC_PINSHAPE) PinShapeNames().Index( aValue );
break;
default:
wxFAIL;
break;
}
}
void AppendRow( const LIB_PIN::ALT& aAlt )
{
push_back( aAlt );
if ( GetView() )
{
wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
GetView()->ProcessTableMessage( msg );
}
}
void RemoveRow( int aRow )
{
erase( begin() + aRow );
if ( GetView() )
{
wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aRow, 1 );
GetView()->ProcessTableMessage( msg );
}
}
};
DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( LIB_EDIT_FRAME* parent, LIB_PIN* aPin ) : DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( LIB_EDIT_FRAME* parent, LIB_PIN* aPin ) :
DIALOG_PIN_PROPERTIES_BASE( parent ), DIALOG_PIN_PROPERTIES_BASE( parent ),
@ -41,7 +131,10 @@ DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( LIB_EDIT_FRAME* parent, LIB_PIN* a
m_posY( parent, m_posYLabel, m_posYCtrl, m_posYUnits, true ), m_posY( parent, m_posYLabel, m_posYCtrl, m_posYUnits, true ),
m_pinLength( parent, m_pinLengthLabel, m_pinLengthCtrl, m_pinLengthUnits, true ), m_pinLength( parent, m_pinLengthLabel, m_pinLengthCtrl, m_pinLengthUnits, true ),
m_nameSize( parent, m_nameSizeLabel, m_nameSizeCtrl, m_nameSizeUnits, true ), m_nameSize( parent, m_nameSizeLabel, m_nameSizeCtrl, m_nameSizeUnits, true ),
m_numberSize( parent, m_numberSizeLabel, m_numberSizeCtrl, m_numberSizeUnits, true ) m_numberSize( parent, m_numberSizeLabel, m_numberSizeCtrl, m_numberSizeUnits, true ),
m_delayedFocusRow( -1 ),
m_delayedFocusColumn( -1 ),
m_initialized( false )
{ {
// Creates a dummy pin to show on a panel, inside this dialog: // Creates a dummy pin to show on a panel, inside this dialog:
m_dummyPin = new LIB_PIN( *m_pin ); m_dummyPin = new LIB_PIN( *m_pin );
@ -49,11 +142,11 @@ DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( LIB_EDIT_FRAME* parent, LIB_PIN* a
COLOR4D bgColor = parent->GetRenderSettings()->GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ); COLOR4D bgColor = parent->GetRenderSettings()->GetLayerColor( LAYER_SCHEMATIC_BACKGROUND );
m_panelShowPin->SetBackgroundColour( bgColor.ToColour() ); m_panelShowPin->SetBackgroundColour( bgColor.ToColour() );
const wxArrayString& orientationNames = LIB_PIN::GetOrientationNames(); const wxArrayString& orientationNames = PinOrientationNames();
const BITMAP_DEF* orientationBitmaps = LIB_PIN::GetOrientationSymbols(); const std::vector<BITMAP_DEF>& orientationIcons = PinOrientationIcons();
for ( unsigned ii = 0; ii < orientationNames.GetCount(); ii++ ) for ( unsigned ii = 0; ii < orientationNames.GetCount(); ii++ )
m_choiceOrientation->Insert( orientationNames[ii], KiBitmap( orientationBitmaps[ii] ), ii ); m_choiceOrientation->Insert( orientationNames[ii], KiBitmap( orientationIcons[ii] ), ii );
// We can't set the tab order through wxWidgets due to shortcomings in their mnemonics // We can't set the tab order through wxWidgets due to shortcomings in their mnemonics
// implementation on MSW // implementation on MSW
@ -75,6 +168,37 @@ DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( LIB_EDIT_FRAME* parent, LIB_PIN* a
m_sdbSizerButtonsCancel m_sdbSizerButtonsCancel
}; };
// Default alternates turndow to whether or not alternates exist
m_alternatesTurndown->Collapse( m_pin->GetAlternates().size() == 0 );
m_alternatesDataModel = new ALT_PIN_DATA_MODEL( GetUserUnits() );
// Save original columns widths so we can do proportional sizing.
for( int i = 0; i < COL_COUNT; ++i )
m_originalColWidths[ i ] = m_alternatesGrid->GetColSize( i );
// Give a bit more room for combobox editors
m_alternatesGrid->SetDefaultRowSize( m_alternatesGrid->GetDefaultRowSize() + 4 );
m_alternatesGrid->SetTable( m_alternatesDataModel );
m_alternatesGrid->PushEventHandler( new GRID_TRICKS( m_alternatesGrid ) );
// Set special attributes
wxGridCellAttr* attr;
attr = new wxGridCellAttr;
attr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinTypeIcons(), PinTypeNames() ) );
attr->SetEditor( new GRID_CELL_ICON_TEXT_POPUP( PinTypeIcons(), PinTypeNames() ) );
m_alternatesGrid->SetColAttr( COL_TYPE, attr );
attr = new wxGridCellAttr;
attr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinShapeIcons(), PinShapeNames() ) );
attr->SetEditor( new GRID_CELL_ICON_TEXT_POPUP( PinShapeIcons(), PinShapeNames() ) );
m_alternatesGrid->SetColAttr( COL_SHAPE, attr );
m_addAlternate->SetBitmap( KiBitmap( small_plus_xpm ) );
m_deleteAlternate->SetBitmap( KiBitmap( trash_xpm ) );
m_sdbSizerButtonsOK->SetDefault(); m_sdbSizerButtonsOK->SetDefault();
SetInitialFocus( m_textPinName ); SetInitialFocus( m_textPinName );
@ -84,12 +208,21 @@ DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( LIB_EDIT_FRAME* parent, LIB_PIN* a
// On some window managers (Unity, XFCE) the dialog is not always raised, depending on // On some window managers (Unity, XFCE) the dialog is not always raised, depending on
// how it is is run. // how it is is run.
Raise(); Raise();
m_initialized = true;
m_width = 0;
} }
DIALOG_PIN_PROPERTIES::~DIALOG_PIN_PROPERTIES() DIALOG_PIN_PROPERTIES::~DIALOG_PIN_PROPERTIES()
{ {
delete m_dummyPin; delete m_dummyPin;
// Prevents crash bug in wxGrid's d'tor
m_alternatesGrid->DestroyTable( m_alternatesDataModel );
// Delete the GRID_TRICKS.
m_alternatesGrid->PopEventHandler( true );
} }
@ -100,7 +233,7 @@ bool DIALOG_PIN_PROPERTIES::TransferDataToWindow()
m_origPos = m_pin->GetPosition(); m_origPos = m_pin->GetPosition();
m_choiceOrientation->SetSelection( LIB_PIN::GetOrientationIndex( m_pin->GetOrientation() ) ); m_choiceOrientation->SetSelection( PinOrientationIndex( m_pin->GetOrientation() ) );
m_choiceStyle->SetSelection( m_pin->GetShape() ); m_choiceStyle->SetSelection( m_pin->GetShape() );
m_choiceElectricalType->SetSelection( m_pin->GetType() ); m_choiceElectricalType->SetSelection( m_pin->GetType() );
m_textPinName->SetValue( m_pin->GetName() ); m_textPinName->SetValue( m_pin->GetName() );
@ -116,12 +249,32 @@ bool DIALOG_PIN_PROPERTIES::TransferDataToWindow()
m_dummyPin->SetVisible( m_pin->IsVisible() ); m_dummyPin->SetVisible( m_pin->IsVisible() );
for( const std::pair<const wxString, LIB_PIN::ALT>& alt : m_pin->GetAlternates() )
m_alternatesDataModel->AppendRow( alt.second );
return true; return true;
} }
bool DIALOG_PIN_PROPERTIES::TransferDataFromWindow() bool DIALOG_PIN_PROPERTIES::TransferDataFromWindow()
{ {
if( !m_alternatesGrid->CommitPendingChanges() )
return false;
// Check for missing alternate names.
for( size_t i = 0; i < m_alternatesDataModel->size(); ++i )
{
if( m_alternatesDataModel->at( i ).m_Name.IsEmpty() )
{
DisplayErrorMessage( this, _( "Alternate pin definitions must have a name." ) );
m_delayedFocusColumn = COL_NAME;
m_delayedFocusRow = i;
return false;
}
}
if( !DIALOG_SHIM::TransferDataFromWindow() ) if( !DIALOG_SHIM::TransferDataFromWindow() )
return false; return false;
@ -145,7 +298,7 @@ bool DIALOG_PIN_PROPERTIES::TransferDataFromWindow()
m_pin->SetNumber( m_textPinNumber->GetValue() ); m_pin->SetNumber( m_textPinNumber->GetValue() );
m_pin->SetNameTextSize( m_nameSize.GetValue() ); m_pin->SetNameTextSize( m_nameSize.GetValue() );
m_pin->SetNumberTextSize( m_numberSize.GetValue() ); m_pin->SetNumberTextSize( m_numberSize.GetValue() );
m_pin->SetOrientation( LIB_PIN::GetOrientationCode( m_choiceOrientation->GetSelection() ) ); m_pin->SetOrientation( PinOrientationCode( m_choiceOrientation->GetSelection() ) );
m_pin->SetLength( m_pinLength.GetValue() ); m_pin->SetLength( m_pinLength.GetValue() );
m_pin->SetPosition( newPos ); m_pin->SetPosition( newPos );
m_pin->SetType( m_choiceElectricalType->GetPinTypeSelection() ); m_pin->SetType( m_choiceElectricalType->GetPinTypeSelection() );
@ -154,6 +307,12 @@ bool DIALOG_PIN_PROPERTIES::TransferDataFromWindow()
m_pin->SetUnit( m_checkApplyToAllParts->GetValue() ? 0 : m_frame->GetUnit() ); m_pin->SetUnit( m_checkApplyToAllParts->GetValue() ? 0 : m_frame->GetUnit() );
m_pin->SetVisible( m_checkShow->GetValue() ); m_pin->SetVisible( m_checkShow->GetValue() );
std::map<wxString, LIB_PIN::ALT>& alternates = m_pin->GetAlternates();
alternates.clear();
for( const LIB_PIN::ALT& alt : *m_alternatesDataModel )
alternates[ alt.m_Name ] = alt;
return true; return true;
} }
@ -204,7 +363,7 @@ void DIALOG_PIN_PROPERTIES::OnPropertiesChange( wxCommandEvent& event )
m_dummyPin->SetNumber( m_textPinNumber->GetValue() ); m_dummyPin->SetNumber( m_textPinNumber->GetValue() );
m_dummyPin->SetNameTextSize( m_nameSize.GetValue() ); m_dummyPin->SetNameTextSize( m_nameSize.GetValue() );
m_dummyPin->SetNumberTextSize( m_numberSize.GetValue() ); m_dummyPin->SetNumberTextSize( m_numberSize.GetValue() );
m_dummyPin->SetOrientation( LIB_PIN::GetOrientationCode( m_choiceOrientation->GetSelection() ) ); m_dummyPin->SetOrientation( PinOrientationCode( m_choiceOrientation->GetSelection() ) );
m_dummyPin->SetLength( m_pinLength.GetValue() ); m_dummyPin->SetLength( m_pinLength.GetValue() );
m_dummyPin->SetType( m_choiceElectricalType->GetPinTypeSelection() ); m_dummyPin->SetType( m_choiceElectricalType->GetPinTypeSelection() );
m_dummyPin->SetShape( m_choiceStyle->GetPinShapeSelection() ); m_dummyPin->SetShape( m_choiceStyle->GetPinShapeSelection() );
@ -212,3 +371,95 @@ void DIALOG_PIN_PROPERTIES::OnPropertiesChange( wxCommandEvent& event )
m_panelShowPin->Refresh(); m_panelShowPin->Refresh();
} }
void DIALOG_PIN_PROPERTIES::OnAddAlternate( wxCommandEvent& event )
{
if( !m_alternatesGrid->CommitPendingChanges() )
return;
LIB_PIN::ALT newAlt;
newAlt.m_Name = wxEmptyString;
newAlt.m_Type = m_pin->GetType();
newAlt.m_Shape = m_pin->GetShape();
m_alternatesDataModel->AppendRow( newAlt );
m_alternatesGrid->MakeCellVisible( m_alternatesGrid->GetNumberRows() - 1, 0 );
m_alternatesGrid->SetGridCursor( m_alternatesGrid->GetNumberRows() - 1, 0 );
m_alternatesGrid->EnableCellEditControl( true );
m_alternatesGrid->ShowCellEditControl();
}
void DIALOG_PIN_PROPERTIES::OnDeleteAlternate( wxCommandEvent& event )
{
if( !m_alternatesGrid->CommitPendingChanges() )
return;
if( m_alternatesDataModel->size() == 0 ) // empty table
return;
int curRow = m_alternatesGrid->GetGridCursorRow();
if( curRow < 0 )
return;
m_alternatesDataModel->RemoveRow( curRow );
curRow = std::max( 0, curRow - 1 );
m_alternatesGrid->MakeCellVisible( curRow, m_alternatesGrid->GetGridCursorCol() );
m_alternatesGrid->SetGridCursor( curRow, m_alternatesGrid->GetGridCursorCol() );
}
void DIALOG_PIN_PROPERTIES::adjustGridColumns( int aWidth )
{
m_width = aWidth;
// Account for margins
aWidth -= 30;
wxGridUpdateLocker deferRepaintsTillLeavingScope;
m_alternatesGrid->SetColSize( COL_TYPE, m_originalColWidths[ COL_TYPE ] );
m_alternatesGrid->SetColSize( COL_SHAPE, m_originalColWidths[ COL_SHAPE ] );
m_alternatesGrid->SetColSize( COL_NAME, aWidth - m_originalColWidths[ COL_TYPE ]
- m_originalColWidths[ COL_SHAPE ] );
}
void DIALOG_PIN_PROPERTIES::OnSize( wxSizeEvent& event )
{
auto new_size = event.GetSize().GetX();
if( m_initialized && m_width != new_size )
adjustGridColumns( new_size );
// Always propagate for a grid repaint (needed if the height changes, as well as width)
event.Skip();
}
void DIALOG_PIN_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
{
// Handle a delayed focus
if( m_delayedFocusRow >= 0 )
{
m_alternatesTurndown->Collapse( false );
m_alternatesGrid->SetFocus();
m_alternatesGrid->MakeCellVisible( m_delayedFocusRow, m_delayedFocusColumn );
m_alternatesGrid->SetGridCursor( m_delayedFocusRow, m_delayedFocusColumn );
m_alternatesGrid->EnableCellEditControl( true );
m_alternatesGrid->ShowCellEditControl();
m_delayedFocusRow = -1;
m_delayedFocusColumn = -1;
}
}

View File

@ -34,20 +34,43 @@
#include <lib_pin.h> #include <lib_pin.h>
#include <lib_edit_frame.h> #include <lib_edit_frame.h>
enum COL_ORDER
{
COL_NAME,
COL_TYPE,
COL_SHAPE,
COL_COUNT // keep as last
};
class ALT_PIN_DATA_MODEL;
/** Implementing DIALOG_LIB_EDIT_PIN_BASE */ /** Implementing DIALOG_LIB_EDIT_PIN_BASE */
class DIALOG_PIN_PROPERTIES : public DIALOG_PIN_PROPERTIES_BASE class DIALOG_PIN_PROPERTIES : public DIALOG_PIN_PROPERTIES_BASE
{ {
LIB_EDIT_FRAME* m_frame; LIB_EDIT_FRAME* m_frame;
LIB_PIN* m_pin; LIB_PIN* m_pin;
LIB_PIN* m_dummyPin; // a working copy used to show changes LIB_PIN* m_dummyPin; // a working copy used to show changes
UNIT_BINDER m_posX; UNIT_BINDER m_posX;
UNIT_BINDER m_posY; UNIT_BINDER m_posY;
UNIT_BINDER m_pinLength; UNIT_BINDER m_pinLength;
UNIT_BINDER m_nameSize; UNIT_BINDER m_nameSize;
UNIT_BINDER m_numberSize; UNIT_BINDER m_numberSize;
wxPoint m_origPos; wxPoint m_origPos;
ALT_PIN_DATA_MODEL* m_alternatesDataModel;
int m_delayedFocusRow;
int m_delayedFocusColumn;
int m_originalColWidths[ COL_COUNT ];
int m_width;
bool m_initialized;
public: public:
/** Constructor */ /** Constructor */
@ -59,6 +82,13 @@ public:
void OnPaintShowPanel( wxPaintEvent& event ) override; void OnPaintShowPanel( wxPaintEvent& event ) override;
void OnPropertiesChange( wxCommandEvent& event ) override; void OnPropertiesChange( wxCommandEvent& event ) override;
void OnAddAlternate( wxCommandEvent& event ) override;
void OnDeleteAlternate( wxCommandEvent& event ) override;
void OnSize( wxSizeEvent& event ) override;
void OnUpdateUI( wxUpdateUIEvent& event ) override;
protected:
void adjustGridColumns( int aWidth );
}; };
#endif // __dialog_lib_edit_pin__ #endif // __dialog_lib_edit_pin__

View File

@ -7,6 +7,7 @@
#include "pin_shape_combobox.h" #include "pin_shape_combobox.h"
#include "pin_type_combobox.h" #include "pin_type_combobox.h"
#include "widgets/wx_grid.h"
#include "wx/bmpcbox.h" #include "wx/bmpcbox.h"
#include "dialog_pin_properties_base.h" #include "dialog_pin_properties_base.h"
@ -133,7 +134,7 @@ DIALOG_PIN_PROPERTIES_BASE::DIALOG_PIN_PROPERTIES_BASE( wxWindow* parent, wxWind
bLeftSizer->Add( gbSizer1, 1, wxEXPAND, 5 ); bLeftSizer->Add( gbSizer1, 1, wxEXPAND, 5 );
bUpperSizer->Add( bLeftSizer, 1, wxEXPAND|wxALL, 5 ); bUpperSizer->Add( bLeftSizer, 1, wxEXPAND|wxALL, 10 );
wxBoxSizer* bRightSizer; wxBoxSizer* bRightSizer;
bRightSizer = new wxBoxSizer( wxVERTICAL ); bRightSizer = new wxBoxSizer( wxVERTICAL );
@ -155,7 +156,11 @@ DIALOG_PIN_PROPERTIES_BASE::DIALOG_PIN_PROPERTIES_BASE( wxWindow* parent, wxWind
checkboxesSizer->Add( m_checkShow, 0, wxBOTTOM, 3 ); checkboxesSizer->Add( m_checkShow, 0, wxBOTTOM, 3 );
bRightSizer->Add( checkboxesSizer, 0, wxEXPAND|wxALL, 5 ); bRightSizer->Add( checkboxesSizer, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_staticText16 = new wxStaticText( this, wxID_ANY, _("Preview:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText16->Wrap( -1 );
bRightSizer->Add( m_staticText16, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_panelShowPin = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL ); m_panelShowPin = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL );
m_panelShowPin->SetMinSize( wxSize( 150,150 ) ); m_panelShowPin->SetMinSize( wxSize( 150,150 ) );
@ -163,10 +168,77 @@ DIALOG_PIN_PROPERTIES_BASE::DIALOG_PIN_PROPERTIES_BASE( wxWindow* parent, wxWind
bRightSizer->Add( m_panelShowPin, 1, wxEXPAND|wxLEFT, 5 ); bRightSizer->Add( m_panelShowPin, 1, wxEXPAND|wxLEFT, 5 );
bUpperSizer->Add( bRightSizer, 1, wxEXPAND|wxALL, 5 ); bUpperSizer->Add( bRightSizer, 1, wxEXPAND|wxALL, 10 );
mainSizer->Add( bUpperSizer, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); mainSizer->Add( bUpperSizer, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
wxBoxSizer* bLowerSizer;
bLowerSizer = new wxBoxSizer( wxVERTICAL );
m_alternatesTurndown = new wxCollapsiblePane( this, wxID_ANY, _("Alternate pin definitions"), wxDefaultPosition, wxDefaultSize, wxCP_DEFAULT_STYLE );
m_alternatesTurndown->Collapse( true );
wxBoxSizer* bAlternatesSizer;
bAlternatesSizer = new wxBoxSizer( wxVERTICAL );
m_alternatesGrid = new WX_GRID( m_alternatesTurndown->GetPane(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_alternatesGrid->CreateGrid( 1, 3 );
m_alternatesGrid->EnableEditing( true );
m_alternatesGrid->EnableGridLines( true );
m_alternatesGrid->EnableDragGridSize( false );
m_alternatesGrid->SetMargins( 0, 0 );
// Columns
m_alternatesGrid->SetColSize( 0, 260 );
m_alternatesGrid->SetColSize( 1, 140 );
m_alternatesGrid->SetColSize( 2, 140 );
m_alternatesGrid->EnableDragColMove( false );
m_alternatesGrid->EnableDragColSize( false );
m_alternatesGrid->SetColLabelSize( 22 );
m_alternatesGrid->SetColLabelValue( 0, _("Alternate Pin Name") );
m_alternatesGrid->SetColLabelValue( 1, _("Electrical Type") );
m_alternatesGrid->SetColLabelValue( 2, _("Graphic Style") );
m_alternatesGrid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Rows
m_alternatesGrid->EnableDragRowSize( false );
m_alternatesGrid->SetRowLabelSize( 0 );
m_alternatesGrid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Label Appearance
// Cell Defaults
m_alternatesGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
m_alternatesGrid->SetMinSize( wxSize( -1,100 ) );
bAlternatesSizer->Add( m_alternatesGrid, 1, wxEXPAND|wxRIGHT, 5 );
wxBoxSizer* bButtonSizer;
bButtonSizer = new wxBoxSizer( wxHORIZONTAL );
m_addAlternate = new wxBitmapButton( m_alternatesTurndown->GetPane(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
bButtonSizer->Add( m_addAlternate, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
bButtonSizer->Add( 20, 0, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_deleteAlternate = new wxBitmapButton( m_alternatesTurndown->GetPane(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
bButtonSizer->Add( m_deleteAlternate, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
bAlternatesSizer->Add( bButtonSizer, 0, wxEXPAND|wxTOP, 5 );
m_alternatesTurndown->GetPane()->SetSizer( bAlternatesSizer );
m_alternatesTurndown->GetPane()->Layout();
bAlternatesSizer->Fit( m_alternatesTurndown->GetPane() );
bLowerSizer->Add( m_alternatesTurndown, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 );
mainSizer->Add( bLowerSizer, 1, wxEXPAND|wxLEFT, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
mainSizer->Add( m_staticline1, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 ); mainSizer->Add( m_staticline1, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 );
@ -188,6 +260,8 @@ DIALOG_PIN_PROPERTIES_BASE::DIALOG_PIN_PROPERTIES_BASE( wxWindow* parent, wxWind
this->Centre( wxBOTH ); this->Centre( wxBOTH );
// Connect Events // Connect Events
this->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnSize ) );
this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnUpdateUI ) );
m_textPinName->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); m_textPinName->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this );
m_textPinNumber->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); m_textPinNumber->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this );
m_pinLengthCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); m_pinLengthCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this );
@ -200,11 +274,15 @@ DIALOG_PIN_PROPERTIES_BASE::DIALOG_PIN_PROPERTIES_BASE( wxWindow* parent, wxWind
m_checkApplyToAllConversions->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); m_checkApplyToAllConversions->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this );
m_checkShow->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); m_checkShow->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this );
m_panelShowPin->Connect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPaintShowPanel ), NULL, this ); m_panelShowPin->Connect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPaintShowPanel ), NULL, this );
m_addAlternate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnAddAlternate ), NULL, this );
m_deleteAlternate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnDeleteAlternate ), NULL, this );
} }
DIALOG_PIN_PROPERTIES_BASE::~DIALOG_PIN_PROPERTIES_BASE() DIALOG_PIN_PROPERTIES_BASE::~DIALOG_PIN_PROPERTIES_BASE()
{ {
// Disconnect Events // Disconnect Events
this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnSize ) );
this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnUpdateUI ) );
m_textPinName->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); m_textPinName->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this );
m_textPinNumber->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); m_textPinNumber->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this );
m_pinLengthCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); m_pinLengthCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this );
@ -217,5 +295,7 @@ DIALOG_PIN_PROPERTIES_BASE::~DIALOG_PIN_PROPERTIES_BASE()
m_checkApplyToAllConversions->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); m_checkApplyToAllConversions->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this );
m_checkShow->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); m_checkShow->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this );
m_panelShowPin->Disconnect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPaintShowPanel ), NULL, this ); m_panelShowPin->Disconnect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPaintShowPanel ), NULL, this );
m_addAlternate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnAddAlternate ), NULL, this );
m_deleteAlternate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnDeleteAlternate ), NULL, this );
} }

View File

@ -53,6 +53,8 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnSize">OnSize</event>
<event name="OnUpdateUI">OnUpdateUI</event>
<object class="wxBoxSizer" expanded="1"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">mainSizer</property> <property name="name">mainSizer</property>
@ -61,26 +63,26 @@
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT</property> <property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT</property>
<property name="proportion">1</property> <property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">bUpperSizer</property> <property name="name">bUpperSizer</property>
<property name="orient">wxHORIZONTAL</property> <property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">10</property>
<property name="flag">wxEXPAND|wxALL</property> <property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1"> <object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">bLeftSizer</property> <property name="name">bLeftSizer</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="0">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND</property> <property name="flag">wxEXPAND</property>
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxGridBagSizer" expanded="1"> <object class="wxGridBagSizer" expanded="0">
<property name="empty_cell_size"></property> <property name="empty_cell_size"></property>
<property name="flexible_direction">wxBOTH</property> <property name="flexible_direction">wxBOTH</property>
<property name="growablecols">1</property> <property name="growablecols">1</property>
@ -1279,14 +1281,14 @@
<event name="OnCombobox">OnPropertiesChange</event> <event name="OnCombobox">OnPropertiesChange</event>
</object> </object>
</object> </object>
<object class="gbsizeritem" expanded="1"> <object class="gbsizeritem" expanded="0">
<property name="border">5</property> <property name="border">5</property>
<property name="colspan">1</property> <property name="colspan">1</property>
<property name="column">0</property> <property name="column">0</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property> <property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="row">6</property> <property name="row">6</property>
<property name="rowspan">1</property> <property name="rowspan">1</property>
<object class="wxStaticText" expanded="1"> <object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
<property name="LeftDockable">1</property> <property name="LeftDockable">1</property>
<property name="RightDockable">1</property> <property name="RightDockable">1</property>
@ -1343,14 +1345,14 @@
<property name="wrap">-1</property> <property name="wrap">-1</property>
</object> </object>
</object> </object>
<object class="gbsizeritem" expanded="1"> <object class="gbsizeritem" expanded="0">
<property name="border">5</property> <property name="border">5</property>
<property name="colspan">2</property> <property name="colspan">2</property>
<property name="column">1</property> <property name="column">1</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxEXPAND</property> <property name="flag">wxALIGN_CENTER_VERTICAL|wxEXPAND</property>
<property name="row">6</property> <property name="row">6</property>
<property name="rowspan">1</property> <property name="rowspan">1</property>
<object class="wxComboBox" expanded="1"> <object class="wxComboBox" expanded="0">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
<property name="LeftDockable">1</property> <property name="LeftDockable">1</property>
<property name="RightDockable">1</property> <property name="RightDockable">1</property>
@ -1737,7 +1739,7 @@
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">10</property>
<property name="flag">wxEXPAND|wxALL</property> <property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1"> <object class="wxBoxSizer" expanded="1">
@ -1747,7 +1749,7 @@
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property> <property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property> <property name="minimum_size"></property>
@ -1961,6 +1963,67 @@
</object> </object>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Preview:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText16</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND|wxLEFT</property> <property name="flag">wxEXPAND|wxLEFT</property>
@ -2023,6 +2086,342 @@
</object> </object>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bLowerSizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">10</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxCollapsiblePane" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="collapsed">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Alternate pin definitions</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_alternatesTurndown</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxCP_DEFAULT_STYLE</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bAlternatesSizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxRIGHT</property>
<property name="proportion">1</property>
<object class="wxGrid" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="autosize_cols">0</property>
<property name="autosize_rows">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="cell_bg"></property>
<property name="cell_font"></property>
<property name="cell_horiz_alignment">wxALIGN_LEFT</property>
<property name="cell_text"></property>
<property name="cell_vert_alignment">wxALIGN_TOP</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="col_label_horiz_alignment">wxALIGN_CENTER</property>
<property name="col_label_size">22</property>
<property name="col_label_values">&quot;Alternate Pin Name&quot; &quot;Electrical Type&quot; &quot;Graphic Style&quot;</property>
<property name="col_label_vert_alignment">wxALIGN_CENTER</property>
<property name="cols">3</property>
<property name="column_sizes">260,140,140</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_col_move">0</property>
<property name="drag_col_size">0</property>
<property name="drag_grid_size">0</property>
<property name="drag_row_size">0</property>
<property name="editing">1</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="grid_line_color"></property>
<property name="grid_lines">1</property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label_bg"></property>
<property name="label_font"></property>
<property name="label_text"></property>
<property name="margin_height">0</property>
<property name="margin_width">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">-1,100</property>
<property name="moveable">1</property>
<property name="name">m_alternatesGrid</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="row_label_horiz_alignment">wxALIGN_CENTER</property>
<property name="row_label_size">0</property>
<property name="row_label_values"></property>
<property name="row_label_vert_alignment">wxALIGN_CENTER</property>
<property name="row_sizes"></property>
<property name="rows">1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass">WX_GRID; widgets/wx_grid.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bButtonSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxBitmapButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Add Alternate</property>
<property name="margins"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_addAlternate</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnAddAlternate</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">20</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxBitmapButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Delete Alternate</property>
<property name="margins"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_deleteAlternate</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnDeleteAlternate</event>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND|wxLEFT|wxRIGHT</property> <property name="flag">wxEXPAND|wxLEFT|wxRIGHT</property>

View File

@ -12,6 +12,7 @@
#include <wx/intl.h> #include <wx/intl.h>
class PinShapeComboBox; class PinShapeComboBox;
class PinTypeComboBox; class PinTypeComboBox;
class WX_GRID;
class wxBitmapComboBox; class wxBitmapComboBox;
#include "dialog_shim.h" #include "dialog_shim.h"
@ -27,8 +28,14 @@ class wxBitmapComboBox;
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/panel.h> #include <wx/panel.h>
#include <wx/statline.h> #include <wx/grid.h>
#include <wx/bmpbuttn.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/collpane.h>
#include <wx/statline.h>
#include <wx/dialog.h> #include <wx/dialog.h>
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -69,15 +76,24 @@ class DIALOG_PIN_PROPERTIES_BASE : public DIALOG_SHIM
wxCheckBox* m_checkApplyToAllParts; wxCheckBox* m_checkApplyToAllParts;
wxCheckBox* m_checkApplyToAllConversions; wxCheckBox* m_checkApplyToAllConversions;
wxCheckBox* m_checkShow; wxCheckBox* m_checkShow;
wxStaticText* m_staticText16;
wxPanel* m_panelShowPin; wxPanel* m_panelShowPin;
wxCollapsiblePane* m_alternatesTurndown;
WX_GRID* m_alternatesGrid;
wxBitmapButton* m_addAlternate;
wxBitmapButton* m_deleteAlternate;
wxStaticLine* m_staticline1; wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizerButtons; wxStdDialogButtonSizer* m_sdbSizerButtons;
wxButton* m_sdbSizerButtonsOK; wxButton* m_sdbSizerButtonsOK;
wxButton* m_sdbSizerButtonsCancel; wxButton* m_sdbSizerButtonsCancel;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnSize( wxSizeEvent& event ) { event.Skip(); }
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnPropertiesChange( wxCommandEvent& event ) { event.Skip(); } virtual void OnPropertiesChange( wxCommandEvent& event ) { event.Skip(); }
virtual void OnPaintShowPanel( wxPaintEvent& event ) { event.Skip(); } virtual void OnPaintShowPanel( wxPaintEvent& event ) { event.Skip(); }
virtual void OnAddAlternate( wxCommandEvent& event ) { event.Skip(); }
virtual void OnDeleteAlternate( wxCommandEvent& event ) { event.Skip(); }
public: public:

View File

@ -0,0 +1,410 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "dialog_sch_pin_table.h"
#include <grid_tricks.h>
#include <pin_number.h>
#include <sch_edit_frame.h>
#include <confirm.h>
#include <lib_edit_frame.h>
#include <widgets/grid_icon_text_helpers.h>
#include <widgets/wx_grid.h>
#include <settings/settings_manager.h>
#include <widgets/grid_combobox.h>
class SCH_PIN_TABLE_DATA_MODEL : public wxGridTableBase, public std::vector<SCH_PIN>
{
protected:
std::vector<wxGridCellAttr*> m_nameAttrs;
wxGridCellAttr* m_typeAttr;
wxGridCellAttr* m_shapeAttr;
public:
SCH_PIN_TABLE_DATA_MODEL() :
m_typeAttr( nullptr ),
m_shapeAttr( nullptr )
{
}
~SCH_PIN_TABLE_DATA_MODEL()
{
for( wxGridCellAttr* attr : m_nameAttrs )
attr->DecRef();
m_typeAttr->DecRef();
m_shapeAttr->DecRef();
}
void BuildAttrs()
{
for( const SCH_PIN& pin : *this )
{
wxArrayString choices;
LIB_PIN* lib_pin = pin.GetLibPin();
choices.push_back( lib_pin->GetName() );
for( const std::pair<const wxString, LIB_PIN::ALT>& alt : lib_pin->GetAlternates() )
choices.push_back( alt.first );
wxGridCellAttr* attr = new wxGridCellAttr();
attr->SetEditor( new GRID_CELL_COMBOBOX( choices ) );
m_nameAttrs.push_back( attr );
}
m_typeAttr = new wxGridCellAttr;
m_typeAttr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinTypeIcons(), PinTypeNames() ) );
m_typeAttr->SetReadOnly( true );
m_shapeAttr = new wxGridCellAttr;
m_shapeAttr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinShapeIcons(), PinShapeNames() ) );
m_shapeAttr->SetReadOnly( true );
}
int GetNumberRows() override { return (int) size(); }
int GetNumberCols() override { return COL_COUNT; }
wxString GetColLabelValue( int aCol ) override
{
switch( aCol )
{
case COL_NUMBER: return _( "Number" );
case COL_NAME: return _( "Name" );
case COL_TYPE: return _( "Electrical Type" );
case COL_SHAPE: return _( "Graphic Style" );
default: wxFAIL; return wxEmptyString;
}
}
bool IsEmptyCell( int row, int col ) override
{
return false; // don't allow adjacent cell overflow, even if we are actually empty
}
wxString GetValue( int aRow, int aCol ) override
{
return GetValue( at( aRow ), aCol );
}
static wxString GetValue( const SCH_PIN& aPin, int aCol )
{
switch( aCol )
{
case COL_NUMBER: return aPin.GetNumber();
case COL_NAME: return aPin.GetName();
case COL_TYPE: return PinTypeNames()[static_cast<int>( aPin.GetType() )];
case COL_SHAPE: return PinShapeNames()[static_cast<int>( aPin.GetShape() )];
default: wxFAIL; return wxEmptyString;
}
}
wxGridCellAttr* GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind ) override
{
switch( aCol )
{
case COL_NAME:
m_nameAttrs[ aRow ]->IncRef();
return m_nameAttrs[ aRow ];
case COL_NUMBER:
return nullptr;
case COL_TYPE:
m_typeAttr->IncRef();
return m_typeAttr;
case COL_SHAPE:
m_shapeAttr->IncRef();
return m_shapeAttr;
default:
wxFAIL;
return nullptr;
}
}
void SetValue( int aRow, int aCol, const wxString &aValue ) override
{
switch( aCol )
{
case COL_NAME:
if( aValue == at( aRow ).GetName() )
at( aRow ).SetAlt( wxEmptyString );
else
at( aRow ).SetAlt( aValue );
break;
case COL_NUMBER:
case COL_TYPE:
case COL_SHAPE:
// Read-only.
break;
default:
wxFAIL;
break;
}
}
static bool compare( const SCH_PIN& lhs, const SCH_PIN& rhs, int sortCol, bool ascending )
{
wxString lhStr = GetValue( lhs, sortCol );
wxString rhStr = GetValue( rhs, sortCol );
if( lhStr == rhStr )
{
// Secondary sort key is always COL_NUMBER
sortCol = COL_NUMBER;
lhStr = GetValue( lhs, sortCol );
rhStr = GetValue( rhs, sortCol );
}
bool res;
// N.B. To meet the iterator sort conditions, we cannot simply invert the truth
// to get the opposite sort. i.e. ~(a<b) != (a>b)
auto cmp = [ ascending ]( const auto a, const auto b )
{
if( ascending )
return a < b;
else
return b < a;
};
switch( sortCol )
{
case COL_NUMBER:
case COL_NAME:
res = cmp( PinNumbers::Compare( lhStr, rhStr ), 0 );
break;
case COL_TYPE:
case COL_SHAPE:
res = cmp( lhStr.CmpNoCase( rhStr ), 0 );
break;
default:
res = cmp( StrNumCmp( lhStr, rhStr ), 0 );
break;
}
return res;
}
void SortRows( int aSortCol, bool ascending )
{
std::sort( begin(), end(),
[ aSortCol, ascending ]( const SCH_PIN& lhs, const SCH_PIN& rhs ) -> bool
{
return compare( lhs, rhs, aSortCol, ascending );
} );
}
};
DIALOG_SCH_PIN_TABLE::DIALOG_SCH_PIN_TABLE( SCH_EDIT_FRAME* parent, SCH_COMPONENT* aComp ) :
DIALOG_SCH_PIN_TABLE_BASE( parent ),
m_editFrame( parent ),
m_comp( aComp )
{
m_dataModel = new SCH_PIN_TABLE_DATA_MODEL();
// Make a copy of the pins for editing
for( const std::unique_ptr<SCH_PIN>& pin : m_comp->GetRawPins() )
m_dataModel->push_back( *pin );
m_dataModel->SortRows( COL_NUMBER, true );
m_dataModel->BuildAttrs();
// Save original columns widths so we can do proportional sizing.
for( int i = 0; i < COL_COUNT; ++i )
m_originalColWidths[ i ] = m_grid->GetColSize( i );
// Give a bit more room for combobox editors
m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
m_grid->SetTable( m_dataModel );
m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) );
GetSizer()->SetSizeHints(this);
Centre();
m_ButtonsOK->SetDefault();
m_initialized = true;
m_modified = false;
m_width = 0;
// Connect Events
m_grid->Connect( wxEVT_GRID_COL_SORT, wxGridEventHandler( DIALOG_SCH_PIN_TABLE::OnColSort ), nullptr, this );
}
DIALOG_SCH_PIN_TABLE::~DIALOG_SCH_PIN_TABLE()
{
// Disconnect Events
m_grid->Disconnect( wxEVT_GRID_COL_SORT, wxGridEventHandler( DIALOG_SCH_PIN_TABLE::OnColSort ), nullptr, this );
// Prevents crash bug in wxGrid's d'tor
m_grid->DestroyTable( m_dataModel );
// Delete the GRID_TRICKS.
m_grid->PopEventHandler( true );
}
bool DIALOG_SCH_PIN_TABLE::TransferDataToWindow()
{
return true;
}
bool DIALOG_SCH_PIN_TABLE::TransferDataFromWindow()
{
if( !m_grid->CommitPendingChanges() )
return false;
// Update any assignments
for( const SCH_PIN& model_pin : *m_dataModel )
{
// map from the edited copy back to the "real" pin in the component
SCH_PIN* src_pin = m_comp->GetPin( model_pin.GetLibPin() );
src_pin->SetAlt( model_pin.GetAlt() );
}
return true;
}
void DIALOG_SCH_PIN_TABLE::OnCellEdited( wxGridEvent& aEvent )
{
int row = aEvent.GetRow();
// These are just to get the cells refreshed
m_dataModel->SetValue( row, COL_TYPE, m_dataModel->GetValue( row, COL_TYPE ) );
m_dataModel->SetValue( row, COL_SHAPE, m_dataModel->GetValue( row, COL_SHAPE ) );
m_modified = true;
}
void DIALOG_SCH_PIN_TABLE::OnColSort( wxGridEvent& aEvent )
{
int sortCol = aEvent.GetCol();
bool ascending;
// This is bonkers, but wxWidgets doesn't tell us ascending/descending in the
// event, and if we ask it will give us pre-event info.
if( m_grid->IsSortingBy( sortCol ) )
// same column; invert ascending
ascending = !m_grid->IsSortOrderAscending();
else
// different column; start with ascending
ascending = true;
m_dataModel->SortRows( sortCol, ascending );
}
void DIALOG_SCH_PIN_TABLE::adjustGridColumns( int aWidth )
{
m_width = aWidth;
// Account for scroll bars
aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x );
wxGridUpdateLocker deferRepaintsTillLeavingScope;
// The Number and Name columns must be at least wide enough to hold their contents, but
// no less wide than their original widths.
m_grid->AutoSizeColumn( COL_NUMBER );
if( m_grid->GetColSize( COL_NUMBER ) < m_originalColWidths[ COL_NUMBER ] )
m_grid->SetColSize( COL_NUMBER, m_originalColWidths[ COL_NUMBER ] );
m_grid->AutoSizeColumn( COL_NAME );
if( m_grid->GetColSize( COL_NAME ) < m_originalColWidths[ COL_NAME ] )
m_grid->SetColSize( COL_NAME, m_originalColWidths[ COL_NAME ] );
// If the grid is still wider than the columns, then stretch the Number and Name columns
// to fit.
for( int i = 0; i < COL_COUNT; ++i )
aWidth -= m_grid->GetColSize( i );
if( aWidth > 0 )
{
m_grid->SetColSize( COL_NUMBER, m_grid->GetColSize( COL_NUMBER ) + aWidth / 2 );
m_grid->SetColSize( COL_NAME, m_grid->GetColSize( COL_NAME ) + aWidth / 2 );
}
}
void DIALOG_SCH_PIN_TABLE::OnSize( wxSizeEvent& event )
{
auto new_size = event.GetSize().GetX();
if( m_initialized && m_width != new_size )
{
adjustGridColumns( new_size );
}
// Always propagate for a grid repaint (needed if the height changes, as well as width)
event.Skip();
}
void DIALOG_SCH_PIN_TABLE::OnCancel( wxCommandEvent& event )
{
Close();
}
void DIALOG_SCH_PIN_TABLE::OnClose( wxCloseEvent& event )
{
// This is a cancel, so commit quietly as we're going to throw the results away anyway.
m_grid->CommitPendingChanges( true );
int retval = wxCANCEL;
if( m_modified && !HandleUnsavedChanges( this, _( "Save changes?" ),
[&]()->bool
{
if( TransferDataFromWindow() )
{
retval = wxOK;
return true;
}
return false;
} ) )
{
event.Veto();
return;
}
if( IsQuasiModal() )
EndQuasiModal( retval );
else
EndModal( retval );
}

View File

@ -0,0 +1,69 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "dialog_sch_pin_table_base.h"
#include <sch_pin.h>
enum COL_ORDER
{
COL_NUMBER,
COL_NAME,
COL_TYPE,
COL_SHAPE,
COL_COUNT // keep as last
};
class SCH_PIN_TABLE_DATA_MODEL;
class SCH_EDIT_FRAME;
class DIALOG_SCH_PIN_TABLE : public DIALOG_SCH_PIN_TABLE_BASE
{
public:
DIALOG_SCH_PIN_TABLE( SCH_EDIT_FRAME* parent, SCH_COMPONENT* aPart );
~DIALOG_SCH_PIN_TABLE() override;
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
void OnColSort( wxGridEvent& aEvent );
void OnCellEdited( wxGridEvent& event ) override;
void OnSize( wxSizeEvent& event ) override;
void OnCancel( wxCommandEvent& event ) override;
void OnClose( wxCloseEvent& event ) override;
protected:
void adjustGridColumns( int aWidth );
SCH_EDIT_FRAME* m_editFrame;
bool m_initialized = false;
int m_originalColWidths[ COL_COUNT ];
SCH_COMPONENT* m_comp;
int m_width;
SCH_PIN_TABLE_DATA_MODEL* m_dataModel;
bool m_modified; ///< true when there are unsaved changes
};

View File

@ -0,0 +1,94 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "widgets/wx_grid.h"
#include "dialog_sch_pin_table_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_SCH_PIN_TABLE_BASE::DIALOG_SCH_PIN_TABLE_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* top_sizer;
top_sizer = new wxBoxSizer( wxVERTICAL );
m_grid = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), 0 );
// Grid
m_grid->CreateGrid( 5, 4 );
m_grid->EnableEditing( true );
m_grid->EnableGridLines( true );
m_grid->EnableDragGridSize( false );
m_grid->SetMargins( 0, 0 );
// Columns
m_grid->SetColSize( 0, 84 );
m_grid->SetColSize( 1, 140 );
m_grid->SetColSize( 2, 140 );
m_grid->SetColSize( 3, 140 );
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->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Rows
m_grid->EnableDragRowSize( false );
m_grid->SetRowLabelSize( 0 );
m_grid->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
// Label Appearance
// Cell Defaults
m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
m_grid->SetMinSize( wxSize( 512,320 ) );
top_sizer->Add( m_grid, 1, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 15 );
m_Buttons = new wxStdDialogButtonSizer();
m_ButtonsOK = new wxButton( this, wxID_OK );
m_Buttons->AddButton( m_ButtonsOK );
m_ButtonsCancel = new wxButton( this, wxID_CANCEL );
m_Buttons->AddButton( m_ButtonsCancel );
m_Buttons->Realize();
top_sizer->Add( m_Buttons, 0, wxEXPAND|wxALL, 5 );
this->SetSizer( top_sizer );
this->Layout();
top_sizer->Fit( this );
this->Centre( wxBOTH );
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnClose ) );
m_grid->Connect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnCellEdited ), NULL, this );
m_grid->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnSize ), NULL, this );
m_ButtonsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnCancel ), NULL, this );
}
DIALOG_SCH_PIN_TABLE_BASE::~DIALOG_SCH_PIN_TABLE_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnClose ) );
m_grid->Disconnect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnCellEdited ), NULL, this );
m_grid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnSize ), NULL, this );
m_ButtonsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_PIN_TABLE_BASE::OnCancel ), NULL, this );
}

View File

@ -0,0 +1,174 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="15" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property>
<property name="disconnect_php_events">0</property>
<property name="disconnect_python_events">0</property>
<property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">connect</property>
<property name="file">dialog_sch_pin_table_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">dialog_sch_pin_table</property>
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="center">wxBOTH</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="event_handler">decl_pure_virtual</property>
<property name="extra_style"></property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">DIALOG_SCH_PIN_TABLE_BASE</property>
<property name="pos"></property>
<property name="size">-1,-1</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Pin Table</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnClose">OnClose</event>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">top_sizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">15</property>
<property name="flag">wxEXPAND|wxLEFT|wxRIGHT|wxTOP</property>
<property name="proportion">1</property>
<object class="wxGrid" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="autosize_cols">0</property>
<property name="autosize_rows">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="cell_bg"></property>
<property name="cell_font"></property>
<property name="cell_horiz_alignment">wxALIGN_LEFT</property>
<property name="cell_text"></property>
<property name="cell_vert_alignment">wxALIGN_TOP</property>
<property name="center_pane">0</property>
<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;</property>
<property name="col_label_vert_alignment">wxALIGN_CENTER</property>
<property name="cols">4</property>
<property name="column_sizes">84,140,140,140</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_col_move">0</property>
<property name="drag_col_size">1</property>
<property name="drag_grid_size">0</property>
<property name="drag_row_size">0</property>
<property name="editing">1</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="grid_line_color"></property>
<property name="grid_lines">1</property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label_bg"></property>
<property name="label_font"></property>
<property name="label_text"></property>
<property name="margin_height">0</property>
<property name="margin_width">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">512,320</property>
<property name="moveable">1</property>
<property name="name">m_grid</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="row_label_horiz_alignment">wxALIGN_CENTER</property>
<property name="row_label_size">0</property>
<property name="row_label_values"></property>
<property name="row_label_vert_alignment">wxALIGN_CENTER</property>
<property name="row_sizes"></property>
<property name="rows">5</property>
<property name="show">1</property>
<property name="size">-1,-1</property>
<property name="subclass">WX_GRID; widgets/wx_grid.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnGridCellChange">OnCellEdited</event>
<event name="OnSize">OnSize</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property>
<property name="Cancel">1</property>
<property name="ContextHelp">0</property>
<property name="Help">0</property>
<property name="No">0</property>
<property name="OK">1</property>
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size"></property>
<property name="name">m_Buttons</property>
<property name="permission">protected</property>
<event name="OnCancelButtonClick">OnCancel</event>
</object>
</object>
</object>
</object>
</object>
</wxFormBuilder_Project>

View File

@ -0,0 +1,55 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#pragma once
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class WX_GRID;
#include "dialog_shim.h"
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/font.h>
#include <wx/grid.h>
#include <wx/gdicmn.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_SCH_PIN_TABLE_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_SCH_PIN_TABLE_BASE : public DIALOG_SHIM
{
private:
protected:
WX_GRID* m_grid;
wxStdDialogButtonSizer* m_Buttons;
wxButton* m_ButtonsOK;
wxButton* m_ButtonsCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnClose( wxCloseEvent& event ) = 0;
virtual void OnCellEdited( wxGridEvent& event ) = 0;
virtual void OnSize( wxSizeEvent& event ) = 0;
virtual void OnCancel( wxCommandEvent& event ) = 0;
public:
DIALOG_SCH_PIN_TABLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Pin Table"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_SCH_PIN_TABLE_BASE();
};

View File

@ -544,7 +544,7 @@ int ERC_TESTER::TestNoConnectPins()
{ {
SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( item ); SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( item );
for( SCH_PIN* pin : comp->GetSchPins( &sheet ) ) for( SCH_PIN* pin : comp->GetPins( &sheet ) )
{ {
if( pin->GetLibPin()->GetType() == ELECTRICAL_PINTYPE::PT_NC ) if( pin->GetLibPin()->GetType() == ELECTRICAL_PINTYPE::PT_NC )
pinMap[pin->GetPosition()].emplace_back( pin ); pinMap[pin->GetPosition()].emplace_back( pin );

View File

@ -23,63 +23,23 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/**
* @file lib_pin.cpp
*/
#include <wx/tokenzr.h>
#include <fctsys.h> #include <fctsys.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <gr_basic.h>
#include <macros.h>
#include <trigo.h>
#include <sch_draw_panel.h> #include <sch_draw_panel.h>
#include <gr_text.h>
#include <plotter.h>
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <base_units.h> #include <base_units.h>
#include <msgpanel.h> #include <msgpanel.h>
#include <math/util.h> // for KiROUND
#include <general.h> #include <general.h>
#include <lib_edit_frame.h> #include <lib_edit_frame.h>
#include <class_libentry.h> #include <class_libentry.h>
#include <lib_pin.h> #include <lib_pin.h>
#include <transform.h>
#include <sch_component.h>
#include <sch_edit_frame.h> // For message panel debug info
#include <sch_sheet_path.h>
#include <settings/settings_manager.h> #include <settings/settings_manager.h>
#include <settings/color_settings.h>
#include <trace_helpers.h>
#include <libedit/libedit_settings.h> #include <libedit/libedit_settings.h>
#include <default_values.h>
#include "sch_painter.h" #include "sch_painter.h"
static const int pin_orientation_codes[] =
{
PIN_RIGHT,
PIN_LEFT,
PIN_UP,
PIN_DOWN
};
#define PIN_ORIENTATION_CNT arrayDim( pin_orientation_codes )
// small margin in internal units between the pin text and the pin line // small margin in internal units between the pin text and the pin line
#define PIN_TEXT_MARGIN 4 #define PIN_TEXT_MARGIN 4
// bitmaps to show pins orientations in dialog editor
// must have same order than pin_orientation_names
static const BITMAP_DEF iconsPinsOrientations[] =
{
pinorient_right_xpm,
pinorient_left_xpm,
pinorient_up_xpm,
pinorient_down_xpm,
};
const wxString LIB_PIN::GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType ) const wxString LIB_PIN::GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType )
{ {
// These strings are the canonical name of the electrictal type // These strings are the canonical name of the electrictal type
@ -105,31 +65,6 @@ const wxString LIB_PIN::GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType
} }
// Helper functions to get the pin orientation name from pin_orientation_codes
// Note: the strings are *not* static because they are translated and must be built
// on the fly, to be properly translated
static const wxString getPinOrientationName( unsigned aPinOrientationCode )
{
/* Note: The following name lists are sentence capitalized per the GNOME UI
* standards for list controls. Please do not change the capitalization
* of these strings unless the GNOME UI standards are changed.
*/
const wxString pin_orientation_names[] =
{
_( "Right" ),
_( "Left" ),
_( "Up" ),
_( "Down" ),
wxT( "???" )
};
if( aPinOrientationCode > PIN_ORIENTATION_CNT )
aPinOrientationCode = PIN_ORIENTATION_CNT;
return pin_orientation_names[ aPinOrientationCode ];
}
/// Utility for getting the size of the 'internal' pin decorators (as a radius) /// Utility for getting the size of the 'internal' pin decorators (as a radius)
// i.e. the clock symbols (falling clock is actually external but is of // i.e. the clock symbols (falling clock is actually external but is of
// the same kind) // the same kind)
@ -1040,7 +975,7 @@ void LIB_PIN::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
} }
void LIB_PIN::getMsgPanelInfoBase( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList ) void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList )
{ {
wxString text = m_number.IsEmpty() ? wxT( "?" ) : m_number; wxString text = m_number.IsEmpty() ? wxT( "?" ) : m_number;
@ -1060,16 +995,9 @@ void LIB_PIN::getMsgPanelInfoBase( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aLis
text = StringFromValue( aFrame->GetUserUnits(), m_length, true ); text = StringFromValue( aFrame->GetUserUnits(), m_length, true );
aList.push_back( MSG_PANEL_ITEM( _( "Length" ), text, MAGENTA ) ); aList.push_back( MSG_PANEL_ITEM( _( "Length" ), text, MAGENTA ) );
text = getPinOrientationName( (unsigned) GetOrientationIndex( m_orientation ) ); text = PinOrientationName( (unsigned) PinOrientationIndex( m_orientation ) );
aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), text, DARKMAGENTA ) ); aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), text, DARKMAGENTA ) );
}
void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList )
{
getMsgPanelInfoBase( aFrame, aList );
wxString text;
wxPoint pinpos = GetPosition(); wxPoint pinpos = GetPosition();
pinpos.y = -pinpos.y; // Display coord are top to bottom pinpos.y = -pinpos.y; // Display coord are top to bottom
// lib items coord are bottom to top // lib items coord are bottom to top
@ -1082,42 +1010,6 @@ void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList )
} }
void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList,
SCH_COMPONENT* aComponent )
{
getMsgPanelInfoBase( aFrame, aList );
if( !aComponent )
return;
wxString text;
wxPoint pinpos = aComponent->GetTransform().TransformCoordinate( GetPosition() )
+ aComponent->GetPosition();
text = MessageTextFromValue( aFrame->GetUserUnits(), pinpos.x, true );
aList.emplace_back( _( "Pos X" ), text, DARKMAGENTA );
text = MessageTextFromValue( aFrame->GetUserUnits(), pinpos.y, true );
aList.emplace_back( _( "Pos Y" ), text, DARKMAGENTA );
aList.emplace_back( aComponent->GetField( REFERENCE )->GetShownText(),
aComponent->GetField( VALUE )->GetShownText(), DARKCYAN );
#if defined(DEBUG)
SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( aFrame );
if( !frame )
return;
auto conn = aComponent->GetConnectionForPin( this, frame->GetCurrentSheet() );
if( conn )
conn->AppendInfoToMsgPanel( aList );
#endif
}
const EDA_RECT LIB_PIN::GetBoundingBox( bool aIncludeInvisibles, bool aPinOnly ) const const EDA_RECT LIB_PIN::GetBoundingBox( bool aIncludeInvisibles, bool aPinOnly ) const
{ {
EDA_RECT bbox; EDA_RECT bbox;
@ -1237,46 +1129,6 @@ const EDA_RECT LIB_PIN::GetBoundingBox( bool aIncludeInvisibles, bool aPinOnly )
} }
wxArrayString LIB_PIN::GetOrientationNames()
{
wxArrayString tmp;
for( unsigned ii = 0; ii < PIN_ORIENTATION_CNT; ii++ )
tmp.Add( getPinOrientationName( ii ) );
return tmp;
}
int LIB_PIN::GetOrientationCode( int index )
{
if( index >= 0 && index < (int) PIN_ORIENTATION_CNT )
return pin_orientation_codes[ index ];
return PIN_RIGHT;
}
int LIB_PIN::GetOrientationIndex( int code )
{
size_t i;
for( i = 0; i < PIN_ORIENTATION_CNT; i++ )
{
if( pin_orientation_codes[i] == code )
return (int) i;
}
return wxNOT_FOUND;
}
const BITMAP_DEF* LIB_PIN::GetOrientationSymbols()
{
return iconsPinsOrientations;
}
BITMAP_DEF LIB_PIN::GetMenuImage() const BITMAP_DEF LIB_PIN::GetMenuImage() const
{ {
return ElectricalPinTypeGetBitmap( m_type ); return ElectricalPinTypeGetBitmap( m_type );

View File

@ -31,10 +31,8 @@ class SCH_COMPONENT;
#include <eda_rect.h> #include <eda_rect.h>
#include <lib_item.h> #include <lib_item.h>
#include <pin_type.h>
#include "pin_shape.h" #include <class_libentry.h>
#include "pin_type.h"
#include "class_libentry.h"
/// The offset of the pin name string from the end of the pin in mils. /// The offset of the pin name string from the end of the pin in mils.
#define DEFAULT_PIN_NAME_OFFSET 40 #define DEFAULT_PIN_NAME_OFFSET 40
@ -59,17 +57,27 @@ enum DrawPinOrient {
class LIB_PIN : public LIB_ITEM class LIB_PIN : public LIB_ITEM
{ {
public:
struct ALT
{
wxString m_Name;
GRAPHIC_PINSHAPE m_Shape; // Shape drawn around pin
ELECTRICAL_PINTYPE m_Type; // Electrical type of the pin.
};
protected: protected:
wxPoint m_position; // Position of the pin. wxPoint m_position; // Position of the pin.
int m_length; // Length of the pin. int m_length; // Length of the pin.
int m_orientation; // Pin orientation (Up, Down, Left, Right) int m_orientation; // Pin orientation (Up, Down, Left, Right)
GRAPHIC_PINSHAPE m_shape; // Shape drawn around pin GRAPHIC_PINSHAPE m_shape; // Shape drawn around pin
ELECTRICAL_PINTYPE m_type; // Electrical type of the pin. ELECTRICAL_PINTYPE m_type; // Electrical type of the pin.
int m_attributes; // Set bit 0 to indicate pin is invisible. int m_attributes; // Set bit 0 to indicate pin is invisible.
wxString m_name; wxString m_name;
wxString m_number; wxString m_number;
int m_numTextSize; // Pin num and Pin name sizes int m_numTextSize; // Pin num and Pin name sizes
int m_nameTextSize; int m_nameTextSize;
std::map<wxString, ALT> m_alternates; // Map of alternate name to ALT structure
protected: protected:
/** /**
@ -96,38 +104,6 @@ protected:
int aOrientation ); int aOrientation );
public: public:
/**
* Get a list of pin orientation names.
*
* @return List of valid pin orientation names.
*/
static wxArrayString GetOrientationNames();
/**
* Get a list of pin orientation bitmaps for menus and dialogs.
*
* @return List of valid pin orientation bitmaps symbols in .xpm format
*/
static const BITMAP_DEF* GetOrientationSymbols();
/**
* Get the orientation code by index used to set the pin orientation.
*
* @param aIndex - The index of the orientation code to look up.
* @return Orientation code if index is valid. Returns right
* orientation on index error.
*/
static int GetOrientationCode( int aIndex );
/**
* Get the index of the orientation code.
*
* @param aCode - The orientation code to look up.
* @return The index of the orientation code if found. Otherwise,
* return wxNOT_FOUND.
*/
static int GetOrientationIndex( int aCode );
/** /**
* return a string giving the electrical type of a pin. * return a string giving the electrical type of a pin.
* Can be used when a known, not translated name is needed (for instance in net lists) * Can be used when a known, not translated name is needed (for instance in net lists)
@ -204,8 +180,10 @@ public:
int GetNumberTextSize() const { return m_numTextSize; } int GetNumberTextSize() const { return m_numTextSize; }
void SetNumberTextSize( int aSize ) { m_numTextSize = aSize; } void SetNumberTextSize( int aSize ) { m_numTextSize = aSize; }
const EDA_RECT GetBoundingBox( bool aIncludeInvisibles, bool aShowName, bool aShowNum, std::map<wxString, ALT>& GetAlternates() { return m_alternates; }
int aNameTextOffset ) const;
ALT GetAlt( const wxString& aAlt ) { return m_alternates[ aAlt ]; }
/** /**
* Print a pin, with or without the pin texts * Print a pin, with or without the pin texts
* *
@ -239,15 +217,6 @@ public:
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override; void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
/**
* Display pin info (given by GetMsgPanelInfo) and add some info related to aComponent
* (schematic pin position, and sheet path)
* @param aList is the message list to fill
* @param aComponent is the component which "owns" the pin
*/
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList,
SCH_COMPONENT* aComponent );
/* Cannot use a default parameter here as it will not be compatible with the virtual. */ /* Cannot use a default parameter here as it will not be compatible with the virtual. */
const EDA_RECT GetBoundingBox() const override { return GetBoundingBox( false ); } const EDA_RECT GetBoundingBox() const override { return GetBoundingBox( false ); }
@ -308,14 +277,6 @@ public:
void CalcEdit( const wxPoint& aPosition ) override; void CalcEdit( const wxPoint& aPosition ) override;
private: private:
/**
* Build the pin basic info to display in message panel.
* they are pin info without the actual pin position, which
* is not known in schematic without knowing the parent component
*/
void getMsgPanelInfoBase( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList );
/** /**
* @copydoc LIB_ITEM::compare() * @copydoc LIB_ITEM::compare()
* *

View File

@ -153,7 +153,7 @@ void NETLIST_EXPORTER::CreatePinList( SCH_COMPONENT* comp, SCH_SHEET_PATH* aShee
else // entry->GetUnitCount() <= 1 means one part per package else // entry->GetUnitCount() <= 1 means one part per package
{ {
for( const auto& pin : comp->GetSchPins( aSheetPath ) ) for( const auto& pin : comp->GetPins( aSheetPath ) )
{ {
if( auto conn = pin->Connection( *aSheetPath ) ) if( auto conn = pin->Connection( *aSheetPath ) )
{ {
@ -234,7 +234,7 @@ void NETLIST_EXPORTER::findAllUnitsOfComponent( SCH_COMPONENT* aComponent,
if( ref2.CmpNoCase( ref ) != 0 ) if( ref2.CmpNoCase( ref ) != 0 )
continue; continue;
for( const auto& pin : comp2->GetSchPins( aSheetPath ) ) for( const auto& pin : comp2->GetPins( aSheetPath ) )
{ {
if( auto conn = pin->Connection( *aSheetPath ) ) if( auto conn = pin->Connection( *aSheetPath ) )
{ {

View File

@ -1,75 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file pin_shape.cpp
* @brief Pin shape handling
*/
#include "pin_shape.h"
#include <macros.h>
struct pinShapeStruct
{
wxString name;
const BITMAP_OPAQUE* bitmap;
};
/*
* Conversion map between PLOT_DASH_TYPE values and style names displayed
*/
// clang-format off
const std::map<GRAPHIC_PINSHAPE, struct pinShapeStruct> pinShapes = {
{ GRAPHIC_PINSHAPE::LINE, { _( "Line" ), pinshape_normal_xpm } },
{ GRAPHIC_PINSHAPE::INVERTED, { _( "Inverted" ), pinshape_invert_xpm } },
{ GRAPHIC_PINSHAPE::CLOCK, { _( "Clock" ), pinshape_clock_normal_xpm } },
{ GRAPHIC_PINSHAPE::INVERTED_CLOCK, { _( "Inverted clock" ), pinshape_clock_invert_xpm } },
{ GRAPHIC_PINSHAPE::INPUT_LOW, { _( "Input low" ), pinshape_active_low_input_xpm } },
{ GRAPHIC_PINSHAPE::CLOCK_LOW, { _( "Clock low" ), pinshape_clock_active_low_xpm } },
{ GRAPHIC_PINSHAPE::OUTPUT_LOW, { _( "Output low" ), pinshape_active_low_output_xpm } },
{ GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK, { _( "Falling edge clock" ), pinshape_clock_fall_xpm } },
{ GRAPHIC_PINSHAPE::NONLOGIC, { _( "NonLogic" ), pinshape_nonlogic_xpm } },
};
// clang-format on
wxString PinShapeGetText( GRAPHIC_PINSHAPE aShape )
{
auto findIt = pinShapes.find( aShape );
wxCHECK_MSG( findIt != pinShapes.end(), wxT( "?" ), "Could not find pinshape in lookup map" );
return findIt->second.name;
}
BITMAP_DEF PinShapeGetBitmap( GRAPHIC_PINSHAPE aShape )
{
auto findIt = pinShapes.find( aShape );
wxCHECK_MSG( findIt != pinShapes.end(), nullptr, "Could not find pinshape in lookup map" );
return findIt->second.bitmap;
}

View File

@ -1,57 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file pin_shape.h
* @brief Pin shape handling
*/
#ifndef _PIN_SHAPE_H_
#define _PIN_SHAPE_H_
#include <wx/string.h>
#include <bitmaps.h>
enum class GRAPHIC_PINSHAPE
{
LINE,
INVERTED,
CLOCK,
INVERTED_CLOCK,
INPUT_LOW,
CLOCK_LOW,
OUTPUT_LOW,
FALLING_EDGE_CLOCK,
NONLOGIC,
LAST_OPTION = NONLOGIC ///< this is the sentinel value, must be set to last enum value
};
#define GRAPHIC_PINSHAPES_TOTAL ( static_cast<int>( GRAPHIC_PINSHAPE::LAST_OPTION ) + 1 )
// UI
wxString PinShapeGetText( GRAPHIC_PINSHAPE shape );
BITMAP_DEF PinShapeGetBitmap( GRAPHIC_PINSHAPE shape );
#endif

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2020 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -21,14 +21,21 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/** #include <pin_type.h>
* @file pin_type.cpp #include <lib_pin.h>
* @brief Electrical pin type handling #include <base_units.h>
*/
#include "pin_type.h"
#include <macros.h> // These are true singletons so it's OK for them to be globals.
static std::vector<BITMAP_DEF> g_typeIcons;
static wxArrayString g_typeNames;
static std::vector<BITMAP_DEF> g_shapeIcons;
static wxArrayString g_shapeNames;
static std::vector<BITMAP_DEF> g_orientationIcons;
static wxArrayString g_orientationNames;
struct pinTypeStruct struct pinTypeStruct
@ -56,6 +63,179 @@ const std::map<ELECTRICAL_PINTYPE, struct pinTypeStruct> pinTypes = {
}; };
// clang-format on // clang-format on
struct pinShapeStruct
{
wxString name;
const BITMAP_OPAQUE* bitmap;
};
/*
* Conversion map between PLOT_DASH_TYPE values and style names displayed
*/
// clang-format off
const std::map<GRAPHIC_PINSHAPE, struct pinShapeStruct> pinShapes = {
{ GRAPHIC_PINSHAPE::LINE, { _( "Line" ), pinshape_normal_xpm } },
{ GRAPHIC_PINSHAPE::INVERTED, { _( "Inverted" ), pinshape_invert_xpm } },
{ GRAPHIC_PINSHAPE::CLOCK, { _( "Clock" ), pinshape_clock_normal_xpm } },
{ GRAPHIC_PINSHAPE::INVERTED_CLOCK, { _( "Inverted clock" ), pinshape_clock_invert_xpm } },
{ GRAPHIC_PINSHAPE::INPUT_LOW, { _( "Input low" ), pinshape_active_low_input_xpm } },
{ GRAPHIC_PINSHAPE::CLOCK_LOW, { _( "Clock low" ), pinshape_clock_active_low_xpm } },
{ GRAPHIC_PINSHAPE::OUTPUT_LOW, { _( "Output low" ), pinshape_active_low_output_xpm } },
{ GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK, { _( "Falling edge clock" ), pinshape_clock_fall_xpm } },
{ GRAPHIC_PINSHAPE::NONLOGIC, { _( "NonLogic" ), pinshape_nonlogic_xpm } },
};
// clang-format on
static const int pin_orientation_codes[] =
{
PIN_RIGHT,
PIN_LEFT,
PIN_UP,
PIN_DOWN
};
// bitmaps to show pins orientations in dialog editor
// must have same order than pin_orientation_names
static const BITMAP_DEF iconsPinsOrientations[] =
{
pinorient_right_xpm,
pinorient_left_xpm,
pinorient_up_xpm,
pinorient_down_xpm,
};
#define PIN_ORIENTATION_CNT arrayDim( pin_orientation_codes )
// Helper functions to get the pin orientation name from pin_orientation_codes
// Note: the strings are *not* static because they are translated and must be built
// on the fly, to be properly translated
wxString PinOrientationName( unsigned aPinOrientationCode )
{
/* Note: The following name lists are sentence capitalized per the GNOME UI
* standards for list controls. Please do not change the capitalization
* of these strings unless the GNOME UI standards are changed.
*/
const wxString pin_orientation_names[] =
{
_( "Right" ),
_( "Left" ),
_( "Up" ),
_( "Down" ),
wxT( "???" )
};
if( aPinOrientationCode > PIN_ORIENTATION_CNT )
aPinOrientationCode = PIN_ORIENTATION_CNT;
return pin_orientation_names[ aPinOrientationCode ];
}
int PinOrientationCode( int index )
{
if( index >= 0 && index < (int) PIN_ORIENTATION_CNT )
return pin_orientation_codes[ index ];
return PIN_RIGHT;
}
int PinOrientationIndex( int code )
{
size_t i;
for( i = 0; i < PIN_ORIENTATION_CNT; i++ )
{
if( pin_orientation_codes[i] == code )
return (int) i;
}
return wxNOT_FOUND;
}
void InitTables()
{
for( unsigned i = 0; i < ELECTRICAL_PINTYPES_TOTAL; ++i )
{
g_typeIcons.push_back( ElectricalPinTypeGetBitmap( static_cast<ELECTRICAL_PINTYPE>( i ) ) );
g_typeNames.push_back( ElectricalPinTypeGetText( static_cast<ELECTRICAL_PINTYPE>( i ) ) );
}
for( unsigned i = 0; i < GRAPHIC_PINSHAPES_TOTAL; ++i )
{
g_shapeIcons.push_back( PinShapeGetBitmap( static_cast<GRAPHIC_PINSHAPE>( i ) ) );
g_shapeNames.push_back( PinShapeGetText( static_cast<GRAPHIC_PINSHAPE>( i ) ) );
}
for( unsigned i = 0; i < PIN_ORIENTATION_CNT; ++i )
{
g_orientationIcons.push_back( iconsPinsOrientations[ i ] );
g_orientationNames.push_back( PinOrientationName( i ) );
}
}
const wxArrayString& PinTypeNames()
{
if( g_typeNames.empty())
InitTables();
return g_typeNames;
}
const std::vector<BITMAP_DEF>& PinTypeIcons()
{
if( g_typeIcons.empty())
InitTables();
return g_typeIcons;
}
const wxArrayString& PinShapeNames()
{
if( g_shapeNames.empty())
InitTables();
return g_shapeNames;
}
const std::vector<BITMAP_DEF>& PinShapeIcons()
{
if( g_shapeIcons.empty())
InitTables();
return g_shapeIcons;
}
const wxArrayString& PinOrientationNames()
{
if( g_orientationNames.empty())
InitTables();
return g_orientationNames;
}
const std::vector<BITMAP_DEF>& PinOrientationIcons()
{
if( g_orientationIcons.empty())
InitTables();
return g_orientationIcons;
}
wxString ElectricalPinTypeGetText( ELECTRICAL_PINTYPE aType ) wxString ElectricalPinTypeGetText( ELECTRICAL_PINTYPE aType )
{ {
auto findIt = pinTypes.find( aType ); auto findIt = pinTypes.find( aType );
@ -74,3 +254,25 @@ BITMAP_DEF ElectricalPinTypeGetBitmap( ELECTRICAL_PINTYPE aType )
return findIt->second.bitmap; return findIt->second.bitmap;
} }
wxString PinShapeGetText( GRAPHIC_PINSHAPE aShape )
{
auto findIt = pinShapes.find( aShape );
wxCHECK_MSG( findIt != pinShapes.end(), wxT( "?" ), "Could not find pinshape in lookup map" );
return findIt->second.name;
}
BITMAP_DEF PinShapeGetBitmap( GRAPHIC_PINSHAPE aShape )
{
auto findIt = pinShapes.find( aShape );
wxCHECK_MSG( findIt != pinShapes.end(), nullptr, "Could not find pinshape in lookup map" );
return findIt->second.bitmap;
}

View File

@ -21,14 +21,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/**
* @file pin_type.h
* @brief Electrical pin type handling
*/
#ifndef PIN_TYPE_H_ #ifndef PIN_TYPE_H_
#define PIN_TYPE_H_ #define PIN_TYPE_H_
#include <wx/string.h> #include <wx/arrstr.h>
#include <bitmaps.h> #include <bitmaps.h>
/** /**
@ -53,8 +49,43 @@ enum class ELECTRICAL_PINTYPE
#define ELECTRICAL_PINTYPES_TOTAL ( static_cast<int>( ELECTRICAL_PINTYPE::PT_LAST_OPTION ) + 1 ) #define ELECTRICAL_PINTYPES_TOTAL ( static_cast<int>( ELECTRICAL_PINTYPE::PT_LAST_OPTION ) + 1 )
enum class GRAPHIC_PINSHAPE
{
LINE,
INVERTED,
CLOCK,
INVERTED_CLOCK,
INPUT_LOW,
CLOCK_LOW,
OUTPUT_LOW,
FALLING_EDGE_CLOCK,
NONLOGIC,
LAST_OPTION = NONLOGIC ///< this is the sentinel value, must be set to last enum value
};
#define GRAPHIC_PINSHAPES_TOTAL ( static_cast<int>( GRAPHIC_PINSHAPE::LAST_OPTION ) + 1 )
// UI // UI
wxString PinShapeGetText( GRAPHIC_PINSHAPE shape );
BITMAP_DEF PinShapeGetBitmap( GRAPHIC_PINSHAPE shape );
wxString ElectricalPinTypeGetText( ELECTRICAL_PINTYPE ); wxString ElectricalPinTypeGetText( ELECTRICAL_PINTYPE );
BITMAP_DEF ElectricalPinTypeGetBitmap( ELECTRICAL_PINTYPE ); BITMAP_DEF ElectricalPinTypeGetBitmap( ELECTRICAL_PINTYPE );
wxString PinOrientationName( unsigned aPinOrientationCode );
int PinOrientationCode( int index );
int PinOrientationIndex( int code );
const wxArrayString& PinTypeNames();
const std::vector<BITMAP_DEF>& PinTypeIcons();
const wxArrayString& PinShapeNames();
const std::vector<BITMAP_DEF>& PinShapeIcons();
const wxArrayString& PinOrientationNames();
const std::vector<BITMAP_DEF>& PinOrientationIcons();
#endif #endif

View File

@ -23,32 +23,16 @@
*/ */
#include <fctsys.h> #include <fctsys.h>
#include <gr_basic.h>
#include <kicad_string.h>
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <plotter.h>
#include <msgpanel.h> #include <msgpanel.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <general.h>
#include <lib_rectangle.h> #include <lib_rectangle.h>
#include <lib_pin.h> #include <lib_pin.h>
#include <lib_text.h> #include <lib_text.h>
#include <sch_component.h> #include <sch_component.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h> #include <sch_sheet_path.h>
#include <schematic.h> #include <schematic.h>
#include <netlist_object.h> #include <netlist_object.h>
#include <lib_item.h>
#include <dialogs/dialog_schematic_find.h>
#include <wx/tokenzr.h>
#include <iostream>
#include <cctype>
#include <eeschema_id.h> // for MAX_UNIT_COUNT_PER_PACKAGE definition
#include <trace_helpers.h> #include <trace_helpers.h>
@ -279,6 +263,14 @@ wxString SCH_COMPONENT::GetDatasheet() const
void SCH_COMPONENT::UpdatePins() void SCH_COMPONENT::UpdatePins()
{ {
std::map<wxString, wxString> altPinMap;
for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
{
if( !pin->GetAlt().IsEmpty() )
altPinMap[ pin->GetNumber() ] = pin->GetAlt();
}
m_pins.clear(); m_pins.clear();
m_pinMap.clear(); m_pinMap.clear();
@ -294,7 +286,13 @@ void SCH_COMPONENT::UpdatePins()
if( libPin->GetConvert() && m_convert && ( m_convert != libPin->GetConvert() ) ) if( libPin->GetConvert() && m_convert && ( m_convert != libPin->GetConvert() ) )
continue; continue;
m_pins.push_back( std::unique_ptr<SCH_PIN>( new SCH_PIN( libPin, this ) ) ); m_pins.push_back( std::make_unique<SCH_PIN>( libPin, this ) );
auto ii = altPinMap.find( libPin->GetNumber() );
if( ii != altPinMap.end() )
m_pins.back()->SetAlt( ii->second );
m_pinMap[ libPin ] = i; m_pinMap[ libPin ] = i;
++i; ++i;
@ -302,15 +300,6 @@ void SCH_COMPONENT::UpdatePins()
} }
SCH_CONNECTION* SCH_COMPONENT::GetConnectionForPin( LIB_PIN* aPin, const SCH_SHEET_PATH& aSheet )
{
if( m_pinMap.count( aPin ) )
return m_pins[ m_pinMap[aPin] ]->Connection( aSheet );
return nullptr;
}
void SCH_COMPONENT::SetUnit( int aUnit ) void SCH_COMPONENT::SetUnit( int aUnit )
{ {
if( m_unit != aUnit ) if( m_unit != aUnit )
@ -702,31 +691,39 @@ void SCH_COMPONENT::UpdateFields( bool aResetStyle, bool aResetRef )
} }
LIB_PIN* SCH_COMPONENT::GetPin( const wxString& number ) SCH_PIN* SCH_COMPONENT::GetPin( const wxString& aNumber )
{ {
if( m_part ) for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
{ {
return m_part->GetPin( number, m_unit, m_convert ); if( pin->GetNumber() == aNumber )
return pin.get();
} }
return NULL; return nullptr;
} }
void SCH_COMPONENT::GetPins( std::vector<LIB_PIN*>& aPinsList ) void SCH_COMPONENT::GetLibPins( std::vector<LIB_PIN*>& aPinsList )
{ {
if( m_part ) if( m_part )
m_part->GetPins( aPinsList, m_unit, m_convert ); m_part->GetPins( aPinsList, m_unit, m_convert );
} }
SCH_PIN_PTRS SCH_COMPONENT::GetSchPins( const SCH_SHEET_PATH* aSheet ) const SCH_PIN* SCH_COMPONENT::GetPin( LIB_PIN* aLibPin )
{ {
SCH_PIN_PTRS ptrs; wxASSERT( m_pinMap.count( aLibPin ) );
return m_pins[ m_pinMap.at( aLibPin ) ].get();
}
std::vector<SCH_PIN*> SCH_COMPONENT::GetPins( const SCH_SHEET_PATH* aSheet ) const
{
std::vector<SCH_PIN*> pins;
if( aSheet == nullptr ) if( aSheet == nullptr )
{ {
wxCHECK_MSG( Schematic(), ptrs, "Can't call GetSchPins on a component with no schematic" ); wxCHECK_MSG( Schematic(), pins, "Can't call GetPins on a component with no schematic" );
aSheet = &Schematic()->CurrentSheet(); aSheet = &Schematic()->CurrentSheet();
} }
@ -738,10 +735,10 @@ SCH_PIN_PTRS SCH_COMPONENT::GetSchPins( const SCH_SHEET_PATH* aSheet ) const
if( unit && p->GetLibPin()->GetUnit() && ( p->GetLibPin()->GetUnit() != unit ) ) if( unit && p->GetLibPin()->GetUnit() && ( p->GetLibPin()->GetUnit() != unit ) )
continue; continue;
ptrs.push_back( p.get() ); pins.push_back( p.get() );
} }
return ptrs; return pins;
} }
@ -1767,10 +1764,3 @@ void SCH_COMPONENT::ClearBrightenedPins()
} }
void SCH_COMPONENT::BrightenPin( LIB_PIN* aPin )
{
if( m_pinMap.count( aPin ) )
m_pins[ m_pinMap.at( aPin ) ]->SetBrightened();
}

View File

@ -65,14 +65,6 @@ class SCH_SCREEN;
class SYMBOL_LIB_TABLE; class SYMBOL_LIB_TABLE;
/// A container for several SCH_PIN items
typedef std::vector<std::unique_ptr<SCH_PIN>> SCH_PINS;
typedef std::vector<SCH_PIN*> SCH_PIN_PTRS;
/// A map from the library pin pointer to the SCH_PIN's index
typedef std::unordered_map<LIB_PIN*, unsigned> SCH_PIN_MAP;
/// A container for several SCH_FIELD items /// A container for several SCH_FIELD items
typedef std::vector<SCH_FIELD> SCH_FIELDS; typedef std::vector<SCH_FIELD> SCH_FIELDS;
@ -87,15 +79,9 @@ extern std::string toUTFTildaText( const wxString& txt );
*/ */
class SCH_COMPONENT : public SCH_ITEM class SCH_COMPONENT : public SCH_ITEM
{ {
public:
private: private:
wxPoint m_Pos; wxPoint m_Pos;
LIB_ID m_lib_id; ///< Name and library the symbol was loaded from, i.e. 74xx:74LS00.
///< Name and library where symbol was loaded from, i.e. "74xx:74LS00".
LIB_ID m_lib_id;
int m_unit; ///< The unit for multiple part per package components. int m_unit; ///< The unit for multiple part per package components.
int m_convert; ///< The alternate body style for components that have more than int m_convert; ///< The alternate body style for components that have more than
///< one body style defined. Primarily used for components that ///< one body style defined. Primarily used for components that
@ -108,21 +94,19 @@ private:
/** /**
* The name used to look up a symbol in the symbol library embedded in a schematic. * The name used to look up a symbol in the symbol library embedded in a schematic.
* *
* By default this is the same as #LIB_ID::GetLibItemName(). However, schematics * By default this is the same as #LIB_ID::GetLibItemName(). However, schematics allow for
* allow for multiple variants of the same library symbol. Set this member In order * multiple variants of the same library symbol. Set this member in order to preserve the
* to preserve the link to the original symbol library. If empty, the return of * link to the original symbol library. If empty, #LIB_ID::GetLibItemName() should be used.
* #LIB_ID::GetLibItemName() should be used.
*/ */
wxString m_schLibSymbolName; wxString m_schLibSymbolName;
TRANSFORM m_transform; ///< The rotation/mirror transformation matrix. TRANSFORM m_transform; ///< The rotation/mirror transformation matrix.
SCH_FIELDS m_Fields; ///< Variable length list of fields. SCH_FIELDS m_Fields; ///< Variable length list of fields.
///< A flattened copy of a LIB_PART found in the PROJECT's libraries to for this component. std::unique_ptr< LIB_PART > m_part; // a flattened copy of the LIB_PART from
std::unique_ptr< LIB_PART > m_part; // the PROJECT's libraries.
std::vector<std::unique_ptr<SCH_PIN>> m_pins; // a SCH_PIN for every LIB_PIN (all units)
SCH_PINS m_pins; ///< a SCH_PIN for every LIB_PIN (across all units) std::unordered_map<LIB_PIN*, unsigned> m_pinMap; // library pin pointer to SCH_PIN's index
SCH_PIN_MAP m_pinMap; ///< the component's pins mapped by LIB_PIN*
bool m_isInNetlist; ///< True if the component should appear in the netlist bool m_isInNetlist; ///< True if the component should appear in the netlist
bool m_inBom; ///< True to include in bill of materials export. bool m_inBom; ///< True to include in bill of materials export.
@ -257,11 +241,6 @@ public:
*/ */
void UpdatePins(); void UpdatePins();
/**
* Retrieves the connection for a given pin of the component
*/
SCH_CONNECTION* GetConnectionForPin( LIB_PIN* aPin, const SCH_SHEET_PATH& aSheet );
/** /**
* Change the unit number to \a aUnit * Change the unit number to \a aUnit
* *
@ -487,14 +466,16 @@ public:
* *
* @return Pin object if found, otherwise NULL. * @return Pin object if found, otherwise NULL.
*/ */
LIB_PIN* GetPin( const wxString& number ); SCH_PIN* GetPin( const wxString& number );
/** /**
* Populate a vector with all the pins from the library object. * Populate a vector with all the pins from the library object.
* *
* @param aPinsList is the list to populate with all of the pins. * @param aPinsList is the list to populate with all of the pins.
*/ */
void GetPins( std::vector<LIB_PIN*>& aPinsList ); void GetLibPins( std::vector<LIB_PIN*>& aPinsList );
SCH_PIN* GetPin( LIB_PIN* aLibPin );
/** /**
* Retrieves a list of the SCH_PINs for the given sheet path. * Retrieves a list of the SCH_PINs for the given sheet path.
@ -502,7 +483,9 @@ public:
* this list returns the subset of pins that exist on a given sheet. * this list returns the subset of pins that exist on a given sheet.
* @return a vector of pointers (non-owning) to SCH_PINs * @return a vector of pointers (non-owning) to SCH_PINs
*/ */
SCH_PIN_PTRS GetSchPins( const SCH_SHEET_PATH* aSheet = nullptr ) const; std::vector<SCH_PIN*> GetPins( const SCH_SHEET_PATH* aSheet = nullptr ) const;
std::vector<std::unique_ptr<SCH_PIN>>& GetRawPins() { return m_pins; }
/** /**
* Print a component * Print a component
@ -669,8 +652,6 @@ public:
bool HasBrightenedPins(); bool HasBrightenedPins();
void BrightenPin( LIB_PIN* aPin );
bool GetIncludeInBom() const { return m_inBom; } bool GetIncludeInBom() const { return m_inBom; }
void SetIncludeInBom( bool aIncludeInBom ) { m_inBom = aIncludeInBom; } void SetIncludeInBom( bool aIncludeInBom ) { m_inBom = aIncludeInBom; }

View File

@ -1286,7 +1286,7 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
component->SetLibSymbol( new LIB_PART( *libSymbol ) ); component->SetLibSymbol( new LIB_PART( *libSymbol ) );
std::vector<LIB_PIN*> pins; std::vector<LIB_PIN*> pins;
component->GetPins( pins ); component->GetLibPins( pins );
for( const auto& pin : pins ) for( const auto& pin : pins )
m_connPoints[component->GetPinPhysicalPosition( pin )].emplace( pin ); m_connPoints[component->GetPinPhysicalPosition( pin )].emplace( pin );

View File

@ -1243,7 +1243,7 @@ void SCH_EDIT_FRAME::FixupJunctions()
{ {
auto cmp = static_cast<SCH_COMPONENT*>( aItem ); auto cmp = static_cast<SCH_COMPONENT*>( aItem );
for( const SCH_PIN* pin : cmp->GetSchPins( &sheet ) ) for( const SCH_PIN* pin : cmp->GetPins( &sheet ) )
{ {
auto pos = pin->GetPosition(); auto pos = pin->GetPosition();

View File

@ -32,7 +32,10 @@
/** /**
* Symbol library file version. * Symbol library file version.
*/ */
#define SEXPR_SYMBOL_LIB_FILE_VERSION 20200126 // Initial version. //#define SEXPR_SYMBOL_LIB_FILE_VERSION 20200126 // Initial version. Add alternate pin
// definitions.
#define SEXPR_SYMBOL_LIB_FILE_VERSION 20200820
/** /**
* Symbol library file version. * Symbol library file version.
@ -51,4 +54,6 @@
//#define SEXPR_SCHEMATIC_FILE_VERSION 20200618 // Disallow duplicate field ids. //#define SEXPR_SCHEMATIC_FILE_VERSION 20200618 // Disallow duplicate field ids.
#define SEXPR_SCHEMATIC_FILE_VERSION 20200714 //#define SEXPR_SCHEMATIC_FILE_VERSION 20200714 // Add alternate pin definitions.
#define SEXPR_SCHEMATIC_FILE_VERSION 20200820

View File

@ -91,7 +91,7 @@ SCH_ITEM* SCH_ITEM::Duplicate( bool doClone ) const
{ {
SCH_COMPONENT* component = (SCH_COMPONENT*) newItem; SCH_COMPONENT* component = (SCH_COMPONENT*) newItem;
for( SCH_PIN* pin : component->GetSchPins() ) for( SCH_PIN* pin : component->GetPins() )
pin->ClearFlags( SELECTED | BRIGHTENED ); pin->ClearFlags( SELECTED | BRIGHTENED );
for( SCH_FIELD& field : component->GetFields() ) for( SCH_FIELD& field : component->GetFields() )

View File

@ -1408,11 +1408,18 @@ static void orientPart( LIB_PART* part, int orientation )
void SCH_PAINTER::draw( SCH_COMPONENT *aComp, int aLayer ) void SCH_PAINTER::draw( SCH_COMPONENT *aComp, int aLayer )
{ {
int unit = aComp->GetUnitSelection( &m_schematic->CurrentSheet() );
int convert = aComp->GetConvert();
// Use dummy part if the actual couldn't be found (or couldn't be locked). // Use dummy part if the actual couldn't be found (or couldn't be locked).
LIB_PART* originalPart = aComp->GetPartRef() ? aComp->GetPartRef().get() : dummy(); LIB_PART* originalPart = aComp->GetPartRef() ? aComp->GetPartRef().get() : dummy();
LIB_PINS originalPins;
originalPart->GetPins( originalPins, unit, convert );
// Copy the source so we can re-orient and translate it. // Copy the source so we can re-orient and translate it.
LIB_PART tempPart( *originalPart ); LIB_PART tempPart( *originalPart );
LIB_PINS tempPins;
tempPart.GetPins( tempPins, unit, convert );
tempPart.SetFlags( aComp->GetFlags() ); tempPart.SetFlags( aComp->GetFlags() );
@ -1425,18 +1432,18 @@ void SCH_PAINTER::draw( SCH_COMPONENT *aComp, int aLayer )
} }
// Copy the pin info from the component to the temp pins // Copy the pin info from the component to the temp pins
LIB_PINS tempPins; for( unsigned i = 0; i < tempPins.size(); ++ i )
tempPart.GetPins( tempPins, aComp->GetUnit(), aComp->GetConvert() );
const SCH_PIN_PTRS compPins = aComp->GetSchPins();
for( unsigned i = 0; i < tempPins.size() && i < compPins.size(); ++ i )
{ {
SCH_PIN* compPin = aComp->GetPin( originalPins[ i ] );
LIB_PIN* tempPin = tempPins[ i ]; LIB_PIN* tempPin = tempPins[ i ];
const SCH_PIN* compPin = compPins[ i ];
tempPin->ClearFlags(); tempPin->ClearFlags();
tempPin->SetFlags( compPin->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED tempPin->SetFlags( compPin->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
tempPin->SetName( compPin->GetName() );
tempPin->SetType( compPin->GetType() );
tempPin->SetShape( compPin->GetShape() );
if( compPin->IsDangling() ) if( compPin->IsDangling() )
tempPin->SetFlags( IS_DANGLING ); tempPin->SetFlags( IS_DANGLING );
} }

View File

@ -23,6 +23,7 @@
#include <sch_component.h> #include <sch_component.h>
#include <sch_pin.h> #include <sch_pin.h>
#include <sch_sheet_path.h> #include <sch_sheet_path.h>
#include <sch_edit_frame.h>
SCH_PIN::SCH_PIN( LIB_PIN* aLibPin, SCH_COMPONENT* aParentComponent ) : SCH_PIN::SCH_PIN( LIB_PIN* aLibPin, SCH_COMPONENT* aParentComponent ) :
@ -37,6 +38,7 @@ SCH_PIN::SCH_PIN( LIB_PIN* aLibPin, SCH_COMPONENT* aParentComponent ) :
SCH_PIN::SCH_PIN( const SCH_PIN& aPin ) : SCH_PIN::SCH_PIN( const SCH_PIN& aPin ) :
SCH_ITEM( aPin ) SCH_ITEM( aPin )
{ {
m_alt = aPin.m_alt;
m_libPin = aPin.m_libPin; m_libPin = aPin.m_libPin;
m_position = aPin.m_position; m_position = aPin.m_position;
m_isDangling = aPin.m_isDangling; m_isDangling = aPin.m_isDangling;
@ -47,6 +49,7 @@ SCH_PIN& SCH_PIN::operator=( const SCH_PIN& aPin )
{ {
SCH_ITEM::operator=( aPin ); SCH_ITEM::operator=( aPin );
m_alt = aPin.m_alt;
m_libPin = aPin.m_libPin; m_libPin = aPin.m_libPin;
m_position = aPin.m_position; m_position = aPin.m_position;
m_isDangling = aPin.m_isDangling; m_isDangling = aPin.m_isDangling;
@ -55,6 +58,45 @@ SCH_PIN& SCH_PIN::operator=( const SCH_PIN& aPin )
} }
wxString SCH_PIN::GetName() const
{
if( !m_alt.IsEmpty() )
return m_alt;
return m_libPin->GetName();
}
ELECTRICAL_PINTYPE SCH_PIN::GetType() const
{
if( !m_alt.IsEmpty() )
m_libPin->GetAlt( m_alt ).m_Type;
return m_libPin->GetType();
}
GRAPHIC_PINSHAPE SCH_PIN::GetShape() const
{
if( !m_alt.IsEmpty() )
m_libPin->GetAlt( m_alt ).m_Shape;
return m_libPin->GetShape();
}
int SCH_PIN::GetOrientation() const
{
return m_libPin->GetOrientation();
}
int SCH_PIN::GetLength() const
{
return m_libPin->GetLength();
}
bool SCH_PIN::Matches( wxFindReplaceData& aSearchData, void* aAuxDat ) bool SCH_PIN::Matches( wxFindReplaceData& aSearchData, void* aAuxDat )
{ {
if( !( aSearchData.GetFlags() & FR_SEARCH_ALL_PINS ) ) if( !( aSearchData.GetFlags() & FR_SEARCH_ALL_PINS ) )
@ -94,7 +136,66 @@ wxString SCH_PIN::GetSelectMenuText( EDA_UNITS aUnits ) const
void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList ) void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList )
{ {
m_libPin->GetMsgPanelInfo( aFrame, aList, GetParentComponent() ); wxString msg;
aList.push_back( MSG_PANEL_ITEM( _( "Type" ), _( "Pin" ), CYAN ) );
if( m_libPin->GetUnit() == 0 )
msg = _( "All" );
else
msg.Printf( wxT( "%d" ), m_libPin->GetUnit() );
aList.push_back( MSG_PANEL_ITEM( _( "Unit" ), msg, BROWN ) );
if( m_libPin->GetConvert() == LIB_ITEM::LIB_CONVERT::BASE )
msg = _( "no" );
else if( m_libPin->GetConvert() == LIB_ITEM::LIB_CONVERT::DEMORGAN )
msg = _( "yes" );
else
msg = wxT( "?" );
aList.push_back( MSG_PANEL_ITEM( _( "Converted" ), msg, BROWN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Name" ), GetName(), DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Number" ), msg, DARKCYAN ) );
aList.push_back( MSG_PANEL_ITEM( _( "Type" ), ElectricalPinTypeGetText( GetType() ), RED ) );
msg = PinShapeGetText( GetShape() );
aList.push_back( MSG_PANEL_ITEM( _( "Style" ), msg, BLUE ) );
msg = IsVisible() ? _( "Yes" ) : _( "No" );
aList.push_back( MSG_PANEL_ITEM( _( "Visible" ), msg, DARKGREEN ) );
// Display pin length
msg = StringFromValue( aFrame->GetUserUnits(), GetLength(), true );
aList.push_back( MSG_PANEL_ITEM( _( "Length" ), msg, MAGENTA ) );
msg = PinOrientationName( (unsigned) PinOrientationIndex( GetOrientation() ) );
aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), msg, DARKMAGENTA ) );
msg = MessageTextFromValue( aFrame->GetUserUnits(), m_position.x, true );
aList.emplace_back( _( "Pos X" ), msg, DARKMAGENTA );
msg = MessageTextFromValue( aFrame->GetUserUnits(), m_position.y, true );
aList.emplace_back( _( "Pos Y" ), msg, DARKMAGENTA );
aList.emplace_back( GetParentComponent()->GetField( REFERENCE )->GetShownText(),
GetParentComponent()->GetField( VALUE )->GetShownText(), DARKCYAN );
#if defined(DEBUG)
SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( aFrame );
if( !frame )
return;
SCH_CONNECTION* conn = Connection( frame->GetCurrentSheet() );
if( conn )
conn->AppendInfoToMsgPanel( aList );
#endif
} }

View File

@ -36,6 +36,8 @@ class SCH_PIN : public SCH_ITEM
{ {
LIB_PIN* m_libPin; LIB_PIN* m_libPin;
wxString m_number;
wxString m_alt;
wxPoint m_position; wxPoint m_position;
bool m_isDangling; bool m_isDangling;
@ -67,6 +69,9 @@ public:
void ClearDefaultNetName( const SCH_SHEET_PATH* aPath ); void ClearDefaultNetName( const SCH_SHEET_PATH* aPath );
wxString GetDefaultNetName( const SCH_SHEET_PATH aPath ); wxString GetDefaultNetName( const SCH_SHEET_PATH aPath );
wxString GetAlt() const { return m_alt; }
void SetAlt( const wxString& aAlt ) { m_alt = aAlt; }
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList ) override; void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList ) override;
@ -102,11 +107,24 @@ public:
*/ */
bool IsVisible() const { return m_libPin->IsVisible(); } bool IsVisible() const { return m_libPin->IsVisible(); }
const wxString& GetName() const { return m_libPin->GetName(); } wxString GetName() const;
const wxString& GetNumber() const { return m_libPin->GetNumber(); } wxString GetNumber() const
{
if( m_libPin )
return m_libPin->GetNumber();
else
return m_number;
}
void SetNumber( const wxString& aNumber ) { m_number = aNumber; }
ELECTRICAL_PINTYPE GetType() const { return m_libPin->GetType(); } ELECTRICAL_PINTYPE GetType() const;
GRAPHIC_PINSHAPE GetShape() const;
int GetOrientation() const;
int GetLength() const;
bool IsPowerConnection() const { return m_libPin->IsPowerConnection(); } bool IsPowerConnection() const { return m_libPin->IsPowerConnection(); }

View File

@ -1071,6 +1071,51 @@ LIB_CIRCLE* SCH_SEXPR_PARSER::parseCircle()
LIB_PIN* SCH_SEXPR_PARSER::parsePin() LIB_PIN* SCH_SEXPR_PARSER::parsePin()
{ {
auto parseType = [&]( T token ) -> ELECTRICAL_PINTYPE
{
switch( token )
{
case T_input: return ELECTRICAL_PINTYPE::PT_INPUT;
case T_output: return ELECTRICAL_PINTYPE::PT_OUTPUT;
case T_bidirectional: return ELECTRICAL_PINTYPE::PT_BIDI;
case T_tri_state: return ELECTRICAL_PINTYPE::PT_TRISTATE;
case T_passive: return ELECTRICAL_PINTYPE::PT_PASSIVE;
case T_unspecified: return ELECTRICAL_PINTYPE::PT_UNSPECIFIED;
case T_power_in: return ELECTRICAL_PINTYPE::PT_POWER_IN;
case T_power_out: return ELECTRICAL_PINTYPE::PT_POWER_OUT;
case T_open_collector: return ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR;
case T_open_emitter: return ELECTRICAL_PINTYPE::PT_OPENEMITTER;
case T_unconnected: return ELECTRICAL_PINTYPE::PT_NC;
default:
Expecting( "input, output, bidirectional, tri_state, passive, "
"unspecified, power_in, power_out, open_collector, "
"open_emitter, or unconnected" );
return ELECTRICAL_PINTYPE::PT_UNSPECIFIED;
}
};
auto parseShape = [&]( T token ) -> GRAPHIC_PINSHAPE
{
switch( token )
{
case T_line: return GRAPHIC_PINSHAPE::LINE;
case T_inverted: return GRAPHIC_PINSHAPE::INVERTED;
case T_clock: return GRAPHIC_PINSHAPE::CLOCK;
case T_inverted_clock: return GRAPHIC_PINSHAPE::INVERTED_CLOCK;
case T_input_low: return GRAPHIC_PINSHAPE::INPUT_LOW;
case T_clock_low: return GRAPHIC_PINSHAPE::CLOCK_LOW;
case T_output_low: return GRAPHIC_PINSHAPE::OUTPUT_LOW;
case T_edge_clock_high: return GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK;
case T_non_logic: return GRAPHIC_PINSHAPE::NONLOGIC;
default:
Expecting( "line, inverted, clock, inverted_clock, input_low, "
"clock_low, output_low, edge_clock_high, non_logic" );
return GRAPHIC_PINSHAPE::LINE;
}
};
wxCHECK_MSG( CurTok() == T_pin, nullptr, wxCHECK_MSG( CurTok() == T_pin, nullptr,
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a pin token." ) ); wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a pin token." ) );
@ -1084,103 +1129,11 @@ LIB_PIN* SCH_SEXPR_PARSER::parsePin()
// Pin electrical type. // Pin electrical type.
token = NextTok(); token = NextTok();
pin->SetType( parseType( token ) );
switch( token )
{
case T_input:
pin->SetType( ELECTRICAL_PINTYPE::PT_INPUT );
break;
case T_output:
pin->SetType( ELECTRICAL_PINTYPE::PT_OUTPUT );
break;
case T_bidirectional:
pin->SetType( ELECTRICAL_PINTYPE::PT_BIDI );
break;
case T_tri_state:
pin->SetType( ELECTRICAL_PINTYPE::PT_TRISTATE );
break;
case T_passive:
pin->SetType( ELECTRICAL_PINTYPE::PT_PASSIVE );
break;
case T_unspecified:
pin->SetType( ELECTRICAL_PINTYPE::PT_UNSPECIFIED );
break;
case T_power_in:
pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
break;
case T_power_out:
pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_OUT );
break;
case T_open_collector:
pin->SetType( ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR );
break;
case T_open_emitter:
pin->SetType( ELECTRICAL_PINTYPE::PT_OPENEMITTER );
break;
case T_unconnected:
pin->SetType( ELECTRICAL_PINTYPE::PT_NC );
break;
default:
Expecting( "input, output, bidirectional, tri_state, passive, unspecified, "
"power_in, power_out, open_collector, open_emitter, or unconnected" );
}
// Pin shape. // Pin shape.
token = NextTok(); token = NextTok();
pin->SetShape( parseShape( token ) );
switch( token )
{
case T_line:
pin->SetShape( GRAPHIC_PINSHAPE::LINE );
break;
case T_inverted:
pin->SetShape( GRAPHIC_PINSHAPE::INVERTED );
break;
case T_clock:
pin->SetShape( GRAPHIC_PINSHAPE::CLOCK );
break;
case T_inverted_clock:
pin->SetShape( GRAPHIC_PINSHAPE::INVERTED_CLOCK );
break;
case T_input_low:
pin->SetShape( GRAPHIC_PINSHAPE::INPUT_LOW );
break;
case T_clock_low:
pin->SetShape( GRAPHIC_PINSHAPE::CLOCK_LOW );
break;
case T_output_low:
pin->SetShape( GRAPHIC_PINSHAPE::OUTPUT_LOW );
break;
case T_edge_clock_high:
pin->SetShape( GRAPHIC_PINSHAPE::FALLING_EDGE_CLOCK );
break;
case T_non_logic:
pin->SetShape( GRAPHIC_PINSHAPE::NONLOGIC );
break;
default:
Expecting( "line, inverted, clock, inverted_clock, input_low, clock_low, "
"output_low, edge_clock_high, non_logic" );
}
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
@ -1300,8 +1253,35 @@ LIB_PIN* SCH_SEXPR_PARSER::parsePin()
break; break;
case T_alternate:
{
LIB_PIN::ALT alt;
token = NextTok();
if( !IsSymbol( token ) )
{
error.Printf( _( "Invalid alternate pin name in\nfile: \"%s\"\nline: %d\noffset: %d" ),
CurSource().c_str(), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
}
alt.m_Name = FromUTF8();
token = NextTok();
alt.m_Type = parseType( token );
token = NextTok();
alt.m_Shape = parseShape( token );
pin->GetAlternates()[ alt.m_Name ] = alt;
NeedRIGHT();
}
break;
default: default:
Expecting( "at, name, number, or length" ); Expecting( "at, name, number, length, or alternate" );
} }
} }
@ -2215,8 +2195,34 @@ SCH_COMPONENT* SCH_SEXPR_PARSER::parseSchematicSymbol()
break; break;
} }
case T_pin:
{
SCH_PIN* pin = new SCH_PIN( nullptr, symbol.get() );
NeedSYMBOL();
pin->SetNumber( FromUTF8() );
token = NextTok();
if( token == T_alternate )
{
NeedSYMBOL();
pin->SetAlt( FromUTF8() );
NeedRIGHT();
}
else
{
Expecting( "alternate" );
}
symbol->GetPins().push_back( pin );
NeedRIGHT();
}
break;
default: default:
Expecting( "lib_id, lib_name, at, mirror, uuid, property, or instances" ); Expecting( "lib_id, lib_name, at, mirror, uuid, property, pin, or instances" );
} }
} }

View File

@ -28,37 +28,21 @@
#define wxUSE_BASE64 1 #define wxUSE_BASE64 1
#include <wx/base64.h> #include <wx/base64.h>
#include <wx/mstream.h> #include <wx/mstream.h>
#include <wx/filename.h>
#include <wx/tokenzr.h>
#include <advanced_config.h> #include <advanced_config.h>
#include <build_version.h> #include <build_version.h>
#include <gal/color4d.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <gr_text.h>
#include <kiway.h>
#include <kicad_string.h>
#include <richio.h>
#include <core/typeinfo.h>
#include <plotter.h> // PLOT_DASH_TYPE
#include <properties.h>
#include <trace_helpers.h> #include <trace_helpers.h>
#include <sch_bitmap.h> #include <sch_bitmap.h>
#include <sch_bus_entry.h> #include <sch_bus_entry.h>
#include <sch_component.h> #include <sch_component.h>
#include <sch_edit_frame.h> // COMPONENT_ORIENTATION_T #include <sch_edit_frame.h> // COMPONENT_ORIENTATION_T
#include <sch_junction.h> #include <sch_junction.h>
#include <sch_line.h> #include <sch_line.h>
#include <sch_marker.h>
#include <sch_no_connect.h> #include <sch_no_connect.h>
#include <sch_text.h> #include <sch_text.h>
#include <sch_sheet.h> #include <sch_sheet.h>
#include <sch_bitmap.h>
#include <schematic.h> #include <schematic.h>
#include <bus_alias.h>
#include <sch_sexpr_plugin.h> #include <sch_sexpr_plugin.h>
#include <template_fieldnames.h>
#include <sch_screen.h> #include <sch_screen.h>
#include <class_libentry.h> #include <class_libentry.h>
#include <class_library.h> #include <class_library.h>
@ -70,17 +54,12 @@
#include <lib_polyline.h> #include <lib_polyline.h>
#include <lib_rectangle.h> #include <lib_rectangle.h>
#include <lib_text.h> #include <lib_text.h>
#include <pin_shape.h>
#include <pin_type.h>
#include <eeschema_id.h> // for MAX_UNIT_COUNT_PER_PACKAGE definition #include <eeschema_id.h> // for MAX_UNIT_COUNT_PER_PACKAGE definition
#include <sch_file_versions.h> #include <sch_file_versions.h>
#include <schematic_lexer.h> #include <schematic_lexer.h>
#include <sch_reference_list.h>
#include <sch_sexpr_parser.h> #include <sch_sexpr_parser.h>
#include <symbol_lib_table.h> // for PropPowerSymsOnly definintion. #include <symbol_lib_table.h> // for PropPowerSymsOnly definintion.
#include <confirm.h>
#include <ee_selection.h> #include <ee_selection.h>
#include <default_values.h> // For some default values
using namespace TSCHEMATIC_T; using namespace TSCHEMATIC_T;
@ -957,6 +936,16 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_COMPONENT* aSymbol, int aNestLevel )
saveField( &field, aNestLevel + 1 ); saveField( &field, aNestLevel + 1 );
} }
for( const SCH_PIN* pin : aSymbol->GetPins() )
{
if( !pin->GetAlt().IsEmpty() )
{
m_out->Print( aNestLevel + 1, "(pin %s (alternate %s))\n",
m_out->Quotew( pin->GetNumber() ).c_str(),
m_out->Quotew( pin->GetAlt() ).c_str() );
}
}
m_out->Print( aNestLevel, ")\n" ); m_out->Print( aNestLevel, ")\n" );
} }
@ -1844,6 +1833,15 @@ void SCH_SEXPR_PLUGIN_CACHE::savePin( LIB_PIN* aPin,
FormatInternalUnits( aPin->GetNumberTextSize() ).c_str(), FormatInternalUnits( aPin->GetNumberTextSize() ).c_str(),
FormatInternalUnits( aPin->GetNumberTextSize() ).c_str() ); FormatInternalUnits( aPin->GetNumberTextSize() ).c_str() );
for( const std::pair<const wxString, LIB_PIN::ALT>& alt : aPin->GetAlternates() )
{
aFormatter.Print( aNestLevel + 1, "(alternate %s %s %s)\n",
aFormatter.Quotew( alt.second.m_Name ).c_str(),
getPinElectricalTypeToken( alt.second.m_Type ),
getPinShapeToken( alt.second.m_Shape ) );
}
aFormatter.Print( aNestLevel, ")\n" ); aFormatter.Print( aNestLevel, ")\n" );
} }

View File

@ -522,7 +522,7 @@ SCH_ITEM* SCH_SHEET_LIST::GetItem( const KIID& aID, SCH_SHEET_PATH* aPathOut )
} }
} }
for( SCH_PIN* pin : comp->GetSchPins() ) for( SCH_PIN* pin : comp->GetPins() )
{ {
if( pin->m_Uuid == aID ) if( pin->m_Uuid == aID )
{ {
@ -583,7 +583,7 @@ void SCH_SHEET_LIST::FillItemMap( std::map<KIID, EDA_ITEM*>& aMap )
for( SCH_FIELD& field : comp->GetFields() ) for( SCH_FIELD& field : comp->GetFields() )
aMap[ field.m_Uuid ] = &field; aMap[ field.m_Uuid ] = &field;
for( SCH_PIN* pin : comp->GetSchPins() ) for( SCH_PIN* pin : comp->GetPins() )
aMap[ pin->m_Uuid ] = pin; aMap[ pin->m_Uuid ] = pin;
} }
else if( aItem->Type() == SCH_SHEET_T ) else if( aItem->Type() == SCH_SHEET_T )

View File

@ -452,8 +452,8 @@ void BACK_ANNOTATE::applyChangelist()
{ {
const wxString& pinNumber = entry.first; const wxString& pinNumber = entry.first;
const wxString& shortNetName = entry.second; const wxString& shortNetName = entry.second;
LIB_PIN* pin = comp->GetPin( pinNumber ); SCH_PIN* pin = comp->GetPin( pinNumber );
SCH_CONNECTION* conn = comp->GetConnectionForPin( pin, ref.GetSheetPath() ); SCH_CONNECTION* conn = pin->Connection( ref.GetSheetPath() );
wxString key = shortNetName + ref.GetSheetPath().PathAsString(); wxString key = shortNetName + ref.GetSheetPath().PathAsString();

View File

@ -1368,18 +1368,12 @@ void EE_SELECTION_TOOL::highlight( EDA_ITEM* aItem, int aMode, EE_SELECTION* aGr
// represented in the LIB_PART and will inherit the settings of the parent component.) // represented in the LIB_PART and will inherit the settings of the parent component.)
if( itemType == SCH_COMPONENT_T ) if( itemType == SCH_COMPONENT_T )
{ {
if( auto schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) ) for( SCH_PIN* pin : static_cast<SCH_COMPONENT*>( aItem )->GetPins() )
{ {
SCH_PIN_PTRS pins = static_cast<SCH_COMPONENT*>( aItem )->GetSchPins( if( aMode == SELECTED )
&schframe->GetCurrentSheet() ); pin->SetSelected();
else if( aMode == BRIGHTENED )
for( SCH_PIN* pin : pins ) pin->SetBrightened();
{
if( aMode == SELECTED )
pin->SetSelected();
else if( aMode == BRIGHTENED )
pin->SetBrightened();
}
} }
for( SCH_FIELD& field : static_cast<SCH_COMPONENT*>( aItem )->GetFields() ) for( SCH_FIELD& field : static_cast<SCH_COMPONENT*>( aItem )->GetFields() )
@ -1432,18 +1426,12 @@ void EE_SELECTION_TOOL::unhighlight( EDA_ITEM* aItem, int aMode, EE_SELECTION* a
// represented in the LIB_PART.) // represented in the LIB_PART.)
if( itemType == SCH_COMPONENT_T ) if( itemType == SCH_COMPONENT_T )
{ {
if( auto schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) ) for( SCH_PIN* pin : static_cast<SCH_COMPONENT*>( aItem )->GetPins() )
{ {
SCH_PIN_PTRS pins = static_cast<SCH_COMPONENT*>( aItem )->GetSchPins( if( aMode == SELECTED )
&schframe->GetCurrentSheet() ); pin->ClearSelected();
else if( aMode == BRIGHTENED )
for( SCH_PIN* pin : pins ) pin->ClearBrightened();
{
if( aMode == SELECTED )
pin->ClearSelected();
else if( aMode == BRIGHTENED )
pin->ClearBrightened();
}
} }
for( SCH_FIELD& field : static_cast<SCH_COMPONENT*>( aItem )->GetFields() ) for( SCH_FIELD& field : static_cast<SCH_COMPONENT*>( aItem )->GetFields() )

View File

@ -273,7 +273,7 @@ int SCH_EDITOR_CONTROL::UpdateFind( const TOOL_EVENT& aEvent )
for( SCH_FIELD& field : cmp->GetFields() ) for( SCH_FIELD& field : cmp->GetFields() )
visit( &field ); visit( &field );
for( SCH_PIN* pin : cmp->GetSchPins() ) for( SCH_PIN* pin : cmp->GetPins() )
visit( pin ); visit( pin );
} }
else if( item->Type() == SCH_SHEET_T ) else if( item->Type() == SCH_SHEET_T )
@ -341,7 +341,7 @@ SCH_ITEM* SCH_EDITOR_CONTROL::nextMatch( SCH_SCREEN* aScreen, SCH_ITEM* aAfter,
return &field; return &field;
} }
for( SCH_PIN* pin : cmp->GetSchPins() ) for( SCH_PIN* pin : cmp->GetPins() )
{ {
if( pin->Matches( *aData, nullptr ) ) if( pin->Matches( *aData, nullptr ) )
return pin; return pin;
@ -851,7 +851,7 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
if( comp && comp->GetPartRef() && comp->GetPartRef()->IsPower() ) if( comp && comp->GetPartRef() && comp->GetPartRef()->IsPower() )
{ {
SCH_PIN_PTRS pins = comp->GetSchPins( &editFrame->GetCurrentSheet() ); std::vector<SCH_PIN*> pins = comp->GetPins();
if( pins.size() == 1 ) if( pins.size() == 1 )
conn = pins[0]->Connection( editFrame->GetCurrentSheet() ); conn = pins[0]->Connection( editFrame->GetCurrentSheet() );
@ -1071,17 +1071,14 @@ int SCH_EDITOR_CONTROL::UpdateNetHighlighting( const TOOL_EVENT& aEvent )
redraw |= comp->HasBrightenedPins(); redraw |= comp->HasBrightenedPins();
comp->ClearBrightenedPins(); comp->ClearBrightenedPins();
std::vector<LIB_PIN*> pins;
comp->GetPins( pins );
for( LIB_PIN* pin : pins ) for( SCH_PIN* pin : comp->GetPins() )
{ {
SCH_CONNECTION* pin_conn = SCH_CONNECTION* pin_conn = pin->Connection( m_frame->GetCurrentSheet() );
comp->GetConnectionForPin( pin, m_frame->GetCurrentSheet() );
if( pin_conn && pin_conn->Name() == selectedName ) if( pin_conn && pin_conn->Name() == selectedName )
{ {
comp->BrightenPin( pin ); pin->SetBrightened();
redraw = true; redraw = true;
} }
} }

View File

@ -27,8 +27,7 @@
*/ */
#include <wx/bmpcbox.h> #include <wx/bmpcbox.h>
#include <pin_type.h>
#include <pin_shape.h>
class PinShapeComboBox : public wxBitmapComboBox class PinShapeComboBox : public wxBitmapComboBox
{ {

View File

@ -46,8 +46,8 @@ public:
wxSize GetBestSize( wxGrid & grid, wxGridCellAttr & attr, wxDC & dc, int row, int col ) override; wxSize GetBestSize( wxGrid & grid, wxGridCellAttr & attr, wxDC & dc, int row, int col ) override;
private: private:
const std::vector<BITMAP_DEF>& m_icons; std::vector<BITMAP_DEF> m_icons;
const wxArrayString& m_names; wxArrayString m_names;
}; };
//---- Grid helpers: custom wxGridCellRenderer that renders just an icon ---------------- //---- Grid helpers: custom wxGridCellRenderer that renders just an icon ----------------
@ -92,9 +92,9 @@ public:
protected: protected:
wxBitmapComboBox* Combo() const { return static_cast<wxBitmapComboBox*>( m_control ); } wxBitmapComboBox* Combo() const { return static_cast<wxBitmapComboBox*>( m_control ); }
const std::vector<BITMAP_DEF>& m_icons; std::vector<BITMAP_DEF> m_icons;
const wxArrayString& m_names; wxArrayString m_names;
wxString m_value; wxString m_value;
wxDECLARE_NO_COPY_CLASS( GRID_CELL_ICON_TEXT_POPUP ); wxDECLARE_NO_COPY_CLASS( GRID_CELL_ICON_TEXT_POPUP );
}; };