Exchange footprints: remove duplicate code, and keep the "Locked" attribute state after exchange/replace.
This commit is contained in:
parent
ad10218a58
commit
d63c017a0a
|
@ -2386,7 +2386,12 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
|
|||
else
|
||||
newFootprint->SetPath( footprint->GetPath() );
|
||||
|
||||
footprint->CopyNetlistSettings( newFootprint );
|
||||
// Copy placement and pad net names.
|
||||
// optionally, copy or not local settings (like local clearances)
|
||||
// if the second param is "true", previous values will be used.
|
||||
// if "false", default library values will be used
|
||||
footprint->CopyNetlistSettings( newFootprint, true );
|
||||
|
||||
Remove( footprint );
|
||||
Add( newFootprint, ADD_APPEND );
|
||||
footprint = newFootprint;
|
||||
|
|
|
@ -377,7 +377,7 @@ BOARD_ITEM* MODULE::Remove( BOARD_ITEM* aBoardItem )
|
|||
}
|
||||
|
||||
|
||||
void MODULE::CopyNetlistSettings( MODULE* aModule )
|
||||
void MODULE::CopyNetlistSettings( MODULE* aModule, bool aCopyLocalSettings )
|
||||
{
|
||||
// Don't do anything foolish like trying to copy to yourself.
|
||||
wxCHECK_RET( aModule != NULL && aModule != this, wxT( "Cannot copy to NULL or yourself." ) );
|
||||
|
@ -391,6 +391,10 @@ void MODULE::CopyNetlistSettings( MODULE* aModule )
|
|||
if( aModule->GetOrientation() != GetOrientation() )
|
||||
aModule->Rotate( aModule->GetPosition(), GetOrientation() );
|
||||
|
||||
aModule->SetLocked( IsLocked() );
|
||||
|
||||
if( aCopyLocalSettings )
|
||||
{
|
||||
aModule->SetLocalSolderMaskMargin( GetLocalSolderMaskMargin() );
|
||||
aModule->SetLocalClearance( GetLocalClearance() );
|
||||
aModule->SetLocalSolderPasteMargin( GetLocalSolderPasteMargin() );
|
||||
|
@ -398,13 +402,14 @@ void MODULE::CopyNetlistSettings( MODULE* aModule )
|
|||
aModule->SetZoneConnection( GetZoneConnection() );
|
||||
aModule->SetThermalWidth( GetThermalWidth() );
|
||||
aModule->SetThermalGap( GetThermalGap() );
|
||||
}
|
||||
|
||||
for( D_PAD* pad = Pads(); pad; pad = pad->Next() )
|
||||
{
|
||||
D_PAD* newPad = aModule->FindPadByName( pad->GetPadName() );
|
||||
|
||||
if( newPad )
|
||||
pad->CopyNetlistSettings( newPad );
|
||||
pad->CopyNetlistSettings( newPad, aCopyLocalSettings );
|
||||
}
|
||||
|
||||
// Not sure about copying description, keywords, 3D models or any other
|
||||
|
|
|
@ -570,15 +570,20 @@ public:
|
|||
/**
|
||||
* Function CopyNetlistSettings
|
||||
* copies the netlist settings to \a aModule.
|
||||
* Used to copy some footprint parameters when replacing a footprint by an other
|
||||
* footprint when reading a netlist, or in exchange footprint dialog
|
||||
*
|
||||
* The netlist settings are all of the #MODULE settings not define by a #MODULE in
|
||||
* a netlist. These setting include position, orientation, local clearances, ets.
|
||||
* a netlist. These setting include placement prms (position, orientation, side)
|
||||
* and optionally local prms( clearances, zone connection type, etc).
|
||||
* The reference designator, value, path, and physical geometry settings are not
|
||||
* copied.
|
||||
*
|
||||
* @param aModule is the #MODULE to copy the settings to.
|
||||
* @param aCopyLocalSettings = false to copy only module placement
|
||||
* true to also copy local prms
|
||||
*/
|
||||
void CopyNetlistSettings( MODULE* aModule );
|
||||
void CopyNetlistSettings( MODULE* aModule, bool aCopyLocalSettings );
|
||||
|
||||
/**
|
||||
* static function IsLibNameValid
|
||||
|
|
|
@ -460,13 +460,15 @@ void D_PAD::Copy( D_PAD* source )
|
|||
}
|
||||
|
||||
|
||||
void D_PAD::CopyNetlistSettings( D_PAD* aPad )
|
||||
void D_PAD::CopyNetlistSettings( D_PAD* aPad, bool aCopyLocalSettings )
|
||||
{
|
||||
// Don't do anything foolish like trying to copy to yourself.
|
||||
wxCHECK_RET( aPad != NULL && aPad != this, wxT( "Cannot copy to NULL or yourself." ) );
|
||||
|
||||
aPad->SetNetCode( GetNetCode() );
|
||||
|
||||
if( aCopyLocalSettings )
|
||||
{
|
||||
aPad->SetLocalClearance( m_LocalClearance );
|
||||
aPad->SetLocalSolderMaskMargin( m_LocalSolderMaskMargin );
|
||||
aPad->SetLocalSolderPasteMargin( m_LocalSolderPasteMargin );
|
||||
|
@ -475,6 +477,7 @@ void D_PAD::CopyNetlistSettings( D_PAD* aPad )
|
|||
aPad->SetThermalWidth( m_ThermalWidth );
|
||||
aPad->SetThermalGap( m_ThermalGap );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
|
||||
|
|
|
@ -472,15 +472,20 @@ public:
|
|||
|
||||
/**
|
||||
* Function CopyNetlistSettings
|
||||
* copies the netlist settings to \a aPad.
|
||||
* copies the netlist settings to \a aPad, and the net name.
|
||||
* Used to copy some pad parameters when replacing a footprint by an other
|
||||
* footprint when reading a netlist, or in exchange footprint dialog
|
||||
*
|
||||
* The netlist settings are all of the #D_PAD settings not define by a #D_PAD in
|
||||
* a netlist. These setting include local clearances, net names, etc. The pad
|
||||
* physical geometry settings are not copied.
|
||||
* a netlist.
|
||||
* The copied settings are the net name and optionally include local clearance, etc.
|
||||
* The pad physical geometry settings are not copied.
|
||||
*
|
||||
* @param aPad is the #D_PAD to copy the settings to.
|
||||
* @param aCopyLocalSettings = false to copy only the net name
|
||||
* true to also copy local prms
|
||||
*/
|
||||
void CopyNetlistSettings( D_PAD* aPad );
|
||||
void CopyNetlistSettings( D_PAD* aPad, bool aCopyLocalSettings );
|
||||
|
||||
#if defined(DEBUG)
|
||||
virtual void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
|
||||
|
|
|
@ -430,21 +430,12 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule,
|
|||
* when all modules are on board
|
||||
*/
|
||||
PlaceModule( aNewModule, NULL, true );
|
||||
aNewModule->SetPosition( aOldModule->GetPosition() );
|
||||
|
||||
// Flip footprint if needed
|
||||
if( aOldModule->GetLayer() != aNewModule->GetLayer() )
|
||||
{
|
||||
aNewModule->Flip( aNewModule->GetPosition() );
|
||||
}
|
||||
// Copy full placement and pad net names (when possible)
|
||||
// but not local settings like clearances (use library values)
|
||||
aOldModule->CopyNetlistSettings( aNewModule, false );
|
||||
|
||||
// Rotate footprint if needed
|
||||
if( aOldModule->GetOrientation() != aNewModule->GetOrientation() )
|
||||
{
|
||||
Rotate_Module( NULL, aNewModule, aOldModule->GetOrientation(), false );
|
||||
}
|
||||
|
||||
// Update reference and value
|
||||
// Copy reference and value
|
||||
aNewModule->SetReference( aOldModule->GetReference() );
|
||||
aNewModule->SetValue( aOldModule->GetValue() );
|
||||
|
||||
|
@ -452,18 +443,6 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule,
|
|||
aNewModule->SetTimeStamp( aOldModule->GetTimeStamp() );
|
||||
aNewModule->SetPath( aOldModule->GetPath() );
|
||||
|
||||
// Update pad netnames (when possible)
|
||||
for( D_PAD* pad = aNewModule->Pads(); pad != NULL; pad = pad->Next() )
|
||||
{
|
||||
pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
|
||||
|
||||
for( D_PAD* old_pad = aOldModule->Pads(); old_pad != NULL; old_pad = old_pad->Next() )
|
||||
{
|
||||
if( pad->PadNameEqual( old_pad ) )
|
||||
pad->SetNetCode( old_pad->GetNetCode() );
|
||||
}
|
||||
}
|
||||
|
||||
if( aUndoPickList )
|
||||
{
|
||||
GetBoard()->Remove( aOldModule );
|
||||
|
|
Loading…
Reference in New Issue