Drop a knee between tracks to a single item when dragging.

This prevents the disambiguation menu from coming up when we don't
really care which element we start the drag on.

Fixes https://gitlab.com/kicad/code/kicad/issues/10745

(cherry picked from commit ae85f57577)
This commit is contained in:
Jeff Young 2022-02-26 22:53:00 +00:00
parent 6341548939
commit 1c6f3f8f0d
1 changed files with 17 additions and 1 deletions

View File

@ -289,6 +289,22 @@ int EDIT_TOOL::Drag( const TOOL_EVENT& aEvent )
{ {
sTool->FilterCollectorForFreePads( aCollector ); sTool->FilterCollectorForFreePads( aCollector );
sTool->FilterCollectorForHierarchy( aCollector, true ); sTool->FilterCollectorForHierarchy( aCollector, true );
// drop a knee between two segments to a single segment
if( aCollector.GetCount() == 2 && dynamic_cast<PCB_TRACK*>( aCollector[0] ) )
{
static KICAD_T types[] = { PCB_VIA_T, PCB_TRACE_T, PCB_ARC_T, EOT };
PCB_TRACK* a = static_cast<PCB_TRACK*>( aCollector[0] );
PCB_TRACK* b = static_cast<PCB_TRACK*>( aCollector[1] );
const auto& c = aCollector[0]->GetBoard()->GetConnectivity();
int dist = a->GetWidth() / 2;
auto connectedItems = c->GetConnectedItemsAtAnchor( a, aPt, types, dist );
if( alg::contains( connectedItems, b ) )
aCollector.Remove( b );
}
}, },
true /* prompt user regarding locked items */ ); true /* prompt user regarding locked items */ );
@ -1213,8 +1229,8 @@ int EDIT_TOOL::FilletTracks( const TOOL_EVENT& aEvent )
auto processFilletOp = auto processFilletOp =
[&]( bool aStartPoint ) [&]( bool aStartPoint )
{ {
std::shared_ptr<CONNECTIVITY_DATA> connectivity = board()->GetConnectivity();
wxPoint anchor = ( aStartPoint ) ? track->GetStart() : track->GetEnd(); wxPoint anchor = ( aStartPoint ) ? track->GetStart() : track->GetEnd();
auto connectivity = board()->GetConnectivity();
auto itemsOnAnchor = connectivity->GetConnectedItemsAtAnchor( track, anchor, auto itemsOnAnchor = connectivity->GetConnectedItemsAtAnchor( track, anchor,
track_types ); track_types );