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;
}

View File

@ -1,50 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2017 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
*/
#ifndef PAD_NAMING_H
#define PAD_NAMING_H
#include <pad.h>
/**
* The PAD_NAMING namespace contains helper functions for common operations
* to do with naming of #PAD objects.
*/
namespace PAD_NAMING
{
/**
* Check if a pad should be named.
*
* For example, NPTH or paste apertures normally do not have names, as they
* cannot be assigned to a netlist.
*
* @param aPad the pad to check
* @return true if the pad gets a name
*/
bool PadCanHaveName( const PAD& aPad );
} // namespace PAD_NAMING
#endif // PAD_NAMING_H

View File

@ -989,9 +989,9 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
if( m_pcbSettings.m_padNumbers )
{
const wxString& padName = aPad->GetName();
const wxString& padNumber = aPad->GetNumber();
textpos.y = -textpos.y;
double tsize = 1.5 * padsize.x / padName.Length();
double tsize = 1.5 * padsize.x / padNumber.Length();
tsize = std::min( tsize, size );
// Use a smaller text size to handle interline, pen size..
@ -1001,7 +1001,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
m_gal->SetGlyphSize( numsize );
m_gal->SetLineWidth( numsize.x / 12.0 );
m_gal->BitmapText( padName, textpos, 0.0 );
m_gal->BitmapText( padNumber, textpos, 0.0 );
}
m_gal->Restore();

View File

@ -106,9 +106,9 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
const bool useUTF8 = false;
const bool useQuoting = false;
gbr_metadata.SetPadName( aPad->GetName(), useUTF8, useQuoting );
gbr_metadata.SetPadName( aPad->GetNumber(), useUTF8, useQuoting );
if( !aPad->GetName().IsEmpty() )
if( !aPad->GetNumber().IsEmpty() )
gbr_metadata.SetPadPinFunction( aPad->GetPinFunction(), useUTF8, useQuoting );
gbr_metadata.SetNetName( aPad->GetNetname() );
@ -116,7 +116,7 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
// Some pads are mechanical pads ( through hole or smd )
// when this is the case, they have no pad name and/or are not plated.
// In this case gerber files have slightly different attributes.
if( aPad->GetAttribute() == PAD_ATTRIB::NPTH || aPad->GetName().IsEmpty() )
if( aPad->GetAttribute() == PAD_ATTRIB::NPTH || aPad->GetNumber().IsEmpty() )
gbr_metadata.m_NetlistMetadata.m_NotInNet = true;
if( !plotOnExternalCopperLayer )

View File

@ -2103,7 +2103,7 @@ void ALTIUM_PCB::ParsePads6Data( const CFB::CompoundFileReader& aReader,
PAD* pad = new PAD( footprint );
footprint->Add( pad, ADD_MODE::APPEND );
pad->SetName( elem.name );
pad->SetNumber( elem.name );
pad->SetNetCode( GetNetCode( elem.net ) );
pad->SetLocked( elem.is_locked );

View File

@ -733,7 +733,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryCoppers( const SYMDEF_PCB& aComponen
PAD* pad = new PAD( aFootprint );
pad->SetAttribute( PAD_ATTRIB::SMD );
pad->SetLayerSet( LSET( 1, copperLayer ) );
pad->SetName( anchorPad.Identifier.IsEmpty()
pad->SetNumber( anchorPad.Identifier.IsEmpty()
? wxString::Format( wxT( "%ld" ), anchorPad.ID )
: anchorPad.Identifier );
@ -774,7 +774,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryCoppers( const SYMDEF_PCB& aComponen
if( associatedPad.PCBonlyPad )
{
PAD* assocPad = getPadReference( aFootprint, padID );
assocPad->SetName( pad->GetName() );
assocPad->SetNumber( pad->GetNumber() );
++numRenames;
}
}
@ -938,8 +938,7 @@ PAD* CADSTAR_PCB_ARCHIVE_LOADER::getKiCadPad( const COMPONENT_PAD& aCadstarPad,
pad->SetLayerSet( padLayerSet );
pad->SetName( aCadstarPad.Identifier.IsEmpty() ?
pad->SetNumber( aCadstarPad.Identifier.IsEmpty() ?
wxString::Format( wxT( "%ld" ), aCadstarPad.ID ) :
aCadstarPad.Identifier );
@ -1605,7 +1604,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadComponents()
if( pinName.empty() )
pinName = wxString::Format( wxT( "%ld" ), pin.ID );
getPadReference( footprint, pin.ID )->SetName( pinName );
getPadReference( footprint, pin.ID )->SetNumber( pinName );
}
}
}
@ -1634,13 +1633,13 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadComponents()
// Find the pad in the footprint definition
PAD* kiPad = getPadReference( footprint, padEx.ID );
wxString padName = kiPad->GetName();
wxString padNumber = kiPad->GetNumber();
if( kiPad )
delete kiPad;
kiPad = getKiCadPad( csPad, footprint );
kiPad->SetName( padName );
kiPad->SetNumber( padNumber );
// Change the pointer in the footprint to the newly created pad
getPadReference( footprint, padEx.ID ) = kiPad;

View File

@ -1139,7 +1139,7 @@ void EAGLE_PLUGIN::loadElements( wxXmlNode* aElements )
// update the nets within the pads of the clone
for( PAD* pad : footprint->Pads() )
{
wxString pn_key = makeKey( e.name, pad->GetName() );
wxString pn_key = makeKey( e.name, pad->GetNumber() );
NET_MAP_CITER ni = m_pads_to_nets.find( pn_key );
if( ni != m_pads_to_nets.end() )
@ -2247,7 +2247,7 @@ void EAGLE_PLUGIN::packageHole( FOOTPRINT* aFootprint, wxXmlNode* aTree, bool aC
// Mechanical purpose only:
// no offset, no net name, no pad name allowed
// pad->SetOffset( wxPoint( 0, 0 ) );
// pad->SetName( wxEmptyString );
// pad->SetNumber( wxEmptyString );
wxPoint padpos( kicad_x( e.x ), kicad_y( e.y ) );
@ -2347,7 +2347,7 @@ void EAGLE_PLUGIN::packageSMD( FOOTPRINT* aFootprint, wxXmlNode* aTree ) const
void EAGLE_PLUGIN::transferPad( const EPAD_COMMON& aEaglePad, PAD* aPad ) const
{
aPad->SetName( FROM_UTF8( aEaglePad.name.c_str() ) );
aPad->SetNumber( FROM_UTF8( aEaglePad.name.c_str() ) );
// pad's "Position" is not relative to the footprint's,
// whereas Pos0 is relative to the footprint's but is the unrotated coordinate.

View File

@ -2240,7 +2240,7 @@ bool FABMASTER::loadFootprints( BOARD* aBoard )
else
newpad->SetY( pin->pin_y );
newpad->SetName( pin->pin_number );
newpad->SetNumber( pin->pin_number );
if( padstack == pads.end() )
{

View File

@ -558,7 +558,7 @@ FOOTPRINT* GPCB_FPL_CACHE::parseFOOTPRINT( LINE_READER* aLineReader )
// and set to the pin name of the netlist on instantiation. Many gEDA
// bare footprints use identical strings for name and number, so this
// can be a bit confusing.
pad->SetName( parameters[paramCnt-3] );
pad->SetNumber( parameters[paramCnt-3] );
int x1 = parseInt( parameters[2], conv_unit );
int x2 = parseInt( parameters[4], conv_unit );
@ -640,7 +640,7 @@ FOOTPRINT* GPCB_FPL_CACHE::parseFOOTPRINT( LINE_READER* aLineReader )
// Pcbnew pad name is used for electrical connection calculations.
// Accordingly it should be mapped to gEDA's pin/pad number,
// which is used for the same purpose.
pad->SetName( parameters[paramCnt-3] );
pad->SetNumber( parameters[paramCnt-3] );
wxPoint padPos( parseInt( parameters[2], conv_unit ),
parseInt( parameters[3], conv_unit ) );

View File

@ -1415,7 +1415,7 @@ void PCB_IO::format( const PAD* aPad, int aNestLevel ) const
}
m_out->Print( aNestLevel, "(pad %s %s %s",
m_out->Quotew( aPad->GetName() ).c_str(),
m_out->Quotew( aPad->GetNumber() ).c_str(),
type,
shape );

View File

@ -3927,7 +3927,7 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent )
pad->SetKeepTopBottom( false );
NeedSYMBOLorNUMBER();
pad->SetName( FromUTF8() );
pad->SetNumber( FromUTF8() );
T token = NextTok();
@ -4397,6 +4397,13 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent )
}
}
if( !pad->CanHaveNumber() )
{
// At some point it was possible to assign a number to aperture pads so we need to clean
// those out here.
pad->SetNumber( wxEmptyString );
}
return pad.release();
}

View File

@ -1344,16 +1344,15 @@ void LEGACY_PLUGIN::loadPAD( FOOTPRINT* aFootprint )
// e.g. "Sh "A2" C 520 520 0 0 900"
// or "Sh "1" R 157 1378 0 0 900"
// mypadname is LATIN1/CRYLIC for BOARD_FORMAT_VERSION 1,
// but for BOARD_FORMAT_VERSION 2, it is UTF8 from disk.
// So we have to go through two code paths. Moving forward
// padnames will be in UTF8 on disk, as are all KiCad strings on disk.
char mypadname[50];
// mypadnumber is LATIN1/CRYLIC for BOARD_FORMAT_VERSION 1, but for
// BOARD_FORMAT_VERSION 2, it is UTF8 from disk.
// Moving forward padnumbers will be in UTF8 on disk, as are all KiCad strings on disk.
char mypadnumber[50];
data = line + SZ( "Sh" ) + 1; // +1 skips trailing whitespace
// +1 trailing whitespace.
data = data + ReadDelimitedText( mypadname, data, sizeof(mypadname) ) + 1;
data = data + ReadDelimitedText( mypadnumber, data, sizeof( mypadnumber ) ) + 1;
while( isSpace( *data ) )
++data;
@ -1381,28 +1380,26 @@ void LEGACY_PLUGIN::loadPAD( FOOTPRINT* aFootprint )
}
// go through a wxString to establish a universal character set properly
wxString padname;
wxString padNumber;
if( m_loading_format_version == 1 )
{
// add 8 bit bytes, file format 1 was KiCad font type byte,
// simply promote those 8 bit bytes up into UNICODE. (subset of LATIN1)
const unsigned char* cp = (unsigned char*) mypadname;
const unsigned char* cp = (unsigned char*) mypadnumber;
while( *cp )
{
padname += *cp++; // unsigned, ls 8 bits only
}
padNumber += *cp++; // unsigned, ls 8 bits only
}
else
{
// version 2, which is UTF8.
padname = FROM_UTF8( mypadname );
padNumber = FROM_UTF8( mypadnumber );
}
// chances are both were ASCII, but why take chances?
pad->SetName( padname );
pad->SetNumber( padNumber );
pad->SetShape( static_cast<PAD_SHAPE>( padshape ) );
pad->SetSize( wxSize( size_x, size_y ) );
pad->SetDelta( wxSize( delta_x, delta_y ) );

View File

@ -263,7 +263,7 @@ void PCB_PAD::AddToFootprint( FOOTPRINT* aFootprint, int aRotation, bool aEncaps
// actually this is a thru-hole pad
pad->SetLayerSet( LSET::AllCuMask() | LSET( 2, B_Mask, F_Mask ) );
pad->SetName( m_name.text );
pad->SetNumber( m_name.text );
if( padShapeName == wxT( "Oval" )
|| padShapeName == wxT( "Ellipse" )

View File

@ -16,12 +16,18 @@
# SetPadName() is the old name for PAD::SetName()
# define it for compatibility
def SetPadName(self, aName):
return self.SetName(aName)
return self.SetNumber(aName)
def SetName(self, aName):
return self.SetNumber(aName)
# GetPadName() is the old name for PAD::GetName()
# define it for compatibility
def GetPadName(self):
return self.GetName()
return self.GetNumber()
def GetName(self):
return self.GetNumber()
# AddPrimitive() is the old name for D_PAD::AddPrimitivePoly(),
# PAD::AddPrimitiveSegment(), PAD::AddPrimitiveCircle(),

View File

@ -612,7 +612,7 @@ typedef std::map<wxString, int> PINMAP;
IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, FOOTPRINT* aFootprint )
{
PINMAP pinmap;
wxString padName;
wxString padNumber;
PCB_TYPE_COLLECTOR fpItems;
@ -676,17 +676,17 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, FOOTPRINT* aFootprint )
PIN* pin = new PIN( image );
padName = pad->GetName();
pin->pin_id = TO_UTF8( padName );
padNumber = pad->GetNumber();
pin->pin_id = TO_UTF8( padNumber );
if( padName != wxEmptyString && pinmap.find( padName ) == pinmap.end() )
if( padNumber != wxEmptyString && pinmap.find( padNumber ) == pinmap.end() )
{
pinmap[ padName ] = 0;
pinmap[ padNumber ] = 0;
}
else // pad name is a duplicate within this footprint
{
char buf[32];
int duplicates = ++pinmap[ padName ];
int duplicates = ++pinmap[ padNumber ];
sprintf( buf, "@%d", duplicates );

View File

@ -462,7 +462,7 @@ int BOARD_EDITOR_CONTROL::ExportNetlist( const TOOL_EVENT& aEvent )
if( !netname.IsEmpty() )
{
component->AddNet( pad->GetName(), netname, pad->GetPinFunction(),
component->AddNet( pad->GetNumber(), netname, pad->GetPinFunction(),
pad->GetPinType() );
}
}

View File

@ -46,7 +46,6 @@
#include <tools/tool_event_utils.h>
#include <tools/pcb_grid_helper.h>
#include <tools/pad_tool.h>
#include <pad_naming.h>
#include <view/view_controls.h>
#include <connectivity/connectivity_algo.h>
#include <connectivity/connectivity_items.h>
@ -2129,14 +2128,14 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
FOOTPRINT* parentFootprint = editFrame->GetBoard()->GetFirstFootprint();
dupe_item = parentFootprint->DuplicateItem( orig_item );
if( increment && item->Type() == PCB_PAD_T
&& PAD_NAMING::PadCanHaveName( *static_cast<PAD*>( dupe_item ) ) )
if( increment && dupe_item->Type() == PCB_PAD_T
&& static_cast<PAD*>( dupe_item )->CanHaveNumber() )
{
PAD_TOOL* padTool = m_toolMgr->GetTool<PAD_TOOL>();
wxString padName = padTool->GetLastPadName();
padName = parentFootprint->GetNextPadName( padName );
padTool->SetLastPadName( padName );
static_cast<PAD*>( dupe_item )->SetName( padName );
wxString padNumber = padTool->GetLastPadNumber();
padNumber = parentFootprint->GetNextPadNumber( padNumber );
padTool->SetLastPadNumber( padNumber );
static_cast<PAD*>( dupe_item )->SetNumber( padNumber );
}
}
else if( orig_item->GetParent() && orig_item->GetParent()->Type() == PCB_FOOTPRINT_T )

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2017-2021 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
@ -40,7 +40,6 @@
#include <tools/pcb_selection_conditions.h>
#include <tools/edit_tool.h>
#include <dialogs/dialog_enum_pads.h>
#include <pad_naming.h>
#include <widgets/infobar.h>
PAD_TOOL::PAD_TOOL() :
@ -58,7 +57,7 @@ PAD_TOOL::~PAD_TOOL()
void PAD_TOOL::Reset( RESET_REASON aReason )
{
if( aReason == MODEL_RELOAD )
m_lastPadName = wxT( "1" );
m_lastPadNumber = wxT( "1" );
m_padCopied = false;
m_editPad = niluuid;
@ -301,7 +300,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
VECTOR2I oldCursorPos; // store the previous mouse cursor position, during mouse drag
std::list<PAD*> selectedPads;
BOARD_COMMIT commit( frame() );
std::map<wxString, std::pair<int, wxString>> oldNames;
std::map<wxString, std::pair<int, wxString>> oldNumbers;
bool isFirstPoint = true; // used to be sure oldCursorPos will be initialized at least once.
STATUS_TEXT_POPUP statusPopup( frame() );
@ -389,10 +388,10 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
else
newval = seqPadNum++;
wxString newName = wxString::Format( wxT( "%s%d" ), padPrefix, newval );
oldNames[newName] = { newval, pad->GetName() };
pad->SetName( newName );
SetLastPadName( newName );
wxString newNumber = wxString::Format( wxT( "%s%d" ), padPrefix, newval );
oldNumbers[newNumber] = { newval, pad->GetNumber() };
pad->SetNumber( newNumber );
SetLastPadNumber( newNumber );
pad->SetSelected();
getView()->Update( pad );
@ -408,15 +407,15 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
// ... or restore the old name if it was enumerated and clicked again
else if( pad->IsSelected() && evt->IsClick( BUT_LEFT ) )
{
auto it = oldNames.find( pad->GetName() );
wxASSERT( it != oldNames.end() );
auto it = oldNumbers.find( pad->GetNumber() );
wxASSERT( it != oldNumbers.end() );
if( it != oldNames.end() )
if( it != oldNumbers.end() )
{
storedPadNumbers.push_back( it->second.first );
pad->SetName( it->second.second );
SetLastPadName( it->second.second );
oldNames.erase( it );
pad->SetNumber( it->second.second );
SetLastPadNumber( it->second.second );
oldNumbers.erase( it );
int newval = storedPadNumbers.front();
@ -484,12 +483,12 @@ int PAD_TOOL::PlacePad( const TOOL_EVENT& aEvent )
pad->ImportSettingsFrom( *(m_frame->GetDesignSettings().m_Pad_Master.get()) );
if( PAD_NAMING::PadCanHaveName( *pad ) )
if( pad->CanHaveNumber() )
{
wxString padName = m_padTool->GetLastPadName();
padName = m_board->GetFirstFootprint()->GetNextPadName( padName );
pad->SetName( padName );
m_padTool->SetLastPadName( padName );
wxString padNumber = m_padTool->GetLastPadNumber();
padNumber = m_board->GetFirstFootprint()->GetNextPadNumber( padNumber );
pad->SetNumber( padNumber );
m_padTool->SetLastPadNumber( padNumber );
}
return std::unique_ptr<BOARD_ITEM>( pad );

View File

@ -59,8 +59,8 @@ public:
*/
int EditPad( const TOOL_EVENT& aEvent );
wxString GetLastPadName() const { return m_lastPadName; }
void SetLastPadName( const wxString& aPadName ) { m_lastPadName = aPadName; }
wxString GetLastPadNumber() const { return m_lastPadNumber; }
void SetLastPadNumber( const wxString& aPadNumber ) { m_lastPadNumber = aPadNumber; }
private:
///< Bind handlers to corresponding TOOL_ACTIONs.
@ -78,7 +78,7 @@ private:
PCB_LAYER_ID explodePad( PAD* aPad );
void recombinePad( PAD* aPad );
wxString m_lastPadName;
wxString m_lastPadNumber;
bool m_padCopied; // Indicates there are valid settings in the Master Pad object
bool m_wasHighContrast;

View File

@ -35,7 +35,7 @@ set( QA_PCBNEW_SRCS
test_array_pad_name_provider.cpp
test_graphics_import_mgr.cpp
test_lset.cpp
test_pad_naming.cpp
test_pad_numbering.cpp
test_libeval_compiler.cpp
test_tracks_cleaner.cpp
test_zone_filler.cpp

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2018-2021 KiCad Developers, see CHANGELOG.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
@ -21,14 +21,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file test_array_pad_name_provider.cpp
* Test suite for the #ARRAY_PAD_NAME_PROVIDER class
*/
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <array_pad_name_provider.h> // UUT
#include <array_pad_number_provider.h> // UUT
#include <common.h> // make_unique
@ -46,7 +41,7 @@ static std::unique_ptr<FOOTPRINT> FootprintWithPads( const std::vector<wxString>
{
std::unique_ptr<PAD> pad = std::make_unique<PAD>( footprint.get() );
pad->SetName( name );
pad->SetNumber( name );
footprint->Add( pad.release() );
}
@ -57,7 +52,7 @@ static std::unique_ptr<FOOTPRINT> FootprintWithPads( const std::vector<wxString>
/**
* Declare the test suite
*/
BOOST_AUTO_TEST_SUITE( ArrayPadNameProv )
BOOST_AUTO_TEST_SUITE( ArrayPadNumberProv )
struct APNP_CASE
@ -66,7 +61,7 @@ struct APNP_CASE
bool m_using_footprint;
std::vector<wxString> m_existing_pads;
std::unique_ptr<ARRAY_OPTIONS> m_arr_opts;
std::vector<wxString> m_exp_arr_names;
std::vector<wxString> m_expected_numbers;
};
@ -117,21 +112,20 @@ std::vector<APNP_CASE> GetFootprintAPNPCases()
/**
* Check that an #ARRAY_PAD_NAME_PROVIDER provides the right names
* Check that an #ARRAY_PAD_NUMBER_PROVIDER provides the right names
* @param aProvider the provider
* @param aExpNames ordered list of expected names
*/
void CheckPadNameProvider( ARRAY_PAD_NAME_PROVIDER& aProvider, std::vector<wxString> aExpNames )
void CheckPadNumberProvider( ARRAY_PAD_NUMBER_PROVIDER& aProvider,
std::vector<wxString> aExpectedNumbers )
{
std::vector<wxString> got_names;
std::vector<wxString> got_numbers;
for( unsigned i = 0; i < aExpNames.size(); ++i )
{
got_names.push_back( aProvider.GetNextPadName() );
}
for( unsigned i = 0; i < aExpectedNumbers.size(); ++i )
got_numbers.push_back( aProvider.GetNextPadNumber() );
BOOST_CHECK_EQUAL_COLLECTIONS(
aExpNames.begin(), aExpNames.end(), got_names.begin(), got_names.end() );
BOOST_CHECK_EQUAL_COLLECTIONS( aExpectedNumbers.begin(), aExpectedNumbers.end(),
got_numbers.begin(), got_numbers.end() );
}
@ -146,9 +140,9 @@ BOOST_AUTO_TEST_CASE( FootprintCases )
if( c.m_using_footprint )
footprint = FootprintWithPads( c.m_existing_pads );
ARRAY_PAD_NAME_PROVIDER apnp( footprint.get(), *c.m_arr_opts );
ARRAY_PAD_NUMBER_PROVIDER apnp( footprint.get(), *c.m_arr_opts );
CheckPadNameProvider( apnp, c.m_exp_arr_names );
CheckPadNumberProvider( apnp, c.m_expected_numbers );
}
}
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018-2021 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
@ -22,10 +22,9 @@
*/
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <board.h>
#include <footprint.h>
#include <pad_naming.h>
#include <pad.h>
struct PAD_FIXTURE
{
@ -70,21 +69,21 @@ struct PAD_FIXTURE
};
BOOST_FIXTURE_TEST_SUITE( PadNaming, PAD_FIXTURE )
BOOST_FIXTURE_TEST_SUITE( PadNumbering, PAD_FIXTURE )
/**
* Check what gets names and what doesn't
*/
BOOST_AUTO_TEST_CASE( CanName )
BOOST_AUTO_TEST_CASE( CanNumber )
{
auto npth = MakeNPTH();
BOOST_CHECK_EQUAL( false, PAD_NAMING::PadCanHaveName( npth ) );
BOOST_CHECK_EQUAL( false, npth.CanHaveNumber() );
auto aperture = MakeAperture();
BOOST_CHECK_EQUAL( false, PAD_NAMING::PadCanHaveName( aperture ) );
BOOST_CHECK_EQUAL( false, aperture.CanHaveNumber() );
auto smd = MakeSmd();
BOOST_CHECK_EQUAL( true, PAD_NAMING::PadCanHaveName( smd ) );
BOOST_CHECK_EQUAL( true, smd.CanHaveNumber() );
}

View File

@ -61,7 +61,7 @@ BOOST_FIXTURE_TEST_CASE( BasicZoneFills, ZONE_FILL_TEST_FIXTURE )
for( PAD* pad : m_board->Footprints()[0]->Pads() )
{
if( pad->GetName() == "2" || pad->GetName() == "4" || pad->GetName() == "6" )
if( pad->GetNumber() == "2" || pad->GetNumber() == "4" || pad->GetNumber() == "6" )
pad->SetSize( pad->GetSize() + wxSize( delta, delta ) );
}
@ -110,17 +110,17 @@ BOOST_FIXTURE_TEST_CASE( BasicZoneFills, ZONE_FILL_TEST_FIXTURE )
PAD* pad_b = dynamic_cast<PAD*>( item_b );
PCB_TRACK* trk_b = dynamic_cast<PCB_TRACK*>( item_b );
if( pad_a && pad_a->GetName() == "2" ) foundPad2Error = true;
else if( pad_a && pad_a->GetName() == "4" ) foundPad4Error = true;
else if( pad_a && pad_a->GetName() == "6" ) foundPad6Error = true;
else if( pad_b && pad_b->GetName() == "2" ) foundPad2Error = true;
else if( pad_b && pad_b->GetName() == "4" ) foundPad4Error = true;
else if( pad_b && pad_b->GetName() == "6" ) foundPad6Error = true;
else if( trk_a && trk_a->m_Uuid == arc8 ) foundArc8Error = true;
else if( trk_a && trk_a->m_Uuid == arc12 ) foundArc12Error = true;
else if( trk_b && trk_b->m_Uuid == arc8 ) foundArc8Error = true;
else if( trk_b && trk_b->m_Uuid == arc12 ) foundArc12Error = true;
else foundOtherError = true;
if( pad_a && pad_a->GetNumber() == "2" ) foundPad2Error = true;
else if( pad_a && pad_a->GetNumber() == "4" ) foundPad4Error = true;
else if( pad_a && pad_a->GetNumber() == "6" ) foundPad6Error = true;
else if( pad_b && pad_b->GetNumber() == "2" ) foundPad2Error = true;
else if( pad_b && pad_b->GetNumber() == "4" ) foundPad4Error = true;
else if( pad_b && pad_b->GetNumber() == "6" ) foundPad6Error = true;
else if( trk_a && trk_a->m_Uuid == arc8 ) foundArc8Error = true;
else if( trk_a && trk_a->m_Uuid == arc12 ) foundArc12Error = true;
else if( trk_b && trk_b->m_Uuid == arc8 ) foundArc8Error = true;
else if( trk_b && trk_b->m_Uuid == arc12 ) foundArc12Error = true;
else foundOtherError = true;
}
} );