Missed some other uses of m_startItem in previous commit.

Fixes https://gitlab.com/kicad/code/kicad/issues/12592
This commit is contained in:
Jeff Young 2022-10-07 13:20:56 +01:00
parent cbb997a3b5
commit bc58480e24
4 changed files with 77 additions and 31 deletions

View File

@ -62,6 +62,9 @@ bool DIALOG_PNS_DIFF_PAIR_DIMENSIONS::TransferDataFromWindow()
m_sizes.SetDiffPairViaGap( m_viaGap.GetValue() );
m_sizes.SetDiffPairWidth( m_traceWidth.GetValue() );
m_sizes.SetDiffPairGapSource( _( "user choice" ) );
m_sizes.SetDiffPairWidthSource( _( "user choice" ) );
return true;
}

View File

@ -547,9 +547,11 @@ bool PNS_KICAD_IFACE_BASE::ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM*
m_startLayer = aStartItem->Layer();
aSizes.SetMinClearance( bds.m_MinClearance );
aSizes.SetClearanceSource( _( "board minimum clearance" ) );
int trackWidth = bds.m_TrackMinWidth;
bool found = false;
aSizes.SetWidthSource( _( "board minimum track width" ) );
if( bds.m_UseConnectedTrackWidth && !bds.m_TempOverrideTrackWidth && aStartItem != nullptr )
{
@ -569,8 +571,6 @@ bool PNS_KICAD_IFACE_BASE::ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM*
if( trackWidth == constraint.m_Value.Opt() )
aSizes.SetWidthSource( constraint.m_RuleName );
else
aSizes.SetWidthSource( _( "board minimum width" ) );
}
}
@ -582,8 +582,6 @@ bool PNS_KICAD_IFACE_BASE::ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM*
aSizes.SetWidthSource( _( "netclass 'Default'" ) );
else if( trackWidth == bds.GetCurrentTrackWidth() )
aSizes.SetWidthSource( _( "user choice" ) );
else
aSizes.SetWidthSource( _( "board minimum width" ) );
}
aSizes.SetTrackWidth( trackWidth );
@ -619,6 +617,9 @@ bool PNS_KICAD_IFACE_BASE::ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM*
int diffPairGap = bds.m_MinClearance;
int diffPairViaGap = bds.m_MinClearance;
aSizes.SetDiffPairWidthSource( _( "board minimum track width" ) );
aSizes.SetDiffPairGapSource( _( "board minimum clearance" ) );
found = false;
// First try to pick up diff pair width from starting track, if enabled
@ -632,6 +633,9 @@ bool PNS_KICAD_IFACE_BASE::ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM*
nullptr, m_startLayer, &constraint ) )
{
diffPairWidth = std::max( diffPairWidth, constraint.m_Value.Opt() );
if( diffPairWidth == constraint.m_Value.Opt() )
aSizes.SetDiffPairWidthSource( constraint.m_RuleName );
}
if( m_ruleResolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_DIFF_PAIR_GAP, aStartItem,
@ -639,6 +643,9 @@ bool PNS_KICAD_IFACE_BASE::ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM*
{
diffPairGap = std::max( diffPairGap, constraint.m_Value.Opt() );
diffPairViaGap = std::max( diffPairViaGap, constraint.m_Value.Opt() );
if( diffPairGap == constraint.m_Value.Opt() )
aSizes.SetDiffPairGapSource( constraint.m_RuleName );
}
}
else
@ -646,6 +653,9 @@ bool PNS_KICAD_IFACE_BASE::ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM*
diffPairWidth = bds.GetCurrentDiffPairWidth();
diffPairGap = bds.GetCurrentDiffPairGap();
diffPairViaGap = bds.GetCurrentDiffPairViaGap();
aSizes.SetDiffPairWidthSource( _( "user choice" ) );
aSizes.SetDiffPairGapSource( _( "user choice" ) );
}
aSizes.SetDiffPairWidth( diffPairWidth );

View File

@ -48,8 +48,7 @@ public:
m_diffPairGap( 180000 ),
m_diffPairViaGap( 180000 ),
m_diffPairViaGapSameAsTraceGap( true ),
m_holeToHole( 0 ),
m_widthSource()
m_holeToHole( 0 )
{};
~SIZES_SETTINGS() {};
@ -104,9 +103,18 @@ public:
void SetViaType( VIATYPE aViaType ) { m_viaType = aViaType; }
VIATYPE ViaType() const { return m_viaType; }
wxString GetClearanceSource() const { return m_clearanceSource; }
void SetClearanceSource( const wxString& aSource ) { m_clearanceSource = aSource; }
wxString GetWidthSource() const { return m_widthSource; }
void SetWidthSource( const wxString& aSource ) { m_widthSource = aSource; }
wxString GetDiffPairWidthSource() const { return m_diffPairWidthSource; }
void SetDiffPairWidthSource( const wxString& aSource ) { m_diffPairWidthSource = aSource; }
wxString GetDiffPairGapSource() const { return m_diffPairGapSource; }
void SetDiffPairGapSource( const wxString& aSource ) { m_diffPairGapSource = aSource; }
private:
int m_minClearance;
int m_trackWidth;
@ -125,7 +133,10 @@ private:
std::map<int, int> m_layerPairs;
wxString m_clearanceSource;
wxString m_widthSource;
wxString m_diffPairWidthSource;
wxString m_diffPairGapSource;
};
}

View File

@ -678,7 +678,14 @@ void ROUTER_TOOL::updateSizesAfterLayerSwitch( PCB_LAYER_ID targetLayer )
targetLayer );
if( !constraint.IsNull() )
{
sizes.SetTrackWidth( std::max( bds.m_TrackMinWidth, constraint.m_Value.Opt() ) );
if( sizes.TrackWidth() == constraint.m_Value.Opt() )
sizes.SetWidthSource( constraint.GetName() );
else
sizes.SetDiffPairGapSource( _( "board minimum track width" ) );
}
}
if( nets.size() >= 2 && ( bds.UseNetClassDiffPair() || !sizes.TrackWidthIsExplicit() ) )
@ -691,13 +698,27 @@ void ROUTER_TOOL::updateSizesAfterLayerSwitch( PCB_LAYER_ID targetLayer )
targetLayer );
if( !constraint.IsNull() )
{
sizes.SetDiffPairWidth( std::max( bds.m_TrackMinWidth, constraint.m_Value.Opt() ) );
if( sizes.DiffPairWidth() == constraint.m_Value.Opt() )
sizes.SetDiffPairWidthSource( constraint.GetName() );
else
sizes.SetDiffPairGapSource( _( "board minimum track width" ) );
}
constraint = drcEngine->EvalRules( DIFF_PAIR_GAP_CONSTRAINT, &dummyTrack, &dummyTrackB,
targetLayer );
if( !constraint.IsNull() )
{
sizes.SetDiffPairGap( std::max( bds.m_MinClearance, constraint.m_Value.Opt() ) );
if( sizes.DiffPairGap() == constraint.m_Value.Opt() )
sizes.SetDiffPairGapSource( constraint.GetName() );
else
sizes.SetDiffPairGapSource( _( "board minimum clearance" ) );
}
}
m_router->UpdateSizes( sizes );
@ -2378,33 +2399,34 @@ void ROUTER_TOOL::UpdateMessagePanel()
items.emplace_back( _( "Corner Style" ), cornerMode );
int width = isDiffPair ? sizes.DiffPairWidth() : sizes.TrackWidth();
items.emplace_back( wxString::Format( _( "Track Width: %s" ),
frame()->MessageTextFromValue( width ) ),
wxString::Format( _( "(from %s)" ),
sizes.GetWidthSource() ) );
if( m_startItem )
{
PNS::SEGMENT dummy;
dummy.SetNet( m_startItem->Net() );
PNS::CONSTRAINT constraint;
if( resolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_CLEARANCE, &dummy, nullptr,
m_router->GetCurrentLayer(), &constraint ) )
{
items.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
frame()->MessageTextFromValue( constraint.m_Value.Min() ) ),
wxString::Format( _( "(from %s)" ),
constraint.m_RuleName ) );
}
}
if( isDiffPair )
{
items.emplace_back( _( "Diff Pair Gap" ),
frame()->MessageTextFromValue( sizes.DiffPairGap() ) );
items.emplace_back( wxString::Format( _( "Track Width: %s" ),
frame()->MessageTextFromValue( sizes.DiffPairWidth() ) ),
wxString::Format( _( "(from %s)" ),
sizes.GetDiffPairWidthSource() ) );
items.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
frame()->MessageTextFromValue( sizes.MinClearance() ) ),
wxString::Format( _( "(from %s)" ),
sizes.GetClearanceSource() ) );
items.emplace_back( wxString::Format( _( "Diff Pair Gap: %s" ),
frame()->MessageTextFromValue( sizes.DiffPairGap() ) ),
wxString::Format( _( "(from %s)" ),
sizes.GetDiffPairGapSource() ) );
}
else
{
items.emplace_back( wxString::Format( _( "Track Width: %s" ),
frame()->MessageTextFromValue( sizes.TrackWidth() ) ),
wxString::Format( _( "(from %s)" ),
sizes.GetWidthSource() ) );
items.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
frame()->MessageTextFromValue( sizes.MinClearance() ) ),
wxString::Format( _( "(from %s)" ),
sizes.GetClearanceSource() ) );
}
frame()->SetMsgPanel( items );