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>
37#include <netclass.h>
38#include <trigo.h>
39#include <board_item.h>
40#include <connection_graph.h>
41#include "sch_painter.h"
42#include "plotters/plotter.h"
43
44
45SCH_BUS_ENTRY_BASE::SCH_BUS_ENTRY_BASE( KICAD_T aType, const VECTOR2I& pos, bool aFlipY ) :
46 SCH_ITEM( nullptr, aType )
47{
48 m_pos = pos;
51
52 m_stroke.SetWidth( 0 );
53 m_stroke.SetLineStyle( LINE_STYLE::DEFAULT );
54 m_stroke.SetColor( COLOR4D::UNSPECIFIED );
55
56 if( aFlipY )
57 m_size.y *= -1;
58
60
62 m_lastResolvedLineStyle = LINE_STYLE::SOLID;
63 m_lastResolvedColor = COLOR4D::UNSPECIFIED;
64}
65
66
69{
71 m_connected_bus_item = nullptr;
72
74 m_lastResolvedLineStyle = LINE_STYLE::SOLID;
75 m_lastResolvedColor = COLOR4D::UNSPECIFIED;
76}
77
78
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( wxS( "SCH_BUS_WIRE_ENTRY ctor: unexpected quadrant" ) );
89 }
90
92 m_connected_bus_item = nullptr;
93
95 m_lastResolvedLineStyle = LINE_STYLE::SOLID;
96 m_lastResolvedColor = COLOR4D::UNSPECIFIED;
97}
98
99
102{
104 m_connected_bus_items[0] = nullptr;
105 m_connected_bus_items[1] = nullptr;
106
108 m_lastResolvedLineStyle = LINE_STYLE::SOLID;
109 m_lastResolvedColor = COLOR4D::UNSPECIFIED;
110}
111
112
114{
115 return new SCH_BUS_WIRE_ENTRY( *this );
116}
117
118
120{
121 return new SCH_BUS_BUS_ENTRY( *this );
122}
123
124
125bool SCH_BUS_ENTRY_BASE::doIsConnected( const VECTOR2I& aPosition ) const
126{
127 return ( m_pos == aPosition || GetEnd() == aPosition );
128}
129
130
132{
133 return VECTOR2I( m_pos.x + m_size.x, m_pos.y + m_size.y );
134}
135
136
138{
139 SCH_ITEM::SwapFlags( aItem );
140
141 SCH_BUS_ENTRY_BASE* item = dynamic_cast<SCH_BUS_ENTRY_BASE*>( aItem );
142 wxCHECK_RET( item, wxT( "Cannot swap bus entry data with invalid item." ) );
143
144 std::swap( m_pos, item->m_pos );
145 std::swap( m_size, item->m_size );
146 std::swap( m_stroke, item->m_stroke );
147
148 std::swap( m_lastResolvedWidth, item->m_lastResolvedWidth );
150 std::swap( m_lastResolvedColor, item->m_lastResolvedColor );
151}
152
153
154void SCH_BUS_ENTRY_BASE::ViewGetLayers( int aLayers[], int& aCount ) const
155{
156 aCount = 4;
157 aLayers[0] = LAYER_DANGLING;
158 aLayers[1] = Type() == SCH_BUS_BUS_ENTRY_T ? LAYER_BUS : LAYER_WIRE;
159 aLayers[2] = LAYER_NET_COLOR_HIGHLIGHT;
160 aLayers[3] = LAYER_SELECTION_SHADOWS;
161}
162
163
165{
166 BOX2I bbox( m_pos );
167 bbox.SetEnd( GetEnd() );
168
169 bbox.Normalize();
170 bbox.Inflate( ( GetPenWidth() / 2 ) + 1 );
171
172 return bbox;
173}
174
175
177{
178 if( m_stroke.GetColor() != COLOR4D::UNSPECIFIED )
180 else if( IsConnectable() && !IsConnectivityDirty() )
181 m_lastResolvedColor = GetEffectiveNetClass()->GetSchematicColor();
182
183 return m_lastResolvedColor;
184}
185
186
188{
189 m_stroke.SetWidth( aWidth );
190 m_lastResolvedWidth = aWidth;
191}
192
193
195{
196 return m_lastResolvedWidth;
197}
198
199
201{
202 m_stroke.SetColor( aColor );
203 m_lastResolvedColor = aColor;
204}
205
206
208{
209 if( m_stroke.GetLineStyle() != LINE_STYLE::DEFAULT )
211 else if( IsConnectable() && !IsConnectivityDirty() )
213
215}
216
217
219{
220 m_stroke.SetLineStyle( aStyle );
222}
223
224
226{
227 if( m_stroke.GetWidth() > 0 )
229 else if( IsConnectable() && !IsConnectivityDirty() )
230 m_lastResolvedWidth = GetEffectiveNetClass()->GetWireWidth();
231
232 return m_lastResolvedWidth;
233}
234
235
237{
238 if( m_stroke.GetWidth() > 0 )
240 else if( IsConnectable() && !IsConnectivityDirty() )
241 m_lastResolvedWidth = GetEffectiveNetClass()->GetBusWidth();
242
243 return m_lastResolvedWidth;
244}
245
246
247void SCH_BUS_WIRE_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
248{
250 aItemList.push_back( item );
251
252 DANGLING_END_ITEM item1( WIRE_ENTRY_END, this, GetEnd() );
253 aItemList.push_back( item1 );
254}
255
256
257void SCH_BUS_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
258{
260 aItemList.push_back( item );
261
262 DANGLING_END_ITEM item1( BUS_ENTRY_END, this, GetEnd() );
263 aItemList.push_back( item1 );
264}
265
266
267void SCH_BUS_ENTRY_BASE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
268 const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed )
269{
270 wxDC* DC = aSettings->GetPrintDC();
271 COLOR4D color = ( GetBusEntryColor() == COLOR4D::UNSPECIFIED )
272 ? aSettings->GetLayerColor( m_layer )
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_90 : ANGLE_270 );
312 RotatePoint( &m_size.x, &m_size.y, aRotateCCW ? ANGLE_90 : ANGLE_270 );
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
447wxString SCH_BUS_WIRE_ENTRY::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
448{
449 return wxString( _( "Bus to Wire Entry" ) );
450}
451
452
453wxString SCH_BUS_BUS_ENTRY::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
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
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:558
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:146
constexpr bool Contains(const Vec &aPoint) const
Definition: box2.h:168
constexpr void SetEnd(coord_type x, coord_type y)
Definition: box2.h:297
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:311
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:131
EDA_ITEM * GetItem() const
Definition: sch_item.h:129
VECTOR2I GetPosition() const
Definition: sch_item.h:128
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:89
const KIID m_Uuid
Definition: eda_item.h:489
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:94
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:105
void MoveTo(const VECTOR2I &pos)
Definition: plotter.h:244
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle)=0
void FinishTo(const VECTOR2I &pos)
Definition: plotter.h:254
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.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) 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.
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...
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)
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
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.
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:166
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition: sch_item.h:670
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
Definition: sch_item.cpp:250
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:281
bool IsConnectivityDirty() const
Definition: sch_item.h:510
void SwapFlags(SCH_ITEM *aItem)
Swap the non-temp and non-edit flags.
Definition: sch_item.cpp:354
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:221
SCH_LAYER_ID m_layer
Definition: sch_item.h:723
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:41
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:89
void SetLineStyle(LINE_STYLE aLineStyle)
Definition: stroke_params.h:93
void SetWidth(int aWidth)
Definition: stroke_params.h:90
void SetColor(const KIGFX::COLOR4D &aColor)
Definition: stroke_params.h:96
LINE_STYLE GetLineStyle() const
Definition: stroke_params.h:92
KIGFX::COLOR4D GetColor() const
Definition: stroke_params.h:95
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:403
static constexpr EDA_ANGLE ANGLE_270
Definition: eda_angle.h:406
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_NET_COLOR_HIGHLIGHT
Definition: layer_ids.h:396
@ LAYER_BUS
Definition: layer_ids.h:357
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:397
@ LAYER_BUS_JUNCTION
Definition: layer_ids.h:400
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:45
#define TYPE_HASH(x)
Definition: property.h:71
#define REGISTER_TYPE(x)
Definition: property_mgr.h:371
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:46
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:175
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:229
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:89
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< int32_t > VECTOR2I
Definition: vector2d.h:691