diff --git a/eeschema/dialogs/dialog_field_properties.cpp b/eeschema/dialogs/dialog_field_properties.cpp index 2661d869a4..ebe923cdb3 100644 --- a/eeschema/dialogs/dialog_field_properties.cpp +++ b/eeschema/dialogs/dialog_field_properties.cpp @@ -24,11 +24,13 @@ */ #include +#include #include #include #include #include #include +#include #include #include #include @@ -184,6 +186,10 @@ void DIALOG_FIELD_PROPERTIES::init() m_TextValueSelectButton->SetBitmap( KiBitmap( BITMAPS::small_library ) ); m_TextValueSelectButton->Show( m_fieldId == FOOTPRINT_FIELD ); + if( m_fieldId == FOOTPRINT_FIELD ) + { + } + m_TextCtrl->Enable( true ); GetSizer()->SetSizeHints( this ); @@ -219,6 +225,9 @@ void DIALOG_FIELD_PROPERTIES::OnTextValueSelectButtonClick( wxCommandEvent& aEve if( KIWAY_PLAYER* frame = Kiway().Player( FRAME_FOOTPRINT_CHOOSER, true ) ) { + KIWAY_EXPRESS event( FRAME_FOOTPRINT_CHOOSER, MAIL_SYMBOL_NETLIST, m_netlist ); + frame->KiwayMailIn( event ); + if( frame->ShowModal( &fpid, this ) ) { if( m_StyledTextCtrl->IsShown() ) @@ -418,6 +427,28 @@ DIALOG_LIB_FIELD_PROPERTIES::DIALOG_LIB_FIELD_PROPERTIES( SCH_BASE_FRAME* aParen if( m_fieldId == VALUE_FIELD ) m_text = UnescapeString( aField->GetText() ); + if( m_fieldId == FOOTPRINT_FIELD ) + { + LIB_SYMBOL* symbol = aField->GetParent(); + wxString netlist; + + /* + * Symbol netlist format: + * pinCount + * fpFilters + */ + netlist << wxString::Format( wxS( "%d\r" ), symbol->GetPinCount() ); + + wxArrayString fpFilters = symbol->GetFPFilters(); + + if( !fpFilters.IsEmpty() ) + netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE ); + + netlist << wxS( "\r" ); + + m_netlist = netlist; + } + m_font = aField->GetFont(); m_nameVisible->Show(); @@ -452,7 +483,26 @@ DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES( SCH_BASE_FRAME* aParen if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T ) { + SCH_SYMBOL* symbol = static_cast( aField->GetParent() ); + wxString netlist; + m_fieldId = aField->GetId(); + + /* + * Symbol netlist format: + * pinCount + * fpFilters + */ + netlist << wxString::Format( wxS( "%zu\r" ), symbol->GetFullPinCount() ); + + wxArrayString fpFilters = symbol->GetLibSymbolRef()->GetFPFilters(); + + if( !fpFilters.IsEmpty() ) + netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE ); + + netlist << wxS( "\r" ); + + m_netlist = netlist; } else if( aField->GetParent() && aField->GetParent()->Type() == SCH_SHEET_T ) { diff --git a/eeschema/dialogs/dialog_field_properties.h b/eeschema/dialogs/dialog_field_properties.h index 82c4022827..8e0dd13b28 100644 --- a/eeschema/dialogs/dialog_field_properties.h +++ b/eeschema/dialogs/dialog_field_properties.h @@ -107,6 +107,7 @@ protected: bool m_firstFocus; SCINTILLA_TRICKS* m_scintillaTricks; + std::string m_netlist; }; diff --git a/eeschema/dialogs/dialog_field_properties_base.cpp b/eeschema/dialogs/dialog_field_properties_base.cpp index 5df67575c7..6f42c72e9e 100644 --- a/eeschema/dialogs/dialog_field_properties_base.cpp +++ b/eeschema/dialogs/dialog_field_properties_base.cpp @@ -8,6 +8,7 @@ #include "widgets/bitmap_button.h" #include "widgets/color_swatch.h" #include "widgets/font_choice.h" +#include "widgets/std_bitmap_button.h" #include "dialog_field_properties_base.h" @@ -68,7 +69,7 @@ DIALOG_FIELD_PROPERTIES_BASE::DIALOG_FIELD_PROPERTIES_BASE( wxWindow* parent, wx m_StyledTextCtrl->SetSelForeground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) ); bTextValueBoxSizer->Add( m_StyledTextCtrl, 1, wxRIGHT|wxLEFT, 5 ); - m_TextValueSelectButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + m_TextValueSelectButton = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); bTextValueBoxSizer->Add( m_TextValueSelectButton, 0, wxALIGN_CENTER_VERTICAL, 5 ); diff --git a/eeschema/dialogs/dialog_field_properties_base.fbp b/eeschema/dialogs/dialog_field_properties_base.fbp index 14f02c554e..410301e4cf 100644 --- a/eeschema/dialogs/dialog_field_properties_base.fbp +++ b/eeschema/dialogs/dialog_field_properties_base.fbp @@ -345,7 +345,7 @@ 1 - ; ; forward_declare + STD_BITMAP_BUTTON; widgets/std_bitmap_button.h; forward_declare 0 diff --git a/eeschema/dialogs/dialog_field_properties_base.h b/eeschema/dialogs/dialog_field_properties_base.h index b0706e4a33..0b3672da3a 100644 --- a/eeschema/dialogs/dialog_field_properties_base.h +++ b/eeschema/dialogs/dialog_field_properties_base.h @@ -13,6 +13,7 @@ class BITMAP_BUTTON; class COLOR_SWATCH; class FONT_CHOICE; +class STD_BITMAP_BUTTON; #include "dialog_shim.h" #include @@ -48,7 +49,7 @@ class DIALOG_FIELD_PROPERTIES_BASE : public DIALOG_SHIM wxStaticText* m_textLabel; wxTextCtrl* m_TextCtrl; wxStyledTextCtrl* m_StyledTextCtrl; - wxBitmapButton* m_TextValueSelectButton; + STD_BITMAP_BUTTON* m_TextValueSelectButton; wxStaticText* m_note; wxCheckBox* m_visible; wxCheckBox* m_nameVisible; diff --git a/eeschema/fields_grid_table.cpp b/eeschema/fields_grid_table.cpp index d80b0df253..1828755fe8 100644 --- a/eeschema/fields_grid_table.cpp +++ b/eeschema/fields_grid_table.cpp @@ -69,7 +69,7 @@ static wxString netList( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH& aSheetPath ) */ wxString netlist; - netlist << wxString::Format( wxS( "%zu\r" ), aSymbol->GetPins().size() ); + netlist << wxString::Format( wxS( "%zu\r" ), aSymbol->GetFullPinCount() ); wxArrayString fpFilters = aSymbol->GetLibSymbolRef()->GetFPFilters(); diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index 13235e2421..857df85513 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -1096,6 +1096,14 @@ std::vector LIB_SYMBOL::GetAllLibPins() const } +int LIB_SYMBOL::GetPinCount() +{ + std::vector pinList; + + GetPins( pinList, 0, 1 ); // All units, but a single convert + return pinList.size(); +} + LIB_PIN* LIB_SYMBOL::GetPin( const wxString& aNumber, int aUnit, int aConvert ) const { diff --git a/eeschema/lib_symbol.h b/eeschema/lib_symbol.h index 127258623d..7b100623f5 100644 --- a/eeschema/lib_symbol.h +++ b/eeschema/lib_symbol.h @@ -430,8 +430,6 @@ public: void RemoveField( LIB_FIELD* aField ) { RemoveDrawItem( aField ); } - size_t GetPinCount() const { return m_drawings.size( LIB_PIN_T ); } - size_t GetFieldCount() const { return m_drawings.size( LIB_FIELD_T ); } /** @@ -456,7 +454,7 @@ public: /** * @return a count of pins for all units / converts. */ - int GetPinCount() override { return GetAllLibPins().size(); } + int GetPinCount() override; /** * Return pin object with the requested pin \a aNumber. diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index 607ccb4791..d079676f21 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -517,9 +517,9 @@ public: std::vector GetAllLibPins() const; /** - * @return a count of pins for all units / converts. + * @return a count of pins for all units. */ - size_t GetFullPinCount() { return GetAllLibPins().size(); } + size_t GetFullPinCount() { return m_part ? m_part->GetPinCount() : 0; } /** * @return the SCH_PIN associated with a particular LIB_PIN. diff --git a/pcbnew/dialogs/dialog_exchange_footprints.cpp b/pcbnew/dialogs/dialog_exchange_footprints.cpp index 26cb5e5dcd..9fa69cfe6f 100644 --- a/pcbnew/dialogs/dialog_exchange_footprints.cpp +++ b/pcbnew/dialogs/dialog_exchange_footprints.cpp @@ -413,7 +413,7 @@ void DIALOG_EXCHANGE_FOOTPRINTS::ViewAndSelectFootprint( wxCommandEvent& event ) */ wxString netlist; - netlist << wxString::Format( wxS( "%ld\r" ), m_currentFootprint->Pads().size() ); + netlist << wxString::Format( wxS( "%u\r" ), m_currentFootprint->GetUniquePadCount() ); netlist << EscapeString( m_currentFootprint->GetFilters(), CTX_LINE ) << wxS( "\r" ); std::string payload( netlist.ToStdString() );