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-2022 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 RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
269{
270 wxDC* DC = aSettings->GetPrintDC();
271 COLOR4D color = ( GetBusEntryColor() == COLOR4D::UNSPECIFIED ) ?
272 aSettings->GetLayerColor( m_layer ) : GetBusEntryColor();
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
309{
310 RotatePoint( m_pos, aCenter, ANGLE_90 );
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{
429 return wxString( _( "Bus to Wire Entry" ) );
430}
431
432
434{
435 return wxString( _( "Bus to Bus Entry" ) );
436}
437
438
440{
441 return BITMAPS::add_line2bus;
442}
443
444
446{
447 return BITMAPS::add_bus2bus;
448}
449
450
451bool SCH_BUS_ENTRY_BASE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
452{
453 // Insure minimum accuracy
454 if( aAccuracy == 0 )
455 aAccuracy = ( GetPenWidth() / 2 ) + 4;
456
457 return TestSegmentHit( aPosition, m_pos, GetEnd(), aAccuracy );
458}
459
460
461bool SCH_BUS_ENTRY_BASE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
462{
463 BOX2I rect = aRect;
464
465 rect.Inflate( aAccuracy );
466
467 if( aContained )
468 return rect.Contains( GetBoundingBox() );
469
470 return rect.Intersects( GetBoundingBox() );
471}
472
473
474void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter, bool aBackground,
475 const SCH_PLOT_SETTINGS& aPlotSettings ) const
476{
477 if( aBackground )
478 return;
479
480 auto* settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
481
482 COLOR4D color = ( GetBusEntryColor() == COLOR4D::UNSPECIFIED )
483 ? settings->GetLayerColor( m_layer )
485
486 int penWidth = ( GetPenWidth() == 0 ) ? settings->GetDefaultPenWidth() : GetPenWidth();
487
488 penWidth = std::max( penWidth, settings->GetMinPenWidth() );
489
490 aPlotter->SetCurrentLineWidth( penWidth );
491 aPlotter->SetColor( color );
492 aPlotter->SetDash( penWidth, GetLineStyle() );
493 aPlotter->MoveTo( m_pos );
494 aPlotter->FinishTo( GetEnd() );
495
496 aPlotter->SetDash( penWidth, LINE_STYLE::SOLID );
497}
498
499
501 std::vector<MSG_PANEL_ITEM>& aList )
502{
503 wxString msg;
504
505 switch( GetLayer() )
506 {
507 default:
508 case LAYER_WIRE: msg = _( "Wire" ); break;
509 case LAYER_BUS: msg = _( "Bus" ); break;
510 }
511
512 aList.emplace_back( _( "Bus Entry Type" ), msg );
513
514 SCH_CONNECTION* conn = nullptr;
515
516 if( !IsConnectivityDirty() && dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) )
517 conn = Connection();
518
519 if( conn )
520 {
521 conn->AppendInfoToMsgPanel( aList );
522
523 if( !conn->IsBus() )
524 aList.emplace_back( _( "Resolved Netclass" ), GetEffectiveNetClass()->GetName() );
525 }
526}
527
528
529bool SCH_BUS_ENTRY_BASE::operator <( const SCH_ITEM& aItem ) const
530{
531 if( Type() != aItem.Type() )
532 return Type() < aItem.Type();
533
534 auto symbol = static_cast<const SCH_BUS_ENTRY_BASE*>( &aItem );
535
536 if( GetLayer() != symbol->GetLayer() )
537 return GetLayer() < symbol->GetLayer();
538
539 if( GetPosition().x != symbol->GetPosition().x )
540 return GetPosition().x < symbol->GetPosition().x;
541
542 if( GetPosition().y != symbol->GetPosition().y )
543 return GetPosition().y < symbol->GetPosition().y;
544
545 if( GetEnd().x != symbol->GetEnd().x )
546 return GetEnd().x < symbol->GetEnd().x;
547
548 return GetEnd().y < symbol->GetEnd().y;
549}
550
551
553{
554 // Don't generate connections between bus entries and buses, since there is
555 // a connectivity change at that point (e.g. A[7..0] to A7)
556 if( ( aItem->Type() == SCH_LINE_T ) &&
557 ( static_cast<const SCH_LINE*>( aItem )->GetLayer() == LAYER_BUS ) )
558 {
559 return false;
560 }
561
562 // Same for bus junctions
563 if( ( aItem->Type() == SCH_JUNCTION_T ) &&
564 ( static_cast<const SCH_JUNCTION*>( aItem )->GetLayer() == LAYER_BUS_JUNCTION ) )
565 {
566 return false;
567 }
568
569 // Don't generate connections between bus entries and bus labels that happen
570 // to land at the same point on the bus wire as this bus entry
571 if( ( aItem->Type() == SCH_LABEL_T ) &&
572 SCH_CONNECTION::IsBusLabel( static_cast<const SCH_LABEL*>( aItem )->GetText() ) )
573 {
574 return false;
575 }
576
577 // Don't generate connections between two bus-wire entries
578 if( aItem->Type() == SCH_BUS_WIRE_ENTRY_T )
579 return false;
580
581 return true;
582}
583
584bool SCH_BUS_ENTRY_BASE::operator==( const SCH_ITEM& aItem ) const
585{
586 if( Type() != aItem.Type() )
587 return false;
588
589 const SCH_BUS_ENTRY_BASE* symbol = static_cast<const SCH_BUS_ENTRY_BASE*>( &aItem );
590
591 if( GetLayer() != symbol->GetLayer() )
592 return false;
593
594 if( GetPosition() != symbol->GetPosition() )
595 return false;
596
597 if( GetEnd() != symbol->GetEnd() )
598 return false;
599
600 return true;
601}
602
603
604double SCH_BUS_ENTRY_BASE::Similarity( const SCH_ITEM& aItem ) const
605{
606 if( aItem.Type() != Type() )
607 return 0.0;
608
609 if( m_Uuid == aItem.m_Uuid )
610 return 1.0;
611
612 const SCH_BUS_ENTRY_BASE& other = static_cast<const SCH_BUS_ENTRY_BASE&>( aItem );
613
614 if( GetLayer() != other.GetLayer() )
615 return 0.0;
616
617 if( GetPosition() != other.GetPosition() )
618 return 0.0;
619
620 return 1.0;
621}
622
623
625{
627 {
635
637
638 if( plotDashTypeEnum.Choices().GetCount() == 0 )
639 {
640 plotDashTypeEnum.Map( LINE_STYLE::DEFAULT, _HKI( "Default" ) )
641 .Map( LINE_STYLE::SOLID, _HKI( "Solid" ) )
642 .Map( LINE_STYLE::DASH, _HKI( "Dashed" ) )
643 .Map( LINE_STYLE::DOT, _HKI( "Dotted" ) )
644 .Map( LINE_STYLE::DASHDOT, _HKI( "Dash-Dot" ) )
645 .Map( LINE_STYLE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
646 }
647
648 // TODO: Maybe SCH_BUS_ENTRY_BASE should inherit from or mix in with SCH_LINE
649 void ( SCH_BUS_ENTRY_BASE::*lineStyleSetter )( LINE_STYLE ) =
651
653 _HKI( "Line Style" ),
654 lineStyleSetter, &SCH_BUS_ENTRY_BASE::GetLineStyle ) );
655
656 propMgr.AddProperty( new PROPERTY<SCH_BUS_ENTRY_BASE, int>( _HKI( "Line Width" ),
658 PROPERTY_DISPLAY::PT_SIZE ) );
659
662 }
int color
Definition: DXF_plotter.cpp:58
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
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:120
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:270
bool Contains(const Vec &aPoint) const
Definition: box2.h:142
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:507
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:256
Helper class used to store the state of schematic items that can be connected to other schematic item...
Definition: sch_item.h:86
DANGLING_END_T GetType() const
Definition: sch_item.h:130
EDA_ITEM * GetItem() const
Definition: sch_item.h:128
VECTOR2I GetPosition() const
Definition: sch_item.h:127
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:85
const KIID m_Uuid
Definition: eda_item.h:482
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:95
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:659
static ENUM_MAP< T > & Instance()
Definition: property.h:653
wxPGChoices & Choices()
Definition: property.h:702
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int GetDefaultPenWidth() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
wxDC * GetPrintDC() const
Store schematic specific render settings.
Definition: sch_painter.h:72
Base plotter engine class.
Definition: plotter.h:104
void MoveTo(const VECTOR2I &pos)
Definition: plotter.h:242
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle)=0
void FinishTo(const VECTOR2I &pos)
Definition: plotter.h:252
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:135
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
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)
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a schematic item.
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 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 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
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_SETTINGS &aPlotSettings) const override
Plot the schematic item to aPlotter.
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) 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:165
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
Definition: sch_item.cpp:176
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:272
bool IsConnectivityDirty() const
Definition: sch_item.h:453
void SwapFlags(SCH_ITEM *aItem)
Swap the non-temp and non-edit flags.
Definition: sch_item.cpp:267
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:147
SCH_LAYER_ID m_layer
Definition: sch_item.h:538
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
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, std::function< void(const VECTOR2I &a, const VECTOR2I &b)> aStroker)
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
#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
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:379
@ LAYER_WIRE
Definition: layer_ids.h:355
@ LAYER_BUS
Definition: layer_ids.h:356
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:393
@ LAYER_BUS_JUNCTION
Definition: layer_ids.h:396
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:67
#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:70
@ BUS_ENTRY_END
Definition: sch_item.h:74
@ WIRE_END
Definition: sch_item.h:69
@ WIRE_ENTRY_END
Definition: sch_item.h:75
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:48
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94
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:148
@ SCH_LABEL_T
Definition: typeinfo.h:155
@ SCH_BUS_BUS_ENTRY_T
Definition: typeinfo.h:147
@ SCH_BUS_WIRE_ENTRY_T
Definition: typeinfo.h:146
@ SCH_JUNCTION_T
Definition: typeinfo.h:144
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588