7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 00:21:25 +00:00

Improve pan performance when showing a large amount of TH pads.

See https://gitlab.com/kicad/code/kicad/-/issues/20506

(cherry picked from commit a1a710dfed)
This commit is contained in:
Alex Shvartzkop 2025-04-04 22:14:07 +03:00
parent 11edaa6e4a
commit 7a04389ac2
13 changed files with 90 additions and 92 deletions

View File

@ -544,23 +544,23 @@ PCB_LAYER_ID LSET::ExtractLayer() const
}
LSET LSET::FrontAssembly()
const LSET& LSET::FrontAssembly()
{
static const LSET saved( { F_SilkS, F_Mask, F_Fab, F_CrtYd } );
static LSET saved( { F_SilkS, F_Mask, F_Fab, F_CrtYd } );
return saved;
}
LSET LSET::BackAssembly()
const LSET& LSET::BackAssembly()
{
static const LSET saved( { B_SilkS, B_Mask, B_Fab, B_CrtYd } );
static LSET saved( { B_SilkS, B_Mask, B_Fab, B_CrtYd } );
return saved;
}
LSET LSET::InternalCuMask()
const LSET& LSET::InternalCuMask()
{
static const LSET saved( { In1_Cu, In2_Cu, In3_Cu, In4_Cu, In5_Cu, In6_Cu,
static LSET saved( { In1_Cu, In2_Cu, In3_Cu, In4_Cu, In5_Cu, In6_Cu,
In7_Cu, In8_Cu, In9_Cu, In10_Cu, In11_Cu, In12_Cu,
In13_Cu, In14_Cu, In15_Cu, In16_Cu, In17_Cu, In18_Cu,
In19_Cu, In20_Cu, In21_Cu, In22_Cu, In23_Cu, In24_Cu,
@ -591,73 +591,72 @@ LSET LSET::AllNonCuMask()
}
LSET LSET::ExternalCuMask()
const LSET& LSET::ExternalCuMask()
{
static const LSET saved( { F_Cu, B_Cu } );
static LSET saved( { F_Cu, B_Cu } );
return saved;
}
LSET LSET::AllLayersMask()
const LSET& LSET::AllLayersMask()
{
static const LSET saved = LSET().set();
static LSET saved = LSET().set();
return saved;
}
LSET LSET::BackTechMask()
const LSET& LSET::BackTechMask()
{
static const LSET saved( { B_SilkS, B_Mask, B_Adhes, B_Paste, B_CrtYd, B_Fab } );
static LSET saved( { B_SilkS, B_Mask, B_Adhes, B_Paste, B_CrtYd, B_Fab } );
return saved;
}
LSET LSET::BackBoardTechMask()
const LSET& LSET::BackBoardTechMask()
{
static const LSET saved( { B_SilkS, B_Mask, B_Adhes, B_Paste } );
static LSET saved( { B_SilkS, B_Mask, B_Adhes, B_Paste } );
return saved;
}
LSET LSET::FrontTechMask()
const LSET& LSET::FrontTechMask()
{
static const LSET saved( { F_SilkS, F_Mask, F_Adhes, F_Paste, F_CrtYd, F_Fab } );
static LSET saved( { F_SilkS, F_Mask, F_Adhes, F_Paste, F_CrtYd, F_Fab } );
return saved;
}
LSET LSET::FrontBoardTechMask()
const LSET& LSET::FrontBoardTechMask()
{
static const LSET saved( { F_SilkS, F_Mask, F_Adhes, F_Paste } );
static LSET saved( { F_SilkS, F_Mask, F_Adhes, F_Paste } );
return saved;
}
LSET LSET::AllTechMask()
const LSET& LSET::AllTechMask()
{
static const LSET saved = BackTechMask() | FrontTechMask();
static LSET saved = BackTechMask() | FrontTechMask();
return saved;
}
LSET LSET::AllBoardTechMask()
const LSET& LSET::AllBoardTechMask()
{
static const LSET saved = BackBoardTechMask() | FrontBoardTechMask();
static LSET saved = BackBoardTechMask() | FrontBoardTechMask();
return saved;
}
LSET LSET::UserMask()
const LSET& LSET::UserMask()
{
static const LSET saved( { Dwgs_User, Cmts_User, Eco1_User, Eco2_User, Edge_Cuts, Margin } );
static LSET saved( { Dwgs_User, Cmts_User, Eco1_User, Eco2_User, Edge_Cuts, Margin } );
return saved;
}
LSET LSET::PhysicalLayersMask()
const LSET& LSET::PhysicalLayersMask()
{
static const LSET saved = AllBoardTechMask() | AllCuMask();
static LSET saved = AllBoardTechMask() | AllCuMask();
return saved;
}
@ -680,31 +679,30 @@ LSET LSET::UserDefinedLayersMask( int aUserDefinedLayerCount )
}
LSET LSET::FrontMask()
const LSET& LSET::FrontMask()
{
static const LSET saved = FrontTechMask().set( F_Cu );
static LSET saved = LSET( FrontTechMask() ).set( F_Cu );
return saved;
}
LSET LSET::BackMask()
const LSET& LSET::BackMask()
{
static const LSET saved = BackTechMask().set( B_Cu );
static LSET saved = LSET( BackTechMask() ).set( B_Cu );
return saved;
}
LSET LSET::SideSpecificMask()
const LSET& LSET::SideSpecificMask()
{
static const LSET saved = BackTechMask() | FrontTechMask() | AllCuMask();
static LSET saved = BackTechMask() | FrontTechMask() | AllCuMask();
return saved;
}
LSET LSET::ForbiddenFootprintLayers()
const LSET& LSET::ForbiddenFootprintLayers()
{
static LSET saved = InternalCuMask();
saved.set( In1_Cu, false );
static LSET saved = LSET( InternalCuMask() ).set( In1_Cu, false );
return saved;
}

View File

@ -573,7 +573,7 @@ public:
*
* @return the enabled layers in bit-mapped form.
*/
inline LSET GetEnabledLayers() const
inline const LSET& GetEnabledLayers() const
{
return m_enabledLayers;
}

View File

@ -102,17 +102,17 @@ public:
* Return a complete set of internal copper layers which is all Cu layers
* except #F_Cu and #B_Cu.
*/
static LSET InternalCuMask();
static const LSET& InternalCuMask();
/**
* Return a complete set of all top assembly layers which is all #F_SilkS and #F_Mask.
*/
static LSET FrontAssembly();
static const LSET& FrontAssembly();
/**
* Return a complete set of all bottom assembly layers which is all #B_SilkS and #B_Mask.
*/
static LSET BackAssembly();
static const LSET& BackAssembly();
/**
* Return a mask holding the requested number of Cu PCB_LAYER_IDs.
@ -122,67 +122,67 @@ public:
/**
* Return a mask holding the Front and Bottom layers.
*/
static LSET ExternalCuMask();
static const LSET& ExternalCuMask();
/**
* Return a mask holding all layer minus CU layers.
*/
static LSET AllNonCuMask();
static LSET AllLayersMask();
static const LSET& AllLayersMask();
/**
* Return a mask holding all technical layers (no CU layer) on front side.
*/
static LSET FrontTechMask();
static const LSET& FrontTechMask();
/**
* Return a mask holding technical layers used in a board fabrication
* (no CU layer) on front side.
*/
static LSET FrontBoardTechMask();
static const LSET& FrontBoardTechMask();
/**
* Return a mask holding all technical layers (no CU layer) on back side.
*/
static LSET BackTechMask();
static const LSET& BackTechMask();
/**
* Return a mask holding technical layers used in a board fabrication
* (no CU layer) on Back side.
*/
static LSET BackBoardTechMask();
static const LSET& BackBoardTechMask();
/**
* Return a mask holding all technical layers (no CU layer) on both side.
*/
static LSET AllTechMask();
static const LSET& AllTechMask();
/**
* Return a mask holding board technical layers (no CU layer) on both side.
*/
static LSET AllBoardTechMask();
static const LSET& AllBoardTechMask();
/**
* Return a mask holding all technical layers and the external CU layer on front side.
*/
static LSET FrontMask();
static const LSET& FrontMask();
/**
* Return a mask holding all technical layers and the external CU layer on back side.
*/
static LSET BackMask();
static const LSET& BackMask();
static LSET SideSpecificMask();
static const LSET& SideSpecificMask();
static LSET UserMask();
static const LSET& UserMask();
/**
* Return a mask holding all layers which are physically realized.
*
* Equivalent to the copper layers + the board tech mask.
*/
static LSET PhysicalLayersMask();
static const LSET& PhysicalLayersMask();
/**
* Return a mask with the requested number of user defined layers.
@ -197,7 +197,7 @@ public:
* Currently internal copper layers and Margin.
*/
static LSET ForbiddenFootprintLayers();
static const LSET& ForbiddenFootprintLayers();
/**
* Return a sequence of copper layers in starting from the front/top

View File

@ -826,7 +826,7 @@ int BOARD::LayerDepth( PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer ) const
}
LSET BOARD::GetEnabledLayers() const
const LSET& BOARD::GetEnabledLayers() const
{
return GetDesignSettings().GetEnabledLayers();
}
@ -840,7 +840,7 @@ bool BOARD::IsLayerVisible( PCB_LAYER_ID aLayer ) const
}
LSET BOARD::GetVisibleLayers() const
const LSET& BOARD::GetVisibleLayers() const
{
return m_project ? m_project->GetLocalSettings().m_VisibleLayers : LSET::AllLayersMask();
}

View File

@ -608,7 +608,7 @@ public:
*
* @return the enabled layers in bit-mapped form.
*/
LSET GetEnabledLayers() const;
const LSET& GetEnabledLayers() const;
LSET GetLayerSet() const override { return GetEnabledLayers(); }
/**
@ -641,7 +641,7 @@ public:
*
* @return the visible layers in bit-mapped form.
*/
LSET GetVisibleLayers() const;
const LSET& GetVisibleLayers() const;
/**
* A proxy function that calls the correspondent function in m_BoardSettings

View File

@ -168,7 +168,7 @@ void DRC_TEST_PROVIDER_MISC::testDisabledLayers()
return true;
};
LSET disabledLayers = m_board->GetEnabledLayers().flip();
LSET disabledLayers = LSET( m_board->GetEnabledLayers() ).flip();
// Perform the test only for copper layers
disabledLayers &= LSET::AllCuMask();

View File

@ -148,10 +148,10 @@ bool DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::Run()
if( item->HasHole() )
{
if( layers.Contains( F_Cu ) )
layers |= LSET::FrontBoardTechMask().set( F_CrtYd );
layers |= LSET( LSET::FrontBoardTechMask() ).set( F_CrtYd );
if( layers.Contains( B_Cu ) )
layers |= LSET::BackBoardTechMask().set( B_CrtYd );
layers |= LSET( LSET::BackBoardTechMask() ).set( B_CrtYd );
if( layers.Contains( F_Cu ) && layers.Contains( B_Cu ) )
layers |= LSET::AllCuMask();
@ -671,10 +671,10 @@ int DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem( BOARD_ITEM* aItem
LSET layers = aItem->GetLayerSet();
if( layers.Contains( F_Cu ) )
layers |= LSET::FrontBoardTechMask().set( F_CrtYd );
layers |= LSET( LSET::FrontBoardTechMask() ).set( F_CrtYd );
if( layers.Contains( B_Cu ) )
layers |= LSET::BackBoardTechMask().set( B_CrtYd );
layers |= LSET( LSET::BackBoardTechMask() ).set( B_CrtYd );
if( layers.Contains( F_Cu ) && layers.Contains( B_Cu ) )
layers |= LSET::AllCuMask();
@ -694,10 +694,10 @@ int DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem( BOARD_ITEM* aItem
LSET layers = aOther->GetLayerSet();
if( layers.Contains( F_Cu ) )
layers |= LSET::FrontBoardTechMask().set( F_CrtYd );
layers |= LSET( LSET::FrontBoardTechMask() ).set( F_CrtYd );
if( layers.Contains( B_Cu ) )
layers |= LSET::BackBoardTechMask().set( B_CrtYd );
layers |= LSET( LSET::BackBoardTechMask() ).set( B_CrtYd );
if( layers.Contains( F_Cu ) && layers.Contains( B_Cu ) )
layers |= LSET::AllCuMask();

View File

@ -342,7 +342,7 @@ PCB_LAYER_ID PAD::GetPrincipalLayer() const
bool PAD::FlashLayer( const LSET& aLayers ) const
{
for( PCB_LAYER_ID layer : aLayers.Seq() )
for( PCB_LAYER_ID layer : aLayers )
{
if( FlashLayer( layer ) )
return true;
@ -1764,7 +1764,7 @@ double PAD::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
return LOD_HIDE;
// Handle Render tab switches
const PCB_LAYER_ID& pcbLayer = static_cast<PCB_LAYER_ID>( aLayer );
//const PCB_LAYER_ID& pcbLayer = static_cast<PCB_LAYER_ID>( aLayer );
if( !IsFlipped() && !aView->IsLayerVisible( LAYER_FOOTPRINTS_FR ) )
return LOD_HIDE;
@ -1772,11 +1772,13 @@ double PAD::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
if( IsFlipped() && !aView->IsLayerVisible( LAYER_FOOTPRINTS_BK ) )
return LOD_HIDE;
LSET visible = board->GetVisibleLayers() & board->GetEnabledLayers();
if( IsHoleLayer( aLayer ) )
{
if( !( visible & LSET::PhysicalLayersMask() ).any() )
LSET visiblePhysical = board->GetVisibleLayers();
visiblePhysical &= board->GetEnabledLayers();
visiblePhysical &= LSET::PhysicalLayersMask();
if( !visiblePhysical.any() )
return LOD_HIDE;
}
else if( IsNetnameLayer( aLayer ) )
@ -1789,6 +1791,9 @@ double PAD::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
}
else
{
LSET visible = board->GetVisibleLayers();
visible &= board->GetEnabledLayers();
// Hide netnames unless pad is flashed to a visible layer
if( !FlashLayer( visible ) )
return LOD_HIDE;
@ -1811,10 +1816,8 @@ double PAD::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
}
}
VECTOR2L padSize = GetShape( pcbLayer ) != PAD_SHAPE::CUSTOM
? VECTOR2L( GetSize( pcbLayer ) ) : GetBoundingBox().GetSize();
int64_t minSide = std::min( padSize.x, padSize.y );
VECTOR2L padSize = GetBoundingBox().GetSize();
int64_t minSide = std::min( padSize.x, padSize.y );
if( minSide > 0 )
return std::min( lodScaleForThreshold( aView, minSide, pcbIUScale.mmToIU( 0.2 ) ), 3.5 );

View File

@ -1038,11 +1038,13 @@ const PADSTACK::COPPER_LAYER_PROPS& PADSTACK::CopperLayer( PCB_LAYER_ID aLayer )
{
PCB_LAYER_ID layer = EffectiveLayerFor( aLayer );
wxCHECK_MSG( m_copperProps.contains( layer ), m_copperProps.at( ALL_LAYERS ),
auto it = m_copperProps.find( layer );
wxCHECK_MSG( it != m_copperProps.end(), m_copperProps.at( ALL_LAYERS ),
"Attempt to retrieve layer " + std::string( magic_enum::enum_name( layer ) ) + " from a "
"padstack that does not contain it" );
return m_copperProps.at( layer );
return it->second;
}

View File

@ -2495,7 +2495,7 @@ void PCB_IO_EAGLE::packageHole( FOOTPRINT* aFootprint, wxXmlNode* aTree, bool aC
pad->SetDrillSize( sz );
pad->SetSize( PADSTACK::ALL_LAYERS, sz );
pad->SetLayerSet( LSET::AllCuMask().set( B_Mask ).set( F_Mask ) );
pad->SetLayerSet( LSET( LSET::AllCuMask() ).set( B_Mask ).set( F_Mask ) );
}

View File

@ -1178,7 +1178,7 @@ BOARD* PCB_IO_KICAD_SEXPR_PARSER::parseBOARD_unchecked()
}
// Make sure the destination layer is enabled, even if not in the file
m_board->SetEnabledLayers( m_board->GetEnabledLayers().set( destLayer ) );
m_board->SetEnabledLayers( LSET( m_board->GetEnabledLayers() ).set( destLayer ) );
const auto visitItem = [&]( BOARD_ITEM& curr_item )
{

View File

@ -1367,15 +1367,10 @@ void PCB_VIA::SanitizeLayers()
bool PCB_VIA::FlashLayer( const LSET& aLayers ) const
{
for( size_t ii = 0; ii < aLayers.size(); ++ii )
for( PCB_LAYER_ID layer : aLayers )
{
if( aLayers.test( ii ) )
{
PCB_LAYER_ID layer = PCB_LAYER_ID( ii );
if( FlashLayer( layer ) )
return true;
}
if( FlashLayer( layer ) )
return true;
}
return false;

View File

@ -376,22 +376,22 @@ LAYER_PRESET APPEARANCE_CONTROLS::presetAllLayers( _HKI( "All Layers" ),
LSET::AllLayersMask(), false );
LAYER_PRESET APPEARANCE_CONTROLS::presetAllCopper( _HKI( "All Copper Layers" ),
LSET::AllCuMask().set( Edge_Cuts ), false );
LSET( LSET::AllCuMask() ).set( Edge_Cuts ), false );
LAYER_PRESET APPEARANCE_CONTROLS::presetInnerCopper( _HKI( "Inner Copper Layers" ),
LSET::InternalCuMask().set( Edge_Cuts ), false );
LSET( LSET::InternalCuMask() ).set( Edge_Cuts ), false );
LAYER_PRESET APPEARANCE_CONTROLS::presetFront( _HKI( "Front Layers" ),
LSET::FrontMask().set( Edge_Cuts ), false );
LSET( LSET::FrontMask() ).set( Edge_Cuts ), false );
LAYER_PRESET APPEARANCE_CONTROLS::presetFrontAssembly( _HKI( "Front Assembly View" ),
LSET::FrontAssembly().set( Edge_Cuts ), GAL_SET::DefaultVisible(), F_SilkS, false );
LSET( LSET::FrontAssembly() ).set( Edge_Cuts ), GAL_SET::DefaultVisible(), F_SilkS, false );
LAYER_PRESET APPEARANCE_CONTROLS::presetBack( _HKI( "Back Layers" ),
LSET::BackMask().set( Edge_Cuts ), true );
LSET( LSET::BackMask() ).set( Edge_Cuts ), true );
LAYER_PRESET APPEARANCE_CONTROLS::presetBackAssembly( _HKI( "Back Assembly View" ),
LSET::BackAssembly().set( Edge_Cuts ), GAL_SET::DefaultVisible(), B_SilkS, true );
LSET( LSET::BackAssembly() ).set( Edge_Cuts ), GAL_SET::DefaultVisible(), B_SilkS, true );
// this one is only used to store the object visibility settings of the last used
// built-in layer preset