diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index e3023c6cec..cf2c2a66ad 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -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(); } diff --git a/common/render_settings.cpp b/common/render_settings.cpp index 838c2674f1..34c556687d 100644 --- a/common/render_settings.cpp +++ b/common/render_settings.cpp @@ -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; diff --git a/gerbview/gerbview_draw_panel_gal.cpp b/gerbview/gerbview_draw_panel_gal.cpp index 28b541c806..76204bf910 100644 --- a/gerbview/gerbview_draw_panel_gal.cpp +++ b/gerbview/gerbview_draw_panel_gal.cpp @@ -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(); } diff --git a/gerbview/gerbview_painter.cpp b/gerbview/gerbview_painter.cpp index f572e9138c..f580bb95e3 100644 --- a/gerbview/gerbview_painter.cpp +++ b/gerbview/gerbview_painter.cpp @@ -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 diff --git a/include/render_settings.h b/include/render_settings.h index 5c95d5e5a0..e737e5b70f 100644 --- a/include/render_settings.h +++ b/include/render_settings.h @@ -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 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 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,16 +264,17 @@ protected: */ virtual void update(); - std::set m_activeLayers; ///< Stores active layers number + PCB_LAYER_ID m_activeLayer; // The active layer (as shown by appearance mgr) + std::set 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_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) - COLOR4D m_hiContrastColor[LAYER_ID_COUNT]; // High-contrast mode layer colors - COLOR4D m_layerColorsDark[LAYER_ID_COUNT]; // Darkened layer colors (for high-contrast mode) - - COLOR4D m_backgroundColor; // The background color + COLOR4D m_backgroundColor; // The background color /// Parameters for display modes bool m_hiContrastEnabled; // High contrast display mode on/off diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index 76063b8b78..af78696750 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -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 ); } } diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 3ff4620fd7..127924c93f 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -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( item->GetParent() ); bool viaActiveLayer = false; - for( int layer : m_activeLayers ) + for( int layer : m_highContrastLayers ) { auto lay_id = static_cast( layer ); viaActiveLayer |= via->IsOnLayer( lay_id ) && pcb->IsLayerVisible( lay_id ); diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index a6b1211de7..19738f8245 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -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 ); diff --git a/pcbnew/tools/grid_helper.cpp b/pcbnew/tools/grid_helper.cpp index 44d94e4977..98ac9fc09c 100644 --- a/pcbnew/tools/grid_helper.cpp +++ b/pcbnew/tools/grid_helper.cpp @@ -262,7 +262,7 @@ std::set GRID_HELPER::queryVisible( const BOX2I& aArea, KIGFX::VIEW* view = m_toolMgr->GetView(); RENDER_SETTINGS* settings = view->GetPainter()->GetSettings(); - const std::set& activeLayers = settings->GetActiveLayers(); + const std::set& 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& activeLayers = settings->GetActiveLayers(); + const std::set& activeLayers = settings->GetHighContrastLayers(); bool isHighContrast = settings->GetHighContrast(); auto handlePadShape = diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 95c6bb81b2..3f0941ee18 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -1795,7 +1795,7 @@ bool SELECTION_TOOL::Selectable( const BOARD_ITEM* aItem, bool checkVisibilityOn if( settings->GetHighContrast() ) { - std::set activeLayers = settings->GetActiveLayers(); + std::set activeLayers = settings->GetHighContrastLayers(); bool onActiveLayer = false; for( unsigned int layer : activeLayers )