Pass symbol's netlist to footprint preview widget.
This allows us to show the pin functions on the corresponding pads. Fixes https://gitlab.com/kicad/code/kicad/-/issues/17349
This commit is contained in:
parent
cb01bca1f4
commit
72ba31ba27
|
@ -92,6 +92,12 @@ void FOOTPRINT_PREVIEW_WIDGET::SetUserUnits( EDA_UNITS aUnits )
|
|||
}
|
||||
|
||||
|
||||
void FOOTPRINT_PREVIEW_WIDGET::SetPinFunctions( const std::map<wxString, wxString>& aPinFunctions )
|
||||
{
|
||||
m_prev_panel->SetPinFunctions( aPinFunctions );
|
||||
}
|
||||
|
||||
|
||||
void FOOTPRINT_PREVIEW_WIDGET::DisplayFootprint( const LIB_ID& aFPID )
|
||||
{
|
||||
if( !m_prev_panel || m_libid == aFPID )
|
||||
|
|
|
@ -287,8 +287,8 @@ protected:
|
|||
|
||||
/*
|
||||
* Symbol netlist format:
|
||||
* pinCount
|
||||
* fpFilters
|
||||
* pinNumber pinName <tab> pinNumber pinName...
|
||||
* fpFilter fpFilter...
|
||||
*/
|
||||
std::string m_symbolNetlist;
|
||||
};
|
||||
|
|
|
@ -465,21 +465,14 @@ void DISPLAY_FOOTPRINTS_FRAME::ReloadFootprint( FOOTPRINT* aFootprint )
|
|||
return;
|
||||
|
||||
GetBoard()->DeleteAllFootprints();
|
||||
GetBoard()->RemoveUnusedNets( nullptr );
|
||||
GetCanvas()->GetView()->Clear();
|
||||
|
||||
|
||||
for( PAD* pad : aFootprint->Pads() )
|
||||
{
|
||||
const COMPONENT_NET& net = m_currentComp->GetNet( pad->GetNumber() );
|
||||
|
||||
if( !net.GetPinFunction().IsEmpty() )
|
||||
{
|
||||
NETINFO_ITEM* netinfo = new NETINFO_ITEM( GetBoard() );
|
||||
netinfo->SetNetname( net.GetPinFunction() );
|
||||
GetBoard()->Add( netinfo );
|
||||
pad->SetNet( netinfo );
|
||||
}
|
||||
pad->SetPinFunction( net.GetPinFunction() );
|
||||
}
|
||||
|
||||
GetBoard()->Add( aFootprint );
|
||||
|
@ -504,7 +497,6 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
|
|||
return;
|
||||
|
||||
GetBoard()->DeleteAllFootprints();
|
||||
GetBoard()->RemoveUnusedNets( nullptr );
|
||||
GetCanvas()->GetView()->Clear();
|
||||
|
||||
INFOBAR_REPORTER infoReporter( m_infoBar );
|
||||
|
@ -528,12 +520,7 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
|
|||
const COMPONENT_NET& net = comp->GetNet( pad->GetNumber() );
|
||||
|
||||
if( !net.GetPinFunction().IsEmpty() )
|
||||
{
|
||||
NETINFO_ITEM* netinfo = new NETINFO_ITEM( GetBoard() );
|
||||
netinfo->SetNetname( net.GetPinFunction() );
|
||||
GetBoard()->Add( netinfo );
|
||||
pad->SetNet( netinfo );
|
||||
}
|
||||
pad->SetPinFunction( net.GetPinFunction() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -431,17 +431,28 @@ DIALOG_LIB_FIELD_PROPERTIES::DIALOG_LIB_FIELD_PROPERTIES( SCH_BASE_FRAME* aParen
|
|||
|
||||
if( m_fieldId == FOOTPRINT_FIELD )
|
||||
{
|
||||
LIB_SYMBOL* symbol = aField->GetParent();
|
||||
wxString netlist;
|
||||
|
||||
/*
|
||||
* Symbol netlist format:
|
||||
* pinCount
|
||||
* fpFilters
|
||||
* pinNumber pinName <tab> pinNumber pinName...
|
||||
* fpFilter fpFilter...
|
||||
*/
|
||||
netlist << wxString::Format( wxS( "%d\r" ), symbol->GetPinCount() );
|
||||
wxString netlist;
|
||||
|
||||
wxArrayString fpFilters = symbol->GetFPFilters();
|
||||
std::vector<LIB_PIN*> pinList;
|
||||
|
||||
aField->GetParent()->GetPins( pinList, 0, 1 ); // All units, but a single convert
|
||||
|
||||
wxArrayString pins;
|
||||
|
||||
for( LIB_PIN* pin : pinList )
|
||||
pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
|
||||
|
||||
if( !pins.IsEmpty() )
|
||||
netlist << EscapeString( wxJoin( pins, '\t' ), CTX_LINE );
|
||||
|
||||
netlist << wxS( "\r" );
|
||||
|
||||
wxArrayString fpFilters = aField->GetParent()->GetFPFilters();
|
||||
|
||||
if( !fpFilters.IsEmpty() )
|
||||
netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
|
||||
|
@ -475,7 +486,7 @@ void DIALOG_LIB_FIELD_PROPERTIES::UpdateField( LIB_FIELD* aField )
|
|||
}
|
||||
|
||||
|
||||
DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES( SCH_BASE_FRAME* aParent,
|
||||
DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES( SCH_EDIT_FRAME* aParent,
|
||||
const wxString& aTitle,
|
||||
const SCH_FIELD* aField ) :
|
||||
DIALOG_FIELD_PROPERTIES( aParent, aTitle, aField ),
|
||||
|
@ -486,16 +497,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;
|
||||
SCH_SHEET_PATH sheetPath = aParent->GetCurrentSheet();
|
||||
|
||||
m_fieldId = aField->GetId();
|
||||
|
||||
/*
|
||||
* Symbol netlist format:
|
||||
* pinCount
|
||||
* fpFilters
|
||||
* pinNumber pinName <tab> pinNumber pinName...
|
||||
* fpFilter fpFilter...
|
||||
*/
|
||||
netlist << wxString::Format( wxS( "%zu\r" ), symbol->GetFullPinCount() );
|
||||
wxString netlist;
|
||||
|
||||
wxArrayString pins;
|
||||
|
||||
for( SCH_PIN* pin : symbol->GetPins( &sheetPath ) )
|
||||
pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
|
||||
|
||||
if( !pins.IsEmpty() )
|
||||
netlist << EscapeString( wxJoin( pins, '\t' ), CTX_LINE );
|
||||
|
||||
netlist << wxS( "\r" );
|
||||
|
||||
wxArrayString fpFilters = symbol->GetLibSymbolRef()->GetFPFilters();
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ public:
|
|||
class DIALOG_SCH_FIELD_PROPERTIES : public DIALOG_FIELD_PROPERTIES
|
||||
{
|
||||
public:
|
||||
DIALOG_SCH_FIELD_PROPERTIES( SCH_BASE_FRAME* aParent, const wxString& aTitle,
|
||||
DIALOG_SCH_FIELD_PROPERTIES( SCH_EDIT_FRAME* aParent, const wxString& aTitle,
|
||||
const SCH_FIELD* aField );
|
||||
|
||||
~DIALOG_SCH_FIELD_PROPERTIES() {}
|
||||
|
|
|
@ -62,16 +62,24 @@ enum
|
|||
|
||||
static wxString netList( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH& aSheetPath )
|
||||
{
|
||||
wxCHECK( aSymbol && aSymbol->GetLibSymbolRef(), wxEmptyString );
|
||||
|
||||
/*
|
||||
* Symbol netlist format:
|
||||
* pinCount
|
||||
* fpFilters
|
||||
* pinNumber pinName <tab> pinNumber pinName...
|
||||
* fpFilter fpFilter...
|
||||
*/
|
||||
wxString netlist;
|
||||
|
||||
netlist << wxString::Format( wxS( "%zu\r" ), aSymbol->GetFullPinCount() );
|
||||
wxArrayString pins;
|
||||
|
||||
wxCHECK( aSymbol && aSymbol->GetLibSymbolRef(), wxEmptyString );
|
||||
for( SCH_PIN* pin : aSymbol->GetPins( &aSheetPath ) )
|
||||
pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
|
||||
|
||||
if( !pins.IsEmpty() )
|
||||
netlist << EscapeString( wxJoin( pins, '\t' ), CTX_LINE );
|
||||
|
||||
netlist << wxS( "\r" );
|
||||
|
||||
wxArrayString fpFilters = aSymbol->GetLibSymbolRef()->GetFPFilters();
|
||||
|
||||
|
@ -88,12 +96,24 @@ static wxString netList( LIB_SYMBOL* aSymbol )
|
|||
{
|
||||
/*
|
||||
* Symbol netlist format:
|
||||
* pinCount
|
||||
* fpFilters
|
||||
* pinNumber pinName <tab> pinNumber pinName...
|
||||
* fpFilter fpFilter...
|
||||
*/
|
||||
wxString netlist;
|
||||
|
||||
netlist << wxString::Format( wxS( "%d\r" ), aSymbol->GetPinCount() );
|
||||
std::vector<LIB_PIN*> pinList;
|
||||
|
||||
aSymbol->GetPins( pinList, 0, 1 ); // All units, but a single convert
|
||||
|
||||
wxArrayString pins;
|
||||
|
||||
for( LIB_PIN* pin : pinList )
|
||||
pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
|
||||
|
||||
if( !pins.IsEmpty() )
|
||||
netlist << EscapeString( wxJoin( pins, '\t' ), CTX_LINE );
|
||||
|
||||
netlist << wxS( "\r" );
|
||||
|
||||
wxArrayString fpFilters = aSymbol->GetFPFilters();
|
||||
|
||||
|
|
|
@ -48,9 +48,8 @@ public:
|
|||
FOOTPRINT_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway );
|
||||
|
||||
/**
|
||||
* Return whether the widget initialized properly. This could return false
|
||||
* if Kiway is not available. If this returns false, no other methods should
|
||||
* be called.
|
||||
* Return whether the widget initialized properly. This could return false if Kiway is
|
||||
* not available. If this returns false, no other methods should be called.
|
||||
*/
|
||||
bool IsInitialized() const { return m_prev_panel != nullptr; }
|
||||
|
||||
|
@ -70,8 +69,15 @@ public:
|
|||
void SetUserUnits( EDA_UNITS aUnits );
|
||||
|
||||
/**
|
||||
* Set the currently displayed footprint. Any footprint passed in here
|
||||
* must have been passed to CacheFootprint before.
|
||||
* Set the pin functions from the symbol's netlist. This allows us to display them in
|
||||
* the corresponding pads.
|
||||
* @param aPinFunctions a map from pin_number to pin_function
|
||||
*/
|
||||
void SetPinFunctions( const std::map<wxString, wxString>& aPinFunctions );
|
||||
|
||||
/**
|
||||
* Set the currently displayed footprint. Any footprint passed in here *MUST* have been
|
||||
* passed to CacheFootprint before.
|
||||
*/
|
||||
void DisplayFootprint( const LIB_ID& aFPID );
|
||||
|
||||
|
@ -111,8 +117,15 @@ public:
|
|||
virtual void SetUserUnits( EDA_UNITS aUnits ) = 0;
|
||||
|
||||
/**
|
||||
* Set the currently displayed footprint. Any footprint passed in here
|
||||
* must have been passed to CacheFootprint before.
|
||||
* Set the pin functions from the symbol's netlist. This allows us to display them in
|
||||
* the corresponding pads.
|
||||
* @param aPinFunctions a map from pin_number to pin_function
|
||||
*/
|
||||
virtual void SetPinFunctions( const std::map<wxString, wxString>& aPinFunctions ) = 0;
|
||||
|
||||
/**
|
||||
* Set the currently displayed footprint. Any footprint passed in here *MUST* have been
|
||||
* passed to CacheFootprint before.
|
||||
*/
|
||||
virtual bool DisplayFootprint( LIB_ID const& aFPID ) = 0;
|
||||
|
||||
|
@ -139,8 +152,8 @@ public:
|
|||
virtual const KIGFX::COLOR4D& GetForegroundColor() const = 0;
|
||||
|
||||
/**
|
||||
* Return a footprint preview panel instance via Kiface. May return null
|
||||
* if Kiway is not available or there is any error on load.
|
||||
* Return a footprint preview panel instance via Kiface. May return null if Kiway is not
|
||||
* available or there is any error on load.
|
||||
*/
|
||||
static FOOTPRINT_PREVIEW_PANEL_BASE* Create( wxWindow* aParent, KIWAY& aKiway );
|
||||
};
|
||||
|
|
|
@ -408,12 +408,21 @@ void DIALOG_EXCHANGE_FOOTPRINTS::ViewAndSelectFootprint( wxCommandEvent& event )
|
|||
{
|
||||
/*
|
||||
* Symbol netlist format:
|
||||
* pinCount
|
||||
* fpFilters
|
||||
* pinNumber pinName <tab> pinNumber pinName...
|
||||
* fpFilter fpFilter...
|
||||
*/
|
||||
wxString netlist;
|
||||
|
||||
netlist << wxString::Format( wxS( "%u\r" ), m_currentFootprint->GetUniquePadCount() );
|
||||
wxArrayString pins;
|
||||
|
||||
for( const wxString& pad : m_currentFootprint->GetUniquePadNumbers() )
|
||||
pins.push_back( pad + ' ' + wxEmptyString /* leave pinName empty */ );
|
||||
|
||||
if( !pins.IsEmpty() )
|
||||
netlist << EscapeString( wxJoin( pins, '\t' ), CTX_LINE );
|
||||
|
||||
netlist << wxS( "\r" );
|
||||
|
||||
netlist << EscapeString( m_currentFootprint->GetFilters(), CTX_LINE ) << wxS( "\r" );
|
||||
|
||||
std::string payload( netlist.ToStdString() );
|
||||
|
|
|
@ -1587,7 +1587,7 @@ unsigned FOOTPRINT::GetPadCount( INCLUDE_NPTH_T aIncludeNPTH ) const
|
|||
}
|
||||
|
||||
|
||||
unsigned FOOTPRINT::GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH ) const
|
||||
std::set<wxString> FOOTPRINT::GetUniquePadNumbers( INCLUDE_NPTH_T aIncludeNPTH ) const
|
||||
{
|
||||
std::set<wxString> usedNumbers;
|
||||
|
||||
|
@ -1614,7 +1614,13 @@ unsigned FOOTPRINT::GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH ) const
|
|||
usedNumbers.insert( pad->GetNumber() );
|
||||
}
|
||||
|
||||
return usedNumbers.size();
|
||||
return usedNumbers;
|
||||
}
|
||||
|
||||
|
||||
unsigned FOOTPRINT::GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH ) const
|
||||
{
|
||||
return GetUniquePadNumbers( aIncludeNPTH ).size();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -797,6 +797,12 @@ public:
|
|||
*/
|
||||
unsigned GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH = INCLUDE_NPTH_T(INCLUDE_NPTH) ) const;
|
||||
|
||||
/**
|
||||
* Return the names of the unique, non-blank pads.
|
||||
*/
|
||||
std::set<wxString>
|
||||
GetUniquePadNumbers( INCLUDE_NPTH_T aIncludeNPTH = INCLUDE_NPTH_T(INCLUDE_NPTH) ) const;
|
||||
|
||||
/**
|
||||
* Return the next available pad number in the footprint.
|
||||
*
|
||||
|
|
|
@ -229,6 +229,7 @@ FOOTPRINT_CHOOSER_FRAME::~FOOTPRINT_CHOOSER_FRAME()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
bool FOOTPRINT_CHOOSER_FRAME::filterFootprint( LIB_TREE_NODE& aNode )
|
||||
{
|
||||
if( aNode.m_Type == LIB_TREE_NODE::TYPE::LIBRARY )
|
||||
|
@ -322,15 +323,18 @@ void FOOTPRINT_CHOOSER_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
|||
|
||||
/*
|
||||
* Symbol netlist format:
|
||||
* pinCount
|
||||
* fpFilters
|
||||
* pinNumber pinName <tab> pinNumber pinName...
|
||||
* fpFilter fpFilter...
|
||||
*/
|
||||
std::map<wxString, wxString> pinNames;
|
||||
std::vector<std::string> strings = split( payload, "\r" );
|
||||
|
||||
if( strings.size() >= 1 )
|
||||
if( strings.size() >= 1 && !strings[0].empty() )
|
||||
{
|
||||
wxString pinCountStr( strings[0] );
|
||||
pinCountStr.ToInt( &m_pinCount );
|
||||
for( const wxString& pin : wxSplit( strings[0], '\t' ) )
|
||||
pinNames[ pin.BeforeFirst( ' ' ) ] = pin.AfterFirst( ' ' );
|
||||
|
||||
m_pinCount = pinNames.size();
|
||||
|
||||
if( m_pinCount > 0 )
|
||||
{
|
||||
|
@ -353,6 +357,7 @@ void FOOTPRINT_CHOOSER_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
|||
m_filterByFPFilters->Show( true );
|
||||
}
|
||||
|
||||
m_chooserPanel->GetViewerPanel()->SetPinFunctions( pinNames );
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <base_units.h>
|
||||
#include <board.h>
|
||||
#include <footprint.h>
|
||||
#include <pad.h>
|
||||
#include <pcb_dimension.h>
|
||||
#include <dpi_scaling_common.h>
|
||||
#include <eda_draw_frame.h>
|
||||
|
@ -126,6 +127,9 @@ void FOOTPRINT_PREVIEW_PANEL::renderFootprint( std::shared_ptr<FOOTPRINT> aFootp
|
|||
PCB_DIM_CENTER_T,
|
||||
PCB_DIM_RADIAL_T } );
|
||||
|
||||
for( PAD* pad : aFootprint->Pads() )
|
||||
pad->SetPinFunction( m_pinFunctions[ pad->GetNumber() ] );
|
||||
|
||||
// Ensure we are not using the high contrast mode to display the selected footprint
|
||||
KIGFX::PAINTER* painter = GetView()->GetPainter();
|
||||
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
||||
|
|
|
@ -55,6 +55,11 @@ public:
|
|||
virtual ~FOOTPRINT_PREVIEW_PANEL( );
|
||||
|
||||
virtual void SetUserUnits( EDA_UNITS aUnits ) override { m_userUnits = aUnits; }
|
||||
virtual void SetPinFunctions( const std::map<wxString, wxString>& aPinFunctions ) override
|
||||
{
|
||||
m_pinFunctions = aPinFunctions;
|
||||
}
|
||||
|
||||
virtual bool DisplayFootprint( const LIB_ID& aFPID ) override;
|
||||
virtual void DisplayFootprints( std::shared_ptr<FOOTPRINT> aFootprintA,
|
||||
std::shared_ptr<FOOTPRINT> aFootprintB ) override;
|
||||
|
@ -91,6 +96,7 @@ private:
|
|||
std::unique_ptr<BOARD> m_dummyBoard;
|
||||
std::unique_ptr<KIGFX::GAL_DISPLAY_OPTIONS> m_displayOptions;
|
||||
EDA_UNITS m_userUnits;
|
||||
std::map<wxString, wxString> m_pinFunctions;
|
||||
std::shared_ptr<FOOTPRINT> m_currentFootprint;
|
||||
std::shared_ptr<FOOTPRINT> m_otherFootprint;
|
||||
};
|
||||
|
|
|
@ -1148,10 +1148,10 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
|
|||
padNumber = UnescapeString( aPad->GetNumber() );
|
||||
|
||||
if( dynamic_cast<CVPCB_SETTINGS*>( viewer_settings() ) )
|
||||
netname = aPad->GetUnescapedShortNetname();
|
||||
netname = aPad->GetPinFunction();
|
||||
}
|
||||
|
||||
if( displayOpts )
|
||||
if( displayOpts && !dynamic_cast<CVPCB_SETTINGS*>( viewer_settings() ) )
|
||||
{
|
||||
if( displayOpts->m_NetNames == 1 || displayOpts->m_NetNames == 3 )
|
||||
netname = aPad->GetUnescapedShortNetname();
|
||||
|
|
Loading…
Reference in New Issue