From e53c3afc2930df0693c3ed6bb9e22c9024ea7518 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 20 Apr 2017 18:19:41 +0200 Subject: [PATCH] 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 --- pcbnew/class_track.cpp | 12 ++++++++++++ pcbnew/class_track.h | 3 +++ pcbnew/pcb_painter.cpp | 5 ----- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index e016c277c9..34d4536c31 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -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::max(); +} + + // see class_track.h void TRACK::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) { diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index 4cfa369f1b..a9e3e887df 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -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) diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 9f0a266555..60ea4aa156 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -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;