Pass symbol netlist from Field Properties dialog.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15806
This commit is contained in:
Jeff Young 2023-10-02 23:32:20 +01:00
parent aa0d39dfe4
commit a3d83cdb6d
10 changed files with 69 additions and 10 deletions

View File

@ -24,11 +24,13 @@
*/
#include <widgets/bitmap_button.h>
#include <widgets/std_bitmap_button.h>
#include <widgets/font_choice.h>
#include <widgets/color_swatch.h>
#include <settings/color_settings.h>
#include <bitmaps.h>
#include <kiway.h>
#include <kiway_express.h>
#include <confirm.h>
#include <common.h>
#include <string_utils.h>
@ -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<SCH_SYMBOL*>( 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 )
{

View File

@ -107,6 +107,7 @@ protected:
bool m_firstFocus;
SCINTILLA_TRICKS* m_scintillaTricks;
std::string m_netlist;
};

View File

@ -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 );

View File

@ -345,7 +345,7 @@
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="subclass">STD_BITMAP_BUTTON; widgets/std_bitmap_button.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>

View File

@ -13,6 +13,7 @@
class BITMAP_BUTTON;
class COLOR_SWATCH;
class FONT_CHOICE;
class STD_BITMAP_BUTTON;
#include "dialog_shim.h"
#include <wx/string.h>
@ -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;

View File

@ -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();

View File

@ -1096,6 +1096,14 @@ std::vector<LIB_PIN*> LIB_SYMBOL::GetAllLibPins() const
}
int LIB_SYMBOL::GetPinCount()
{
std::vector<LIB_PIN*> 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
{

View File

@ -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.

View File

@ -517,9 +517,9 @@ public:
std::vector<LIB_PIN*> 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.

View File

@ -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() );