From eb689a5221c23faa6dd942f7a39af465adf53aed Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 18 Nov 2018 19:54:01 -0800 Subject: [PATCH] Ratsnest: Improve show heuristics When the local ratsnest tool is used, it should toggle the state based on the global ratsnest visibility. After changing state, the layer cache is marked as well. Possibly related to lp:1800301 (cherry picked from commit 22fbf30f22be43f8daffaeba2955188ea22fefa3) --- pcbnew/ratsnest_viewitem.cpp | 13 ++++++++++++- pcbnew/tool_pcb_editor.cpp | 2 +- pcbnew/tools/pcb_editor_control.cpp | 17 +++++++---------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/pcbnew/ratsnest_viewitem.cpp b/pcbnew/ratsnest_viewitem.cpp index 2a1216eb87..d5fe3d0400 100644 --- a/pcbnew/ratsnest_viewitem.cpp +++ b/pcbnew/ratsnest_viewitem.cpp @@ -112,7 +112,18 @@ void RATSNEST_VIEWITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const continue; bool enable = !sourceNode->GetNoLine() && !targetNode->GetNoLine(); - bool show = sourceNode->Parent()->GetLocalRatsnestVisible() || targetNode->Parent()->GetLocalRatsnestVisible(); + bool show; + + // If the ratsnest layer is currently enabled, the local ratsnest + // should be easy to turn off, so either element can disable it + // If the layer is off, the local ratsnest should be easy to turn on + // so either element can enable it. + if( sourceNode->Parent()->GetBoard()->IsElementVisible( LAYER_RATSNEST ) ) + show = sourceNode->Parent()->GetLocalRatsnestVisible() && + targetNode->Parent()->GetLocalRatsnestVisible(); + else + show = sourceNode->Parent()->GetLocalRatsnestVisible() || + targetNode->Parent()->GetLocalRatsnestVisible(); if ( enable && show ) { diff --git a/pcbnew/tool_pcb_editor.cpp b/pcbnew/tool_pcb_editor.cpp index f24bc2be4f..37db99a4ea 100644 --- a/pcbnew/tool_pcb_editor.cpp +++ b/pcbnew/tool_pcb_editor.cpp @@ -760,7 +760,7 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) case ID_TB_OPTIONS_SHOW_RATSNEST: SetElementVisibility( LAYER_RATSNEST, state ); - OnModify(); + PCB_BASE_FRAME::OnModify(); Compile_Ratsnest( NULL, true ); if( IsGalCanvasActive() ) diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index c86b9423c8..6f7706e960 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -1089,25 +1089,22 @@ static bool showLocalRatsnest( TOOL_MANAGER* aToolMgr, BOARD* aBoard, const VECT for( auto mod : modules ) { for( auto pad : mod->Pads() ) - { - pad->SetLocalRatsnestVisible( false ); - } + pad->SetLocalRatsnestVisible( aBoard->IsElementVisible( LAYER_RATSNEST ) ); } - - return true; } - - for( auto item : selection ) + else { - if( item->Type() == PCB_MODULE_T ) + for( auto item : selection ) { - for( auto pad : static_cast (item)->Pads() ) + if( auto mod = dyn_cast(item) ) { - pad->SetLocalRatsnestVisible( !pad->GetLocalRatsnestVisible() ); + for( auto pad : mod->Pads() ) + pad->SetLocalRatsnestVisible( !pad->GetLocalRatsnestVisible() ); } } } + aToolMgr->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); return true; }