pcbnew: Cancel highlight with ESC

When editing the pcb, Ctrl-Click will highlight a net.  This allows
de-highlight with the ESC/cancel action from the selection tool.  Inside
the highlight tool, ESC reverts to the selection tool while keeping the
net highlighted.

Fixes: lp:1793842
* https://bugs.launchpad.net/kicad/+bug/1793842

(cherry picked from commit 518b53f78c)
This commit is contained in:
Seth Hillbrand 2018-09-23 15:06:24 -07:00
parent 3f58dce1de
commit 5ce0c2065c
5 changed files with 31 additions and 1 deletions

View File

@ -382,6 +382,7 @@ public:
static TOOL_ACTION switchCursor;
static TOOL_ACTION switchUnits;
static TOOL_ACTION deleteItemCursor;
static TOOL_ACTION clearHighlight;
static TOOL_ACTION highlightNet;
static TOOL_ACTION highlightNetCursor;
static TOOL_ACTION highlightNetSelection;

View File

@ -96,7 +96,6 @@ TOOL_ACTION PCB_ACTIONS::zoneDuplicate( "pcbnew.EditorControl.zoneDuplicate",
_( "Duplicate Zone onto Layer..." ), _( "Duplicate zone outline onto a different layer" ),
zone_duplicate_xpm );
TOOL_ACTION PCB_ACTIONS::placeTarget( "pcbnew.EditorControl.placeTarget",
AS_GLOBAL, 0,
_( "Add Layer Alignment Target" ), _( "Add a layer alignment target" ), NULL, AF_ACTIVATE );
@ -133,6 +132,10 @@ TOOL_ACTION PCB_ACTIONS::highlightNet( "pcbnew.EditorControl.highlightNet",
AS_GLOBAL, 0,
"", "" );
TOOL_ACTION PCB_ACTIONS::clearHighlight( "pcbnew.EditorControl.clearHighlight",
AS_GLOBAL, 0,
"", "" );
TOOL_ACTION PCB_ACTIONS::highlightNetCursor( "pcbnew.EditorControl.highlightNetCursor",
AS_GLOBAL, 0,
"", "" );
@ -1020,6 +1023,21 @@ int PCB_EDITOR_CONTROL::HighlightNet( const TOOL_EVENT& aEvent )
}
int PCB_EDITOR_CONTROL::ClearHighlight( const TOOL_EVENT& aEvent )
{
auto frame = static_cast<PCB_EDIT_FRAME*>( m_toolMgr->GetEditFrame() );
auto board = static_cast<BOARD*>( m_toolMgr->GetModel() );
KIGFX::RENDER_SETTINGS* render = m_toolMgr->GetView()->GetPainter()->GetSettings();
board->ResetHighLight();
render->SetHighlight( false );
m_toolMgr->GetView()->UpdateAllLayersColor();
frame->SetMsgPanel( board );
frame->SendCrossProbeNetName( "" );
return 0;
}
int PCB_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent )
{
// If the keyboard hotkey was triggered, the behavior is as follows:
@ -1199,6 +1217,7 @@ void PCB_EDITOR_CONTROL::setTransitions()
Go( &PCB_EDITOR_CONTROL::CrossProbeSchToPcb, PCB_ACTIONS::crossProbeSchToPcb.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::DrillOrigin, PCB_ACTIONS::drillOrigin.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::HighlightNet, PCB_ACTIONS::highlightNet.MakeEvent() );
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() );

View File

@ -104,6 +104,9 @@ public:
///> Highlights net belonging to the item under the cursor.
int HighlightNet( const TOOL_EVENT& aEvent );
///> Clears all board highlights
int ClearHighlight( const TOOL_EVENT& aEvent );
///> Launches a tool to pick the item whose net is going to be highlighted.
int HighlightNetCursor( const TOOL_EVENT& aEvent );

View File

@ -355,6 +355,9 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
else if( evt->IsCancel() || evt->Action() == TA_UNDO_REDO_PRE )
{
clearSelection();
if( evt->IsCancel() && !m_editModules )
m_toolMgr->RunAction( PCB_ACTIONS::clearHighlight, true );
}
else if( evt->Action() == TA_CONTEXT_MENU_CLOSED )

View File

@ -281,6 +281,10 @@ TOOL_ACTION PCB_ACTIONS::highlightNet( "pcbnew.EditorControl.highlightNet",
AS_GLOBAL, 0,
"", "" );
TOOL_ACTION PCB_ACTIONS::clearHighlight( "pcbnew.EditorControl.clearHighlight",
AS_GLOBAL, 0,
"", "" );
DIALOG_BLOCK_OPTIONS_BASE::DIALOG_BLOCK_OPTIONS_BASE( wxWindow* parent,
wxWindowID id,