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 )
|
if( aScreen == nullptr )
|
||||||
aScreen = GetScreen();
|
aScreen = GetScreen();
|
||||||
|
|
||||||
bool brokenSegments = false;
|
bool brokenSegments = false;
|
||||||
std::vector<SCH_LINE*> wires;
|
|
||||||
|
|
||||||
for( SCH_ITEM* item : aScreen->Items().Overlapping( SCH_LINE_T, aPoint ) )
|
for( SCH_LINE* wire : aScreen->GetBusesAndWires( aPoint, true ) )
|
||||||
{
|
|
||||||
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 )
|
|
||||||
{
|
{
|
||||||
BreakSegment( wire, aPoint, nullptr, aScreen );
|
BreakSegment( wire, aPoint, nullptr, aScreen );
|
||||||
brokenSegments = true;
|
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
|
SCH_LABEL_BASE* SCH_SCREEN::GetLabel( const VECTOR2I& aPosition, int aAccuracy ) const
|
||||||
{
|
{
|
||||||
for( SCH_ITEM* item : Items().Overlapping( aPosition, aAccuracy ) )
|
for( SCH_ITEM* item : Items().Overlapping( aPosition, aAccuracy ) )
|
||||||
|
|
|
@ -436,6 +436,15 @@ public:
|
||||||
return GetLine( aPosition, aAccuracy, LAYER_BUS, aSearchType );
|
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.
|
* Return a label item located at \a aPosition.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue