diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index da78be8b9b..6c1ae3e898 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -49,6 +49,8 @@ #include #include +#include + #include EDGE_MODULE::EDGE_MODULE( MODULE* parent, STROKE_T aShape ) : @@ -321,6 +323,12 @@ void EDGE_MODULE::Flip( const wxPoint& aCentre ) SetLayer( FlipLayer( GetLayer() ) ); } +bool EDGE_MODULE::IsParentFlipped() const +{ + if( GetParent() && GetParent()->GetLayer() == B_Cu ) + return true; + return false; +} void EDGE_MODULE::Mirror( wxPoint aCentre, bool aMirrorAroundXAxis ) { @@ -394,3 +402,21 @@ void EDGE_MODULE::Move( const wxPoint& aMoveVector ) SetDrawCoord(); } + +unsigned int EDGE_MODULE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const +{ + const int HIDE = std::numeric_limits::max(); + + if( !aView ) + return 0; + + // Handle Render tab switches + if( !IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_FR ) ) + return HIDE; + + if( IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_BK ) ) + return HIDE; + + // Other layers are shown without any conditions + return 0; +} diff --git a/pcbnew/class_edge_mod.h b/pcbnew/class_edge_mod.h index 571b692403..38dcac19e3 100644 --- a/pcbnew/class_edge_mod.h +++ b/pcbnew/class_edge_mod.h @@ -88,6 +88,8 @@ public: */ void Flip( const wxPoint& aCentre ) override; + bool IsParentFlipped() const; + void SetStart0( const wxPoint& aPoint ) { m_Start0 = aPoint; } const wxPoint& GetStart0() const { return m_Start0; } @@ -126,6 +128,7 @@ public: EDA_ITEM* Clone() const override; + virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override; #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index cdbef322e4..379cf45d4b 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -1274,6 +1275,25 @@ void D_PAD::ViewGetLayers( int aLayers[], int& aCount ) const unsigned int D_PAD::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const { + const int HIDE = std::numeric_limits::max(); + + // Handle Render tab switches + if( ( GetAttribute() == PAD_ATTRIB_STANDARD || GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED ) + && !aView->IsLayerVisible( LAYER_PADS_TH ) ) + return HIDE; + + if( !IsFlipped() && !aView->IsLayerVisible( LAYER_MOD_FR ) ) + return HIDE; + + if( IsFlipped() && !aView->IsLayerVisible( LAYER_MOD_BK ) ) + return HIDE; + + if( IsFrontLayer( ( PCB_LAYER_ID )aLayer ) && !aView->IsLayerVisible( LAYER_PAD_FR ) ) + return HIDE; + + if( IsBackLayer( ( PCB_LAYER_ID )aLayer ) && !aView->IsLayerVisible( LAYER_PAD_BK ) ) + return HIDE; + // Netnames will be shown only if zoom is appropriate if( IsNetnameLayer( aLayer ) ) { @@ -1282,7 +1302,7 @@ unsigned int D_PAD::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const // Pad sizes can be zero briefly when someone is typing a number like "0.5" // in the pad properties dialog if( divisor == 0 ) - return UINT_MAX; + return HIDE; return ( Millimeter2iu( 100 ) / divisor ); } diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index df45cf2d50..2728d74e5b 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -145,6 +145,13 @@ void TEXTE_MODULE::Flip( const wxPoint& aCentre ) SetLocalCoord(); } +bool TEXTE_MODULE::IsParentFlipped() const +{ + if( GetParent() && GetParent()->GetLayer() == B_Cu ) + return true; + return false; +} + void TEXTE_MODULE::Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis ) { @@ -473,27 +480,33 @@ void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const unsigned int TEXTE_MODULE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const { - const int MAX = std::numeric_limits::max(); + const int HIDE = std::numeric_limits::max(); if( !aView ) return 0; + // Handle Render tab switches if( ( m_Type == TEXT_is_VALUE || m_Text == wxT( "%V" ) ) && !aView->IsLayerVisible( LAYER_MOD_VALUES ) ) - return MAX; + return HIDE; if( ( m_Type == TEXT_is_REFERENCE || m_Text == wxT( "%R" ) ) && !aView->IsLayerVisible( LAYER_MOD_REFERENCES ) ) - return MAX; + return HIDE; - if( IsFrontLayer( m_Layer ) && ( !aView->IsLayerVisible( LAYER_MOD_TEXT_FR ) || - !aView->IsLayerVisible( LAYER_MOD_FR ) ) ) - return MAX; + if( !IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_FR ) ) + return HIDE; - if( IsBackLayer( m_Layer ) && ( !aView->IsLayerVisible( LAYER_MOD_TEXT_BK ) || - !aView->IsLayerVisible( LAYER_MOD_BK ) ) ) - return MAX; + if( IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_BK ) ) + return HIDE; + if( IsFrontLayer( m_Layer ) && !aView->IsLayerVisible( LAYER_MOD_TEXT_FR ) ) + return HIDE; + + if( IsBackLayer( m_Layer ) && !aView->IsLayerVisible( LAYER_MOD_TEXT_BK ) ) + return HIDE; + + // Other layers are shown without any conditions return 0; } diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index eb4318e080..11a42e8c12 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -104,6 +104,8 @@ public: /// Flip entity during module flip void Flip( const wxPoint& aCentre ) override; + bool IsParentFlipped() const; + /// Mirror text position in footprint edition /// the text itself is not mirrored, and the layer not modified, /// only position is mirrored. diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index 15ea7c57d8..d9476fccc3 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -446,26 +446,12 @@ void PCB_DRAW_PANEL_GAL::setDefaultLayerDeps() m_view->SetRequired( LAYER_PADS_NETNAMES, LAYER_PADS_TH ); // Front modules - m_view->SetRequired( LAYER_PAD_FR, LAYER_MOD_FR ); m_view->SetRequired( LAYER_MOD_TEXT_FR, LAYER_MOD_FR ); m_view->SetRequired( LAYER_PAD_FR_NETNAMES, LAYER_PAD_FR ); - m_view->SetRequired( F_Adhes, LAYER_PAD_FR ); - m_view->SetRequired( F_Paste, LAYER_PAD_FR ); - m_view->SetRequired( F_Mask, LAYER_PAD_FR ); - m_view->SetRequired( F_CrtYd, LAYER_MOD_FR ); - m_view->SetRequired( F_Fab, LAYER_MOD_FR ); - m_view->SetRequired( F_SilkS, LAYER_MOD_FR ); // Back modules - m_view->SetRequired( LAYER_PAD_BK, LAYER_MOD_BK ); m_view->SetRequired( LAYER_MOD_TEXT_BK, LAYER_MOD_BK ); m_view->SetRequired( LAYER_PAD_BK_NETNAMES, LAYER_PAD_BK ); - m_view->SetRequired( B_Adhes, LAYER_PAD_BK ); - m_view->SetRequired( B_Paste, LAYER_PAD_BK ); - m_view->SetRequired( B_Mask, LAYER_PAD_BK ); - m_view->SetRequired( B_CrtYd, LAYER_MOD_BK ); - m_view->SetRequired( B_Fab, LAYER_MOD_BK ); - m_view->SetRequired( B_SilkS, LAYER_MOD_BK ); m_view->SetLayerTarget( LAYER_GP_OVERLAY , KIGFX::TARGET_OVERLAY ); m_view->SetLayerDisplayOnly( LAYER_GP_OVERLAY ) ;