pcbnew: Fix ratsnest display

Checks for ratsnest enabled prior to calculating and displaying the
local/dynamic ratsnest.  Calls the ratsnest clear from selection clear

Notably, it appears that the tool actions do not chain transitions for
the same event.  So only a single action (first specified) will be
executed when an event fires unless the actions are executed by separate
tools.

Fixes: lp:1809752
* https://bugs.launchpad.net/kicad/+bug/1809752
This commit is contained in:
Seth Hillbrand 2018-12-30 12:17:00 -07:00
parent 2f5dd6a43a
commit 583e0173b9
5 changed files with 17 additions and 3 deletions

View File

@ -266,6 +266,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
{
auto panel = static_cast<PCB_DRAW_PANEL_GAL*>( frame->GetGalCanvas() );
connectivity->RecalculateRatsnest();
connectivity->ClearDynamicRatsnest();
panel->RedrawRatsnest();
}

View File

@ -192,6 +192,9 @@ static MODULE movedModule( nullptr );
void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule, wxPoint aMoveVector )
{
if( !GetBoard()->IsElementVisible( LAYER_RATSNEST ) )
return;
auto connectivity = GetBoard()->GetConnectivity();
movedModule = *aModule;

View File

@ -381,6 +381,7 @@ public:
static TOOL_ACTION appendBoard;
static TOOL_ACTION showHelp;
static TOOL_ACTION showLocalRatsnest;
static TOOL_ACTION hideLocalRatsnest;
static TOOL_ACTION toBeDone;
/// Find an item

View File

@ -148,6 +148,10 @@ TOOL_ACTION PCB_ACTIONS::showLocalRatsnest( "pcbnew.Control.showLocalRatsnest",
AS_GLOBAL, 0,
"", "" );
TOOL_ACTION PCB_ACTIONS::hideLocalRatsnest( "pcbnew.Control.hideLocalRatsnest",
AS_GLOBAL, 0,
"", "" );
class ZONE_CONTEXT_MENU : public CONTEXT_MENU
{
public:
@ -1147,7 +1151,7 @@ int PCB_EDITOR_CONTROL::UpdateSelectionRatsnest( const TOOL_EVENT& aEvent )
auto& selection = selectionTool->GetSelection();
auto connectivity = getModel<BOARD>()->GetConnectivity();
if( selection.Empty() )
if( selection.Empty() || !getModel<BOARD>()->IsElementVisible( LAYER_RATSNEST ) )
{
connectivity->ClearDynamicRatsnest();
}
@ -1196,6 +1200,9 @@ void PCB_EDITOR_CONTROL::ratsnestTimer( wxTimerEvent& aEvent )
void PCB_EDITOR_CONTROL::calculateSelectionRatsnest()
{
if( !board()->IsElementVisible( LAYER_RATSNEST ) )
return;
auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
auto& selection = selectionTool->GetSelection();
auto connectivity = board()->GetConnectivity();
@ -1239,9 +1246,10 @@ void PCB_EDITOR_CONTROL::setTransitions()
Go( &PCB_EDITOR_CONTROL::ClearHighlight, PCB_ACTIONS::clearHighlight.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::HighlightNetCursor, PCB_ACTIONS::highlightNetCursor.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::HighlightNetCursor, PCB_ACTIONS::highlightNetSelection.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::ShowLocalRatsnest, PCB_ACTIONS::showLocalRatsnest.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::UpdateSelectionRatsnest, PCB_ACTIONS::selectionModified.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::HideSelectionRatsnest, SELECTION_TOOL::ClearedEvent );
Go( &PCB_EDITOR_CONTROL::ShowLocalRatsnest, PCB_ACTIONS::showLocalRatsnest.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::HideSelectionRatsnest, PCB_ACTIONS::hideLocalRatsnest.MakeEvent() );
}

View File

@ -1433,6 +1433,7 @@ void SELECTION_TOOL::clearSelection()
// Inform other potentially interested tools
m_toolMgr->ProcessEvent( ClearedEvent );
m_toolMgr->RunAction( PCB_ACTIONS::hideLocalRatsnest, true );
}