Special selection mode when in high-contrast with courtyard layer active.

Fixes https://gitlab.com/kicad/code/kicad/issues/13521
This commit is contained in:
Jeff Young 2023-01-25 13:31:37 +00:00
parent 95fb3825bd
commit 362d85ef50
14 changed files with 47 additions and 29 deletions

View File

@ -254,7 +254,7 @@ public:
* @param aLayer The layer to test for.
* @return true if on given layer, else false.
*/
virtual bool IsOnLayer( PCB_LAYER_ID aLayer ) const
virtual bool IsOnLayer( PCB_LAYER_ID aLayer, bool aIncludeCourtyards = false ) const
{
return m_layer == aLayer;
}

View File

@ -146,7 +146,7 @@ public:
PCB_GROUP* DeepDuplicate() const;
///< @copydoc BOARD_ITEM::IsOnLayer
bool IsOnLayer( PCB_LAYER_ID aLayer ) const override;
bool IsOnLayer( PCB_LAYER_ID aLayer, bool aIncludeCourtyards = false ) const override;
///< @copydoc EDA_ITEM::HitTest
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;

View File

@ -150,7 +150,7 @@ void PCB_BASE_EDIT_FRAME::ShowGraphicItemPropertiesDialog( BOARD_ITEM* aItem )
if( dlg.ShowQuasiModal() == wxID_OK )
{
if( aItem->IsOnLayer( GetActiveLayer() ) )
if( aItem->IsOnLayer( GetActiveLayer(), true ) )
{
DRAWING_TOOL* drawingTool = m_toolManager->GetTool<DRAWING_TOOL>();
drawingTool->SetStroke( aItem->GetStroke(), GetActiveLayer() );

View File

@ -1085,8 +1085,13 @@ void FOOTPRINT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
}
bool FOOTPRINT::IsOnLayer( PCB_LAYER_ID aLayer ) const
bool FOOTPRINT::IsOnLayer( PCB_LAYER_ID aLayer, bool aIncludeCourtyards ) const
{
static const LSET courtyardLayers( 2, B_CrtYd, F_CrtYd );
if( aIncludeCourtyards && courtyardLayers[aLayer] )
return !GetCourtyard( aLayer ).IsEmpty();
// If we have any pads, fall back on normal checking
if( !m_pads.empty() )
return m_layer == aLayer;

View File

@ -328,7 +328,7 @@ public:
* given layer, even if that layer is not one of the valid footprint layers F_Cu and B_Cu.
* This allows selection of "graphic" footprints that contain only silkscreen, for example.
*/
bool IsOnLayer( PCB_LAYER_ID aLayer ) const override;
bool IsOnLayer( PCB_LAYER_ID aLayer, bool aIncludeCourtyards = false ) const override;
// m_footprintStatus bits:
#define FP_is_LOCKED 0x01 ///< footprint LOCKED: no autoplace allowed

View File

@ -628,7 +628,7 @@ public:
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
bool IsOnLayer( PCB_LAYER_ID aLayer ) const override
bool IsOnLayer( PCB_LAYER_ID aLayer, bool aIncludeCourtyards = false ) const override
{
return m_layerMask[aLayer];
}

View File

@ -1298,7 +1298,7 @@ void PCB_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer )
// as they won't be found in the view layer's itemset for re-painting.
if( GetDisplayOptions().m_ContrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN )
{
if( item->IsOnLayer( oldLayer ) || item->IsOnLayer( aLayer ) )
if( item->IsOnLayer( oldLayer, true ) || item->IsOnLayer( aLayer, true ) )
return KIGFX::ALL;
}

View File

@ -117,7 +117,7 @@ static void existsOnLayerFunc( LIBEVAL::CONTEXT* aCtx, void *self )
{
anyMatch = true;
if( item->IsOnLayer( ToLAYER_ID( entry.GetValue())))
if( item->IsOnLayer( ToLAYER_ID( entry.GetValue() ), true ) )
return 1.0;
}
}

View File

@ -329,12 +329,12 @@ LSET PCB_GROUP::GetLayerSet() const
}
bool PCB_GROUP::IsOnLayer( PCB_LAYER_ID aLayer ) const
bool PCB_GROUP::IsOnLayer( PCB_LAYER_ID aLayer, bool aIncludeCourtyards ) const
{
// A group is on a layer if any item is on the layer
for( BOARD_ITEM* item : m_items )
{
if( item->IsOnLayer( aLayer ) )
if( item->IsOnLayer( aLayer, aIncludeCourtyards ) )
return true;
}

View File

@ -482,7 +482,7 @@ int PCB_VIA::GetSolderMaskExpansion() const
}
bool PCB_VIA::IsOnLayer( PCB_LAYER_ID aLayer ) const
bool PCB_VIA::IsOnLayer( PCB_LAYER_ID aLayer, bool aIncludeCourtyards ) const
{
#if 0
// Nice and simple, but raises its ugly head in performance profiles....

View File

@ -404,7 +404,7 @@ public:
bool IsTented() const override;
int GetSolderMaskExpansion() const;
bool IsOnLayer( PCB_LAYER_ID aLayer ) const override;
bool IsOnLayer( PCB_LAYER_ID aLayer, bool aIncludeCourtyards = false ) const override;
virtual LSET GetLayerSet() const override;
virtual void SetLayerSet( LSET aLayers ) override;

View File

@ -2388,7 +2388,7 @@ bool PCB_SELECTION_TOOL::Selectable( const BOARD_ITEM* aItem, bool checkVisibili
for( int layer : activeLayers )
{
// NOTE: Only checking the regular layers (not GAL meta-layers)
if( layer < PCB_LAYER_ID_COUNT && aItem->IsOnLayer( ToLAYER_ID( layer ) ) )
if( layer < PCB_LAYER_ID_COUNT && aItem->IsOnLayer( ToLAYER_ID( layer ), true ) )
{
onActiveLayer = true;
break;
@ -2897,19 +2897,21 @@ int PCB_SELECTION_TOOL::hitTestDistance( const wxPoint& aWhere, BOARD_ITEM* aIte
void PCB_SELECTION_TOOL::GuessSelectionCandidates( GENERAL_COLLECTOR& aCollector,
const VECTOR2I& aWhere ) const
{
std::set<BOARD_ITEM*> preferred;
std::set<BOARD_ITEM*> rejected;
wxPoint where( aWhere.x, aWhere.y );
static const LSET silkLayers( 2, B_SilkS, F_SilkS );
static const LSET courtyardLayers( 2, B_CrtYd, F_CrtYd );
PCB_LAYER_ID activeLayer = m_frame->GetActiveLayer();
LSET silkLayers( 2, B_SilkS, F_SilkS );
std::set<BOARD_ITEM*> preferred;
std::set<BOARD_ITEM*> rejected;
wxPoint where( aWhere.x, aWhere.y );
const RENDER_SETTINGS* settings = getView()->GetPainter()->GetSettings();
PCB_LAYER_ID activeLayer = m_frame->GetActiveLayer();
if( silkLayers[activeLayer] )
{
for( int i = 0; i < aCollector.GetCount(); ++i )
{
BOARD_ITEM* item = aCollector[i];
KICAD_T type = item->Type();
KICAD_T type = item->Type();
if( ( type == PCB_TEXT_T || type == PCB_TEXTBOX_T || type == PCB_SHAPE_T )
&& silkLayers[item->GetLayer()] )
@ -2917,18 +2919,29 @@ void PCB_SELECTION_TOOL::GuessSelectionCandidates( GENERAL_COLLECTOR& aCollector
preferred.insert( item );
}
}
if( preferred.size() > 0 )
}
else if( courtyardLayers[activeLayer] && settings->GetHighContrast() )
{
for( int i = 0; i < aCollector.GetCount(); ++i )
{
aCollector.Empty();
BOARD_ITEM* item = aCollector[i];
KICAD_T type = item->Type();
for( BOARD_ITEM* item : preferred )
aCollector.Append( item );
return;
if( type == PCB_FOOTPRINT_T )
preferred.insert( item );
}
}
if( preferred.size() > 0 )
{
aCollector.Empty();
for( BOARD_ITEM* item : preferred )
aCollector.Append( item );
return;
}
// Prefer exact hits to sloppy ones
constexpr int MAX_SLOP = 5;

View File

@ -320,7 +320,7 @@ double ZONE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
}
bool ZONE::IsOnLayer( PCB_LAYER_ID aLayer ) const
bool ZONE::IsOnLayer( PCB_LAYER_ID aLayer, bool aIncludeCourtyards ) const
{
return m_layerSet.test( aLayer );
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -164,7 +164,7 @@ public:
// Return the first layer in GUI sequence.
PCB_LAYER_ID GetFirstLayer() const;
virtual bool IsOnLayer( PCB_LAYER_ID ) const override;
virtual bool IsOnLayer( PCB_LAYER_ID, bool aIncludeCourtyards = false ) const override;
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;