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;
65 mergedLines.emplace_back(
new SCH_LINE( *line ) );
71 if( item->HitTest( aPosition, -1 ) )
72 info.hasExplicitJunctionDot =
true;
78 info.hasBusEntry =
true;
87 if( mergedLines.size() + filtered.
size() < 2 )
95 if(
info.hasExplicitJunctionDot || aBreakCrossings )
100 for(
auto it_i = mergedLines.begin(); it_i != mergedLines.end() && !merged; ++it_i )
102 for(
auto it_j = std::next( it_i ); it_j != mergedLines.end(); ++it_j )
104 if(
auto* line = ( *it_i )->MergeOverlap(
nullptr, it_j->get(),
false ) )
107 mergedLines.erase( it_j );
115 for(
const auto& line : mergedLines )
116 filtered.
insert( line.get() );
120 int uniqueAngle = 10000;
122 for(
const SCH_ITEM* item : filtered )
127 switch( item->Type() )
130 if( item->HitTest( aPosition, -1 ) )
131 info.hasExplicitJunctionDot =
true;
151 breakLines[layer] =
true;
152 exitAngles[layer].insert( line->
GetAngleFrom( aPosition ) );
154 else if( line->
HitTest( aPosition, -1 ) )
156 if( aBreakCrossings )
157 breakLines[layer] =
true;
160 midPointLines[layer].push_back( line );
166 if( item->IsConnected( aPosition ) )
168 breakLines[BUSES] =
true;
169 exitAngles[BUSES].insert( uniqueAngle++ );
170 breakLines[WIRES] =
true;
171 exitAngles[WIRES].insert( uniqueAngle++ );
172 info.hasBusEntry =
true;
179 if( item->IsConnected( aPosition ) )
181 breakLines[WIRES] =
true;
182 exitAngles[WIRES].insert( uniqueAngle++ );
191 for(
int layer : { WIRES, BUSES } )
193 if( breakLines[layer] )
195 for(
const SCH_LINE* line : midPointLines[layer] )
197 exitAngles[layer].insert( line->GetAngleFrom( aPosition ) );
198 exitAngles[layer].insert( line->GetReverseAngleFrom( aPosition ) );
203 if(
info.hasBusEntry )
208 info.hasBusEntryToMultipleWires =
209 exitAngles[WIRES].size() > 2 && exitAngles[BUSES].size() == 1;
213 info.isJunction = exitAngles[WIRES].size() >= 3 || exitAngles[BUSES].size() >= 3;
220 const std::vector<SCH_ITEM*>& aItems )
227 if( !item->IsConnectable() )
236 if( !item || !item->IsConnectable() )
242 std::vector<VECTOR2I> pts;
246 if( !item || !item->IsConnectable() )
249 std::vector<VECTOR2I> new_pts = item->GetConnectionPoints();
250 pts.insert( pts.end(), new_pts.begin(), new_pts.end() );
256 for(
const VECTOR2I& pt : connections )
264 std::sort( pts.begin(), pts.end(),
267 return a.x < b.x || ( a.x == b.x && a.y < b.y );
270 pts.erase( std::unique( pts.begin(), pts.end() ), pts.end() );
272 std::vector<SCH_JUNCTION*> jcts;
278 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.
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