From 25209516a618b5033ac8301cb37eba7ca0744803 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 12 May 2019 18:03:17 +0100 Subject: [PATCH] Adjust net highlighting after edits. Fixes: lp:1800291 * https://bugs.launchpad.net/kicad/+bug/1800291 --- eeschema/bus-wire-junction.cpp | 2 ++ eeschema/cross-probing.cpp | 2 +- eeschema/hierarch.cpp | 2 +- eeschema/sch_edit_frame.cpp | 2 +- eeschema/tools/ee_actions.h | 2 +- eeschema/tools/sch_editor_control.cpp | 9 +++++---- eeschema/tools/sch_editor_control.h | 4 ++-- eeschema/tools/sch_move_tool.cpp | 2 +- eeschema/tools/sch_wire_bus_tool.cpp | 5 +---- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index de7131431d..e11a79eda9 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -434,6 +434,8 @@ SCH_JUNCTION* SCH_EDIT_FRAME::AddJunction( const wxPoint& aPos, bool aUndoAppend if( aFinal ) { + m_toolManager->PostEvent( EVENTS::SelectedItemsModified ); + TestDanglingEnds(); OnModify(); diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index 8a2b2d771b..35f691f044 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -82,7 +82,7 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline ) SetStatusText( _( "Selected net: " ) + UnescapeString( m_SelectedNetName ) ); - GetToolManager()->RunAction( EE_ACTIONS::highlightNetSelection, true ); + GetToolManager()->RunAction( EE_ACTIONS::updateNetHighlighting, true ); } return; diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp index 25eef8635d..ed5a8a4c26 100644 --- a/eeschema/hierarch.cpp +++ b/eeschema/hierarch.cpp @@ -286,6 +286,6 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet() UpdateTitle(); - GetToolManager()->RunAction( EE_ACTIONS::highlightNetSelection, true ); + GetToolManager()->RunAction( EE_ACTIONS::updateNetHighlighting, true ); HardRedraw(); // Ensure any item has its view updated, especially the worksheet items } diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 5f46044507..a86cdfc0f3 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1270,7 +1270,7 @@ void SCH_EDIT_FRAME::AddItemToScreenAndUndoList( SCH_ITEM* aItem, bool aUndoAppe TrimWire( *i, *j ); if( screen->IsJunctionNeeded( *i, true ) ) - AddJunction( *i, true ); + AddJunction( *i, true, false ); } TestDanglingEnds(); diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index 3a62c86ff7..8f805f9833 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -177,7 +177,7 @@ public: // Net highlighting static TOOL_ACTION highlightNet; static TOOL_ACTION clearHighlight; - static TOOL_ACTION highlightNetSelection; + static TOOL_ACTION updateNetHighlighting; static TOOL_ACTION highlightNetCursor; ///> @copydoc COMMON_ACTIONS::TranslateLegacyId() diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index f2788ba3eb..2d27db79d3 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -67,7 +67,7 @@ TOOL_ACTION EE_ACTIONS::highlightNet( "eeschema.EditorControl.highlightNet", TOOL_ACTION EE_ACTIONS::clearHighlight( "eeschema.EditorControl.clearHighlight", AS_GLOBAL, 0, "", "" ); -TOOL_ACTION EE_ACTIONS::highlightNetSelection( "eeschema.EditorControl.highlightNetSelection", +TOOL_ACTION EE_ACTIONS::updateNetHighlighting( "eeschema.EditorControl.updateNetHighlighting", AS_GLOBAL, 0, "", "" ); TOOL_ACTION EE_ACTIONS::highlightNetCursor( "eeschema.EditorControl.highlightNetCursor", @@ -334,7 +334,7 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition ) editFrame->SetSelectedNetName( netName ); TOOL_EVENT dummy; - editorControl->HighlightNetSelection( dummy ); + editorControl->UpdateNetHighlighting( dummy ); return retVal; } @@ -359,7 +359,7 @@ int SCH_EDITOR_CONTROL::ClearHighlight( const TOOL_EVENT& aEvent ) } -int SCH_EDITOR_CONTROL::HighlightNetSelection( const TOOL_EVENT& aEvent ) +int SCH_EDITOR_CONTROL::UpdateNetHighlighting( const TOOL_EVENT& aEvent ) { SCH_SCREEN* screen = g_CurrentSheet->LastScreen(); std::vector itemsToRedraw; @@ -710,7 +710,8 @@ void SCH_EDITOR_CONTROL::setTransitions() Go( &SCH_EDITOR_CONTROL::HighlightNet, EE_ACTIONS::highlightNet.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::ClearHighlight, EE_ACTIONS::clearHighlight.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::HighlightNetCursor, EE_ACTIONS::highlightNetCursor.MakeEvent() ); - Go( &SCH_EDITOR_CONTROL::HighlightNetSelection, EE_ACTIONS::highlightNetSelection.MakeEvent() ); + Go( &SCH_EDITOR_CONTROL::UpdateNetHighlighting, EVENTS::SelectedItemsModified ); + Go( &SCH_EDITOR_CONTROL::UpdateNetHighlighting, EE_ACTIONS::updateNetHighlighting.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::Cut, EE_ACTIONS::cut.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::Copy, EE_ACTIONS::copy.MakeEvent() ); diff --git a/eeschema/tools/sch_editor_control.h b/eeschema/tools/sch_editor_control.h index e00f60432c..bdf9149fb0 100644 --- a/eeschema/tools/sch_editor_control.h +++ b/eeschema/tools/sch_editor_control.h @@ -63,8 +63,8 @@ public: ///> Removes any net highlighting int ClearHighlight( const TOOL_EVENT& aEvent ); - ///> Highlights frame's SelectedNetName. - int HighlightNetSelection( const TOOL_EVENT& aEvent ); + ///> Updates net highlighting after an edit + int UpdateNetHighlighting( const TOOL_EVENT& aEvent ); ///> Launches a tool to highlight nets. int HighlightNetCursor( const TOOL_EVENT& aEvent ); diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index c2cac1c94a..a22f0e43ce 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -566,7 +566,7 @@ void SCH_MOVE_TOOL::addJunctionsIfNeeded( SELECTION& aSelection ) for( auto point : pts ) { if( m_frame->GetScreen()->IsJunctionNeeded( point, true ) ) - m_frame->AddJunction( point, true ); + m_frame->AddJunction( point, true, false ); } } diff --git a/eeschema/tools/sch_wire_bus_tool.cpp b/eeschema/tools/sch_wire_bus_tool.cpp index f265f3592c..2b076acdf1 100644 --- a/eeschema/tools/sch_wire_bus_tool.cpp +++ b/eeschema/tools/sch_wire_bus_tool.cpp @@ -202,10 +202,6 @@ bool SCH_WIRE_BUS_TOOL::Init() { EE_TOOL_BASE::Init(); - auto activeTool = [ this ] ( const SELECTION& aSel ) { - return ( m_frame->GetToolId() != ID_NO_TOOL_SELECTED ); - }; - auto wireOrBusTool = [ this ] ( const SELECTION& aSel ) { return ( m_frame->GetToolId() == ID_WIRE_BUTT || m_frame->GetToolId() == ID_BUS_BUTT ); }; @@ -977,6 +973,7 @@ void SCH_WIRE_BUS_TOOL::finishSegments() m_busUnfold = {}; m_frame->TestDanglingEnds(); + m_toolMgr->PostEvent( EVENTS::SelectedItemsModified ); m_frame->OnModify(); }