7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-14 17:09:36 +00:00

Clear numbers from non-numberable pads and don't run DRC on them.

This was also the last straw on the misnamed PAD::GetName() and
PAD::SetName(), which are now PAD::GetNumber() and PAD::SetNumber().

Fixes https://gitlab.com/kicad/code/kicad/issues/9017
This commit is contained in:
Jeff Young 2021-08-24 00:10:21 +01:00
parent baab2e6119
commit e6ca9837a2
47 changed files with 253 additions and 329 deletions

View File

@ -721,7 +721,7 @@ void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event )
reporter.Report( wxString::Format( _( "Net %s\tNetClass %s\tPadName %s" ),
pad->GetNet()->GetNetname(),
pad->GetNet()->GetNetClassName(),
pad->GetName() ) );
pad->GetNumber() ) );
}
}
break;

View File

@ -269,7 +269,7 @@ set( PCBNEW_CLASS_SRCS
action_plugin.cpp
array_creator.cpp
array_pad_name_provider.cpp
array_pad_number_provider.cpp
build_BOM_from_board.cpp
cleanup_item.cpp
convert_drawsegment_list_to_polygon.cpp
@ -294,11 +294,8 @@ set( PCBNEW_CLASS_SRCS
load_select_footprint.cpp
menubar_footprint_editor.cpp
menubar_pcb_editor.cpp
pad_naming.cpp
pcb_base_edit_frame.cpp
pcb_layer_box_selector.cpp
# pcb_draw_panel_gal.cpp
# pcb_view.cpp
pcb_edit_frame.cpp
pcbnew_config.cpp
pcbnew_printout.cpp

View File

@ -24,11 +24,10 @@
#include "array_creator.h"
#include <array_pad_name_provider.h>
#include <array_pad_number_provider.h>
#include <board_commit.h>
#include <pcb_group.h>
#include <pad_naming.h>
#include <pad.h>
#include <dialogs/dialog_create_array.h>
/**
@ -69,7 +68,7 @@ void ARRAY_CREATOR::Invoke()
BOARD_COMMIT commit( &m_parent );
ARRAY_PAD_NAME_PROVIDER pad_name_provider( fp, *array_opts );
ARRAY_PAD_NUMBER_PROVIDER pad_number_provider( fp, *array_opts );
for ( int i = 0; i < m_selection.Size(); ++i )
{
@ -185,10 +184,10 @@ void ARRAY_CREATOR::Invoke()
{
PAD& pad = static_cast<PAD&>( *this_item );
if( PAD_NAMING::PadCanHaveName( pad ) )
if( pad.CanHaveNumber() )
{
wxString newName = pad_name_provider.GetNextPadName();
pad.SetName( newName );
wxString newNumber = pad_number_provider.GetNextPadNumber();
pad.SetNumber( newNumber );
}
}
}

View File

@ -21,13 +21,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <array_pad_name_provider.h>
#include <array_pad_number_provider.h>
#include <pad.h>
ARRAY_PAD_NAME_PROVIDER::ARRAY_PAD_NAME_PROVIDER( const FOOTPRINT* aFootprint,
const ARRAY_OPTIONS& aArrayOpts )
ARRAY_PAD_NUMBER_PROVIDER::ARRAY_PAD_NUMBER_PROVIDER( const FOOTPRINT* aFootprint,
const ARRAY_OPTIONS& aArrayOpts )
: m_arrayOpts( aArrayOpts )
{
// start by numbering the first new item
@ -46,27 +46,28 @@ ARRAY_PAD_NAME_PROVIDER::ARRAY_PAD_NAME_PROVIDER( const FOOTPRINT* aFootprint,
{
// reserve the name of each existing pad
for( PAD* pad : aFootprint->Pads() )
m_existing_pad_names.insert( pad->GetName() );
m_existing_pad_numbers.insert( pad->GetNumber() );
}
}
}
wxString ARRAY_PAD_NAME_PROVIDER::GetNextPadName()
wxString ARRAY_PAD_NUMBER_PROVIDER::GetNextPadNumber()
{
return getNextName( m_current_pad_index, m_existing_pad_names );
return getNextNumber( m_current_pad_index, m_existing_pad_numbers );
}
wxString ARRAY_PAD_NAME_PROVIDER::getNextName( int& aIndex, const std::set<wxString>& aExisting )
wxString ARRAY_PAD_NUMBER_PROVIDER::getNextNumber( int& aIndex,
const std::set<wxString>& aExisting )
{
wxString next_name;
wxString next_number;
do
{
next_name = m_arrayOpts.GetItemNumber( aIndex );
next_number = m_arrayOpts.GetItemNumber( aIndex );
aIndex++;
} while( aExisting.count( next_name ) != 0 );
} while( aExisting.count( next_number ) != 0 );
return next_name;
return next_number;
}

View File

@ -29,35 +29,34 @@
#include <footprint.h>
/**
* Simple class that sequentially provides names from an #ARRAY_OPTIONS
* object, making sure that they do not conflict with names already existing
* in a #FOOTPRINT.
* Simple class that sequentially provides numbers from an #ARRAY_OPTIONS object, making sure
* that they do not conflict with numbers already existing in a #FOOTPRINT.
*/
class ARRAY_PAD_NAME_PROVIDER
class ARRAY_PAD_NUMBER_PROVIDER
{
public:
/**
* @param aFootprint the footprint to gather existing names from (nullptr for no footprint)
* @oaram aArrayOpts the array options that provide the candidate names
* @param aFootprint the footprint to gather existing numbers from (nullptr for no footprint)
* @oaram aArrayOpts the array options that provide the candidate numbers
*/
ARRAY_PAD_NAME_PROVIDER( const FOOTPRINT* aFootprint, const ARRAY_OPTIONS& aArrayOpts );
ARRAY_PAD_NUMBER_PROVIDER( const FOOTPRINT* aFootprint, const ARRAY_OPTIONS& aArrayOpts );
/**
* Get the next available pad name.
*/
wxString GetNextPadName();
wxString GetNextPadNumber();
private:
/**
* Get the next name from a given index/list combo
* Get the next number from a given index/list combo
* @param aIndex index to start at, will be updated
* @param aExisting the set of existing names to skip
* @return the first name found that's not in aExisting
* @param aExisting the set of existing numbers to skip
* @return the first number found that's not in aExisting
*/
wxString getNextName( int& aIndex, const std::set<wxString>& aExisting );
wxString getNextNumber( int& aIndex, const std::set<wxString>& aExisting );
const ARRAY_OPTIONS& m_arrayOpts;
std::set<wxString> m_existing_pad_names;
std::set<wxString> m_existing_pad_numbers;
int m_current_pad_index;
};

View File

@ -39,7 +39,7 @@ void FROM_TO_CACHE::buildEndpointList( )
for( PAD* pad : footprint->Pads() )
{
FT_ENDPOINT ent;
ent.name = footprint->GetReference() + "-" + pad->GetName();
ent.name = footprint->GetReference() + "-" + pad->GetNumber();
ent.parent = pad;
m_ftEndpoints.push_back( ent );
ent.name = footprint->GetReference();
@ -140,7 +140,7 @@ int FROM_TO_CACHE::cacheFromToPaths( const wxString& aFrom, const wxString& aTo
int count = 0;
auto netName = path.from->GetNetname();
wxString fromName = path.from->GetParent()->GetReference() + "-" + path.from->GetName();
wxString fromName = path.from->GetParent()->GetReference() + "-" + path.from->GetNumber();
const KICAD_T onlyRouting[] = { PCB_PAD_T, PCB_ARC_T, PCB_VIA_T, PCB_TRACE_T, EOT };
@ -157,7 +157,7 @@ int FROM_TO_CACHE::cacheFromToPaths( const wxString& aFrom, const wxString& aTo
const PAD *pad = static_cast<const PAD*>( pitem );
wxString toName = pad->GetParent()->GetReference() + "-" + pad->GetName();
wxString toName = pad->GetParent()->GetReference() + "-" + pad->GetNumber();
for ( const auto& endpoint : m_ftEndpoints )

View File

@ -159,7 +159,7 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
footprint = pcb->FindFootprintByReference( modName );
if( footprint )
pad = footprint->FindPadByName( pinName );
pad = footprint->FindPadByNumber( pinName );
if( pad )
netcode = pad->GetNetCode();
@ -434,7 +434,7 @@ std::string FormatProbeItem( BOARD_ITEM* aItem )
case PCB_PAD_T:
{
footprint = static_cast<FOOTPRINT*>( aItem->GetParent() );
wxString pad = static_cast<PAD*>( aItem )->GetName();
wxString pad = static_cast<PAD*>( aItem )->GetNumber();
return StrPrintf( "$PART: \"%s\" $PAD: \"%s\"", TO_UTF8( footprint->GetReference() ),
TO_UTF8( pad ) );
@ -535,7 +535,7 @@ void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
if( !netname.IsEmpty() )
{
component->AddNet( pad->GetName(), netname, pad->GetPinFunction(),
component->AddNet( pad->GetNumber(), netname, pad->GetPinFunction(),
pad->GetPinType() );
}
}

View File

@ -520,8 +520,8 @@ void PCB_EDIT_FRAME::ExchangeFootprint( FOOTPRINT* aExisting, FOOTPRINT* aNew,
if( !pad->IsOnCopperLayer() )
continue;
// Pads with no name are never connected to a net
if( pad->GetName().IsEmpty() )
// Pads with no numbers are never connected to a net
if( pad->GetNumber().IsEmpty() )
continue;
// Search for a similar pad on a copper layer, to reuse net info
@ -529,7 +529,7 @@ void PCB_EDIT_FRAME::ExchangeFootprint( FOOTPRINT* aExisting, FOOTPRINT* aNew,
while( true )
{
pad_model = aExisting->FindPadByName( pad->GetName(), last_pad );
pad_model = aExisting->FindPadByNumber( pad->GetNumber(), last_pad );
if( !pad_model )
break;

View File

@ -115,7 +115,7 @@ void PCB_BASE_FRAME::ShowPadPropertiesDialog( PAD* aPad )
PAD_TOOL* padTools = m_toolManager->GetTool<PAD_TOOL>();
if( padTools )
padTools->SetLastPadName( aPad->GetName() );
padTools->SetLastPadNumber( aPad->GetNumber() );
}
}
}
@ -515,7 +515,7 @@ void DIALOG_PAD_PROPERTIES::initValues()
m_FlippedWarningSizer->Show( m_isFlipped );
m_PadNumCtrl->SetValue( m_dummyPad->GetName() );
m_PadNumCtrl->SetValue( m_dummyPad->GetNumber() );
m_PadNetSelector->SetSelectedNetcode( m_dummyPad->GetNetCode() );
// Display current pad parameters units:
@ -981,7 +981,7 @@ void DIALOG_PAD_PROPERTIES::PadTypeSelected( wxCommandEvent& event )
}
else if( m_PadNumCtrl->GetValue().IsEmpty() && m_currentPad )
{
m_PadNumCtrl->ChangeValue( m_currentPad->GetName() );
m_PadNumCtrl->ChangeValue( m_currentPad->GetNumber() );
m_PadNetSelector->SetSelectedNetcode( m_currentPad->GetNetCode() );
}
@ -1583,7 +1583,7 @@ bool DIALOG_PAD_PROPERTIES::TransferDataFromWindow()
m_currentPad->SetRemoveUnconnected( m_padMaster->GetRemoveUnconnected() );
m_currentPad->SetKeepTopBottom( m_padMaster->GetKeepTopBottom() );
m_currentPad->SetName( m_padMaster->GetName() );
m_currentPad->SetNumber( m_padMaster->GetNumber() );
int padNetcode = NETINFO_LIST::UNCONNECTED;
@ -1779,7 +1779,7 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( PAD* aPad )
aPad->SetPadToDieLength( 0 );
aPad->SetOrientation( m_OrientValue * 10.0 );
aPad->SetName( m_PadNumCtrl->GetValue() );
aPad->SetNumber( m_PadNumCtrl->GetValue() );
aPad->SetNetCode( m_PadNetSelector->GetSelectedNetcode() );
int chamfers = 0;
@ -1848,7 +1848,7 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( PAD* aPad )
case PAD_ATTRIB::NPTH:
// Mechanical purpose only:
// no net name, no pad name allowed
aPad->SetName( wxEmptyString );
aPad->SetNumber( wxEmptyString );
aPad->SetNetCode( NETINFO_LIST::UNCONNECTED );
break;

View File

@ -357,7 +357,7 @@ bool DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange( const std::vector<PAD*>& cha
PAD* pad = *changingPads.begin();
msg.Printf( _( "Changing the net will also update %s pad %s to %s." ),
pad->GetParent()->GetReference(),
pad->GetName(),
pad->GetNumber(),
m_netSelector->GetValue() );
}
else if( changingPads.size() == 2 )
@ -366,9 +366,9 @@ bool DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange( const std::vector<PAD*>& cha
PAD* pad2 = *( ++changingPads.begin() );
msg.Printf( _( "Changing the net will also update %s pad %s and %s pad %s to %s." ),
pad1->GetParent()->GetReference(),
pad1->GetName(),
pad1->GetNumber(),
pad2->GetParent()->GetReference(),
pad2->GetName(),
pad2->GetNumber(),
m_netSelector->GetValue() );
}
else

View File

@ -132,7 +132,10 @@ void DRC_TEST_PROVIDER_LVS::testFootprints( NETLIST& aNetlist )
if( m_drcEngine->IsErrorLimitExceeded( DRCE_NET_CONFLICT ) )
break;
const COMPONENT_NET& sch_net = component->GetNet( pad->GetName() );
if( !pad->CanHaveNumber() )
continue;
const COMPONENT_NET& sch_net = component->GetNet( pad->GetNumber() );
const wxString& pcb_netname = pad->GetNetname();
if( !pcb_netname.IsEmpty() && sch_net.GetPinName().IsEmpty() )
@ -174,7 +177,7 @@ void DRC_TEST_PROVIDER_LVS::testFootprints( NETLIST& aNetlist )
const COMPONENT_NET& sch_net = component->GetNet( jj );
if( !footprint->FindPadByName( sch_net.GetPinName() ) )
if( !footprint->FindPadByNumber( sch_net.GetPinName() ) )
{
m_msg.Printf( _( "No pad found for pin %s in schematic." ),
sch_net.GetPinName() );

View File

@ -108,7 +108,7 @@ static void build_pad_testpoints( BOARD *aPcb, std::vector <D356_RECORD>& aRecor
if( rk.access != -1 )
{
rk.netname = pad->GetNetname();
rk.pin = pad->GetName();
rk.pin = pad->GetNumber();
rk.refdes = footprint->GetReference();
rk.midpoint = false; // XXX MAYBE need to be computed (how?)
const wxSize& drill = pad->GetDrillSize();

View File

@ -375,12 +375,12 @@ std::string PLACE_FILE_EXPORTER::GenReportData()
std::sort( sortedPads.begin(), sortedPads.end(),
[]( PAD* a, PAD* b ) -> bool
{
return StrNumCmp( a->GetName(), b->GetName(), true ) < 0;
return StrNumCmp( a->GetNumber(), b->GetNumber(), true ) < 0;
});
for( PAD* pad : sortedPads )
{
sprintf( line, "$PAD \"%s\"\n", TO_UTF8( pad->GetName() ) );
sprintf( line, "$PAD \"%s\"\n", TO_UTF8( pad->GetNumber() ) );
buffer += line;
int layer = 0;

View File

@ -793,7 +793,7 @@ static void CreateShapesSection( FILE* aFile, BOARD* aPcb )
* all pads need to be marked as TOP to use the padstack information correctly.
*/
layer = "TOP";
pinname = pad->GetName();
pinname = pad->GetNumber();
if( pinname.IsEmpty() )
pinname = wxT( "none" );
@ -944,7 +944,7 @@ static void CreateSignalsSection( FILE* aFile, BOARD* aPcb )
msg.Printf( wxT( "NODE \"%s\" \"%s\"" ),
escapeString( footprint->GetReference() ),
escapeString( pad->GetName() ) );
escapeString( pad->GetNumber() ) );
fputs( TO_UTF8( msg ), aFile );
fputs( "\n", aFile );

View File

@ -448,7 +448,7 @@ bool HYPERLYNX_EXPORTER::writeNetObjects( const std::vector<BOARD_ITEM*>& aObjec
if( ref.IsEmpty() )
ref = "EMPTY";
wxString padName = pad->GetName();
wxString padName = pad->GetNumber();
if( padName.IsEmpty() )
padName = "1";

View File

@ -337,7 +337,7 @@ static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD
kplate = IDF3::PTH;
// hole type
tstr = TO_UTF8( pad->GetName() );
tstr = TO_UTF8( pad->GetNumber() );
if( tstr.empty() || !tstr.compare( "0" ) || !tstr.compare( "~" )
|| ( kplate == IDF3::NPTH )

View File

@ -235,7 +235,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
gbr_metadata.SetApertureAttrib(
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_PAD1_POSITION );
gbr_metadata.SetPadName( pad1->GetName(), allowUtf8, true );
gbr_metadata.SetPadName( pad1->GetNumber(), allowUtf8, true );
gbr_metadata.SetPadPinFunction( pad1->GetPinFunction(), allowUtf8, true );
@ -276,7 +276,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
if( !pad->IsOnLayer( aLayer ) )
continue;
gbr_metadata.SetPadName( pad->GetName(), allowUtf8, true );
gbr_metadata.SetPadName( pad->GetNumber(), allowUtf8, true );
gbr_metadata.SetPadPinFunction( pad->GetPinFunction(), allowUtf8, true );
@ -336,7 +336,7 @@ void PLACEFILE_GERBER_WRITER::findPads1( std::vector<PAD*>& aPadList, FOOTPRINT*
if( !pad->IsOnLayer( m_layer ) )
continue;
if( pad->GetName() == "1" || pad->GetName() == "A1")
if( pad->GetNumber() == "1" || pad->GetNumber() == "A1")
aPadList.push_back( pad );
}
}

View File

@ -1009,7 +1009,7 @@ bool FOOTPRINT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
}
PAD* FOOTPRINT::FindPadByName( const wxString& aPadName, PAD* aSearchAfterMe ) const
PAD* FOOTPRINT::FindPadByNumber( const wxString& aPadNumber, PAD* aSearchAfterMe ) const
{
bool can_select = aSearchAfterMe ? false : true;
@ -1021,7 +1021,7 @@ PAD* FOOTPRINT::FindPadByName( const wxString& aPadName, PAD* aSearchAfterMe ) c
continue;
}
if( can_select && pad->GetName() == aPadName )
if( can_select && pad->GetNumber() == aPadNumber )
return pad;
}
@ -1085,7 +1085,7 @@ unsigned FOOTPRINT::GetPadCount( INCLUDE_NPTH_T aIncludeNPTH ) const
unsigned FOOTPRINT::GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH ) const
{
std::set<wxString> usedNames;
std::set<wxString> usedNumbers;
// Create a set of used pad numbers
for( PAD* pad : m_pads )
@ -1097,22 +1097,20 @@ unsigned FOOTPRINT::GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH ) const
// Skip pads with no name, because they are usually "mechanical"
// pads, not "electrical" pads
if( pad->GetName().IsEmpty() )
if( pad->GetNumber().IsEmpty() )
continue;
if( !aIncludeNPTH )
{
// skip NPTH
if( pad->GetAttribute() == PAD_ATTRIB::NPTH )
{
continue;
}
}
usedNames.insert( pad->GetName() );
usedNumbers.insert( pad->GetNumber() );
}
return usedNames.size();
return usedNumbers.size();
}
@ -1760,20 +1758,20 @@ BOARD_ITEM* FOOTPRINT::DuplicateItem( const BOARD_ITEM* aItem, bool aAddToFootpr
}
wxString FOOTPRINT::GetNextPadName( const wxString& aLastPadName ) const
wxString FOOTPRINT::GetNextPadNumber( const wxString& aLastPadNumber ) const
{
std::set<wxString> usedNames;
std::set<wxString> usedNumbers;
// Create a set of used pad numbers
for( PAD* pad : m_pads )
usedNames.insert( pad->GetName() );
usedNumbers.insert( pad->GetNumber() );
// Pad names aren't technically reference designators, but the formatting is close enough
// Pad numbers aren't technically reference designators, but the formatting is close enough
// for these to give us what we need.
wxString prefix = UTIL::GetRefDesPrefix( aLastPadName );
int num = GetTrailingInt( aLastPadName );
wxString prefix = UTIL::GetRefDesPrefix( aLastPadNumber );
int num = GetTrailingInt( aLastPadNumber );
while( usedNames.count( wxString::Format( "%s%d", prefix, num ) ) )
while( usedNumbers.count( wxString::Format( "%s%d", prefix, num ) ) )
num++;
return wxString::Format( "%s%d", prefix, num );
@ -2093,8 +2091,8 @@ bool FOOTPRINT::cmp_drawings::operator()( const BOARD_ITEM* aFirst,
bool FOOTPRINT::cmp_pads::operator()( const PAD* aFirst, const PAD* aSecond ) const
{
if( aFirst->GetName() != aSecond->GetName() )
return StrNumCmp( aFirst->GetName(), aSecond->GetName() ) < 0;
if( aFirst->GetNumber() != aSecond->GetNumber() )
return StrNumCmp( aFirst->GetNumber(), aSecond->GetNumber() ) < 0;
if( aFirst->m_Uuid != aSecond->m_Uuid ) // shopuld be always the case foer valid boards
return aFirst->m_Uuid < aSecond->m_Uuid;

View File

@ -480,15 +480,15 @@ public:
void SetProperty( const wxString& aKey, const wxString& aVal ) { m_properties[ aKey ] = aVal; }
/**
* Return a #PAD with a matching name.
* Return a #PAD with a matching number.
*
* @note Names may not be unique depending on how the footprint was created.
* @note Numbers may not be unique depending on how the footprint was created.
*
* @param aPadName the pad name to find.
* @param aPadNumber the pad number to find.
* @param aSearchAfterMe = not nullptr to find a pad living after aAfterMe
* @return the first matching named #PAD is returned or NULL if not found.
* @return the first matching numbered #PAD is returned or NULL if not found.
*/
PAD* FindPadByName( const wxString& aPadName, PAD* aSearchAfterMe = nullptr ) const;
PAD* FindPadByNumber( const wxString& aPadNumber, PAD* aSearchAfterMe = nullptr ) const;
/**
* Get a pad at \a aPosition on \a aLayerMask in the footprint.
@ -523,13 +523,13 @@ public:
unsigned GetUniquePadCount( INCLUDE_NPTH_T aIncludeNPTH = INCLUDE_NPTH_T(INCLUDE_NPTH) ) const;
/**
* Return the next available pad name in the footprint.
* Return the next available pad number in the footprint.
*
* @param aFillSequenceGaps true if the numbering should "fill in" gaps in the sequence,
* else return the highest value + 1
* @return the next available pad name
* @return the next available pad number
*/
wxString GetNextPadName( const wxString& aLastPadName ) const;
wxString GetNextPadNumber( const wxString& aLastPadName ) const;
double GetArea( int aPadding = 0 ) const;

View File

@ -133,7 +133,7 @@ FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprint
break;
case MICROWAVE_FOOTPRINT_SHAPE::STUB: //Stub :
pad->SetName( wxT( "1" ) );
pad->SetNumber( wxT( "1" ) );
pad = *( it + 1 );
pad->SetY0( -( gap_size + pad->GetSize().y ) / 2 );
pad->SetSize( wxSize( pad->GetSize().x, gap_size ) );
@ -200,7 +200,6 @@ FOOTPRINT* MICROWAVE_TOOL::createBaseFootprint( const wxString& aValue,
// Create 2 pads used in gaps and stubs. The gap is between these 2 pads
// the stub is the pad 2
wxString Line;
int pad_num = 1;
while( aPadCount-- )
@ -217,8 +216,7 @@ FOOTPRINT* MICROWAVE_TOOL::createBaseFootprint( const wxString& aValue,
pad->SetAttribute( PAD_ATTRIB::SMD );
pad->SetLayerSet( F_Cu );
Line.Printf( wxT( "%d" ), pad_num );
pad->SetName( Line );
pad->SetNumber( wxString::Format( wxT( "%d" ), pad_num ) );
pad_num++;
}

View File

@ -441,7 +441,7 @@ FOOTPRINT* MICROWAVE_TOOL::createMicrowaveInductor( MICROWAVE_INDUCTOR_PATTERN&
footprint->Add( pad );
pad->SetName( "1" );
pad->SetNumber( "1" );
pad->SetPosition( aInductorPattern.m_End );
pad->SetPos0( pad->GetPosition() - footprint->GetPosition() );
@ -457,7 +457,7 @@ FOOTPRINT* MICROWAVE_TOOL::createMicrowaveInductor( MICROWAVE_INDUCTOR_PATTERN&
footprint->Add( newpad );
pad = newpad;
pad->SetName( "2" );
pad->SetNumber( "2" );
pad->SetPosition( aInductorPattern.m_Start );
pad->SetPos0( pad->GetPosition() - footprint->GetPosition() );

View File

@ -412,7 +412,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
// At this point, the component footprint is updated. Now update the nets.
for( PAD* pad : aFootprint->Pads() )
{
const COMPONENT_NET& net = aNewComponent->GetNet( pad->GetName() );
const COMPONENT_NET& net = aNewComponent->GetNet( pad->GetNumber() );
wxString pinFunction;
wxString pinType;
@ -451,23 +451,23 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
{
msg.Printf( _( "Disconnect %s pin %s." ),
aFootprint->GetReference(),
pad->GetName() );
pad->GetNumber() );
}
else
{
msg.Printf( _( "Disconnected %s pin %s." ),
aFootprint->GetReference(),
pad->GetName() );
pad->GetNumber() );
}
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
}
else if( m_warnForNoNetPads && pad->IsOnCopperLayer() && !pad->GetName().IsEmpty() )
else if( m_warnForNoNetPads && pad->IsOnCopperLayer() && !pad->GetNumber().IsEmpty() )
{
// pad is connectable but has no net found in netlist
msg.Printf( _( "No net found for symbol %s pin %s." ),
aFootprint->GetReference(),
pad->GetName() );
pad->GetNumber() );
m_reporter->Report( msg, RPT_SEVERITY_WARNING);
}
@ -529,7 +529,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
{
msg.Printf( _( "Reconnect %s pin %s from %s to %s."),
aFootprint->GetReference(),
pad->GetName(),
pad->GetNumber(),
UnescapeString( pad->GetNetname() ),
UnescapeString( netName ) );
}
@ -537,7 +537,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
{
msg.Printf( _( "Reconnected %s pin %s from %s to %s."),
aFootprint->GetReference(),
pad->GetName(),
pad->GetNumber(),
UnescapeString( pad->GetNetname() ),
UnescapeString( netName ) );
}
@ -548,15 +548,14 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
{
msg.Printf( _( "Connect %s pin %s to %s."),
aFootprint->GetReference(),
pad->GetName(),
pad->GetNumber(),
UnescapeString( netName ) );
}
else
{
msg.Printf( _( "Connected %s pin %s to %s."),
aFootprint->GetReference(),
pad->GetName(),
pad->GetNumber(),
UnescapeString( netName ) );
}
}
@ -873,7 +872,7 @@ bool BOARD_NETLIST_UPDATER::testConnectivity( NETLIST& aNetlist,
// wrong or missing.
wxString msg;
wxString padname;
wxString padNumber;
for( int i = 0; i < (int) aNetlist.GetCount(); i++ )
{
@ -886,16 +885,15 @@ bool BOARD_NETLIST_UPDATER::testConnectivity( NETLIST& aNetlist,
// Explore all pins/pads in component
for( unsigned jj = 0; jj < component->GetNetCount(); jj++ )
{
const COMPONENT_NET& net = component->GetNet( jj );
padname = net.GetPinName();
padNumber = component->GetNet( jj ).GetPinName();
if( footprint->FindPadByName( padname ) )
if( footprint->FindPadByNumber( padNumber ) )
continue; // OK, pad found
// not found: bad footprint, report error
msg.Printf( _( "%s pad %s not found in %s." ),
component->GetReference(),
padname,
padNumber,
footprint->GetFPID().Format().wx_str() );
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
++m_errorCount;

View File

@ -113,7 +113,7 @@ PAD::PAD( const PAD& aOther ) :
SetPadToDieLength( aOther.GetPadToDieLength() );
SetPosition( aOther.GetPosition() );
SetPos0( aOther.GetPos0() );
SetName( aOther.GetName() );
SetNumber( aOther.GetNumber() );
SetPinFunction( aOther.GetPinFunction() );
SetSubRatsnest( aOther.GetSubRatsnest() );
m_effectiveBoundingRadius = aOther.m_effectiveBoundingRadius;
@ -131,7 +131,7 @@ PAD& PAD::operator=( const PAD &aOther )
SetPadToDieLength( aOther.GetPadToDieLength() );
SetPosition( aOther.GetPosition() );
SetPos0( aOther.GetPos0() );
SetName( aOther.GetName() );
SetNumber( aOther.GetNumber() );
SetPinFunction( aOther.GetPinFunction() );
SetSubRatsnest( aOther.GetSubRatsnest() );
m_effectiveBoundingRadius = aOther.m_effectiveBoundingRadius;
@ -142,6 +142,20 @@ PAD& PAD::operator=( const PAD &aOther )
}
bool PAD::CanHaveNumber() const
{
// Aperture pads don't get a number
if( IsAperturePad() )
return false;
// NPTH pads don't get numbers
if( GetAttribute() == PAD_ATTRIB::NPTH )
return false;
return true;
}
bool PAD::IsLocked() const
{
if( GetParent() && static_cast<FOOTPRINT*>( GetParent() )->IsLocked() )
@ -857,7 +871,7 @@ void PAD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>&
if( parentFootprint )
aList.emplace_back( _( "Footprint" ), parentFootprint->GetReference() );
aList.emplace_back( _( "Pad" ), m_name );
aList.emplace_back( _( "Pad" ), m_number );
if( !GetPinFunction().IsEmpty() )
aList.emplace_back( _( "Pin Name" ), GetPinFunction() );
@ -1106,7 +1120,7 @@ wxString PAD::ShowPadAttr() const
wxString PAD::GetSelectMenuText( EDA_UNITS aUnits ) const
{
if( GetName().IsEmpty() )
if( GetNumber().IsEmpty() )
{
if( GetAttribute() == PAD_ATTRIB::SMD || GetAttribute() == PAD_ATTRIB::CONN )
{
@ -1125,14 +1139,14 @@ wxString PAD::GetSelectMenuText( EDA_UNITS aUnits ) const
if( GetAttribute() == PAD_ATTRIB::SMD || GetAttribute() == PAD_ATTRIB::CONN )
{
return wxString::Format( _( "Pad %s of %s on %s" ),
GetName(),
GetNumber(),
GetParent()->GetReference(),
layerMaskDescribe() );
}
else
{
return wxString::Format( _( "Through hole pad %s of %s" ),
GetName(),
GetNumber(),
GetParent()->GetReference() );
}
}
@ -1221,7 +1235,7 @@ void PAD::ViewGetLayers( int aLayers[], int& aCount ) const
wxString msg;
msg.Printf( wxT( "footprint %s, pad %s: could not find valid layer for pad" ),
GetParent() ? GetParent()->GetReference() : "<null>",
GetName().IsEmpty() ? "(unnamed)" : GetName() );
GetNumber().IsEmpty() ? "(unnumbered)" : GetNumber() );
wxLogWarning( msg );
}
#endif
@ -1476,7 +1490,7 @@ static struct PAD_DESC
propMgr.AddProperty( shape );
propMgr.AddProperty( new PROPERTY<PAD, wxString>( _HKI( "Pad Number" ),
&PAD::SetName, &PAD::GetName ) );
&PAD::SetNumber, &PAD::GetNumber ) );
propMgr.AddProperty( new PROPERTY<PAD, wxString>( _HKI( "Pin Name" ),
&PAD::SetPinFunction, &PAD::GetPinFunction ) );
propMgr.AddProperty( new PROPERTY<PAD, wxString>( _HKI( "Pin Type" ),

View File

@ -123,11 +123,15 @@ public:
bool IsFlipped() const;
/**
* Set the pad name (sometimes called pad number, although it can be an array reference
* like AA12).
* Set the pad number (note that it can be alphanumeric, such as the array reference "AA12").
*/
void SetName( const wxString& aName ) { m_name = aName; }
const wxString& GetName() const { return m_name; }
void SetNumber( const wxString& aNumber ) { m_number = aNumber; }
const wxString& GetNumber() const { return m_number; }
/**
* Indicates whether or not the pad can have a number. (NPTH and SMD aperture pads can not.)
*/
bool CanHaveNumber() const;
/**
* Set the pad function (pin name in schematic)
@ -148,7 +152,7 @@ public:
bool SameLogicalPadAs( const PAD* other ) const
{
// hide tricks behind sensible API
return GetParent() == other->GetParent() && m_name == other->m_name;
return GetParent() == other->GetParent() && m_number == other->m_number;
}
/**
@ -670,7 +674,7 @@ private:
ERROR_LOC aErrorLoc ) const;
private:
wxString m_name; // Pad name (pin number in schematic)
wxString m_number; // Pad name (pin number in schematic)
wxString m_pinFunction; // Pin name in schematic
wxString m_pinType; // Pin electrical type in schematic

View File

@ -1,37 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 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 "pad_naming.h"
bool PAD_NAMING::PadCanHaveName( const PAD& aPad )
{
// Aperture pads don't get a number
if( aPad.IsAperturePad() )
return false;
// NPTH pads don't get numbers
if( aPad.GetAttribute() == PAD_ATTRIB::NPTH )
return false;
return true;
}

Some files were not shown because too many files have changed in this diff Show More