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>
48#include <tools/sch_actions.h>
51#include <wx_filename.h>
52#include <wx/button.h>
53#include <set>
54
55static const wxString MISSING_FIELD_SENTINEL = wxS( "\uE000" );
56
58{
59public:
60 SCH_SYMBOL_FIELD_PROPERTY( const wxString& aName ) :
61 PROPERTY_BASE( aName ),
62 m_name( aName )
63 { }
64
65 size_t OwnerHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
66 size_t BaseHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
67 size_t TypeHash() const override { return TYPE_HASH( wxString ); }
68
69 bool Writeable( INSPECTABLE* aObject ) const override
70 {
71 return PROPERTY_BASE::Writeable( aObject );
72 }
73
74 void setter( void* obj, wxAny& v ) override
75 {
76 wxString value;
77
78 if( !v.GetAs( &value ) )
79 return;
80
81 SCH_SYMBOL* symbol = reinterpret_cast<SCH_SYMBOL*>( obj );
82 SCH_FIELD* field = symbol->GetField( m_name );
83
84 wxString variantName;
85 const SCH_SHEET_PATH* sheetPath = nullptr;
86
87 if( symbol->Schematic() )
88 {
89 variantName = symbol->Schematic()->GetCurrentVariant();
90 sheetPath = &symbol->Schematic()->CurrentSheet();
91 }
92
93 if( !field )
94 {
95 SCH_FIELD newField( symbol, FIELD_T::USER, m_name );
96 newField.SetText( value, sheetPath, variantName );
97 symbol->AddField( newField );
98 }
99 else
100 {
101 field->SetText( value, sheetPath, variantName );
102 }
103 }
104
105 wxAny getter( const void* obj ) const override
106 {
107 const SCH_SYMBOL* symbol = reinterpret_cast<const SCH_SYMBOL*>( obj );
108 const SCH_FIELD* field = symbol->GetField( m_name );
109
110 if( field )
111 {
112 wxString variantName;
113 const SCH_SHEET_PATH* sheetPath = nullptr;
114
115 if( symbol->Schematic() )
116 {
117 variantName = symbol->Schematic()->GetCurrentVariant();
118 sheetPath = &symbol->Schematic()->CurrentSheet();
119 }
120
121 wxString text;
122
123 if( !variantName.IsEmpty() && sheetPath )
124 text = field->GetText( sheetPath, variantName );
125 else
126 text = field->GetText();
127
128 return wxAny( text );
129 }
130 else
131 {
132 return wxAny( MISSING_FIELD_SENTINEL );
133 }
134 }
135
136private:
137 wxString m_name;
138};
139
141{
142public:
143 SCH_SHEET_FIELD_PROPERTY( const wxString& aName ) :
144 PROPERTY_BASE( aName ),
145 m_name( aName )
146 {
147 }
148
149 size_t OwnerHash() const override { return TYPE_HASH( SCH_SHEET ); }
150 size_t BaseHash() const override { return TYPE_HASH( SCH_SHEET ); }
151 size_t TypeHash() const override { return TYPE_HASH( wxString ); }
152
153 bool Writeable( INSPECTABLE* aObject ) const override { return PROPERTY_BASE::Writeable( aObject ); }
154
155 void setter( void* obj, wxAny& v ) override
156 {
157 wxString value;
158
159 if( !v.GetAs( &value ) )
160 return;
161
162 SCH_SHEET* sheet = reinterpret_cast<SCH_SHEET*>( obj );
163 SCH_FIELD* field = sheet->GetField( m_name );
164
165 wxString variantName;
166 const SCH_SHEET_PATH* sheetPath = nullptr;
167
168 if( sheet->Schematic() )
169 {
170 variantName = sheet->Schematic()->GetCurrentVariant();
171 sheetPath = &sheet->Schematic()->CurrentSheet();
172 }
173
174 if( !field )
175 {
176 SCH_FIELD newField( sheet, FIELD_T::USER, m_name );
177 newField.SetText( value, sheetPath, variantName );
178 sheet->AddField( newField );
179 }
180 else
181 {
182 field->SetText( value, sheetPath, variantName );
183 }
184 }
185
186 wxAny getter( const void* obj ) const override
187 {
188 const SCH_SHEET* sheet = reinterpret_cast<const SCH_SHEET*>( obj );
189 const SCH_FIELD* field = sheet->GetField( m_name );
190
191 if( field )
192 {
193 wxString variantName;
194 const SCH_SHEET_PATH* sheetPath = nullptr;
195
196 if( sheet->Schematic() )
197 {
198 variantName = sheet->Schematic()->GetCurrentVariant();
199 sheetPath = &sheet->Schematic()->CurrentSheet();
200 }
201
202 wxString text;
203
204 if( !variantName.IsEmpty() && sheetPath )
205 text = field->GetText( sheetPath, variantName );
206 else
207 text = field->GetText();
208
209 return wxAny( text );
210 }
211 else
212 {
213 return wxAny( MISSING_FIELD_SENTINEL );
214 }
215 }
216
217private:
218 wxString m_name;
219};
220
221// Stable property names for the Pin Map group (issue #2282). Kept canonical (untranslated) so the
222// PROPERTY_MANAGER lookup is locale-independent; the displayed captions are translated by the grid.
223static const wxString PIN_MAP_GROUP = _HKI( "Pin Map" );
224static const wxString PIN_MAP_FOOTPRINT_PROP = wxS( "Pin Map Footprint" );
225static const wxString PIN_MAP_MODE_PROP = wxS( "Pin Map Mode" );
226static const wxString PIN_MAP_NAME_PROP = wxS( "Pin Map Name" );
227
228
235{
236 const std::unique_ptr<LIB_SYMBOL>& libSymbol = aSymbol->GetLibSymbolRef();
237
238 if( !libSymbol )
239 return nullptr;
240
241 const std::vector<ASSOCIATED_FOOTPRINT>& assoc = libSymbol->GetEffectiveAssociatedFootprints();
242
243 if( assoc.empty() )
244 return nullptr;
245
246 LIB_ID fpId;
247
248 if( const SCH_FIELD* fpField = aSymbol->GetField( FIELD_T::FOOTPRINT ) )
249 fpId.Parse( fpField->GetText() );
250
251 for( const ASSOCIATED_FOOTPRINT& candidate : assoc )
252 {
253 if( candidate.m_FootprintLibId == fpId )
254 return &candidate;
255 }
256
257 return &assoc.front();
258}
259
260
262{
263 const SCH_SYMBOL* symbol = dynamic_cast<const SCH_SYMBOL*>( aObject );
264
265 return symbol && activeAssociatedFootprint( symbol ) != nullptr;
266}
267
268
273{
274public:
279
280 size_t OwnerHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
281 size_t BaseHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
282 size_t TypeHash() const override { return TYPE_HASH( wxString ); }
283
284 bool Writeable( INSPECTABLE* aObject ) const override { return false; }
285
286 void setter( void* obj, wxAny& v ) override {}
287
288 wxAny getter( const void* obj ) const override
289 {
290 const SCH_SYMBOL* symbol = reinterpret_cast<const SCH_SYMBOL*>( obj );
291
292 if( const ASSOCIATED_FOOTPRINT* active = activeAssociatedFootprint( symbol ) )
293 return wxAny( active->m_FootprintLibId.Format().wx_str() );
294
295 return wxAny( wxEmptyString );
296 }
297};
298
299
308{
309public:
314
315 size_t OwnerHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
316 size_t BaseHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
317 size_t TypeHash() const override { return TYPE_HASH( int ); }
318
319 static wxPGChoices BuildChoices()
320 {
321 wxPGChoices choices;
322 choices.Add( _( "Library default" ), static_cast<int>( PIN_MAP_OVERRIDE_MODE::USE_LIBRARY_DEFAULT ) );
323 choices.Add( _( "Named map" ), static_cast<int>( PIN_MAP_OVERRIDE_MODE::USE_NAMED_MAP ) );
324 choices.Add( _( "Identity" ), static_cast<int>( PIN_MAP_OVERRIDE_MODE::FORCE_IDENTITY ) );
325
326 return choices;
327 }
328
329 void setter( void* obj, wxAny& v ) override
330 {
331 int value = 0;
332
333 if( !v.GetAs( &value ) )
334 return;
335
336 SCH_SYMBOL* symbol = reinterpret_cast<SCH_SYMBOL*>( obj );
337
338 const SCH_SHEET_PATH* sheetPath = nullptr;
339 wxString variantName;
340
341 if( symbol->Schematic() )
342 {
343 sheetPath = &symbol->Schematic()->CurrentSheet();
344 variantName = symbol->Schematic()->GetCurrentVariant();
345 }
346
347 PIN_MAP_INSTANCE_OVERRIDE override = symbol->GetPinMapOverride( sheetPath, variantName );
348 override.m_Mode = static_cast<PIN_MAP_OVERRIDE_MODE>( value );
349
350 // The active-map name is meaningful only in named-map mode; the library default is used
351 // otherwise. Seed it from the symbol's active associated footprint when switching to
352 // named-map mode and no name has been chosen yet.
353 if( override.m_Mode == PIN_MAP_OVERRIDE_MODE::USE_NAMED_MAP && override.m_ActiveMapName.IsEmpty() )
354 {
355 if( const ASSOCIATED_FOOTPRINT* active = activeAssociatedFootprint( symbol ) )
356 override.m_ActiveMapName = active->m_MapName;
357 }
358
359 symbol->SetPinMapOverride( override, sheetPath, variantName );
360 }
361
362 wxAny getter( const void* obj ) const override
363 {
364 const SCH_SYMBOL* symbol = reinterpret_cast<const SCH_SYMBOL*>( obj );
365
366 const SCH_SHEET_PATH* sheetPath = nullptr;
367 wxString variantName;
368
369 if( symbol->Schematic() )
370 {
371 sheetPath = &symbol->Schematic()->CurrentSheet();
372 variantName = symbol->Schematic()->GetCurrentVariant();
373 }
374
375 PIN_MAP_INSTANCE_OVERRIDE override = symbol->GetPinMapOverride( sheetPath, variantName );
376
377 // Internal delegation is resolved away by GetPinMapOverride, but guard against any leak by
378 // mapping unknown modes to the library default for display.
379 switch( override.m_Mode )
380 {
383 case PIN_MAP_OVERRIDE_MODE::FORCE_IDENTITY: return wxAny( static_cast<int>( override.m_Mode ) );
384
385 default: return wxAny( static_cast<int>( PIN_MAP_OVERRIDE_MODE::USE_LIBRARY_DEFAULT ) );
386 }
387 }
388};
389
390
392{
393public:
398
399 size_t OwnerHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
400 size_t BaseHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
401 size_t TypeHash() const override { return TYPE_HASH( int ); }
402
403 static std::vector<wxString> MapNames( const SCH_SYMBOL* aSymbol )
404 {
405 std::vector<wxString> names;
406
407 if( const LIB_SYMBOL* lib = aSymbol->GetLibSymbolRef().get() )
408 {
409 for( const PIN_MAP& map : lib->GetEffectivePinMaps().GetAll() )
410 names.push_back( map.GetName() );
411 }
412
413 return names;
414 }
415
416 static wxPGChoices BuildChoices( const SCH_SYMBOL* aSymbol )
417 {
418 wxPGChoices choices;
419 const std::vector<wxString> names = MapNames( aSymbol );
420
421 for( size_t ii = 0; ii < names.size(); ++ii )
422 choices.Add( names[ii], (int) ii );
423
424 return choices;
425 }
426
427 void setter( void* obj, wxAny& v ) override
428 {
429 int value = 0;
430
431 if( !v.GetAs( &value ) )
432 return;
433
434 SCH_SYMBOL* symbol = reinterpret_cast<SCH_SYMBOL*>( obj );
435 const std::vector<wxString> names = MapNames( symbol );
436
437 if( value < 0 || value >= (int) names.size() )
438 return;
439
440 const SCH_SHEET_PATH* sheetPath = nullptr;
441 wxString variantName;
442
443 if( symbol->Schematic() )
444 {
445 sheetPath = &symbol->Schematic()->CurrentSheet();
446 variantName = symbol->Schematic()->GetCurrentVariant();
447 }
448
449 PIN_MAP_INSTANCE_OVERRIDE override = symbol->GetPinMapOverride( sheetPath, variantName );
451 override.m_ActiveMapName = names[value];
452 symbol->SetPinMapOverride( override, sheetPath, variantName );
453 }
454
455 wxAny getter( const void* obj ) const override
456 {
457 const SCH_SYMBOL* symbol = reinterpret_cast<const SCH_SYMBOL*>( obj );
458
459 const SCH_SHEET_PATH* sheetPath = nullptr;
460 wxString variantName;
461
462 if( symbol->Schematic() )
463 {
464 sheetPath = &symbol->Schematic()->CurrentSheet();
465 variantName = symbol->Schematic()->GetCurrentVariant();
466 }
467
468 PIN_MAP_INSTANCE_OVERRIDE override = symbol->GetPinMapOverride( sheetPath, variantName );
469
470 wxString active;
471
472 if( override.m_Mode == PIN_MAP_OVERRIDE_MODE::USE_NAMED_MAP )
473 active = override.m_ActiveMapName;
474
475 const std::vector<wxString> names = MapNames( symbol );
476
477 // A stale named-map reference falls back to the library default for display, matching resolution.
478 if( std::find( names.begin(), names.end(), active ) == names.end() )
479 {
480 if( const ASSOCIATED_FOOTPRINT* fp = activeAssociatedFootprint( symbol ) )
481 active = fp->m_MapName;
482 }
483
484 for( size_t ii = 0; ii < names.size(); ++ii )
485 {
486 if( names[ii] == active )
487 return wxAny( (int) ii );
488 }
489
490 return wxAny( 0 );
491 }
492};
493
494
495// Stable group caption for the effective pin->pad table rows (issue #2282). Nested under the Pin
496// Map group as one read-only child property per symbol pin.
497static const wxString PIN_MAP_TABLE_GROUP = _HKI( "Effective Pin Map" );
498
499// Caption prefix for a per-pin table property. The property name doubles as its displayed label in
500// wxPropertyGrid, so it is kept human-readable ("Pin <number>") and untranslated for a stable,
501// locale-independent PROPERTY_MANAGER lookup key.
502static const wxString PIN_MAP_ENTRY_PREFIX = wxS( "Pin " );
503
504
513{
514public:
515 SCH_SYMBOL_PIN_MAP_ENTRY_PROPERTY( const wxString& aName, const wxString& aPinNumber ) :
516 PROPERTY_BASE( aName ),
517 m_pinNumber( aPinNumber )
518 {
519 }
520
521 size_t OwnerHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
522 size_t BaseHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
523 size_t TypeHash() const override { return TYPE_HASH( wxString ); }
524
525 bool Writeable( INSPECTABLE* aObject ) const override { return false; }
526
527 void setter( void* obj, wxAny& v ) override {}
528
529 wxAny getter( const void* obj ) const override
530 {
531 const SCH_SYMBOL* symbol = reinterpret_cast<const SCH_SYMBOL*>( obj );
532
533 const SCH_SHEET_PATH* sheetPath = nullptr;
534 wxString variantName;
535
536 if( symbol->Schematic() )
537 {
538 sheetPath = &symbol->Schematic()->CurrentSheet();
539 variantName = symbol->Schematic()->GetCurrentVariant();
540 }
541
542 if( !sheetPath )
543 return wxAny( m_pinNumber );
544
545 for( const SCH_PIN* pin : symbol->GetPins( sheetPath ) )
546 {
547 std::vector<wxString> logical = pin->GetStackedPinNumbers();
548
549 if( std::find( logical.begin(), logical.end(), m_pinNumber ) == logical.end() )
550 continue;
551
552 wxString pad = pin->GetEffectivePadNumber( *sheetPath, variantName );
553
554 if( pad == m_pinNumber )
555 return wxAny( wxString::Format( _( "%s (identity)" ), pad ) );
556
557 return wxAny( pad );
558 }
559
560 return wxAny( m_pinNumber );
561 }
562
563private:
564 wxString m_pinNumber;
565};
566
567
571
573 PROPERTIES_PANEL( aParent, aFrame ),
574 m_frame( aFrame ),
575 m_propMgr( PROPERTY_MANAGER::Instance() ),
576 m_unitEditorInstance( nullptr ),
577 m_checkboxEditorInstance( nullptr ),
578 m_colorEditorInstance( nullptr ),
579 m_fpEditorInstance( nullptr ),
580 m_urlEditorInstance( nullptr ),
581 m_editPinMapButton( nullptr )
582{
583 // Pin Map editor launcher (issue #2282). The button lives below the property grid and is only
584 // shown when a single symbol with an effective associated footprint is selected.
585 m_editPinMapButton = new wxButton( this, wxID_ANY, _( "Edit Pin Map..." ) );
586 m_editPinMapButton->Hide();
587 GetSizer()->Add( m_editPinMapButton, 0, wxALL | wxEXPAND, 5 );
588 m_editPinMapButton->Bind( wxEVT_BUTTON, &SCH_PROPERTIES_PANEL::onEditPinMap, this );
589
590 m_propMgr.Rebuild();
591 bool found = false;
592
593 wxASSERT( wxPGGlobalVars );
594
595 wxString editorKey = PG_UNIT_EDITOR::BuildEditorName( m_frame );
596
597 auto it = wxPGGlobalVars->m_mapEditorClasses.find( editorKey );
598
599 if( it != wxPGGlobalVars->m_mapEditorClasses.end() )
600 {
601 m_unitEditorInstance = static_cast<PG_UNIT_EDITOR*>( it->second );
602 m_unitEditorInstance->UpdateFrame( m_frame );
603 found = true;
604 }
605
606 if( !found )
607 {
608 PG_UNIT_EDITOR* new_editor = new PG_UNIT_EDITOR( m_frame );
609 m_unitEditorInstance = static_cast<PG_UNIT_EDITOR*>( wxPropertyGrid::RegisterEditorClass( new_editor ) );
610 }
611
612 it = wxPGGlobalVars->m_mapEditorClasses.find( PG_CHECKBOX_EDITOR::EDITOR_NAME );
613
614 if( it == wxPGGlobalVars->m_mapEditorClasses.end() )
615 {
616 PG_CHECKBOX_EDITOR* cbEditor = new PG_CHECKBOX_EDITOR();
617 m_checkboxEditorInstance = static_cast<PG_CHECKBOX_EDITOR*>( wxPropertyGrid::RegisterEditorClass( cbEditor ) );
618 }
619 else
620 {
621 m_checkboxEditorInstance = static_cast<PG_CHECKBOX_EDITOR*>( it->second );
622 }
623
624 it = wxPGGlobalVars->m_mapEditorClasses.find( PG_COLOR_EDITOR::EDITOR_NAME );
625
626 if( it == wxPGGlobalVars->m_mapEditorClasses.end() )
627 {
628 PG_COLOR_EDITOR* colorEditor = new PG_COLOR_EDITOR();
629 m_colorEditorInstance = static_cast<PG_COLOR_EDITOR*>( wxPropertyGrid::RegisterEditorClass( colorEditor ) );
630 }
631 else
632 {
633 m_colorEditorInstance = static_cast<PG_COLOR_EDITOR*>( it->second );
634 }
635
636 auto netlistCallback = [this]()
637 {
638 SCH_SELECTION& sel = m_frame->GetToolManager()->GetTool<SCH_SELECTION_TOOL>()->GetSelection();
639 LIB_SYMBOL* libSymbol = nullptr;
640
641 for( EDA_ITEM* item : sel )
642 {
643 if( item->Type() == SCH_SYMBOL_T )
644 {
645 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
646
647 if( !libSymbol )
648 libSymbol = symbol->GetLibSymbolRef().get();
649 else if( libSymbol != symbol->GetLibSymbolRef().get() )
650 return std::string( "" );
651 }
652 }
653
654 if( !libSymbol )
655 return std::string( "" );
656
657 wxString symbolNetlist;
658 wxArrayString pins;
659
660 for( SCH_PIN* pin : libSymbol->GetGraphicalPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
661 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
662
663 if( !pins.IsEmpty() )
664 symbolNetlist << EscapeString( wxJoin( pins, '\t' ), CTX_LINE );
665
666 symbolNetlist << wxS( "\r" );
667
668 wxArrayString fpFilters = libSymbol->GetFPFilters();
669
670 if( !fpFilters.IsEmpty() )
671 symbolNetlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
672
673 symbolNetlist << wxS( "\r" );
674
675 return symbolNetlist.ToStdString();
676 };
677
678 it = wxPGGlobalVars->m_mapEditorClasses.find( PG_FPID_EDITOR::BuildEditorName( m_frame ) );
679
680 if( it != wxPGGlobalVars->m_mapEditorClasses.end() )
681 {
682 m_fpEditorInstance = static_cast<PG_FPID_EDITOR*>( it->second );
683 m_fpEditorInstance->UpdateFrame( m_frame );
684 m_fpEditorInstance->UpdateCallback( netlistCallback );
685 }
686 else
687 {
688 PG_FPID_EDITOR* fpEditor = new PG_FPID_EDITOR( m_frame, netlistCallback );
689 m_fpEditorInstance = static_cast<PG_FPID_EDITOR*>( wxPropertyGrid::RegisterEditorClass( fpEditor ) );
690 }
691
692 it = wxPGGlobalVars->m_mapEditorClasses.find( PG_URL_EDITOR::BuildEditorName( m_frame ) );
693
694 if( it != wxPGGlobalVars->m_mapEditorClasses.end() )
695 {
696 m_urlEditorInstance = static_cast<PG_URL_EDITOR*>( it->second );
697 m_urlEditorInstance->UpdateFrame( m_frame );
698 }
699 else
700 {
701 PG_URL_EDITOR* urlEditor = new PG_URL_EDITOR( m_frame );
702 m_urlEditorInstance = static_cast<PG_URL_EDITOR*>( wxPropertyGrid::RegisterEditorClass( urlEditor ) );
703 }
704}
705
706
708{
709 m_unitEditorInstance->UpdateFrame( nullptr );
710 m_fpEditorInstance->UpdateFrame( nullptr );
711 m_urlEditorInstance->UpdateFrame( nullptr );
712}
713
714
716{
717 SCH_SELECTION_TOOL* selectionTool = m_frame->GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
718 const SELECTION& selection = selectionTool->GetSelection();
719
720 if( selection.Empty() && m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
721 {
722 SYMBOL_EDIT_FRAME* symbolFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
723
724 if( symbolFrame->GetCurSymbol() )
725 {
726 aFallbackSelection.Clear();
727 aFallbackSelection.Add( symbolFrame->GetCurSymbol() );
728 return aFallbackSelection;
729 }
730 }
731
732 return selection;
733}
734
735
737{
738 SELECTION fallbackSelection;
739 const SELECTION& selection = getSelection( fallbackSelection );
740
741 return selection.Empty() ? nullptr : selection.Front();
742}
743
744
746{
747 SELECTION fallbackSelection;
748 const SELECTION& selection = getSelection( fallbackSelection );
749
750 // Will actually just be updatePropertyValues() if selection hasn't changed
751 rebuildProperties( selection );
752}
753
754
756{
757 SELECTION fallbackSelection;
758 const SELECTION& selection = getSelection( fallbackSelection );
759
760 rebuildProperties( selection );
761}
762
763
765{
769
770 // The effective pin->pad table is only meaningful for a single pin-mapped symbol; collecting the
771 // pin numbers here lets the per-pin rows hide for everything else.
772 if( SCH_SYMBOL* pinMapped = getSinglePinMappedSymbol() )
773 {
774 const SCH_SHEET_PATH* sheetPath = pinMapped->Schematic() ? &pinMapped->Schematic()->CurrentSheet() : nullptr;
775
776 if( sheetPath )
777 {
778 // Use logical (stacked-expanded) pin numbers so the rows match the editor grid's keys.
779 for( const SCH_PIN* pin : pinMapped->GetPins( sheetPath ) )
780 {
781 for( const wxString& number : pin->GetStackedPinNumbers() )
782 {
783 if( !number.IsEmpty() )
784 m_currentPinMapPinNumbers.insert( number );
785 }
786 }
787 }
788 }
789
790 for( EDA_ITEM* item : aSelection )
791 {
792 if( item->Type() == SCH_SYMBOL_T )
793 {
794 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
795
796 for( const SCH_FIELD& field : symbol->GetFields() )
797 {
798 if( field.IsPrivate() )
799 continue;
800
801 m_currentSymbolFieldNames.insert( field.GetCanonicalName() );
802 }
803 }
804 else if( item->Type() == SCH_SHEET_T )
805 {
806 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
807
808 for( const SCH_FIELD& field : sheet->GetFields() )
809 {
810 if( field.IsPrivate() )
811 continue;
812
813 m_currentSheetFieldNames.insert( field.GetCanonicalName() );
814 }
815 }
816 }
817
818 const wxString groupFields = _HKI( "Fields" );
819
820 for( const wxString& name : m_currentSymbolFieldNames )
821 {
822 if( !m_propMgr.GetProperty( TYPE_HASH( SCH_SYMBOL ), name ) )
823 {
824 m_propMgr.AddProperty( new SCH_SYMBOL_FIELD_PROPERTY( name ), groupFields )
825 .SetAvailableFunc(
826 [name]( INSPECTABLE* )
827 {
829 } );
830 }
831 }
832
833 for( const wxString& name : m_currentSheetFieldNames )
834 {
835 if( !m_propMgr.GetProperty( TYPE_HASH( SCH_SHEET ), name ) )
836 {
837 m_propMgr.AddProperty( new SCH_SHEET_FIELD_PROPERTY( name ), groupFields )
838 .SetAvailableFunc(
839 [name]( INSPECTABLE* )
840 {
842 } );
843 }
844 }
845
846 // Pin Map group (issue #2282). These properties are only available when the symbol carries at
847 // least one effective associated footprint, so they stay hidden for ordinary symbols.
848 const wxString groupPinMap = PIN_MAP_GROUP;
849
850 if( !m_propMgr.GetProperty( TYPE_HASH( SCH_SYMBOL ), PIN_MAP_FOOTPRINT_PROP ) )
851 {
852 m_propMgr.AddProperty( new SCH_SYMBOL_PIN_MAP_FOOTPRINT_PROPERTY(), groupPinMap )
853 .SetAvailableFunc( symbolHasAssociatedFootprint );
854 }
855
856 if( !m_propMgr.GetProperty( TYPE_HASH( SCH_SYMBOL ), PIN_MAP_MODE_PROP ) )
857 {
858 m_propMgr.AddProperty( new SCH_SYMBOL_PIN_MAP_MODE_PROPERTY(), groupPinMap )
859 .SetAvailableFunc( symbolHasAssociatedFootprint )
860 .SetChoicesFunc(
861 []( INSPECTABLE* ) -> wxPGChoices
862 {
864 } );
865 }
866
867 if( !m_propMgr.GetProperty( TYPE_HASH( SCH_SYMBOL ), PIN_MAP_NAME_PROP ) )
868 {
869 m_propMgr.AddProperty( new SCH_SYMBOL_PIN_MAP_NAME_PROPERTY(), groupPinMap )
870 .SetAvailableFunc(
871 []( INSPECTABLE* aObject )
872 {
873 const SCH_SYMBOL* symbol = dynamic_cast<const SCH_SYMBOL*>( aObject );
874
875 return symbol && symbolHasAssociatedFootprint( aObject )
876 && SCH_SYMBOL_PIN_MAP_NAME_PROPERTY::MapNames( symbol ).size() > 1;
877 } )
878 .SetChoicesFunc(
879 []( INSPECTABLE* aObject ) -> wxPGChoices
880 {
881 if( const SCH_SYMBOL* symbol = dynamic_cast<const SCH_SYMBOL*>( aObject ) )
883
884 return wxPGChoices();
885 } );
886 }
887
888 // One read-only row per symbol pin under a collapsible group, showing the effective pad each pin
889 // resolves to (issue #2282). wxPropertyGrid has no table widget, so the table is expressed as
890 // nested category rows; they register once per pin number and gate on the current selection.
891 const wxString groupPinMapTable = PIN_MAP_TABLE_GROUP;
892
893 for( const wxString& pinNumber : m_currentPinMapPinNumbers )
894 {
895 const wxString propName = PIN_MAP_ENTRY_PREFIX + pinNumber;
896
897 if( !m_propMgr.GetProperty( TYPE_HASH( SCH_SYMBOL ), propName ) )
898 {
899 m_propMgr.AddProperty( new SCH_SYMBOL_PIN_MAP_ENTRY_PROPERTY( propName, pinNumber ), groupPinMapTable )
900 .SetAvailableFunc(
901 [pinNumber]( INSPECTABLE* )
902 {
903 return SCH_PROPERTIES_PANEL::m_currentPinMapPinNumbers.count( pinNumber );
904 } );
905 }
906 }
907
909
910 // The Edit Pin Map button targets the schematic-editor symbol properties dialog, so it is only
911 // shown there for a single pin-mapped symbol.
912 bool showEditButton = m_frame->IsType( FRAME_SCH ) && getSinglePinMappedSymbol() != nullptr;
913
914 if( m_editPinMapButton && m_editPinMapButton->IsShown() != showEditButton )
915 {
916 m_editPinMapButton->Show( showEditButton );
917 Layout();
918 }
919}
920
921
923{
924 SELECTION fallbackSelection;
925 const SELECTION& selection = getSelection( fallbackSelection );
926
927 if( selection.Size() != 1 || selection.Front()->Type() != SCH_SYMBOL_T )
928 return nullptr;
929
930 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( selection.Front() );
931
932 return symbolHasAssociatedFootprint( symbol ) ? symbol : nullptr;
933}
934
935
936void SCH_PROPERTIES_PANEL::onEditPinMap( wxCommandEvent& aEvent )
937{
939
940 if( !symbol || !m_frame->IsType( FRAME_SCH ) )
941 return;
942
943 SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( m_frame );
944
945 DIALOG_SYMBOL_PROPERTIES dlg( editFrame, symbol );
946 dlg.SelectPinMapPage();
947
948 // The dialog can subsequently invoke a KIWAY_PLAYER as a quasimodal frame, so it must run
949 // quasimodally to keep that support working.
950 int retval = dlg.ShowQuasiModal();
951
952 if( retval == SYMBOL_PROPS_EDIT_OK )
953 {
954 editFrame->OnModify();
955 AfterCommit();
956 }
957 else if( retval == SYMBOL_PROPS_WANT_SET_VARIANT_SYMBOL )
958 {
960 }
961 else if( retval == SYMBOL_PROPS_WANT_CLEAR_VARIANT_SYMBOL )
962 {
964 }
965}
966
967
968wxPGProperty* SCH_PROPERTIES_PANEL::createPGProperty( const PROPERTY_BASE* aProperty ) const
969{
970 wxPGProperty* prop = PGPropertyFactory( aProperty, m_frame );
971
972 if( auto colorProp = dynamic_cast<PGPROPERTY_COLOR4D*>( prop ) )
973 {
974 COLOR4D bg = m_frame->GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND );
975 colorProp->SetBackgroundColor( bg );
976 }
977
978 if( aProperty->Name() == GetCanonicalFieldName( FIELD_T::FOOTPRINT ) )
979 prop->SetEditor( PG_FPID_EDITOR::BuildEditorName( m_frame ) );
980 else if( aProperty->Name() == GetCanonicalFieldName( FIELD_T::DATASHEET ) )
981 prop->SetEditor( PG_URL_EDITOR::BuildEditorName( m_frame ) );
982
983 return prop;
984}
985
986
987PROPERTY_BASE* SCH_PROPERTIES_PANEL::getPropertyFromEvent( const wxPropertyGridEvent& aEvent ) const
988{
989 EDA_ITEM* item = const_cast<SCH_PROPERTIES_PANEL*>( this )->getFrontItem();
990
991 if( !item || !item->IsSCH_ITEM() )
992 return nullptr;
993
994 SCH_ITEM* firstItem = static_cast<SCH_ITEM*>( item );
995
996 wxCHECK_MSG( firstItem, nullptr, wxT( "getPropertyFromEvent for a property with nothing selected!") );
997
998 PROPERTY_BASE* property = m_propMgr.GetProperty( TYPE_HASH( *firstItem ), aEvent.GetPropertyName() );
999 wxCHECK_MSG( property, nullptr, wxT( "getPropertyFromEvent for a property not found on the selected item!" ) );
1000
1001 return property;
1002}
1003
1004
1005void SCH_PROPERTIES_PANEL::valueChanging( wxPropertyGridEvent& aEvent )
1006{
1008 return;
1009
1010 EDA_ITEM* frontItem = getFrontItem();
1011
1012 if( !frontItem )
1013 return;
1014
1015 if( PROPERTY_BASE* property = getPropertyFromEvent( aEvent ) )
1016 {
1017 wxVariant newValue = aEvent.GetPropertyValue();
1018
1019 if( VALIDATOR_RESULT validationFailure = property->Validate( newValue.GetAny(), frontItem ) )
1020 {
1021 wxString errorMsg = wxString::Format( wxS( "%s: %s" ), wxGetTranslation( property->Name() ),
1022 validationFailure->get()->Format( m_frame ) );
1023 m_frame->ShowInfoBarError( errorMsg );
1024 aEvent.Veto();
1025 return;
1026 }
1027
1028 aEvent.Skip();
1029 }
1030}
1031
1032
1033void SCH_PROPERTIES_PANEL::valueChanged( wxPropertyGridEvent& aEvent )
1034{
1036 return;
1037
1038 SELECTION fallbackSelection;
1039 const SELECTION& selection = getSelection( fallbackSelection );
1040
1041 wxCHECK( getPropertyFromEvent( aEvent ), /* void */ );
1042
1043 wxVariant newValue = aEvent.GetPropertyValue();
1044 SCH_COMMIT changes( m_frame );
1045 SCH_SCREEN* screen = m_frame->GetScreen();
1046
1047 PROPERTY_COMMIT_HANDLER handler( &changes );
1048
1049 for( EDA_ITEM* edaItem : selection )
1050 {
1051 if( !edaItem->IsSCH_ITEM() )
1052 continue;
1053
1054 SCH_ITEM* item = static_cast<SCH_ITEM*>( edaItem );
1055 PROPERTY_BASE* property = m_propMgr.GetProperty( TYPE_HASH( *item ), aEvent.GetPropertyName() );
1056 wxCHECK2( property, continue );
1057
1058 // Editing reference text in the schematic must go through the parent symbol in order to handle
1059 // symbol instance data properly.
1060 if( item->Type() == SCH_FIELD_T && static_cast<SCH_FIELD*>( item )->GetId() == FIELD_T::REFERENCE
1061 && m_frame->IsType( FRAME_SCH )
1062 && property->Name() == wxT( "Text" ) )
1063 {
1064 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item->GetParentSymbol() );
1065 wxCHECK2( symbol, continue );
1066
1067 changes.Modify( symbol, screen, RECURSE_MODE::NO_RECURSE );
1068 symbol->SetRefProp( newValue.GetString() );
1069 symbol->SyncOtherUnits( symbol->Schematic()->CurrentSheet(), changes, property );
1070 continue;
1071 }
1072
1073 // Editing field text in the schematic when a variant is active must use variant-aware
1074 // SetText to properly store the value as a variant override.
1075 if( item->Type() == SCH_FIELD_T
1076 && m_frame->IsType( FRAME_SCH )
1077 && property->Name() == wxT( "Text" ) )
1078 {
1079 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
1080 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item->GetParentSymbol() );
1081
1082 if( symbol && symbol->Schematic() )
1083 {
1084 wxString variantName = symbol->Schematic()->GetCurrentVariant();
1085
1086 if( !variantName.IsEmpty() )
1087 {
1088 changes.Modify( symbol, screen, RECURSE_MODE::NO_RECURSE );
1089 field->SetText( newValue.GetString(), &symbol->Schematic()->CurrentSheet(), variantName );
1090 symbol->SyncOtherUnits( symbol->Schematic()->CurrentSheet(), changes, nullptr, variantName );
1091 continue;
1092 }
1093 }
1094 }
1095
1096 // Changing a sheet's filename field requires file operations to match the dialog behavior.
1097 if( item->Type() == SCH_FIELD_T
1098 && m_frame->IsType( FRAME_SCH )
1099 && property->Name() == wxT( "Text" ) )
1100 {
1101 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
1102 SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( item->GetParent() );
1103
1104 if( sheet && field->GetId() == FIELD_T::SHEET_FILENAME )
1105 {
1106 SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( m_frame );
1107
1108 if( !handleSheetFilenameChange( editFrame, sheet, changes, newValue.GetString() ) )
1109 {
1110 UpdateData();
1111 return;
1112 }
1113
1114 continue;
1115 }
1116 }
1117
1118 if( item->Type() == SCH_TABLECELL_T )
1119 changes.Modify( item->GetParent(), screen, RECURSE_MODE::NO_RECURSE );
1120 else
1121 changes.Modify( item, screen, RECURSE_MODE::NO_RECURSE );
1122
1123 item->Set( property, newValue );
1124
1125 if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item ) )
1126 {
1127 symbol->SyncOtherUnits( symbol->Schematic()->CurrentSheet(), changes, property,
1128 symbol->Schematic()->GetCurrentVariant() );
1129 }
1130 }
1131
1132 changes.Push( _( "Edit Properties" ) );
1133
1134 // Force a repaint of the items whose properties were changed
1135 // This is necessary to update field displays in the schematic view
1136 for( EDA_ITEM* edaItem : selection )
1137 m_frame->UpdateItem( edaItem );
1138
1139 // Perform grid updates as necessary based on value change
1140 AfterCommit();
1141
1142 aEvent.Skip();
1143}
1144
1145
1147 SCH_COMMIT& aChanges,
1148 const wxString& aNewFilename )
1149{
1150 wxString newFilename = EnsureFileExtension( aNewFilename, FILEEXT::KiCadSchematicFileExtension );
1151
1152 if( newFilename.IsEmpty() || !IsFullFileNameValid( newFilename ) )
1153 {
1154 DisplayError( aFrame, _( "A sheet must have a valid file name." ) );
1155 return false;
1156 }
1157
1158 // Normalize separators to unix notation
1159 newFilename.Replace( wxT( "\\" ), wxT( "/" ) );
1160
1161 wxString oldFilename = aSheet->GetFileName();
1162 oldFilename.Replace( wxT( "\\" ), wxT( "/" ) );
1163
1164 if( newFilename == oldFilename )
1165 return true;
1166
1167 if( !aFrame->ChangeSheetFile( aSheet, newFilename ) )
1168 return false;
1169
1170 SCH_SCREEN* currentScreen = aFrame->GetCurrentSheet().LastScreen();
1171 aChanges.Modify( aSheet, currentScreen, RECURSE_MODE::NO_RECURSE );
1172 aSheet->SetFileName( newFilename );
1173
1174 return true;
1175}
1176
1177
1178void SCH_PROPERTIES_PANEL::OnLanguageChanged( wxCommandEvent& aEvent )
1179{
1181
1182 aEvent.Skip();
1183}
1184
1185
1186bool SCH_PROPERTIES_PANEL::getItemValue( EDA_ITEM* aItem, PROPERTY_BASE* aProperty, wxVariant& aValue )
1187{
1188 // For SCH_FIELD "Text" property, return the variant-aware value when a variant is active
1189 if( aItem->Type() == SCH_FIELD_T
1190 && m_frame->IsType( FRAME_SCH )
1191 && aProperty->Name() == wxT( "Text" ) )
1192 {
1193 SCH_FIELD* field = static_cast<SCH_FIELD*>( aItem );
1194 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( field->GetParentSymbol() );
1195
1196 if( symbol && symbol->Schematic() )
1197 {
1198 wxString variantName = symbol->Schematic()->GetCurrentVariant();
1199
1200 if( !variantName.IsEmpty() )
1201 {
1202 wxString text = field->GetText( &symbol->Schematic()->CurrentSheet(), variantName );
1203 aValue = wxVariant( text );
1204 return true;
1205 }
1206 }
1207 }
1208
1209 return PROPERTIES_PANEL::getItemValue( aItem, aProperty, aValue );
1210}
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:114
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:242
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
static TOOL_ACTION clearVariantSymbol
static TOOL_ACTION setVariantSymbol
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)
A null aItem is ignored; the selection never holds null members.
Definition selection.cpp:38
EDA_ITEM * Front() const
Definition selection.h:176
virtual void Clear() override
Remove all the stored items from the group.
Definition selection.h:97
int Size() const
Returns the number of selected parts.
Definition selection.h:120
bool Empty() const
Checks if there is anything selected.
Definition selection.h:114
The symbol library editor main window.
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
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_WANT_SET_VARIANT_SYMBOL
@ SYMBOL_PROPS_EDIT_OK
@ SYMBOL_PROPS_WANT_CLEAR_VARIANT_SYMBOL
#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:494
#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.