Hi all, This patch improves the logic for d-code display in GerbView so that there is now no cost in toggling the codes on or off. They are still slow to render in huge files, but at least we only have the hit once when the file first is loaded.
-Jon
From 1d670987a0a40e0fe339b60ec33546bbcf737a79 Mon Sep 17 00:00:00 2001 From: Jon Evans <j...@craftyjon.com> Date: Wed, 21 Feb 2018 23:08:59 -0500 Subject: [PATCH 1/2] Don't recache items unnecessarily when toggling D-code display --- gerbview/gerbview_frame.cpp | 20 ++++++++++++++++++-- gerbview/gerbview_painter.cpp | 5 +---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 6a4dd1107..72252108a 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -488,9 +488,12 @@ void GERBVIEW_FRAME::ReFillLayerWidget() void GERBVIEW_FRAME::SetElementVisibility( GERBVIEW_LAYER_ID aItemIdVisible, bool aNewState ) { + bool dcodes_changed = false; + switch( aItemIdVisible ) { case LAYER_DCODES: + dcodes_changed = m_DisplayOptions.m_DisplayDCodes != aNewState; m_DisplayOptions.m_DisplayDCodes = aNewState; break; @@ -506,6 +509,19 @@ void GERBVIEW_FRAME::SetElementVisibility( GERBVIEW_LAYER_ID aItemIdVisible, wxLogDebug( wxT( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d" ), aItemIdVisible ); } + if( dcodes_changed ) + { + auto view = GetGalCanvas()->GetView(); + + for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ ) + { + int layer = GERBER_DRAW_LAYER( i ); + int dcode_layer = GERBER_DCODE_LAYER( layer ); + view->SetLayerVisible( dcode_layer, + aNewState && view->IsLayerVisible( layer ) ); + } + } + applyDisplaySettingsToGAL(); m_LayersManager->SetRenderState( aItemIdVisible, aNewState ); } @@ -520,7 +536,6 @@ void GERBVIEW_FRAME::applyDisplaySettingsToGAL() settings->ImportLegacyColors( m_colorsSettings ); - view->RecacheAllItems(); view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); } @@ -756,7 +771,8 @@ void GERBVIEW_FRAME::SetVisibleLayers( long aLayerMask ) bool v = ( aLayerMask & ( 1 << i ) ); int layer = GERBER_DRAW_LAYER( i ); canvas->GetView()->SetLayerVisible( layer, v ); - canvas->GetView()->SetLayerVisible( GERBER_DCODE_LAYER( layer ), v ); + canvas->GetView()->SetLayerVisible( GERBER_DCODE_LAYER( layer ), + m_DisplayOptions.m_DisplayDCodes && v ); } } } diff --git a/gerbview/gerbview_painter.cpp b/gerbview/gerbview_painter.cpp index 486c90a66..ada045a9f 100644 --- a/gerbview/gerbview_painter.cpp +++ b/gerbview/gerbview_painter.cpp @@ -189,12 +189,9 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer ) // TODO(JE) This doesn't actually work properly for ImageNegative bool isNegative = ( aItem->GetLayerPolarity() ^ aItem->m_GerberImageFile->m_ImageNegative ); - // Draw DCODEs if enabled + // Draw DCODE overlay text if( IsDCodeLayer( aLayer ) ) { - if( !m_gerbviewSettings.m_showCodes ) - return; - wxString codeText; VECTOR2D textPosition; double textSize; -- 2.14.1
_______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : kicad-developers@lists.launchpad.net Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp