Selection Tool: compare footprint area ratio only if there are >1 footprints

There is no point in comparing candidate footprint areas when there is
only one footprint, because it is always equal to 1 and rejected.

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

Fixes: lp:1747378
* https://bugs.launchpad.net/kicad/+bug/1747378
This commit is contained in:
Maciej Suminski 2018-02-09 16:16:35 +01:00
parent 86566fc142
commit 6dbd7a8d73
1 changed files with 5 additions and 2 deletions

View File

@ -1944,7 +1944,9 @@ void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) c
}
}
if( aCollector.CountType( PCB_MODULE_T ) > 0 )
int moduleCount = aCollector.CountType( PCB_MODULE_T );
if( moduleCount > 0 )
{
double maxArea = calcMaxArea( aCollector, PCB_MODULE_T );
BOX2D viewportD = getView()->GetViewport();
@ -1964,7 +1966,8 @@ void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) c
// if a footprint is much smaller than the largest overlapping
// footprint then it should be considered for selection; reject
// all other footprints
else if( calcRatio( calcArea( mod ), maxArea ) > footprintToFootprintMinRatio )
else if( moduleCount > 1
&& calcRatio( calcArea( mod ), maxArea ) > footprintToFootprintMinRatio )
rejected.insert( mod );
}
}