pcbnew: Adjust drag snapping to avoid start
When dragging, you will seldom want to snap to the original item. This
commit prevents the "size of track" snap to the original item and
replaces it with an auxilary grid origin for the snap. This means
effectively that the snap will happen to grid for the original item
unless the cursor is closer to the original item line than it is to the
grid crossing.
Fixes: lp:1820248
* https://bugs.launchpad.net/kicad/+bug/1820248
(cherry picked from commit 0de25e557b
)
This commit is contained in:
parent
fc1fb7a590
commit
84db5644d6
|
@ -110,7 +110,8 @@ void TOOL_BASE::Reset( RESET_REASON aReason )
|
|||
}
|
||||
|
||||
|
||||
ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, bool aIgnorePads )
|
||||
ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, bool aIgnorePads,
|
||||
const std::vector<ITEM*> aAvoidItems)
|
||||
{
|
||||
int tl = getView()->GetTopLayer();
|
||||
|
||||
|
@ -140,6 +141,9 @@ ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, b
|
|||
if( !m_iface->IsAnyLayerVisible( item->Layers() ) )
|
||||
continue;
|
||||
|
||||
if( std::find( aAvoidItems.begin(), aAvoidItems.end(), item ) != aAvoidItems.end() )
|
||||
continue;
|
||||
|
||||
// fixme: this causes flicker with live loop removal...
|
||||
//if( item->Parent() && !item->Parent()->ViewIsVisible() )
|
||||
// continue;
|
||||
|
@ -289,7 +293,7 @@ void TOOL_BASE::updateStartItem( const TOOL_EVENT& aEvent, bool aIgnorePads )
|
|||
|
||||
m_startSnapPoint = snapToItem( snapEnabled, m_startItem, p );
|
||||
|
||||
if( checkSnap ( m_startItem ) )
|
||||
if( checkSnap( m_startItem ) )
|
||||
{
|
||||
controls()->ForceCursorPosition( true, m_startSnapPoint );
|
||||
}
|
||||
|
@ -327,7 +331,7 @@ void TOOL_BASE::updateEndItem( const TOOL_EVENT& aEvent )
|
|||
|
||||
for( int net : nets )
|
||||
{
|
||||
endItem = pickSingleItem( mousePos, net, layer );
|
||||
endItem = pickSingleItem( mousePos, net, layer, false, { m_startItem } );
|
||||
|
||||
if( endItem )
|
||||
break;
|
||||
|
|
|
@ -55,7 +55,7 @@ protected:
|
|||
bool checkSnap( ITEM* aItem );
|
||||
const VECTOR2I snapToItem( bool aEnabled, ITEM* aItem, VECTOR2I aP);
|
||||
virtual ITEM* pickSingleItem( const VECTOR2I& aWhere, int aNet = -1, int aLayer = -1,
|
||||
bool aIgnorePads = false );
|
||||
bool aIgnorePads = false, const std::vector<ITEM*> aAvoidItems = {} );
|
||||
virtual void highlightNet( bool aEnabled, int aNetcode = -1 );
|
||||
virtual void updateStartItem( const TOOL_EVENT& aEvent, bool aIgnorePads = false );
|
||||
virtual void updateEndItem( const TOOL_EVENT& aEvent );
|
||||
|
|
|
@ -1026,6 +1026,7 @@ void ROUTER_TOOL::performDragging( int aMode )
|
|||
return;
|
||||
}
|
||||
|
||||
m_gridHelper->SetAuxAxes( true, m_startSnapPoint, true );
|
||||
bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem, aMode );
|
||||
|
||||
if( !dragStarted )
|
||||
|
@ -1178,6 +1179,7 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
|
|||
|
||||
VECTOR2I p0 = controls()->GetCursorPosition( false );
|
||||
auto p = snapToItem( true, m_startItem, p0 );
|
||||
m_gridHelper->SetAuxAxes( true, p, true );
|
||||
int dragMode = aEvent.Parameter<int64_t> ();
|
||||
|
||||
bool dragStarted = m_router->StartDragging( p, m_startItem, dragMode );
|
||||
|
|
Loading…
Reference in New Issue