From 6f5cb1f97d95ad893744cdcb47115ca0fb1db438 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 3 Jun 2021 22:42:07 +0100 Subject: [PATCH] Fix printing of hidden refs and/or values. IsLayerVisible() is patched to always return true when printing (even when "print according to appearance settings" is checked, and that's too risky to change at this point. So we also look to see if the layer colour is set to the background colour. Fixes https://gitlab.com/kicad/code/kicad/issues/8548 --- pcbnew/fp_text.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/pcbnew/fp_text.cpp b/pcbnew/fp_text.cpp index bbf967c63e..503e6c4afd 100644 --- a/pcbnew/fp_text.cpp +++ b/pcbnew/fp_text.cpp @@ -32,6 +32,7 @@ #include #include #include +#include FP_TEXT::FP_TEXT( FOOTPRINT* aParentFootprint, TEXT_TYPE text_type ) : BOARD_ITEM( aParentFootprint, PCB_FP_TEXT_T ), @@ -360,6 +361,8 @@ void FP_TEXT::ViewGetLayers( int aLayers[], int& aCount ) const double FP_TEXT::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const { constexpr double HIDE = (double)std::numeric_limits::max(); + RENDER_SETTINGS* renderSettings = aView->GetPainter()->GetSettings(); + COLOR4D backgroundColor = renderSettings->GetLayerColor( LAYER_PCB_BACKGROUND ); if( !aView ) return 0.0; @@ -370,13 +373,23 @@ double FP_TEXT::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const return HIDE; // Handle Render tab switches - if( ( m_Type == TEXT_is_VALUE || GetText() == wxT( "${VALUE}" ) ) - && !aView->IsLayerVisible( LAYER_MOD_VALUES ) ) - return HIDE; + if( m_Type == TEXT_is_VALUE || GetText() == wxT( "${VALUE}" ) ) + { + if( !aView->IsLayerVisible( LAYER_MOD_VALUES ) + || renderSettings->GetLayerColor( LAYER_MOD_VALUES ) == backgroundColor ) + { + return HIDE; + } + } - if( ( m_Type == TEXT_is_REFERENCE || GetText() == wxT( "${REFERENCE}" ) ) - && !aView->IsLayerVisible( LAYER_MOD_REFERENCES ) ) - return HIDE; + if( m_Type == TEXT_is_REFERENCE || GetText() == wxT( "${REFERENCE}" ) ) + { + if( !aView->IsLayerVisible( LAYER_MOD_REFERENCES ) + || renderSettings->GetLayerColor( LAYER_MOD_REFERENCES ) == backgroundColor ) + { + return HIDE; + } + } if( !IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_FR ) ) return HIDE;