KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_item.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) 2006 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, 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 <pgm_base.h>
27#include <eeschema_settings.h>
28#include <eda_item.h>
29#include <sch_connection.h>
30#include <sch_group.h>
31#include <sch_item.h>
32#include <sch_screen.h>
33#include <sch_sheet_path.h>
34#include <sch_draw_panel.h>
35#include <sch_edit_frame.h>
36#include <schematic.h>
37#include <symbol.h>
38#include <connection_graph.h>
39#include <trace_helpers.h>
40#include <general.h>
41#include <netclass.h>
44
45
46// Rendering fonts is expensive (particularly when using outline fonts). At small effective
47// sizes (ie: zoomed out) the visual differences between outline and/or stroke fonts and the
48// bitmap font becomes immaterial, and there's often more to draw when zoomed out so the
49// performance gain becomes more significant.
50#define BITMAP_FONT_SIZE_THRESHOLD 3
51
52
53wxString SCH_ITEM::GetUnitDescription( int aUnit )
54{
55 if( aUnit == 0 )
56 return _( "All" );
57 else
58 return LIB_SYMBOL::LetterSubReference( aUnit, 'A' );
59}
60
61
62wxString SCH_ITEM::GetBodyStyleDescription( int aBodyStyle )
63{
64 if( aBodyStyle == 0 )
65 return _( "All" );
66 else if( aBodyStyle == BODY_STYLE::DEMORGAN )
67 return _( "Alternate" );
68 else if( aBodyStyle == BODY_STYLE::BASE )
69 return _( "Standard" );
70 else
71 return wxT( "?" );
72}
73
74
75/* Constructor and destructor for SCH_ITEM */
76/* They are not inline because this creates problems with gcc at linking time in debug mode */
77
78SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType, int aUnit, int aBodyStyle ) :
79 EDA_ITEM( aParent, aType, true, false ),
80 m_unit( aUnit ),
81 m_bodyStyle( aBodyStyle ),
82 m_private( false )
83{
84 m_layer = LAYER_WIRE; // It's only a default, in fact
86 m_connectivity_dirty = false; // Item is unconnected until it is placed, so it's clean
87}
88
89
91 EDA_ITEM( aItem )
92{
93 m_layer = aItem.m_layer;
94 m_unit = aItem.m_unit;
96 m_private = aItem.m_private;
99}
100
101
103{
104 m_layer = aItem.m_layer;
105 m_unit = aItem.m_unit;
106 m_bodyStyle = aItem.m_bodyStyle;
107 m_private = aItem.m_private;
110
111 return *this;
112}
113
114
116{
117 for( const auto& it : m_connection_map )
118 delete it.second;
119
120 // Do not try to modify SCHEMATIC::ConnectionGraph()
121 // if the schematic does not exist
123 return;
124
125 SCHEMATIC* sch = Schematic();
126
127 if( sch != nullptr )
128 sch->ConnectionGraph()->RemoveItem( this );
129}
130
131
132SCH_ITEM* SCH_ITEM::Duplicate( bool doClone ) const
133{
134 SCH_ITEM* newItem = (SCH_ITEM*) Clone();
135
136 if( !doClone )
137 const_cast<KIID&>( newItem->m_Uuid ) = KIID();
138
139 if( newItem->GetParentGroup() )
140 newItem->GetParentGroup()->AddItem( newItem );
141
142 newItem->ClearFlags( SELECTED | BRIGHTENED );
143
144 newItem->RunOnChildren(
145 []( SCH_ITEM* aChild )
146 {
147 aChild->ClearFlags( SELECTED | BRIGHTENED );
148 },
149 RECURSE_MODE::NO_RECURSE );
150
151 return newItem;
152}
153
154
155void SCH_ITEM::SetUnitProp( int aUnit )
156{
157 if( GetParentSymbol() )
158 aUnit = std::min( aUnit, GetParentSymbol()->GetUnitCount() );
159
160 aUnit = std::max( aUnit, 0 );
161
162 m_unit = aUnit;
163}
164
165
166void SCH_ITEM::SetBodyStyleProp( int aBodyStyle )
167{
168 if( GetParentSymbol() && GetParentSymbol()->HasAlternateBodyStyle() )
169 aBodyStyle = std::min( aBodyStyle, (int) BODY_STYLE::DEMORGAN );
170
171 aBodyStyle = std::max( aBodyStyle, 0 );
172
173 m_bodyStyle = aBodyStyle;
174}
175
176
178{
179 EDA_ITEM* parent = GetParent();
180
181 while( parent )
182 {
183 if( parent->Type() == SCHEMATIC_T )
184 return static_cast<SCHEMATIC*>( parent );
185 else
186 parent = parent->GetParent();
187 }
188
189 return nullptr;
190}
191
192
194{
195 const EDA_ITEM* parent = GetParent();
196
197 while( parent )
198 {
199 if( parent->Type() == SCH_SYMBOL_T )
200 return static_cast<const SCH_SYMBOL*>( parent );
201 else if( parent->Type() == LIB_SYMBOL_T )
202 return static_cast<const LIB_SYMBOL*>( parent );
203 else
204 parent = parent->GetParent();
205 }
206
207 return nullptr;
208}
209
210
212{
213 EDA_ITEM* parent = GetParent();
214
215 while( parent )
216 {
217 if( parent->Type() == SCH_SYMBOL_T )
218 return static_cast<SCH_SYMBOL*>( parent );
219 else if( parent->Type() == LIB_SYMBOL_T )
220 return static_cast<LIB_SYMBOL*>( parent );
221 else
222 parent = parent->GetParent();
223 }
224
225 return nullptr;
226}
227
228
229std::vector<int> SCH_ITEM::ViewGetLayers() const
230{
231 // Basic fallback
233}
234
235
236bool SCH_ITEM::IsConnected( const VECTOR2I& aPosition ) const
237{
238 if(( m_flags & STRUCT_DELETED ) || ( m_flags & SKIP_STRUCT ) )
239 return false;
240
241 return doIsConnected( aPosition );
242}
243
244
246{
247 if( !IsConnectable() )
248 return nullptr;
249
250 if( !aSheet )
251 aSheet = &Schematic()->CurrentSheet();
252
253 auto it = m_connection_map.find( *aSheet );
254
255 if( it == m_connection_map.end() )
256 return nullptr;
257 else
258 return it->second;
259}
260
261
263{
264 for( auto& [path, conn] : m_connection_map )
265 {
266 conn->SetGraph( aGraph );
267
268 for( auto& member : conn->AllMembers() )
269 member->SetGraph( aGraph );
270 }
271}
272
273
274std::shared_ptr<NETCLASS> SCH_ITEM::GetEffectiveNetClass( const SCH_SHEET_PATH* aSheet ) const
275{
276 static std::shared_ptr<NETCLASS> nullNetclass = std::make_shared<NETCLASS>( wxEmptyString );
277
278 SCHEMATIC* schematic = Schematic();
279
280 if( schematic )
281 {
282 std::shared_ptr<NET_SETTINGS>& netSettings =
283 schematic->Prj().GetProjectFile().m_NetSettings;
284 SCH_CONNECTION* connection = Connection( aSheet );
285
286 if( connection )
287 return netSettings->GetEffectiveNetClass( connection->Name() );
288 else
289 return netSettings->GetDefaultNetclass();
290 }
291
292 return nullNetclass;
293}
294
295
297{
298 auto it = m_connected_items.find( aSheet );
299
300 if( it != m_connected_items.end() )
301 it->second.clear();
302}
303
304
306{
307 return m_connected_items[ aSheet ];
308}
309
310
312{
313 SCH_ITEM_VEC& vec = m_connected_items[ aSheet ];
314
315 // The vector elements are small, so reserve 1k at a time to prevent re-allocations
316 if( vec.size() == vec.capacity() )
317 vec.reserve( vec.size() + 4096 );
318
319 // Add item to the correct place in the sorted vector if it is not already there
320 auto it = std::lower_bound( vec.begin(), vec.end(), aItem );
321
322 if( it == vec.end() || *it != aItem )
323 vec.insert( it, aItem );
324}
325
326
328 CONNECTION_GRAPH* aGraph )
329{
330 SCH_CONNECTION* connection = Connection( &aSheet );
331
332 // N.B. Do not clear the dirty connectivity flag here because we may need
333 // to create a connection for a different sheet, and we don't want to
334 // skip the connection creation because the flag is cleared.
335 if( connection )
336 {
337 connection->Reset();
338 }
339 else
340 {
341 connection = new SCH_CONNECTION( this );
342 m_connection_map.insert( std::make_pair( aSheet, connection ) );
343 }
344
345 connection->SetGraph( aGraph );
346 connection->SetSheet( aSheet );
347 return connection;
348}
349
350
352 CONNECTION_GRAPH* aGraph )
353{
354 if( !IsConnectable() )
355 return nullptr;
356
357 SCH_CONNECTION* connection = Connection( &aSheet );
358
359 if( connection )
360 return connection;
361 else
362 return InitializeConnection( aSheet, aGraph );
363}
364
365
366const wxString& SCH_ITEM::GetCachedDriverName() const
367{
368 static wxString s_empty;
369 return s_empty;
370}
371
372
374{
376}
377
378
380{
381 if( aImage == nullptr )
382 return;
383
384 EDA_ITEM* parent = GetParent();
386
387 SetParentGroup( nullptr );
388 aImage->SetParentGroup( nullptr );
389 swapData( aImage );
390
391 // Restore pointers to be sure they are not broken
392 SetParent( parent );
394}
395
396
398{
399 EDA_ITEM_FLAGS editFlags = GetEditFlags();
400 EDA_ITEM_FLAGS tempFlags = GetTempFlags();
401 EDA_ITEM_FLAGS aItem_editFlags = aItem->GetEditFlags();
402 EDA_ITEM_FLAGS aItem_tempFlags = aItem->GetTempFlags();
403
404 std::swap( m_flags, aItem->m_flags );
405
407 SetFlags( editFlags );
409 SetFlags( tempFlags );
410
411 aItem->ClearEditFlags();
412 aItem->SetFlags( aItem_editFlags );
413 aItem->ClearTempFlags();
414 aItem->SetFlags( aItem_tempFlags );
415}
416
417
419{
420 auto clearTextCaches =
421 []( SCH_ITEM* aItem )
422 {
423 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
424
425 if( text )
426 {
427 text->ClearBoundingBoxCache();
428 text->ClearRenderCache();
429 }
430 };
431
432 clearTextCaches( this );
433
434 RunOnChildren( clearTextCaches, RECURSE_MODE::NO_RECURSE );
435}
436
437
438bool SCH_ITEM::operator==( const SCH_ITEM& aOther ) const
439{
440 if( Type() != aOther.Type() )
441 return false;
442
443 return compare( aOther, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) == 0;
444}
445
446
447bool SCH_ITEM::operator<( const SCH_ITEM& aOther ) const
448{
449 if( Type() != aOther.Type() )
450 return Type() < aOther.Type();
451
452 return ( compare( aOther ) < 0 );
453}
454
455
456bool SCH_ITEM::cmp_items::operator()( const SCH_ITEM* aFirst, const SCH_ITEM* aSecond ) const
457{
458 return aFirst->compare( *aSecond, COMPARE_FLAGS::EQUALITY ) < 0;
459}
460
461
462int SCH_ITEM::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
463{
464 if( Type() != aOther.Type() )
465 return Type() - aOther.Type();
466
467 if( !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::UNIT ) && m_unit != aOther.m_unit )
468 return m_unit - aOther.m_unit;
469
470 if( !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::UNIT ) && m_bodyStyle != aOther.m_bodyStyle )
471 return m_bodyStyle - aOther.m_bodyStyle;
472
473 if( IsPrivate() != aOther.IsPrivate() )
474 return IsPrivate() ? 1 : -1;
475
476 if( !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::SKIP_TST_POS ) )
477 {
478 if( GetPosition().x != aOther.GetPosition().x )
479 return GetPosition().x - aOther.GetPosition().x;
480
481 if( GetPosition().y != aOther.GetPosition().y )
482 return GetPosition().y - aOther.GetPosition().y;
483 }
484
485 if( ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY )
486 || ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) )
487 {
488 return 0;
489 }
490
491 if( m_Uuid < aOther.m_Uuid )
492 return -1;
493
494 if( m_Uuid > aOther.m_Uuid )
495 return 1;
496
497 return 0;
498}
499
500
501const wxString& SCH_ITEM::GetDefaultFont() const
502{
504 EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" );
505
506 return cfg->m_Appearance.default_font;
507}
508
509
511{
512 if( SCHEMATIC* schematic = Schematic() )
513 return schematic->Settings().m_FontMetrics;
514
516}
517
518
520{
521 // For historical reasons, a stored value of 0 means "default width" and negative
522 // numbers meant "don't stroke".
523
524 if( GetPenWidth() < 0 )
525 {
526 return 0;
527 }
528 else if( GetPenWidth() == 0 )
529 {
530 if( GetParent() && GetParent()->Type() == LIB_SYMBOL_T )
531 return std::max( aSettings->m_SymbolLineWidth, aSettings->GetMinPenWidth() );
532 else
533 return std::max( aSettings->GetDefaultPenWidth(), aSettings->GetMinPenWidth() );
534 }
535 else
536 {
537 return std::max( GetPenWidth(), aSettings->GetMinPenWidth() );
538 }
539}
540
541
542bool SCH_ITEM::RenderAsBitmap( double aWorldScale ) const
543{
544 if( IsHypertext() )
545 return false;
546
547 if( const EDA_TEXT* text = dynamic_cast<const EDA_TEXT*>( this ) )
548 return text->GetTextHeight() * aWorldScale < BITMAP_FONT_SIZE_THRESHOLD;
549
550 return false;
551}
552
553
555 std::vector<MSG_PANEL_ITEM>& aList )
556{
557 wxString msg;
558
559 aList.emplace_back( _( "Type" ), GetFriendlyName() );
560
561 if( const SYMBOL* parent = GetParentSymbol() )
562 {
563 if( parent->GetUnitCount() )
564 aList.emplace_back( _( "Unit" ), GetUnitDescription( m_unit ) );
565
566 if( parent->HasAlternateBodyStyle() )
567 aList.emplace_back( _( "Body Style" ), GetBodyStyleDescription( m_bodyStyle ) );
568 }
569
570 if( IsPrivate() )
571 aList.emplace_back( _( "Private" ), wxEmptyString );
572}
573
574
575static struct SCH_ITEM_DESC
576{
578 {
582
583#ifdef NOTYET
584 // Not yet functional in UI
585 propMgr.AddProperty( new PROPERTY<SCH_ITEM, bool>( _HKI( "Locked" ),
587#endif
588
589 auto multiUnit =
590 [=]( INSPECTABLE* aItem ) -> bool
591 {
592 if( SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( aItem ) )
593 {
594 if( const SYMBOL* symbol = schItem->GetParentSymbol() )
595 return symbol->IsMulti();
596 }
597
598 return false;
599 };
600
601 auto multiBodyStyle =
602 [=]( INSPECTABLE* aItem ) -> bool
603 {
604 if( SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( aItem ) )
605 {
606 if( const SYMBOL* symbol = schItem->GetParentSymbol() )
607 return symbol->HasAlternateBodyStyle();
608 }
609
610 return false;
611 };
612
613 propMgr.AddProperty( new PROPERTY<SCH_ITEM, int>( _HKI( "Unit" ),
615 .SetAvailableFunc( multiUnit )
617
618 propMgr.AddProperty( new PROPERTY<SCH_ITEM, int>( _HKI( "Body Style" ),
620 .SetAvailableFunc( multiBodyStyle )
622
623 propMgr.AddProperty( new PROPERTY<SCH_ITEM, bool>( _HKI( "Private" ),
626 }
628
630
631
632static bool lessYX( const DANGLING_END_ITEM& a, const DANGLING_END_ITEM& b )
633{
634 const auto aPos = a.GetPosition();
635 const auto bPos = b.GetPosition();
636 return aPos.y < bPos.y ? true : ( aPos.y > bPos.y ? false : aPos.x < bPos.x );
637};
638
639
640static bool lessType( const DANGLING_END_ITEM& a, const DANGLING_END_ITEM& b )
641{
642 return a.GetType() < b.GetType();
643};
644
645
646std::vector<DANGLING_END_ITEM>::iterator
647DANGLING_END_ITEM_HELPER::get_lower_pos( std::vector<DANGLING_END_ITEM>& aItemListByPos,
648 const VECTOR2I& aPos )
649{
650 DANGLING_END_ITEM needle = DANGLING_END_ITEM( PIN_END, nullptr, aPos );
651 auto start = aItemListByPos.begin();
652 auto end = aItemListByPos.end();
653 return std::lower_bound( start, end, needle, lessYX );
654}
655
656
657std::vector<DANGLING_END_ITEM>::iterator
658DANGLING_END_ITEM_HELPER::get_lower_type( std::vector<DANGLING_END_ITEM>& aItemListByType,
659 const DANGLING_END_T& aType )
660{
661 DANGLING_END_ITEM needle = DANGLING_END_ITEM( aType, nullptr, VECTOR2I{} );
662 auto start = aItemListByType.begin();
663 auto end = aItemListByType.end();
664 return std::lower_bound( start, end, needle, lessType );
665}
666
667
669 std::vector<DANGLING_END_ITEM>& aItemListByType,
670 std::vector<DANGLING_END_ITEM>& aItemListByPos )
671{
672 // WIRE_END pairs must be kept together. Hence stable sort.
673 std::stable_sort( aItemListByType.begin(), aItemListByType.end(), lessType );
674
675 // Sort by y first, pins are more likely to share x than y.
676 std::sort( aItemListByPos.begin(), aItemListByPos.end(), lessYX );
677}
Calculate the connectivity of a schematic and generates netlists.
void RemoveItem(SCH_ITEM *aItem)
static std::vector< DANGLING_END_ITEM >::iterator get_lower_type(std::vector< DANGLING_END_ITEM > &aItemListByType, const DANGLING_END_T &aType)
Definition: sch_item.cpp:658
static std::vector< DANGLING_END_ITEM >::iterator get_lower_pos(std::vector< DANGLING_END_ITEM > &aItemListByPos, const VECTOR2I &aPos)
Definition: sch_item.cpp:647
static void sort_dangling_end_items(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos)
Both contain the same information.
Definition: sch_item.cpp:668
Helper class used to store the state of schematic items that can be connected to other schematic item...
Definition: sch_item.h:96
DANGLING_END_T GetType() const
Definition: sch_item.h:132
The base class for create windows for drawing purpose.
A set of EDA_ITEMs (i.e., without duplicates).
Definition: eda_group.h:46
virtual bool AddItem(EDA_ITEM *aItem)=0
Add item to group.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:96
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:256
virtual void ClearEditFlags()
Definition: eda_item.h:152
virtual void SetLocked(bool aLocked)
Definition: eda_item.h:117
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:144
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:138
const KIID m_Uuid
Definition: eda_item.h:502
virtual EDA_GROUP * GetParentGroup() const
Definition: eda_item.h:114
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:108
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:140
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:513
EDA_ITEM_FLAGS GetTempFlags() const
Definition: eda_item.h:157
virtual void SetParentGroup(EDA_GROUP *aGroup)
Definition: eda_item.h:113
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:111
virtual wxString GetFriendlyName() const
Definition: eda_item.cpp:374
EDA_ITEM * GetParent() const
Definition: eda_item.h:110
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:92
virtual bool IsLocked() const
Definition: eda_item.h:116
virtual void ClearTempFlags()
Definition: eda_item.h:165
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:79
Class that other classes need to inherit from, in order to be inspectable.
Definition: inspectable.h:37
static const METRICS & Default()
Definition: font.cpp:52
int GetDefaultPenWidth() const
Definition: kiid.h:49
Define a library symbol object.
Definition: lib_symbol.h:85
static wxString LetterSubReference(int aUnit, int aFirstId)
Definition: lib_symbol.cpp:518
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:125
std::shared_ptr< NET_SETTINGS > m_NetSettings
Net settings for this project (owned here)
Definition: project_file.h:195
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:203
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
Definition: property.h:258
PROPERTY_BASE & SetIsHiddenFromDesignEditors(bool aIsHidden=true)
Definition: property.h:322
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.
Holds all the data relating to one schematic.
Definition: schematic.h:69
PROJECT & Prj() const
Return a reference to the project this schematic is part of.
Definition: schematic.h:84
CONNECTION_GRAPH * ConnectionGraph() const
Definition: schematic.h:158
static bool m_IsSchematicExists
True if a SCHEMATIC exists, false if not.
Definition: schematic.h:352
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:148
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
void Reset()
Clears connectivity information.
wxString Name(bool aIgnoreSheet=false) const
void SetGraph(CONNECTION_GRAPH *aGraph)
void SetSheet(SCH_SHEET_PATH aSheet)
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:167
virtual void SetBodyStyle(int aBodyStyle)
Definition: sch_item.h:239
virtual bool IsConnectable() const
Definition: sch_item.h:475
int m_unit
Definition: sch_item.h:720
virtual int GetPenWidth() const
Definition: sch_item.h:301
const SCH_ITEM_VEC & ConnectedItems(const SCH_SHEET_PATH &aPath)
Retrieve the set of items connected to this item on the given sheet.
Definition: sch_item.cpp:305
SCH_ITEM & operator=(const SCH_ITEM &aPin)
Definition: sch_item.cpp:102
void ClearConnectedItems(const SCH_SHEET_PATH &aPath)
Clear all connections to this item.
Definition: sch_item.cpp:296
virtual bool doIsConnected(const VECTOR2I &aPosition) const
Provide the object specific test to see if it is connected to aPosition.
Definition: sch_item.h:716
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode)
Definition: sch_item.h:579
int m_bodyStyle
Definition: sch_item.h:721
const wxString & GetDefaultFont() const
Definition: sch_item.cpp:501
virtual ~SCH_ITEM()
Definition: sch_item.cpp:115
const SYMBOL * GetParentSymbol() const
Definition: sch_item.cpp:193
void SetPrivate(bool aPrivate)
Definition: sch_item.h:243
virtual void swapData(SCH_ITEM *aItem)
Swap the internal data structures aItem with the schematic item.
Definition: sch_item.cpp:373
virtual const wxString & GetCachedDriverName() const
Definition: sch_item.cpp:366
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:177
int GetBodyStyle() const
Definition: sch_item.h:240
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:229
static wxString GetUnitDescription(int aUnit)
Definition: sch_item.cpp:53
SCH_CONNECTION * InitializeConnection(const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
Create a new connection object associated with this object.
Definition: sch_item.cpp:327
void AddConnectionTo(const SCH_SHEET_PATH &aPath, SCH_ITEM *aItem)
Add a connection link between this item and another.
Definition: sch_item.cpp:311
@ SKIP_TST_POS
Definition: sch_item.h:649
@ EQUALITY
Definition: sch_item.h:647
int GetUnit() const
Definition: sch_item.h:236
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
Definition: sch_item.cpp:274
void SetUnitProp(int aUnit)
Definition: sch_item.cpp:155
virtual bool operator==(const SCH_ITEM &aOther) const
Definition: sch_item.cpp:438
bool m_connectivity_dirty
Definition: sch_item.h:733
bool IsPrivate() const
Definition: sch_item.h:244
virtual void ClearCaches()
Definition: sch_item.cpp:418
virtual int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const
Provide the draw object specific comparison called by the == and < operators.
Definition: sch_item.cpp:462
bool RenderAsBitmap(double aWorldScale) const override
Definition: sch_item.cpp:542
static wxString GetBodyStyleDescription(int aBodyStyle)
Definition: sch_item.cpp:62
void SetConnectionGraph(CONNECTION_GRAPH *aGraph)
Update the connection graph for all connections in this item.
Definition: sch_item.cpp:262
AUTOPLACE_ALGO m_fieldsAutoplaced
Definition: sch_item.h:723
void SwapFlags(SCH_ITEM *aItem)
Swap the non-temp and non-edit flags.
Definition: sch_item.cpp:397
bool IsConnected(const VECTOR2I &aPoint) const
Test the item to see if it is connected to aPoint.
Definition: sch_item.cpp:236
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition: sch_item.cpp:78
std::unordered_map< SCH_SHEET_PATH, SCH_CONNECTION * > m_connection_map
Store connectivity information, per sheet.
Definition: sch_item.h:731
virtual bool operator<(const SCH_ITEM &aItem) const
Definition: sch_item.cpp:447
bool m_private
Definition: sch_item.h:722
virtual bool IsHypertext() const
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_item.h:283
SCH_CONNECTION * GetOrInitConnection(const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
Definition: sch_item.cpp:351
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:245
wxString GetClass() const override
Return the class name.
Definition: sch_item.h:177
const KIFONT::METRICS & GetFontMetrics() const
Definition: sch_item.cpp:510
std::map< SCH_SHEET_PATH, SCH_ITEM_VEC, SHEET_PATH_CMP > m_connected_items
Store pointers to other items that are connected to this one, per sheet.
Definition: sch_item.h:728
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
Definition: sch_item.cpp:519
void SetBodyStyleProp(int aBodyStyle)
Definition: sch_item.cpp:166
void SwapItemData(SCH_ITEM *aImage)
Swap data between aItem and aImage.
Definition: sch_item.cpp:379
SCH_LAYER_ID m_layer
Definition: sch_item.h:719
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:132
void getSymbolEditorMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Definition: sch_item.cpp:554
int m_SymbolLineWidth
Override line widths for symbol drawing objects set to default line width.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Schematic symbol object.
Definition: sch_symbol.h:75
T * GetAppSettings(const char *aFilename)
Return a handle to the a given settings by type.
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition: symbol.h:63
#define _HKI(x)
#define _(s)
#define BRIGHTENED
item is drawn with a bright contour
#define SELECTED
Item was manually selected by the user.
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
std::uint32_t EDA_ITEM_FLAGS
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:438
@ LAYER_DEVICE
Definition: layer_ids.h:455
@ LAYER_WIRE
Definition: layer_ids.h:441
@ LAYER_DEVICE_BACKGROUND
Definition: layer_ids.h:473
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:483
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:96
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:1071
see class PGM_BASE
#define TYPE_HASH(x)
Definition: property.h:72
#define IMPLEMENT_ENUM_TO_WXANY(type)
Definition: property.h:781
#define REGISTER_TYPE(x)
Definition: property_mgr.h:371
Class to handle a set of SCH_ITEMs.
static bool lessYX(const DANGLING_END_ITEM &a, const DANGLING_END_ITEM &b)
Definition: sch_item.cpp:632
#define BITMAP_FONT_SIZE_THRESHOLD
Definition: sch_item.cpp:50
static bool lessType(const DANGLING_END_ITEM &a, const DANGLING_END_ITEM &b)
Definition: sch_item.cpp:640
static struct SCH_ITEM_DESC _SCH_ITEM_DESC
@ AUTOPLACE_NONE
Definition: sch_item.h:69
DANGLING_END_T
Definition: sch_item.h:77
@ PIN_END
Definition: sch_item.h:82
std::vector< SCH_ITEM * > SCH_ITEM_VEC
Definition: sch_item.h:156
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
bool operator()(const SCH_ITEM *aFirst, const SCH_ITEM *aSecond) const
Definition: sch_item.cpp:456
VECTOR2I end
wxLogTrace helper definitions.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ LIB_SYMBOL_T
Definition: typeinfo.h:148
@ SCH_SYMBOL_T
Definition: typeinfo.h:172
@ SCHEMATIC_T
Definition: typeinfo.h:204