Special case via area generation.
Fixes https://gitlab.com/kicad/code/kicad/issues/7105
This commit is contained in:
parent
b90e72ed07
commit
3e920c665f
|
@ -1883,43 +1883,6 @@ bool PCB_SELECTION_TOOL::doSelectionMenu( GENERAL_COLLECTOR* aCollector )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOARD_ITEM* PCB_SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector )
|
|
||||||
{
|
|
||||||
int count = aCollector->GetPrimaryCount(); // try to use preferred layer
|
|
||||||
|
|
||||||
if( 0 == count )
|
|
||||||
count = aCollector->GetCount();
|
|
||||||
|
|
||||||
for( int i = 0; i < count; ++i )
|
|
||||||
{
|
|
||||||
if(( *aCollector )[i]->Type() != PCB_FOOTPRINT_T )
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// All are footprints, now find smallest FOOTPRINT
|
|
||||||
int minDim = 0x7FFFFFFF;
|
|
||||||
int minNdx = 0;
|
|
||||||
|
|
||||||
for( int i = 0; i < count; ++i )
|
|
||||||
{
|
|
||||||
FOOTPRINT* footprint = (FOOTPRINT*) ( *aCollector )[i];
|
|
||||||
|
|
||||||
int lx = footprint->GetFootprintRect().GetWidth();
|
|
||||||
int ly = footprint->GetFootprintRect().GetHeight();
|
|
||||||
|
|
||||||
int lmin = std::min( lx, ly );
|
|
||||||
|
|
||||||
if( lmin < minDim )
|
|
||||||
{
|
|
||||||
minDim = lmin;
|
|
||||||
minNdx = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (*aCollector)[minNdx];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool PCB_SELECTION_TOOL::Selectable( const BOARD_ITEM* aItem, bool checkVisibilityOnly ) const
|
bool PCB_SELECTION_TOOL::Selectable( const BOARD_ITEM* aItem, bool checkVisibilityOnly ) const
|
||||||
{
|
{
|
||||||
const RENDER_SETTINGS* settings = getView()->GetPainter()->GetSettings();
|
const RENDER_SETTINGS* settings = getView()->GetPainter()->GetSettings();
|
||||||
|
@ -2237,9 +2200,9 @@ bool PCB_SELECTION_TOOL::selectionContains( const VECTOR2I& aPoint ) const
|
||||||
GENERAL_COLLECTORS_GUIDE guide = getCollectorsGuide();
|
GENERAL_COLLECTORS_GUIDE guide = getCollectorsGuide();
|
||||||
GENERAL_COLLECTOR collector;
|
GENERAL_COLLECTOR collector;
|
||||||
|
|
||||||
// Since we're just double-checking, we want something considerably sloppier than the initial
|
// Since we're just double-checking, we want a considerably sloppier check than the initial
|
||||||
// selection (most tools use a 5 pixel slop value). We increase this to an effective 20 pixels
|
// selection (for which most tools use 5 pixels). So we increase this to an effective 20
|
||||||
// by inflating the value of a pixel by 4x.
|
// pixels by artificially inflating the value of a pixel by 4X.
|
||||||
guide.SetOnePixelInIU( guide.OnePixelInIU() * 4 );
|
guide.SetOnePixelInIU( guide.OnePixelInIU() * 4 );
|
||||||
|
|
||||||
collector.Collect( board(), m_isFootprintEditor ? GENERAL_COLLECTOR::FootprintItems
|
collector.Collect( board(), m_isFootprintEditor ? GENERAL_COLLECTOR::FootprintItems
|
||||||
|
@ -2430,7 +2393,13 @@ void PCB_SELECTION_TOOL::GuessSelectionCandidates( GENERAL_COLLECTOR& aCollector
|
||||||
&& static_cast<ZONE*>( item )->HitTestForEdge( where, MAX_SLOP * pixel / 2 ) )
|
&& static_cast<ZONE*>( item )->HitTestForEdge( where, MAX_SLOP * pixel / 2 ) )
|
||||||
{
|
{
|
||||||
// Zone borders are very specific, so make them "small"
|
// Zone borders are very specific, so make them "small"
|
||||||
area = MAX_SLOP * pixel * pixel;
|
area = MAX_SLOP * SEG::Square( pixel );
|
||||||
|
}
|
||||||
|
else if( item->Type() == PCB_VIA_T )
|
||||||
|
{
|
||||||
|
// Vias rarely hide other things, and we don't want them deferring to short track
|
||||||
|
// segments -- so make them artificially small by dropping the π from πr².
|
||||||
|
area = SEG::Square( static_cast<VIA*>( item )->GetDrill() / 2 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -310,14 +310,6 @@ private:
|
||||||
///> Returns true if the given item passes the current SELECTION_FILTER_OPTIONS
|
///> Returns true if the given item passes the current SELECTION_FILTER_OPTIONS
|
||||||
bool itemPassesFilter( BOARD_ITEM* aItem );
|
bool itemPassesFilter( BOARD_ITEM* aItem );
|
||||||
|
|
||||||
/**
|
|
||||||
* Function pickSmallestComponent()
|
|
||||||
* Allows one to find the smallest (in terms of bounding box area) item from the list.
|
|
||||||
*
|
|
||||||
* @param aCollector containes the list of items.
|
|
||||||
*/
|
|
||||||
BOARD_ITEM* pickSmallestComponent( GENERAL_COLLECTOR* aCollector );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function unselect()
|
* Function unselect()
|
||||||
* Takes necessary action mark an item as unselected.
|
* Takes necessary action mark an item as unselected.
|
||||||
|
|
|
@ -763,12 +763,6 @@ bool PCB_SELECTION_TOOL::doSelectionMenu( GENERAL_COLLECTOR* aCollector )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOARD_ITEM* PCB_SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector )
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool PCB_SELECTION_TOOL::Selectable( const BOARD_ITEM* aItem, bool checkVisibilityOnly ) const
|
bool PCB_SELECTION_TOOL::Selectable( const BOARD_ITEM* aItem, bool checkVisibilityOnly ) const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue