Fix regression in auto-selection-disambiguation.
Fixes: lp:1646339 * https://bugs.launchpad.net/kicad/+bug/1646339
This commit is contained in:
parent
cb77babe52
commit
c69db55c1f
|
@ -1317,20 +1317,38 @@ static void addRect( SHAPE_POLY_SET& aPolySet, wxRect aRect )
|
|||
aPolySet.Append( aRect.GetX(), aRect.GetY()+aRect.height );
|
||||
}
|
||||
|
||||
double MODULE::CoverageRatio() const
|
||||
double MODULE::CoverageRatio( const GENERAL_COLLECTOR& aCollector ) const
|
||||
{
|
||||
double moduleArea = GetFootprintRect().GetArea();
|
||||
SHAPE_POLY_SET coveredRegion;
|
||||
addRect(coveredRegion, GetFootprintRect() );
|
||||
addRect( coveredRegion, GetFootprintRect() );
|
||||
|
||||
// build hole list if full area
|
||||
// build list of holes (covered areas not available for selection)
|
||||
SHAPE_POLY_SET holes;
|
||||
|
||||
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
|
||||
addRect( holes, pad->GetBoundingBox() );
|
||||
|
||||
addRect( holes, m_Reference->GetBoundingBox() );
|
||||
addRect( holes, m_Value->GetBoundingBox() );
|
||||
|
||||
for( int i = 0; i < aCollector.GetCount(); ++i )
|
||||
{
|
||||
BOARD_ITEM* item = aCollector[i];
|
||||
|
||||
switch( item->Type() )
|
||||
{
|
||||
case PCB_TEXT_T:
|
||||
case PCB_MODULE_TEXT_T:
|
||||
case PCB_TRACE_T:
|
||||
case PCB_VIA_T:
|
||||
addRect( holes, item->GetBoundingBox() );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SHAPE_POLY_SET uncoveredRegion;
|
||||
uncoveredRegion.BooleanSubtract( coveredRegion, holes, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
||||
uncoveredRegion.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <layers_id_colors_and_visibility.h> // ALL_LAYERS definition.
|
||||
#include <class_board_item.h>
|
||||
#include <board_item_container.h>
|
||||
#include <collectors.h>
|
||||
#include <lib_id.h>
|
||||
|
||||
#include <class_text_mod.h>
|
||||
|
@ -680,7 +681,7 @@ public:
|
|||
* to the area of the footprint. Used by selection tool heuristics.
|
||||
* @return the ratio
|
||||
*/
|
||||
double CoverageRatio() const;
|
||||
double CoverageRatio( const GENERAL_COLLECTOR& aCollector ) const;
|
||||
|
||||
/// Return the initial comments block or NULL if none, without transfer of ownership.
|
||||
const wxArrayString* GetInitialComments() const { return m_initial_comments; }
|
||||
|
|
|
@ -1975,13 +1975,15 @@ void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) c
|
|||
rejected.insert( mod );
|
||||
// footprints completely covered with other features have no other
|
||||
// means of selection, so must be kept
|
||||
else if ( mod->CoverageRatio() > footprintMaxCoverRatio )
|
||||
else if( mod->CoverageRatio( aCollector ) > footprintMaxCoverRatio )
|
||||
rejected.erase( mod );
|
||||
// if a footprint is much smaller than the largest overlapping
|
||||
// footprint then it should be considered for selection; reject
|
||||
// all other footprints
|
||||
else if( moduleCount > 1
|
||||
&& calcRatio( calcArea( mod ), maxArea ) > footprintToFootprintMinRatio )
|
||||
// footprint then it should be considered for selection
|
||||
else if( calcRatio( calcArea( mod ), maxArea ) <= footprintToFootprintMinRatio )
|
||||
continue;
|
||||
// reject ALL OTHER footprints (whether there are one or more of
|
||||
// them); the other items in the list should have precedence
|
||||
else
|
||||
rejected.insert( mod );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue