mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-20 19:21:41 +00:00
Move more elements from fixed size arrays
Refactor layer data storage from compile-time array sizes to run-time map storage
This commit is contained in:
parent
d04a20b765
commit
bf6a255a3e
@ -41,17 +41,20 @@ public:
|
||||
|
||||
virtual COLOR4D GetColor( const KIGFX::VIEW_ITEM* aItem, int aLayer ) const override
|
||||
{
|
||||
return m_layerColors[ aLayer ];
|
||||
auto it = m_layerColors.find( aLayer );
|
||||
return it == m_layerColors.end() ? COLOR4D::WHITE : it->second;
|
||||
}
|
||||
|
||||
bool IsBackgroundDark() const override
|
||||
{
|
||||
return m_layerColors[ LAYER_SCHEMATIC_BACKGROUND ].GetBrightness() < 0.5;
|
||||
auto it = m_layerColors.find( LAYER_SCHEMATIC_BACKGROUND );
|
||||
return it != m_layerColors.end() && it->second.GetBrightness() < 0.5;
|
||||
}
|
||||
|
||||
const KIGFX::COLOR4D& GetBackgroundColor() const override
|
||||
{
|
||||
return m_layerColors[ LAYER_SCHEMATIC_BACKGROUND ];
|
||||
auto it = m_layerColors.find( LAYER_SCHEMATIC_BACKGROUND );
|
||||
return it == m_layerColors.end() ? COLOR4D::BLACK : it->second;
|
||||
}
|
||||
|
||||
void SetBackgroundColor( const COLOR4D& aColor ) override
|
||||
|
@ -108,46 +108,76 @@ COLOR4D GERBVIEW_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer )
|
||||
|
||||
// All DCODE layers stored under a single color setting
|
||||
if( IsDCodeLayer( aLayer ) )
|
||||
return m_layerColors[ LAYER_DCODES ];
|
||||
{
|
||||
auto it = m_layerColors.find( LAYER_DCODES );
|
||||
return it == m_layerColors.end() ? COLOR4D::WHITE : it->second;
|
||||
}
|
||||
|
||||
if( item && item->IsSelected() )
|
||||
return m_layerColorsSel[aLayer];
|
||||
{
|
||||
auto it = m_layerColorsSel.find( aLayer );
|
||||
return it == m_layerColorsSel.end() ? COLOR4D::WHITE : it->second;
|
||||
}
|
||||
|
||||
if( gbrItem && gbrItem->GetLayerPolarity() )
|
||||
{
|
||||
if( gvconfig()->m_Appearance.show_negative_objects )
|
||||
return m_layerColors[LAYER_NEGATIVE_OBJECTS];
|
||||
{
|
||||
auto it = m_layerColors.find( LAYER_NEGATIVE_OBJECTS );
|
||||
return it == m_layerColors.end() ? COLOR4D::WHITE : it->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
return transparent;
|
||||
}
|
||||
}
|
||||
|
||||
if( !m_netHighlightString.IsEmpty() && gbrItem &&
|
||||
m_netHighlightString == gbrItem->GetNetAttributes().m_Netname )
|
||||
return m_layerColorsHi[aLayer];
|
||||
{
|
||||
auto it = m_layerColorsHi.find( aLayer );
|
||||
return it == m_layerColorsHi.end() ? COLOR4D::WHITE : it->second;
|
||||
}
|
||||
|
||||
if( !m_componentHighlightString.IsEmpty() && gbrItem &&
|
||||
m_componentHighlightString == gbrItem->GetNetAttributes().m_Cmpref )
|
||||
return m_layerColorsHi[aLayer];
|
||||
{
|
||||
auto it = m_layerColorsHi.find( aLayer );
|
||||
return it == m_layerColorsHi.end() ? COLOR4D::WHITE : it->second;
|
||||
}
|
||||
|
||||
if( !m_attributeHighlightString.IsEmpty() && gbrItem && gbrItem->GetDcodeDescr() &&
|
||||
m_attributeHighlightString == gbrItem->GetDcodeDescr()->m_AperFunction )
|
||||
return m_layerColorsHi[aLayer];
|
||||
{
|
||||
auto it = m_layerColorsHi.find( aLayer );
|
||||
return it == m_layerColorsHi.end() ? COLOR4D::WHITE : it->second;
|
||||
}
|
||||
|
||||
if( m_dcodeHighlightValue> 0 && gbrItem && gbrItem->GetDcodeDescr() &&
|
||||
m_dcodeHighlightValue == gbrItem->GetDcodeDescr()->m_Num_Dcode )
|
||||
return m_layerColorsHi[aLayer];
|
||||
{
|
||||
auto it = m_layerColorsHi.find( aLayer );
|
||||
return it == m_layerColorsHi.end() ? COLOR4D::WHITE : it->second;
|
||||
}
|
||||
|
||||
// Return grayish color for non-highlighted layers in the high contrast mode
|
||||
if( m_hiContrastEnabled && m_highContrastLayers.count( aLayer ) == 0)
|
||||
return m_hiContrastColor[aLayer];
|
||||
{
|
||||
auto it = m_hiContrastColor.find( aLayer );
|
||||
return it == m_hiContrastColor.end() ? COLOR4D::WHITE.Darkened( 0.25 ) : it->second;
|
||||
}
|
||||
|
||||
// Catch the case when highlight and high-contraste modes are enabled
|
||||
// and we are drawing a not highlighted track
|
||||
if( m_highlightEnabled )
|
||||
return m_layerColorsDark[aLayer];
|
||||
{
|
||||
auto it = m_layerColorsDark.find( aLayer );
|
||||
return it == m_layerColorsDark.end() ? COLOR4D::WHITE.Darkened( 0.5 ) : it->second;
|
||||
}
|
||||
|
||||
// No special modificators enabled
|
||||
return m_layerColors[aLayer];
|
||||
auto it = m_layerColors.find( aLayer );
|
||||
return it == m_layerColors.end() ? COLOR4D::WHITE : it->second;
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,7 +62,8 @@ public:
|
||||
*/
|
||||
inline const COLOR4D& GetLayerColor( int aLayer ) const
|
||||
{
|
||||
return m_layerColors[aLayer];
|
||||
auto it = m_layerColors.find( aLayer );
|
||||
return it == m_layerColors.end() ? COLOR4D::WHITE : it->second;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,7 +81,8 @@ public:
|
||||
|
||||
const COLOR4D& GetBackgroundColor() const override
|
||||
{
|
||||
return m_layerColors[ LAYER_GERBVIEW_BACKGROUND ];
|
||||
auto it = m_layerColors.find( LAYER_GERBVIEW_BACKGROUND );
|
||||
return it == m_layerColors.end() ? COLOR4D::BLACK : it->second;
|
||||
}
|
||||
|
||||
void SetBackgroundColor( const COLOR4D& aColor ) override
|
||||
|
@ -269,7 +269,7 @@ public:
|
||||
if( aLayer == LAYER_INTERSHEET_REFS )
|
||||
aLayer = LAYER_GLOBLABEL;
|
||||
|
||||
return m_layerColors[aLayer];
|
||||
return m_layerColors.count( aLayer ) ? m_layerColors.at( aLayer ) : COLOR4D::BLACK;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -319,12 +319,11 @@ protected:
|
||||
wxString m_layerName;
|
||||
std::set<int> m_highContrastLayers; // High-contrast layers (both board layers and
|
||||
// synthetic GAL layers)
|
||||
COLOR4D m_layerColors[LAYER_ID_COUNT]; // Layer colors
|
||||
COLOR4D m_layerColorsHi[LAYER_ID_COUNT]; // Layer colors for highlighted objects
|
||||
COLOR4D m_layerColorsSel[LAYER_ID_COUNT]; // Layer colors for selected objects
|
||||
|
||||
COLOR4D m_hiContrastColor[LAYER_ID_COUNT]; // High-contrast mode layer colors
|
||||
COLOR4D m_layerColorsDark[LAYER_ID_COUNT]; // Darkened layer colors (for high-contrast mode)
|
||||
std::map<int, COLOR4D> m_layerColors; // Layer colors
|
||||
std::map<int, COLOR4D> m_layerColorsHi; // Layer colors for highlighted objects
|
||||
std::map<int, COLOR4D> m_layerColorsSel; // Layer colors for selected objects
|
||||
std::map<int, COLOR4D> m_hiContrastColor; // High-contrast mode layer colors
|
||||
std::map<int, COLOR4D> m_layerColorsDark; // Darkened layer colors (for high-contrast mode)
|
||||
|
||||
COLOR4D m_backgroundColor; // The background color
|
||||
|
||||
|
@ -545,24 +545,19 @@ TRACKS BOARD::TracksInNet( int aNetCode )
|
||||
|
||||
bool BOARD::SetLayerDescr( PCB_LAYER_ID aIndex, const LAYER& aLayer )
|
||||
{
|
||||
if( unsigned( aIndex ) < arrayDim( m_layers ) )
|
||||
{
|
||||
m_layers[ aIndex ] = aLayer;
|
||||
recalcOpposites();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
m_layers[ aIndex ] = aLayer;
|
||||
recalcOpposites();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
PCB_LAYER_ID BOARD::GetLayerID( const wxString& aLayerName ) const
|
||||
{
|
||||
// Check the BOARD physical layer names.
|
||||
for( int layer = 0; layer < PCB_LAYER_ID_COUNT; ++layer )
|
||||
for( auto& [ layer_id, layer ] : m_layers )
|
||||
{
|
||||
if ( m_layers[ layer ].m_name == aLayerName || m_layers[ layer ].m_userName == aLayerName )
|
||||
return ToLAYER_ID( layer );
|
||||
if( layer.m_name == aLayerName || layer.m_userName == aLayerName )
|
||||
return ToLAYER_ID( layer_id );
|
||||
}
|
||||
|
||||
// Otherwise fall back to the system standard layer names for virtual layers.
|
||||
@ -581,11 +576,13 @@ const wxString BOARD::GetLayerName( PCB_LAYER_ID aLayer ) const
|
||||
// All layer names are stored in the BOARD.
|
||||
if( IsLayerEnabled( aLayer ) )
|
||||
{
|
||||
auto it = m_layers.find( aLayer );
|
||||
|
||||
// Standard names were set in BOARD::BOARD() but they may be over-ridden by
|
||||
// BOARD::SetLayerName(). For copper layers, return the user defined layer name,
|
||||
// if it was set. Otherwise return the Standard English layer name.
|
||||
if( !m_layers[aLayer].m_userName.IsEmpty() )
|
||||
return m_layers[aLayer].m_userName;
|
||||
if( it != m_layers.end() && !it->second.m_userName.IsEmpty() )
|
||||
return it->second.m_userName;
|
||||
}
|
||||
|
||||
return GetStandardLayerName( aLayer );
|
||||
@ -615,7 +612,12 @@ bool BOARD::SetLayerName( PCB_LAYER_ID aLayer, const wxString& aLayerName )
|
||||
LAYER_T BOARD::GetLayerType( PCB_LAYER_ID aLayer ) const
|
||||
{
|
||||
if( IsLayerEnabled( aLayer ) )
|
||||
return m_layers[aLayer].m_type;
|
||||
{
|
||||
auto it = m_layers.find( aLayer );
|
||||
|
||||
if( it != m_layers.end() )
|
||||
return it->second.m_type;
|
||||
}
|
||||
|
||||
if( aLayer >= User_1 && aLayer <= User_9 )
|
||||
return LT_AUX;
|
||||
@ -731,7 +733,8 @@ void BOARD::recalcOpposites()
|
||||
|
||||
PCB_LAYER_ID BOARD::FlipLayer( PCB_LAYER_ID aLayer ) const
|
||||
{
|
||||
return ToLAYER_ID( m_layers[aLayer].m_opposite );
|
||||
auto it = m_layers.find( aLayer );
|
||||
return it == m_layers.end() ? aLayer : ToLAYER_ID( it->second.m_opposite );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1349,7 +1349,7 @@ private:
|
||||
// Cache for fast access to items in the containers above by KIID, including children
|
||||
std::unordered_map<KIID, BOARD_ITEM*> m_itemByIdCache;
|
||||
|
||||
LAYER m_layers[PCB_LAYER_ID_COUNT];
|
||||
std::map<int, LAYER> m_layers; // layer data
|
||||
|
||||
HIGH_LIGHT_INFO m_highLight; // current high light data
|
||||
HIGH_LIGHT_INFO m_highLightPrevious; // a previously stored high light data
|
||||
|
@ -136,15 +136,15 @@ DIALOG_EXPORT_SVG::~DIALOG_EXPORT_SVG()
|
||||
if( cfg )
|
||||
cfg->m_ExportSvg.layers.clear();
|
||||
|
||||
for( unsigned layer = 0; layer < arrayDim( m_boxSelectLayer ); ++layer )
|
||||
for( auto& [ layer_idx, layer] : m_boxSelectLayer )
|
||||
{
|
||||
if( !m_boxSelectLayer[layer].first )
|
||||
if( !layer.first )
|
||||
continue;
|
||||
|
||||
if( m_boxSelectLayer[layer].first->IsChecked( m_boxSelectLayer[layer].second ) )
|
||||
if( layer.first->IsChecked( layer.second ) )
|
||||
{
|
||||
if( cfg )
|
||||
cfg->m_ExportSvg.layers.push_back( layer );
|
||||
cfg->m_ExportSvg.layers.push_back( layer_idx );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -200,13 +200,13 @@ LSET DIALOG_EXPORT_SVG::getCheckBoxSelectedLayers() const
|
||||
{
|
||||
LSET ret;
|
||||
|
||||
for( unsigned layer = 0; layer < arrayDim(m_boxSelectLayer); ++layer )
|
||||
for( auto& [layer_idx, layer] : m_boxSelectLayer )
|
||||
{
|
||||
if( !m_boxSelectLayer[layer].first )
|
||||
if( !layer.first )
|
||||
continue;
|
||||
|
||||
if( m_boxSelectLayer[layer].first->IsChecked( m_boxSelectLayer[layer].second ) )
|
||||
ret.set( layer );
|
||||
if( layer.first->IsChecked( layer.second ) )
|
||||
ret.set( layer_idx );
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -45,7 +45,7 @@ private:
|
||||
LSEQ m_printMaskLayer;
|
||||
// the list of existing board layers in wxCheckListBox, with the
|
||||
// board layers id:
|
||||
std::pair<wxCheckListBox*, int> m_boxSelectLayer[PCB_LAYER_ID_COUNT];
|
||||
std::map<int, std::pair<wxCheckListBox*, int>> m_boxSelectLayer;
|
||||
bool m_printBW;
|
||||
wxString m_outputDirectory;
|
||||
bool m_printMirror;
|
||||
|
@ -89,7 +89,7 @@ public:
|
||||
|
||||
~DRC_RTREE()
|
||||
{
|
||||
for( drc_rtree* tree : m_tree )
|
||||
for( auto& [_, tree] : m_tree )
|
||||
{
|
||||
for( DRC_RTREE::ITEM_WITH_SHAPE* el : *tree )
|
||||
delete el;
|
||||
@ -169,7 +169,7 @@ public:
|
||||
*/
|
||||
void clear()
|
||||
{
|
||||
for( auto tree : m_tree )
|
||||
for( auto& [_, tree] : m_tree )
|
||||
tree->RemoveAll();
|
||||
|
||||
m_count = 0;
|
||||
@ -203,7 +203,9 @@ public:
|
||||
return true;
|
||||
};
|
||||
|
||||
this->m_tree[aTargetLayer]->Search( min, max, visit );
|
||||
if( auto it = m_tree.find( aTargetLayer ); it != m_tree.end() )
|
||||
it->second->Search( min, max, visit );
|
||||
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
@ -275,7 +277,9 @@ public:
|
||||
return true;
|
||||
};
|
||||
|
||||
this->m_tree[aTargetLayer]->Search( min, max, visit );
|
||||
if( auto it = m_tree.find( aTargetLayer ); it != m_tree.end() )
|
||||
it->second->Search( min, max, visit );
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@ -322,7 +326,8 @@ public:
|
||||
return true;
|
||||
};
|
||||
|
||||
this->m_tree[aLayer]->Search( min, max, visit );
|
||||
if( auto it = m_tree.find( aLayer ); it != m_tree.end() )
|
||||
it->second->Search( min, max, visit );
|
||||
|
||||
if( collision )
|
||||
{
|
||||
@ -397,11 +402,15 @@ public:
|
||||
|
||||
return true;
|
||||
};
|
||||
auto it = m_tree.find( aLayer );
|
||||
|
||||
if( it == m_tree.end() )
|
||||
return false;
|
||||
|
||||
if( poly && poly->OutlineCount() == 1 && poly->HoleCount( 0 ) == 0 )
|
||||
this->m_tree[aLayer]->Search( min, max, polyVisitor );
|
||||
it->second->Search( min, max, polyVisitor );
|
||||
else
|
||||
this->m_tree[aLayer]->Search( min, max, visitor );
|
||||
it->second->Search( min, max, visitor );
|
||||
|
||||
return collision;
|
||||
}
|
||||
@ -478,7 +487,10 @@ public:
|
||||
return true;
|
||||
};
|
||||
|
||||
this->m_tree[targetLayer]->Search( min, max, visit );
|
||||
auto it = m_tree.find( targetLayer );
|
||||
|
||||
if( it != m_tree.end() )
|
||||
it->second->Search( min, max, visit );
|
||||
};
|
||||
}
|
||||
|
||||
@ -572,25 +584,28 @@ public:
|
||||
|
||||
DRC_LAYER OnLayer( PCB_LAYER_ID aLayer ) const
|
||||
{
|
||||
return DRC_LAYER( m_tree[int( aLayer )] );
|
||||
auto it = m_tree.find( int( aLayer ) );
|
||||
return it == m_tree.end() ? DRC_LAYER( nullptr ) : DRC_LAYER( it->second );
|
||||
}
|
||||
|
||||
DRC_LAYER Overlapping( PCB_LAYER_ID aLayer, const VECTOR2I& aPoint, int aAccuracy = 0 ) const
|
||||
{
|
||||
BOX2I rect( aPoint, VECTOR2I( 0, 0 ) );
|
||||
rect.Inflate( aAccuracy );
|
||||
return DRC_LAYER( m_tree[int( aLayer )], rect );
|
||||
auto it = m_tree.find( int( aLayer ) );
|
||||
return it == m_tree.end() ? DRC_LAYER( nullptr ) : DRC_LAYER( it->second, rect );
|
||||
}
|
||||
|
||||
DRC_LAYER Overlapping( PCB_LAYER_ID aLayer, const BOX2I& aRect ) const
|
||||
{
|
||||
return DRC_LAYER( m_tree[int( aLayer )], aRect );
|
||||
auto it = m_tree.find( int( aLayer ) );
|
||||
return it == m_tree.end() ? DRC_LAYER( nullptr ) : DRC_LAYER( it->second, aRect );
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
drc_rtree* m_tree[PCB_LAYER_ID_COUNT];
|
||||
size_t m_count;
|
||||
std::map<int, drc_rtree*> m_tree;
|
||||
size_t m_count;
|
||||
};
|
||||
|
||||
|
||||
|
@ -113,9 +113,6 @@ EXPORTER_PCB_VRML::EXPORTER_PCB_VRML( BOARD* aBoard ) :
|
||||
for( int ii = 0; ii < VRML_COLOR_LAST; ++ii )
|
||||
m_sgmaterial[ii] = nullptr;
|
||||
|
||||
for( unsigned i = 0; i < arrayDim( m_layer_z ); ++i )
|
||||
m_layer_z[i] = 0;
|
||||
|
||||
// this default only makes sense if the output is in mm
|
||||
m_brd_thickness = pcbIUScale.IUTomm( m_board->GetDesignSettings().GetBoardThickness() );
|
||||
|
||||
|
@ -139,10 +139,12 @@ private:
|
||||
|
||||
double GetLayerZ( int aLayer )
|
||||
{
|
||||
if( unsigned( aLayer ) >= arrayDim( m_layer_z ) )
|
||||
auto it = m_layer_z.find( aLayer );
|
||||
|
||||
if( it == m_layer_z.end() )
|
||||
return 0;
|
||||
|
||||
return m_layer_z[ aLayer ];
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void SetLayerZ( int aLayer, double aValue )
|
||||
@ -263,10 +265,10 @@ private:
|
||||
double m_brd_thickness; // depth of the PCB
|
||||
|
||||
private:
|
||||
BOARD* m_board;
|
||||
VRML_COLOR vrml_colors_list[VRML_COLOR_LAST];
|
||||
double m_layer_z[PCB_LAYER_ID_COUNT];
|
||||
SHAPE_POLY_SET m_pcbOutlines; // stores the board main outlines
|
||||
BOARD* m_board;
|
||||
VRML_COLOR vrml_colors_list[VRML_COLOR_LAST];
|
||||
std::map<int, double> m_layer_z;
|
||||
SHAPE_POLY_SET m_pcbOutlines; // stores the board main outlines
|
||||
|
||||
int m_precision; // precision factor when exporting fp shapes
|
||||
// to separate files
|
||||
|
@ -226,10 +226,13 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const BOARD_ITEM* aItem, int aLayer ) con
|
||||
else if( via )
|
||||
annularRingLayer = F_Cu;
|
||||
|
||||
if( annularRingLayer != UNDEFINED_LAYER
|
||||
&& m_layerColors[ holeLayer ] == m_layerColors[ annularRingLayer ] )
|
||||
if( annularRingLayer != UNDEFINED_LAYER )
|
||||
{
|
||||
aLayer = LAYER_PCB_BACKGROUND;
|
||||
auto it = m_layerColors.find( holeLayer );
|
||||
auto it2 = m_layerColors.find( annularRingLayer );
|
||||
|
||||
if( it != m_layerColors.end() && it2 != m_layerColors.end() && it->second == it2->second )
|
||||
aLayer = LAYER_PCB_BACKGROUND;
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,10 +270,11 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const BOARD_ITEM* aItem, int aLayer ) con
|
||||
}
|
||||
|
||||
// Normal path: get the layer base color
|
||||
COLOR4D color = m_layerColors[aLayer];
|
||||
auto it = m_layerColors.find( aLayer );
|
||||
COLOR4D color = it == m_layerColors.end() ? COLOR4D::WHITE : it->second;
|
||||
|
||||
if( !aItem )
|
||||
return m_layerColors[aLayer];
|
||||
return color;
|
||||
|
||||
// Selection disambiguation
|
||||
if( aItem->IsBrightened() )
|
||||
@ -278,7 +282,10 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const BOARD_ITEM* aItem, int aLayer ) con
|
||||
|
||||
// Normal selection
|
||||
if( aItem->IsSelected() )
|
||||
color = m_layerColorsSel[aLayer];
|
||||
{
|
||||
auto it_selected = m_layerColorsSel.find( aLayer );
|
||||
color = it_selected == m_layerColorsSel.end() ? color.Brightened( 0.8 ) : it_selected->second;
|
||||
}
|
||||
|
||||
// Some graphic objects are BOARD_CONNECTED_ITEM, but they are seen here as
|
||||
// actually board connected objects only if on a copper layer
|
||||
@ -334,8 +341,16 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const BOARD_ITEM* aItem, int aLayer ) con
|
||||
else if( !selected && m_highlightEnabled )
|
||||
{
|
||||
// Single net highlight mode
|
||||
color = m_highlightNetcodes.count( netCode ) ? m_layerColorsHi[aLayer]
|
||||
: m_layerColorsDark[aLayer];
|
||||
if( m_highlightNetcodes.contains( netCode ) )
|
||||
{
|
||||
auto it_hi = m_layerColorsHi.find( aLayer );
|
||||
color = it_hi == m_layerColorsHi.end() ? color.Brightened( m_highlightFactor ) : it_hi->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto it_dark = m_layerColorsDark.find( aLayer );
|
||||
color = it_dark == m_layerColorsDark.end() ? color.Darkened( 1.0 - m_highlightFactor ) : it_dark->second;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply high-contrast dimming
|
||||
@ -450,16 +465,26 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const BOARD_ITEM* aItem, int aLayer ) con
|
||||
|| hide )
|
||||
{
|
||||
if( originalLayer == Edge_Cuts )
|
||||
color = color.Mix( m_layerColors[LAYER_PCB_BACKGROUND], dim_factor_Edge_Cuts );
|
||||
{
|
||||
it = m_layerColors.find( LAYER_PCB_BACKGROUND );
|
||||
|
||||
if( it != m_layerColors.end() )
|
||||
color = color.Mix( it->second, dim_factor_Edge_Cuts );
|
||||
else
|
||||
color = color.Mix( COLOR4D::BLACK, dim_factor_Edge_Cuts );
|
||||
}
|
||||
else
|
||||
color = COLOR4D::CLEAR;
|
||||
}
|
||||
else
|
||||
{
|
||||
it = m_layerColors.find( LAYER_PCB_BACKGROUND );
|
||||
COLOR4D backgroundColor = it == m_layerColors.end() ? COLOR4D::BLACK : it->second;
|
||||
|
||||
if( originalLayer == Edge_Cuts )
|
||||
color = color.Mix( m_layerColors[LAYER_PCB_BACKGROUND], dim_factor_Edge_Cuts );
|
||||
color = color.Mix( backgroundColor, dim_factor_Edge_Cuts );
|
||||
else
|
||||
color = color.Mix( m_layerColors[LAYER_PCB_BACKGROUND], m_hiContrastFactor );
|
||||
color = color.Mix( backgroundColor, m_hiContrastFactor );
|
||||
|
||||
// Reference images can't have their color mixed so just reduce the opacity a bit
|
||||
// so they show through less
|
||||
|
@ -107,12 +107,19 @@ public:
|
||||
|
||||
inline bool IsBackgroundDark() const override
|
||||
{
|
||||
auto luma = m_layerColors[ LAYER_PCB_BACKGROUND ].GetBrightness();
|
||||
auto it = m_layerColors.find( LAYER_PCB_BACKGROUND );
|
||||
|
||||
return luma < 0.5;
|
||||
if( it == m_layerColors.end() )
|
||||
return false;
|
||||
|
||||
return it->second.GetBrightness() < 0.5;
|
||||
}
|
||||
|
||||
const COLOR4D& GetBackgroundColor() const override { return m_layerColors[ LAYER_PCB_BACKGROUND ]; }
|
||||
const COLOR4D& GetBackgroundColor() const override
|
||||
{
|
||||
auto it = m_layerColors.find( LAYER_PCB_BACKGROUND );
|
||||
return it == m_layerColors.end() ? COLOR4D::BLACK : it->second;
|
||||
}
|
||||
|
||||
void SetBackgroundColor( const COLOR4D& aColor ) override
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user