router: when dragging segments, don't snap to other segments on the same layer. Fixes drag flickering for short segments.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/9720
This commit is contained in:
Tomasz Wlostowski 2021-12-15 01:46:03 +01:00
parent 2ae3a83b54
commit 965ab42938
3 changed files with 11 additions and 1 deletions

View File

@ -161,6 +161,7 @@ bool ROUTER::StartDragging( const VECTOR2I& aP, ITEM_SET aStartItems, int aDragM
{ {
m_dragger = std::make_unique<COMPONENT_DRAGGER>( this ); m_dragger = std::make_unique<COMPONENT_DRAGGER>( this );
m_forceMarkObstaclesMode = true; m_forceMarkObstaclesMode = true;
m_state = DRAG_COMPONENT;
} }
else else
{ {
@ -170,6 +171,7 @@ bool ROUTER::StartDragging( const VECTOR2I& aP, ITEM_SET aStartItems, int aDragM
m_forceMarkObstaclesMode = false; m_forceMarkObstaclesMode = false;
m_dragger = std::make_unique<DRAGGER>( this ); m_dragger = std::make_unique<DRAGGER>( this );
m_state = DRAG_SEGMENT;
} }
m_dragger->SetMode( aDragMode ); m_dragger->SetMode( aDragMode );
@ -187,7 +189,6 @@ bool ROUTER::StartDragging( const VECTOR2I& aP, ITEM_SET aStartItems, int aDragM
if( m_dragger->Start( aP, aStartItems ) ) if( m_dragger->Start( aP, aStartItems ) )
{ {
m_state = DRAG_SEGMENT;
return true; return true;
} }
else else

View File

@ -119,6 +119,7 @@ public:
{ {
IDLE, IDLE,
DRAG_SEGMENT, DRAG_SEGMENT,
DRAG_COMPONENT,
ROUTE_TRACK ROUTE_TRACK
}; };

View File

@ -243,6 +243,14 @@ bool TOOL_BASE::checkSnap( ITEM *aItem )
// Sync PNS engine settings with the general PCB editor options. // Sync PNS engine settings with the general PCB editor options.
auto& pnss = m_router->Settings(); auto& pnss = m_router->Settings();
// If we're dragging a track segment, don't try to snap to items on the same copper layer.
// This way we avoid 'flickery' behaviour for short segments when the snap algo is trying to
// snap to the corners of the segments next to the one being dragged.
if( m_startItem && aItem && m_router->GetState() == ROUTER::DRAG_SEGMENT
&& aItem->Layer() == m_startItem->Layer() && aItem->OfKind( ITEM::SEGMENT_T )
&& m_startItem->OfKind( ITEM::SEGMENT_T ) )
return false;
pnss.SetSnapToPads( pnss.SetSnapToPads(
frame()->GetMagneticItemsSettings()->pads == MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL || frame()->GetMagneticItemsSettings()->pads == MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL ||
frame()->GetMagneticItemsSettings()->pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS ); frame()->GetMagneticItemsSettings()->pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );