From ea6dc0d730befaa0fba26bf103cdb806f22f20a7 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 29 Jan 2021 14:07:49 -0800 Subject: [PATCH] Make auto-wire use snapping behavior Forcing grid snap for the kick-start behavior loses snaps to pins that may be desired. This also adds force-snapping in select mode to match the user's auto-start preferences Fixes https://gitlab.com/kicad/code/kicad/issues/7293 --- eeschema/tools/ee_selection_tool.cpp | 9 +++++++++ eeschema/tools/sch_line_wire_bus_tool.cpp | 9 +++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 15b32163ac..4d087cfc29 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -363,8 +363,12 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) newParams->quitOnDraw = true; newEvt->SetParameter( newParams ); + + getViewControls()->ForceCursorPosition( true, snappedCursorPos ); newEvt->SetMousePosition( snappedCursorPos ); + newEvt->SetHasPosition( true ); m_toolMgr->ProcessEvent( *newEvt ); + continueSelect = false; } else if( collector[0]->IsHypertext() ) @@ -526,6 +530,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) && collector[0]->IsPointClickableAnchor( (wxPoint) snappedCursorPos ) ) { displayWireCursor = true; + getViewControls()->ForceCursorPosition( true, snappedCursorPos ); } else if( collector[0]->IsHypertext() && !collector[0]->IsSelected() @@ -535,6 +540,10 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) } } } + else + { + getViewControls()->ForceCursorPosition( false ); + } } else { diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index 0bee42b1e7..edd01403ed 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -282,16 +282,17 @@ int SCH_LINE_WIRE_BUS_TOOL::DrawSegments( const TOOL_EVENT& aEvent ) { DRAW_SEGMENT_EVENT_PARAMS* params = aEvent.Parameter(); - if( aEvent.HasPosition() ) - getViewControls()->WarpCursor( aEvent.Position(), true ); - std::string tool = aEvent.GetCommandStr().get(); m_frame->PushTool( tool ); m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); if( aEvent.HasPosition() ) { - VECTOR2D cursorPos = getViewControls()->GetCursorPosition( !aEvent.Modifier( MD_ALT ) ); + EE_GRID_HELPER grid( m_toolMgr ); + grid.SetSnap( !aEvent.Modifier( MD_SHIFT ) ); + grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !aEvent.Modifier( MD_ALT ) ); + + VECTOR2D cursorPos = grid.BestSnapAnchor( aEvent.Position(), LAYER_CONNECTABLE, nullptr ); startSegments( params->layer, cursorPos ); }