1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
23  */
24 
25 #include <sch_draw_panel.h>
26 #include <bitmaps.h>
27 #include <core/mirror.h>
28 #include <schematic.h>
29 #include <sch_bus_entry.h>
30 #include <sch_edit_frame.h>
31 #include <sch_junction.h>
32 #include <sch_line.h>
33 #include <sch_text.h>
34 #include <project/net_settings.h>
35 #include <project/project_file.h>
36 #include <settings/color_settings.h>
37 #include <netclass.h>
38 #include <trigo.h>
39 #include <board_item.h>
40 #include <advanced_config.h>
41 #include <connection_graph.h>
42 #include "sch_painter.h"
43 
44 
SCH_BUS_ENTRY_BASE(KICAD_T aType,const wxPoint & pos,bool aFlipY)45 SCH_BUS_ENTRY_BASE::SCH_BUS_ENTRY_BASE( KICAD_T aType, const wxPoint& pos, bool aFlipY ) :
46     SCH_ITEM( nullptr, aType )
47 {
48     m_pos    = pos;
49     m_size.x = Mils2iu( DEFAULT_SCH_ENTRY_SIZE );
50     m_size.y = Mils2iu( DEFAULT_SCH_ENTRY_SIZE );
51 
52     m_stroke.SetWidth( 0 );
53     m_stroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT );
54     m_stroke.SetColor( COLOR4D::UNSPECIFIED );
55 
56     if( aFlipY )
57         m_size.y *= -1;
58 
59     m_isDanglingStart = m_isDanglingEnd = true;
60 
61     m_lastResolvedWidth = Mils2iu( DEFAULT_WIRE_WIDTH_MILS );
62     m_lastResolvedLineStyle = PLOT_DASH_TYPE::SOLID;
63     m_lastResolvedColor = COLOR4D::UNSPECIFIED;
64 }
65 
66 
SCH_BUS_WIRE_ENTRY(const wxPoint & pos,bool aFlipY)67 SCH_BUS_WIRE_ENTRY::SCH_BUS_WIRE_ENTRY( const wxPoint& pos, bool aFlipY ) :
68     SCH_BUS_ENTRY_BASE( SCH_BUS_WIRE_ENTRY_T, pos, aFlipY )
69 {
70     m_layer  = LAYER_WIRE;
71     m_connected_bus_item = nullptr;
72 
73     m_lastResolvedWidth = Mils2iu( DEFAULT_WIRE_WIDTH_MILS );
74     m_lastResolvedLineStyle = PLOT_DASH_TYPE::SOLID;
75     m_lastResolvedColor = COLOR4D::UNSPECIFIED;
76 }
77 
78 
SCH_BUS_WIRE_ENTRY(const wxPoint & pos,int aQuadrant)79 SCH_BUS_WIRE_ENTRY::SCH_BUS_WIRE_ENTRY( const wxPoint& pos, int aQuadrant ) :
80     SCH_BUS_ENTRY_BASE( SCH_BUS_WIRE_ENTRY_T, pos, false )
81 {
82     switch( aQuadrant )
83     {
84     case 1: m_size.x *=  1; m_size.y *= -1; break;
85     case 2: m_size.x *=  1; m_size.y *=  1; break;
86     case 3: m_size.x *= -1; m_size.y *=  1; break;
87     case 4: m_size.x *= -1; m_size.y *= -1; break;
88     default: wxFAIL_MSG( "SCH_BUS_WIRE_ENTRY ctor: unexpected quadrant" );
89     }
90 
91     m_layer  = LAYER_WIRE;
92     m_connected_bus_item = nullptr;
93 
94     m_lastResolvedWidth = Mils2iu( DEFAULT_WIRE_WIDTH_MILS );
95     m_lastResolvedLineStyle = PLOT_DASH_TYPE::SOLID;
96     m_lastResolvedColor = COLOR4D::UNSPECIFIED;
97 }
98 
99 
SCH_BUS_BUS_ENTRY(const wxPoint & pos,bool aFlipY)100 SCH_BUS_BUS_ENTRY::SCH_BUS_BUS_ENTRY( const wxPoint& pos, bool aFlipY ) :
101     SCH_BUS_ENTRY_BASE( SCH_BUS_BUS_ENTRY_T, pos, aFlipY )
102 {
103     m_layer = LAYER_BUS;
104     m_connected_bus_items[0] = nullptr;
105     m_connected_bus_items[1] = nullptr;
106 
107     m_lastResolvedWidth = Mils2iu( DEFAULT_WIRE_WIDTH_MILS );
108     m_lastResolvedLineStyle = PLOT_DASH_TYPE::SOLID;
109     m_lastResolvedColor = COLOR4D::UNSPECIFIED;
110 }
111 
112 
Clone() const113 EDA_ITEM* SCH_BUS_WIRE_ENTRY::Clone() const
114 {
115     return new SCH_BUS_WIRE_ENTRY( *this );
116 }
117 
118 
Clone() const119 EDA_ITEM* SCH_BUS_BUS_ENTRY::Clone() const
120 {
121     return new SCH_BUS_BUS_ENTRY( *this );
122 }
123 
124 
doIsConnected(const wxPoint & aPosition) const125 bool SCH_BUS_ENTRY_BASE::doIsConnected( const wxPoint& aPosition ) const
126 {
127     return ( m_pos == aPosition || GetEnd() == aPosition );
128 }
129 
130 
GetEnd() const131 wxPoint SCH_BUS_ENTRY_BASE::GetEnd() const
132 {
133     return wxPoint( m_pos.x + m_size.x, m_pos.y + m_size.y );
134 }
135 
136 
SwapData(SCH_ITEM * aItem)137 void SCH_BUS_ENTRY_BASE::SwapData( SCH_ITEM* aItem )
138 {
139     SCH_BUS_ENTRY_BASE* item = dynamic_cast<SCH_BUS_ENTRY_BASE*>( aItem );
140     wxCHECK_RET( item, wxT( "Cannot swap bus entry data with invalid item." ) );
141 
142     std::swap( m_pos, item->m_pos );
143     std::swap( m_size, item->m_size );
144     std::swap( m_stroke, item->m_stroke );
145 
146     std::swap( m_lastResolvedWidth, item->m_lastResolvedWidth );
147     std::swap( m_lastResolvedLineStyle, item->m_lastResolvedLineStyle );
148     std::swap( m_lastResolvedColor, item->m_lastResolvedColor );
149 }
150 
151 
ViewGetLayers(int aLayers[],int & aCount) const152 void SCH_BUS_ENTRY_BASE::ViewGetLayers( int aLayers[], int& aCount ) const
153 {
154     aCount     = 3;
155     aLayers[0] = LAYER_DANGLING;
156     aLayers[1] = Type() == SCH_BUS_BUS_ENTRY_T ? LAYER_BUS : LAYER_WIRE;
157     aLayers[2] = LAYER_SELECTION_SHADOWS;
158 }
159 
160 
GetBoundingBox() const161 const EDA_RECT SCH_BUS_ENTRY_BASE::GetBoundingBox() const
162 {
163     EDA_RECT box;
164 
165     box.SetOrigin( m_pos );
166     box.SetEnd( GetEnd() );
167 
168     box.Normalize();
169     box.Inflate( ( GetPenWidth() / 2 ) + 1 );
170 
171     return box;
172 }
173 
174 
GetStrokeColor() const175 COLOR4D SCH_BUS_ENTRY_BASE::GetStrokeColor() const
176 {
177     if( m_stroke.GetColor() != COLOR4D::UNSPECIFIED )
178     {
179         m_lastResolvedColor = m_stroke.GetColor();
180     }
181     else if( IsConnectable() && !IsConnectivityDirty() )
182     {
183         NETCLASSPTR netclass = NetClass();
184 
185         if( netclass )
186             m_lastResolvedColor = netclass->GetSchematicColor();
187     }
188 
189     return m_lastResolvedColor;
190 }
191 
192 
GetStrokeStyle() const193 PLOT_DASH_TYPE SCH_BUS_ENTRY_BASE::GetStrokeStyle() const
194 {
195     if( m_stroke.GetPlotStyle() != PLOT_DASH_TYPE::DEFAULT )
196     {
197         m_lastResolvedLineStyle = m_stroke.GetPlotStyle();
198     }
199     else if( IsConnectable() && !IsConnectivityDirty() )
200     {
201         NETCLASSPTR netclass = NetClass();
202 
203         if( netclass )
204             m_lastResolvedLineStyle = static_cast<PLOT_DASH_TYPE>( netclass->GetLineStyle() );
205     }
206 
207     return m_lastResolvedLineStyle;
208 }
209 
210 
GetPenWidth() const211 int SCH_BUS_WIRE_ENTRY::GetPenWidth() const
212 {
213     if( m_stroke.GetWidth() > 0 )
214     {
215         m_lastResolvedWidth = m_stroke.GetWidth();
216     }
217     else if( IsConnectable() && !IsConnectivityDirty() )
218     {
219         NETCLASSPTR netclass = NetClass();
220 
221         if( netclass )
222             m_lastResolvedWidth = netclass->GetWireWidth();
223     }
224 
225     return m_lastResolvedWidth;
226 }
227 
228 
GetPenWidth() const229 int SCH_BUS_BUS_ENTRY::GetPenWidth() const
230 {
231     if( m_stroke.GetWidth() > 0 )
232     {
233         m_lastResolvedWidth = m_stroke.GetWidth();
234     }
235     else if( IsConnectable() && !IsConnectivityDirty() )
236     {
237         NETCLASSPTR netclass = NetClass();
238 
239         if( netclass )
240             m_lastResolvedWidth = netclass->GetBusWidth();
241     }
242 
243     return m_lastResolvedWidth;
244 }
245 
246 
GetEndPoints(std::vector<DANGLING_END_ITEM> & aItemList)247 void SCH_BUS_WIRE_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
248 {
249     DANGLING_END_ITEM item( WIRE_ENTRY_END, this, m_pos );
250     aItemList.push_back( item );
251 
252     DANGLING_END_ITEM item1( WIRE_ENTRY_END, this, GetEnd() );
253     aItemList.push_back( item1 );
254 }
255 
256 
GetEndPoints(std::vector<DANGLING_END_ITEM> & aItemList)257 void SCH_BUS_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
258 {
259     DANGLING_END_ITEM item( BUS_ENTRY_END, this, m_pos );
260     aItemList.push_back( item );
261 
262     DANGLING_END_ITEM item1( BUS_ENTRY_END, this, GetEnd() );
263     aItemList.push_back( item1 );
264 }
265 
266 
Print(const RENDER_SETTINGS * aSettings,const wxPoint & aOffset)267 void SCH_BUS_ENTRY_BASE::Print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
268 {
269     wxDC*   DC = aSettings->GetPrintDC();
270     COLOR4D color = ( GetStrokeColor() == COLOR4D::UNSPECIFIED ) ?
271                     aSettings->GetLayerColor( m_layer ) : GetStrokeColor();
272     wxPoint start = m_pos + aOffset;
273     wxPoint end = GetEnd() + aOffset;
274     int     penWidth = ( GetPenWidth() == 0 ) ? aSettings->GetDefaultPenWidth() : GetPenWidth();
275 
276     if( GetStrokeStyle() <= PLOT_DASH_TYPE::FIRST_TYPE )
277     {
278         GRLine( nullptr, DC, start.x, start.y, end.x, end.y, penWidth, color );
279     }
280     else
281     {
282         EDA_RECT clip( (wxPoint) start, wxSize( end.x - start.x, end.y - start.y ) );
283         clip.Normalize();
284 
285         double theta = atan2( end.y - start.y, end.x - start.x );
286         double strokes[] = { 1.0, dash_gap_len( penWidth ), 1.0, dash_gap_len( penWidth ) };
287 
288         switch( GetStrokeStyle() )
289         {
290         default:
291         case PLOT_DASH_TYPE::DASH:
292             strokes[0] = strokes[2] = dash_mark_len( penWidth );
293             break;
294         case PLOT_DASH_TYPE::DOT:
295             strokes[0] = strokes[2] = dot_mark_len( penWidth );
296             break;
297         case PLOT_DASH_TYPE::DASHDOT:
298             strokes[0] = dash_mark_len( penWidth );
299             strokes[2] = dot_mark_len( penWidth );
300             break;
301         }
302 
303         for( size_t i = 0; i < 10000; ++i )
304         {
305             // Calculations MUST be done in doubles to keep from accumulating rounding
306             // errors as we go.
307             wxPoint next( start.x + strokes[ i % 4 ] * cos( theta ),
308                           start.y + strokes[ i % 4 ] * sin( theta ) );
309 
310             // Drawing each segment can be done rounded to ints.
311             wxPoint segStart( KiROUND( start.x ), KiROUND( start.y ) );
312             wxPoint segEnd( KiROUND( next.x ), KiROUND( next.y ) );
313 
314             if( ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
315                 break;
316             else if( i % 2 == 0 )
317                 GRLine( nullptr, DC, segStart.x, segStart.y, segEnd.x, segEnd.y, penWidth, color );
318 
319             start = next;
320         }
321     }
322 }
323 
324 
MirrorVertically(int aCenter)325 void SCH_BUS_ENTRY_BASE::MirrorVertically( int aCenter )
326 {
327     MIRROR( m_pos.y, aCenter );
328     m_size.y = -m_size.y;
329 }
330 
331 
MirrorHorizontally(int aCenter)332 void SCH_BUS_ENTRY_BASE::MirrorHorizontally( int aCenter )
333 {
334     MIRROR( m_pos.x, aCenter );
335     m_size.x = -m_size.x;
336 }
337 
338 
Rotate(const wxPoint & aCenter)339 void SCH_BUS_ENTRY_BASE::Rotate( const wxPoint& aCenter )
340 {
341     RotatePoint( &m_pos, aCenter, 900 );
342     RotatePoint( &m_size.x, &m_size.y, 900 );
343 }
344 
345 
UpdateDanglingState(std::vector<DANGLING_END_ITEM> & aItemList,const SCH_SHEET_PATH * aPath)346 bool SCH_BUS_WIRE_ENTRY::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
347                                               const SCH_SHEET_PATH* aPath )
348 {
349     bool previousStateStart = m_isDanglingStart;
350     bool previousStateEnd = m_isDanglingEnd;
351 
352     m_isDanglingStart = m_isDanglingEnd = true;
353 
354     // Store the connection type and state for the start (0) and end (1)
355     bool has_wire[2] = { false };
356     bool has_bus[2] = { false };
357 
358     for( unsigned ii = 0; ii < aItemList.size(); ii++ )
359     {
360         DANGLING_END_ITEM& item = aItemList[ii];
361 
362         if( item.GetItem() == this )
363             continue;
364 
365         switch( item.GetType() )
366         {
367         case WIRE_END:
368             if( m_pos == item.GetPosition() )
369                 has_wire[0] = true;
370             else if( GetEnd() == item.GetPosition() )
371                 has_wire[1] = true;
372 
373             break;
374 
375         case BUS_END:
376         {
377             // The bus has created 2 DANGLING_END_ITEMs, one per end.
378             DANGLING_END_ITEM& nextItem = aItemList[++ii];
379 
380             if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), m_pos ) )
381                 has_bus[0] = true;
382             else if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetEnd() ) )
383                 has_bus[1] = true;
384         }
385             break;
386 
387         default:
388             break;
389         }
390     }
391 
392     // A bus-wire entry is connected at both ends if it has a bus and a wire on its
393     // ends.  Otherwise, we connect only one end (in the case of a wire-wire or bus-bus)
394     if( ( has_wire[0] && has_bus[1] ) || ( has_wire[1] && has_bus[0] ) )
395         m_isDanglingEnd = m_isDanglingStart = false;
396     else if( has_wire[0] || has_bus[0] )
397         m_isDanglingStart = false;
398     else if( has_wire[1] || has_bus[1] )
399         m_isDanglingEnd = false;
400 
401     return (previousStateStart != m_isDanglingStart) || (previousStateEnd != m_isDanglingEnd);
402 }
403 
404 
UpdateDanglingState(std::vector<DANGLING_END_ITEM> & aItemList,const SCH_SHEET_PATH * aPath)405 bool SCH_BUS_BUS_ENTRY::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
406                                              const SCH_SHEET_PATH* aPath )
407 {
408     bool previousStateStart = m_isDanglingStart;
409     bool previousStateEnd = m_isDanglingEnd;
410 
411     m_isDanglingStart = m_isDanglingEnd = true;
412 
413     for( unsigned ii = 0; ii < aItemList.size(); ii++ )
414     {
415         DANGLING_END_ITEM& item = aItemList[ii];
416 
417         if( item.GetItem() == this )
418             continue;
419 
420         switch( item.GetType() )
421         {
422         case BUS_END:
423         {
424             // The bus has created 2 DANGLING_END_ITEMs, one per end.
425             DANGLING_END_ITEM& nextItem = aItemList[++ii];
426 
427             if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), m_pos ) )
428                 m_isDanglingStart = false;
429             if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetEnd() ) )
430                 m_isDanglingEnd = false;
431         }
432             break;
433 
434         default:
435             break;
436         }
437     }
438 
439     return (previousStateStart != m_isDanglingStart) || (previousStateEnd != m_isDanglingEnd);
440 }
441 
442 
IsDangling() const443 bool SCH_BUS_ENTRY_BASE::IsDangling() const
444 {
445     return m_isDanglingStart || m_isDanglingEnd;
446 }
447 
448 
GetConnectionPoints() const449 std::vector<wxPoint> SCH_BUS_ENTRY_BASE::GetConnectionPoints() const
450 {
451     return { m_pos, GetEnd() };
452 }
453 
454 
GetSelectMenuText(EDA_UNITS aUnits) const455 wxString SCH_BUS_WIRE_ENTRY::GetSelectMenuText( EDA_UNITS aUnits ) const
456 {
457     return wxString( _( "Bus to Wire Entry" ) );
458 }
459 
460 
GetSelectMenuText(EDA_UNITS aUnits) const461 wxString SCH_BUS_BUS_ENTRY::GetSelectMenuText( EDA_UNITS aUnits ) const
462 {
463     return wxString( _( "Bus to Bus Entry" ) );
464 }
465 
466 
GetMenuImage() const467 BITMAPS SCH_BUS_WIRE_ENTRY::GetMenuImage() const
468 {
469     return BITMAPS::add_line2bus;
470 }
471 
472 
GetMenuImage() const473 BITMAPS SCH_BUS_BUS_ENTRY::GetMenuImage() const
474 {
475     return BITMAPS::add_bus2bus;
476 }
477 
478 
HitTest(const wxPoint & aPosition,int aAccuracy) const479 bool SCH_BUS_ENTRY_BASE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
480 {
481     // Insure minimum accuracy
482     if( aAccuracy == 0 )
483         aAccuracy = ( GetPenWidth() / 2 ) + 4;
484 
485     return TestSegmentHit( aPosition, m_pos, GetEnd(), aAccuracy );
486 }
487 
488 
HitTest(const EDA_RECT & aRect,bool aContained,int aAccuracy) const489 bool SCH_BUS_ENTRY_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
490 {
491     EDA_RECT rect = aRect;
492 
493     rect.Inflate( aAccuracy );
494 
495     if( aContained )
496         return rect.Contains( GetBoundingBox() );
497 
498     return rect.Intersects( GetBoundingBox() );
499 }
500 
501 
Plot(PLOTTER * aPlotter) const502 void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter ) const
503 {
504     auto* settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
505 
506     COLOR4D color = ( GetStrokeColor() == COLOR4D::UNSPECIFIED ) ?
507                     settings->GetLayerColor( m_layer ) : GetStrokeColor();
508     int     penWidth = ( GetPenWidth() == 0 ) ? settings->GetDefaultPenWidth() : GetPenWidth();
509 
510     penWidth = std::max( penWidth, settings->GetMinPenWidth() );
511 
512     aPlotter->SetCurrentLineWidth( penWidth );
513     aPlotter->SetColor( color );
514     aPlotter->SetDash( GetStrokeStyle() );
515     aPlotter->MoveTo( m_pos );
516     aPlotter->FinishTo( GetEnd() );
517 }
518 
519 
GetMsgPanelInfo(EDA_DRAW_FRAME * aFrame,std::vector<MSG_PANEL_ITEM> & aList)520 void SCH_BUS_ENTRY_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
521                                           std::vector<MSG_PANEL_ITEM>& aList )
522 {
523     wxString msg;
524 
525     switch( GetLayer() )
526     {
527     default:
528     case LAYER_WIRE: msg = _( "Wire" ); break;
529     case LAYER_BUS:  msg = _( "Bus" );  break;
530     }
531 
532     aList.emplace_back( _( "Bus Entry Type" ), msg );
533 
534     SCH_CONNECTION* conn = nullptr;
535 
536     if( !IsConnectivityDirty() && dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) )
537         conn = Connection();
538 
539     if( conn )
540     {
541         conn->AppendInfoToMsgPanel( aList );
542 
543         if( !conn->IsBus() )
544         {
545             NET_SETTINGS& netSettings = Schematic()->Prj().GetProjectFile().NetSettings();
546             wxString netname = conn->Name();
547             wxString netclassName = netSettings.m_NetClasses.GetDefaultPtr()->GetName();
548 
549             if( netSettings.m_NetClassAssignments.count( netname ) )
550                 netclassName = netSettings.m_NetClassAssignments[ netname ];
551 
552             aList.emplace_back( _( "Assigned Netclass" ), netclassName );
553         }
554     }
555 }
556 
557 
operator <(const SCH_ITEM & aItem) const558 bool SCH_BUS_ENTRY_BASE::operator <( const SCH_ITEM& aItem ) const
559 {
560     if( Type() != aItem.Type() )
561         return Type() < aItem.Type();
562 
563     auto symbol = static_cast<const SCH_BUS_ENTRY_BASE*>( &aItem );
564 
565     if( GetLayer() != symbol->GetLayer() )
566         return GetLayer() < symbol->GetLayer();
567 
568     if( GetPosition().x != symbol->GetPosition().x )
569         return GetPosition().x < symbol->GetPosition().x;
570 
571     if( GetPosition().y != symbol->GetPosition().y )
572         return GetPosition().y < symbol->GetPosition().y;
573 
574     if( GetEnd().x != symbol->GetEnd().x )
575         return GetEnd().x < symbol->GetEnd().x;
576 
577     return GetEnd().y < symbol->GetEnd().y;
578 }
579 
580 
ConnectionPropagatesTo(const EDA_ITEM * aItem) const581 bool SCH_BUS_WIRE_ENTRY::ConnectionPropagatesTo( const EDA_ITEM* aItem ) const
582 {
583     // Don't generate connections between bus entries and buses, since there is
584     // a connectivity change at that point (e.g. A[7..0] to A7)
585     if( ( aItem->Type() == SCH_LINE_T ) &&
586         ( static_cast<const SCH_LINE*>( aItem )->GetLayer() == LAYER_BUS ) )
587     {
588         return false;
589     }
590 
591     // Same for bus junctions
592     if( ( aItem->Type() == SCH_JUNCTION_T ) &&
593         ( static_cast<const SCH_JUNCTION*>( aItem )->GetLayer() == LAYER_BUS_JUNCTION ) )
594     {
595         return false;
596     }
597 
598     // Don't generate connections between bus entries and bus labels that happen
599     // to land at the same point on the bus wire as this bus entry
600     if( ( aItem->Type() == SCH_LABEL_T ) &&
601         SCH_CONNECTION::IsBusLabel( static_cast<const SCH_LABEL*>( aItem )->GetText() ) )
602     {
603         return false;
604     }
605 
606     // Don't generate connections between two bus-wire entries
607     if( aItem->Type() == SCH_BUS_WIRE_ENTRY_T )
608         return false;
609 
610     return true;
611 }
612