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 = 3;
157 aLayers[0] = LAYER_DANGLING;
158 aLayers[1] = Type() == SCH_BUS_BUS_ENTRY_T ? LAYER_BUS : LAYER_WIRE;
159 aLayers[2] = LAYER_SELECTION_SHADOWS;
160}
161
162
164{
165 BOX2I bbox( m_pos );
166 bbox.SetEnd( GetEnd() );
167
168 bbox.Normalize();
169 bbox.Inflate( ( GetPenWidth() / 2 ) + 1 );
170
171 return bbox;
172}
173
174
176{
177 if( m_stroke.GetColor() != COLOR4D::UNSPECIFIED )
179 else if( IsConnectable() && !IsConnectivityDirty() )
180 m_lastResolvedColor = GetEffectiveNetClass()->GetSchematicColor();
181
182 return m_lastResolvedColor;
183}
184
185
187{
188 m_stroke.SetWidth( aWidth );
189 m_lastResolvedWidth = aWidth;
190}
191
192
194{
195 return m_lastResolvedWidth;
196}
197
198
200{
201 m_stroke.SetColor( aColor );
202 m_lastResolvedColor = aColor;
203}
204
205
207{
208 if( m_stroke.GetLineStyle() != LINE_STYLE::DEFAULT )
210 else if( IsConnectable() && !IsConnectivityDirty() )
212
214}
215
216
218{
219 m_stroke.SetLineStyle( aStyle );
221}
222
223
225{
226 if( m_stroke.GetWidth() > 0 )
228 else if( IsConnectable() && !IsConnectivityDirty() )
229 m_lastResolvedWidth = GetEffectiveNetClass()->GetWireWidth();
230
231 return m_lastResolvedWidth;
232}
233
234
236{
237 if( m_stroke.GetWidth() > 0 )
239 else if( IsConnectable() && !IsConnectivityDirty() )
240 m_lastResolvedWidth = GetEffectiveNetClass()->GetBusWidth();
241
242 return m_lastResolvedWidth;
243}
244
245
246void SCH_BUS_WIRE_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
247{
249 aItemList.push_back( item );
250
251 DANGLING_END_ITEM item1( WIRE_ENTRY_END, this, GetEnd() );
252 aItemList.push_back( item1 );
253}
254
255
256void SCH_BUS_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
257{
259 aItemList.push_back( item );
260
261 DANGLING_END_ITEM item1( BUS_ENTRY_END, this, GetEnd() );
262 aItemList.push_back( item1 );
263}
264
265
266void SCH_BUS_ENTRY_BASE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
267 const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed )
268{
269 wxDC* DC = aSettings->GetPrintDC();
270 COLOR4D color = ( GetBusEntryColor() == COLOR4D::UNSPECIFIED )
271 ? aSettings->GetLayerColor( m_layer )
273 VECTOR2I start = m_pos + aOffset;
274 VECTOR2I end = GetEnd() + aOffset;
275 int penWidth = ( GetPenWidth() == 0 ) ? aSettings->GetDefaultPenWidth() : GetPenWidth();
276
277 if( GetLineStyle() <= LINE_STYLE::FIRST_TYPE )
278 {
279 GRLine( DC, start.x, start.y, end.x, end.y, penWidth, color );
280 }
281 else
282 {
283 SHAPE_SEGMENT segment( start, end );
284
285 STROKE_PARAMS::Stroke( &segment, GetLineStyle(), penWidth, aSettings,
286 [&]( const VECTOR2I& a, const VECTOR2I& b )
287 {
288 GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
289 } );
290 }
291}
292
293
295{
296 MIRROR( m_pos.y, aCenter );
297 m_size.y = -m_size.y;
298}
299
300
302{
303 MIRROR( m_pos.x, aCenter );
304 m_size.x = -m_size.x;
305}
306
307
308void SCH_BUS_ENTRY_BASE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
309{
310 RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
311 RotatePoint( &m_size.x, &m_size.y, aRotateCCW ? ANGLE_90 : ANGLE_270 );
312}
313
314
315bool SCH_BUS_WIRE_ENTRY::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
316 std::vector<DANGLING_END_ITEM>& aItemListByPos,
317 const SCH_SHEET_PATH* aPath )
318{
319 bool previousStateStart = m_isDanglingStart;
320 bool previousStateEnd = m_isDanglingEnd;
321
323
324 // Store the connection type and state for the start (0) and end (1)
325 bool has_wire[2] = { false };
326 bool has_bus[2] = { false };
327
328 for( unsigned ii = 0; ii < aItemListByType.size(); ii++ )
329 {
330 DANGLING_END_ITEM& item = aItemListByType[ii];
331
332 if( item.GetItem() == this )
333 continue;
334
335 switch( item.GetType() )
336 {
337 case WIRE_END:
338 if( m_pos == item.GetPosition() )
339 has_wire[0] = true;
340 else if( GetEnd() == item.GetPosition() )
341 has_wire[1] = true;
342
343 break;
344
345 case BUS_END:
346 {
347 // The bus has created 2 DANGLING_END_ITEMs, one per end.
348 DANGLING_END_ITEM& nextItem = aItemListByType[++ii];
349
350 if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), m_pos ) )
351 has_bus[0] = true;
352 else if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetEnd() ) )
353 has_bus[1] = true;
354 }
355 break;
356
357 default:
358 break;
359 }
360 }
361
362 // A bus-wire entry is connected at both ends if it has a bus and a wire on its
363 // ends. Otherwise, we connect only one end (in the case of a wire-wire or bus-bus)
364 if( ( has_wire[0] && has_bus[1] ) || ( has_wire[1] && has_bus[0] ) )
366 else if( has_wire[0] || has_bus[0] )
367 m_isDanglingStart = false;
368 else if( has_wire[1] || has_bus[1] )
369 m_isDanglingEnd = false;
370
371 return (previousStateStart != m_isDanglingStart) || (previousStateEnd != m_isDanglingEnd);
372}
373
374
375bool SCH_BUS_BUS_ENTRY::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
376 std::vector<DANGLING_END_ITEM>& aItemListByPos,
377 const SCH_SHEET_PATH* aPath )
378{
379 bool previousStateStart = m_isDanglingStart;
380 bool previousStateEnd = m_isDanglingEnd;
381
383
384 // TODO: filter using get_lower as we only use one item type
385 for( unsigned ii = 0; ii < aItemListByType.size(); ii++ )
386 {
387 DANGLING_END_ITEM& item = aItemListByType[ii];
388
389 if( item.GetItem() == this )
390 continue;
391
392 switch( item.GetType() )
393 {
394 case BUS_END:
395 {
396 // The bus has created 2 DANGLING_END_ITEMs, one per end.
397 DANGLING_END_ITEM& nextItem = aItemListByType[++ii];
398
399 if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), m_pos ) )
400 m_isDanglingStart = false;
401 if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetEnd() ) )
402 m_isDanglingEnd = false;
403 }
404 break;
405
406 default:
407 break;
408 }
409 }
410
411 return (previousStateStart != m_isDanglingStart) || (previousStateEnd != m_isDanglingEnd);
412}
413
414
416{
418}
419
420
421std::vector<VECTOR2I> SCH_BUS_ENTRY_BASE::GetConnectionPoints() const
422{
423 return { m_pos, GetEnd() };
424}
425
426
428 const SCH_SHEET_PATH* aInstance ) const
429{
430 // Do not compare to ourself.
431 if( aItem == this )
432 return false;
433
434 const SCH_BUS_ENTRY_BASE* busEntry = dynamic_cast<const SCH_BUS_ENTRY_BASE*>( aItem );
435
436 // Don't compare against a different SCH_ITEM.
437 wxCHECK( busEntry, false );
438
439 if( GetPosition() != busEntry->GetPosition() )
440 return true;
441
442 return GetEnd() != busEntry->GetEnd();
443}
444
445
447{
448 return wxString( _( "Bus to Wire Entry" ) );
449}
450
451
453{
454 return wxString( _( "Bus to Bus Entry" ) );
455}
456
457
459{
460 return BITMAPS::add_line2bus;
461}
462
463
465{
466 return BITMAPS::add_bus2bus;
467}
468
469
470bool SCH_BUS_ENTRY_BASE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
471{
472 // Insure minimum accuracy
473 if( aAccuracy == 0 )
474 aAccuracy = ( GetPenWidth() / 2 ) + 4;
475
476 return TestSegmentHit( aPosition, m_pos, GetEnd(), aAccuracy );
477}
478
479
480bool SCH_BUS_ENTRY_BASE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
481{
482 BOX2I rect = aRect;
483
484 rect.Inflate( aAccuracy );
485
486 if( aContained )
487 return rect.Contains( GetBoundingBox() );
488
489 return rect.Intersects( GetBoundingBox() );
490}
491
492
493void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
494 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
495{
496 if( aBackground )
497 return;
498
499 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
500
501 COLOR4D color = ( GetBusEntryColor() == COLOR4D::UNSPECIFIED )
502 ? renderSettings->GetLayerColor( m_layer ) : GetBusEntryColor();
503
504 int penWidth = ( GetPenWidth() == 0 ) ? renderSettings->GetDefaultPenWidth() : GetPenWidth();
505
506 penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() );
507
508 aPlotter->SetCurrentLineWidth( penWidth );
509 aPlotter->SetColor( color );
510 aPlotter->SetDash( penWidth, GetLineStyle() );
511 aPlotter->MoveTo( m_pos );
512 aPlotter->FinishTo( GetEnd() );
513
514 aPlotter->SetDash( penWidth, LINE_STYLE::SOLID );
515}
516
517
519 std::vector<MSG_PANEL_ITEM>& aList )
520{
521 wxString msg;
522
523 switch( GetLayer() )
524 {
525 default:
526 case LAYER_WIRE: msg = _( "Wire" ); break;
527 case LAYER_BUS: msg = _( "Bus" ); break;
528 }
529
530 aList.emplace_back( _( "Bus Entry Type" ), msg );
531
532 SCH_CONNECTION* conn = nullptr;
533
534 if( !IsConnectivityDirty() && dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) )
535 conn = Connection();
536
537 if( conn )
538 {
539 conn->AppendInfoToMsgPanel( aList );
540
541 if( !conn->IsBus() )
542 aList.emplace_back( _( "Resolved Netclass" ), GetEffectiveNetClass()->GetName() );
543 }
544}
545
546
547bool SCH_BUS_ENTRY_BASE::operator <( const SCH_ITEM& aItem ) const
548{
549 if( Type() != aItem.Type() )
550 return Type() < aItem.Type();
551
552 auto symbol = static_cast<const SCH_BUS_ENTRY_BASE*>( &aItem );
553
554 if( GetLayer() != symbol->GetLayer() )
555 return GetLayer() < symbol->GetLayer();
556
557 if( GetPosition().x != symbol->GetPosition().x )
558 return GetPosition().x < symbol->GetPosition().x;
559
560 if( GetPosition().y != symbol->GetPosition().y )
561 return GetPosition().y < symbol->GetPosition().y;
562
563 if( GetEnd().x != symbol->GetEnd().x )
564 return GetEnd().x < symbol->GetEnd().x;
565
566 return GetEnd().y < symbol->GetEnd().y;
567}
568
569
571{
572 // Don't generate connections between bus entries and buses, since there is
573 // a connectivity change at that point (e.g. A[7..0] to A7)
574 if( ( aItem->Type() == SCH_LINE_T ) &&
575 ( static_cast<const SCH_LINE*>( aItem )->GetLayer() == LAYER_BUS ) )
576 {
577 return false;
578 }
579
580 // Same for bus junctions
581 if( ( aItem->Type() == SCH_JUNCTION_T ) &&
582 ( static_cast<const SCH_JUNCTION*>( aItem )->GetLayer() == LAYER_BUS_JUNCTION ) )
583 {
584 return false;
585 }
586
587 // Don't generate connections between bus entries and bus labels that happen
588 // to land at the same point on the bus wire as this bus entry
589 if( ( aItem->Type() == SCH_LABEL_T ) &&
590 SCH_CONNECTION::IsBusLabel( static_cast<const SCH_LABEL*>( aItem )->GetText() ) )
591 {
592 return false;
593 }
594
595 // Don't generate connections between two bus-wire entries
596 if( aItem->Type() == SCH_BUS_WIRE_ENTRY_T )
597 return false;
598
599 return true;
600}
601
602bool SCH_BUS_ENTRY_BASE::operator==( const SCH_ITEM& aItem ) const
603{
604 if( Type() != aItem.Type() )
605 return false;
606
607 const SCH_BUS_ENTRY_BASE* symbol = static_cast<const SCH_BUS_ENTRY_BASE*>( &aItem );
608
609 if( GetLayer() != symbol->GetLayer() )
610 return false;
611
612 if( GetPosition() != symbol->GetPosition() )
613 return false;
614
615 if( GetEnd() != symbol->GetEnd() )
616 return false;
617
618 return true;
619}
620
621
622double SCH_BUS_ENTRY_BASE::Similarity( const SCH_ITEM& aItem ) const
623{
624 if( aItem.Type() != Type() )
625 return 0.0;
626
627 if( m_Uuid == aItem.m_Uuid )
628 return 1.0;
629
630 const SCH_BUS_ENTRY_BASE& other = static_cast<const SCH_BUS_ENTRY_BASE&>( aItem );
631
632 if( GetLayer() != other.GetLayer() )
633 return 0.0;
634
635 if( GetPosition() != other.GetPosition() )
636 return 0.0;
637
638 return 1.0;
639}
640
641
643{
645 {
653
655
656 if( plotDashTypeEnum.Choices().GetCount() == 0 )
657 {
658 plotDashTypeEnum.Map( LINE_STYLE::DEFAULT, _HKI( "Default" ) )
659 .Map( LINE_STYLE::SOLID, _HKI( "Solid" ) )
660 .Map( LINE_STYLE::DASH, _HKI( "Dashed" ) )
661 .Map( LINE_STYLE::DOT, _HKI( "Dotted" ) )
662 .Map( LINE_STYLE::DASHDOT, _HKI( "Dash-Dot" ) )
663 .Map( LINE_STYLE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
664 }
665
666 // TODO: Maybe SCH_BUS_ENTRY_BASE should inherit from or mix in with SCH_LINE
667 void ( SCH_BUS_ENTRY_BASE::*lineStyleSetter )( LINE_STYLE ) =
669
671 _HKI( "Line Style" ),
672 lineStyleSetter, &SCH_BUS_ENTRY_BASE::GetLineStyle ) );
673
674 propMgr.AddProperty( new PROPERTY<SCH_BUS_ENTRY_BASE, int>( _HKI( "Line Width" ),
676 PROPERTY_DISPLAY::PT_SIZE ) );
677
680 }
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: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: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: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.
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: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:245
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:349
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:216
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: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: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_BUS
Definition: layer_ids.h:357
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:396
@ LAYER_BUS_JUNCTION
Definition: layer_ids.h:399
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: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: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< int32_t > VECTOR2I
Definition: vector2d.h:638