31 bool aBreakCrossings )
40 info.hasBusEntry =
false;
41 info.hasExplicitJunctionDot =
false;
42 info.isJunction =
false;
43 info.hasBusEntryToMultipleWires =
false;
45 bool breakLines[2] = {
false };
46 std::unordered_set<int> exitAngles[2];
47 std::vector<const SCH_LINE*> midPointLines[2];
50 std::list<std::unique_ptr<SCH_LINE>> mergedLines;
59 switch( item->Type() )
66 mergedLines.emplace_back(
new SCH_LINE( *line ) );
72 if( item->HitTest( aPosition, -1 ) )
73 info.hasExplicitJunctionDot =
true;
79 info.hasBusEntry =
true;
96 if( mergedLines.size() + filtered.
size() < 2 )
104 if(
info.hasExplicitJunctionDot || aBreakCrossings )
109 for(
auto it_i = mergedLines.begin(); it_i != mergedLines.end() && !merged; ++it_i )
111 for(
auto it_j = std::next( it_i ); it_j != mergedLines.end(); ++it_j )
113 if(
auto* line = ( *it_i )->MergeOverlap(
nullptr, it_j->get(),
false ) )
116 mergedLines.erase( it_j );
124 for(
const auto& line : mergedLines )
125 filtered.
insert( line.get() );
129 int uniqueAngle = 10000;
131 for(
const SCH_ITEM* item : filtered )
136 switch( item->Type() )
139 if( item->HitTest( aPosition, -1 ) )
140 info.hasExplicitJunctionDot =
true;
160 breakLines[layer] =
true;
161 exitAngles[layer].insert( line->
GetAngleFrom( aPosition ) );
163 else if( line->
HitTest( aPosition, -1 ) )
165 if( aBreakCrossings )
166 breakLines[layer] =
true;
169 midPointLines[layer].push_back( line );
175 if( item->IsConnected( aPosition ) )
177 breakLines[BUSES] =
true;
178 exitAngles[BUSES].insert( uniqueAngle++ );
179 breakLines[WIRES] =
true;
180 exitAngles[WIRES].insert( uniqueAngle++ );
181 info.hasBusEntry =
true;
188 if( item->IsConnected( aPosition ) )
190 breakLines[WIRES] =
true;
191 exitAngles[WIRES].insert( uniqueAngle++ );
197 if( item->IsConnected( aPosition ) )
200 breakLines[BUSES] =
true;
202 breakLines[WIRES] =
true;
209 if( item->IsConnected( aPosition ) )
210 breakLines[WIRES] =
true;
219 for(
int layer : { WIRES, BUSES } )
221 if( breakLines[layer] )
223 for(
const SCH_LINE* line : midPointLines[layer] )
225 exitAngles[layer].insert( line->GetAngleFrom( aPosition ) );
226 exitAngles[layer].insert( line->GetReverseAngleFrom( aPosition ) );
231 if(
info.hasBusEntry )
236 info.hasBusEntryToMultipleWires = exitAngles[WIRES].size() > 2 && exitAngles[BUSES].size() == 1;
240 info.isJunction = exitAngles[WIRES].size() >= 3 || exitAngles[BUSES].size() >= 3;
247 const std::vector<SCH_ITEM*>& aItems )
254 if( !item->IsConnectable() )
263 if( !item || !item->IsConnectable() )
269 std::vector<VECTOR2I> pts;
273 if( !item || !item->IsConnectable() )
276 std::vector<VECTOR2I> new_pts = item->GetConnectionPoints();
277 pts.insert( pts.end(), new_pts.begin(), new_pts.end() );
283 for(
const VECTOR2I& pt : connections )
291 std::sort( pts.begin(), pts.end(),
294 return a.x < b.x || ( a.x == b.x && a.y < b.y );
297 pts.erase( std::unique( pts.begin(), pts.end() ), pts.end() );
299 std::vector<SCH_JUNCTION*> jcts;
305 if(
info.isJunction && ( !
info.hasBusEntry ||
info.hasBusEntryToMultipleWires ) )
Implement an R-tree for fast spatial and type indexing of schematic items.
size_t size() const
Return the number of items in the tree.
EE_TYPE Overlapping(const BOX2I &aRect) const
void insert(SCH_ITEM *aItem)
Insert an item into the tree.
static bool IsBusLabel(const wxString &aLabel)
Test if aLabel has a bus notation.
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
bool IsConnected(const VECTOR2I &aPoint) const
Test the item to see if it is connected to aPoint.
Segment description base class to describe items which have 2 end points (track, wire,...
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
int GetAngleFrom(const VECTOR2I &aPoint) const
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
bool IsConnectable() const override
EE_RTREE & Items()
Get the full RTree, usually for iterating.
std::vector< VECTOR2I > GetConnections() const
Collect a unique list of all possible connection points in the schematic.
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
std::vector< SCH_JUNCTION * > PreviewJunctions(const class SCH_SCREEN *aScreen, const std::vector< class SCH_ITEM * > &aItems)
Determine the points where explicit junctions would be required if the given temporary items were com...
POINT_INFO AnalyzePoint(const EE_RTREE &aItem, const VECTOR2I &aPosition, bool aBreakCrossings)
Check a tree of items for a confluence at a given point and work out what kind of junction it is,...
A selection of information about a point in the schematic that might be eligible for turning into a j...
bool IsPointOnSegment(const VECTOR2I &aSegStart, const VECTOR2I &aSegEnd, const VECTOR2I &aTestPoint)
Test if aTestPoint is on line defined by aSegStart and aSegEnd.
VECTOR2< int32_t > VECTOR2I