Make snapping size grid-dependent

Fixes https://gitlab.com/kicad/code/kicad/issues/5638

Fixes https://gitlab.com/kicad/code/kicad/issues/5588
This commit is contained in:
Seth Hillbrand 2020-09-15 11:30:53 -07:00
parent 08bf5f4b4e
commit 67a7aa8ba4
4 changed files with 4 additions and 12 deletions

View File

@ -44,7 +44,6 @@ EE_GRID_HELPER::EE_GRID_HELPER( TOOL_MANAGER* aToolMgr ) :
{
m_enableSnap = true;
m_enableSnapLine = true;
m_snapSize = 25;
m_snapItem = nullptr;
KIGFX::VIEW* view = m_toolMgr->GetView();
@ -251,9 +250,8 @@ VECTOR2I EE_GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, SCH_ITEM* aDra
VECTOR2I EE_GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& aLayers,
const std::vector<SCH_ITEM*>& aSkip )
{
double worldScale = m_toolMgr->GetView()->GetGAL()->GetWorldScale();
double snapDist = m_snapSize / worldScale;
int snapRange = KiROUND( snapDist );
int snapDist = GetGrid().x;
int snapRange = snapDist;
BOX2I bb( VECTOR2I( aOrigin.x - snapRange / 2, aOrigin.y - snapRange / 2 ),
VECTOR2I( snapRange, snapRange ) );
@ -291,7 +289,6 @@ VECTOR2I EE_GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& aL
if( snapLine && m_skipPoint != VECTOR2I( m_viewSnapLine.GetPosition() ) )
{
m_viewSnapLine.SetEndPosition( nearestGrid );
m_toolMgr->GetView()->SetVisible( &m_viewSnapPoint, false );
if( m_toolMgr->GetView()->IsVisible( &m_viewSnapLine ) )
m_toolMgr->GetView()->Update( &m_viewSnapLine, KIGFX::GEOMETRY );

View File

@ -147,7 +147,6 @@ private:
bool m_enableSnap; // If true, allow snapping to other items on the layers
bool m_enableSnapLine; // If true, allow drawing lines from snap points
int m_snapSize; // Sets the radius in screen units for snapping to items
ANCHOR* m_snapItem; // Pointer to the currently snapped item in m_anchors
// (NULL if not snapped)
VECTOR2I m_skipPoint; // When drawing a line, we avoid snapping to the source point

View File

@ -52,7 +52,6 @@ GRID_HELPER::GRID_HELPER( TOOL_MANAGER* aToolMgr, MAGNETIC_SETTINGS* aMagneticSe
m_enableSnap = true;
m_enableGrid = true;
m_enableSnapLine = true;
m_snapSize = 25;
m_snapItem = nullptr;
KIGFX::VIEW* view = m_toolMgr->GetView();
@ -305,9 +304,8 @@ VECTOR2I GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, BOARD_ITEM* aDrag
VECTOR2I GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& aLayers,
const std::vector<BOARD_ITEM*>& aSkip )
{
double worldScale = m_toolMgr->GetView()->GetGAL()->GetWorldScale();
double snapDist = m_snapSize / worldScale;
int snapRange = KiROUND( snapDist );
int snapDist = GetGrid().x;
int snapRange = snapDist;
BOX2I bb( VECTOR2I( aOrigin.x - snapRange / 2, aOrigin.y - snapRange / 2 ),
VECTOR2I( snapRange, snapRange ) );
@ -346,7 +344,6 @@ VECTOR2I GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& aLaye
if( snapLine && m_skipPoint != VECTOR2I( m_viewSnapLine.GetPosition() ) )
{
m_viewSnapLine.SetEndPosition( nearestGrid );
m_toolMgr->GetView()->SetVisible( &m_viewSnapPoint, false );
if( m_toolMgr->GetView()->IsVisible( &m_viewSnapLine ) )
m_toolMgr->GetView()->Update( &m_viewSnapLine, KIGFX::GEOMETRY );

View File

@ -153,7 +153,6 @@ private:
bool m_enableSnap; // If true, allow snapping to other items on the layers
bool m_enableGrid; // If true, allow snapping to grid
bool m_enableSnapLine; // If true, allow drawing lines from snap points
int m_snapSize; // Sets the radius in screen units for snapping to items
ANCHOR* m_snapItem; // Pointer to the currently snapped item in m_anchors
// (NULL if not snapped)
VECTOR2I m_skipPoint; // When drawing a line, we avoid snapping to the source point