7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-14 13:09:35 +00:00

Re-enable grid snap line

This was accidentally disabled by 4039b7da6b
This commit is contained in:
Seth Hillbrand 2024-08-08 14:28:58 -07:00
parent 7fc367e688
commit 094d265313
5 changed files with 15 additions and 7 deletions

View File

@ -41,7 +41,7 @@ GRID_HELPER::GRID_HELPER( TOOL_MANAGER* aToolMgr ) :
m_enableSnap = true;
m_enableSnapLine = true;
m_enableGrid = true;
m_snapItem = nullptr;
m_snapItem = std::nullopt;
}

View File

@ -236,7 +236,7 @@ VECTOR2I EE_GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, GRID_HELPER_GR
}
else if( snapPoint )
{
m_snapItem = nearest;
m_snapItem = *nearest;
m_viewSnapPoint.SetPosition( pt );
m_viewSnapLine.SetPosition( pt );

View File

@ -154,7 +154,6 @@ protected:
void clearAnchors()
{
m_anchors.clear();
m_snapItem = nullptr;
}
/**
@ -177,7 +176,7 @@ protected:
bool m_enableSnap; // Allow snapping to other items on the layers
bool m_enableGrid; // If true, allow snapping to grid
bool m_enableSnapLine; // Allow drawing lines from snap points
ANCHOR* m_snapItem; // Pointer to the currently snapped item in m_anchors
std::optional<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

@ -370,12 +370,12 @@ VECTOR2I PCB_GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& a
else
m_toolMgr->GetView()->SetVisible( &m_viewSnapPoint, true );
m_snapItem = nearest;
m_snapItem = *nearest;
return nearest->pos;
}
}
m_snapItem = nullptr;
m_snapItem = std::nullopt;
m_toolMgr->GetView()->SetVisible( &m_viewSnapPoint, false );
m_toolMgr->GetView()->SetVisible( &m_viewSnapLine, false );
return nearestGrid;

View File

@ -30,6 +30,7 @@
#include <pcb_item_containers.h>
#include <tool/grid_helper.h>
#include <board.h>
class LSET;
class SHAPE_ARC;
@ -37,7 +38,7 @@ class TOOL_MANAGER;
struct MAGNETIC_SETTINGS;
struct PCB_SELECTION_FILTER_OPTIONS;
class PCB_GRID_HELPER : public GRID_HELPER
class PCB_GRID_HELPER : public GRID_HELPER, public BOARD_LISTENER
{
public:
@ -66,6 +67,14 @@ public:
VECTOR2I AlignToNearestPad( const VECTOR2I& aMousePos, std::deque<PAD*>& aPads );
virtual void OnBoardItemRemoved( BOARD& aBoard, BOARD_ITEM* aBoardItem ) override
{
if( m_snapItem->item == aBoardItem )
{
m_snapItem = std::nullopt;
}
}
/**
* Chooses the "best" snap anchor around the given point, optionally taking layers from
* the reference item. The reference item will not be snapped to (it is being dragged or