pcbnew: Handle intermediate pad on route

The length calculation wanted to find start/end pads but this was
complicated for paths that had a via on the intermediate pad.  Instead
of warning, we calculate the longest path of the three possibilities

Fixes: lp:1838261
* https://bugs.launchpad.net/kicad/+bug/1838261

Fixes #2554 | https://gitlab.com/kicad/code/kicad/issues/2554
This commit is contained in:
Seth Hillbrand 2019-12-03 05:08:56 -08:00
parent 8c7e0bcb0a
commit 20a5d8effd
1 changed files with 40 additions and 4 deletions

View File

@ -2078,9 +2078,27 @@ TRACK* BOARD::MarkTrace( TRACK* aTrackList, TRACK* aTrace, int* aCount,
dist_fromend = dist;
e_pad = pad_on_start;
}
else // Should not occur, at least for basic pads
else // If we have a via in a pad in the middle of a trace
{
wxLogWarning( "Unexpected BOARD::MarkTrace: multiple pad_on_start" );
// In this case, we want the distance between the farthest pads
// Forgive me this anti-pattern. This is a v5-only fix, so complete refactor is
// a non-starter.
if( dist_fromend < dist_fromstart )
{
if( dist > dist_fromend )
{
dist_fromend = dist;
e_pad = pad_on_start;
}
}
else
{
if( dist > dist_fromstart )
{
dist_fromstart = dist;
s_pad = pad_on_start;
}
}
}
}
@ -2099,9 +2117,27 @@ TRACK* BOARD::MarkTrace( TRACK* aTrackList, TRACK* aTrace, int* aCount,
dist_fromend = dist;
e_pad = pad_on_end;
}
else // Should not occur, at least for basic pads
else // If we have a via in a pad in the middle of a trace
{
wxLogWarning( "Unexpected BOARD::MarkTrace: multiple pad_on_end" );
// In this case, we want the distance between the farthest pads
// Forgive me this anti-pattern. This is a v5-only fix, so complete refactor is
// a non-starter.
if( dist_fromend < dist_fromstart )
{
if( dist > dist_fromend )
{
dist_fromend = dist;
e_pad = pad_on_start;
}
}
else
{
if( dist > dist_fromstart )
{
dist_fromstart = dist;
s_pad = pad_on_start;
}
}
}
}
}