KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_item.h
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, [email protected]
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#pragma once
22
23#include <memory>
24#include <optional>
25#include <unordered_map>
26#include <unordered_set>
27#include <map>
28#include <set>
29
30#include <eda_item.h>
31#include <properties/property.h>
32#include <sch_sheet_path.h>
33#include <netclass.h>
34#include <stroke_params.h>
35#include <layer_ids.h>
36#include <sch_render_settings.h>
37#include <plotters/plotter.h>
38
41class SCH_CONNECTION;
42class SCH_SHEET_PATH;
43class SCHEMATIC;
44class SCH_COMMIT;
45class SYMBOL;
46class LINE_READER;
47class SCH_EDIT_FRAME;
48class SCH_RULE_AREA;
49struct SCH_PLOT_OPTS;
50
51namespace KIFONT
52{
53class METRICS;
54}
55
56
57enum BODY_STYLE : int
58{
59 BASE = 1,
61};
62
63
64#define MINIMUM_SELECTION_DISTANCE 2 // Minimum selection distance in mils
65
66
68{
69 AUTOPLACE_NONE, // No autoplacement
70 AUTOPLACE_AUTO, // A minimalist placement algorithm.
71 AUTOPLACE_MANUAL // A more involved routine that can be annoying if done from the get go.
72 // Initiated by a hotkey or menu item.
73};
74
75
89
90
96{
97public:
98 DANGLING_END_ITEM( DANGLING_END_T aType, EDA_ITEM* aItem, const VECTOR2I& aPosition )
99 {
100 m_item = aItem;
101 m_type = aType;
102 m_pos = aPosition;
103 m_parent = aItem;
104 }
105
106 DANGLING_END_ITEM( DANGLING_END_T aType, EDA_ITEM* aItem, const VECTOR2I& aPosition,
107 const EDA_ITEM* aParent )
108 {
109 m_item = aItem;
110 m_type = aType;
111 m_pos = aPosition;
112 m_parent = aParent;
113 }
114
115 bool operator==( const DANGLING_END_ITEM& aB ) const
116 {
117 return GetItem() == aB.GetItem()
118 && GetPosition() == aB.GetPosition()
119 && GetType() == aB.GetType()
120 && GetParent() == aB.GetParent();
121 }
122
123 bool operator<( const DANGLING_END_ITEM& rhs ) const
124 {
125 return( m_pos.x < rhs.m_pos.x || ( m_pos.x == rhs.m_pos.x && m_pos.y < rhs.m_pos.y )
126 || ( m_pos == rhs.m_pos && m_item < rhs.m_item ) );
127 }
128
129 VECTOR2I GetPosition() const { return m_pos; }
130 EDA_ITEM* GetItem() const { return m_item; }
131 const EDA_ITEM* GetParent() const { return m_parent; }
132 DANGLING_END_T GetType() const { return m_type; }
133
134private:
139};
140
141
143{
144public:
145 static std::vector<DANGLING_END_ITEM>::iterator
146 get_lower_pos( std::vector<DANGLING_END_ITEM>& aItemListByPos, const VECTOR2I& aPos );
147
148 static std::vector<DANGLING_END_ITEM>::iterator
149 get_lower_type( std::vector<DANGLING_END_ITEM>& aItemListByType, const DANGLING_END_T& aType );
150
152 static void sort_dangling_end_items( std::vector<DANGLING_END_ITEM>& aItemListByType,
153 std::vector<DANGLING_END_ITEM>& aItemListByPos );
154};
155
156
164class SCH_ITEM : public EDA_ITEM
165{
166public:
167 SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType, int aUnit = 0, int aBodyStyle = 0 );
168
169 SCH_ITEM( const SCH_ITEM& aItem );
170
171 SCH_ITEM& operator=( const SCH_ITEM& aPin );
172
173 virtual ~SCH_ITEM();
174
175 wxString GetClass() const override
176 {
177 return wxT( "SCH_ITEM" );
178 }
179
180 bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
181 {
182 if( EDA_ITEM::IsType( aScanTypes ) )
183 return true;
184
185 for( KICAD_T scanType : aScanTypes )
186 {
187 if( scanType == SCH_ITEM_LOCATE_WIRE_T && m_layer == LAYER_WIRE )
188 return true;
189
190 if ( scanType == SCH_ITEM_LOCATE_BUS_T && m_layer == LAYER_BUS )
191 return true;
192
193 if ( scanType == SCH_ITEM_LOCATE_GRAPHIC_LINE_T
194 && Type() == SCH_LINE_T && m_layer == LAYER_NOTES )
195 {
196 return true;
197 }
198 }
199
200 return false;
201 }
202
203 bool IsGroupableType() const;
204
215 void SwapItemData( SCH_ITEM* aImage );
216
220 void SwapFlags( SCH_ITEM* aItem );
221
233 SCH_ITEM* Duplicate( bool addToParentGroup, SCH_COMMIT* aCommit = nullptr, bool doClone = false ) const;
234
235 // Note: 0 represents "All Units", NOT the first unit
236 virtual void SetUnit( int aUnit ) { m_unit = aUnit; }
237 int GetUnit() const { return m_unit; }
238
239 virtual void SetUnitString( const wxString& aUnit );
240 virtual wxString GetUnitString() const;
241
242 virtual wxString GetUnitDisplayName( int aUnit, bool aLabel ) const;
243 virtual wxString GetBodyStyleDescription( int aBodyStyle, bool aLabel ) const;
244
245 // Note: 0 represents "All Body Styles, NOT the first body style
246 virtual void SetBodyStyle( int aBodyStyle ) { m_bodyStyle = aBodyStyle; }
247 int GetBodyStyle() const { return m_bodyStyle; }
248
249 virtual void SetBodyStyleProp( const wxString& aBodyStyle );
250 virtual wxString GetBodyStyleProp() const;
251
252 void SetPrivate( bool aPrivate ) { m_private = aPrivate; }
253 bool IsPrivate() const { return m_private; }
254
255 bool IsLocked() const override;
256 void SetLocked( bool aLocked ) override { m_isLocked = aLocked; }
257
258 virtual void SetExcludedFromSim( bool aExclude, const SCH_SHEET_PATH* aInstance = nullptr,
259 const wxString& aVariantName = wxEmptyString ) { }
260 virtual bool GetExcludedFromSim( const SCH_SHEET_PATH* aInstance = nullptr,
261 const wxString& aVariantName = wxEmptyString ) const { return false; }
262 bool ResolveExcludedFromSim( const SCH_SHEET_PATH* aInstance = nullptr,
263 const wxString& aVariantName = wxEmptyString ) const;
264
265 virtual void SetExcludedFromBOM( bool aExcludeFromBOM, const SCH_SHEET_PATH* aInstance = nullptr,
266 const wxString& aVariantName = wxEmptyString ) { }
267 virtual bool GetExcludedFromBOM( const SCH_SHEET_PATH* aInstance = nullptr,
268 const wxString& aVariantName = wxEmptyString ) const { return false; }
269 bool ResolveExcludedFromBOM( const SCH_SHEET_PATH* aInstance = nullptr,
270 const wxString& aVariantName = wxEmptyString ) const;
271
272 virtual void SetExcludedFromBoard( bool aExclude, const SCH_SHEET_PATH* aInstance = nullptr,
273 const wxString& aVariantName = wxEmptyString ) { }
274 virtual bool GetExcludedFromBoard( const SCH_SHEET_PATH* aInstance = nullptr,
275 const wxString& aVariantName = wxEmptyString ) const { return false; }
276 bool ResolveExcludedFromBoard( const SCH_SHEET_PATH* aInstance = nullptr,
277 const wxString& aVariantName = wxEmptyString ) const;
278
279 virtual void SetExcludedFromPosFiles( bool aExclude, const SCH_SHEET_PATH* aInstance = nullptr,
280 const wxString& aVariantName = wxEmptyString ) { }
281 virtual bool GetExcludedFromPosFiles( const SCH_SHEET_PATH* aInstance = nullptr,
282 const wxString& aVariantName = wxEmptyString ) const { return false; }
283 bool ResolveExcludedFromPosFiles( const SCH_SHEET_PATH* aInstance = nullptr,
284 const wxString& aVariantName = wxEmptyString ) const;
285
286 virtual void SetDNP( bool aDNP, const SCH_SHEET_PATH* aInstance = nullptr,
287 const wxString& aVariantName = wxEmptyString ) { }
288 virtual bool GetDNP( const SCH_SHEET_PATH* aInstance = nullptr,
289 const wxString& aVariantName = wxEmptyString ) const { return false; }
290 bool ResolveDNP( const SCH_SHEET_PATH* aInstance = nullptr,
291 const wxString& aVariantName = wxEmptyString ) const;
292
293 wxString ResolveText( const wxString& aText, const SCH_SHEET_PATH* aPath, int aDepth = 0 ) const;
294 wxString ResolveText( const wxString& aText, const SCH_SHEET_PATH* aPath, int aDepth,
295 const wxString& aVariantName ) const;
296
306 virtual bool IsMovableFromAnchorPoint() const { return true; }
307
309 void SetStoredPos( const VECTOR2I& aPos ) { m_storedPos = aPos; }
310
323 SCHEMATIC* Schematic() const;
324
325 const SYMBOL* GetParentSymbol() const;
327
332 virtual bool HasHypertext() const { return false; }
333
338 virtual bool HasHoveredHypertext() const { return HasHypertext() && IsRollover(); }
339
340 virtual void DoHypertextAction( EDA_DRAW_FRAME* aFrame, const VECTOR2I& aMousePos ) const { }
341
345 SCH_LAYER_ID GetLayer() const { return m_layer; }
346 void SetLayer( SCH_LAYER_ID aLayer ) { m_layer = aLayer; }
347
351 std::vector<int> ViewGetLayers() const override;
352
353 int GetMaxError() const;
354
358 virtual int GetPenWidth() const { return 0; }
359
360 int GetEffectivePenWidth( const SCH_RENDER_SETTINGS* aSettings ) const;
361
362 const wxString& GetDefaultFont( const RENDER_SETTINGS* aSettings ) const;
363
364 const KIFONT::METRICS& GetFontMetrics() const;
365
366 bool RenderAsBitmap( double aWorldScale ) const override;
367
374 virtual double Similarity( const SCH_ITEM& aItem ) const
375 {
376 wxCHECK_MSG( false, 0.0, wxT( "Similarity not implemented in " ) + GetClass() );
377 }
378
384 double SimilarityBase( const SCH_ITEM& aItem ) const
385 {
386 double similarity = 1.0;
387
388 if( m_unit != aItem.m_unit )
389 similarity *= 0.9;
390
391 if( m_bodyStyle != aItem.m_bodyStyle )
392 similarity *= 0.9;
393
394 if( m_private != aItem.m_private )
395 similarity *= 0.9;
396
397 return similarity;
398 }
399
403 virtual void Move( const VECTOR2I& aMoveVector )
404 {
405 wxCHECK_MSG( false, /*void*/, wxT( "Move not implemented in " ) + GetClass() );
406 }
407
411 virtual void MirrorHorizontally( int aCenter )
412 {
413 wxCHECK_MSG( false, /*void*/, wxT( "MirrorHorizontally not implemented in " ) + GetClass() );
414 }
415
419 virtual void MirrorVertically( int aCenter )
420 {
421 wxCHECK_MSG( false, /*void*/, wxT( "MirrorVertically not implemented in " ) + GetClass() );
422 }
423
427 virtual void Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
428 {
429 wxCHECK_MSG( false, /*void*/, wxT( "Rotate not implemented in " ) + GetClass() );
430 }
431
441 virtual void BeginEdit( const VECTOR2I& aPosition ) {}
442
453 virtual bool ContinueEdit( const VECTOR2I& aPosition ) { return false; }
454
460 virtual void EndEdit( bool aClosed = false ) {}
461
471 virtual void CalcEdit( const VECTOR2I& aPosition ) {}
472
483 virtual void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) {}
484
503 virtual bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
504 std::vector<DANGLING_END_ITEM>& aItemListByPos,
505 const SCH_SHEET_PATH* aSheet = nullptr )
506 {
507 return false;
508 }
509
522 virtual bool IsEndPoint( const VECTOR2I& aPt ) const { return false; }
523
524 virtual bool IsDangling() const { return false; }
525
526 virtual bool CanConnect( const SCH_ITEM* aItem ) const { return m_layer == aItem->GetLayer(); }
527
531 virtual bool IsConnectable() const { return false; }
532
537 virtual bool IsPointClickableAnchor( const VECTOR2I& aPos ) const { return false; }
538
546 virtual std::vector<VECTOR2I> GetConnectionPoints() const { return {}; }
547
554 bool IsConnected( const VECTOR2I& aPoint ) const;
555
561 SCH_CONNECTION* Connection( const SCH_SHEET_PATH* aSheet = nullptr ) const;
562
564 std::optional<wxString> GetConnectionName( const SCH_SHEET_PATH* aSheet = nullptr,
565 bool aLocal = false, bool aIgnoreSheet = false ) const;
566
567 bool HasBusConnection( const SCH_SHEET_PATH* aSheet = nullptr ) const;
568
572 const std::vector<SCH_ITEM*>& ConnectedItems( const SCH_SHEET_PATH& aPath ) const;
573
577 void AddConnectionTo( const SCH_SHEET_PATH& aPath, SCH_ITEM* aItem );
578
582 void ClearConnectedItems( const SCH_SHEET_PATH& aPath );
583
590
592
596 virtual bool ConnectionPropagatesTo( const EDA_ITEM* aItem ) const { return true; }
597
599
600 void SetConnectivityDirty( bool aDirty = true ) { m_connectivity_dirty = aDirty; }
601
617 virtual bool HasConnectivityChanges( const SCH_ITEM* aItem,
618 const SCH_SHEET_PATH* aInstance = nullptr ) const
619 {
620 return false;
621 }
622
624 void SetConnectionGraph( CONNECTION_GRAPH* aGraph );
625
626 virtual bool HasCachedDriverName() const { return false; }
627 virtual const wxString& GetCachedDriverName() const;
628
629 virtual void SetLastResolvedState( const SCH_ITEM* aItem ) { }
630
631 std::shared_ptr<NETCLASS> GetEffectiveNetClass( const SCH_SHEET_PATH* aSheet = nullptr ) const;
632
638
639 virtual void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) { }
640
641 virtual void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode ) { }
642
643 virtual void ClearCaches();
644
652 virtual bool HasLineStroke() const { return false; }
653
654 virtual STROKE_PARAMS GetStroke() const { wxCHECK( false, STROKE_PARAMS() ); }
655
656 virtual void SetStroke( const STROKE_PARAMS& aStroke ) { wxCHECK( false, /* void */ ); }
657
658 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
659
670 virtual void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
671 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed)
672 {
673 wxCHECK_MSG( false, /*void*/, wxT( "Plot not implemented in " ) + GetClass() );
674 }
675
680
684 void AddRuleAreaToCache( SCH_RULE_AREA* aRuleArea ) { m_rule_areas_cache.insert( aRuleArea ); }
685
689 void RemoveRuleAreaFromCache( SCH_RULE_AREA* aRuleArea ) { m_rule_areas_cache.erase( aRuleArea ); }
690
694 const std::unordered_set<SCH_RULE_AREA*>& GetRuleAreaCache() const
695 {
696 return m_rule_areas_cache;
697 }
698
699 const std::vector<wxString>* GetEmbeddedFonts() override;
700
704 enum COMPARE_FLAGS : int
705 {
706 UNIT = 1 << 0,
707 POSITION = 1 << 1,
708 UUID = 1 << 2,
710 EXTRA_FIELDS = 1 << 4,
711 FIELD_TEXT = 1 << 5,
716 PIN_ALT_DEFS = 1 << 10,
719 DNP = 1 << 13,
722 IDENTITY = 1 << 17,
723 };
724
725 virtual bool operator==( const SCH_ITEM& aOther ) const;
726
727 virtual bool operator<( const SCH_ITEM& aItem ) const;
728
729protected:
737 virtual void swapData( SCH_ITEM* aItem );
738
740 {
741 return static_cast<SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
742 }
743
745 {
746 bool operator()( const SCH_ITEM* aFirst, const SCH_ITEM* aSecond ) const;
747 };
748
769 virtual int compare( const SCH_ITEM& aOther, int aCompareFlags = ~COMPARE_FLAGS::UNIT ) const;
770
771private:
772 friend class CONNECTION_GRAPH;
773
787 virtual bool doIsConnected( const VECTOR2I& aPosition ) const { return false; }
788
789protected:
791 int m_unit; // set to 0 if common to all units
792 int m_bodyStyle; // set to 0 if common to all body styles
793 bool m_private; // only shown in Symbol Editor
794 AUTOPLACE_ALGO m_fieldsAutoplaced; // indicates status of field autoplacement
795 VECTOR2I m_storedPos; // temp variable used in some move commands to store
796 // an initial position of the item or mouse cursor
797
799 std::map<SCH_SHEET_PATH, std::vector<SCH_ITEM*>, SHEET_PATH_CMP> m_connected_items;
800
802 std::unordered_map<SCH_SHEET_PATH, SCH_CONNECTION*> m_connection_map;
803
805
807 std::unordered_set<SCH_RULE_AREA*> m_rule_areas_cache;
808
810
811private:
812 friend class LIB_SYMBOL;
813 friend class CONNECTION_GRAPH;
814
816 void registerConnectivityOwner( const std::shared_ptr<CONNECTION_GRAPH_LIFETIME>& aOwner );
817
819 std::vector<std::weak_ptr<CONNECTION_GRAPH_LIFETIME>> m_connectivityOwners;
820};
821
Calculate the connectivity of a schematic and generate netlists.
static std::vector< DANGLING_END_ITEM >::iterator get_lower_type(std::vector< DANGLING_END_ITEM > &aItemListByType, const DANGLING_END_T &aType)
static std::vector< DANGLING_END_ITEM >::iterator get_lower_pos(std::vector< DANGLING_END_ITEM > &aItemListByPos, const VECTOR2I &aPos)
Definition sch_item.cpp:993
static void sort_dangling_end_items(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos)
Both contain the same information.
const EDA_ITEM * m_parent
A pointer to the parent object (in the case of pins).
Definition sch_item.h:138
bool operator==(const DANGLING_END_ITEM &aB) const
Definition sch_item.h:115
DANGLING_END_T m_type
The type of connection of m_item.
Definition sch_item.h:137
DANGLING_END_ITEM(DANGLING_END_T aType, EDA_ITEM *aItem, const VECTOR2I &aPosition)
Definition sch_item.h:98
DANGLING_END_T GetType() const
Definition sch_item.h:132
bool operator<(const DANGLING_END_ITEM &rhs) const
Definition sch_item.h:123
DANGLING_END_ITEM(DANGLING_END_T aType, EDA_ITEM *aItem, const VECTOR2I &aPosition, const EDA_ITEM *aParent)
Definition sch_item.h:106
VECTOR2I m_pos
The position of the connection point.
Definition sch_item.h:136
const EDA_ITEM * GetParent() const
Definition sch_item.h:131
EDA_ITEM * GetItem() const
Definition sch_item.h:130
EDA_ITEM * m_item
A pointer to the connectable object.
Definition sch_item.h:135
VECTOR2I GetPosition() const
Definition sch_item.h:129
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:98
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition eda_item.h:214
bool IsRollover() const
Definition eda_item.h:142
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition richio.h:65
Base plotter engine class.
Definition plotter.h:136
RENDER_SETTINGS * RenderSettings()
Definition plotter.h:167
Holds all the data relating to one schematic.
Definition schematic.h:148
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
Schematic editor (Eeschema) main window.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:165
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.
Definition sch_item.cpp:859
void SetStoredPos(const VECTOR2I &aPos)
Definition sch_item.h:309
virtual void SetExcludedFromBOM(bool aExcludeFromBOM, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString)
Definition sch_item.h:265
VECTOR2I m_storedPos
Definition sch_item.h:795
SCH_ITEM * Duplicate(bool addToParentGroup, SCH_COMMIT *aCommit=nullptr, bool doClone=false) const
Routine to create a new copy of given item.
Definition sch_item.cpp:170
virtual void SetBodyStyle(int aBodyStyle)
Definition sch_item.h:246
virtual bool CanConnect(const SCH_ITEM *aItem) const
Definition sch_item.h:526
virtual bool IsEndPoint(const VECTOR2I &aPt) const
Test if aPt is an end point of this schematic object.
Definition sch_item.h:522
virtual bool IsConnectable() const
Definition sch_item.h:531
void SetLocked(bool aLocked) override
Definition sch_item.h:256
friend class CONNECTION_GRAPH
Definition sch_item.h:772
void RemoveRuleAreaFromCache(SCH_RULE_AREA *aRuleArea)
Remove a specific rule area from the item's cache.
Definition sch_item.h:689
virtual void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo)
Definition sch_item.h:639
virtual bool HasHoveredHypertext() const
Indicates that a hypertext link is currently active.
Definition sch_item.h:338
int m_unit
Definition sch_item.h:791
bool ResolveExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:359
virtual int GetPenWidth() const
Definition sch_item.h:358
SCH_ITEM & operator=(const SCH_ITEM &aPin)
Definition sch_item.cpp:78
std::map< SCH_SHEET_PATH, std::vector< SCH_ITEM * >, SHEET_PATH_CMP > m_connected_items
Store pointers to other items that are connected to this one, per sheet.
Definition sch_item.h:799
void ClearConnectedItems(const SCH_SHEET_PATH &aPath)
Clear all connections to this item.
Definition sch_item.cpp:580
virtual bool doIsConnected(const VECTOR2I &aPosition) const
Provide the object specific test to see if it is connected to aPosition.
Definition sch_item.h:787
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode)
Definition sch_item.h:641
int m_bodyStyle
Definition sch_item.h:792
virtual void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList)
Add the schematic item end points to aItemList if the item has end points.
Definition sch_item.h:483
std::vector< std::weak_ptr< CONNECTION_GRAPH_LIFETIME > > m_connectivityOwners
An item may be indexed by multiple graphs, each with an independent lifetime.
Definition sch_item.h:819
const std::vector< wxString > * GetEmbeddedFonts() override
Definition sch_item.cpp:875
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition sch_item.h:739
virtual bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos, const SCH_SHEET_PATH *aSheet=nullptr)
Test the schematic item to aItemList to check if it's dangling state has changed.
Definition sch_item.h:503
virtual ~SCH_ITEM()
Definition sch_item.cpp:92
const SYMBOL * GetParentSymbol() const
Definition sch_item.cpp:287
virtual wxString GetBodyStyleDescription(int aBodyStyle, bool aLabel) const
Definition sch_item.cpp:215
void SetPrivate(bool aPrivate)
Definition sch_item.h:252
virtual void swapData(SCH_ITEM *aItem)
Swap the internal data structures aItem with the schematic item.
Definition sch_item.cpp:659
virtual const wxString & GetCachedDriverName() const
Definition sch_item.cpp:652
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:281
virtual void SetLastResolvedState(const SCH_ITEM *aItem)
Definition sch_item.h:629
int GetBodyStyle() const
Definition sch_item.h:247
virtual double Similarity(const SCH_ITEM &aItem) const
Return a measure of how likely the other object is to represent the same object.
Definition sch_item.h:374
virtual bool IsDangling() const
Definition sch_item.h:524
virtual bool IsPointClickableAnchor(const VECTOR2I &aPos) const
Definition sch_item.h:537
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition sch_item.cpp:487
virtual bool ContinueEdit(const VECTOR2I &aPosition)
Continue an edit in progress at aPosition.
Definition sch_item.h:453
virtual void MirrorHorizontally(int aCenter)
Mirror item horizontally about aCenter.
Definition sch_item.h:411
virtual void DoHypertextAction(EDA_DRAW_FRAME *aFrame, const VECTOR2I &aMousePos) const
Definition sch_item.h:340
const std::unordered_set< SCH_RULE_AREA * > & GetRuleAreaCache() const
Get the cache of rule areas enclosing this item.
Definition sch_item.h:694
SCH_CONNECTION * InitializeConnection(const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
Create a new connection object associated with this object.
Definition sch_item.cpp:613
const std::vector< SCH_ITEM * > & ConnectedItems(const SCH_SHEET_PATH &aPath) const
Retrieve the set of items connected to this item on the given sheet.
Definition sch_item.cpp:589
virtual wxString GetUnitDisplayName(int aUnit, bool aLabel) const
Definition sch_item.cpp:204
bool IsLocked() const override
Definition sch_item.cpp:158
void AddConnectionTo(const SCH_SHEET_PATH &aPath, SCH_ITEM *aItem)
Add a connection link between this item and another.
Definition sch_item.cpp:597
friend class LIB_SYMBOL
Definition sch_item.h:812
virtual void Move(const VECTOR2I &aMoveVector)
Move the item by aMoveVector to a new position.
Definition sch_item.h:403
COMPARE_FLAGS
The list of flags used by various compare functions.
Definition sch_item.h:705
@ MISSING_FIELDS
Definition sch_item.h:709
@ EXCLUDE_FROM_BOARD
Definition sch_item.h:718
@ FIELD_VISIBILITY
Definition sch_item.h:712
@ EXCLUDE_FROM_POS_FILES
Definition sch_item.h:721
@ EXTRA_FIELDS
Definition sch_item.h:710
@ FIELD_SIZE_AND_STYLE
Definition sch_item.h:713
@ EXCLUDE_FROM_BOM
Definition sch_item.h:720
@ FIELD_TEXT
Definition sch_item.h:711
@ PIN_ALT_DEFS
Definition sch_item.h:716
@ EXCLUDE_FROM_SIM
Definition sch_item.h:717
@ FIELD_POSITIONS
Definition sch_item.h:714
@ PIN_VISIBILITIES
Definition sch_item.h:715
virtual bool HasHypertext() const
Indicates that the item has at least one hypertext action.
Definition sch_item.h:332
virtual bool GetExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.h:281
int GetUnit() const
Definition sch_item.h:237
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
Definition sch_item.cpp:556
virtual void CalcEdit(const VECTOR2I &aPosition)
Calculate the attributes of an item at aPosition when it is being edited.
Definition sch_item.h:471
virtual bool operator==(const SCH_ITEM &aOther) const
Definition sch_item.cpp:730
bool m_connectivity_dirty
Definition sch_item.h:804
virtual void SetDNP(bool aDNP, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString)
Definition sch_item.h:286
bool IsPrivate() const
Definition sch_item.h:253
virtual void ClearCaches()
Definition sch_item.cpp:710
void SetLayer(SCH_LAYER_ID aLayer)
Definition sch_item.h:346
void AddRuleAreaToCache(SCH_RULE_AREA *aRuleArea)
Add a rule area to the item's cache.
Definition sch_item.h:684
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition sch_item.h:345
void ClearRuleAreasCache()
Reset the cache of rule areas (called prior to schematic connectivity computation)
Definition sch_item.h:679
virtual void SetStroke(const STROKE_PARAMS &aStroke)
Definition sch_item.h:656
int GetMaxError() const
Definition sch_item.cpp:793
virtual bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.h:274
virtual void SetBodyStyleProp(const wxString &aBodyStyle)
Definition sch_item.cpp:253
void SetConnectivityDirty(bool aDirty=true)
Definition sch_item.h:600
virtual wxString GetBodyStyleProp() const
Definition sch_item.cpp:275
void SetFieldsAutoplaced(AUTOPLACE_ALGO aAlgo)
Definition sch_item.h:637
bool RenderAsBitmap(double aWorldScale) const override
Definition sch_item.cpp:847
virtual void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed)
Plot the item to aPlotter.
Definition sch_item.h:670
virtual void Rotate(const VECTOR2I &aCenter, bool aRotateCCW)
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition sch_item.h:427
const wxString & GetDefaultFont(const RENDER_SETTINGS *aSettings) const
Definition sch_item.cpp:802
bool IsConnectivityDirty() const
Definition sch_item.h:598
std::optional< wxString > GetConnectionName(const SCH_SHEET_PATH *aSheet=nullptr, bool aLocal=false, bool aIgnoreSheet=false) const
Return the connection name for this sheet instance, if connected.
Definition sch_item.cpp:539
void SetConnectionGraph(CONNECTION_GRAPH *aGraph)
Update the connection graph for all connections in this item.
Definition sch_item.cpp:527
virtual void SetUnit(int aUnit)
Definition sch_item.h:236
AUTOPLACE_ALGO m_fieldsAutoplaced
Definition sch_item.h:794
std::unordered_set< SCH_RULE_AREA * > m_rule_areas_cache
Store pointers to rule areas which this item is contained within.
Definition sch_item.h:807
void SwapFlags(SCH_ITEM *aItem)
Swap the non-temp and non-edit flags.
Definition sch_item.cpp:689
bool IsConnected(const VECTOR2I &aPoint) const
Test the item to see if it is connected to aPoint.
Definition sch_item.cpp:494
virtual void SetUnitString(const wxString &aUnit)
Definition sch_item.cpp:226
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:52
std::unordered_map< SCH_SHEET_PATH, SCH_CONNECTION * > m_connection_map
Store connectivity information, per sheet.
Definition sch_item.h:802
virtual bool HasCachedDriverName() const
Definition sch_item.h:626
virtual bool operator<(const SCH_ITEM &aItem) const
Definition sch_item.cpp:739
bool ResolveExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:327
bool m_private
Definition sch_item.h:793
void registerConnectivityOwner(const std::shared_ptr< CONNECTION_GRAPH_LIFETIME > &aOwner)
Graph membership belongs to this item identity and must not propagate to clones.
Definition sch_item.cpp:109
SCH_CONNECTION * GetOrInitConnection(const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
Definition sch_item.cpp:637
virtual bool IsMovableFromAnchorPoint() const
Check if object is movable from the anchor point.
Definition sch_item.h:306
virtual bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const
Check if aItem has connectivity changes against this object.
Definition sch_item.h:617
AUTOPLACE_ALGO GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
Definition sch_item.h:636
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:503
wxString ResolveText(const wxString &aText, const SCH_SHEET_PATH *aPath, int aDepth=0) const
Definition sch_item.cpp:390
virtual int compare(const SCH_ITEM &aOther, int aCompareFlags=~COMPARE_FLAGS::UNIT) const
Provide the draw object specific comparison called by the == and < operators.
Definition sch_item.cpp:754
virtual void SetExcludedFromPosFiles(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString)
Definition sch_item.h:279
wxString GetClass() const override
Return the class name.
Definition sch_item.h:175
VECTOR2I & GetStoredPos()
Definition sch_item.h:308
bool ResolveExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:343
virtual void EndEdit(bool aClosed=false)
End an object editing action.
Definition sch_item.h:460
const KIFONT::METRICS & GetFontMetrics() const
Definition sch_item.cpp:815
bool ResolveDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:375
virtual wxString GetUnitString() const
Definition sch_item.cpp:248
bool HasBusConnection(const SCH_SHEET_PATH *aSheet=nullptr) const
Definition sch_item.cpp:549
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
Definition sch_item.cpp:824
virtual STROKE_PARAMS GetStroke() const
Definition sch_item.h:654
virtual void BeginEdit(const VECTOR2I &aPosition)
Begin drawing a symbol library draw item at aPosition.
Definition sch_item.h:441
bool IsGroupableType() const
Definition sch_item.cpp:123
void SwapItemData(SCH_ITEM *aImage)
Swap data between aItem and aImage.
Definition sch_item.cpp:665
bool ResolveExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:311
SCH_LAYER_ID m_layer
Definition sch_item.h:790
virtual bool HasLineStroke() const
Check if this schematic item has line stoke properties.
Definition sch_item.h:652
virtual bool ConnectionPropagatesTo(const EDA_ITEM *aItem) const
Return true if this item should propagate connection info to aItem.
Definition sch_item.h:596
bool m_isLocked
Definition sch_item.h:809
virtual std::vector< VECTOR2I > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition sch_item.h:546
virtual void SetExcludedFromBoard(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString)
Definition sch_item.h:272
double SimilarityBase(const SCH_ITEM &aItem) const
Calculate the boilerplate similarity for all LIB_ITEMs without preventing the use above of a pure vir...
Definition sch_item.h:384
virtual bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.h:260
virtual bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.h:288
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition sch_item.h:180
virtual void MirrorVertically(int aCenter)
Mirror item vertically about aCenter.
Definition sch_item.h:419
virtual void SetExcludedFromSim(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString)
Definition sch_item.h:258
virtual bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.h:267
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Simple container to manage line stroke parameters.
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition symbol.h:59
RECURSE_MODE
Definition eda_item.h:50
SCH_LAYER_ID
Eeschema drawing layers.
Definition layer_ids.h:471
@ LAYER_WIRE
Definition layer_ids.h:474
@ LAYER_NOTES
Definition layer_ids.h:489
@ LAYER_BUS
Definition layer_ids.h:475
#define DECLARE_ENUM_TO_WXANY(type)
Definition property.h:838
AUTOPLACE_ALGO
Definition sch_item.h:68
@ AUTOPLACE_MANUAL
Definition sch_item.h:71
@ AUTOPLACE_NONE
Definition sch_item.h:69
@ AUTOPLACE_AUTO
Definition sch_item.h:70
DANGLING_END_T
Definition sch_item.h:77
@ NO_CONNECT_END
Definition sch_item.h:87
@ SHEET_LABEL_END
Definition sch_item.h:86
@ LABEL_END
Definition sch_item.h:83
@ JUNCTION_END
Definition sch_item.h:81
@ BUS_END
Definition sch_item.h:80
@ PIN_END
Definition sch_item.h:82
@ BUS_ENTRY_END
Definition sch_item.h:84
@ WIRE_END
Definition sch_item.h:79
@ WIRE_ENTRY_END
Definition sch_item.h:85
@ DANGLING_END_UNKNOWN
Definition sch_item.h:78
BODY_STYLE
Definition sch_item.h:58
@ BASE
Definition sch_item.h:59
@ DEMORGAN
Definition sch_item.h:60
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
Lets indexed items detect graph destruction without traversing their schematic parents.
bool operator()(const SCH_ITEM *aFirst, const SCH_ITEM *aSecond) const
Definition sch_item.cpp:748
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:70
@ SCH_LINE_T
Definition typeinfo.h:159
@ SCH_ITEM_LOCATE_WIRE_T
Definition typeinfo.h:182
@ SCH_ITEM_LOCATE_BUS_T
Definition typeinfo.h:183
@ SCH_ITEM_LOCATE_GRAPHIC_LINE_T
Definition typeinfo.h:184
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683