Better selection heuristics for highlight tool
Fixes https://gitlab.com/kicad/code/kicad/-/issues/4011
This commit is contained in:
parent
f9cff177a2
commit
2abce40553
|
@ -537,16 +537,15 @@ int PCB_INSPECTION_TOOL::HighlightItem( const TOOL_EVENT& aEvent )
|
|||
*/
|
||||
bool PCB_INSPECTION_TOOL::highlightNet( const VECTOR2D& aPosition, bool aUseSelection )
|
||||
{
|
||||
BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
|
||||
KIGFX::RENDER_SETTINGS* settings = getView()->GetPainter()->GetSettings();
|
||||
BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
|
||||
KIGFX::RENDER_SETTINGS* settings = getView()->GetPainter()->GetSettings();
|
||||
SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
||||
|
||||
int net = -1;
|
||||
bool enableHighlight = false;
|
||||
|
||||
if( aUseSelection )
|
||||
{
|
||||
SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
||||
|
||||
const PCBNEW_SELECTION& selection = selectionTool->GetSelection();
|
||||
|
||||
for( auto item : selection )
|
||||
|
@ -568,21 +567,35 @@ int PCB_INSPECTION_TOOL::HighlightItem( const TOOL_EVENT& aEvent )
|
|||
// If we didn't get a net to highlight from the selection, use the cursor
|
||||
if( net < 0 )
|
||||
{
|
||||
auto guide = m_frame->GetCollectorsGuide();
|
||||
GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
|
||||
GENERAL_COLLECTOR collector;
|
||||
|
||||
PCB_LAYER_ID activeLayer = static_cast<PCB_LAYER_ID>( view()->GetTopLayer() );
|
||||
guide.SetPreferredLayer( activeLayer );
|
||||
|
||||
// Find a connected item for which we are going to highlight a net
|
||||
collector.Collect( board, GENERAL_COLLECTOR::PadsOrTracks, (wxPoint) aPosition, guide );
|
||||
|
||||
if( collector.GetCount() == 0 )
|
||||
collector.Collect( board, GENERAL_COLLECTOR::Zones, (wxPoint) aPosition, guide );
|
||||
|
||||
// Apply the active selection filter
|
||||
selectionTool->FilterCollectedItems( collector );
|
||||
|
||||
// Clear the previous highlight
|
||||
m_frame->SendMessageToEESCHEMA( nullptr );
|
||||
|
||||
bool highContrast = settings->GetHighContrast();
|
||||
PCB_LAYER_ID contrastLayer = settings->GetPrimaryHighContrastLayer();
|
||||
|
||||
for( int i = 0; i < collector.GetCount(); i++ )
|
||||
{
|
||||
if( ( collector[i]->GetLayerSet() & LSET::AllCuMask() ).none() )
|
||||
LSET itemLayers = collector[i]->GetLayerSet();
|
||||
|
||||
if( ( itemLayers & LSET::AllCuMask() ).none() )
|
||||
collector.Remove( i );
|
||||
|
||||
if( highContrast && !itemLayers.Contains( contrastLayer ) )
|
||||
collector.Remove( i );
|
||||
|
||||
if( collector[i]->Type() == PCB_PAD_T )
|
||||
|
|
|
@ -548,7 +548,7 @@ bool SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere, bool aOnDrag,
|
|||
aClientFilter( aWhere, collector, this );
|
||||
|
||||
// Apply the stateful filter
|
||||
filterCollectedItems( collector );
|
||||
FilterCollectedItems( collector );
|
||||
|
||||
FilterCollectorForGroups( collector );
|
||||
|
||||
|
@ -715,7 +715,7 @@ bool SELECTION_TOOL::selectMultiple()
|
|||
}
|
||||
|
||||
// Apply the stateful filter
|
||||
filterCollectedItems( collector );
|
||||
FilterCollectedItems( collector );
|
||||
|
||||
FilterCollectorForGroups( collector );
|
||||
|
||||
|
@ -1481,7 +1481,7 @@ int SELECTION_TOOL::filterSelection( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
void SELECTION_TOOL::filterCollectedItems( GENERAL_COLLECTOR& aCollector )
|
||||
void SELECTION_TOOL::FilterCollectedItems( GENERAL_COLLECTOR& aCollector )
|
||||
{
|
||||
if( aCollector.GetCount() == 0 )
|
||||
return;
|
||||
|
|
|
@ -197,6 +197,9 @@ public:
|
|||
|
||||
PCB_GROUP* GetEnteredGroup() { return m_enteredGroup; }
|
||||
|
||||
///> Applies the SELECTION_FILTER_OPTIONS to a collection of items
|
||||
void FilterCollectedItems( GENERAL_COLLECTOR& aCollector );
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
@ -307,9 +310,6 @@ private:
|
|||
///> Invoke filter dialog and modify current selection
|
||||
int filterSelection( const TOOL_EVENT& aEvent );
|
||||
|
||||
///> Applies the SELECTION_FILTER_OPTIONS to a collection of items
|
||||
void filterCollectedItems( GENERAL_COLLECTOR& aCollector );
|
||||
|
||||
///> Returns true if the given item passes the current SELECTION_FILTER_OPTIONS
|
||||
bool itemPassesFilter( BOARD_ITEM* aItem );
|
||||
|
||||
|
|
|
@ -734,7 +734,7 @@ int SELECTION_TOOL::filterSelection( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
void SELECTION_TOOL::filterCollectedItems( GENERAL_COLLECTOR& aCollector )
|
||||
void SELECTION_TOOL::FilterCollectedItems( GENERAL_COLLECTOR& aCollector )
|
||||
{
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue