From 3b0a758f971a977d47281ad572630a985fa3323b Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 16 Mar 2018 02:42:38 +0000 Subject: [PATCH] Ensure router layer is visible. Fixes: lp:1663556 * https://bugs.launchpad.net/kicad/+bug/1663556 --- pcbnew/layer_widget.cpp | 7 +++++++ pcbnew/layer_widget.h | 2 ++ pcbnew/pcb_edit_frame.h | 2 ++ pcbnew/pcb_layer_widget.cpp | 17 ++++++++++------- pcbnew/router/router_tool.cpp | 4 +++- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/pcbnew/layer_widget.cpp b/pcbnew/layer_widget.cpp index 9f36a5f8cc..7d62798371 100644 --- a/pcbnew/layer_widget.cpp +++ b/pcbnew/layer_widget.cpp @@ -687,6 +687,13 @@ LAYER_NUM LAYER_WIDGET::GetSelectedLayer() void LAYER_WIDGET::SetLayerVisible( LAYER_NUM aLayer, bool isVisible ) +{ + setLayerCheckbox( aLayer, isVisible ); + OnLayerVisible( aLayer, isVisible ); +} + + +void LAYER_WIDGET::setLayerCheckbox( LAYER_NUM aLayer, bool isVisible ) { int row = findLayerRow( aLayer ); if( row >= 0 ) diff --git a/pcbnew/layer_widget.h b/pcbnew/layer_widget.h index 532e296bde..bf341239c6 100644 --- a/pcbnew/layer_widget.h +++ b/pcbnew/layer_widget.h @@ -236,6 +236,8 @@ protected: void insertRenderRow( int aRow, const ROW& aSpec ); + void setLayerCheckbox( LAYER_NUM aLayer, bool isVisible ); + /** * Function passOnFocus * gives away the keyboard focus up to the main parent window. diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index fe7589ffff..6493e95db3 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -623,6 +623,8 @@ public: */ virtual void SetActiveLayer( PCB_LAYER_ID aLayer ) override; + PCB_LAYER_WIDGET* GetLayerManager() { return m_Layers; } + /** * Update the UI to reflect changes to the current layer's transparency. */ diff --git a/pcbnew/pcb_layer_widget.cpp b/pcbnew/pcb_layer_widget.cpp index 1e6e877c54..7acb911795 100644 --- a/pcbnew/pcb_layer_widget.cpp +++ b/pcbnew/pcb_layer_widget.cpp @@ -444,7 +444,7 @@ void PCB_LAYER_WIDGET::SyncLayerVisibilities() PCB_LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) ); // this does not fire a UI event - SetLayerVisible( layerId, board->IsLayerVisible( layerId ) ); + setLayerCheckbox( layerId, board->IsLayerVisible( layerId ) ); } } @@ -646,16 +646,19 @@ void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal LSET visibleLayers = brd->GetVisibleLayers(); - visibleLayers.set( aLayer, isVisible ); + if( visibleLayers.test( aLayer ) != isVisible ) + { + visibleLayers.set( aLayer, isVisible ); - brd->SetVisibleLayers( visibleLayers ); + brd->SetVisibleLayers( visibleLayers ); - myframe->OnModify(); + myframe->OnModify(); - EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas(); + EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas(); - if( galCanvas ) - galCanvas->GetView()->SetLayerVisible( aLayer, isVisible ); + if( galCanvas ) + galCanvas->GetView()->SetLayerVisible( aLayer, isVisible ); + } if( isFinal ) myframe->GetCanvas()->Refresh(); diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index abf4622f8a..c0d8c08c27 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -34,6 +34,7 @@ using namespace std::placeholders; #include #include #include +#include #include #include #include @@ -657,7 +658,8 @@ bool ROUTER_TOOL::prepareInteractive() frame()->SetActiveLayer( ToLAYER_ID( routingLayer ) ); - // fixme: switch on invisible layer + // Force layer visible + frame()->GetLayerManager()->SetLayerVisible( routingLayer, true ); // for some reason I don't understand, GetNetclass() may return null sometimes... if( m_startItem && m_startItem->Net() >= 0 &&