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, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <sch_render_settings.h>
22#include <plotters/plotter.h>
23#include <pgm_base.h>
26#include <advanced_config.h>
27#include <wx/thread.h>
29#include <eeschema_settings.h>
30#include <eda_item.h>
31#include <sch_connection.h>
32#include <sch_screen.h>
33#include <sch_group.h>
34#include <sch_rule_area.h>
35#include <sch_draw_panel.h>
36#include <sch_edit_frame.h>
37#include <connection_graph.h>
38#include <netclass.h>
42#include <properties/property.h>
44
45
47{
48 return static_cast<SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
49}
50
51
52// Rendering fonts is expensive (particularly when using outline fonts). At small effective
53// sizes (ie: zoomed out) the visual differences between outline and/or stroke fonts and the
54// bitmap font becomes immaterial, and there's often more to draw when zoomed out so the
55// performance gain becomes more significant.
56#define BITMAP_FONT_SIZE_THRESHOLD 3
57
58
59static const std::vector<KICAD_T> labelTypes = { SCH_LABEL_LOCATE_ANY_T };
60
61
62/* Constructor and destructor for SCH_ITEM */
63/* They are not inline because this creates problems with gcc at linking time in debug mode */
64
65SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType, int aUnit, int aBodyStyle ) :
66 EDA_ITEM( aParent, aType, true, false ),
67 m_unit( aUnit ),
68 m_bodyStyle( aBodyStyle ),
69 m_private( false ),
70 m_isLocked( false )
71{
72 m_layer = LAYER_WIRE; // It's only a default, in fact
74 m_connectivity_dirty = false; // Item is unconnected until it is placed, so it's clean
75}
76
77
79 EDA_ITEM( aItem )
80{
81 m_layer = aItem.m_layer;
82 m_unit = aItem.m_unit;
84 m_private = aItem.m_private;
87 m_isLocked = aItem.m_isLocked;
88}
89
90
92{
93 if( SCH_SCREEN* screen = GetParentScreen() )
94 screen->BumpConnectivityRevision( Type() );
95
97 m_layer = aItem.m_layer;
98 m_unit = aItem.m_unit;
100 m_private = aItem.m_private;
103 m_isLocked = aItem.m_isLocked;
104
105 return *this;
106}
107
108
110{
111 for( const std::weak_ptr<CONNECTION_GRAPH_LIFETIME>& weakOwner : m_connectivityOwners )
112 {
113 if( const std::shared_ptr<CONNECTION_GRAPH_LIFETIME>& owner = weakOwner.lock() )
114 owner->graph->RemoveItem( this );
115 }
116
117 for( const auto& [path, connection] : m_connection_map )
118 delete connection;
119
120 // Remove this item from any rule areas that contain it
121 for( SCH_RULE_AREA* ruleArea : m_rule_areas_cache )
122 ruleArea->RemoveItem( this );
123}
124
125
126void SCH_ITEM::registerConnectivityOwner( const std::shared_ptr<CONNECTION_GRAPH_LIFETIME>& aOwner )
127{
128 std::erase_if( m_connectivityOwners,
129 []( const auto& owner )
130 {
131 return owner.expired();
132 } );
133
134 for( const std::weak_ptr<CONNECTION_GRAPH_LIFETIME>& owner : m_connectivityOwners )
135 {
136 if( owner.lock() == aOwner )
137 return;
138 }
139
140 m_connectivityOwners.emplace_back( aOwner );
141}
142
143
145{
146 switch( Type() )
147 {
148 case SCH_SYMBOL_T:
149 case SCH_PIN_T:
150 case SCH_SHAPE_T:
151 case SCH_BITMAP_T:
152 case SCH_FIELD_T:
153 case SCH_TEXT_T:
154 case SCH_TEXTBOX_T:
155 case SCH_TABLE_T:
156 case SCH_GROUP_T:
157 case SCH_LINE_T:
158 case SCH_JUNCTION_T:
159 case SCH_NO_CONNECT_T:
162 case SCH_LABEL_T:
164 case SCH_HIER_LABEL_T:
165 case SCH_RULE_AREA_T:
167 case SCH_SHEET_T:
168 return true;
169
170 // Don't group sheet pins directly, they go along with an SCH_SHEET, and all operations
171 // should be performed on that sheet.
172 case SCH_SHEET_PIN_T:
173 default:
174 return false;
175 }
176}
177
178
180{
182 {
183 if( group->AsEdaItem()->IsLocked() )
184 return true;
185 }
186
187 return m_isLocked;
188}
189
190
191SCH_ITEM* SCH_ITEM::Duplicate( bool addToParentGroup, SCH_COMMIT* aCommit, bool doClone ) const
192{
193 SCH_ITEM* newItem = (SCH_ITEM*) Clone();
194
195 if( !doClone )
196 const_cast<KIID&>( newItem->m_Uuid ) = KIID();
197
198 newItem->ClearFlags( SELECTED | BRIGHTENED );
199
200 newItem->RunOnChildren(
201 [renewIdentity = !doClone && Type() == SCH_SYMBOL_T]( SCH_ITEM* aChild )
202 {
203 if( renewIdentity )
204 const_cast<KIID&>( aChild->m_Uuid ) = KIID();
205
206 aChild->ClearFlags( SELECTED | BRIGHTENED );
207 },
209
210 if( addToParentGroup )
211 {
212 wxCHECK_MSG( aCommit, newItem, "Must supply a commit to update parent group" );
213
214 if( EDA_GROUP* group = newItem->GetParentGroup() )
215 {
216 aCommit->Modify( group->AsEdaItem(), nullptr, RECURSE_MODE::NO_RECURSE );
217 group->AddItem( newItem );
218 }
219 }
220
221 return newItem;
222}
223
224
225wxString SCH_ITEM::GetUnitDisplayName( int aUnit, bool aLabel ) const
226{
227 if( aUnit == 0 )
228 return aLabel ? _( "All units" ) : wxString( _HKI( "All units" ) );
229 else if( const SYMBOL* symbol = GetParentSymbol() )
230 return symbol->GetUnitDisplayName( aUnit, aLabel );
231
232 return wxEmptyString;
233}
234
235
236wxString SCH_ITEM::GetBodyStyleDescription( int aBodyStyle, bool aLabel ) const
237{
238 if( aBodyStyle == 0 )
239 return aLabel ? _( "All body styles" ) : wxString( _HKI( "All body styles" ) );
240 else if( const SYMBOL* symbol = GetParentSymbol() )
241 return symbol->GetBodyStyleDescription( aBodyStyle, aLabel );
242
243 return wxEmptyString;
244}
245
246
247void SCH_ITEM::SetUnitString( const wxString& aUnit )
248{
249 if( aUnit == _HKI( "All units" ) )
250 {
251 m_unit = 0;
252 return;
253 }
254
255 if( SYMBOL* symbol = GetParentSymbol() )
256 {
257 for( int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
258 {
259 if( symbol->GetUnitDisplayName( ii, false ) == aUnit )
260 {
261 m_unit = ii;
262 return;
263 }
264 }
265 }
266}
267
268
270{
271 return GetUnitDisplayName( m_unit, false );
272}
273
274void SCH_ITEM::SetBodyStyleProp( const wxString& aBodyStyle )
275{
276 if( aBodyStyle == _HKI( "All body styles" ) )
277 {
278 m_bodyStyle = 0;
279 return;
280 }
281
282 if( SYMBOL* symbol = GetParentSymbol() )
283 {
284 for( int bodyStyle : { BODY_STYLE::BASE, BODY_STYLE::DEMORGAN } )
285 {
286 if( symbol->GetBodyStyleDescription( bodyStyle, false ) == aBodyStyle )
287 {
288 m_bodyStyle = bodyStyle;
289 return;
290 }
291 }
292 }
293}
294
295
297{
298 return GetBodyStyleDescription( m_bodyStyle, false );
299}
300
301
303{
304 return static_cast<SCHEMATIC*>( findParent( SCHEMATIC_T ) );
305}
306
307
309{
310 return static_cast<SCH_SCREEN*>( findParent( SCH_SCREEN_T ) );
311}
312
313
315{
316 m_connectivity_dirty = aDirty;
317
318 if( aDirty && SCH_SCREEN::IsConnectivitySource( this ) )
320}
321
322
324{
325 SCH_SCREEN* screen = GetParentScreen();
326
327 if( !screen )
328 return;
329
330 if( auto* owner = dynamic_cast<SCH_ITEM*>( GetParent() ) )
331 {
332 // Plotting and property dialogs use child copies with a live parent pointer
333 bool owned = false;
334 owner->RunOnChildren( [&]( SCH_ITEM* child )
335 {
336 owned |= child == this;
337 },
339
340 if( owned && screen->CheckIfOnDrawList( owner ) )
341 screen->BumpConnectivityRevision( aChangedType );
342 }
343 else if( screen->CheckIfOnDrawList( this ) )
344 {
345 screen->BumpConnectivityRevision( aChangedType );
346 }
347}
348
349
351{
352 if( SYMBOL* sch_symbol = static_cast<SCH_SYMBOL*>( findParent( SCH_SYMBOL_T ) ) )
353 return sch_symbol;
354
355 if( SYMBOL* lib_symbol = static_cast<LIB_SYMBOL*>( findParent( LIB_SYMBOL_T ) ) )
356 return lib_symbol;
357
358 return nullptr;
359}
360
361
363{
364 if( SYMBOL* sch_symbol = static_cast<SCH_SYMBOL*>( findParent( SCH_SYMBOL_T ) ) )
365 return sch_symbol;
366
367 if( SYMBOL* lib_symbol = static_cast<LIB_SYMBOL*>( findParent( LIB_SYMBOL_T ) ) )
368 return lib_symbol;
369
370 return nullptr;
371}
372
373
374bool SCH_ITEM::ResolveExcludedFromSim( const SCH_SHEET_PATH* aInstance, const wxString& aVariantName ) const
375{
376 if( GetExcludedFromSim( aInstance, aVariantName ) )
377 return true;
378
380 return false;
381
382 for( SCH_RULE_AREA* area : m_rule_areas_cache )
383 {
384 if( area->GetExcludedFromSim( aInstance, aVariantName ) )
385 return true;
386 }
387
388 return false;
389}
390
391
392bool SCH_ITEM::ResolveExcludedFromBOM( const SCH_SHEET_PATH* aInstance, const wxString& aVariantName ) const
393{
394 if( GetExcludedFromBOM( aInstance, aVariantName ) )
395 return true;
396
398 return false;
399
400 for( SCH_RULE_AREA* area : m_rule_areas_cache )
401 {
402 if( area->GetExcludedFromBOM( aInstance, aVariantName ) )
403 return true;
404 }
405
406 return false;
407}
408
409
410bool SCH_ITEM::ResolveExcludedFromBoard( const SCH_SHEET_PATH* aInstance, const wxString& aVariantName ) const
411{
412 if( GetExcludedFromBoard( aInstance, aVariantName ) )
413 return true;
414
416 return false;
417
418 for( SCH_RULE_AREA* area : m_rule_areas_cache )
419 {
420 if( area->GetExcludedFromBoard( aInstance, aVariantName ) )
421 return true;
422 }
423
424 return false;
425}
426
427
428bool SCH_ITEM::ResolveExcludedFromPosFiles( const SCH_SHEET_PATH* aInstance, const wxString& aVariantName ) const
429{
430 if( GetExcludedFromPosFiles( aInstance, aVariantName ) )
431 return true;
432
434 return false;
435
436 for( SCH_RULE_AREA* area : m_rule_areas_cache )
437 {
438 if( area->GetExcludedFromPosFiles( aInstance, aVariantName ) )
439 return true;
440 }
441
442 return false;
443}
444
445
446bool SCH_ITEM::ResolveDNP( const SCH_SHEET_PATH* aInstance, const wxString& aVariantName ) const
447{
448 if( GetDNP( aInstance, aVariantName ) )
449 return true;
450
452 return false;
453
454 for( SCH_RULE_AREA* area : m_rule_areas_cache )
455 {
456 if( area->GetDNP( aInstance, aVariantName ) )
457 return true;
458 }
459
460 return false;
461}
462
463
464wxString SCH_ITEM::ResolveText( const wxString& aText, const SCH_SHEET_PATH* aPath, int aDepth ) const
465{
466 const SCHEMATIC* schematic = Schematic();
467 return ResolveText( aText, aPath, aDepth, schematic ? schematic->GetCurrentVariant() : wxString() );
468}
469
470
471wxString SCH_ITEM::ResolveText( const wxString& aText, const SCH_SHEET_PATH* aPath, int aDepth,
472 const wxString& aVariantName ) const
473{
474 // Use aDepth to track recursion across nested GetShownText/ResolveText calls
475 int depth = aDepth;
476
477 std::function<bool( wxString* )> libSymbolResolver =
478 [&]( wxString* token ) -> bool
479 {
480 LIB_SYMBOL* symbol = static_cast<LIB_SYMBOL*>( m_parent );
481 return symbol->ResolveTextVar( token, depth + 1 );
482 };
483
484 std::function<bool( wxString* )> symbolResolver =
485 [&]( wxString* token ) -> bool
486 {
487 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( m_parent );
488 return symbol->ResolveTextVar( aPath, token, aVariantName, depth + 1 );
489 };
490
491 std::function<bool( wxString* )> schematicResolver =
492 [&]( wxString* token ) -> bool
493 {
494 if( !aPath )
495 return false;
496
497 if( SCHEMATIC* schematic = Schematic() )
498 return schematic->ResolveTextVar( aPath, token, depth + 1 );
499
500 return false;
501 };
502
503 std::function<bool( wxString* )> sheetResolver =
504 [&]( wxString* token ) -> bool
505 {
506 if( !aPath )
507 return false;
508
509 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( m_parent );
510 SCH_SHEET_PATH path = *aPath;
511
512 if( path.Last() != sheet )
513 path.push_back( sheet );
514
515 // Sheet resolver will recurse to ancestors, including the schematic itself
516 return sheet->ResolveTextVar( &path, token, depth + 1 );
517 };
518
519 std::function<bool( wxString* )> labelResolver =
520 [&]( wxString* token ) -> bool
521 {
522 if( !aPath )
523 return false;
524
525 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( m_parent );
526 return label->ResolveTextVar( aPath, token, depth + 1 );
527 };
528
529 // Create a unified resolver that delegates to the appropriate resolver based on parent type
530 std::function<bool( wxString* )> fieldResolver =
531 [&]( wxString* token ) -> bool
532 {
533 bool resolved = false;
534
535 if( m_parent && m_parent->Type() == LIB_SYMBOL_T )
536 resolved = libSymbolResolver( token );
537 else if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
538 resolved = symbolResolver( token );
539 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
540 resolved = sheetResolver( token );
541 else if( m_parent && m_parent->IsType( labelTypes ) )
542 resolved = labelResolver( token );
543 else if( Schematic() )
544 {
545 // Project-level and schematic-level variables
546 resolved = Schematic()->Project().TextVarResolver( token );
547 resolved |= schematicResolver( token );
548 }
549
550 return resolved;
551 };
552
553 return ResolveTextVars( aText, &fieldResolver, depth );
554}
555
556
558{
560 return EDA_ITEM::ViewBBox();
561}
562
563
564std::vector<int> SCH_ITEM::ViewGetLayers() const
565{
566 // Basic fallback
568}
569
570
571bool SCH_ITEM::IsConnected( const VECTOR2I& aPosition ) const
572{
573 if(( m_flags & STRUCT_DELETED ) || ( m_flags & SKIP_STRUCT ) )
574 return false;
575
576 return doIsConnected( aPosition );
577}
578
579
581{
582 if( !IsConnectable() )
583 return nullptr;
584
585 if( !aSheet )
586 {
587 SCHEMATIC* sch = Schematic();
588
589 if( !sch )
590 return nullptr; // Item has been removed from schematic (e.g. SCH_PIN during symbol deletion)
591
592 aSheet = &sch->CurrentSheet();
593 }
594
595 auto it = m_connection_map.find( *aSheet );
596
597 if( it == m_connection_map.end() )
598 return nullptr;
599 else
600 return it->second;
601}
602
603
605{
606 for( auto& [path, conn] : m_connection_map )
607 {
608 conn->SetGraph( aGraph );
609
610 for( auto& member : conn->AllMembers() )
611 member->SetGraph( aGraph );
612 }
613}
614
615
616static std::optional<SCH_CONNECTIVITY::ITEM_VIEW> publishedConnection( const SCH_ITEM& aItem,
617 const SCH_SHEET_PATH* aSheet )
618{
619 SCHEMATIC* schematic = aItem.Schematic();
620
621 if( !schematic || !schematic->IsValid() )
622 return std::nullopt;
623
624 const SCH_SHEET_PATH& path = aSheet ? *aSheet : schematic->CurrentSheet();
625 return schematic->Connectivity().Connection( aItem.m_Uuid, path.PathRef() );
626}
627
628
629std::optional<wxString> SCH_ITEM::GetConnectionName( const SCH_SHEET_PATH* aSheet, bool aLocal,
630 bool aIgnoreSheet ) const
631{
632 if( ADVANCED_CFG::GetCfg().m_ConnectivityEngine && wxThread::IsMain() )
633 {
634 if( const auto connection = publishedConnection( *this, aSheet ) )
635 return aLocal ? connection->LocalName() : connection->Name( aIgnoreSheet );
636
637 return std::nullopt;
638 }
639
640 if( const SCH_CONNECTION* connection = Connection( aSheet ) )
641 return aLocal ? connection->LocalName() : connection->Name( aIgnoreSheet );
642
643 return std::nullopt;
644}
645
646
647std::vector<wxString> SCH_ITEM::GetBusMemberNames( const SCH_SHEET_PATH* aSheet ) const
648{
649 std::vector<wxString> names;
650
651 if( ADVANCED_CFG::GetCfg().m_ConnectivityEngine && wxThread::IsMain() )
652 {
653 const auto connection = publishedConnection( *this, aSheet );
654
655 if( connection && connection->IsBus() )
656 {
657 for( const auto& member : connection->Members().leaves )
658 names.push_back( member.Name() );
659 }
660
661 return names;
662 }
663
664 const SCH_CONNECTION* connection = Connection( aSheet );
665
666 if( connection && connection->IsBus() )
667 {
668 for( const std::shared_ptr<SCH_CONNECTION>& member : connection->Members() )
669 names.push_back( member->Name() );
670 }
671
672 return names;
673}
674
675
676bool SCH_ITEM::MatchesNetName( const EDA_SEARCH_DATA& aSearchData, const SCH_SHEET_PATH* aSheet ) const
677{
678 if( ADVANCED_CFG::GetCfg().m_ConnectivityEngine && wxThread::IsMain() )
679 {
680 const std::optional<SCH_CONNECTIVITY::ITEM_VIEW> connection = publishedConnection( *this, aSheet );
681
682 if( !connection )
683 return false;
684
685 if( !connection->IsBus() )
686 return EDA_ITEM::Matches( connection->Name(), aSearchData );
687
688 for( const SCH_CONNECTIVITY::NET_VIEW& member : connection->Members().leaves )
689 {
690 if( EDA_ITEM::Matches( member.Name(), aSearchData ) )
691 return true;
692 }
693
694 return false;
695 }
696
697 const SCH_CONNECTION* connection = Connection( aSheet );
698
699 if( !connection )
700 return false;
701
702 if( !connection->IsBus() )
703 return EDA_ITEM::Matches( connection->GetNetName(), aSearchData );
704
705 std::set<wxString> netNames;
706
707 for( const std::shared_ptr<SCH_CONNECTION>& member : connection->AllMembers() )
708 netNames.insert( member->GetNetName() );
709
710 for( const wxString& netName : netNames )
711 {
712 if( EDA_ITEM::Matches( netName, aSearchData ) )
713 return true;
714 }
715
716 return false;
717}
718
719
721{
722 if( ADVANCED_CFG::GetCfg().m_ConnectivityEngine )
723 {
724 const auto connection = wxThread::IsMain() ? publishedConnection( *this, aSheet ) : std::nullopt;
725 return connection && connection->IsBus();
726 }
727
728 const SCH_CONNECTION* connection = Connection( aSheet );
729 return connection && connection->IsBus();
730}
731
732
733std::shared_ptr<NETCLASS> SCH_ITEM::GetEffectiveNetClass( const SCH_SHEET_PATH* aSheet ) const
734{
735 static std::shared_ptr<NETCLASS> nullNetclass = std::make_shared<NETCLASS>( wxEmptyString );
736
737 SCHEMATIC* schematic = Schematic();
738
739 if( !schematic || !schematic->IsValid() )
740 return nullNetclass;
741
742 std::shared_ptr<NET_SETTINGS>& netSettings = schematic->Project().GetProjectFile().m_NetSettings;
743
744 if( !netSettings )
745 return nullNetclass;
746
747 if( const auto name = GetConnectionName( aSheet ) )
748 return netSettings->GetEffectiveNetClass( *name );
749
750 if( std::shared_ptr<NETCLASS> defaultNetclass = netSettings->GetDefaultNetclass() )
751 return defaultNetclass;
752
753 return nullNetclass;
754}
755
756
758{
759 auto it = m_connected_items.find( aSheet );
760
761 if( it != m_connected_items.end() )
762 it->second.clear();
763}
764
765
766const std::vector<SCH_ITEM*>& SCH_ITEM::ConnectedItems( const SCH_SHEET_PATH& aSheet ) const
767{
768 static const std::vector<SCH_ITEM*> empty;
769 const auto it = m_connected_items.find( aSheet );
770 return it == m_connected_items.end() ? empty : it->second;
771}
772
773
775{
776 std::vector<SCH_ITEM*>& vec = m_connected_items[ aSheet ];
777
778 // The vector elements are small, so reserve 1k at a time to prevent re-allocations
779 if( vec.size() == vec.capacity() )
780 vec.reserve( vec.size() + 4096 );
781
782 // Add item to the correct place in the sorted vector if it is not already there
783 auto it = std::lower_bound( vec.begin(), vec.end(), aItem );
784
785 if( it == vec.end() || *it != aItem )
786 vec.insert( it, aItem );
787}
788
789
791{
792 SCH_CONNECTION* connection = Connection( &aSheet );
793
794 // N.B. Do not clear the dirty connectivity flag here because we may need
795 // to create a connection for a different sheet, and we don't want to
796 // skip the connection creation because the flag is cleared.
797 if( connection )
798 {
799 connection->Reset();
800 }
801 else
802 {
803 connection = new SCH_CONNECTION( this );
804 m_connection_map.insert( std::make_pair( aSheet, connection ) );
805 }
806
807 connection->SetGraph( aGraph );
808 connection->SetSheet( aSheet );
809 return connection;
810}
811
812
814{
815 if( !IsConnectable() )
816 return nullptr;
817
818 SCH_CONNECTION* connection = Connection( &aSheet );
819
820 if( connection )
821 return connection;
822 else
823 return InitializeConnection( aSheet, aGraph );
824}
825
826
827const wxString& SCH_ITEM::GetCachedDriverName() const
828{
829 static wxString s_empty;
830 return s_empty;
831}
832
833
835{
837}
838
839
841{
842 if( aImage == nullptr )
843 return;
844
845 if( SCH_SCREEN* screen = GetParentScreen() )
846 screen->BumpConnectivityRevision( Type() );
847
848 if( SCH_SCREEN* screen = aImage->GetParentScreen() )
849 screen->BumpConnectivityRevision( aImage->Type() );
850
851 EDA_ITEM* parent = GetParent();
852
853 SwapFlags( aImage );
854 std::swap( m_layer, aImage->m_layer );
855 std::swap( m_unit, aImage->m_unit );
856 std::swap( m_bodyStyle, aImage->m_bodyStyle );
857 std::swap( m_private, aImage->m_private );
858 std::swap( m_fieldsAutoplaced, aImage->m_fieldsAutoplaced );
859 std::swap( m_customProperties, aImage->m_customProperties );
860
861 // Don't swap m_group. Group membership is restored by SCH_GROUP::swapData, and the undo copy
862 // has no group, so swapping it here would drop the item out of its group.
863 std::swap( m_isLocked, aImage->m_isLocked );
864 swapData( aImage );
865
866 SetParent( parent );
867}
868
869
871{
872 EDA_ITEM_FLAGS editFlags = GetEditFlags();
873 EDA_ITEM_FLAGS tempFlags = GetTempFlags();
874 EDA_ITEM_FLAGS aItem_editFlags = aItem->GetEditFlags();
875 EDA_ITEM_FLAGS aItem_tempFlags = aItem->GetTempFlags();
876
877 std::swap( m_flags, aItem->m_flags );
878
880 SetFlags( editFlags );
882 SetFlags( tempFlags );
883
884 aItem->ClearEditFlags();
885 aItem->SetFlags( aItem_editFlags );
886 aItem->ClearTempFlags();
887 aItem->SetFlags( aItem_tempFlags );
888}
889
890
892{
893 auto clearTextCaches =
894 []( SCH_ITEM* aItem )
895 {
896 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
897
898 if( text )
899 {
900 text->ClearBoundingBoxCache();
901 text->ClearRenderCache();
902 }
903 };
904
905 clearTextCaches( this );
906
907 RunOnChildren( clearTextCaches, RECURSE_MODE::NO_RECURSE );
908}
909
910
911bool SCH_ITEM::operator==( const SCH_ITEM& aOther ) const
912{
913 if( Type() != aOther.Type() )
914 return false;
915
916 return compare( aOther, ~COMPARE_FLAGS::UUID ) == 0;
917}
918
919
920bool SCH_ITEM::operator<( const SCH_ITEM& aOther ) const
921{
922 if( Type() != aOther.Type() )
923 return Type() < aOther.Type();
924
925 return ( compare( aOther ) < 0 );
926}
927
928
929bool SCH_ITEM::cmp_items::operator()( const SCH_ITEM* aFirst, const SCH_ITEM* aSecond ) const
930{
931 return aFirst->compare( *aSecond, ~COMPARE_FLAGS::UUID ) < 0;
932}
933
934
935int SCH_ITEM::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
936{
937 if( Type() != aOther.Type() )
938 return Type() - aOther.Type();
939
940 if( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::UNIT )
941 {
942 if( m_unit != aOther.m_unit )
943 return m_unit - aOther.m_unit;
944
945 if( m_bodyStyle != aOther.m_bodyStyle )
946 return m_bodyStyle - aOther.m_bodyStyle;
947 }
948
949 if( IsPrivate() != aOther.IsPrivate() )
950 return IsPrivate() ? 1 : -1;
951
952 if( aCompareFlags & COMPARE_FLAGS::POSITION )
953 {
954 if( GetPosition().x != aOther.GetPosition().x )
955 return GetPosition().x - aOther.GetPosition().x;
956
957 if( GetPosition().y != aOther.GetPosition().y )
958 return GetPosition().y - aOther.GetPosition().y;
959 }
960
961 if( aCompareFlags & COMPARE_FLAGS::UUID )
962 {
963 if( m_Uuid < aOther.m_Uuid )
964 return -1;
965
966 if( m_Uuid > aOther.m_Uuid )
967 return 1;
968 }
969
970 for( const auto& [name, value] : m_customProperties )
971 {
972 if( !aOther.m_customProperties.contains( name ) )
973 {
974 if( !value.IsEmpty() )
975 return false;
976
977 continue;
978 }
979
980 int cmp = aOther.m_customProperties.at( name ).Cmp( value );
981
982 if( cmp != 0 )
983 return cmp;
984 }
985
986 return 0;
987}
988
989
991{
992 if( SCHEMATIC* schematic = Schematic() )
993 return schematic->Settings().m_MaxError;
994 else
995 return schIUScale.mmToIU( ARC_LOW_DEF_MM );
996}
997
998
999const wxString& SCH_ITEM::GetDefaultFont( const KIGFX::RENDER_SETTINGS* aSettings ) const
1000{
1001 static wxString defaultName = KICAD_FONT_NAME;
1002
1003 if( aSettings )
1004 return aSettings->GetDefaultFont();
1005 else if( EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) )
1006 return cfg->m_Appearance.default_font;
1007 else
1008 return defaultName;
1009}
1010
1011
1013{
1014 if( SCHEMATIC* schematic = Schematic() )
1015 return schematic->Settings().m_FontMetrics;
1016
1017 return KIFONT::METRICS::Default();
1018}
1019
1020
1022{
1023 // For historical reasons, a stored value of 0 means "default width" and negative
1024 // numbers meant "don't stroke".
1025
1026 if( GetPenWidth() < 0 )
1027 {
1028 return 0;
1029 }
1030 else if( GetPenWidth() == 0 )
1031 {
1032 if( GetParent() && GetParent()->Type() == LIB_SYMBOL_T )
1033 return std::max( aSettings->m_SymbolLineWidth, aSettings->GetMinPenWidth() );
1034 else
1035 return std::max( aSettings->GetDefaultPenWidth(), aSettings->GetMinPenWidth() );
1036 }
1037 else
1038 {
1039 return std::max( GetPenWidth(), aSettings->GetMinPenWidth() );
1040 }
1041}
1042
1043
1044bool SCH_ITEM::RenderAsBitmap( double aWorldScale ) const
1045{
1046 if( HasHypertext() )
1047 return false;
1048
1049 if( const EDA_TEXT* text = dynamic_cast<const EDA_TEXT*>( this ) )
1050 return text->GetTextHeight() * aWorldScale < BITMAP_FONT_SIZE_THRESHOLD;
1051
1052 return false;
1053}
1054
1055
1056void SCH_ITEM::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
1057{
1058 if( SYMBOL* symbol = GetParentSymbol() )
1059 {
1060 if( symbol->IsMultiUnit() )
1061 aList.emplace_back( _( "Unit" ), GetUnitDisplayName( GetUnit(), false ) );
1062
1063 if( symbol->IsMultiBodyStyle() )
1064 aList.emplace_back( _( "Body Style" ), GetBodyStyleDescription( GetBodyStyle(), true ) );
1065
1066 if( dynamic_cast<LIB_SYMBOL*>( symbol ) && IsPrivate() )
1067 aList.emplace_back( _( "Private" ), wxEmptyString );
1068 }
1069}
1070
1071
1072const std::vector<wxString>* SCH_ITEM::GetEmbeddedFonts()
1073{
1074 if( SCHEMATIC* schematic = Schematic() )
1075 return schematic->GetEmbeddedFiles()->GetFontFiles();
1076
1077 if( SYMBOL* symbol = GetParentSymbol() )
1078 {
1079 if( EMBEDDED_FILES* symbolEmbeddedFiles = symbol->GetEmbeddedFiles() )
1080 return symbolEmbeddedFiles->UpdateFontFiles();
1081 }
1082
1083 return nullptr;
1084}
1085
1086
1087static struct SCH_ITEM_DESC
1088{
1090 {
1094
1095 propMgr.AddProperty( new PROPERTY<SCH_ITEM, bool>( _HKI( "Locked" ),
1098
1099 auto multiUnit =
1100 [=]( INSPECTABLE* aItem ) -> bool
1101 {
1102 if( SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( aItem ) )
1103 {
1104 if( const SYMBOL* symbol = schItem->GetParentSymbol() )
1105 return symbol->IsMultiUnit();
1106 }
1107
1108 return false;
1109 };
1110
1111 auto multiBodyStyle =
1112 [=]( INSPECTABLE* aItem ) -> bool
1113 {
1114 if( SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( aItem ) )
1115 {
1116 if( const SYMBOL* symbol = schItem->GetParentSymbol() )
1117 return symbol->IsMultiBodyStyle();
1118 }
1119
1120 return false;
1121 };
1122
1123 propMgr.AddProperty( new PROPERTY<SCH_ITEM, wxString>( _HKI( "Unit" ),
1125 .SetAvailableFunc( multiUnit )
1127 .SetChoicesFunc( []( INSPECTABLE* aItem )
1128 {
1129 wxPGChoices choices;
1130 choices.Add( _HKI( "All units" ), 0 );
1131
1132 if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
1133 {
1134 if( SYMBOL* symbol = item->GetParentSymbol() )
1135 {
1136 for( int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
1137 choices.Add( symbol->GetUnitDisplayName( ii, false ), ii );
1138 }
1139 }
1140
1141 return choices;
1142 } );
1143
1144
1145 propMgr.AddProperty( new PROPERTY<SCH_ITEM, wxString>( _HKI( "Body Style" ),
1147 .SetAvailableFunc( multiBodyStyle )
1149 .SetChoicesFunc( []( INSPECTABLE* aItem )
1150 {
1151 wxPGChoices choices;
1152 choices.Add( _HKI( "All body styles" ) );
1153
1154 if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
1155 {
1156 if( SYMBOL* symbol = item->GetParentSymbol() )
1157 {
1158 for( int ii : { BODY_STYLE::BASE, BODY_STYLE::DEMORGAN } )
1159 choices.Add( symbol->GetBodyStyleDescription( ii, false ) );
1160 }
1161 }
1162
1163 return choices;
1164 } );
1165
1166 propMgr.AddProperty( new PROPERTY<SCH_ITEM, bool>( _HKI( "Private" ),
1169 }
1171
1173
1174
1175static bool lessYX( const DANGLING_END_ITEM& a, const DANGLING_END_ITEM& b )
1176{
1177 const auto aPos = a.GetPosition();
1178 const auto bPos = b.GetPosition();
1179 return aPos.y < bPos.y ? true : ( aPos.y > bPos.y ? false : aPos.x < bPos.x );
1180};
1181
1182
1183static bool lessType( const DANGLING_END_ITEM& a, const DANGLING_END_ITEM& b )
1184{
1185 return a.GetType() < b.GetType();
1186};
1187
1188
1189std::vector<DANGLING_END_ITEM>::iterator
1190DANGLING_END_ITEM_HELPER::get_lower_pos( std::vector<DANGLING_END_ITEM>& aItemListByPos,
1191 const VECTOR2I& aPos )
1192{
1193 DANGLING_END_ITEM needle = DANGLING_END_ITEM( PIN_END, nullptr, aPos );
1194 auto start = aItemListByPos.begin();
1195 auto end = aItemListByPos.end();
1196 return std::lower_bound( start, end, needle, lessYX );
1197}
1198
1199
1200std::vector<DANGLING_END_ITEM>::iterator
1201DANGLING_END_ITEM_HELPER::get_lower_type( std::vector<DANGLING_END_ITEM>& aItemListByType,
1202 const DANGLING_END_T& aType )
1203{
1204 DANGLING_END_ITEM needle = DANGLING_END_ITEM( aType, nullptr, VECTOR2I{} );
1205 auto start = aItemListByType.begin();
1206 auto end = aItemListByType.end();
1207 return std::lower_bound( start, end, needle, lessType );
1208}
1209
1210
1212 std::vector<DANGLING_END_ITEM>& aItemListByType,
1213 std::vector<DANGLING_END_ITEM>& aItemListByPos )
1214{
1215 // WIRE_END pairs must be kept together. Hence stable sort.
1216 std::stable_sort( aItemListByType.begin(), aItemListByType.end(), lessType );
1217
1218 // Sort by y first, pins are more likely to share x than y.
1219 std::sort( aItemListByPos.begin(), aItemListByPos.end(), lessYX );
1220}
const char * name
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:130
constexpr double ARC_LOW_DEF_MM
Definition base_units.h:134
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
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:102
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)
static void sort_dangling_end_items(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos)
Helper class used to store the state of schematic items that can be connected to other schematic item...
Definition sch_item.h:101
DANGLING_END_T GetType() const
Definition sch_item.h:137
The base class for create windows for drawing purpose.
A set of EDA_ITEMs (i.e., without duplicates).
Definition eda_group.h:43
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:348
virtual void ClearEditFlags()
Definition eda_item.h:178
EDA_ITEM_FLAGS GetEditFlags() const
Definition eda_item.h:170
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition eda_item.h:158
const KIID m_Uuid
Definition eda_item.h:599
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:160
EDA_ITEM_FLAGS m_flags
Definition eda_item.h:608
EDA_ITEM_FLAGS GetTempFlags() const
Definition eda_item.h:183
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition eda_item.h:484
std::map< wxString, wxString > m_customProperties
Definition eda_item.h:617
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:278
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition eda_item.cpp:509
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:153
EDA_ITEM * m_parent
Owner.
Definition eda_item.h:609
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
virtual void ClearTempFlags()
Definition eda_item.h:191
EDA_ITEM * findParent(KICAD_T aType) const
Definition eda_item.cpp:137
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:94
Class that other classes need to inherit from, in order to be inspectable.
Definition inspectable.h:39
static const METRICS & Default()
Definition font.cpp:48
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const wxString & GetDefaultFont() const
Definition kiid.h:46
bool ResolveTextVar(wxString *aToken, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
Base plotter engine class.
Definition plotter.h:136
RENDER_SETTINGS * RenderSettings()
Definition plotter.h:167
std::shared_ptr< NET_SETTINGS > m_NetSettings
Net settings for this project (owned here)
virtual bool TextVarResolver(wxString *aToken) const
Definition project.cpp:81
virtual PROJECT_FILE & GetProjectFile() const
Definition project.h:201
PROPERTY_BASE & SetChoicesFunc(std::function< wxPGChoices(INSPECTABLE *)> aFunc)
Definition property.h:277
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
Definition property.h:263
PROPERTY_BASE & SetIsHiddenFromDesignEditors(bool aIsHidden=true)
Definition property.h:346
PROPERTY_BASE & SetIsHiddenFromLibraryEditors(bool aIsHidden=true)
Definition property.h:339
Provide class metadata.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
Holds all the data relating to one schematic.
Definition schematic.h:149
PROJECT & Project() const
Return a reference to the project this schematic is part of.
Definition schematic.h:171
SCH_CONNECTIVITY::FACADE & Connectivity() const
Definition schematic.h:316
wxString GetCurrentVariant() const
Return the current variant being edited.
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition schematic.h:289
SCH_SHEET_PATH & CurrentSheet() const
Definition schematic.h:304
Commit for the schematic and symbol editors.
Definition sch_commit.h:54
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString GetNetName() const
const std::vector< std::shared_ptr< SCH_CONNECTION > > AllMembers() const
void Reset()
Clears connectivity information.
bool IsBus() const
void SetGraph(CONNECTION_GRAPH *aGraph)
const std::vector< std::shared_ptr< SCH_CONNECTION > > & Members() const
void SetSheet(const SCH_SHEET_PATH &aSheet)
std::optional< ITEM_VIEW > Connection(const KIID &aItem, const KIID_PATH &aPath) const
BUS_MEMBERS Members() const
Marks the canvas reads of this thread, which are item drawing and view bounds.
Definition conn_text.h:61
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:170
SCH_ITEM * Duplicate(bool addToParentGroup, SCH_COMMIT *aCommit=nullptr, bool aDoClone=false) const
Routine to create a new copy of given item.
Definition sch_item.cpp:191
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.
friend class CONNECTION_GRAPH
Definition sch_item.h:816
virtual bool IsConnectable() const
Definition sch_item.h:545
void SetLocked(bool aLocked) override
Definition sch_item.h:262
bool MatchesNetName(const EDA_SEARCH_DATA &aSearchData, const SCH_SHEET_PATH *aSheet) const
Match aSearchData against the connection of this item on aSheet.
Definition sch_item.cpp:676
int m_unit
Definition sch_item.h:839
bool ResolveExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:428
virtual int GetPenWidth() const
Definition sch_item.h:372
SCH_ITEM & operator=(const SCH_ITEM &aPin)
Definition sch_item.cpp:91
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:847
const wxString & GetDefaultFont(const KIGFX::RENDER_SETTINGS *aSettings) const
Definition sch_item.cpp:999
void ClearConnectedItems(const SCH_SHEET_PATH &aPath)
Clear all connections to this item.
Definition sch_item.cpp:757
virtual bool doIsConnected(const VECTOR2I &aPosition) const
Provide the object specific test to see if it is connected to aPosition.
Definition sch_item.h:835
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode)
Definition sch_item.h:678
SCH_SCREEN * GetParentScreen() const
Definition sch_item.cpp:308
int m_bodyStyle
Definition sch_item.h:840
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:861
void invalidateConnectivity(KICAD_T aChangedType=TYPE_NOT_INIT)
Bump the parent screen's connectivity revision when this item, or the item owning it as a child,...
Definition sch_item.cpp:323
const std::vector< wxString > * GetEmbeddedFonts() override
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition sch_item.cpp:46
virtual ~SCH_ITEM()
Definition sch_item.cpp:109
const SYMBOL * GetParentSymbol() const
Definition sch_item.cpp:350
virtual wxString GetBodyStyleDescription(int aBodyStyle, bool aLabel) const
Definition sch_item.cpp:236
void SetPrivate(bool aPrivate)
Definition sch_item.h:258
virtual void swapData(SCH_ITEM *aItem)
Swap the internal data structures aItem with the schematic item.
Definition sch_item.cpp:834
virtual const wxString & GetCachedDriverName() const
Definition sch_item.cpp:827
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:302
int GetBodyStyle() const
Definition sch_item.h:253
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:564
SCH_CONNECTION * InitializeConnection(const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
Create a new connection object associated with this object.
Definition sch_item.cpp:790
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:766
virtual wxString GetUnitDisplayName(int aUnit, bool aLabel) const
Definition sch_item.cpp:225
bool IsLocked() const override
Definition sch_item.cpp:179
void AddConnectionTo(const SCH_SHEET_PATH &aPath, SCH_ITEM *aItem)
Add a connection link between this item and another.
Definition sch_item.cpp:774
friend class LIB_SYMBOL
Definition sch_item.h:817
virtual bool HasHypertext() const
Indicates that the item has at least one hypertext action.
Definition sch_item.h:340
virtual bool GetExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.h:287
std::vector< wxString > GetBusMemberNames(const SCH_SHEET_PATH *aSheet=nullptr) const
Names of the bus members of this item's connection, empty when it does not have a bus.
Definition sch_item.cpp:647
int GetUnit() const
Definition sch_item.h:243
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
Definition sch_item.cpp:733
virtual bool operator==(const SCH_ITEM &aOther) const
Definition sch_item.cpp:911
bool m_connectivity_dirty
Definition sch_item.h:852
bool IsPrivate() const
Definition sch_item.h:259
virtual void ClearCaches()
Definition sch_item.cpp:891
int GetMaxError() const
Definition sch_item.cpp:990
virtual bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.h:280
virtual void SetBodyStyleProp(const wxString &aBodyStyle)
Definition sch_item.cpp:274
void SetConnectivityDirty(bool aDirty=true)
Set the dirty flag.
Definition sch_item.cpp:314
virtual wxString GetBodyStyleProp() const
Definition sch_item.cpp:296
bool RenderAsBitmap(double aWorldScale) const override
std::optional< wxString > GetConnectionName(const SCH_SHEET_PATH *aSheet=nullptr, bool aLocal=false, bool aIgnoreSheet=false) const
Return the active connection name; absent for missing or stale published rows.
Definition sch_item.cpp:629
void SetConnectionGraph(CONNECTION_GRAPH *aGraph)
Update the connection graph for all connections in this item.
Definition sch_item.cpp:604
AUTOPLACE_ALGO m_fieldsAutoplaced
Definition sch_item.h:842
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:855
void SwapFlags(SCH_ITEM *aItem)
Swap the non-temp and non-edit flags.
Definition sch_item.cpp:870
bool IsConnected(const VECTOR2I &aPoint) const
Test the item to see if it is connected to aPoint.
Definition sch_item.cpp:571
virtual void SetUnitString(const wxString &aUnit)
Definition sch_item.cpp:247
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:65
std::unordered_map< SCH_SHEET_PATH, SCH_CONNECTION * > m_connection_map
Store connectivity information, per sheet.
Definition sch_item.h:850
virtual bool operator<(const SCH_ITEM &aItem) const
Definition sch_item.cpp:920
bool ResolveExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:392
bool m_private
Definition sch_item.h:841
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:126
SCH_CONNECTION * GetOrInitConnection(const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
Definition sch_item.cpp:813
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:580
wxString ResolveText(const wxString &aText, const SCH_SHEET_PATH *aPath, int aDepth=0) const
Definition sch_item.cpp:464
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:935
wxString GetClass() const override
Return the class name.
Definition sch_item.h:180
bool ResolveExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:410
const KIFONT::METRICS & GetFontMetrics() const
bool ResolveDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:446
virtual wxString GetUnitString() const
Definition sch_item.cpp:269
bool HasBusConnection(const SCH_SHEET_PATH *aSheet=nullptr) const
Definition sch_item.cpp:720
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
bool IsGroupableType() const
Definition sch_item.cpp:144
void SwapItemData(SCH_ITEM *aImage)
Swap data between aItem and aImage.
Definition sch_item.cpp:840
bool ResolveExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.cpp:374
SCH_LAYER_ID m_layer
Definition sch_item.h:838
bool m_isLocked
Definition sch_item.h:857
virtual bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.h:266
virtual bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.h:294
const BOX2I ViewBBox() const override
The view bounds of text that shows a net name must match the drawing, so this reads connectivity insi...
Definition sch_item.cpp:557
virtual bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
Definition sch_item.h:273
virtual bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth) const
Resolve any references to system tokens supported by the label.
int m_SymbolLineWidth
Override line widths for symbol drawing objects set to default line width.
static bool IsConnectivitySource(const SCH_ITEM *aItem)
Markers, bitmaps, plain shapes, graphic lines and groups carry nothing captured by connectivity.
void BumpConnectivityRevision(KICAD_T aChangedType=TYPE_NOT_INIT)
Increment the connectivity revisions of this screen.
bool CheckIfOnDrawList(const SCH_ITEM *aItem) const
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:48
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
Schematic symbol object.
Definition sch_symbol.h:73
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition symbol.h:60
wxString ResolveTextVars(const wxString &aSource, const std::function< bool(wxString *)> *aResolver, int &aDepth)
Multi-pass text variable expansion and math expression evaluation.
Definition common.cpp:333
static bool empty(const wxTextEntryBase *aCtrl)
#define _(s)
@ NO_RECURSE
Definition eda_item.h:52
#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:471
@ LAYER_DEVICE
Definition layer_ids.h:488
@ LAYER_WIRE
Definition layer_ids.h:474
@ LAYER_DEVICE_BACKGROUND
Definition layer_ids.h:506
@ LAYER_SELECTION_SHADOWS
Definition layer_ids.h:517
#define UNIMPLEMENTED_FOR(type)
Definition macros.h:92
#define _HKI(x)
Definition page_info.cpp:40
see class PGM_BASE
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
Definition property.h:74
#define IMPLEMENT_ENUM_TO_WXANY(type)
Definition property.h:888
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
static const std::vector< KICAD_T > labelTypes
Definition sch_field.cpp:48
Class to handle a set of SCH_ITEMs.
static bool lessYX(const DANGLING_END_ITEM &a, const DANGLING_END_ITEM &b)
#define BITMAP_FONT_SIZE_THRESHOLD
Definition sch_item.cpp:56
static bool lessType(const DANGLING_END_ITEM &a, const DANGLING_END_ITEM &b)
static struct SCH_ITEM_DESC _SCH_ITEM_DESC
static std::optional< SCH_CONNECTIVITY::ITEM_VIEW > publishedConnection(const SCH_ITEM &aItem, const SCH_SHEET_PATH *aSheet)
Definition sch_item.cpp:616
@ AUTOPLACE_NONE
Definition sch_item.h:74
DANGLING_END_T
Definition sch_item.h:82
@ PIN_END
Definition sch_item.h:87
@ BASE
Definition sch_item.h:64
@ DEMORGAN
Definition sch_item.h:65
T * GetAppSettings(const char *aFilename)
std::vector< NET_VIEW > leaves
bool operator()(const SCH_ITEM *aFirst, const SCH_ITEM *aSecond) const
Definition sch_item.cpp:929
std::string path
VECTOR2I end
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:70
@ SCH_GROUP_T
Definition typeinfo.h:169
@ SCH_TABLE_T
Definition typeinfo.h:161
@ SCH_LINE_T
Definition typeinfo.h:159
@ LIB_SYMBOL_T
Definition typeinfo.h:144
@ SCH_NO_CONNECT_T
Definition typeinfo.h:156
@ SCH_SYMBOL_T
Definition typeinfo.h:168
@ SCH_FIELD_T
Definition typeinfo.h:146
@ SCH_DIRECTIVE_LABEL_T
Definition typeinfo.h:167
@ SCH_LABEL_T
Definition typeinfo.h:163
@ SCH_SHEET_T
Definition typeinfo.h:171
@ SCH_SHAPE_T
Definition typeinfo.h:145
@ SCH_RULE_AREA_T
Definition typeinfo.h:166
@ SCH_HIER_LABEL_T
Definition typeinfo.h:165
@ SCH_BUS_BUS_ENTRY_T
Definition typeinfo.h:158
@ SCH_SCREEN_T
Definition typeinfo.h:198
@ SCH_LABEL_LOCATE_ANY_T
Definition typeinfo.h:187
@ SCHEMATIC_T
Definition typeinfo.h:200
@ SCH_SHEET_PIN_T
Definition typeinfo.h:170
@ SCH_TEXT_T
Definition typeinfo.h:147
@ SCH_BUS_WIRE_ENTRY_T
Definition typeinfo.h:157
@ SCH_BITMAP_T
Definition typeinfo.h:160
@ SCH_TEXTBOX_T
Definition typeinfo.h:148
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:164
@ SCH_JUNCTION_T
Definition typeinfo.h:155
@ SCH_PIN_T
Definition typeinfo.h:149
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708