- Do not autonumber NPTH pads on add in module editor (keep the number blank)
Factored out the next-pad-number function
This commit is contained in:
parent
8c5292207f
commit
29dcb49c62
|
@ -123,14 +123,34 @@ void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw )
|
||||||
aPad->GetParent()->SetLastEditTime();
|
aPad->GetParent()->SetLastEditTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Compute the 'next' pad number for autoincrement
|
||||||
|
* aPadName is the last pad name used */
|
||||||
|
static wxString GetNextPadName( wxString aPadName )
|
||||||
|
{
|
||||||
|
// Automatically increment the current pad number.
|
||||||
|
int num = 0;
|
||||||
|
int ponder = 1;
|
||||||
|
|
||||||
|
// Trim and extract the trailing numeric part
|
||||||
|
while( aPadName.Len()
|
||||||
|
&& aPadName.Last() >= '0'
|
||||||
|
&& aPadName.Last() <= '9' )
|
||||||
|
{
|
||||||
|
num += ( aPadName.Last() - '0' ) * ponder;
|
||||||
|
aPadName.RemoveLast();
|
||||||
|
ponder *= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
num++; // Use next number for the new pad
|
||||||
|
aPadName << num;
|
||||||
|
|
||||||
|
return aPadName;
|
||||||
|
}
|
||||||
|
|
||||||
/* Add a new pad to aModule.
|
/* Add a new pad to aModule.
|
||||||
*/
|
*/
|
||||||
void PCB_BASE_FRAME::AddPad( MODULE* aModule, bool draw )
|
void PCB_BASE_FRAME::AddPad( MODULE* aModule, bool draw )
|
||||||
{
|
{
|
||||||
// Last used pad name (pad num)
|
|
||||||
wxString lastPadName = GetDesignSettings().m_Pad_Master.GetPadName();
|
|
||||||
|
|
||||||
m_Pcb->m_Status_Pcb = 0;
|
m_Pcb->m_Status_Pcb = 0;
|
||||||
aModule->SetLastEditTime();
|
aModule->SetLastEditTime();
|
||||||
|
|
||||||
|
@ -152,22 +172,15 @@ void PCB_BASE_FRAME::AddPad( MODULE* aModule, bool draw )
|
||||||
RotatePoint( &pos0, -aModule->GetOrientation() );
|
RotatePoint( &pos0, -aModule->GetOrientation() );
|
||||||
pad->SetPos0( pos0 );
|
pad->SetPos0( pos0 );
|
||||||
|
|
||||||
// Automatically increment the current pad number.
|
/* NPTH pads take empty pad number (since they can't be connected),
|
||||||
long num = 0;
|
* other pads get incremented from the last one edited */
|
||||||
int ponder = 1;
|
wxString padName;
|
||||||
|
if( pad->GetAttribute() != PAD_HOLE_NOT_PLATED ) {
|
||||||
while( lastPadName.Len() && lastPadName.Last() >= '0' && lastPadName.Last() <= '9' )
|
padName = GetNextPadName( GetDesignSettings()
|
||||||
{
|
.m_Pad_Master.GetPadName() );
|
||||||
num += ( lastPadName.Last() - '0' ) * ponder;
|
|
||||||
lastPadName.RemoveLast();
|
|
||||||
ponder *= 10;
|
|
||||||
}
|
}
|
||||||
|
pad->SetPadName( padName );
|
||||||
num++; // Use next number for the new pad
|
GetDesignSettings().m_Pad_Master.SetPadName( padName );
|
||||||
lastPadName << num;
|
|
||||||
pad->SetPadName( lastPadName );
|
|
||||||
|
|
||||||
GetDesignSettings().m_Pad_Master.SetPadName(lastPadName);
|
|
||||||
|
|
||||||
aModule->CalculateBoundingBox();
|
aModule->CalculateBoundingBox();
|
||||||
SetMsgPanel( pad );
|
SetMsgPanel( pad );
|
||||||
|
|
Loading…
Reference in New Issue