diff --git a/pcbnew/router/pns_mouse_trail_tracer.cpp b/pcbnew/router/pns_mouse_trail_tracer.cpp index e88d808962..6f9940a6c0 100644 --- a/pcbnew/router/pns_mouse_trail_tracer.cpp +++ b/pcbnew/router/pns_mouse_trail_tracer.cpp @@ -257,5 +257,18 @@ void MOUSE_TRAIL_TRACER::FlipPosture() m_manuallyForced = true; } + +VECTOR2I MOUSE_TRAIL_TRACER::GetTrailLeadVector() const +{ + if( m_trail.PointCount() < 2 ) + { + return VECTOR2I(0, 0); + } + else + { + return m_trail.CPoint( -1 ) - m_trail.CPoint( 0 ); + } +} + } diff --git a/pcbnew/router/pns_mouse_trail_tracer.h b/pcbnew/router/pns_mouse_trail_tracer.h index a2cb59a581..41a542fcd3 100644 --- a/pcbnew/router/pns_mouse_trail_tracer.h +++ b/pcbnew/router/pns_mouse_trail_tracer.h @@ -59,6 +59,7 @@ public: bool IsManuallyForced() const { return m_manuallyForced; } + VECTOR2I GetTrailLeadVector() const; private: SHAPE_LINE_CHAIN m_trail; int m_tolerance; diff --git a/pcbnew/tools/pcb_grid_helper.cpp b/pcbnew/tools/pcb_grid_helper.cpp index 42c8122109..f6370fae69 100644 --- a/pcbnew/tools/pcb_grid_helper.cpp +++ b/pcbnew/tools/pcb_grid_helper.cpp @@ -79,6 +79,8 @@ VECTOR2I PCB_GRID_HELPER::AlignToSegment( const VECTOR2I& aPoint, const SEG& aSe { OPT_VECTOR2I pts[6]; + const int c_gridSnapEpsilon = 2; + if( !m_enableSnap ) return aPoint; @@ -97,7 +99,7 @@ VECTOR2I PCB_GRID_HELPER::AlignToSegment( const VECTOR2I& aPoint, const SEG& aSe for( int i = 0; i < 4; i++ ) { - if( pts[i] && aSeg.Contains( *pts[i] ) ) + if( pts[i] && aSeg.Distance( *pts[i] ) <= c_gridSnapEpsilon ) { int d = (*pts[i] - aPoint).EuclideanNorm();