pcbnew: Ensure source snapping
Choosing the drag origin should not be dependent on the snap settings in pcbnew. Snap settings are sensible when you are designating a target only. Additionally, when dragging a module, we do not want the footprint's pads to be used as targets for snapping. Fixes: lp:1814402 * https://bugs.launchpad.net/kicad/+bug/1814402
This commit is contained in:
parent
5c3f6f2abf
commit
b461fc44ef
|
@ -372,10 +372,16 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
for( auto it : selection )
|
for( auto it : selection )
|
||||||
{
|
{
|
||||||
auto item = dynamic_cast<BOARD_ITEM*>( it );
|
if( auto item = dynamic_cast<BOARD_ITEM*>( it ) )
|
||||||
|
{
|
||||||
if( item )
|
|
||||||
sel_items.push_back( item );
|
sel_items.push_back( item );
|
||||||
|
|
||||||
|
if( auto mod = dyn_cast<MODULE*>( item ) )
|
||||||
|
{
|
||||||
|
for( auto pad : mod->Pads() )
|
||||||
|
sel_items.push_back( pad );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool restore_state = false;
|
bool restore_state = false;
|
||||||
|
|
|
@ -187,7 +187,7 @@ VECTOR2I GRID_HELPER::AlignToSegment( const VECTOR2I& aPoint, const SEG& aSeg )
|
||||||
VECTOR2I GRID_HELPER::BestDragOrigin( const VECTOR2I &aMousePos, BOARD_ITEM* aItem )
|
VECTOR2I GRID_HELPER::BestDragOrigin( const VECTOR2I &aMousePos, BOARD_ITEM* aItem )
|
||||||
{
|
{
|
||||||
clearAnchors();
|
clearAnchors();
|
||||||
computeAnchors( aItem, aMousePos );
|
computeAnchors( aItem, aMousePos, true );
|
||||||
|
|
||||||
double worldScale = m_frame->GetGalCanvas()->GetGAL()->GetWorldScale();
|
double worldScale = m_frame->GetGalCanvas()->GetGAL()->GetWorldScale();
|
||||||
double lineSnapMinCornerDistance = 50.0 / worldScale;
|
double lineSnapMinCornerDistance = 50.0 / worldScale;
|
||||||
|
@ -325,7 +325,7 @@ BOARD_ITEM* GRID_HELPER::GetSnapped( void ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos )
|
void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos, const bool aFrom )
|
||||||
{
|
{
|
||||||
VECTOR2I origin;
|
VECTOR2I origin;
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos )
|
||||||
|
|
||||||
for( auto pad : mod->Pads() )
|
for( auto pad : mod->Pads() )
|
||||||
{
|
{
|
||||||
if( m_frame->Settings().m_magneticPads == CAPTURE_ALWAYS &&
|
if( ( aFrom || m_frame->Settings().m_magneticPads == CAPTURE_ALWAYS ) &&
|
||||||
pad->GetBoundingBox().Contains( wxPoint( aRefPos.x, aRefPos.y ) ) )
|
pad->GetBoundingBox().Contains( wxPoint( aRefPos.x, aRefPos.y ) ) )
|
||||||
{
|
{
|
||||||
addAnchor( pad->GetPosition(), CORNER | SNAPPABLE, pad );
|
addAnchor( pad->GetPosition(), CORNER | SNAPPABLE, pad );
|
||||||
|
@ -352,7 +352,7 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos )
|
||||||
|
|
||||||
case PCB_PAD_T:
|
case PCB_PAD_T:
|
||||||
{
|
{
|
||||||
if( m_frame->Settings().m_magneticPads == CAPTURE_ALWAYS )
|
if( aFrom || m_frame->Settings().m_magneticPads == CAPTURE_ALWAYS )
|
||||||
{
|
{
|
||||||
D_PAD* pad = static_cast<D_PAD*>( aItem );
|
D_PAD* pad = static_cast<D_PAD*>( aItem );
|
||||||
addAnchor( pad->GetPosition(), CORNER | SNAPPABLE, pad );
|
addAnchor( pad->GetPosition(), CORNER | SNAPPABLE, pad );
|
||||||
|
@ -427,7 +427,7 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos )
|
||||||
|
|
||||||
case PCB_TRACE_T:
|
case PCB_TRACE_T:
|
||||||
{
|
{
|
||||||
if( m_frame->Settings().m_magneticTracks == CAPTURE_ALWAYS )
|
if( aFrom || m_frame->Settings().m_magneticTracks == CAPTURE_ALWAYS )
|
||||||
{
|
{
|
||||||
TRACK* track = static_cast<TRACK*>( aItem );
|
TRACK* track = static_cast<TRACK*>( aItem );
|
||||||
VECTOR2I start = track->GetStart();
|
VECTOR2I start = track->GetStart();
|
||||||
|
@ -449,7 +449,7 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos )
|
||||||
|
|
||||||
case PCB_VIA_T:
|
case PCB_VIA_T:
|
||||||
{
|
{
|
||||||
if( m_frame->Settings().m_magneticTracks == CAPTURE_ALWAYS )
|
if( aFrom || m_frame->Settings().m_magneticTracks == CAPTURE_ALWAYS )
|
||||||
addAnchor( aItem->GetPosition(), ORIGIN | CORNER | SNAPPABLE, aItem );
|
addAnchor( aItem->GetPosition(), ORIGIN | CORNER | SNAPPABLE, aItem );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -114,7 +114,15 @@ private:
|
||||||
|
|
||||||
ANCHOR* nearestAnchor( const VECTOR2I& aPos, int aFlags, LSET aMatchLayers );
|
ANCHOR* nearestAnchor( const VECTOR2I& aPos, int aFlags, LSET aMatchLayers );
|
||||||
|
|
||||||
void computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos );
|
/**
|
||||||
|
* computeAnchors inserts the local anchor points in to the grid helper for the specified
|
||||||
|
* board item, given the reference point and the direction of use for the point.
|
||||||
|
*
|
||||||
|
* @param aItem The board item for which to compute the anchors
|
||||||
|
* @param aRefPos The point for which to compute the anchors (if used by the component)
|
||||||
|
* @param aFrom Is this for an anchor that is designating a source point (aFrom=true) or not
|
||||||
|
*/
|
||||||
|
void computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos, const bool aFrom = false );
|
||||||
|
|
||||||
void clearAnchors()
|
void clearAnchors()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue