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_rule_area.h>
32#include <sch_draw_panel.h>
33#include <sch_edit_frame.h>
34#include <connection_graph.h>
35#include <netclass.h>
39
40
41// Rendering fonts is expensive (particularly when using outline fonts). At small effective
42// sizes (ie: zoomed out) the visual differences between outline and/or stroke fonts and the
43// bitmap font becomes immaterial, and there's often more to draw when zoomed out so the
44// performance gain becomes more significant.
45#define BITMAP_FONT_SIZE_THRESHOLD 3
46
47
48/* Constructor and destructor for SCH_ITEM */
49/* They are not inline because this creates problems with gcc at linking time in debug mode */
50
51SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType, int aUnit, int aBodyStyle ) :
52 EDA_ITEM( aParent, aType, true, false ),
53 m_unit( aUnit ),
54 m_bodyStyle( aBodyStyle ),
55 m_private( false )
56{
57 m_layer = LAYER_WIRE; // It's only a default, in fact
59 m_connectivity_dirty = false; // Item is unconnected until it is placed, so it's clean
60}
61
62
64 EDA_ITEM( aItem )
65{
66 m_layer = aItem.m_layer;
67 m_unit = aItem.m_unit;
69 m_private = aItem.m_private;
72}
73
74
76{
77 m_layer = aItem.m_layer;
78 m_unit = aItem.m_unit;
80 m_private = aItem.m_private;
83
84 return *this;
85}
86
87
89{
90 for( const auto& it : m_connection_map )
91 delete it.second;
92
93 // Do not try to modify SCHEMATIC::ConnectionGraph()
94 // if the schematic does not exist
96 return;
97
98 SCHEMATIC* sch = Schematic();
99
100 if( sch != nullptr )
101 sch->ConnectionGraph()->RemoveItem( this );
102}
103
104
106{
107 switch( Type() )
108 {
109 case SCH_SYMBOL_T:
110 case SCH_PIN_T:
111 case SCH_SHAPE_T:
112 case SCH_BITMAP_T:
113 case SCH_FIELD_T:
114 case SCH_TEXT_T:
115 case SCH_TEXTBOX_T:
116 case SCH_TABLE_T:
117 case SCH_GROUP_T:
118 case SCH_LINE_T:
119 case SCH_JUNCTION_T:
120 case SCH_NO_CONNECT_T:
123 case SCH_LABEL_T:
125 case SCH_HIER_LABEL_T:
126 case SCH_RULE_AREA_T:
128 case SCH_SHEET_PIN_T:
129 case SCH_SHEET_T:
130 return true;
131 default:
132 return false;
133 }
134}
135
136
137SCH_ITEM* SCH_ITEM::Duplicate( bool addToParentGroup, SCH_COMMIT* aCommit, bool doClone ) const
138{
139 SCH_ITEM* newItem = (SCH_ITEM*) Clone();
140
141 if( !doClone )
142 const_cast<KIID&>( newItem->m_Uuid ) = KIID();
143
144 newItem->ClearFlags( SELECTED | BRIGHTENED );
145
146 newItem->RunOnChildren(
147 []( SCH_ITEM* aChild )
148 {
149 aChild->ClearFlags( SELECTED | BRIGHTENED );
150 },
151 RECURSE_MODE::NO_RECURSE );
152
153 if( addToParentGroup )
154 {
155 wxCHECK_MSG( aCommit, newItem, "Must supply a commit to update parent group" );
156
157 if( EDA_GROUP* group = newItem->GetParentGroup() )
158 {
159 aCommit->Modify( group->AsEdaItem(), nullptr, RECURSE_MODE::NO_RECURSE );
160 group->AddItem( newItem );
161 }
162 }
163
164 return newItem;
165}
166
167
168void SCH_ITEM::SetUnitProp( const wxString& aUnit )
169{
170 if( aUnit == _HKI( "All units" ) )
171 {
172 m_unit = 0;
173 return;
174 }
175
176 if( SYMBOL* symbol = GetParentSymbol() )
177 {
178 for( int unit = 1; unit <= symbol->GetUnitCount(); unit++ )
179 {
180 if( symbol->GetUnitDisplayName( unit, false ) == aUnit )
181 {
182 m_unit = unit;
183 return;
184 }
185 }
186 }
187}
188
189
190wxString SCH_ITEM::GetUnitDisplayName( int aUnit, bool aLabel ) const
191{
192 if( aUnit == 0 )
193 return aLabel ? _( "All units" ) : wxString( _HKI( "All units" ) );
194 else if( const SYMBOL* symbol = GetParentSymbol() )
195 return symbol->GetUnitDisplayName( aUnit, aLabel );
196
197 return wxEmptyString;
198}
199
200
201wxString SCH_ITEM::GetBodyStyleDescription( int aBodyStyle, bool aLabel ) const
202{
203 if( aBodyStyle == 0 )
204 return aLabel ? _( "All body styles" ) : wxString( _HKI( "All body styles" ) );
205 else if( const SYMBOL* symbol = GetParentSymbol() )
206 return symbol->GetBodyStyleDescription( aBodyStyle, aLabel );
207
208 return wxEmptyString;
209}
210
211
212wxString SCH_ITEM::GetUnitProp() const
213{
214 return GetUnitDisplayName( m_unit, false );
215}
216
217
218void SCH_ITEM::SetBodyStyleProp( const wxString& aBodyStyle )
219{
220 if( aBodyStyle == _HKI( "All body styles" ) )
221 {
222 m_bodyStyle = 0;
223 return;
224 }
225
226 if( SYMBOL* symbol = GetParentSymbol() )
227 {
228 for( int bodyStyle : { BODY_STYLE::BASE, BODY_STYLE::DEMORGAN } )
229 {
230 if( symbol->GetBodyStyleDescription( bodyStyle, false ) == aBodyStyle )
231 {
232 m_bodyStyle = bodyStyle;
233 return;
234 }
235 }
236 }
237}
238
239
241{
242 return GetBodyStyleDescription( m_bodyStyle, false );
243}
244
245
247{
248 return static_cast<SCHEMATIC*>( findParent( SCHEMATIC_T ) );
249}
250
251
253{
254 if( SYMBOL* sch_symbol = static_cast<SCH_SYMBOL*>( findParent( SCH_SYMBOL_T ) ) )
255 return sch_symbol;
256
257 if( SYMBOL* lib_symbol = static_cast<LIB_SYMBOL*>( findParent( LIB_SYMBOL_T ) ) )
258 return lib_symbol;
259
260 return nullptr;
261}
262
263
265{
266 if( SYMBOL* sch_symbol = static_cast<SCH_SYMBOL*>( findParent( SCH_SYMBOL_T ) ) )
267 return sch_symbol;
268
269 if( SYMBOL* lib_symbol = static_cast<LIB_SYMBOL*>( findParent( LIB_SYMBOL_T ) ) )
270 return lib_symbol;
271
272 return nullptr;
273}
274
275
277{
278 if( GetExcludedFromSim() )
279 return true;
280
281 for( SCH_RULE_AREA* area : m_rule_areas_cache )
282 {
283 if( area->GetExcludedFromSim() )
284 return true;
285 }
286
287 return false;
288}
289
290
292{
293 if( GetExcludedFromBOM() )
294 return true;
295
296 for( SCH_RULE_AREA* area : m_rule_areas_cache )
297 {
298 if( area->GetExcludedFromBOM() )
299 return true;
300 }
301
302 return false;
303}
304
305
307{
309 return true;
310
311 for( SCH_RULE_AREA* area : m_rule_areas_cache )
312 {
313 if( area->GetExcludedFromBoard() )
314 return true;
315 }
316
317 return false;
318}
319
320
322{
323 if( GetDNP() )
324 return true;
325
326 for( SCH_RULE_AREA* area : m_rule_areas_cache )
327 {
328 if( area->GetDNP() )
329 return true;
330 }
331
332 return false;
333}
334
335
336std::vector<int> SCH_ITEM::ViewGetLayers() const
337{
338 // Basic fallback
340}
341
342
343bool SCH_ITEM::IsConnected( const VECTOR2I& aPosition ) const
344{
345 if(( m_flags & STRUCT_DELETED ) || ( m_flags & SKIP_STRUCT ) )
346 return false;
347
348 return doIsConnected( aPosition );
349}
350
351
353{
354 if( !IsConnectable() )
355 return nullptr;
356
357 if( !aSheet )
358 aSheet = &Schematic()->CurrentSheet();
359
360 auto it = m_connection_map.find( *aSheet );
361
362 if( it == m_connection_map.end() )
363 return nullptr;
364 else
365 return it->second;
366}
367
368
370{
371 for( auto& [path, conn] : m_connection_map )
372 {
373 conn->SetGraph( aGraph );
374
375 for( auto& member : conn->AllMembers() )
376 member->SetGraph( aGraph );
377 }
378}
379
380
381std::shared_ptr<NETCLASS> SCH_ITEM::GetEffectiveNetClass( const SCH_SHEET_PATH* aSheet ) const
382{
383 static std::shared_ptr<NETCLASS> nullNetclass = std::make_shared<NETCLASS>( wxEmptyString );
384
385 SCHEMATIC* schematic = Schematic();
386
387 if( schematic )
388 {
389 std::shared_ptr<NET_SETTINGS>& netSettings = schematic->Project().GetProjectFile().m_NetSettings;
390 SCH_CONNECTION* connection = Connection( aSheet );
391
392 if( connection )
393 return netSettings->GetEffectiveNetClass( connection->Name() );
394 else
395 return netSettings->GetDefaultNetclass();
396 }
397
398 return nullNetclass;
399}
400
401
403{
404 auto it = m_connected_items.find( aSheet );
405
406 if( it != m_connected_items.end() )
407 it->second.clear();
408}
409
410
412{
413 return m_connected_items[ aSheet ];
414}
415
416
418{
419 SCH_ITEM_VEC& vec = m_connected_items[ aSheet ];
420
421 // The vector elements are small, so reserve 1k at a time to prevent re-allocations
422 if( vec.size() == vec.capacity() )
423 vec.reserve( vec.size() + 4096 );
424
425 // Add item to the correct place in the sorted vector if it is not already there
426 auto it = std::lower_bound( vec.begin(), vec.end(), aItem );
427
428 if( it == vec.end() || *it != aItem )
429 vec.insert( it, aItem );
430}
431
432
434 CONNECTION_GRAPH* aGraph )
435{
436 SCH_CONNECTION* connection = Connection( &aSheet );
437
438 // N.B. Do not clear the dirty connectivity flag here because we may need
439 // to create a connection for a different sheet, and we don't want to
440 // skip the connection creation because the flag is cleared.
441 if( connection )
442 {
443 connection->Reset();
444 }
445 else
446 {
447 connection = new SCH_CONNECTION( this );
448 m_connection_map.insert( std::make_pair( aSheet, connection ) );
449 }
450
451 connection->SetGraph( aGraph );
452 connection->SetSheet( aSheet );
453 return connection;
454}
455
456
458 CONNECTION_GRAPH* aGraph )
459{
460 if( !IsConnectable() )
461 return nullptr;
462
463 SCH_CONNECTION* connection = Connection( &aSheet );
464
465 if( connection )
466 return connection;
467 else
468 return InitializeConnection( aSheet, aGraph );
469}
470
471
472const wxString& SCH_ITEM::GetCachedDriverName() const
473{
474 static wxString s_empty;
475 return s_empty;
476}
477
478
480{
482}
483
484
486{
487 if( aImage == nullptr )
488 return;
489
490 EDA_ITEM* parent = GetParent();
491
492 SwapFlags( aImage );
493 std::swap( m_group, aImage->m_group );
494 swapData( aImage );
495
496 SetParent( parent );
497}
498
499
501{
502 EDA_ITEM_FLAGS editFlags = GetEditFlags();
503 EDA_ITEM_FLAGS tempFlags = GetTempFlags();
504 EDA_ITEM_FLAGS aItem_editFlags = aItem->GetEditFlags();
505 EDA_ITEM_FLAGS aItem_tempFlags = aItem->GetTempFlags();
506
507 std::swap( m_flags, aItem->m_flags );
508
510 SetFlags( editFlags );
512 SetFlags( tempFlags );
513
514 aItem->ClearEditFlags();
515 aItem->SetFlags( aItem_editFlags );
516 aItem->ClearTempFlags();
517 aItem->SetFlags( aItem_tempFlags );
518}
519
520
522{
523 auto clearTextCaches =
524 []( SCH_ITEM* aItem )
525 {
526 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
527
528 if( text )
529 {
530 text->ClearBoundingBoxCache();
531 text->ClearRenderCache();
532 }
533 };
534
535 clearTextCaches( this );
536
537 RunOnChildren( clearTextCaches, RECURSE_MODE::NO_RECURSE );
538}
539
540
541bool SCH_ITEM::operator==( const SCH_ITEM& aOther ) const
542{
543 if( Type() != aOther.Type() )
544 return false;
545
546 return compare( aOther, SCH_ITEM::COMPARE_FLAGS::EQUALITY ) == 0;
547}
548
549
550bool SCH_ITEM::operator<( const SCH_ITEM& aOther ) const
551{
552 if( Type() != aOther.Type() )
553 return Type() < aOther.Type();
554
555 return ( compare( aOther ) < 0 );
556}
557
558
559bool SCH_ITEM::cmp_items::operator()( const SCH_ITEM* aFirst, const SCH_ITEM* aSecond ) const
560{
561 return aFirst->compare( *aSecond, COMPARE_FLAGS::EQUALITY ) < 0;
562}
563
564
565int SCH_ITEM::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
566{
567 if( Type() != aOther.Type() )
568 return Type() - aOther.Type();
569
570 if( !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::UNIT ) && m_unit != aOther.m_unit )
571 return m_unit - aOther.m_unit;
572
573 if( !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::UNIT ) && m_bodyStyle != aOther.m_bodyStyle )
574 return m_bodyStyle - aOther.m_bodyStyle;
575
576 if( IsPrivate() != aOther.IsPrivate() )
577 return IsPrivate() ? 1 : -1;
578
579 if( !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::SKIP_TST_POS ) )
580 {
581 if( GetPosition().x != aOther.GetPosition().x )
582 return GetPosition().x - aOther.GetPosition().x;
583
584 if( GetPosition().y != aOther.GetPosition().y )
585 return GetPosition().y - aOther.GetPosition().y;
586 }
587
588 if( ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY )
589 || ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) )
590 {
591 return 0;
592 }
593
594 if( m_Uuid < aOther.m_Uuid )
595 return -1;
596
597 if( m_Uuid > aOther.m_Uuid )
598 return 1;
599
600 return 0;
601}
602
603
604const wxString& SCH_ITEM::GetDefaultFont( const RENDER_SETTINGS* aSettings ) const
605{
606 static wxString defaultName = KICAD_FONT_NAME;
607
608 if( aSettings )
609 return aSettings->GetDefaultFont();
610 else if( EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) )
611 return cfg->m_Appearance.default_font;
612 else
613 return defaultName;
614}
615
616
618{
619 if( SCHEMATIC* schematic = Schematic() )
620 return schematic->Settings().m_FontMetrics;
621
623}
624
625
627{
628 // For historical reasons, a stored value of 0 means "default width" and negative
629 // numbers meant "don't stroke".
630
631 if( GetPenWidth() < 0 )
632 {
633 return 0;
634 }
635 else if( GetPenWidth() == 0 )
636 {
637 if( GetParent() && GetParent()->Type() == LIB_SYMBOL_T )
638 return std::max( aSettings->m_SymbolLineWidth, aSettings->GetMinPenWidth() );
639 else
640 return std::max( aSettings->GetDefaultPenWidth(), aSettings->GetMinPenWidth() );
641 }
642 else
643 {
644 return std::max( GetPenWidth(), aSettings->GetMinPenWidth() );
645 }
646}
647
648
649bool SCH_ITEM::RenderAsBitmap( double aWorldScale ) const
650{
651 if( IsHypertext() )
652 return false;
653
654 if( const EDA_TEXT* text = dynamic_cast<const EDA_TEXT*>( this ) )
655 return text->GetTextHeight() * aWorldScale < BITMAP_FONT_SIZE_THRESHOLD;
656
657 return false;
658}
659
660
661void SCH_ITEM::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
662{
663 wxString msg;
664
665 if( SYMBOL* symbol = GetParentSymbol() )
666 {
667 if( symbol->GetUnitCount() )
668 aList.emplace_back( _( "Unit" ), GetUnitDisplayName( GetUnit(), false ) );
669
670 if( symbol->HasAlternateBodyStyle() )
671 aList.emplace_back( _( "Body Style" ), GetBodyStyleDescription( GetBodyStyle(), true ) );
672
673 if( dynamic_cast<LIB_SYMBOL*>( symbol ) && IsPrivate() )
674 aList.emplace_back( _( "Private" ), wxEmptyString );
675 }
676}
677
678
679const std::vector<wxString>* SCH_ITEM::GetEmbeddedFonts()
680{
681 if( SCHEMATIC* schematic = Schematic() )
682 return schematic->GetEmbeddedFiles()->GetFontFiles();
683 else if( SYMBOL* symbol = GetParentSymbol() )
684 return symbol->GetEmbeddedFiles()->UpdateFontFiles();
685
686 return nullptr;
687}
688
689
690static struct SCH_ITEM_DESC
691{
693 {
697
698#ifdef NOTYET
699 // Not yet functional in UI
700 propMgr.AddProperty( new PROPERTY<SCH_ITEM, bool>( _HKI( "Locked" ),
702#endif
703
704 auto multiUnit =
705 [=]( INSPECTABLE* aItem ) -> bool
706 {
707 if( SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( aItem ) )
708 {
709 if( const SYMBOL* symbol = schItem->GetParentSymbol() )
710 return symbol->IsMulti();
711 }
712
713 return false;
714 };
715
716 auto multiBodyStyle =
717 [=]( INSPECTABLE* aItem ) -> bool
718 {
719 if( SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( aItem ) )
720 {
721 if( const SYMBOL* symbol = schItem->GetParentSymbol() )
722 return symbol->HasAlternateBodyStyle();
723 }
724
725 return false;
726 };
727
728 propMgr.AddProperty( new PROPERTY<SCH_ITEM, wxString>( _HKI( "Unit" ),
730 .SetAvailableFunc( multiUnit )
732 .SetChoicesFunc( []( INSPECTABLE* aItem )
733 {
734 wxPGChoices choices;
735 choices.Add( _HKI( "All units" ) );
736
737 if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
738 {
739 if( SYMBOL* symbol = item->GetParentSymbol() )
740 {
741 for( int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
742 choices.Add( symbol->GetUnitDisplayName( ii, false ) );
743 }
744 }
745
746 return choices;
747 } );
748
749
750 propMgr.AddProperty( new PROPERTY<SCH_ITEM, wxString>( _HKI( "Body Style" ),
752 .SetAvailableFunc( multiBodyStyle )
754 .SetChoicesFunc( []( INSPECTABLE* aItem )
755 {
756 wxPGChoices choices;
757 choices.Add( _HKI( "All body styles" ) );
758
759 if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
760 {
761 if( SYMBOL* symbol = item->GetParentSymbol() )
762 {
763 for( int ii : { BODY_STYLE::BASE, BODY_STYLE::DEMORGAN } )
764 choices.Add( symbol->GetBodyStyleDescription( ii, false ) );
765 }
766 }
767
768 return choices;
769 } );
770
771 propMgr.AddProperty( new PROPERTY<SCH_ITEM, bool>( _HKI( "Private" ),
774 }
776
778
779
780static bool lessYX( const DANGLING_END_ITEM& a, const DANGLING_END_ITEM& b )
781{
782 const auto aPos = a.GetPosition();
783 const auto bPos = b.GetPosition();
784 return aPos.y < bPos.y ? true : ( aPos.y > bPos.y ? false : aPos.x < bPos.x );
785};
786
787
788static bool lessType( const DANGLING_END_ITEM& a, const DANGLING_END_ITEM& b )
789{
790 return a.GetType() < b.GetType();
791};
792
793
794std::vector<DANGLING_END_ITEM>::iterator
795DANGLING_END_ITEM_HELPER::get_lower_pos( std::vector<DANGLING_END_ITEM>& aItemListByPos,
796 const VECTOR2I& aPos )
797{
798 DANGLING_END_ITEM needle = DANGLING_END_ITEM( PIN_END, nullptr, aPos );
799 auto start = aItemListByPos.begin();
800 auto end = aItemListByPos.end();
801 return std::lower_bound( start, end, needle, lessYX );
802}
803
804
805std::vector<DANGLING_END_ITEM>::iterator
806DANGLING_END_ITEM_HELPER::get_lower_type( std::vector<DANGLING_END_ITEM>& aItemListByType,
807 const DANGLING_END_T& aType )
808{
809 DANGLING_END_ITEM needle = DANGLING_END_ITEM( aType, nullptr, VECTOR2I{} );
810 auto start = aItemListByType.begin();
811 auto end = aItemListByType.end();
812 return std::lower_bound( start, end, needle, lessType );
813}
814
815
817 std::vector<DANGLING_END_ITEM>& aItemListByType,
818 std::vector<DANGLING_END_ITEM>& aItemListByPos )
819{
820 // WIRE_END pairs must be kept together. Hence stable sort.
821 std::stable_sort( aItemListByType.begin(), aItemListByType.end(), lessType );
822
823 // Sort by y first, pins are more likely to share x than y.
824 std::sort( aItemListByPos.begin(), aItemListByPos.end(), lessYX );
825}
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition: commit.h:107
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:806
static std::vector< DANGLING_END_ITEM >::iterator get_lower_pos(std::vector< DANGLING_END_ITEM > &aItemListByPos, const VECTOR2I &aPos)
Definition: sch_item.cpp:795
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:816
Helper class used to store the state of schematic items that can be connected to other schematic item...
Definition: sch_item.h:97
DANGLING_END_T GetType() const
Definition: sch_item.h:133
The base class for create windows for drawing purpose.
A set of EDA_ITEMs (i.e., without duplicates).
Definition: eda_group.h:46
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:98
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:272
virtual void ClearEditFlags()
Definition: eda_item.h:156
virtual void SetLocked(bool aLocked)
Definition: eda_item.h:121
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:148
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:142
const KIID m_Uuid
Definition: eda_item.h:516
virtual EDA_GROUP * GetParentGroup() const
Definition: eda_item.h:116
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:110
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:144
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:527
EDA_ITEM_FLAGS GetTempFlags() const
Definition: eda_item.h:161
EDA_GROUP * m_group
The group this item belongs to, if any. No ownership implied.
Definition: eda_item.h:529
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:113
EDA_ITEM * GetParent() const
Definition: eda_item.h:112
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:118
virtual bool IsLocked() const
Definition: eda_item.h:120
virtual void ClearTempFlags()
Definition: eda_item.h:169
EDA_ITEM * findParent(KICAD_T aType) const
Definition: eda_item.cpp:75
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
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int GetDefaultPenWidth() const
const wxString & GetDefaultFont() const
Definition: kiid.h:49
Define a library symbol object.
Definition: lib_symbol.h:85
std::shared_ptr< NET_SETTINGS > m_NetSettings
Net settings for this project (owned here)
Definition: project_file.h:189
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:204
PROPERTY_BASE & SetChoicesFunc(std::function< wxPGChoices(INSPECTABLE *)> aFunc)
Definition: property.h:272
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:336
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:74
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:76
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
Holds all the data relating to one schematic.
Definition: schematic.h:88
PROJECT & Project() const
Return a reference to the project this schematic is part of.
Definition: schematic.h:103
CONNECTION_GRAPH * ConnectionGraph() const
Definition: schematic.h:183
static bool m_IsSchematicExists
True if a SCHEMATIC exists, false if not.
Definition: schematic.h:449
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:171
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(const SCH_SHEET_PATH &aSheet)
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:168
virtual bool GetExcludedFromSim() const
Definition: sch_item.h:257
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:661
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:137
virtual bool IsConnectable() const
Definition: sch_item.h:498
int m_unit
Definition: sch_item.h:745
virtual int GetPenWidth() const
Definition: sch_item.h:324
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:411
SCH_ITEM & operator=(const SCH_ITEM &aPin)
Definition: sch_item.cpp:75
void ClearConnectedItems(const SCH_SHEET_PATH &aPath)
Clear all connections to this item.
Definition: sch_item.cpp:402
virtual bool doIsConnected(const VECTOR2I &aPosition) const
Provide the object specific test to see if it is connected to aPosition.
Definition: sch_item.h:741
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode)
Definition: sch_item.h:602
virtual wxString GetUnitProp() const
Definition: sch_item.cpp:212
int m_bodyStyle
Definition: sch_item.h:746
const std::vector< wxString > * GetEmbeddedFonts() override
Definition: sch_item.cpp:679
virtual ~SCH_ITEM()
Definition: sch_item.cpp:88
const SYMBOL * GetParentSymbol() const
Definition: sch_item.cpp:252
virtual wxString GetBodyStyleDescription(int aBodyStyle, bool aLabel) const
Definition: sch_item.cpp:201
void SetPrivate(bool aPrivate)
Definition: sch_item.h:253
virtual void swapData(SCH_ITEM *aItem)
Swap the internal data structures aItem with the schematic item.
Definition: sch_item.cpp:479
virtual const wxString & GetCachedDriverName() const
Definition: sch_item.cpp:472
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:246
int GetBodyStyle() const
Definition: sch_item.h:248
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:336
bool ResolveExcludedFromBOM() const
Definition: sch_item.cpp:291
SCH_CONNECTION * InitializeConnection(const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
Create a new connection object associated with this object.
Definition: sch_item.cpp:433
virtual wxString GetUnitDisplayName(int aUnit, bool aLabel) const
Definition: sch_item.cpp:190
void AddConnectionTo(const SCH_SHEET_PATH &aPath, SCH_ITEM *aItem)
Add a connection link between this item and another.
Definition: sch_item.cpp:417
virtual void SetUnitProp(const wxString &aUnit)
Definition: sch_item.cpp:168
@ SKIP_TST_POS
Definition: sch_item.h:676
@ EQUALITY
Definition: sch_item.h:674
int GetUnit() const
Definition: sch_item.h:239
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
Definition: sch_item.cpp:381
bool ResolveExcludedFromBoard() const
Definition: sch_item.cpp:306
virtual bool GetDNP() const
Definition: sch_item.h:269
virtual bool operator==(const SCH_ITEM &aOther) const
Definition: sch_item.cpp:541
bool m_connectivity_dirty
Definition: sch_item.h:758
virtual bool GetExcludedFromBOM() const
Definition: sch_item.h:261
bool IsPrivate() const
Definition: sch_item.h:254
virtual void ClearCaches()
Definition: sch_item.cpp:521
virtual bool GetExcludedFromBoard() const
Definition: sch_item.h:265
virtual void SetBodyStyleProp(const wxString &aBodyStyle)
Definition: sch_item.cpp:218
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:565
virtual wxString GetBodyStyleProp() const
Definition: sch_item.cpp:240
bool RenderAsBitmap(double aWorldScale) const override
Definition: sch_item.cpp:649
const wxString & GetDefaultFont(const RENDER_SETTINGS *aSettings) const
Definition: sch_item.cpp:604
void SetConnectionGraph(CONNECTION_GRAPH *aGraph)
Update the connection graph for all connections in this item.
Definition: sch_item.cpp:369
AUTOPLACE_ALGO m_fieldsAutoplaced
Definition: sch_item.h:748
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:761
void SwapFlags(SCH_ITEM *aItem)
Swap the non-temp and non-edit flags.
Definition: sch_item.cpp:500
bool IsConnected(const VECTOR2I &aPoint) const
Test the item to see if it is connected to aPoint.
Definition: sch_item.cpp:343
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition: sch_item.cpp:51
std::unordered_map< SCH_SHEET_PATH, SCH_CONNECTION * > m_connection_map
Store connectivity information, per sheet.
Definition: sch_item.h:756
virtual bool operator<(const SCH_ITEM &aItem) const
Definition: sch_item.cpp:550
bool m_private
Definition: sch_item.h:747
virtual bool IsHypertext() const
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_item.h:306
SCH_CONNECTION * GetOrInitConnection(const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
Definition: sch_item.cpp:457
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:352
wxString GetClass() const override
Return the class name.
Definition: sch_item.h:178
bool ResolveExcludedFromSim() const
Definition: sch_item.cpp:276
const KIFONT::METRICS & GetFontMetrics() const
Definition: sch_item.cpp:617
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:753
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
Definition: sch_item.cpp:626
bool IsGroupableType() const
Definition: sch_item.cpp:105
void SwapItemData(SCH_ITEM *aImage)
Swap data between aItem and aImage.
Definition: sch_item.cpp:485
SCH_LAYER_ID m_layer
Definition: sch_item.h:744
bool ResolveDNP() const
Definition: sch_item.cpp:321
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
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
#define KICAD_FONT_NAME
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:439
@ LAYER_DEVICE
Definition: layer_ids.h:456
@ LAYER_WIRE
Definition: layer_ids.h:442
@ LAYER_DEVICE_BACKGROUND
Definition: layer_ids.h:474
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:484
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:96
see class PGM_BASE
#define TYPE_HASH(x)
Definition: property.h:72
#define IMPLEMENT_ENUM_TO_WXANY(type)
Definition: property.h:797
#define REGISTER_TYPE(x)
Definition: property_mgr.h:351
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:780
#define BITMAP_FONT_SIZE_THRESHOLD
Definition: sch_item.cpp:45
static bool lessType(const DANGLING_END_ITEM &a, const DANGLING_END_ITEM &b)
Definition: sch_item.cpp:788
static struct SCH_ITEM_DESC _SCH_ITEM_DESC
@ AUTOPLACE_NONE
Definition: sch_item.h:70
DANGLING_END_T
Definition: sch_item.h:78
@ PIN_END
Definition: sch_item.h:83
std::vector< SCH_ITEM * > SCH_ITEM_VEC
Definition: sch_item.h:157
bool operator()(const SCH_ITEM *aFirst, const SCH_ITEM *aSecond) const
Definition: sch_item.cpp:559
VECTOR2I end
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_GROUP_T
Definition: typeinfo.h:174
@ SCH_TABLE_T
Definition: typeinfo.h:166
@ SCH_LINE_T
Definition: typeinfo.h:164
@ LIB_SYMBOL_T
Definition: typeinfo.h:149
@ SCH_NO_CONNECT_T
Definition: typeinfo.h:161
@ SCH_SYMBOL_T
Definition: typeinfo.h:173
@ SCH_FIELD_T
Definition: typeinfo.h:151
@ SCH_DIRECTIVE_LABEL_T
Definition: typeinfo.h:172
@ SCH_LABEL_T
Definition: typeinfo.h:168
@ SCH_SHEET_T
Definition: typeinfo.h:176
@ SCH_SHAPE_T
Definition: typeinfo.h:150
@ SCH_RULE_AREA_T
Definition: typeinfo.h:171
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:170
@ SCH_BUS_BUS_ENTRY_T
Definition: typeinfo.h:163
@ SCHEMATIC_T
Definition: typeinfo.h:205
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:175
@ SCH_TEXT_T
Definition: typeinfo.h:152
@ SCH_BUS_WIRE_ENTRY_T
Definition: typeinfo.h:162
@ SCH_BITMAP_T
Definition: typeinfo.h:165
@ SCH_TEXTBOX_T
Definition: typeinfo.h:153
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:169
@ SCH_JUNCTION_T
Definition: typeinfo.h:160
@ SCH_PIN_T
Definition: typeinfo.h:154