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 along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
23
24#include <font/fontconfig.h>
25#include <pgm_base.h>
26#include <common.h>
27#include <confirm.h>
28#include <connection_graph.h>
32#include <properties/property.h>
33#include <sch_commit.h>
34#include <sch_edit_frame.h>
35#include <sch_sheet.h>
36#include <symbol_edit_frame.h>
37#include <symbol_viewer_frame.h>
38#include <schematic.h>
39#include <sch_symbol.h>
40#include <sch_field.h>
41#include <template_fieldnames.h>
43#include <string_utils.h>
44#include <tool/tool_manager.h>
47#include <wx_filename.h>
48#include <set>
49
50static const wxString MISSING_FIELD_SENTINEL = wxS( "\uE000" );
51
53{
54public:
55 SCH_SYMBOL_FIELD_PROPERTY( const wxString& aName ) :
56 PROPERTY_BASE( aName ),
57 m_name( aName )
58 { }
59
60 size_t OwnerHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
61 size_t BaseHash() const override { return TYPE_HASH( SCH_SYMBOL ); }
62 size_t TypeHash() const override { return TYPE_HASH( wxString ); }
63
64 bool Writeable( INSPECTABLE* aObject ) const override
65 {
66 return PROPERTY_BASE::Writeable( aObject );
67 }
68
69 void setter( void* obj, wxAny& v ) override
70 {
71 wxString value;
72
73 if( !v.GetAs( &value ) )
74 return;
75
76 SCH_SYMBOL* symbol = reinterpret_cast<SCH_SYMBOL*>( obj );
77 SCH_FIELD* field = symbol->GetField( m_name );
78
79 wxString variantName;
80 const SCH_SHEET_PATH* sheetPath = nullptr;
81
82 if( symbol->Schematic() )
83 {
84 variantName = symbol->Schematic()->GetCurrentVariant();
85 sheetPath = &symbol->Schematic()->CurrentSheet();
86 }
87
88 if( !field )
89 {
90 SCH_FIELD newField( symbol, FIELD_T::USER, m_name );
91 newField.SetText( value, sheetPath, variantName );
92 symbol->AddField( newField );
93 }
94 else
95 {
96 field->SetText( value, sheetPath, variantName );
97 }
98 }
99
100 wxAny getter( const void* obj ) const override
101 {
102 const SCH_SYMBOL* symbol = reinterpret_cast<const SCH_SYMBOL*>( obj );
103 const SCH_FIELD* field = symbol->GetField( m_name );
104
105 if( field )
106 {
107 wxString variantName;
108 const SCH_SHEET_PATH* sheetPath = nullptr;
109
110 if( symbol->Schematic() )
111 {
112 variantName = symbol->Schematic()->GetCurrentVariant();
113 sheetPath = &symbol->Schematic()->CurrentSheet();
114 }
115
116 wxString text;
117
118 if( !variantName.IsEmpty() && sheetPath )
119 text = field->GetText( sheetPath, variantName );
120 else
121 text = field->GetText();
122
123 return wxAny( text );
124 }
125 else
126 {
127 return wxAny( MISSING_FIELD_SENTINEL );
128 }
129 }
130
131private:
132 wxString m_name;
133};
134
136{
137public:
138 SCH_SHEET_FIELD_PROPERTY( const wxString& aName ) :
139 PROPERTY_BASE( aName ),
140 m_name( aName )
141 {
142 }
143
144 size_t OwnerHash() const override { return TYPE_HASH( SCH_SHEET ); }
145 size_t BaseHash() const override { return TYPE_HASH( SCH_SHEET ); }
146 size_t TypeHash() const override { return TYPE_HASH( wxString ); }
147
148 bool Writeable( INSPECTABLE* aObject ) const override { return PROPERTY_BASE::Writeable( aObject ); }
149
150 void setter( void* obj, wxAny& v ) override
151 {
152 wxString value;
153
154 if( !v.GetAs( &value ) )
155 return;
156
157 SCH_SHEET* sheet = reinterpret_cast<SCH_SHEET*>( obj );
158 SCH_FIELD* field = sheet->GetField( m_name );
159
160 wxString variantName;
161 const SCH_SHEET_PATH* sheetPath = nullptr;
162
163 if( sheet->Schematic() )
164 {
165 variantName = sheet->Schematic()->GetCurrentVariant();
166 sheetPath = &sheet->Schematic()->CurrentSheet();
167 }
168
169 if( !field )
170 {
171 SCH_FIELD newField( sheet, FIELD_T::USER, m_name );
172 newField.SetText( value, sheetPath, variantName );
173 sheet->AddField( newField );
174 }
175 else
176 {
177 field->SetText( value, sheetPath, variantName );
178 }
179 }
180
181 wxAny getter( const void* obj ) const override
182 {
183 const SCH_SHEET* sheet = reinterpret_cast<const SCH_SHEET*>( obj );
184 const SCH_FIELD* field = sheet->GetField( m_name );
185
186 if( field )
187 {
188 wxString variantName;
189 const SCH_SHEET_PATH* sheetPath = nullptr;
190
191 if( sheet->Schematic() )
192 {
193 variantName = sheet->Schematic()->GetCurrentVariant();
194 sheetPath = &sheet->Schematic()->CurrentSheet();
195 }
196
197 wxString text;
198
199 if( !variantName.IsEmpty() && sheetPath )
200 text = field->GetText( sheetPath, variantName );
201 else
202 text = field->GetText();
203
204 return wxAny( text );
205 }
206 else
207 {
208 return wxAny( MISSING_FIELD_SENTINEL );
209 }
210 }
211
212private:
213 wxString m_name;
214};
215
218
220 PROPERTIES_PANEL( aParent, aFrame ),
221 m_frame( aFrame ),
222 m_propMgr( PROPERTY_MANAGER::Instance() ),
223 m_unitEditorInstance( nullptr ),
224 m_checkboxEditorInstance( nullptr ),
225 m_colorEditorInstance( nullptr ),
226 m_fpEditorInstance( nullptr ),
227 m_urlEditorInstance( nullptr )
228{
229 m_propMgr.Rebuild();
230 bool found = false;
231
232 wxASSERT( wxPGGlobalVars );
233
234 wxString editorKey = PG_UNIT_EDITOR::BuildEditorName( m_frame );
235
236 auto it = wxPGGlobalVars->m_mapEditorClasses.find( editorKey );
237
238 if( it != wxPGGlobalVars->m_mapEditorClasses.end() )
239 {
240 m_unitEditorInstance = static_cast<PG_UNIT_EDITOR*>( it->second );
241 m_unitEditorInstance->UpdateFrame( m_frame );
242 found = true;
243 }
244
245 if( !found )
246 {
247 PG_UNIT_EDITOR* new_editor = new PG_UNIT_EDITOR( m_frame );
248 m_unitEditorInstance = static_cast<PG_UNIT_EDITOR*>( wxPropertyGrid::RegisterEditorClass( new_editor ) );
249 }
250
251 it = wxPGGlobalVars->m_mapEditorClasses.find( PG_CHECKBOX_EDITOR::EDITOR_NAME );
252
253 if( it == wxPGGlobalVars->m_mapEditorClasses.end() )
254 {
255 PG_CHECKBOX_EDITOR* cbEditor = new PG_CHECKBOX_EDITOR();
256 m_checkboxEditorInstance = static_cast<PG_CHECKBOX_EDITOR*>( wxPropertyGrid::RegisterEditorClass( cbEditor ) );
257 }
258 else
259 {
260 m_checkboxEditorInstance = static_cast<PG_CHECKBOX_EDITOR*>( it->second );
261 }
262
263 it = wxPGGlobalVars->m_mapEditorClasses.find( PG_COLOR_EDITOR::EDITOR_NAME );
264
265 if( it == wxPGGlobalVars->m_mapEditorClasses.end() )
266 {
267 PG_COLOR_EDITOR* colorEditor = new PG_COLOR_EDITOR();
268 m_colorEditorInstance = static_cast<PG_COLOR_EDITOR*>( wxPropertyGrid::RegisterEditorClass( colorEditor ) );
269 }
270 else
271 {
272 m_colorEditorInstance = static_cast<PG_COLOR_EDITOR*>( it->second );
273 }
274
275 auto netlistCallback = [this]()
276 {
277 SCH_SELECTION& sel = m_frame->GetToolManager()->GetTool<SCH_SELECTION_TOOL>()->GetSelection();
278 LIB_SYMBOL* libSymbol = nullptr;
279
280 for( EDA_ITEM* item : sel )
281 {
282 if( item->Type() == SCH_SYMBOL_T )
283 {
284 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
285
286 if( !libSymbol )
287 libSymbol = symbol->GetLibSymbolRef().get();
288 else if( libSymbol != symbol->GetLibSymbolRef().get() )
289 return std::string( "" );
290 }
291 }
292
293 if( !libSymbol )
294 return std::string( "" );
295
296 wxString symbolNetlist;
297 wxArrayString pins;
298
299 for( SCH_PIN* pin : libSymbol->GetGraphicalPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
300 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
301
302 if( !pins.IsEmpty() )
303 symbolNetlist << EscapeString( wxJoin( pins, '\t' ), CTX_LINE );
304
305 symbolNetlist << wxS( "\r" );
306
307 wxArrayString fpFilters = libSymbol->GetFPFilters();
308
309 if( !fpFilters.IsEmpty() )
310 symbolNetlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
311
312 symbolNetlist << wxS( "\r" );
313
314 return symbolNetlist.ToStdString();
315 };
316
317 it = wxPGGlobalVars->m_mapEditorClasses.find( PG_FPID_EDITOR::BuildEditorName( m_frame ) );
318
319 if( it != wxPGGlobalVars->m_mapEditorClasses.end() )
320 {
321 m_fpEditorInstance = static_cast<PG_FPID_EDITOR*>( it->second );
322 m_fpEditorInstance->UpdateFrame( m_frame );
323 m_fpEditorInstance->UpdateCallback( netlistCallback );
324 }
325 else
326 {
327 PG_FPID_EDITOR* fpEditor = new PG_FPID_EDITOR( m_frame, netlistCallback );
328 m_fpEditorInstance = static_cast<PG_FPID_EDITOR*>( wxPropertyGrid::RegisterEditorClass( fpEditor ) );
329 }
330
331 it = wxPGGlobalVars->m_mapEditorClasses.find( PG_URL_EDITOR::BuildEditorName( m_frame ) );
332
333 if( it != wxPGGlobalVars->m_mapEditorClasses.end() )
334 {
335 m_urlEditorInstance = static_cast<PG_URL_EDITOR*>( it->second );
336 m_urlEditorInstance->UpdateFrame( m_frame );
337 }
338 else
339 {
340 PG_URL_EDITOR* urlEditor = new PG_URL_EDITOR( m_frame );
341 m_urlEditorInstance = static_cast<PG_URL_EDITOR*>( wxPropertyGrid::RegisterEditorClass( urlEditor ) );
342 }
343}
344
345
347{
348 m_unitEditorInstance->UpdateFrame( nullptr );
349 m_fpEditorInstance->UpdateFrame( nullptr );
350 m_urlEditorInstance->UpdateFrame( nullptr );
351}
352
353
355{
356 SCH_SELECTION_TOOL* selectionTool = m_frame->GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
357 const SELECTION& selection = selectionTool->GetSelection();
358
359 if( selection.Empty() && m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
360 {
361 SYMBOL_EDIT_FRAME* symbolFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
362
363 if( symbolFrame->GetCurSymbol() )
364 {
365 aFallbackSelection.Clear();
366 aFallbackSelection.Add( symbolFrame->GetCurSymbol() );
367 return aFallbackSelection;
368 }
369 }
370
371 return selection;
372}
373
374
376{
377 SELECTION fallbackSelection;
378 const SELECTION& selection = getSelection( fallbackSelection );
379
380 return selection.Empty() ? nullptr : selection.Front();
381}
382
383
385{
386 SELECTION fallbackSelection;
387 const SELECTION& selection = getSelection( fallbackSelection );
388
389 // Will actually just be updatePropertyValues() if selection hasn't changed
390 rebuildProperties( selection );
391}
392
393
395{
396 SELECTION fallbackSelection;
397 const SELECTION& selection = getSelection( fallbackSelection );
398
399 rebuildProperties( selection );
400}
401
402
404{
407
408 for( EDA_ITEM* item : aSelection )
409 {
410 if( item->Type() == SCH_SYMBOL_T )
411 {
412 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
413
414 for( const SCH_FIELD& field : symbol->GetFields() )
415 {
416 if( field.IsPrivate() )
417 continue;
418
419 m_currentSymbolFieldNames.insert( field.GetCanonicalName() );
420 }
421 }
422 else if( item->Type() == SCH_SHEET_T )
423 {
424 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
425
426 for( const SCH_FIELD& field : sheet->GetFields() )
427 {
428 if( field.IsPrivate() )
429 continue;
430
431 m_currentSheetFieldNames.insert( field.GetCanonicalName() );
432 }
433 }
434 }
435
436 const wxString groupFields = _HKI( "Fields" );
437
438 for( const wxString& name : m_currentSymbolFieldNames )
439 {
440 if( !m_propMgr.GetProperty( TYPE_HASH( SCH_SYMBOL ), name ) )
441 {
442 m_propMgr.AddProperty( new SCH_SYMBOL_FIELD_PROPERTY( name ), groupFields )
443 .SetAvailableFunc(
444 [name]( INSPECTABLE* )
445 {
447 } );
448 }
449 }
450
451 for( const wxString& name : m_currentSheetFieldNames )
452 {
453 if( !m_propMgr.GetProperty( TYPE_HASH( SCH_SHEET ), name ) )
454 {
455 m_propMgr.AddProperty( new SCH_SHEET_FIELD_PROPERTY( name ), groupFields )
456 .SetAvailableFunc(
457 [name]( INSPECTABLE* )
458 {
460 } );
461 }
462 }
463
465}
466
467
468wxPGProperty* SCH_PROPERTIES_PANEL::createPGProperty( const PROPERTY_BASE* aProperty ) const
469{
470 wxPGProperty* prop = PGPropertyFactory( aProperty, m_frame );
471
472 if( auto colorProp = dynamic_cast<PGPROPERTY_COLOR4D*>( prop ) )
473 {
474 COLOR4D bg = m_frame->GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND );
475 colorProp->SetBackgroundColor( bg );
476 }
477
478 if( aProperty->Name() == GetCanonicalFieldName( FIELD_T::FOOTPRINT ) )
479 prop->SetEditor( PG_FPID_EDITOR::BuildEditorName( m_frame ) );
480 else if( aProperty->Name() == GetCanonicalFieldName( FIELD_T::DATASHEET ) )
481 prop->SetEditor( PG_URL_EDITOR::BuildEditorName( m_frame ) );
482
483 return prop;
484}
485
486
487PROPERTY_BASE* SCH_PROPERTIES_PANEL::getPropertyFromEvent( const wxPropertyGridEvent& aEvent ) const
488{
489 EDA_ITEM* item = const_cast<SCH_PROPERTIES_PANEL*>( this )->getFrontItem();
490
491 if( !item || !item->IsSCH_ITEM() )
492 return nullptr;
493
494 SCH_ITEM* firstItem = static_cast<SCH_ITEM*>( item );
495
496 wxCHECK_MSG( firstItem, nullptr, wxT( "getPropertyFromEvent for a property with nothing selected!") );
497
498 PROPERTY_BASE* property = m_propMgr.GetProperty( TYPE_HASH( *firstItem ), aEvent.GetPropertyName() );
499 wxCHECK_MSG( property, nullptr, wxT( "getPropertyFromEvent for a property not found on the selected item!" ) );
500
501 return property;
502}
503
504
505void SCH_PROPERTIES_PANEL::valueChanging( wxPropertyGridEvent& aEvent )
506{
508 return;
509
510 EDA_ITEM* frontItem = getFrontItem();
511
512 if( !frontItem )
513 return;
514
515 if( PROPERTY_BASE* property = getPropertyFromEvent( aEvent ) )
516 {
517 wxVariant newValue = aEvent.GetPropertyValue();
518
519 if( VALIDATOR_RESULT validationFailure = property->Validate( newValue.GetAny(), frontItem ) )
520 {
521 wxString errorMsg = wxString::Format( wxS( "%s: %s" ), wxGetTranslation( property->Name() ),
522 validationFailure->get()->Format( m_frame ) );
523 m_frame->ShowInfoBarError( errorMsg );
524 aEvent.Veto();
525 return;
526 }
527
528 aEvent.Skip();
529 }
530}
531
532
533void SCH_PROPERTIES_PANEL::valueChanged( wxPropertyGridEvent& aEvent )
534{
536 return;
537
538 SELECTION fallbackSelection;
539 const SELECTION& selection = getSelection( fallbackSelection );
540
541 wxCHECK( getPropertyFromEvent( aEvent ), /* void */ );
542
543 wxVariant newValue = aEvent.GetPropertyValue();
544 SCH_COMMIT changes( m_frame );
545 SCH_SCREEN* screen = m_frame->GetScreen();
546
547 PROPERTY_COMMIT_HANDLER handler( &changes );
548
549 for( EDA_ITEM* edaItem : selection )
550 {
551 if( !edaItem->IsSCH_ITEM() )
552 continue;
553
554 SCH_ITEM* item = static_cast<SCH_ITEM*>( edaItem );
555 PROPERTY_BASE* property = m_propMgr.GetProperty( TYPE_HASH( *item ), aEvent.GetPropertyName() );
556 wxCHECK2( property, continue );
557
558 // Editing reference text in the schematic must go through the parent symbol in order to handle
559 // symbol instance data properly.
560 if( item->Type() == SCH_FIELD_T && static_cast<SCH_FIELD*>( item )->GetId() == FIELD_T::REFERENCE
561 && m_frame->IsType( FRAME_SCH )
562 && property->Name() == wxT( "Text" ) )
563 {
564 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item->GetParentSymbol() );
565 wxCHECK2( symbol, continue );
566
567 changes.Modify( symbol, screen, RECURSE_MODE::NO_RECURSE );
568 symbol->SetRefProp( newValue.GetString() );
569 symbol->SyncOtherUnits( symbol->Schematic()->CurrentSheet(), changes, property );
570 continue;
571 }
572
573 // Editing field text in the schematic when a variant is active must use variant-aware
574 // SetText to properly store the value as a variant override.
575 if( item->Type() == SCH_FIELD_T
576 && m_frame->IsType( FRAME_SCH )
577 && property->Name() == wxT( "Text" ) )
578 {
579 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
580 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item->GetParentSymbol() );
581
582 if( symbol && symbol->Schematic() )
583 {
584 wxString variantName = symbol->Schematic()->GetCurrentVariant();
585
586 if( !variantName.IsEmpty() )
587 {
588 changes.Modify( symbol, screen, RECURSE_MODE::NO_RECURSE );
589 field->SetText( newValue.GetString(), &symbol->Schematic()->CurrentSheet(), variantName );
590 symbol->SyncOtherUnits( symbol->Schematic()->CurrentSheet(), changes, property,
591 variantName );
592 continue;
593 }
594 }
595 }
596
597 // Changing a sheet's filename field requires file operations to match the dialog behavior.
598 if( item->Type() == SCH_FIELD_T
599 && m_frame->IsType( FRAME_SCH )
600 && property->Name() == wxT( "Text" ) )
601 {
602 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
603 SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( item->GetParent() );
604
605 if( sheet && field->GetId() == FIELD_T::SHEET_FILENAME )
606 {
607 SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( m_frame );
608
609 if( !handleSheetFilenameChange( editFrame, sheet, changes, newValue.GetString() ) )
610 {
611 UpdateData();
612 return;
613 }
614
615 continue;
616 }
617 }
618
619 if( item->Type() == SCH_TABLECELL_T )
620 changes.Modify( item->GetParent(), screen, RECURSE_MODE::NO_RECURSE );
621 else
622 changes.Modify( item, screen, RECURSE_MODE::NO_RECURSE );
623
624 item->Set( property, newValue );
625
626 if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item ) )
627 {
628 symbol->SyncOtherUnits( symbol->Schematic()->CurrentSheet(), changes, property,
629 symbol->Schematic()->GetCurrentVariant() );
630 }
631 }
632
633 changes.Push( _( "Edit Properties" ) );
634
635 // Force a repaint of the items whose properties were changed
636 // This is necessary to update field displays in the schematic view
637 for( EDA_ITEM* edaItem : selection )
638 m_frame->UpdateItem( edaItem );
639
640 // Perform grid updates as necessary based on value change
641 AfterCommit();
642
643 aEvent.Skip();
644}
645
646
648 SCH_COMMIT& aChanges,
649 const wxString& aNewFilename )
650{
651 wxString newFilename = EnsureFileExtension( aNewFilename, FILEEXT::KiCadSchematicFileExtension );
652
653 if( newFilename.IsEmpty() || !IsFullFileNameValid( newFilename ) )
654 {
655 DisplayError( aFrame, _( "A sheet must have a valid file name." ) );
656 return false;
657 }
658
659 // Normalize separators to unix notation
660 newFilename.Replace( wxT( "\\" ), wxT( "/" ) );
661
662 wxString oldFilename = aSheet->GetFileName();
663 oldFilename.Replace( wxT( "\\" ), wxT( "/" ) );
664
665 if( newFilename == oldFilename )
666 return true;
667
668 if( !aFrame->ChangeSheetFile( aSheet, newFilename ) )
669 return false;
670
671 SCH_SCREEN* currentScreen = aFrame->GetCurrentSheet().LastScreen();
672 aChanges.Modify( aSheet, currentScreen, RECURSE_MODE::NO_RECURSE );
673 aSheet->SetFileName( newFilename );
674
675 return true;
676}
677
678
679void SCH_PROPERTIES_PANEL::OnLanguageChanged( wxCommandEvent& aEvent )
680{
682
683 aEvent.Skip();
684}
685
686
687bool SCH_PROPERTIES_PANEL::getItemValue( EDA_ITEM* aItem, PROPERTY_BASE* aProperty, wxVariant& aValue )
688{
689 // For SCH_FIELD "Text" property, return the variant-aware value when a variant is active
690 if( aItem->Type() == SCH_FIELD_T
691 && m_frame->IsType( FRAME_SCH )
692 && aProperty->Name() == wxT( "Text" ) )
693 {
694 SCH_FIELD* field = static_cast<SCH_FIELD*>( aItem );
695 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( field->GetParentSymbol() );
696
697 if( symbol && symbol->Schematic() )
698 {
699 wxString variantName = symbol->Schematic()->GetCurrentVariant();
700
701 if( !variantName.IsEmpty() )
702 {
703 wxString text = field->GetText( &symbol->Schematic()->CurrentSheet(), variantName );
704 aValue = wxVariant( text );
705 return true;
706 }
707 }
708 }
709
710 return PROPERTIES_PANEL::getItemValue( aItem, aProperty, aValue );
711}
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:106
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:100
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:112
EDA_ITEM * GetParent() const
Definition eda_item.h:114
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:105
bool IsSCH_ITEM() const
Definition view_item.h:101
Define a library symbol object.
Definition lib_symbol.h:83
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:211
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)
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:188
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.
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:177
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:123
FIELD_T GetId() const
Definition sch_field.h:127
void SetText(const wxString &aText) override
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:168
const SYMBOL * GetParentSymbol() const
Definition sch_item.cpp:275
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:269
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
PG_FPID_EDITOR * m_fpEditorInstance
const SELECTION & getSelection(SELECTION &aFallbackSelection)
Get the current selection from the selection tool.
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_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:48
void SetFileName(const wxString &aFilename)
Definition sch_sheet.h:377
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition sch_sheet.h:371
std::vector< SCH_FIELD > & GetFields()
Return a reference to the vector holding the sheet's fields.
Definition sch_sheet.h:88
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
Schematic symbol object.
Definition sch_symbol.h:76
void SetRefProp(const wxString &aRef)
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:184
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
virtual void Add(EDA_ITEM *aItem)
Definition selection.cpp:42
EDA_ITEM * Front() const
Definition selection.h:177
virtual void Clear() override
Remove all the stored items from the group.
Definition selection.h:98
bool Empty() const
Checks if there is anything selected.
Definition selection.h:115
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:629
The common library.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition confirm.cpp:177
This file is part of the common library.
#define _(s)
@ NO_RECURSE
Definition eda_item.h:54
@ FRAME_SCH_SYMBOL_EDITOR
Definition frame_type.h:35
@ FRAME_SCH
Definition frame_type.h:34
static const std::string KiCadSchematicFileExtension
@ LAYER_SCHEMATIC_BACKGROUND
Definition layer_ids.h:490
#define _HKI(x)
Definition page_info.cpp:44
wxPGProperty * PGPropertyFactory(const PROPERTY_BASE *aProperty, EDA_DRAW_FRAME *aFrame)
Customized abstract wxPGProperty class to handle coordinate/size units.
see class PGM_BASE
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 MISSING_FIELD_SENTINEL
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
@ 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:173
@ SCH_TABLECELL_T
Definition typeinfo.h:167
@ SCH_FIELD_T
Definition typeinfo.h:151
@ SCH_SHEET_T
Definition typeinfo.h:176
Definition of file extensions used in Kicad.