KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_bus_entry.cpp
Go to the documentation of this file.
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-2024 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>
30#include <sch_bus_entry.h>
31#include <sch_edit_frame.h>
32#include <sch_junction.h>
33#include <sch_line.h>
34#include <sch_label.h>
38#include <netclass.h>
39#include <trigo.h>
40#include <board_item.h>
41#include <advanced_config.h>
42#include <connection_graph.h>
43#include "sch_painter.h"
44#include "plotters/plotter.h"
45
46
47SCH_BUS_ENTRY_BASE::SCH_BUS_ENTRY_BASE( KICAD_T aType, const VECTOR2I& pos, bool aFlipY ) :
48 SCH_ITEM( nullptr, aType )
49{
50 m_pos = pos;
53
54 m_stroke.SetWidth( 0 );
55 m_stroke.SetLineStyle( LINE_STYLE::DEFAULT );
56 m_stroke.SetColor( COLOR4D::UNSPECIFIED );
57
58 if( aFlipY )
59 m_size.y *= -1;
60
62
64 m_lastResolvedLineStyle = LINE_STYLE::SOLID;
65 m_lastResolvedColor = COLOR4D::UNSPECIFIED;
66}
67
68
71{
73 m_connected_bus_item = nullptr;
74
76 m_lastResolvedLineStyle = LINE_STYLE::SOLID;
77 m_lastResolvedColor = COLOR4D::UNSPECIFIED;
78}
79
80
83{
84 switch( aQuadrant )
85 {
86 case 1: m_size.x *= 1; m_size.y *= -1; break;
87 case 2: m_size.x *= 1; m_size.y *= 1; break;
88 case 3: m_size.x *= -1; m_size.y *= 1; break;
89 case 4: m_size.x *= -1; m_size.y *= -1; break;
90 default: wxFAIL_MSG( wxS( "SCH_BUS_WIRE_ENTRY ctor: unexpected quadrant" ) );
91 }
92
94 m_connected_bus_item = nullptr;
95
97 m_lastResolvedLineStyle = LINE_STYLE::SOLID;
98 m_lastResolvedColor = COLOR4D::UNSPECIFIED;
99}
100
101
104{
106 m_connected_bus_items[0] = nullptr;
107 m_connected_bus_items[1] = nullptr;
108
110 m_lastResolvedLineStyle = LINE_STYLE::SOLID;
111 m_lastResolvedColor = COLOR4D::UNSPECIFIED;
112}
113
114
116{
117 return new SCH_BUS_WIRE_ENTRY( *this );
118}
119
120
122{
123 return new SCH_BUS_BUS_ENTRY( *this );
124}
125
126
127bool SCH_BUS_ENTRY_BASE::doIsConnected( const VECTOR2I& aPosition ) const
128{
129 return ( m_pos == aPosition || GetEnd() == aPosition );
130}
131
132
134{
135 return VECTOR2I( m_pos.x + m_size.x, m_pos.y + m_size.y );
136}
137
138
140{
141 SCH_ITEM::SwapFlags( aItem );
142
143 SCH_BUS_ENTRY_BASE* item = dynamic_cast<SCH_BUS_ENTRY_BASE*>( aItem );
144 wxCHECK_RET( item, wxT( "Cannot swap bus entry data with invalid item." ) );
145
146 std::swap( m_pos, item->m_pos );
147 std::swap( m_size, item->m_size );
148 std::swap( m_stroke, item->m_stroke );
149
150 std::swap( m_lastResolvedWidth, item->m_lastResolvedWidth );
152 std::swap( m_lastResolvedColor, item->m_lastResolvedColor );
153}
154
155
156void SCH_BUS_ENTRY_BASE::ViewGetLayers( int aLayers[], int& aCount ) const
157{
158 aCount = 3;
159 aLayers[0] = LAYER_DANGLING;
160 aLayers[1] = Type() == SCH_BUS_BUS_ENTRY_T ? LAYER_BUS : LAYER_WIRE;
161 aLayers[2] = LAYER_SELECTION_SHADOWS;
162}
163
164
166{
167 BOX2I bbox( m_pos );
168 bbox.SetEnd( GetEnd() );
169
170 bbox.Normalize();
171 bbox.Inflate( ( GetPenWidth() / 2 ) + 1 );
172
173 return bbox;
174}
175
176
178{
179 if( m_stroke.GetColor() != COLOR4D::UNSPECIFIED )
181 else if( IsConnectable() && !IsConnectivityDirty() )
182 m_lastResolvedColor = GetEffectiveNetClass()->GetSchematicColor();
183
184 return m_lastResolvedColor;
185}
186
187
189{
190 m_stroke.SetWidth( aWidth );
191 m_lastResolvedWidth = aWidth;
192}
193
194
196{
197 return m_lastResolvedWidth;
198}
199
200
202{
203 m_stroke.SetColor( aColor );
204 m_lastResolvedColor = aColor;
205}
206
207
209{
210 if( m_stroke.GetLineStyle() != LINE_STYLE::DEFAULT )
212 else if( IsConnectable() && !IsConnectivityDirty() )
214
216}
217
218
220{
221 m_stroke.SetLineStyle( aStyle );
223}
224
225
227{
228 if( m_stroke.GetWidth() > 0 )
230 else if( IsConnectable() && !IsConnectivityDirty() )
231 m_lastResolvedWidth = GetEffectiveNetClass()->GetWireWidth();
232
233 return m_lastResolvedWidth;
234}
235
236
238{
239 if( m_stroke.GetWidth() > 0 )
241 else if( IsConnectable() && !IsConnectivityDirty() )
242 m_lastResolvedWidth = GetEffectiveNetClass()->GetBusWidth();
243
244 return m_lastResolvedWidth;
245}
246
247
248void SCH_BUS_WIRE_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
249{
251 aItemList.push_back( item );
252
253 DANGLING_END_ITEM item1( WIRE_ENTRY_END, this, GetEnd() );
254 aItemList.push_back( item1 );
255}
256
257
258void SCH_BUS_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
259{
261 aItemList.push_back( item );
262
263 DANGLING_END_ITEM item1( BUS_ENTRY_END, this, GetEnd() );
264 aItemList.push_back( item1 );
265}
266
267
268void SCH_BUS_ENTRY_BASE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
269 const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed )
270{
271 wxDC* DC = aSettings->GetPrintDC();
272 COLOR4D color = ( GetBusEntryColor() == COLOR4D::UNSPECIFIED ) ?
273 aSettings->GetLayerColor( m_layer ) : GetBusEntryColor();
274 VECTOR2I start = m_pos + aOffset;
275 VECTOR2I end = GetEnd() + aOffset;
276 int penWidth = ( GetPenWidth() == 0 ) ? aSettings->GetDefaultPenWidth() : GetPenWidth();
277
278 if( GetLineStyle() <= LINE_STYLE::FIRST_TYPE )
279 {
280 GRLine( DC, start.x, start.y, end.x, end.y, penWidth, color );
281 }
282 else
283 {
284 SHAPE_SEGMENT segment( start, end );
285
286 STROKE_PARAMS::Stroke( &segment, GetLineStyle(), penWidth, aSettings,
287 [&]( const VECTOR2I& a, const VECTOR2I& b )
288 {
289 GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
290 } );
291 }
292}
293
294
296{
297 MIRROR( m_pos.y, aCenter );
298 m_size.y = -m_size.y;
299}
300
301
303{
304 MIRROR( m_pos.x, aCenter );
305 m_size.x = -m_size.x;
306}
307
308
309void SCH_BUS_ENTRY_BASE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
310{
311 RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_270 : ANGLE_90 );
312 RotatePoint( &m_size.x, &m_size.y, aRotateCCW ? ANGLE_270 : ANGLE_90 );
313}
314
315
316bool SCH_BUS_WIRE_ENTRY::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
317 std::vector<DANGLING_END_ITEM>& aItemListByPos,
318 const SCH_SHEET_PATH* aPath )
319{
320 bool previousStateStart = m_isDanglingStart;
321 bool previousStateEnd = m_isDanglingEnd;
322
324
325 // Store the connection type and state for the start (0) and end (1)
326 bool has_wire[2] = { false };
327 bool has_bus[2] = { false };
328
329 for( unsigned ii = 0; ii < aItemListByType.size(); ii++ )
330 {
331 DANGLING_END_ITEM& item = aItemListByType[ii];
332
333 if( item.GetItem() == this )
334 continue;
335
336 switch( item.GetType() )
337 {
338 case WIRE_END:
339 if( m_pos == item.GetPosition() )
340 has_wire[0] = true;
341 else if( GetEnd() == item.GetPosition() )
342 has_wire[1] = true;
343
344 break;
345
346 case BUS_END:
347 {
348 // The bus has created 2 DANGLING_END_ITEMs, one per end.
349 DANGLING_END_ITEM& nextItem = aItemListByType[++ii];
350
351 if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), m_pos ) )
352 has_bus[0] = true;
353 else if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetEnd() ) )
354 has_bus[1] = true;
355 }
356 break;
357
358 default:
359 break;
360 }
361 }
362
363 // A bus-wire entry is connected at both ends if it has a bus and a wire on its
364 // ends. Otherwise, we connect only one end (in the case of a wire-wire or bus-bus)
365 if( ( has_wire[0] && has_bus[1] ) || ( has_wire[1] && has_bus[0] ) )
367 else if( has_wire[0] || has_bus[0] )
368 m_isDanglingStart = false;
369 else if( has_wire[1] || has_bus[1] )
370 m_isDanglingEnd = false;
371
372 return (previousStateStart != m_isDanglingStart) || (previousStateEnd != m_isDanglingEnd);
373}
374
375
376bool SCH_BUS_BUS_ENTRY::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
377 std::vector<DANGLING_END_ITEM>& aItemListByPos,
378 const SCH_SHEET_PATH* aPath )
379{
380 bool previousStateStart = m_isDanglingStart;
381 bool previousStateEnd = m_isDanglingEnd;
382
384
385 // TODO: filter using get_lower as we only use one item type
386 for( unsigned ii = 0; ii < aItemListByType.size(); ii++ )
387 {
388 DANGLING_END_ITEM& item = aItemListByType[ii];
389
390 if( item.GetItem() == this )
391 continue;
392
393 switch( item.GetType() )
394 {
395 case BUS_END:
396 {
397 // The bus has created 2 DANGLING_END_ITEMs, one per end.
398 DANGLING_END_ITEM& nextItem = aItemListByType[++ii];
399
400 if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), m_pos ) )
401 m_isDanglingStart = false;
402 if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetEnd() ) )
403 m_isDanglingEnd = false;
404 }
405 break;
406
407 default:
408 break;
409 }
410 }
411
412 return (previousStateStart != m_isDanglingStart) || (previousStateEnd != m_isDanglingEnd);
413}
414
415
417{
419}
420
421
422std::vector<VECTOR2I> SCH_BUS_ENTRY_BASE::GetConnectionPoints() const
423{
424 return { m_pos, GetEnd() };
425}
426
427
429 const SCH_SHEET_PATH* aInstance ) const
430{
431 // Do not compare to ourself.
432 if( aItem == this )
433 return false;
434
435 const SCH_BUS_ENTRY_BASE* busEntry = dynamic_cast<const SCH_BUS_ENTRY_BASE*>( aItem );
436
437 // Don't compare against a different SCH_ITEM.
438 wxCHECK( busEntry, false );
439
440 if( GetPosition() != busEntry->GetPosition() )
441 return true;
442
443 return GetEnd() != busEntry->GetEnd();
444}
445
446
448{
449 return wxString( _( "Bus to Wire Entry" ) );
450}
451
452
454{
455 return wxString( _( "Bus to Bus Entry" ) );
456}
457
458
460{
461 return BITMAPS::add_line2bus;
462}
463
464
466{
467 return BITMAPS::add_bus2bus;
468}
469
470
471bool SCH_BUS_ENTRY_BASE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
472{
473 // Insure minimum accuracy
474 if( aAccuracy == 0 )
475 aAccuracy = ( GetPenWidth() / 2 ) + 4;
476
477 return TestSegmentHit( aPosition, m_pos, GetEnd(), aAccuracy );
478}
479
480
481bool SCH_BUS_ENTRY_BASE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
482{
483 BOX2I rect = aRect;
484
485 rect.Inflate( aAccuracy );
486
487 if( aContained )
488 return rect.Contains( GetBoundingBox() );
489
490 return rect.Intersects( GetBoundingBox() );
491}
492
493
494void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
495 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
496{
497 if( aBackground )
498 return;
499
500 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
501
502 COLOR4D color = ( GetBusEntryColor() == COLOR4D::UNSPECIFIED )
503 ? renderSettings->GetLayerColor( m_layer ) : GetBusEntryColor();
504
505 int penWidth = ( GetPenWidth() == 0 ) ? renderSettings->GetDefaultPenWidth() : GetPenWidth();
506
507 penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() );
508
509 aPlotter->SetCurrentLineWidth( penWidth );
510 aPlotter->SetColor( color );
511 aPlotter->SetDash( penWidth, GetLineStyle() );
512 aPlotter->MoveTo( m_pos );
513 aPlotter->FinishTo( GetEnd() );
514
515 aPlotter->SetDash( penWidth, LINE_STYLE::SOLID );
516}
517
518
520 std::vector<MSG_PANEL_ITEM>& aList )
521{
522 wxString msg;
523
524 switch( GetLayer() )
525 {
526 default:
527 case LAYER_WIRE: msg = _( "Wire" ); break;
528 case LAYER_BUS: msg = _( "Bus" ); break;
529 }
530
531 aList.emplace_back( _( "Bus Entry Type" ), msg );
532
533 SCH_CONNECTION* conn = nullptr;
534
535 if( !IsConnectivityDirty() && dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) )
536 conn = Connection();
537
538 if( conn )
539 {
540 conn->AppendInfoToMsgPanel( aList );
541
542 if( !conn->IsBus() )
543 aList.emplace_back( _( "Resolved Netclass" ), GetEffectiveNetClass()->GetName() );
544 }
545}
546
547
548bool SCH_BUS_ENTRY_BASE::operator <( const SCH_ITEM& aItem ) const
549{
550 if( Type() != aItem.Type() )
551 return Type() < aItem.Type();
552
553 auto symbol = static_cast<const SCH_BUS_ENTRY_BASE*>( &aItem );
554
555 if( GetLayer() != symbol->GetLayer() )
556 return GetLayer() < symbol->GetLayer();
557
558 if( GetPosition().x != symbol->GetPosition().x )
559 return GetPosition().x < symbol->GetPosition().x;
560
561 if( GetPosition().y != symbol->GetPosition().y )
562 return GetPosition().y < symbol->GetPosition().y;
563
564 if( GetEnd().x != symbol->GetEnd().x )
565 return GetEnd().x < symbol->GetEnd().x;
566
567 return GetEnd().y < symbol->GetEnd().y;
568}
569
570
572{
573 // Don't generate connections between bus entries and buses, since there is
574 // a connectivity change at that point (e.g. A[7..0] to A7)
575 if( ( aItem->Type() == SCH_LINE_T ) &&
576 ( static_cast<const SCH_LINE*>( aItem )->GetLayer() == LAYER_BUS ) )
577 {
578 return false;
579 }
580
581 // Same for bus junctions
582 if( ( aItem->Type() == SCH_JUNCTION_T ) &&
583 ( static_cast<const SCH_JUNCTION*>( aItem )->GetLayer() == LAYER_BUS_JUNCTION ) )
584 {
585 return false;
586 }
587
588 // Don't generate connections between bus entries and bus labels that happen
589 // to land at the same point on the bus wire as this bus entry
590 if( ( aItem->Type() == SCH_LABEL_T ) &&
591 SCH_CONNECTION::IsBusLabel( static_cast<const SCH_LABEL*>( aItem )->GetText() ) )
592 {
593 return false;
594 }
595
596 // Don't generate connections between two bus-wire entries
597 if( aItem->Type() == SCH_BUS_WIRE_ENTRY_T )
598 return false;
599
600 return true;
601}
602
603bool SCH_BUS_ENTRY_BASE::operator==( const SCH_ITEM& aItem ) const
604{
605 if( Type() != aItem.Type() )
606 return false;
607
608 const SCH_BUS_ENTRY_BASE* symbol = static_cast<const SCH_BUS_ENTRY_BASE*>( &aItem );
609
610 if( GetLayer() != symbol->GetLayer() )
611 return false;
612
613 if( GetPosition() != symbol->GetPosition() )
614 return false;
615
616 if( GetEnd() != symbol->GetEnd() )
617 return false;
618
619 return true;
620}
621
622
623double SCH_BUS_ENTRY_BASE::Similarity( const SCH_ITEM& aItem ) const
624{
625 if( aItem.Type() != Type() )
626 return 0.0;
627
628 if( m_Uuid == aItem.m_Uuid )
629 return 1.0;
630
631 const SCH_BUS_ENTRY_BASE& other = static_cast<const SCH_BUS_ENTRY_BASE&>( aItem );
632
633 if( GetLayer() != other.GetLayer() )
634 return 0.0;
635
636 if( GetPosition() != other.GetPosition() )
637 return 0.0;
638
639 return 1.0;
640}
641
642
644{
646 {
654
656
657 if( plotDashTypeEnum.Choices().GetCount() == 0 )
658 {
659 plotDashTypeEnum.Map( LINE_STYLE::DEFAULT, _HKI( "Default" ) )
660 .Map( LINE_STYLE::SOLID, _HKI( "Solid" ) )
661 .Map( LINE_STYLE::DASH, _HKI( "Dashed" ) )
662 .Map( LINE_STYLE::DOT, _HKI( "Dotted" ) )
663 .Map( LINE_STYLE::DASHDOT, _HKI( "Dash-Dot" ) )
664 .Map( LINE_STYLE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
665 }
666
667 // TODO: Maybe SCH_BUS_ENTRY_BASE should inherit from or mix in with SCH_LINE
668 void ( SCH_BUS_ENTRY_BASE::*lineStyleSetter )( LINE_STYLE ) =
670
672 _HKI( "Line Style" ),
673 lineStyleSetter, &SCH_BUS_ENTRY_BASE::GetLineStyle ) );
674
675 propMgr.AddProperty( new PROPERTY<SCH_BUS_ENTRY_BASE, int>( _HKI( "Line Width" ),
677 PROPERTY_DISPLAY::PT_SIZE ) );
678
681 }
int color
Definition: DXF_plotter.cpp:58
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:110
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:136
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:294
bool Contains(const Vec &aPoint) const
Definition: box2.h:158
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:541
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:280
Helper class used to store the state of schematic items that can be connected to other schematic item...
Definition: sch_item.h:95
DANGLING_END_T GetType() const
Definition: sch_item.h:139
EDA_ITEM * GetItem() const
Definition: sch_item.h:137
VECTOR2I GetPosition() const
Definition: sch_item.h:136
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:88
const KIID m_Uuid
Definition: eda_item.h:485
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:98
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:669
static ENUM_MAP< T > & Instance()
Definition: property.h:663
wxPGChoices & Choices()
Definition: property.h:712
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
int GetDefaultPenWidth() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
wxDC * GetPrintDC() const
Base plotter engine class.
Definition: plotter.h:104
void MoveTo(const VECTOR2I &pos)
Definition: plotter.h:243
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle)=0
void FinishTo(const VECTOR2I &pos)
Definition: plotter.h:253
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void SetColor(const COLOR4D &color)=0
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:85
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:87
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
Class for a bus to bus entry.
int GetPenWidth() const override
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
SCH_BUS_BUS_ENTRY(const VECTOR2I &pos=VECTOR2I(0, 0), bool aFlipY=false)
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos, const SCH_SHEET_PATH *aPath=nullptr) override
Test the schematic item to aItemList to check if it's dangling state has changed.
SCH_ITEM * m_connected_bus_items[2]
Pointer to the bus items (usually bus wires) connected to this bus-bus entry (either or both may be n...
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:38
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
double Similarity(const SCH_ITEM &aItem) const override
Return a measure of how likely the other object is to represent the same object.
VECTOR2I m_pos
bool m_isDanglingStart
LINE_STYLE m_lastResolvedLineStyle
COLOR4D GetBusEntryColor() const
bool m_isDanglingEnd
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
LINE_STYLE GetLineStyle() const
void SetBusEntryColor(const COLOR4D &aColor)
VECTOR2I GetPosition() const override
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
void Print(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aForceNoFill, bool aDimmed) override
Print an item.
void SetPenWidth(int aWidth)
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
bool operator==(const SCH_ITEM &aItem) const override
int m_lastResolvedWidth
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
void SetLineStyle(LINE_STYLE aStyle)
bool IsConnectable() const override
int GetPenWidth() const override
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
VECTOR2I GetEnd() const
bool IsDangling() const override
COLOR4D m_lastResolvedColor
STROKE_PARAMS m_stroke
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
VECTOR2I m_size
SCH_BUS_ENTRY_BASE(KICAD_T aType, const VECTOR2I &pos=VECTOR2I(0, 0), bool aFlipY=false)
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
bool operator<(const SCH_ITEM &aItem) const override
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Class for a wire to bus entry.
SCH_BUS_WIRE_ENTRY(const VECTOR2I &pos=VECTOR2I(0, 0), bool aFlipY=false)
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
int GetPenWidth() const override
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos, const SCH_SHEET_PATH *aPath=nullptr) override
Test the schematic item to aItemList to check if it's dangling state has changed.
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
virtual bool ConnectionPropagatesTo(const EDA_ITEM *aItem) const override
Return true if this item should propagate connection info to aItem.
SCH_ITEM * m_connected_bus_item
Pointer to the bus item (usually a bus wire) connected to this bus-wire entry, if it is connected to ...
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
bool IsBus() const
void AppendInfoToMsgPanel(std::vector< MSG_PANEL_ITEM > &aList) const
Adds information about the connection object to aList.
static bool IsBusLabel(const wxString &aLabel)
Test if aLabel has a bus notation.
Schematic editor (Eeschema) main window.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:174
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition: sch_item.h:678
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
Definition: sch_item.cpp:239
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:289
bool IsConnectivityDirty() const
Definition: sch_item.h:518
void SwapFlags(SCH_ITEM *aItem)
Swap the non-temp and non-edit flags.
Definition: sch_item.cpp:343
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:210
SCH_LAYER_ID m_layer
Definition: sch_item.h:731
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:40
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
int GetWidth() const
Definition: stroke_params.h:91
void SetLineStyle(LINE_STYLE aLineStyle)
Definition: stroke_params.h:95
void SetWidth(int aWidth)
Definition: stroke_params.h:92
void SetColor(const KIGFX::COLOR4D &aColor)
Definition: stroke_params.h:98
LINE_STYLE GetLineStyle() const
Definition: stroke_params.h:94
KIGFX::COLOR4D GetColor() const
Definition: stroke_params.h:97
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, const std::function< void(const VECTOR2I &a, const VECTOR2I &b)> &aStroker)
#define DEFAULT_SCH_ENTRY_SIZE
The default text size in mils. (can be changed in preference menu)
#define DEFAULT_WIRE_WIDTH_MILS
The default bus width in mils. (can be changed in preference menu)
#define _HKI(x)
#define _(s)
static constexpr EDA_ANGLE ANGLE_90
Definition: eda_angle.h:437
static constexpr EDA_ANGLE ANGLE_270
Definition: eda_angle.h:440
void GRLine(wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:171
@ LAYER_DANGLING
Definition: layer_ids.h:381
@ LAYER_WIRE
Definition: layer_ids.h:356
@ LAYER_BUS
Definition: layer_ids.h:357
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:395
@ LAYER_BUS_JUNCTION
Definition: layer_ids.h:398
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:40
#define TYPE_HASH(x)
Definition: property.h:71
#define REGISTER_TYPE(x)
Definition: property_mgr.h:366
static struct SCH_BUS_ENTRY_DESC _SCH_BUS_ENTRY_DESC
@ BUS_END
Definition: sch_item.h:79
@ BUS_ENTRY_END
Definition: sch_item.h:83
@ WIRE_END
Definition: sch_item.h:78
@ WIRE_ENTRY_END
Definition: sch_item.h:84
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:48
constexpr int MilsToIU(int mils) const
Definition: base_units.h:93
SCH_BUS_ENTRY_DESC()
bool TestSegmentHit(const VECTOR2I &aRefPoint, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
Definition: trigo.cpp:174
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
Definition: trigo.cpp:228
bool IsPointOnSegment(const VECTOR2I &aSegStart, const VECTOR2I &aSegEnd, const VECTOR2I &aTestPoint)
Test if aTestPoint is on line defined by aSegStart and aSegEnd.
Definition: trigo.cpp:88
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_LINE_T
Definition: typeinfo.h:163
@ SCH_LABEL_T
Definition: typeinfo.h:167
@ SCH_BUS_BUS_ENTRY_T
Definition: typeinfo.h:162
@ SCH_BUS_WIRE_ENTRY_T
Definition: typeinfo.h:161
@ SCH_JUNCTION_T
Definition: typeinfo.h:159
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588