diff --git a/pcbnew/router/pns_tool_base.cpp b/pcbnew/router/pns_tool_base.cpp index 6cf3e6b622..b8023ed612 100644 --- a/pcbnew/router/pns_tool_base.cpp +++ b/pcbnew/router/pns_tool_base.cpp @@ -397,7 +397,8 @@ void TOOL_BASE::updateEndItem( const TOOL_EVENT& aEvent ) else { m_endItem = nullptr; - m_endSnapPoint = m_gridHelper->Align( mousePos ); + m_endSnapPoint = + m_gridHelper->Align( mousePos, m_router->IsPlacingVia() ? GRID_VIAS : GRID_WIRES ); } controls()->ForceCursorPosition( true, m_endSnapPoint ); @@ -421,7 +422,7 @@ const VECTOR2I TOOL_BASE::snapToItem( ITEM* aItem, const VECTOR2I& aP ) { if( !aItem || !m_iface->IsItemVisible( aItem ) ) { - return m_gridHelper->Align( aP ); + return m_gridHelper->Align( aP, m_router->IsPlacingVia() ? GRID_VIAS : GRID_WIRES ); } switch( aItem->Kind() ) @@ -486,7 +487,7 @@ const VECTOR2I TOOL_BASE::snapToItem( ITEM* aItem, const VECTOR2I& aP ) break; } - return m_gridHelper->Align( aP ); + return m_gridHelper->Align( aP, m_router->IsPlacingVia() ? GRID_VIAS : GRID_WIRES ); } } diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index c262a08993..9be9236c70 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -596,9 +596,10 @@ int DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent ) grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() ); - cursorPos = GetClampedCoords( - grid.BestSnapAnchor( m_controls->GetMousePosition(), m_frame->GetActiveLayer() ), - COORDS_PADDING ); + cursorPos = + GetClampedCoords( grid.BestSnapAnchor( m_controls->GetMousePosition(), + m_frame->GetActiveLayer(), GRID_GRAPHICS ), + COORDS_PADDING ); m_controls->ForceCursorPosition( true, cursorPos ); if( evt->IsCancelInteractive() || ( image && evt->IsAction( &ACTIONS::undo ) ) ) @@ -830,9 +831,10 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent ) grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() ); - VECTOR2I cursorPos = GetClampedCoords( - grid.BestSnapAnchor( m_controls->GetMousePosition(), m_frame->GetActiveLayer() ), - COORDS_PADDING ); + VECTOR2I cursorPos = + GetClampedCoords( grid.BestSnapAnchor( m_controls->GetMousePosition(), + m_frame->GetActiveLayer(), GRID_TEXT ), + COORDS_PADDING ); m_controls->ForceCursorPosition( true, cursorPos ); if( evt->IsCancelInteractive() || ( text && evt->IsAction( &ACTIONS::undo ) ) ) @@ -1104,7 +1106,8 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) } VECTOR2I cursorPos = evt->HasPosition() ? evt->Position() : m_controls->GetMousePosition(); - cursorPos = GetClampedCoords( grid.BestSnapAnchor( cursorPos, nullptr ), COORDS_PADDING ); + cursorPos = GetClampedCoords( grid.BestSnapAnchor( cursorPos, nullptr, GRID_GRAPHICS ), + COORDS_PADDING ); m_controls->ForceCursorPosition( true, cursorPos ); @@ -1574,7 +1577,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent ) grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() ); cursorPos = GetClampedCoords( - grid.BestSnapAnchor( m_controls->GetMousePosition(), layer ), + grid.BestSnapAnchor( m_controls->GetMousePosition(), layer, GRID_GRAPHICS ), COORDS_PADDING ); m_controls->ForceCursorPosition( true, cursorPos ); @@ -1843,7 +1846,7 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic, grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() ); cursorPos = GetClampedCoords( - grid.BestSnapAnchor( m_controls->GetMousePosition(), m_layer ), + grid.BestSnapAnchor( m_controls->GetMousePosition(), m_layer, GRID_GRAPHICS ), COORDS_PADDING ); m_controls->ForceCursorPosition( true, cursorPos ); @@ -2234,7 +2237,8 @@ bool DRAWING_TOOL::drawArc( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic, grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() ); VECTOR2I cursorPos = GetClampedCoords( - grid.BestSnapAnchor( m_controls->GetMousePosition(), graphic ), COORDS_PADDING ); + grid.BestSnapAnchor( m_controls->GetMousePosition(), graphic, GRID_GRAPHICS ), + COORDS_PADDING ); m_controls->ForceCursorPosition( true, cursorPos ); if( evt->IsCancelInteractive() || ( started && evt->IsAction( &ACTIONS::undo ) ) ) @@ -2562,7 +2566,8 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent ) grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() ); VECTOR2I cursorPos = evt->HasPosition() ? evt->Position() : m_controls->GetMousePosition(); - cursorPos = GetClampedCoords( grid.BestSnapAnchor( cursorPos, layers ), COORDS_PADDING ); + cursorPos = GetClampedCoords( grid.BestSnapAnchor( cursorPos, layers, GRID_GRAPHICS ), + COORDS_PADDING ); m_controls->ForceCursorPosition( true, cursorPos );