Browse Source

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
pull/13/head
Seth Hillbrand 7 years ago
parent
commit
0de25e557b
  1. 10
      pcbnew/router/pns_tool_base.cpp
  2. 2
      pcbnew/router/pns_tool_base.h
  3. 7
      pcbnew/router/router_tool.cpp

10
pcbnew/router/pns_tool_base.cpp

@ -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();
@ -137,6 +138,9 @@ ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, b
if( !IsCopperLayer( item->Layers().Start() ) )
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;
@ -286,7 +290,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 );
}
@ -324,7 +328,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;

2
pcbnew/router/pns_tool_base.h

@ -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 );

7
pcbnew/router/router_tool.cpp

@ -54,6 +54,7 @@ using namespace std::placeholders;
#include <tools/pcb_actions.h>
#include <tools/selection_tool.h>
#include <tools/edit_tool.h>
#include <tools/grid_helper.h>
#include <tools/tool_event_utils.h>
#include "router_tool.h"
@ -1025,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 )
@ -1175,10 +1177,11 @@ 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( p0, m_startItem, dragMode );
bool dragStarted = m_router->StartDragging( p, m_startItem, dragMode );
if( !dragStarted )
return 0;

Loading…
Cancel
Save