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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <sch_draw_panel.h>
22#include <bitmaps.h>
23#include <core/mirror.h>
24#include <schematic.h>
27#include <sch_bus_entry.h>
28#include <sch_edit_frame.h>
29#include <sch_junction.h>
30#include <sch_line.h>
34#include <netclass.h>
35#include <trigo.h>
36#include <board_item.h>
37#include <connection_graph.h>
38#include <api/api_enums.h>
39#include <api/api_utils.h>
40#include <api/schematic/schematic_types.pb.h>
41#include "sch_painter.h"
42#include "plotters/plotter.h"
43#include <properties/property.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 );
57
58 if( aFlipY )
59 m_size.y *= -1;
60
62
66}
67
68
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
99}
100
101
113
114
115void SCH_BUS_ENTRY_BASE::Serialize( google::protobuf::Any& aContainer ) const
116{
117 using namespace kiapi::common;
118
119 kiapi::schematic::types::BusEntry entry;
120 types::StrokeAttributes* stroke = entry.mutable_stroke();
121
122 entry.mutable_id()->set_value( m_Uuid.AsStdString() );
123 PackVector2( *entry.mutable_position(), m_pos, schIUScale );
124 PackVector2( *entry.mutable_size(), m_size, schIUScale );
125 entry.set_locked( IsLocked() ? types::LockedState::LS_LOCKED : types::LockedState::LS_UNLOCKED );
126 entry.set_type( Type() == SCH_BUS_BUS_ENTRY_T ? kiapi::schematic::types::BET_BUS_TO_BUS
127 : kiapi::schematic::types::BET_WIRE_TO_BUS );
128
129 PackDistance( *stroke->mutable_width(), m_stroke.GetWidth(), schIUScale );
130 stroke->set_style( ToProtoEnum<LINE_STYLE, types::StrokeLineStyle>( m_stroke.GetLineStyle() ) );
131
132 if( m_stroke.GetColor() != COLOR4D::UNSPECIFIED )
133 PackColor( *stroke->mutable_color(), m_stroke.GetColor() );
134
135 aContainer.PackFrom( entry );
136}
137
138
139bool SCH_BUS_ENTRY_BASE::Deserialize( const google::protobuf::Any& aContainer )
140{
141 using namespace kiapi::common;
142
143 kiapi::schematic::types::BusEntry entry;
144
145 if( !aContainer.UnpackTo( &entry ) )
146 return false;
147
148 if( ( Type() == SCH_BUS_WIRE_ENTRY_T && entry.type() != kiapi::schematic::types::BET_WIRE_TO_BUS )
149 || ( Type() == SCH_BUS_BUS_ENTRY_T && entry.type() != kiapi::schematic::types::BET_BUS_TO_BUS ) )
150 {
151 return false;
152 }
153
154 const_cast<KIID&>( m_Uuid ) = KIID( entry.id().value() );
155 m_pos = UnpackVector2( entry.position(), schIUScale );
156 m_size = UnpackVector2( entry.size(), schIUScale );
157 SetLocked( entry.locked() == types::LockedState::LS_LOCKED );
158
159 m_stroke.SetWidth( UnpackDistance( entry.stroke().width(), schIUScale ) );
160 m_stroke.SetLineStyle( FromProtoEnum<LINE_STYLE, types::StrokeLineStyle>( entry.stroke().style() ) );
161
162 if( entry.stroke().has_color() )
163 m_stroke.SetColor( UnpackColor( entry.stroke().color() ) );
164 else
165 m_stroke.SetColor( COLOR4D::UNSPECIFIED );
166
167 SetLayer( entry.type() == kiapi::schematic::types::BET_BUS_TO_BUS ? LAYER_BUS : LAYER_WIRE );
168 return true;
169}
170
171
173{
174 return new SCH_BUS_WIRE_ENTRY( *this );
175}
176
177
179{
180 return new SCH_BUS_BUS_ENTRY( *this );
181}
182
183
184bool SCH_BUS_ENTRY_BASE::doIsConnected( const VECTOR2I& aPosition ) const
185{
186 return ( m_pos == aPosition || GetEnd() == aPosition );
187}
188
189
191{
192 return VECTOR2I( m_pos.x + m_size.x, m_pos.y + m_size.y );
193}
194
195
197{
198 SCH_BUS_ENTRY_BASE* item = dynamic_cast<SCH_BUS_ENTRY_BASE*>( aItem );
199 wxCHECK_RET( item, wxT( "Cannot swap bus entry data with invalid item." ) );
200
201 std::swap( m_pos, item->m_pos );
202 std::swap( m_size, item->m_size );
203 std::swap( m_stroke, item->m_stroke );
204
205 std::swap( m_lastResolvedWidth, item->m_lastResolvedWidth );
207 std::swap( m_lastResolvedColor, item->m_lastResolvedColor );
208}
209
210
218
219
221{
222 BOX2I bbox( m_pos );
223 bbox.SetEnd( GetEnd() );
224
225 bbox.Normalize();
226 bbox.Inflate( ( GetPenWidth() / 2 ) + 1 );
227
228 return bbox;
229}
230
231
241
242
244{
245 m_stroke.SetWidth( aWidth );
246 m_lastResolvedWidth = aWidth;
247}
248
249
251{
252 return m_lastResolvedWidth;
253}
254
255
257{
258 m_stroke.SetColor( aColor );
259 m_lastResolvedColor = aColor;
260}
261
262
272
273
275{
276 m_stroke.SetLineStyle( aStyle );
278}
279
280
282{
283 if( m_stroke.GetWidth() > 0 )
284 m_lastResolvedWidth = m_stroke.GetWidth();
285 else if( IsConnectable() && !IsConnectivityDirty() )
287
288 return m_lastResolvedWidth;
289}
290
291
293{
294 if( m_stroke.GetWidth() > 0 )
295 m_lastResolvedWidth = m_stroke.GetWidth();
296 else if( IsConnectable() && !IsConnectivityDirty() )
298
299 return m_lastResolvedWidth;
300}
301
302
303void SCH_BUS_WIRE_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
304{
306 aItemList.push_back( item );
307
308 DANGLING_END_ITEM item1( WIRE_ENTRY_END, this, GetEnd() );
309 aItemList.push_back( item1 );
310}
311
312
313void SCH_BUS_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
314{
316 aItemList.push_back( item );
317
318 DANGLING_END_ITEM item1( BUS_ENTRY_END, this, GetEnd() );
319 aItemList.push_back( item1 );
320}
321
322
324{
325 MIRROR( m_pos.y, aCenter );
326 m_size.y = -m_size.y;
327}
328
329
331{
332 MIRROR( m_pos.x, aCenter );
333 m_size.x = -m_size.x;
334}
335
336
337void SCH_BUS_ENTRY_BASE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
338{
339 RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
340 RotatePoint( &m_size.x, &m_size.y, aRotateCCW ? ANGLE_90 : ANGLE_270 );
341}
342
343
344bool SCH_BUS_WIRE_ENTRY::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
345 std::vector<DANGLING_END_ITEM>& aItemListByPos,
346 const SCH_SHEET_PATH* aPath )
347{
348 bool previousStateStart = m_isStartDangling;
349 bool previousStateEnd = m_isEndDangling;
350
352
353 // Store the connection type and state for the start (0) and end (1)
354 bool has_wire[2] = { false };
355 bool has_bus[2] = { false };
356
357 for( unsigned ii = 0; ii < aItemListByType.size(); ii++ )
358 {
359 DANGLING_END_ITEM& item = aItemListByType[ii];
360
361 if( item.GetItem() == this )
362 continue;
363
364 switch( item.GetType() )
365 {
366 case WIRE_END:
367 if( m_pos == item.GetPosition() )
368 has_wire[0] = true;
369 else if( GetEnd() == item.GetPosition() )
370 has_wire[1] = true;
371
372 break;
373
374 case BUS_END:
375 {
376 // The bus has created 2 DANGLING_END_ITEMs, one per end.
377 DANGLING_END_ITEM& nextItem = aItemListByType[++ii];
378
379 if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), m_pos ) )
380 has_bus[0] = true;
381 else if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetEnd() ) )
382 has_bus[1] = true;
383 }
384 break;
385
386 default:
387 break;
388 }
389 }
390
391 // A bus-wire entry is connected at both ends if it has a bus and a wire on its
392 // ends. Otherwise, we connect only one end (in the case of a wire-wire or bus-bus)
393 if( ( has_wire[0] && has_bus[1] ) || ( has_wire[1] && has_bus[0] ) )
395 else if( has_wire[0] || has_bus[0] )
396 m_isStartDangling = false;
397 else if( has_wire[1] || has_bus[1] )
398 m_isEndDangling = false;
399
400 return (previousStateStart != m_isStartDangling) || (previousStateEnd != m_isEndDangling);
401}
402
403
404bool SCH_BUS_BUS_ENTRY::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
405 std::vector<DANGLING_END_ITEM>& aItemListByPos,
406 const SCH_SHEET_PATH* aPath )
407{
408 bool previousStateStart = m_isStartDangling;
409 bool previousStateEnd = m_isEndDangling;
410
412
413 // TODO: filter using get_lower as we only use one item type
414 for( unsigned ii = 0; ii < aItemListByType.size(); ii++ )
415 {
416 DANGLING_END_ITEM& item = aItemListByType[ii];
417
418 if( item.GetItem() == this )
419 continue;
420
421 switch( item.GetType() )
422 {
423 case BUS_END:
424 {
425 // The bus has created 2 DANGLING_END_ITEMs, one per end.
426 DANGLING_END_ITEM& nextItem = aItemListByType[++ii];
427
428 if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), m_pos ) )
429 m_isStartDangling = false;
430
431 if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetEnd() ) )
432 m_isEndDangling = false;
433 }
434 break;
435
436 default:
437 break;
438 }
439 }
440
441 return (previousStateStart != m_isStartDangling) || (previousStateEnd != m_isEndDangling);
442}
443
444
449
450
451std::vector<VECTOR2I> SCH_BUS_ENTRY_BASE::GetConnectionPoints() const
452{
453 return { m_pos, GetEnd() };
454}
455
456
458 const SCH_SHEET_PATH* aInstance ) const
459{
460 // Do not compare to ourselves.
461 if( aItem == this )
462 return false;
463
464 const SCH_BUS_ENTRY_BASE* busEntry = dynamic_cast<const SCH_BUS_ENTRY_BASE*>( aItem );
465
466 // Don't compare against a different SCH_ITEM.
467 wxCHECK( busEntry, false );
468
469 if( GetPosition() != busEntry->GetPosition() )
470 return true;
471
472 return GetEnd() != busEntry->GetEnd();
473}
474
475
476wxString SCH_BUS_WIRE_ENTRY::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
477{
478 return wxString( _( "Bus to wire entry" ) );
479}
480
481
482wxString SCH_BUS_BUS_ENTRY::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
483{
484 return wxString( _( "Bus to bus entry" ) );
485}
486
487
492
493
498
499
500bool SCH_BUS_ENTRY_BASE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
501{
502 // Insure minimum accuracy
503 if( aAccuracy == 0 )
504 aAccuracy = ( GetPenWidth() / 2 ) + 4;
505
506 return TestSegmentHit( aPosition, m_pos, GetEnd(), aAccuracy );
507}
508
509
510bool SCH_BUS_ENTRY_BASE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
511{
512 BOX2I rect = aRect;
513
514 rect.Inflate( aAccuracy );
515
516 if( aContained )
517 return rect.Contains( GetBoundingBox() );
518
519 return rect.Intersects( GetBoundingBox() );
520}
521
522
523bool SCH_BUS_ENTRY_BASE::HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const
524{
526 return KIGEOM::ShapeHitTest( aPoly, line, aContained );
527}
528
529
530void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
531 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
532{
533 if( aBackground )
534 return;
535
536 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
537
539 ? renderSettings->GetLayerColor( m_layer ) : GetBusEntryColor();
540
541 if( color.m_text && Schematic() )
542 color = COLOR4D( ResolveText( *color.m_text, &Schematic()->CurrentSheet() ) );
543
544 int penWidth = ( GetPenWidth() == 0 ) ? renderSettings->GetDefaultPenWidth() : GetPenWidth();
545
546 penWidth = std::max( penWidth, renderSettings->GetMinPenWidth() );
547
548 aPlotter->SetCurrentLineWidth( penWidth );
549 aPlotter->SetColor( color );
550 aPlotter->SetDash( penWidth, GetEffectiveLineStyle() );
551 aPlotter->MoveTo( m_pos );
552 aPlotter->FinishTo( GetEnd() );
553
554 aPlotter->SetDash( penWidth, LINE_STYLE::SOLID );
555}
556
557
559 std::vector<MSG_PANEL_ITEM>& aList )
560{
561 wxString msg;
562
563 switch( GetLayer() )
564 {
565 default:
566 case LAYER_WIRE: msg = _( "Wire" ); break;
567 case LAYER_BUS: msg = _( "Bus" ); break;
568 }
569
570 aList.emplace_back( _( "Bus Entry Type" ), msg );
571
572 SCH_CONNECTION* conn = nullptr;
573
574 if( !IsConnectivityDirty() && dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) )
575 conn = Connection();
576
577 if( conn )
578 {
579 conn->AppendInfoToMsgPanel( aList );
580
581 if( !conn->IsBus() )
582 aList.emplace_back( _( "Resolved Netclass" ),
583 GetEffectiveNetClass()->GetHumanReadableName() );
584 }
585}
586
587
588bool SCH_BUS_ENTRY_BASE::operator <( const SCH_ITEM& aItem ) const
589{
590 if( Type() != aItem.Type() )
591 return Type() < aItem.Type();
592
593 auto symbol = static_cast<const SCH_BUS_ENTRY_BASE*>( &aItem );
594
595 if( GetLayer() != symbol->GetLayer() )
596 return GetLayer() < symbol->GetLayer();
597
598 if( GetPosition().x != symbol->GetPosition().x )
599 return GetPosition().x < symbol->GetPosition().x;
600
601 if( GetPosition().y != symbol->GetPosition().y )
602 return GetPosition().y < symbol->GetPosition().y;
603
604 if( GetEnd().x != symbol->GetEnd().x )
605 return GetEnd().x < symbol->GetEnd().x;
606
607 return GetEnd().y < symbol->GetEnd().y;
608}
609
610
612{
613 // Don't generate connections between bus entries and buses, since there is
614 // a connectivity change at that point (e.g. A[7..0] to A7)
615 if( ( aItem->Type() == SCH_LINE_T ) &&
616 ( static_cast<const SCH_LINE*>( aItem )->GetLayer() == LAYER_BUS ) )
617 {
618 return false;
619 }
620
621 // Same for bus junctions
622 if( ( aItem->Type() == SCH_JUNCTION_T ) &&
623 ( static_cast<const SCH_JUNCTION*>( aItem )->GetLayer() == LAYER_BUS_JUNCTION ) )
624 {
625 return false;
626 }
627
628 // Don't generate connections between bus entries and bus labels that happen
629 // to land at the same point on the bus wire as this bus entry
630 if( ( aItem->Type() == SCH_LABEL_T ) &&
631 SCH_CONNECTION::IsBusLabel( static_cast<const SCH_LABEL*>( aItem )->GetText() ) )
632 {
633 return false;
634 }
635
636 // Don't generate connections between two bus-wire entries
637 if( aItem->Type() == SCH_BUS_WIRE_ENTRY_T )
638 return false;
639
640 return true;
641}
642
643bool SCH_BUS_ENTRY_BASE::operator==( const SCH_ITEM& aItem ) const
644{
645 if( Type() != aItem.Type() )
646 return false;
647
648 const SCH_BUS_ENTRY_BASE* symbol = static_cast<const SCH_BUS_ENTRY_BASE*>( &aItem );
649
650 if( GetLayer() != symbol->GetLayer() )
651 return false;
652
653 if( GetPosition() != symbol->GetPosition() )
654 return false;
655
656 if( GetEnd() != symbol->GetEnd() )
657 return false;
658
659 return true;
660}
661
662
663double SCH_BUS_ENTRY_BASE::Similarity( const SCH_ITEM& aItem ) const
664{
665 if( aItem.Type() != Type() )
666 return 0.0;
667
668 if( m_Uuid == aItem.m_Uuid )
669 return 1.0;
670
671 const SCH_BUS_ENTRY_BASE& other = static_cast<const SCH_BUS_ENTRY_BASE&>( aItem );
672
673 if( GetLayer() != other.GetLayer() )
674 return 0.0;
675
676 if( GetPosition() != other.GetPosition() )
677 return 0.0;
678
679 return 1.0;
680}
681
682
684{
686 {
694
696
697 if( wireLineStyleEnum.Choices().GetCount() == 0 )
698 {
699 wireLineStyleEnum.Map( WIRE_STYLE::DEFAULT, _HKI( "Default" ) )
700 .Map( WIRE_STYLE::SOLID, _HKI( "Solid" ) )
701 .Map( WIRE_STYLE::DASH, _HKI( "Dashed" ) )
702 .Map( WIRE_STYLE::DOT, _HKI( "Dotted" ) )
703 .Map( WIRE_STYLE::DASHDOT, _HKI( "Dash-Dot" ) )
704 .Map( WIRE_STYLE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
705 }
706
709
710 propMgr.AddProperty( new PROPERTY<SCH_BUS_ENTRY_BASE, int>( _HKI( "Line Width" ),
713
716 }
types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
Definition api_enums.cpp:47
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:123
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:554
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition box2.h:142
constexpr bool Contains(const Vec &aPoint) const
Definition box2.h:164
constexpr void SetEnd(coord_type x, coord_type y)
Definition box2.h:293
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition box2.h:307
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:398
Helper class used to store the state of schematic items that can be connected to other schematic item...
Definition sch_item.h:93
DANGLING_END_T GetType() const
Definition sch_item.h:129
EDA_ITEM * GetItem() const
Definition sch_item.h:127
VECTOR2I GetPosition() const
Definition sch_item.h:126
The base class for create windows for drawing purpose.
const KIID m_Uuid
Definition eda_item.h:531
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:37
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:110
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition property.h:727
static ENUM_MAP< T > & Instance()
Definition property.h:721
wxPGChoices & Choices()
Definition property.h:772
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
std::shared_ptr< wxString > m_text
Definition color4d.h:395
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
Definition kiid.h:44
int GetLineStyle() const
Definition netclass.h:240
int GetWireWidth() const
Definition netclass.h:210
COLOR4D GetSchematicColor(bool aIsForSave=false) const
Definition netclass.h:225
int GetBusWidth() const
Definition netclass.h:218
Base plotter engine class.
Definition plotter.h:133
void MoveTo(const VECTOR2I &pos)
Definition plotter.h:305
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle)=0
void FinishTo(const VECTOR2I &pos)
Definition plotter.h:315
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.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
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.
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
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
LINE_STYLE m_lastResolvedLineStyle
COLOR4D GetBusEntryColor() const
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
void SetBusEntryColor(const COLOR4D &aColor)
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
VECTOR2I GetPosition() const override
bool m_isEndDangling
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
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 SetWireStyle(WIRE_STYLE aStyle)
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
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
WIRE_STYLE GetWireStyle() const
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.
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)
LINE_STYLE GetEffectiveLineStyle() const
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 m_isStartDangling
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:162
void SetLocked(bool aLocked) override
Definition sch_item.h:251
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition sch_item.h:724
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:268
bool IsLocked() const override
Definition sch_item.cpp:148
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
Definition sch_item.cpp:523
void SetLayer(SCH_LAYER_ID aLayer)
Definition sch_item.h:339
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition sch_item.h:338
bool IsConnectivityDirty() const
Definition sch_item.h:585
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:52
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:487
wxString ResolveText(const wxString &aText, const SCH_SHEET_PATH *aPath, int aDepth=0) const
Definition sch_item.cpp:377
SCH_LAYER_ID m_layer
Definition sch_item.h:775
Segment description base class to describe items which have 2 end points (track, wire,...
Definition sch_line.h:38
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
#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 _(s)
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:413
static constexpr EDA_ANGLE ANGLE_270
Definition eda_angle.h:416
a few functions useful in geometry calculations.
@ LAYER_WIRE
Definition layer_ids.h:450
@ LAYER_NET_COLOR_HIGHLIGHT
Definition layer_ids.h:491
@ LAYER_BUS
Definition layer_ids.h:451
@ LAYER_SELECTION_SHADOWS
Definition layer_ids.h:493
@ LAYER_BUS_JUNCTION
Definition layer_ids.h:496
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition mirror.h:41
bool ShapeHitTest(const SHAPE_LINE_CHAIN &aHitter, const SHAPE &aHittee, bool aHitteeContained)
Perform a shape-to-shape hit test.
KICOMMON_API void PackColor(types::Color &aOutput, const KIGFX::COLOR4D &aInput)
KICOMMON_API int UnpackDistance(const types::Distance &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API KIGFX::COLOR4D UnpackColor(const types::Color &aInput)
KICOMMON_API VECTOR2I UnpackVector2(const types::Vector2 &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackDistance(types::Distance &aOutput, int aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackVector2(types::Vector2 &aOutput, const VECTOR2I &aInput, const EDA_IU_SCALE &aScale)
#define _HKI(x)
Definition page_info.cpp:40
#define TYPE_HASH(x)
Definition property.h:74
@ PT_SIZE
Size expressed in distance units (mm/inch)
Definition property.h:63
#define REGISTER_TYPE(x)
static struct SCH_BUS_ENTRY_DESC _SCH_BUS_ENTRY_DESC
@ BUS_END
Definition sch_item.h:77
@ BUS_ENTRY_END
Definition sch_item.h:81
@ WIRE_END
Definition sch_item.h:76
@ WIRE_ENTRY_END
Definition sch_item.h:82
LINE_STYLE
Dashed line types.
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:171
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:225
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:85
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:71
@ SCH_LINE_T
Definition typeinfo.h:160
@ SCH_LABEL_T
Definition typeinfo.h:164
@ SCH_BUS_BUS_ENTRY_T
Definition typeinfo.h:159
@ SCH_BUS_WIRE_ENTRY_T
Definition typeinfo.h:158
@ SCH_JUNCTION_T
Definition typeinfo.h:156
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683