From f1fed08fa78e6302373b8504cb93f448679294b9 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 29 Jan 2019 07:16:11 -0800 Subject: [PATCH] pcbnew: Finalize previous snapping preferences Snap/Grid modifier follow preferences from 05483a06c6. Brings Shift/Alt modifiers into alignment with drawing tools. Shift modifier still conflicts when choosing end item with the complete track click-modifier. This will be addressed in v6 with a larger preference setting. --- pcbnew/router/pns_tool_base.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pcbnew/router/pns_tool_base.cpp b/pcbnew/router/pns_tool_base.cpp index 5e50288311..982f98473f 100644 --- a/pcbnew/router/pns_tool_base.cpp +++ b/pcbnew/router/pns_tool_base.cpp @@ -264,6 +264,8 @@ void TOOL_BASE::updateStartItem( const TOOL_EVENT& aEvent, bool aIgnorePads ) VECTOR2I p; controls()->ForceCursorPosition( false ); + m_gridHelper->SetUseGrid( !aEvent.Modifier( MD_ALT ) ); + m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) ); bool snapEnabled = true; @@ -284,7 +286,7 @@ void TOOL_BASE::updateStartItem( const TOOL_EVENT& aEvent, bool aIgnorePads ) m_startSnapPoint = snapToItem( snapEnabled, m_startItem, p ); - if( checkSnap ( m_startItem )) + if( checkSnap ( m_startItem ) ) { controls()->ForceCursorPosition( true, m_startSnapPoint ); } @@ -293,13 +295,13 @@ void TOOL_BASE::updateStartItem( const TOOL_EVENT& aEvent, bool aIgnorePads ) void TOOL_BASE::updateEndItem( const TOOL_EVENT& aEvent ) { - controls()->ForceCursorPosition( false ); - - VECTOR2I mousePos = controls()->GetMousePosition(); - VECTOR2I cursorPos = controls()->GetCursorPosition(); - int layer; bool snapEnabled = !aEvent.Modifier( MD_SHIFT ); + m_gridHelper->SetUseGrid( !aEvent.Modifier( MD_ALT ) ); + m_gridHelper->SetSnap( snapEnabled ); + + controls()->ForceCursorPosition( false ); + VECTOR2I mousePos = controls()->GetMousePosition(); if( m_router->Settings().Mode() != RM_MarkObstacles && ( m_router->GetCurrentNets().empty() || m_router->GetCurrentNets().front() < 0 ) ) @@ -330,15 +332,15 @@ void TOOL_BASE::updateEndItem( const TOOL_EVENT& aEvent ) if( checkSnap( endItem ) ) { - VECTOR2I p = snapToItem( snapEnabled, endItem, mousePos ); - controls()->ForceCursorPosition( true, p ); m_endItem = endItem; - m_endSnapPoint = p; + m_endSnapPoint = snapToItem( snapEnabled, endItem, mousePos ); } else { m_endItem = nullptr; - m_endSnapPoint = cursorPos; + m_endSnapPoint = m_gridHelper->Align( mousePos ); } + controls()->ForceCursorPosition( true, m_endSnapPoint ); + if( m_endItem ) { wxLogTrace( "PNS", "%s, layer : %d", m_endItem->KindStr().c_str(), m_endItem->Layers().Start() );