Anchor a selected wire at the edge of a drag which is connected to a non-drag item.
Fixes: lp:1827846 * https://bugs.launchpad.net/kicad/+bug/1827846
This commit is contained in:
parent
f40408187e
commit
cf046e0548
|
@ -440,35 +440,35 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aItem, wxPoint aPoint, EDA_ITEMS& aList )
|
void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, wxPoint aPoint,
|
||||||
|
EDA_ITEMS& aList )
|
||||||
{
|
{
|
||||||
for( SCH_ITEM* test = m_frame->GetScreen()->GetDrawItems(); test; test = test->Next() )
|
for( SCH_ITEM* test = m_frame->GetScreen()->GetDrawItems(); test; test = test->Next() )
|
||||||
{
|
{
|
||||||
if( test->IsSelected() || !test->IsConnectable() || !test->CanConnect( aItem ) )
|
if( test->IsSelected() || !test->IsConnectable() || !test->CanConnect( aOriginalItem ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
switch( test->Type() )
|
switch( test->Type() )
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
case SCH_LINE_T:
|
case SCH_LINE_T:
|
||||||
{
|
{
|
||||||
// Select wires/busses that are connected at one end and/or the other. Any
|
// Select wires/busses that are connected at one end and/or the other. Any
|
||||||
// unconnected ends must be flagged (STARTPOINT or ENDPOINT).
|
// unconnected ends must be flagged (STARTPOINT or ENDPOINT).
|
||||||
SCH_LINE* line = (SCH_LINE*) test;
|
SCH_LINE* testLine = (SCH_LINE*) test;
|
||||||
|
|
||||||
if( line->GetStartPoint() == aPoint )
|
if( testLine->GetStartPoint() == aPoint )
|
||||||
{
|
{
|
||||||
if( !( line->GetFlags() & SELECTEDNODE ) )
|
if( !( testLine->GetFlags() & SELECTEDNODE ) )
|
||||||
aList.push_back( line );
|
aList.push_back( testLine );
|
||||||
|
|
||||||
line->SetFlags( STARTPOINT | SELECTEDNODE );
|
testLine->SetFlags( STARTPOINT | SELECTEDNODE );
|
||||||
}
|
}
|
||||||
else if( line->GetEndPoint() == aPoint )
|
else if( testLine->GetEndPoint() == aPoint )
|
||||||
{
|
{
|
||||||
if( !( line->GetFlags() & SELECTEDNODE ) )
|
if( !( testLine->GetFlags() & SELECTEDNODE ) )
|
||||||
aList.push_back( line );
|
aList.push_back( testLine );
|
||||||
|
|
||||||
line->SetFlags( ENDPOINT | SELECTEDNODE );
|
testLine->SetFlags( ENDPOINT | SELECTEDNODE );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -481,10 +481,25 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aItem, wxPoint aPoint, EDA_
|
||||||
case SCH_COMPONENT_T:
|
case SCH_COMPONENT_T:
|
||||||
case SCH_NO_CONNECT_T:
|
case SCH_NO_CONNECT_T:
|
||||||
case SCH_JUNCTION_T:
|
case SCH_JUNCTION_T:
|
||||||
// Select connected items that have no wire between them.
|
if( test->IsConnected( aPoint ) )
|
||||||
if( aItem->Type() != SCH_LINE_T && test->IsConnected( aPoint ) )
|
{
|
||||||
aList.push_back( test );
|
// Connected to a wire: anchor the wire
|
||||||
|
if( aOriginalItem->Type() == SCH_LINE_T )
|
||||||
|
{
|
||||||
|
SCH_LINE* originalLine = (SCH_LINE*) aOriginalItem;
|
||||||
|
|
||||||
|
if( originalLine->GetStartPoint() == aPoint )
|
||||||
|
originalLine->ClearFlags( STARTPOINT );
|
||||||
|
else if( originalLine->GetEndPoint() == aPoint )
|
||||||
|
originalLine->ClearFlags( ENDPOINT );
|
||||||
|
}
|
||||||
|
// Connected directly to something else with no wire to adjust: pick up the
|
||||||
|
// component/no-connect/junction
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aList.push_back( test );
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCH_LABEL_T:
|
case SCH_LABEL_T:
|
||||||
|
@ -493,18 +508,21 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aItem, wxPoint aPoint, EDA_
|
||||||
case SCH_BUS_WIRE_ENTRY_T:
|
case SCH_BUS_WIRE_ENTRY_T:
|
||||||
case SCH_BUS_BUS_ENTRY_T:
|
case SCH_BUS_BUS_ENTRY_T:
|
||||||
// Select labels and bus entries that are connected to a wire being moved.
|
// Select labels and bus entries that are connected to a wire being moved.
|
||||||
if( aItem->Type() == SCH_LINE_T )
|
if( aOriginalItem->Type() == SCH_LINE_T )
|
||||||
{
|
{
|
||||||
std::vector<wxPoint> connections;
|
std::vector<wxPoint> connections;
|
||||||
test->GetConnectionPoints( connections );
|
test->GetConnectionPoints( connections );
|
||||||
|
|
||||||
for( wxPoint& point : connections )
|
for( wxPoint& point : connections )
|
||||||
{
|
{
|
||||||
if( aItem->HitTest( point ) )
|
if( aOriginalItem->HitTest( point ) )
|
||||||
aList.push_back( test );
|
aList.push_back( test );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ private:
|
||||||
///> Finds additional items for a drag operation.
|
///> Finds additional items for a drag operation.
|
||||||
///> Connected items with no wire are included (as there is no wire to adjust for the drag).
|
///> Connected items with no wire are included (as there is no wire to adjust for the drag).
|
||||||
///> Connected wires are included with any un-connected ends flagged (STARTPOINT or ENDPOINT).
|
///> Connected wires are included with any un-connected ends flagged (STARTPOINT or ENDPOINT).
|
||||||
void getConnectedDragItems( SCH_ITEM* aItem, wxPoint aPoint, EDA_ITEMS& aList );
|
void getConnectedDragItems( SCH_ITEM* aOriginalItem, wxPoint aPoint, EDA_ITEMS& aList );
|
||||||
|
|
||||||
///> Adds junctions if needed to each item in the list after they have been
|
///> Adds junctions if needed to each item in the list after they have been
|
||||||
///> moved.
|
///> moved.
|
||||||
|
|
Loading…
Reference in New Issue