Pad export/import settings functions: remove duplicate code.
This commit is contained in:
parent
9d43817db8
commit
dd5b024903
|
@ -1036,3 +1036,59 @@ wxString LayerMaskDescribe( const BOARD *aBoard, LSET aMask )
|
||||||
|
|
||||||
return layerInfo;
|
return layerInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void D_PAD::ImportSettingsFromMaster( const D_PAD& aMasterPad )
|
||||||
|
{
|
||||||
|
SetShape( aMasterPad.GetShape() );
|
||||||
|
SetLayerSet( aMasterPad.GetLayerSet() );
|
||||||
|
SetAttribute( aMasterPad.GetAttribute() );
|
||||||
|
|
||||||
|
// The pad orientation, for historical reasons is the
|
||||||
|
// pad rotation + parent rotation.
|
||||||
|
// So we have to manage this parent rotation
|
||||||
|
double pad_rot = aMasterPad.GetOrientation();
|
||||||
|
|
||||||
|
if( aMasterPad.GetParent() )
|
||||||
|
pad_rot -= aMasterPad.GetParent()->GetOrientation();
|
||||||
|
|
||||||
|
if( GetParent() )
|
||||||
|
pad_rot += GetParent()->GetOrientation();
|
||||||
|
|
||||||
|
SetOrientation( pad_rot );
|
||||||
|
|
||||||
|
SetSize( aMasterPad.GetSize() );
|
||||||
|
SetDelta( wxSize( 0, 0 ) );
|
||||||
|
SetOffset( aMasterPad.GetOffset() );
|
||||||
|
SetDrillSize( aMasterPad.GetDrillSize() );
|
||||||
|
SetDrillShape( aMasterPad.GetDrillShape() );
|
||||||
|
SetRoundRectRadiusRatio( aMasterPad.GetRoundRectRadiusRatio() );
|
||||||
|
|
||||||
|
switch( aMasterPad.GetShape() )
|
||||||
|
{
|
||||||
|
case PAD_SHAPE_TRAPEZOID:
|
||||||
|
SetDelta( aMasterPad.GetDelta() );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PAD_SHAPE_CIRCLE:
|
||||||
|
// ensure size.y == size.x
|
||||||
|
SetSize( wxSize( GetSize().x, GetSize().x ) );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch( aMasterPad.GetAttribute() )
|
||||||
|
{
|
||||||
|
case PAD_ATTRIB_SMD:
|
||||||
|
case PAD_ATTRIB_CONN:
|
||||||
|
// These pads do not have hole (they are expected to be only on one
|
||||||
|
// external copper layer)
|
||||||
|
SetDrillSize( wxSize( 0, 0 ) );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -107,6 +107,14 @@ public:
|
||||||
|
|
||||||
MODULE* GetParent() const { return (MODULE*) m_Parent; }
|
MODULE* GetParent() const { return (MODULE*) m_Parent; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Imports the pad settings from aMasterPad.
|
||||||
|
* The result is "this" has the same settinds (sizes, shapes ... )
|
||||||
|
* as aMasterPad
|
||||||
|
* @param aMasterPad = the template pad
|
||||||
|
*/
|
||||||
|
void ImportSettingsFromMaster( const D_PAD& aMasterPad );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if the pad has a footprint parent flipped
|
* @return true if the pad has a footprint parent flipped
|
||||||
* (on the back/bottom layer)
|
* (on the back/bottom layer)
|
||||||
|
|
|
@ -50,13 +50,9 @@ void PCB_BASE_FRAME::Export_Pad_Settings( D_PAD* aPad )
|
||||||
|
|
||||||
SetMsgPanel( aPad );
|
SetMsgPanel( aPad );
|
||||||
|
|
||||||
D_PAD& mp = GetDesignSettings().m_Pad_Master;
|
D_PAD& masterPad = GetDesignSettings().m_Pad_Master;
|
||||||
// Copy all settings. Some of them are not used, but they break anything
|
|
||||||
mp = *aPad;
|
masterPad.ImportSettingsFromMaster( *aPad );
|
||||||
// The pad orientation, for historical reasons is the
|
|
||||||
// pad rotation + parent rotation.
|
|
||||||
// store only the pad rotation.
|
|
||||||
mp.SetOrientation( aPad->GetOrientation() - aPad->GetParent()->GetOrientation() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,46 +69,9 @@ void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw )
|
||||||
aPad->ClearFlags( DO_NOT_DRAW );
|
aPad->ClearFlags( DO_NOT_DRAW );
|
||||||
}
|
}
|
||||||
|
|
||||||
D_PAD& mp = GetDesignSettings().m_Pad_Master;
|
const D_PAD& mp = GetDesignSettings().m_Pad_Master;
|
||||||
|
|
||||||
aPad->SetShape( mp.GetShape() );
|
aPad->ImportSettingsFromMaster( mp );
|
||||||
aPad->SetLayerSet( mp.GetLayerSet() );
|
|
||||||
aPad->SetAttribute( mp.GetAttribute() );
|
|
||||||
aPad->SetOrientation( mp.GetOrientation() + aPad->GetParent()->GetOrientation() );
|
|
||||||
aPad->SetSize( mp.GetSize() );
|
|
||||||
aPad->SetDelta( wxSize( 0, 0 ) );
|
|
||||||
aPad->SetOffset( mp.GetOffset() );
|
|
||||||
aPad->SetDrillSize( mp.GetDrillSize() );
|
|
||||||
aPad->SetDrillShape( mp.GetDrillShape() );
|
|
||||||
aPad->SetRoundRectRadiusRatio( mp.GetRoundRectRadiusRatio() );
|
|
||||||
|
|
||||||
switch( mp.GetShape() )
|
|
||||||
{
|
|
||||||
case PAD_SHAPE_TRAPEZOID:
|
|
||||||
aPad->SetDelta( mp.GetDelta() );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PAD_SHAPE_CIRCLE:
|
|
||||||
// ensure size.y == size.x
|
|
||||||
aPad->SetSize( wxSize( aPad->GetSize().x, aPad->GetSize().x ) );
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch( mp.GetAttribute() )
|
|
||||||
{
|
|
||||||
case PAD_ATTRIB_SMD:
|
|
||||||
case PAD_ATTRIB_CONN:
|
|
||||||
// These pads do not have hole (they are expected to be only on one
|
|
||||||
// external copper layer)
|
|
||||||
aPad->SetDrillSize( wxSize( 0, 0 ) );
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( aDraw )
|
if( aDraw )
|
||||||
m_canvas->RefreshDrawingRect( aPad->GetBoundingBox() );
|
m_canvas->RefreshDrawingRect( aPad->GetBoundingBox() );
|
||||||
|
|
|
@ -132,76 +132,6 @@ bool PAD_TOOL::Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function doCopyPadSettings
|
|
||||||
*
|
|
||||||
* Copy a given pad setting to the destination pad. Normally, the destination
|
|
||||||
* would be a board reference settings master pad.
|
|
||||||
*/
|
|
||||||
static void doCopyPadSettings( const D_PAD& aSrc, D_PAD& aDest )
|
|
||||||
{
|
|
||||||
// Copy all settings. Some of them are not used, but they break anything
|
|
||||||
aDest = aSrc;
|
|
||||||
|
|
||||||
// The pad orientation, for historical reasons is the
|
|
||||||
// pad rotation + parent rotation.
|
|
||||||
// store only the pad rotation.
|
|
||||||
aDest.SetOrientation( aSrc.GetOrientation() - aSrc.GetParent()->GetOrientation() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function doApplyPadSettings
|
|
||||||
*
|
|
||||||
* Apply pad settings from a "reference" source to a destination.
|
|
||||||
* Often, the reference source will be a board reference settings
|
|
||||||
* master pad.
|
|
||||||
*/
|
|
||||||
static void doApplyPadSettings( const D_PAD& aSrc, D_PAD& aDest )
|
|
||||||
{
|
|
||||||
const auto& destParent = *aDest.GetParent();
|
|
||||||
|
|
||||||
aDest.SetShape( aSrc.GetShape() );
|
|
||||||
aDest.SetLayerSet( aSrc.GetLayerSet() );
|
|
||||||
aDest.SetAttribute( aSrc.GetAttribute() );
|
|
||||||
aDest.SetOrientation( aSrc.GetOrientation() + destParent.GetOrientation() );
|
|
||||||
aDest.SetSize( aSrc.GetSize() );
|
|
||||||
aDest.SetDelta( wxSize( 0, 0 ) );
|
|
||||||
aDest.SetOffset( aSrc.GetOffset() );
|
|
||||||
aDest.SetDrillSize( aSrc.GetDrillSize() );
|
|
||||||
aDest.SetDrillShape( aSrc.GetDrillShape() );
|
|
||||||
aDest.SetRoundRectRadiusRatio( aSrc.GetRoundRectRadiusRatio() );
|
|
||||||
|
|
||||||
switch( aSrc.GetShape() )
|
|
||||||
{
|
|
||||||
case PAD_SHAPE_TRAPEZOID:
|
|
||||||
aDest.SetDelta( aSrc.GetDelta() );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PAD_SHAPE_CIRCLE:
|
|
||||||
// ensure size.y == size.x
|
|
||||||
aDest.SetSize( wxSize( aDest.GetSize().x, aDest.GetSize().x ) );
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch( aSrc.GetAttribute() )
|
|
||||||
{
|
|
||||||
case PAD_ATTRIB_SMD:
|
|
||||||
case PAD_ATTRIB_CONN:
|
|
||||||
// These pads do not have hole (they are expected to be only on one
|
|
||||||
// external copper layer)
|
|
||||||
aDest.SetDrillSize( wxSize( 0, 0 ) );
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int PAD_TOOL::applyPadSettings( const TOOL_EVENT& aEvent )
|
int PAD_TOOL::applyPadSettings( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
auto& selTool = *m_toolMgr->GetTool<SELECTION_TOOL>();
|
auto& selTool = *m_toolMgr->GetTool<SELECTION_TOOL>();
|
||||||
|
@ -220,9 +150,8 @@ int PAD_TOOL::applyPadSettings( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
commit.Modify( item );
|
commit.Modify( item );
|
||||||
|
|
||||||
auto& destPad = static_cast<D_PAD&>( *item );
|
D_PAD& destPad = static_cast<D_PAD&>( *item );
|
||||||
|
destPad.ImportSettingsFromMaster( masterPad );
|
||||||
doApplyPadSettings( masterPad, destPad );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,8 +181,7 @@ int PAD_TOOL::copyPadSettings( const TOOL_EVENT& aEvent )
|
||||||
if( item->Type() == PCB_PAD_T )
|
if( item->Type() == PCB_PAD_T )
|
||||||
{
|
{
|
||||||
const auto& selPad = static_cast<const D_PAD&>( *item );
|
const auto& selPad = static_cast<const D_PAD&>( *item );
|
||||||
|
masterPad.ImportSettingsFromMaster( selPad );
|
||||||
doCopyPadSettings( selPad, masterPad );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +237,7 @@ static void globalChangePadSettings( BOARD& board,
|
||||||
commit.Modify( pad );
|
commit.Modify( pad );
|
||||||
|
|
||||||
// Apply source pad settings to this pad
|
// Apply source pad settings to this pad
|
||||||
doApplyPadSettings( aSrcPad, *pad );
|
pad->ImportSettingsFromMaster( aSrcPad );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue