Extract GetBusesAndWires function out of SCH_EDIT_FRAME::BreakSegments
This function is called by SCH_EDIT_FRAME::AddJunction
This commit is contained in:
parent
0328cae94c
commit
64105dcf84
|
@ -325,24 +325,9 @@ bool SCH_EDIT_FRAME::BreakSegments( const VECTOR2I& aPoint, SCH_SCREEN* aScreen
|
|||
if( aScreen == nullptr )
|
||||
aScreen = GetScreen();
|
||||
|
||||
bool brokenSegments = false;
|
||||
std::vector<SCH_LINE*> wires;
|
||||
bool brokenSegments = false;
|
||||
|
||||
for( SCH_ITEM* item : aScreen->Items().Overlapping( SCH_LINE_T, aPoint ) )
|
||||
{
|
||||
if( item->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } ) )
|
||||
{
|
||||
SCH_LINE* wire = static_cast<SCH_LINE*>( item );
|
||||
|
||||
if( IsPointOnSegment( wire->GetStartPoint(), wire->GetEndPoint(), aPoint )
|
||||
&& !wire->IsEndPoint( aPoint ) )
|
||||
{
|
||||
wires.push_back( wire );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for( SCH_LINE* wire : wires )
|
||||
for( SCH_LINE* wire : aScreen->GetBusesAndWires( aPoint, true ) )
|
||||
{
|
||||
BreakSegment( wire, aPoint, nullptr, aScreen );
|
||||
brokenSegments = true;
|
||||
|
|
|
@ -1382,6 +1382,29 @@ SCH_LINE* SCH_SCREEN::GetLine( const VECTOR2I& aPosition, int aAccuracy, int aLa
|
|||
}
|
||||
|
||||
|
||||
std::vector<SCH_LINE*> SCH_SCREEN::GetBusesAndWires( const VECTOR2I& aPosition,
|
||||
bool aIgnoreEndpoints ) const
|
||||
{
|
||||
std::vector<SCH_LINE*> retVal;
|
||||
|
||||
for( SCH_ITEM* item : Items().Overlapping( SCH_LINE_T, aPosition ) )
|
||||
{
|
||||
if( item->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } ) )
|
||||
{
|
||||
SCH_LINE* wire = static_cast<SCH_LINE*>( item );
|
||||
|
||||
if( aIgnoreEndpoints && wire->IsEndPoint( aPosition ) )
|
||||
continue;
|
||||
|
||||
if( IsPointOnSegment( wire->GetStartPoint(), wire->GetEndPoint(), aPosition ) )
|
||||
retVal.push_back( wire );
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
SCH_LABEL_BASE* SCH_SCREEN::GetLabel( const VECTOR2I& aPosition, int aAccuracy ) const
|
||||
{
|
||||
for( SCH_ITEM* item : Items().Overlapping( aPosition, aAccuracy ) )
|
||||
|
|
|
@ -436,6 +436,15 @@ public:
|
|||
return GetLine( aPosition, aAccuracy, LAYER_BUS, aSearchType );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return buses and wires passing through aPosition.
|
||||
*
|
||||
* @param aPosition Position to search for
|
||||
* @param aIgnoreEndpoints If true, ignore wires/buses with end points matching aPosition
|
||||
* @return Buses and wires
|
||||
*/
|
||||
std::vector<SCH_LINE*> GetBusesAndWires( const VECTOR2I& aPosition, bool aIgnoreEndpoints = false ) const;
|
||||
|
||||
/**
|
||||
* Return a label item located at \a aPosition.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue