From 5a428e195712c41a9fc227dbabd4c24c47a7aa47 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 9 Jul 2014 11:24:56 +0200 Subject: [PATCH] Moved layers visibility synchronization to PCB_DRAW_PANEL_GAL::SyncLayersVisibility(). --- pcbnew/pcb_draw_panel_gal.cpp | 25 +++++++++++++++++++++++++ pcbnew/pcb_draw_panel_gal.h | 7 +++++++ pcbnew/pcbframe.cpp | 24 +----------------------- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index 2c60634453..92293aaf24 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -321,3 +321,28 @@ void PCB_DRAW_PANEL_GAL::SetTopLayer( LAYER_ID aLayer ) m_view->UpdateAllLayersOrder(); } + + +void PCB_DRAW_PANEL_GAL::SyncLayersVisibility( const BOARD* aBoard ) +{ + // Load layer & elements visibility settings + for( LAYER_NUM i = 0; i < NB_LAYERS; ++i ) + { + m_view->SetLayerVisible( i, aBoard->IsLayerVisible( i ) ); + + // Synchronize netname layers as well + if( IsCopperLayer( i ) ) + m_view->SetLayerVisible( GetNetnameLayer( i ), aBoard->IsLayerVisible( i ) ); + } + + for( LAYER_NUM i = 0; i < END_PCB_VISIBLE_LIST; ++i ) + { + m_view->SetLayerVisible( ITEM_GAL_LAYER( i ), aBoard->IsElementVisible( i ) ); + } + + // Enable some layers that are GAL specific + m_view->SetLayerVisible( ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ), true ); + m_view->SetLayerVisible( ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ), true ); + m_view->SetLayerVisible( ITEM_GAL_LAYER( WORKSHEET ), true ); + m_view->SetLayerVisible( ITEM_GAL_LAYER( GP_OVERLAY ), true ); +} diff --git a/pcbnew/pcb_draw_panel_gal.h b/pcbnew/pcb_draw_panel_gal.h index fa32cde04a..26ac94f968 100644 --- a/pcbnew/pcb_draw_panel_gal.h +++ b/pcbnew/pcb_draw_panel_gal.h @@ -70,6 +70,13 @@ public: ///> @copydoc EDA_DRAW_PANEL_GAL::SetTopLayer() virtual void SetTopLayer( LAYER_ID aLayer ); + /** + * Function SyncLayersVisibility + * Updates "visibility" property of each layer of a given BOARD. + * @param aBoard contains layers visibility settings to be applied. + */ + void SyncLayersVisibility( const BOARD* aBoard ); + protected: ///> Currently used worksheet KIGFX::WORKSHEET_VIEWITEM* m_worksheet; diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 66f939663d..fdf24ad63f 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -813,29 +813,7 @@ void PCB_EDIT_FRAME::syncRenderStates() void PCB_EDIT_FRAME::syncLayerVisibilities() { m_Layers->SyncLayerVisibilities(); - - KIGFX::VIEW* view = GetGalCanvas()->GetView(); - - // Load layer & elements visibility settings - for( LAYER_NUM i = 0; i < LAYER_ID_COUNT; ++i ) - { - view->SetLayerVisible( i, m_Pcb->IsLayerVisible( LAYER_ID( i ) ) ); - - // Synchronize netname layers as well - if( IsCopperLayer( i ) ) - view->SetLayerVisible( GetNetnameLayer( i ), m_Pcb->IsLayerVisible( LAYER_ID( i ) ) ); - } - - for( LAYER_NUM i = 0; i < END_PCB_VISIBLE_LIST; ++i ) - { - view->SetLayerVisible( ITEM_GAL_LAYER( i ), m_Pcb->IsElementVisible( i ) ); - } - - // Enable some layers that are GAL specific - view->SetLayerVisible( ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ), true ); - view->SetLayerVisible( ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ), true ); - view->SetLayerVisible( ITEM_GAL_LAYER( WORKSHEET ), true ); - view->SetLayerVisible( ITEM_GAL_LAYER( GP_OVERLAY ), true ); + static_cast( GetGalCanvas() )->SyncLayersVisibility( m_Pcb ); }