Fixed a bug with invisible vias

If there was a board with no copper layers checked as visible, the
initial GAL cache contained an empty entry for them. In such case,
toggling layers visibility have not changed anything.

The visibility condition check has been moved to ViewGetLOD() method
which serves better the purpose of dynamic visibility checks.

Fixes: lp:1639974
* https://bugs.launchpad.net/kicad/+bug/1639974
This commit is contained in:
Maciej Suminski 2017-04-20 18:19:41 +02:00
parent 217593f6bc
commit e53c3afc29
3 changed files with 15 additions and 5 deletions

View File

@ -1018,6 +1018,18 @@ void VIA::ViewGetLayers( int aLayers[], int& aCount ) const
}
unsigned int VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
{
BOARD* board = GetBoard();
// Only draw the via if at least one of the layers it crosses is being displayed
if( board && ( board->GetVisibleLayers() & GetLayerSet() ).any() )
return 0;
return std::numeric_limits<unsigned int>::max();
}
// see class_track.h
void TRACK::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
{

View File

@ -434,6 +434,9 @@ public:
/// @copydoc VIEW_ITEM::ViewGetLayers()
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
/// @copydoc VIEW_ITEM::ViewGetLOD()
virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
virtual void Flip( const wxPoint& aCentre ) override;
#if defined (DEBUG)

View File

@ -393,11 +393,6 @@ void PCB_PAINTER::draw( const VIA* aVia, int aLayer )
VECTOR2D center( aVia->GetStart() );
double radius = 0.0;
// Only draw the via if at least one of the layers it crosses is being displayed
BOARD* brd = aVia->GetBoard( );
if( !( brd->GetVisibleLayers() & aVia->GetLayerSet() ).any() )
return;
// Choose drawing settings depending on if we are drawing via's pad or hole
if( aLayer == LAYER_VIAS_HOLES )
radius = aVia->GetDrillValue() / 2.0;