Clean up terminology around active & high contrast layers.

This commit is contained in:
Jeff Young 2020-10-03 22:26:44 +01:00
parent 70f329df91
commit bb753aaadf
10 changed files with 66 additions and 57 deletions

View File

@ -376,8 +376,8 @@ void EDA_DRAW_PANEL_GAL::SetHighContrastLayer( int aLayer )
SetTopLayer( aLayer );
rSettings->ClearActiveLayers();
rSettings->SetActiveLayer( aLayer );
rSettings->ClearHighContrastLayers();
rSettings->SetLayerIsHighContrast( aLayer );
m_view->UpdateAllLayersColor();
}

View File

@ -31,6 +31,7 @@ RENDER_SETTINGS::RENDER_SETTINGS() :
m_printDC( nullptr )
{
// Set the default initial values
m_activeLayer = F_Cu;
m_highlightFactor = 0.5f;
m_selectFactor = 0.5f;
m_highlightEnabled = false;

View File

@ -79,9 +79,9 @@ void GERBVIEW_DRAW_PANEL_GAL::SetHighContrastLayer( int aLayer )
SetTopLayer( aLayer );
rSettings->ClearActiveLayers();
rSettings->SetActiveLayer( aLayer );
rSettings->SetActiveLayer( GERBER_DCODE_LAYER( aLayer ) );
rSettings->ClearHighContrastLayers();
rSettings->SetLayerIsHighContrast( aLayer );
rSettings->SetLayerIsHighContrast( GERBER_DCODE_LAYER( aLayer ) );
m_view->UpdateAllLayersColor();
}

View File

@ -139,7 +139,7 @@ COLOR4D GERBVIEW_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer )
return m_layerColorsHi[aLayer];
// Return grayish color for non-highlighted layers in the high contrast mode
if( m_hiContrastEnabled && m_activeLayers.count( aLayer ) == 0)
if( m_hiContrastEnabled && m_highContrastLayers.count( aLayer ) == 0)
return m_hiContrastColor[aLayer];
// Catch the case when highlight and high-contraste modes are enabled

View File

@ -58,33 +58,46 @@ public:
virtual void LoadColors( const COLOR_SETTINGS* aSettings ) { }
/**
* Function SetActiveLayer
* Sets the specified layer as active - it means that it can be drawn in a specific mode
* (eg. highlighted, so it differs from other layers).
* Function SetLayerIsHighContrast
* Sets the specified layer as high-contrast.
* @param aLayerId is a layer number that should be displayed in a specific mode.
* @param aEnabled is the new layer state ( true = active or false = not active).
*/
inline void SetActiveLayer( int aLayerId, bool aEnabled = true )
inline void SetLayerIsHighContrast( int aLayerId, bool aEnabled = true )
{
if( aEnabled )
m_activeLayers.insert( aLayerId );
m_highContrastLayers.insert( aLayerId );
else
m_activeLayers.erase( aLayerId );
m_highContrastLayers.erase( aLayerId );
}
/**
* Function GetActiveLayers()
* Returns the set of currently active layers.
* @return The set of currently active layers.
* Function GetLayerIsHighContrast
* Returns information whether the queried layer is marked as high-contrast.
* @return True if the queried layer is marked as active.
*/
const std::set<unsigned int> GetActiveLayers() const
inline bool GetLayerIsHighContrast( int aLayerId ) const
{
return m_activeLayers;
return ( m_highContrastLayers.count( aLayerId ) > 0 );
}
PCB_LAYER_ID GetActiveLayer() const
/**
* Function GetHighContrastLayers()
* Returns the set of currently high-contrast layers.
*/
const std::set<unsigned int> GetHighContrastLayers() const
{
for( int layer : m_activeLayers )
return m_highContrastLayers;
}
/**
* Returns the board layer which is in high-contrast. There should only be one
* board layer which is high-contrast at any given time, although there might be
* many high-contrast synthetic (GAL) layers.
*/
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
{
for( int layer : m_highContrastLayers )
{
if( layer >= PCBNEW_LAYER_ID_START && layer < PCB_LAYER_ID_COUNT )
return (PCB_LAYER_ID) layer;
@ -93,23 +106,16 @@ public:
return UNDEFINED_LAYER;
}
/**
* Function ClearActiveLayers
* Clears the list of active layers.
*/
inline void ClearActiveLayers()
{
m_activeLayers.clear();
}
PCB_LAYER_ID GetActiveLayer() const { return m_activeLayer; }
void SetActiveLayer( PCB_LAYER_ID aLayer ) { m_activeLayer = aLayer; }
/**
* Function IsActiveLayer
* Returns information whether the queried layer is marked as active.
* @return True if the queried layer is marked as active.
* Function ClearHighContrastLayers
* Clears the list of active layers.
*/
inline bool IsActiveLayer( int aLayerId ) const
inline void ClearHighContrastLayers()
{
return ( m_activeLayers.count( aLayerId ) > 0 );
m_highContrastLayers.clear();
}
/**
@ -258,8 +264,9 @@ protected:
*/
virtual void update();
std::set<unsigned int> m_activeLayers; ///< Stores active layers number
PCB_LAYER_ID m_activeLayer; // The active layer (as shown by appearance mgr)
std::set<unsigned 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

View File

@ -261,10 +261,11 @@ void PCB_DRAW_PANEL_GAL::SetHighContrastLayer( PCB_LAYER_ID aLayer )
KIGFX::RENDER_SETTINGS* rSettings = m_view->GetPainter()->GetSettings();
SetTopLayer( aLayer );
rSettings->ClearActiveLayers();
rSettings->SetActiveLayer( aLayer );
rSettings->ClearHighContrastLayers();
rSettings->SetLayerIsHighContrast( aLayer );
if( IsCopperLayer( aLayer ) )
{
// Bring some other layers to the front in case of copper layers and make them colored
@ -281,20 +282,20 @@ void PCB_DRAW_PANEL_GAL::SetHighContrastLayer( PCB_LAYER_ID aLayer )
};
for( unsigned int i : layers )
rSettings->SetActiveLayer( i );
rSettings->SetLayerIsHighContrast( i );
// Pads should be shown too
if( aLayer == B_Cu )
{
rSettings->SetActiveLayer( LAYER_PAD_BK );
rSettings->SetActiveLayer( LAYER_MOD_BK );
rSettings->SetActiveLayer( LAYER_PAD_BK_NETNAMES );
rSettings->SetLayerIsHighContrast( LAYER_PAD_BK );
rSettings->SetLayerIsHighContrast( LAYER_MOD_BK );
rSettings->SetLayerIsHighContrast( LAYER_PAD_BK_NETNAMES );
}
else if( aLayer == F_Cu )
{
rSettings->SetActiveLayer( LAYER_PAD_FR );
rSettings->SetActiveLayer( LAYER_MOD_FR );
rSettings->SetActiveLayer( LAYER_PAD_FR_NETNAMES );
rSettings->SetLayerIsHighContrast( LAYER_PAD_FR );
rSettings->SetLayerIsHighContrast( LAYER_MOD_FR );
rSettings->SetLayerIsHighContrast( LAYER_PAD_FR_NETNAMES );
}
}

View File

@ -230,11 +230,11 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons
aLayer = aLayer - LAYER_ZONE_START;
// Make items invisible in "other layers hidden" contrast mode
if( m_contrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN && m_activeLayers.count( aLayer ) == 0 )
if( m_contrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN && m_highContrastLayers.count( aLayer ) == 0 )
return COLOR4D::CLEAR;
// Hide net names in "dimmed" contrast mode
if( m_hiContrastEnabled && IsNetnameLayer( aLayer ) && m_activeLayers.count( aLayer ) == 0 )
if( m_hiContrastEnabled && IsNetnameLayer( aLayer ) && m_highContrastLayers.count( aLayer ) == 0 )
return COLOR4D::CLEAR;
// Normal path: get the layer base color
@ -264,7 +264,7 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons
bool dimmedMode = m_contrastModeDisplay == HIGH_CONTRAST_MODE::DIMMED;
bool highlighted = m_highlightEnabled && m_highlightNetcodes.count( netCode );
bool activeLayer = m_activeLayers.count( aLayer );
bool activeLayer = m_highContrastLayers.count( aLayer );
// Apply net color overrides
if( conItem && m_netColorMode == NET_COLOR_MODE::ALL && IsNetCopperLayer( aLayer ) )
@ -325,7 +325,7 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons
const BOARD* pcb = static_cast<const BOARD*>( item->GetParent() );
bool viaActiveLayer = false;
for( int layer : m_activeLayers )
for( int layer : m_highContrastLayers )
{
auto lay_id = static_cast<PCB_LAYER_ID>( layer );
viaActiveLayer |= via->IsOnLayer( lay_id ) && pcb->IsLayerVisible( lay_id );

View File

@ -943,7 +943,7 @@ bool PNS_KICAD_IFACE::IsItemVisible( const PNS::ITEM* aItem )
{
int layers[KIGFX::VIEW::VIEW_MAX_LAYERS];
int layers_count;
auto activeLayers = m_view->GetPainter()->GetSettings()->GetActiveLayers();
auto activeLayers = m_view->GetPainter()->GetSettings()->GetHighContrastLayers();
isOnVisibleLayer = false;
item->ViewGetLayers( layers, layers_count );

View File

@ -262,7 +262,7 @@ std::set<BOARD_ITEM*> GRID_HELPER::queryVisible( const BOX2I& aArea,
KIGFX::VIEW* view = m_toolMgr->GetView();
RENDER_SETTINGS* settings = view->GetPainter()->GetSettings();
const std::set<unsigned int>& activeLayers = settings->GetActiveLayers();
const std::set<unsigned int>& activeLayers = settings->GetHighContrastLayers();
bool isHighContrast = settings->GetHighContrast();
view->Query( aArea, selectedItems );
@ -397,7 +397,7 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos, bo
VECTOR2I origin;
KIGFX::VIEW* view = m_toolMgr->GetView();
RENDER_SETTINGS* settings = view->GetPainter()->GetSettings();
const std::set<unsigned int>& activeLayers = settings->GetActiveLayers();
const std::set<unsigned int>& activeLayers = settings->GetHighContrastLayers();
bool isHighContrast = settings->GetHighContrast();
auto handlePadShape =

View File

@ -1795,7 +1795,7 @@ bool SELECTION_TOOL::Selectable( const BOARD_ITEM* aItem, bool checkVisibilityOn
if( settings->GetHighContrast() )
{
std::set<unsigned int> activeLayers = settings->GetActiveLayers();
std::set<unsigned int> activeLayers = settings->GetHighContrastLayers();
bool onActiveLayer = false;
for( unsigned int layer : activeLayers )