KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_properties_panel.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) 2020 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Maciej Suminski <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 3
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
23
25#include <font/fontconfig.h>
26#include <pgm_base.h>
27#include <common.h>
28#include <confirm.h>
29#include <connection_graph.h>
33#include <properties/property.h>
34#include <sch_commit.h>
35#include <sch_edit_frame.h>
36#include <sch_sheet.h>
37#include <symbol_edit_frame.h>
38#include <symbol_viewer_frame.h>
39#include <schematic.h>
40#include <sch_symbol.h>
41#include <lib_symbol.h>
42#include <sch_field.h>
43#include <pin_map.h>
44#include <template_fieldnames.h>
46#include <string_utils.h>
47#include <tool/tool_manager.h>
50#include <wx_filename.h>
51#include <wx/button.h>
52#include <set>
53
54static const wxString MISSING_FIELD_SENTINEL = wxS( "\uE000" );
55
57{
58public:
59 SCH_SYMBOL_FIELD_PROPERTY( const wxString& aName ) :
60 PROPERTY_BASE( aName ),
61 m_name( aName )
62 { }
63
64 size_t OwnerHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
65 size_t BaseHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
66 size_t TypeHash() const override { return TYPE_HASH( wxString ); }
67
68 bool Writeable( INSPECTABLE* aObject ) const override
69 {
70 return PROPERTY_BASE::Writeable( aObject );
71 }
72
73 void setter( void* obj, wxAny& v ) override
74 {
75 wxString value;
76
77 if( !v.GetAs( &value ) )
78 return;
79
80 SCH_SYMBOL* symbol = reinterpret_cast<SCH_SYMBOL*>( obj );
81 SCH_FIELD* field = symbol->GetField( m_name );
82
83 wxString variantName;
84 const SCH_SHEET_PATH* sheetPath = nullptr;
85
86 if( symbol->Schematic() )
87 {
88 variantName = symbol->Schematic()->GetCurrentVariant();
89 sheetPath = &symbol->Schematic()->CurrentSheet();
90 }
91
92 if( !field )
93 {
94 SCH_FIELD newField( symbol, FIELD_T::USER, m_name );
95 newField.SetText( value, sheetPath, variantName );
96 symbol->AddField( newField );
97 }
98 else
99 {
100 field->SetText( value, sheetPath, variantName );
101 }
102 }
103
104 wxAny getter( const void* obj ) const override
105 {
106 const SCH_SYMBOL* symbol = reinterpret_cast<const SCH_SYMBOL*>( obj );
107 const SCH_FIELD* field = symbol->GetField( m_name );
108
109 if( field )
110 {
111 wxString variantName;
112 const SCH_SHEET_PATH* sheetPath = nullptr;
113
114 if( symbol->Schematic() )
115 {
116 variantName = symbol->Schematic()->GetCurrentVariant();
117 sheetPath = &symbol->Schematic()->CurrentSheet();
118 }
119
120 wxString text;
121
122 if( !variantName.IsEmpty() && sheetPath )
123 text = field->GetText( sheetPath, variantName );
124 else
125 text = field->GetText();
126
127 return wxAny( text );
128 }
129 else
130 {
131 return wxAny( MISSING_FIELD_SENTINEL );
132 }
133 }
134
135private:
136 wxString m_name;
137};
138
140{
141public:
142 SCH_SHEET_FIELD_PROPERTY( const wxString& aName ) :
143 PROPERTY_BASE( aName ),
144 m_name( aName )
145 {
146 }
147
148 size_t OwnerHash() const override { return TYPE_HASH( SCH_SHEET ); }
149 size_t BaseHash() const override { return TYPE_HASH( SCH_SHEET ); }
150 size_t TypeHash() const override { return TYPE_HASH( wxString ); }
151
152 bool Writeable( INSPECTABLE* aObject ) const override { return PROPERTY_BASE::Writeable( aObject ); }
153
154 void setter( void* obj, wxAny& v ) override
155 {
156 wxString value;
157
158 if( !v.GetAs( &value ) )
159 return;
160
161 SCH_SHEET* sheet = reinterpret_cast<SCH_SHEET*>( obj );
162 SCH_FIELD* field = sheet->GetField( m_name );
163
164 wxString variantName;
165 const SCH_SHEET_PATH* sheetPath = nullptr;
166
167 if( sheet->Schematic() )
168 {
169 variantName = sheet->Schematic()->GetCurrentVariant();
170 sheetPath = &sheet->Schematic()->CurrentSheet();
171 }
172
173 if( !field )
174 {
175 SCH_FIELD newField( sheet, FIELD_T::USER, m_name );
176 newField.SetText( value, sheetPath, variantName );
177 sheet->AddField( newField );
178 }
179 else
180 {
181 field->SetText( value, sheetPath, variantName );
182 }
183 }
184
185 wxAny getter( const void* obj ) const override
186 {
187 const SCH_SHEET* sheet = reinterpret_cast<const SCH_SHEET*>( obj );
188 const SCH_FIELD* field = sheet->GetField( m_name );
189
190 if( field )
191 {
192 wxString variantName;
193 const SCH_SHEET_PATH* sheetPath = nullptr;
194
195 if( sheet->Schematic() )
196 {
197 variantName = sheet->Schematic()->GetCurrentVariant();
198 sheetPath = &sheet->Schematic()->CurrentSheet();
199 }
200
201 wxString text;
202
203 if( !variantName.IsEmpty() && sheetPath )
204 text = field->GetText( sheetPath, variantName );
205 else
206 text = field->GetText();
207
208 return wxAny( text );
209 }
210 else
211 {
212 return wxAny( MISSING_FIELD_SENTINEL );
213 }
214 }
215
216private:
217 wxString m_name;
218};
219
220// Stable property names for the Pin Map group (issue #2282). Kept canonical (untranslated) so the
221// PROPERTY_MANAGER lookup is locale-independent; the displayed captions are translated by the grid.
222static const wxString PIN_MAP_GROUP = _HKI( "Pin Map" );
223static const wxString PIN_MAP_FOOTPRINT_PROP = wxS( "Pin Map Footprint" );
224static const wxString PIN_MAP_MODE_PROP = wxS( "Pin Map Mode" );
225static const wxString PIN_MAP_NAME_PROP = wxS( "Pin Map Name" );
226
227
234{
235 const std::unique_ptr<LIB_SYMBOL>& libSymbol = aSymbol->GetLibSymbolRef();
236
237 if( !libSymbol )
238 return nullptr;
239
240 const std::vector<ASSOCIATED_FOOTPRINT>& assoc = libSymbol->GetEffectiveAssociatedFootprints();
241
242 if( assoc.empty() )
243 return nullptr;
244
245 LIB_ID fpId;
246
247 if( const SCH_FIELD* fpField = aSymbol->GetField( FIELD_T::FOOTPRINT ) )
248 fpId.Parse( fpField->GetText() );
249
250 for( const ASSOCIATED_FOOTPRINT& candidate : assoc )
251 {
252 if( candidate.m_FootprintLibId == fpId )
253 return &candidate;
254 }
255
256 return &assoc.front();
257}
258
259
261{
262 const SCH_SYMBOL* symbol = dynamic_cast<const SCH_SYMBOL*>( aObject );
263
264 return symbol && activeAssociatedFootprint( symbol ) != nullptr;
265}
266
267
272{
273public:
278
279 size_t OwnerHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
280 size_t BaseHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
281 size_t TypeHash() const override { return TYPE_HASH( wxString ); }
282
283 bool Writeable( INSPECTABLE* aObject ) const override { return false; }
284
285 void setter( void* obj, wxAny& v ) override {}
286
287 wxAny getter( const void* obj ) const override
288 {
289 const SCH_SYMBOL* symbol = reinterpret_cast<const SCH_SYMBOL*>( obj );
290
291 if( const ASSOCIATED_FOOTPRINT* active = activeAssociatedFootprint( symbol ) )
292 return wxAny( active->m_FootprintLibId.Format().wx_str() );
293
294 return wxAny( wxEmptyString );
295 }
296};
297
298
307{
308public:
313
314 size_t OwnerHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
315 size_t BaseHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
316 size_t TypeHash() const override { return TYPE_HASH( int ); }
317
318 static wxPGChoices BuildChoices()
319 {
320 wxPGChoices choices;
321 choices.Add( _( "Library default" ), static_cast<int>( PIN_MAP_OVERRIDE_MODE::USE_LIBRARY_DEFAULT ) );
322 choices.Add( _( "Named map" ), static_cast<int>( PIN_MAP_OVERRIDE_MODE::USE_NAMED_MAP ) );
323 choices.Add( _( "Identity" ), static_cast<int>( PIN_MAP_OVERRIDE_MODE::FORCE_IDENTITY ) );
324
325 return choices;
326 }
327
328 void setter( void* obj, wxAny& v ) override
329 {
330 int value = 0;
331
332 if( !v.GetAs( &value ) )
333 return;
334
335 SCH_SYMBOL* symbol = reinterpret_cast<SCH_SYMBOL*>( obj );
336
337 const SCH_SHEET_PATH* sheetPath = nullptr;
338 wxString variantName;
339
340 if( symbol->Schematic() )
341 {
342 sheetPath = &symbol->Schematic()->CurrentSheet();
343 variantName = symbol->Schematic()->GetCurrentVariant();
344 }
345
346 PIN_MAP_INSTANCE_OVERRIDE override = symbol->GetPinMapOverride( sheetPath, variantName );
347 override.m_Mode = static_cast<PIN_MAP_OVERRIDE_MODE>( value );
348
349 // The active-map name is meaningful only in named-map mode; the library default is used
350 // otherwise. Seed it from the symbol's active associated footprint when switching to
351 // named-map mode and no name has been chosen yet.
352 if( override.m_Mode == PIN_MAP_OVERRIDE_MODE::USE_NAMED_MAP && override.m_ActiveMapName.IsEmpty() )
353 {
354 if( const ASSOCIATED_FOOTPRINT* active = activeAssociatedFootprint( symbol ) )
355 override.m_ActiveMapName = active->m_MapName;
356 }
357
358 symbol->SetPinMapOverride( override, sheetPath, variantName );
359 }
360
361 wxAny getter( const void* obj ) const override
362 {
363 const SCH_SYMBOL* symbol = reinterpret_cast<const SCH_SYMBOL*>( obj );
364
365 const SCH_SHEET_PATH* sheetPath = nullptr;
366 wxString variantName;
367
368 if( symbol->Schematic() )
369 {
370 sheetPath = &symbol->Schematic()->CurrentSheet();
371 variantName = symbol->Schematic()->GetCurrentVariant();
372 }
373
374 PIN_MAP_INSTANCE_OVERRIDE override = symbol->GetPinMapOverride( sheetPath, variantName );
375
376 // Internal delegation is resolved away by GetPinMapOverride, but guard against any leak by
377 // mapping unknown modes to the library default for display.
378 switch( override.m_Mode )
379 {
382 case PIN_MAP_OVERRIDE_MODE::FORCE_IDENTITY: return wxAny( static_cast<int>( override.m_Mode ) );
383
384 default: return wxAny( static_cast<int>( PIN_MAP_OVERRIDE_MODE::USE_LIBRARY_DEFAULT ) );
385 }
386 }
387};
388
389
391{
392public:
397
398 size_t OwnerHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
399 size_t BaseHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
400 size_t TypeHash() const override { return TYPE_HASH( int ); }
401
402 static std::vector<wxString> MapNames( const SCH_SYMBOL* aSymbol )
403 {
404 std::vector<wxString> names;
405
406 if( const LIB_SYMBOL* lib = aSymbol->GetLibSymbolRef().get() )
407 {
408 for( const PIN_MAP& map : lib->GetEffectivePinMaps().GetAll() )
409 names.push_back( map.GetName() );
410 }
411
412 return names;
413 }
414
415 static wxPGChoices BuildChoices( const SCH_SYMBOL* aSymbol )
416 {
417 wxPGChoices choices;
418 const std::vector<wxString> names = MapNames( aSymbol );
419
420 for( size_t ii = 0; ii < names.size(); ++ii )
421 choices.Add( names[ii], (int) ii );
422
423 return choices;
424 }
425
426 void setter( void* obj, wxAny& v ) override
427 {
428 int value = 0;
429
430 if( !v.GetAs( &value ) )
431 return;
432
433 SCH_SYMBOL* symbol = reinterpret_cast<SCH_SYMBOL*>( obj );
434 const std::vector<wxString> names = MapNames( symbol );
435
436 if( value < 0 || value >= (int) names.size() )
437 return;
438
439 const SCH_SHEET_PATH* sheetPath = nullptr;
440 wxString variantName;
441
442 if( symbol->Schematic() )
443 {
444 sheetPath = &symbol->Schematic()->CurrentSheet();
445 variantName = symbol->Schematic()->GetCurrentVariant();
446 }
447
448 PIN_MAP_INSTANCE_OVERRIDE override = symbol->GetPinMapOverride( sheetPath, variantName );
450 override.m_ActiveMapName = names[value];
451 symbol->SetPinMapOverride( override, sheetPath, variantName );
452 }
453
454 wxAny getter( const void* obj ) const override
455 {
456 const SCH_SYMBOL* symbol = reinterpret_cast<const SCH_SYMBOL*>( obj );
457
458 const SCH_SHEET_PATH* sheetPath = nullptr;
459 wxString variantName;
460
461 if( symbol->Schematic() )
462 {
463 sheetPath = &symbol->Schematic()->CurrentSheet();
464 variantName = symbol->Schematic()->GetCurrentVariant();
465 }
466
467 PIN_MAP_INSTANCE_OVERRIDE override = symbol->GetPinMapOverride( sheetPath, variantName );
468
469 wxString active;
470
471 if( override.m_Mode == PIN_MAP_OVERRIDE_MODE::USE_NAMED_MAP )
472 active = override.m_ActiveMapName;
473
474 const std::vector<wxString> names = MapNames( symbol );
475
476 // A stale named-map reference falls back to the library default for display, matching resolution.
477 if( std::find( names.begin(), names.end(), active ) == names.end() )
478 {
479 if( const ASSOCIATED_FOOTPRINT* fp = activeAssociatedFootprint( symbol ) )
480 active = fp->m_MapName;
481 }
482
483 for( size_t ii = 0; ii < names.size(); ++ii )
484 {
485 if( names[ii] == active )
486 return wxAny( (int) ii );
487 }
488
489 return wxAny( 0 );
490 }
491};
492
493
494// Stable group caption for the effective pin->pad table rows (issue #2282). Nested under the Pin
495// Map group as one read-only child property per symbol pin.
496static const wxString PIN_MAP_TABLE_GROUP = _HKI( "Effective Pin Map" );
497
498// Caption prefix for a per-pin table property. The property name doubles as its displayed label in
499// wxPropertyGrid, so it is kept human-readable ("Pin <number>") and untranslated for a stable,
500// locale-independent PROPERTY_MANAGER lookup key.
501static const wxString PIN_MAP_ENTRY_PREFIX = wxS( "Pin " );
502
503
512{
513public:
514 SCH_SYMBOL_PIN_MAP_ENTRY_PROPERTY( const wxString& aName, const wxString& aPinNumber ) :
515 PROPERTY_BASE( aName ),
516 m_pinNumber( aPinNumber )
517 {
518 }
519
520 size_t OwnerHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
521 size_t BaseHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
522 size_t TypeHash() const override { return TYPE_HASH( wxString ); }
523
524 bool Writeable( INSPECTABLE* aObject ) const override { return false; }
525
526 void setter( void* obj, wxAny& v ) override {}
527
528 wxAny getter( const void* obj ) const override
529 {
530 const SCH_SYMBOL* symbol = reinterpret_cast<const SCH_SYMBOL*>( obj );
531
532 const SCH_SHEET_PATH* sheetPath = nullptr;
533 wxString variantName;
534
535 if( symbol->Schematic() )
536 {
537 sheetPath = &symbol->Schematic()->CurrentSheet();
538 variantName = symbol->Schematic()->GetCurrentVariant();
539 }
540
541 if( !sheetPath )
542 return wxAny( m_pinNumber );
543
544 for( const SCH_PIN* pin : symbol->GetPins( sheetPath ) )
545 {
546 std::vector<wxString> logical = pin->GetStackedPinNumbers();
547
548 if( std::find( logical.begin(), logical.end(), m_pinNumber ) == logical.end() )
549 continue;
550
551 wxString pad = pin->GetEffectivePadNumber( *sheetPath, variantName );
552
553 if( pad == m_pinNumber )
554 return wxAny( wxString::Format( _( "%s (identity)" ), pad ) );
555
556 return wxAny( pad );
557 }
558
559 return wxAny( m_pinNumber );
560 }
561
562private:
563 wxString m_pinNumber;
564};
565
566
570
572 PROPERTIES_PANEL( aParent, aFrame ),
573 m_frame( aFrame ),
574 m_propMgr( PROPERTY_MANAGER::Instance() ),
575 m_unitEditorInstance( nullptr ),
576 m_checkboxEditorInstance( nullptr ),
577 m_colorEditorInstance( nullptr ),
578 m_fpEditorInstance( nullptr ),
579 m_urlEditorInstance( nullptr ),
580 m_editPinMapButton( nullptr )
581{
582 // Pin Map editor launcher (issue #2282). The button lives below the property grid and is only
583 // shown when a single symbol with an effective associated footprint is selected.
584 m_editPinMapButton = new wxButton( this, wxID_ANY, _( "Edit Pin Map..." ) );
585 m_editPinMapButton->Hide();
586 GetSizer()->Add( m_editPinMapButton, 0, wxALL | wxEXPAND, 5 );
587 m_editPinMapButton->Bind( wxEVT_BUTTON, &SCH_PROPERTIES_PANEL::onEditPinMap, this );
588
589 m_propMgr.Rebuild();
590 bool found = false;
591
592 wxASSERT( wxPGGlobalVars );
593
594 wxString editorKey = PG_UNIT_EDITOR::BuildEditorName( m_frame );
595
596 auto it = wxPGGlobalVars->m_mapEditorClasses.find( editorKey );
597
598 if( it != wxPGGlobalVars->m_mapEditorClasses.end() )
599 {
600 m_unitEditorInstance = static_cast<PG_UNIT_EDITOR*>( it->second );
601 m_unitEditorInstance->UpdateFrame( m_frame );
602 found = true;
603 }
604
605 if( !found )
606 {
607 PG_UNIT_EDITOR* new_editor = new PG_UNIT_EDITOR( m_frame );
608 m_unitEditorInstance = static_cast<PG_UNIT_EDITOR*>( wxPropertyGrid::RegisterEditorClass( new_editor ) );
609 }
610
611 it = wxPGGlobalVars->m_mapEditorClasses.find( PG_CHECKBOX_EDITOR::EDITOR_NAME );
612
613 if( it == wxPGGlobalVars->m_mapEditorClasses.end() )
614 {
615 PG_CHECKBOX_EDITOR* cbEditor = new PG_CHECKBOX_EDITOR();
616 m_checkboxEditorInstance = static_cast<PG_CHECKBOX_EDITOR*>( wxPropertyGrid::RegisterEditorClass( cbEditor ) );
617 }
618 else
619 {
620 m_checkboxEditorInstance = static_cast<PG_CHECKBOX_EDITOR*>( it->second );
621 }
622
623 it = wxPGGlobalVars->m_mapEditorClasses.find( PG_COLOR_EDITOR::EDITOR_NAME );
624
625 if( it == wxPGGlobalVars->m_mapEditorClasses.end() )
626 {
627 PG_COLOR_EDITOR* colorEditor = new PG_COLOR_EDITOR();
628 m_colorEditorInstance = static_cast<PG_COLOR_EDITOR*>( wxPropertyGrid::RegisterEditorClass( colorEditor ) );
629 }
630 else
631 {
632 m_colorEditorInstance = static_cast<PG_COLOR_EDITOR*>( it->second );
633 }
634
635 auto netlistCallback = [this]()
636 {
637 SCH_SELECTION& sel = m_frame->GetToolManager()->GetTool<SCH_SELECTION_TOOL>()->GetSelection();
638 LIB_SYMBOL* libSymbol = nullptr;
639
640 for( EDA_ITEM* item : sel )
641 {
642 if( item->Type() == SCH_SYMBOL_T )
643 {
644 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
645
646 if( !libSymbol )
647 libSymbol = symbol->GetLibSymbolRef().get();
648 else if( libSymbol != symbol->GetLibSymbolRef().get() )
649 return std::string( "" );
650 }
651 }
652
653 if( !libSymbol )
654 return std::string( "" );
655
656 wxString symbolNetlist;
657 wxArrayString pins;
658
659 for( SCH_PIN* pin : libSymbol->GetGraphicalPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
660 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
661
662 if( !pins.IsEmpty() )
663 symbolNetlist << EscapeString( wxJoin( pins, '\t' ), CTX_LINE );
664
665 symbolNetlist << wxS( "\r" );
666
667 wxArrayString fpFilters = libSymbol->GetFPFilters();
668
669 if( !fpFilters.IsEmpty() )
670 symbolNetlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
671
672 symbolNetlist << wxS( "\r" );
673
674 return symbolNetlist.ToStdString();
675 };
676
677 it = wxPGGlobalVars->m_mapEditorClasses.find( PG_FPID_EDITOR::BuildEditorName( m_frame ) );
678
679 if( it != wxPGGlobalVars->m_mapEditorClasses.end() )
680 {
681 m_fpEditorInstance = static_cast<PG_FPID_EDITOR*>( it->second );
682 m_fpEditorInstance->UpdateFrame( m_frame );
683 m_fpEditorInstance->UpdateCallback( netlistCallback );
684 }
685 else
686 {
687 PG_FPID_EDITOR* fpEditor = new PG_FPID_EDITOR( m_frame, netlistCallback );
688 m_fpEditorInstance = static_cast<PG_FPID_EDITOR*>( wxPropertyGrid::RegisterEditorClass( fpEditor ) );
689 }
690
691 it = wxPGGlobalVars->m_mapEditorClasses.find( PG_URL_EDITOR::BuildEditorName( m_frame ) );
692
693 if( it != wxPGGlobalVars->m_mapEditorClasses.end() )
694 {
695 m_urlEditorInstance = static_cast<PG_URL_EDITOR*>( it->second );
696 m_urlEditorInstance->UpdateFrame( m_frame );
697 }
698 else
699 {
700 PG_URL_EDITOR* urlEditor = new PG_URL_EDITOR( m_frame );
701 m_urlEditorInstance = static_cast<PG_URL_EDITOR*>( wxPropertyGrid::RegisterEditorClass( urlEditor ) );
702 }
703}
704
705
707{
708 m_unitEditorInstance->UpdateFrame( nullptr );
709 m_fpEditorInstance->UpdateFrame( nullptr );
710 m_urlEditorInstance->UpdateFrame( nullptr );
711}
712
713
715{
716 SCH_SELECTION_TOOL* selectionTool = m_frame->GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
717 const SELECTION& selection = selectionTool->GetSelection();
718
719 if( selection.Empty() && m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
720 {
721 SYMBOL_EDIT_FRAME* symbolFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
722
723 if( symbolFrame->GetCurSymbol() )
724 {
725 aFallbackSelection.Clear();
726 aFallbackSelection.Add( symbolFrame->GetCurSymbol() );
727 return aFallbackSelection;
728 }
729 }
730
731 return selection;
732}
733
734
736{
737 SELECTION fallbackSelection;
738 const SELECTION& selection = getSelection( fallbackSelection );
739
740 return selection.Empty() ? nullptr : selection.Front();
741}
742
743
745{
746 SELECTION fallbackSelection;
747 const SELECTION& selection = getSelection( fallbackSelection );
748
749 // Will actually just be updatePropertyValues() if selection hasn't changed
750 rebuildProperties( selection );
751}
752
753
755{
756 SELECTION fallbackSelection;
757 const SELECTION& selection = getSelection( fallbackSelection );
758
759 rebuildProperties( selection );
760}
761
762
764{
768
769 // The effective pin->pad table is only meaningful for a single pin-mapped symbol; collecting the
770 // pin numbers here lets the per-pin rows hide for everything else.
771 if( SCH_SYMBOL* pinMapped = getSinglePinMappedSymbol() )
772 {
773 const SCH_SHEET_PATH* sheetPath = pinMapped->Schematic() ? &pinMapped->Schematic()->CurrentSheet() : nullptr;
774
775 if( sheetPath )
776 {
777 // Use logical (stacked-expanded) pin numbers so the rows match the editor grid's keys.
778 for( const SCH_PIN* pin : pinMapped->GetPins( sheetPath ) )
779 {
780 for( const wxString& number : pin->GetStackedPinNumbers() )
781 {
782 if( !number.IsEmpty() )
783 m_currentPinMapPinNumbers.insert( number );
784 }
785 }
786 }
787 }
788
789 for( EDA_ITEM* item : aSelection )
790 {
791 if( item->Type() == SCH_SYMBOL_T )
792 {
793 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
794
795 for( const SCH_FIELD& field : symbol->GetFields() )
796 {
797 if( field.IsPrivate() )
798 continue;
799
800 m_currentSymbolFieldNames.insert( field.GetCanonicalName() );
801 }
802 }
803 else if( item->Type() == SCH_SHEET_T )
804 {
805 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
806
807 for( const SCH_FIELD& field : sheet->GetFields() )
808 {
809 if( field.IsPrivate() )
810 continue;
811
812 m_currentSheetFieldNames.insert( field.GetCanonicalName() );
813 }
814 }
815 }
816
817 const wxString groupFields = _HKI( "Fields" );
818
819 for( const wxString& name : m_currentSymbolFieldNames )
820 {
821 if( !m_propMgr.GetProperty( TYPE_HASH( SCH_SYMBOL ), name ) )
822 {
823 m_propMgr.AddProperty( new SCH_SYMBOL_FIELD_PROPERTY( name ), groupFields )
824 .SetAvailableFunc(
825 [name]( INSPECTABLE* )
826 {
828 } );
829 }
830 }
831
832 for( const wxString& name : m_currentSheetFieldNames )
833 {
834 if( !m_propMgr.GetProperty( TYPE_HASH( SCH_SHEET ), name ) )
835 {
836 m_propMgr.AddProperty( new SCH_SHEET_FIELD_PROPERTY( name ), groupFields )
837 .SetAvailableFunc(
838 [name]( INSPECTABLE* )
839 {
841 } );
842 }
843 }
844
845 // Pin Map group (issue #2282). These properties are only available when the symbol carries at
846 // least one effective associated footprint, so they stay hidden for ordinary symbols.
847 const wxString groupPinMap = PIN_MAP_GROUP;
848
849 if( !m_propMgr.GetProperty( TYPE_HASH( SCH_SYMBOL ), PIN_MAP_FOOTPRINT_PROP ) )
850 {
851 m_propMgr.AddProperty( new SCH_SYMBOL_PIN_MAP_FOOTPRINT_PROPERTY(), groupPinMap )
852 .SetAvailableFunc( symbolHasAssociatedFootprint );
853 }
854
855 if( !m_propMgr.GetProperty( TYPE_HASH( SCH_SYMBOL ), PIN_MAP_MODE_PROP ) )
856 {
857 m_propMgr.AddProperty( new SCH_SYMBOL_PIN_MAP_MODE_PROPERTY(), groupPinMap )
858 .SetAvailableFunc( symbolHasAssociatedFootprint )
859 .SetChoicesFunc(
860 []( INSPECTABLE* ) -> wxPGChoices
861 {
863 } );
864 }
865
866 if( !m_propMgr.GetProperty( TYPE_HASH( SCH_SYMBOL ), PIN_MAP_NAME_PROP ) )
867 {
868 m_propMgr.AddProperty( new SCH_SYMBOL_PIN_MAP_NAME_PROPERTY(), groupPinMap )
869 .SetAvailableFunc(
870 []( INSPECTABLE* aObject )
871 {
872 const SCH_SYMBOL* symbol = dynamic_cast<const SCH_SYMBOL*>( aObject );
873
874 return symbol && symbolHasAssociatedFootprint( aObject )
875 && SCH_SYMBOL_PIN_MAP_NAME_PROPERTY::MapNames( symbol ).size() > 1;
876 } )
877 .SetChoicesFunc(
878 []( INSPECTABLE* aObject ) -> wxPGChoices
879 {
880 if( const SCH_SYMBOL* symbol = dynamic_cast<const SCH_SYMBOL*>( aObject ) )
882
883 return wxPGChoices();
884 } );
885 }
886
887 // One read-only row per symbol pin under a collapsible group, showing the effective pad each pin
888 // resolves to (issue #2282). wxPropertyGrid has no table widget, so the table is expressed as
889 // nested category rows; they register once per pin number and gate on the current selection.
890 const wxString groupPinMapTable = PIN_MAP_TABLE_GROUP;
891
892 for( const wxString& pinNumber : m_currentPinMapPinNumbers )
893 {
894 const wxString propName = PIN_MAP_ENTRY_PREFIX + pinNumber;
895
896 if( !m_propMgr.GetProperty( TYPE_HASH( SCH_SYMBOL ), propName ) )
897 {
898 m_propMgr.AddProperty( new SCH_SYMBOL_PIN_MAP_ENTRY_PROPERTY( propName, pinNumber ), groupPinMapTable )
899 .SetAvailableFunc(
900 [pinNumber]( INSPECTABLE* )
901 {
902 return SCH_PROPERTIES_PANEL::m_currentPinMapPinNumbers.count( pinNumber );
903 } );
904 }
905 }
906
908
909 // The Edit Pin Map button targets the schematic-editor symbol properties dialog, so it is only
910 // shown there for a single pin-mapped symbol.
911 bool showEditButton = m_frame->IsType( FRAME_SCH ) && getSinglePinMappedSymbol() != nullptr;
912
913 if( m_editPinMapButton && m_editPinMapButton->IsShown() != showEditButton )
914 {
915 m_editPinMapButton->Show( showEditButton );
916 Layout();
917 }
918}
919
920
922{
923 SELECTION fallbackSelection;
924 const SELECTION& selection = getSelection( fallbackSelection );
925
926 if( selection.Size() != 1 || selection.Front()->Type() != SCH_SYMBOL_T )
927 return nullptr;
928
929 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( selection.Front() );
930
931 return symbolHasAssociatedFootprint( symbol ) ? symbol : nullptr;
932}
933
934
935void SCH_PROPERTIES_PANEL::onEditPinMap( wxCommandEvent& aEvent )
936{
938
939 if( !symbol || !m_frame->IsType( FRAME_SCH ) )
940 return;
941
942 SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( m_frame );
943
944 DIALOG_SYMBOL_PROPERTIES dlg( editFrame, symbol );
945 dlg.SelectPinMapPage();
946
947 // The dialog can subsequently invoke a KIWAY_PLAYER as a quasimodal frame, so it must run
948 // quasimodally to keep that support working.
950 {
951 editFrame->OnModify();
952 AfterCommit();
953 }
954}
955
956
957wxPGProperty* SCH_PROPERTIES_PANEL::createPGProperty( const PROPERTY_BASE* aProperty ) const
958{
959 wxPGProperty* prop = PGPropertyFactory( aProperty, m_frame );
960
961 if( auto colorProp = dynamic_cast<PGPROPERTY_COLOR4D*>( prop ) )
962 {
963 COLOR4D bg = m_frame->GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND );
964 colorProp->SetBackgroundColor( bg );
965 }
966
967 if( aProperty->Name() == GetCanonicalFieldName( FIELD_T::FOOTPRINT ) )
968 prop->SetEditor( PG_FPID_EDITOR::BuildEditorName( m_frame ) );
969 else if( aProperty->Name() == GetCanonicalFieldName( FIELD_T::DATASHEET ) )
970 prop->SetEditor( PG_URL_EDITOR::BuildEditorName( m_frame ) );
971
972 return prop;
973}
974
975
976PROPERTY_BASE* SCH_PROPERTIES_PANEL::getPropertyFromEvent( const wxPropertyGridEvent& aEvent ) const
977{
978 EDA_ITEM* item = const_cast<SCH_PROPERTIES_PANEL*>( this )->getFrontItem();
979
980 if( !item || !item->IsSCH_ITEM() )
981 return nullptr;
982
983 SCH_ITEM* firstItem = static_cast<SCH_ITEM*>( item );
984
985 wxCHECK_MSG( firstItem, nullptr, wxT( "getPropertyFromEvent for a property with nothing selected!") );
986
987 PROPERTY_BASE* property = m_propMgr.GetProperty( TYPE_HASH( *firstItem ), aEvent.GetPropertyName() );
988 wxCHECK_MSG( property, nullptr, wxT( "getPropertyFromEvent for a property not found on the selected item!" ) );
989
990 return property;
991}
992
993
994void SCH_PROPERTIES_PANEL::valueChanging( wxPropertyGridEvent& aEvent )
995{
997 return;
998
999 EDA_ITEM* frontItem = getFrontItem();
1000
1001 if( !frontItem )
1002 return;
1003
1004 if( PROPERTY_BASE* property = getPropertyFromEvent( aEvent ) )
1005 {
1006 wxVariant newValue = aEvent.GetPropertyValue();
1007
1008 if( VALIDATOR_RESULT validationFailure = property->Validate( newValue.GetAny(), frontItem ) )
1009 {
1010 wxString errorMsg = wxString::Format( wxS( "%s: %s" ), wxGetTranslation( property->Name() ),
1011 validationFailure->get()->Format( m_frame ) );
1012 m_frame->ShowInfoBarError( errorMsg );
1013 aEvent.Veto();
1014 return;
1015 }
1016
1017 aEvent.Skip();
1018 }
1019}
1020
1021
1022void SCH_PROPERTIES_PANEL::valueChanged( wxPropertyGridEvent& aEvent )
1023{
1025 return;
1026
1027 SELECTION fallbackSelection;
1028 const SELECTION& selection = getSelection( fallbackSelection );
1029
1030 wxCHECK( getPropertyFromEvent( aEvent ), /* void */ );
1031
1032 wxVariant newValue = aEvent.GetPropertyValue();
1033 SCH_COMMIT changes( m_frame );
1034 SCH_SCREEN* screen = m_frame->GetScreen();
1035
1036 PROPERTY_COMMIT_HANDLER handler( &changes );
1037
1038 for( EDA_ITEM* edaItem : selection )
1039 {
1040 if( !edaItem->IsSCH_ITEM() )
1041 continue;
1042
1043 SCH_ITEM* item = static_cast<SCH_ITEM*>( edaItem );
1044 PROPERTY_BASE* property = m_propMgr.GetProperty( TYPE_HASH( *item ), aEvent.GetPropertyName() );
1045 wxCHECK2( property, continue );
1046
1047 // Editing reference text in the schematic must go through the parent symbol in order to handle
1048 // symbol instance data properly.
1049 if( item->Type() == SCH_FIELD_T && static_cast<SCH_FIELD*>( item )->GetId() == FIELD_T::REFERENCE
1050 && m_frame->IsType( FRAME_SCH )
1051 && property->Name() == wxT( "Text" ) )
1052 {
1053 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item->GetParentSymbol() );
1054 wxCHECK2( symbol, continue );
1055
1056 changes.Modify( symbol, screen, RECURSE_MODE::NO_RECURSE );
1057 symbol->SetRefProp( newValue.GetString() );
1058 symbol->SyncOtherUnits( symbol->Schematic()->CurrentSheet(), changes, property );
1059 continue;
1060 }
1061
1062 // Editing field text in the schematic when a variant is active must use variant-aware
1063 // SetText to properly store the value as a variant override.
1064 if( item->Type() == SCH_FIELD_T
1065 && m_frame->IsType( FRAME_SCH )
1066 && property->Name() == wxT( "Text" ) )
1067 {
1068 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
1069 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item->GetParentSymbol() );
1070
1071 if( symbol && symbol->Schematic() )
1072 {
1073 wxString variantName = symbol->Schematic()->GetCurrentVariant();
1074
1075 if( !variantName.IsEmpty() )
1076 {
1077 changes.Modify( symbol, screen, RECURSE_MODE::NO_RECURSE );
1078 field->SetText( newValue.GetString(), &symbol->Schematic()->CurrentSheet(), variantName );
1079 symbol->SyncOtherUnits( symbol->Schematic()->CurrentSheet(), changes, property,
1080 variantName );
1081 continue;
1082 }
1083 }
1084 }
1085
1086 // Changing a sheet's filename field requires file operations to match the dialog behavior.
1087 if( item->Type() == SCH_FIELD_T
1088 && m_frame->IsType( FRAME_SCH )
1089 && property->Name() == wxT( "Text" ) )
1090 {
1091 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
1092 SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( item->GetParent() );
1093
1094 if( sheet && field->GetId() == FIELD_T::SHEET_FILENAME )
1095 {
1096 SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( m_frame );
1097
1098 if( !handleSheetFilenameChange( editFrame, sheet, changes, newValue.GetString() ) )
1099 {
1100 UpdateData();
1101 return;
1102 }
1103
1104 continue;
1105 }
1106 }
1107
1108 if( item->Type() == SCH_TABLECELL_T )
1109 changes.Modify( item->GetParent(), screen, RECURSE_MODE::NO_RECURSE );
1110 else
1111 changes.Modify( item, screen, RECURSE_MODE::NO_RECURSE );
1112
1113 item->Set( property, newValue );
1114
1115 if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item ) )
1116 {
1117 symbol->SyncOtherUnits( symbol->Schematic()->CurrentSheet(), changes, property,
1118 symbol->Schematic()->GetCurrentVariant() );
1119 }
1120 }
1121
1122 changes.Push( _( "Edit Properties" ) );
1123
1124 // Force a repaint of the items whose properties were changed
1125 // This is necessary to update field displays in the schematic view
1126 for( EDA_ITEM* edaItem : selection )
1127 m_frame->UpdateItem( edaItem );
1128
1129 // Perform grid updates as necessary based on value change
1130 AfterCommit();
1131
1132 aEvent.Skip();
1133}
1134
1135
1137 SCH_COMMIT& aChanges,
1138 const wxString& aNewFilename )
1139{
1140 wxString newFilename = EnsureFileExtension( aNewFilename, FILEEXT::KiCadSchematicFileExtension );
1141
1142 if( newFilename.IsEmpty() || !IsFullFileNameValid( newFilename ) )
1143 {
1144 DisplayError( aFrame, _( "A sheet must have a valid file name." ) );
1145 return false;
1146 }
1147
1148 // Normalize separators to unix notation
1149 newFilename.Replace( wxT( "\\" ), wxT( "/" ) );
1150
1151 wxString oldFilename = aSheet->GetFileName();
1152 oldFilename.Replace( wxT( "\\" ), wxT( "/" ) );
1153
1154 if( newFilename == oldFilename )
1155 return true;
1156
1157 if( !aFrame->ChangeSheetFile( aSheet, newFilename ) )
1158 return false;
1159
1160 SCH_SCREEN* currentScreen = aFrame->GetCurrentSheet().LastScreen();
1161 aChanges.Modify( aSheet, currentScreen, RECURSE_MODE::NO_RECURSE );
1162 aSheet->SetFileName( newFilename );
1163
1164 return true;
1165}
1166
1167
1168void SCH_PROPERTIES_PANEL::OnLanguageChanged( wxCommandEvent& aEvent )
1169{
1171
1172 aEvent.Skip();
1173}
1174
1175
1176bool SCH_PROPERTIES_PANEL::getItemValue( EDA_ITEM* aItem, PROPERTY_BASE* aProperty, wxVariant& aValue )
1177{
1178 // For SCH_FIELD "Text" property, return the variant-aware value when a variant is active
1179 if( aItem->Type() == SCH_FIELD_T
1180 && m_frame->IsType( FRAME_SCH )
1181 && aProperty->Name() == wxT( "Text" ) )
1182 {
1183 SCH_FIELD* field = static_cast<SCH_FIELD*>( aItem );
1184 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( field->GetParentSymbol() );
1185
1186 if( symbol && symbol->Schematic() )
1187 {
1188 wxString variantName = symbol->Schematic()->GetCurrentVariant();
1189
1190 if( !variantName.IsEmpty() )
1191 {
1192 wxString text = field->GetText( &symbol->Schematic()->CurrentSheet(), variantName );
1193 aValue = wxVariant( text );
1194 return true;
1195 }
1196 }
1197 }
1198
1199 return PROPERTIES_PANEL::getItemValue( aItem, aProperty, aValue );
1200}
const char * name
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
Dialog used to edit SCH_SYMBOL objects in a schematic.
void SelectPinMapPage()
Select the Pin Map page so the dialog opens directly on the pin-to-pad mapping editor (issue #2282).
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:96
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
EDA_ITEM * GetParent() const
Definition eda_item.h:110
Class that other classes need to inherit from, in order to be inspectable.
Definition inspectable.h:38
bool Set(PROPERTY_BASE *aProperty, wxAny &aValue, bool aNotify=true)
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
bool IsSCH_ITEM() const
Definition view_item.h:97
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition lib_id.cpp:65
Define a library symbol object.
Definition lib_symbol.h:80
std::vector< const SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
wxArrayString GetFPFilters() const
Definition lib_symbol.h:208
static const wxString EDITOR_NAME
Definition pg_editors.h:75
static const wxString EDITOR_NAME
Definition pg_editors.h:91
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
A named pin map.
Definition pin_map.h:64
PROPERTIES_PANEL(wxWindow *aParent, EDA_BASE_FRAME *aFrame)
virtual void OnLanguageChanged(wxCommandEvent &aEvent)
virtual bool getItemValue(EDA_ITEM *aItem, PROPERTY_BASE *aProperty, wxVariant &aValue)
Utility to fetch a property value and convert to wxVariant Precondition: aItem is known to have prope...
virtual void rebuildProperties(const SELECTION &aSelection)
Generates the property grid for a given selection of items.
PROPERTY_BASE(const wxString &aName, PROPERTY_DISPLAY aDisplay=PT_DEFAULT, ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType=ORIGIN_TRANSFORMS::NOT_A_COORD)
< Used to generate unique IDs. Must come up front so it's initialized before ctor.
Definition property.h:201
virtual bool Writeable(INSPECTABLE *aObject) const
Definition property.h:282
friend class INSPECTABLE
Definition property.h:459
const wxString & Name() const
Definition property.h:220
Provide class metadata.Helper macro to map type hashes to names.
wxString GetCurrentVariant() const
Return the current variant being edited.
SCH_SHEET_PATH & CurrentSheet() const
Definition schematic.h:189
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Schematic editor (Eeschema) main window.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
SCH_SHEET_PATH & GetCurrentSheet() const
bool ChangeSheetFile(SCH_SHEET *aSheet, const wxString &aNewFilename, bool *aClearAnnotationNewItems=nullptr, bool *aIsUndoable=nullptr, const wxString *aSourceSheetFilename=nullptr)
Change the file backing a schematic sheet.
Definition sheet.cpp:173
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:128
FIELD_T GetId() const
Definition sch_field.h:132
void SetText(const wxString &aText) override
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:162
const SYMBOL * GetParentSymbol() const
Definition sch_item.cpp:274
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:268
bool getItemValue(EDA_ITEM *aItem, PROPERTY_BASE *aProperty, wxVariant &aValue) override
Utility to fetch a property value and convert to wxVariant Precondition: aItem is known to have prope...
static std::set< wxString > m_currentSymbolFieldNames
wxPGProperty * createPGProperty(const PROPERTY_BASE *aProperty) const override
PROPERTY_MANAGER & m_propMgr
PG_CHECKBOX_EDITOR * m_checkboxEditorInstance
void onEditPinMap(wxCommandEvent &aEvent)
Open the symbol properties dialog on its Pin Map page for the single selected symbol (issue #2282).
PG_FPID_EDITOR * m_fpEditorInstance
const SELECTION & getSelection(SELECTION &aFallbackSelection)
Get the current selection from the selection tool.
static std::set< wxString > m_currentPinMapPinNumbers
Distinct pin numbers of the selected pin-mapped symbol, gating the per-pin table rows.
void valueChanging(wxPropertyGridEvent &aEvent) override
static std::set< wxString > m_currentSheetFieldNames
PG_UNIT_EDITOR * m_unitEditorInstance
void valueChanged(wxPropertyGridEvent &aEvent) override
SCH_PROPERTIES_PANEL(wxWindow *aParent, SCH_BASE_FRAME *aFrame)
PG_COLOR_EDITOR * m_colorEditorInstance
EDA_ITEM * getFrontItem()
Get the front item of the current selection.
PROPERTY_BASE * getPropertyFromEvent(const wxPropertyGridEvent &aEvent) const
void OnLanguageChanged(wxCommandEvent &aEvent) override
bool handleSheetFilenameChange(SCH_EDIT_FRAME *aFrame, SCH_SHEET *aSheet, SCH_COMMIT &aChanges, const wxString &aNewFilename)
void rebuildProperties(const SELECTION &aSelection) override
Generates the property grid for a given selection of items.
PG_URL_EDITOR * m_urlEditorInstance
SCH_SYMBOL * getSinglePinMappedSymbol()
SCH_SELECTION & GetSelection()
size_t BaseHash() const override
Return type-id of the Base class.
bool Writeable(INSPECTABLE *aObject) const override
SCH_SHEET_FIELD_PROPERTY(const wxString &aName)
wxAny getter(const void *obj) const override
void setter(void *obj, wxAny &v) override
size_t OwnerHash() const override
Return type-id of the Owner class.
size_t TypeHash() const override
Return type-id of the property type.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SCREEN * LastScreen()
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:44
void SetFileName(const wxString &aFilename)
Definition sch_sheet.h:376
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition sch_sheet.h:370
std::vector< SCH_FIELD > & GetFields()
Return a reference to the vector holding the sheet's fields.
Definition sch_sheet.h:87
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a @aField to the list of fields.
size_t BaseHash() const override
Return type-id of the Base class.
size_t OwnerHash() const override
Return type-id of the Owner class.
size_t TypeHash() const override
Return type-id of the property type.
wxAny getter(const void *obj) const override
SCH_SYMBOL_FIELD_PROPERTY(const wxString &aName)
bool Writeable(INSPECTABLE *aObject) const override
void setter(void *obj, wxAny &v) override
Read-only per-pin row of the effective pin->pad table (issue #2282).
size_t TypeHash() const override
Return type-id of the property type.
size_t BaseHash() const override
Return type-id of the Base class.
SCH_SYMBOL_PIN_MAP_ENTRY_PROPERTY(const wxString &aName, const wxString &aPinNumber)
bool Writeable(INSPECTABLE *aObject) const override
wxString m_pinNumber
wxAny getter(const void *obj) const override
size_t OwnerHash() const override
Return type-id of the Owner class.
void setter(void *obj, wxAny &v) override
Read-only property showing the footprint a symbol's pin map resolves against (issue #2282).
wxAny getter(const void *obj) const override
size_t OwnerHash() const override
Return type-id of the Owner class.
void setter(void *obj, wxAny &v) override
size_t TypeHash() const override
Return type-id of the property type.
size_t BaseHash() const override
Return type-id of the Base class.
bool Writeable(INSPECTABLE *aObject) const override
Override-mode selector for a symbol's per-instance pin map (issue #2282).
wxAny getter(const void *obj) const override
void setter(void *obj, wxAny &v) override
size_t TypeHash() const override
Return type-id of the property type.
size_t OwnerHash() const override
Return type-id of the Owner class.
size_t BaseHash() const override
Return type-id of the Base class.
wxAny getter(const void *obj) const override
size_t TypeHash() const override
Return type-id of the property type.
static wxPGChoices BuildChoices(const SCH_SYMBOL *aSymbol)
static std::vector< wxString > MapNames(const SCH_SYMBOL *aSymbol)
size_t OwnerHash() const override
Return type-id of the Owner class.
void setter(void *obj, wxAny &v) override
size_t BaseHash() const override
Return type-id of the Base class.
Schematic symbol object.
Definition sch_symbol.h:69
void SetRefProp(const wxString &aRef)
PIN_MAP_INSTANCE_OVERRIDE GetPinMapOverride(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
void SetPinMapOverride(const PIN_MAP_INSTANCE_OVERRIDE &aOverride, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString)
Set the per-instance pin-to-pad map override (issue #2282).
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
void SyncOtherUnits(const SCH_SHEET_PATH &aSourceSheet, SCH_COMMIT &aCommit, PROPERTY_BASE *aProperty, const wxString &aVariantName=wxEmptyString)
Keep fields other than the reference, include/exclude flags, and alternate pin assignments in sync in...
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition sch_symbol.h:177
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
virtual void Add(EDA_ITEM *aItem)
Definition selection.cpp:38
EDA_ITEM * Front() const
Definition selection.h:173
virtual void Clear() override
Remove all the stored items from the group.
Definition selection.h:94
int Size() const
Returns the number of selected parts.
Definition selection.h:117
bool Empty() const
Checks if there is anything selected.
Definition selection.h:111
The symbol library editor main window.
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
wxString EnsureFileExtension(const wxString &aFilename, const wxString &aExtension)
It's annoying to throw up nag dialogs when the extension isn't right.
Definition common.cpp:792
The common library.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition confirm.cpp:192
This file is part of the common library.
@ SYMBOL_PROPS_EDIT_OK
#define _(s)
@ NO_RECURSE
Definition eda_item.h:50
@ FRAME_SCH_SYMBOL_EDITOR
Definition frame_type.h:31
@ FRAME_SCH
Definition frame_type.h:30
static const std::string KiCadSchematicFileExtension
@ LAYER_SCHEMATIC_BACKGROUND
Definition layer_ids.h:486
#define _HKI(x)
Definition page_info.cpp:40
wxPGProperty * PGPropertyFactory(const PROPERTY_BASE *aProperty, EDA_DRAW_FRAME *aFrame)
Customized abstract wxPGProperty class to handle coordinate/size units.
see class PGM_BASE
PIN_MAP_OVERRIDE_MODE
Override mode stored on a SCH_SYMBOL_INSTANCE.
Definition pin_map.h:177
APIIMPORT wxPGGlobalVarsClass * wxPGGlobalVars
#define TYPE_HASH(x)
Definition property.h:74
std::optional< std::unique_ptr< VALIDATION_ERROR > > VALIDATOR_RESULT
Null optional means validation succeeded.
static const wxString PIN_MAP_GROUP
static const wxString PIN_MAP_MODE_PROP
static const wxString MISSING_FIELD_SENTINEL
static const wxString PIN_MAP_FOOTPRINT_PROP
static const ASSOCIATED_FOOTPRINT * activeAssociatedFootprint(const SCH_SYMBOL *aSymbol)
static const wxString PIN_MAP_ENTRY_PREFIX
static bool symbolHasAssociatedFootprint(INSPECTABLE *aObject)
static const wxString PIN_MAP_NAME_PROP
static const wxString PIN_MAP_TABLE_GROUP
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
bool IsFullFileNameValid(const wxString &aFullFilename)
Checks if a full filename is valid, i.e.
@ CTX_LINE
A first-class footprint choice on a LIB_SYMBOL, tied to a named pin map.
Definition pin_map.h:158
Per-instance override of the active pin map and a sparse delta on top.
Definition pin_map.h:199
PIN_MAP_OVERRIDE_MODE m_Mode
Definition pin_map.h:200
@ USER
The field ID hasn't been set yet; field is invalid.
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
wxString GetCanonicalFieldName(FIELD_T aFieldType)
KIBIS_PIN * pin
@ SCH_SYMBOL_T
Definition typeinfo.h:169
@ SCH_TABLECELL_T
Definition typeinfo.h:163
@ SCH_FIELD_T
Definition typeinfo.h:147
@ SCH_SHEET_T
Definition typeinfo.h:172
Definition of file extensions used in Kicad.