Fix pads and footprints rendering switches behavior

Pads and footprints rendering switches in Render tab were working incorrectly, as described in bug report:
https://bugs.launchpad.net/kicad/+bug/1743890

This patch fixes it and makes GAL behave as the legacy canvas.

Fixes: lp:1743890
This commit is contained in:
Andrzej Wolski 2018-02-17 19:03:22 +01:00 committed by Wayne Stambaugh
parent b300e8cce5
commit 4c19606eb7
6 changed files with 74 additions and 24 deletions

View File

@ -49,6 +49,8 @@
#include <class_module.h>
#include <class_edge_mod.h>
#include <view/view.h>
#include <stdio.h>
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<unsigned int>::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;
}

View File

@ -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 ); }

View File

@ -36,6 +36,7 @@
#include <base_units.h>
#include <bitmaps.h>
#include <view/view.h>
#include <pcbnew.h>
#include <class_board.h>
@ -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<unsigned int>::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 );
}

View File

@ -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<unsigned int>::max();
const int HIDE = std::numeric_limits<unsigned int>::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;
}

View File

@ -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.

View File

@ -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 ) ;