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
138 PROPERTIES_PANEL( aParent, aFrame ),
139 m_frame( aFrame ),
140 m_propMgr( PROPERTY_MANAGER::Instance() ),
141 m_unitEditorInstance( nullptr ),
142 m_checkboxEditorInstance( nullptr ),
143 m_colorEditorInstance( nullptr ),
144 m_fpEditorInstance( nullptr ),
145 m_urlEditorInstance( nullptr )
146{
147 m_propMgr.Rebuild();
148 bool found = false;
149
150 wxASSERT( wxPGGlobalVars );
151
152 wxString editorKey = PG_UNIT_EDITOR::BuildEditorName( m_frame );
153
154 auto it = wxPGGlobalVars->m_mapEditorClasses.find( editorKey );
155
156 if( it != wxPGGlobalVars->m_mapEditorClasses.end() )
157 {
158 m_unitEditorInstance = static_cast<PG_UNIT_EDITOR*>( it->second );
159 m_unitEditorInstance->UpdateFrame( m_frame );
160 found = true;
161 }
162
163 if( !found )
164 {
165 PG_UNIT_EDITOR* new_editor = new PG_UNIT_EDITOR( m_frame );
166 m_unitEditorInstance = static_cast<PG_UNIT_EDITOR*>( wxPropertyGrid::RegisterEditorClass( new_editor ) );
167 }
168
169 it = wxPGGlobalVars->m_mapEditorClasses.find( PG_CHECKBOX_EDITOR::EDITOR_NAME );
170
171 if( it == wxPGGlobalVars->m_mapEditorClasses.end() )
172 {
173 PG_CHECKBOX_EDITOR* cbEditor = new PG_CHECKBOX_EDITOR();
174 m_checkboxEditorInstance = static_cast<PG_CHECKBOX_EDITOR*>( wxPropertyGrid::RegisterEditorClass( cbEditor ) );
175 }
176 else
177 {
178 m_checkboxEditorInstance = static_cast<PG_CHECKBOX_EDITOR*>( it->second );
179 }
180
181 it = wxPGGlobalVars->m_mapEditorClasses.find( PG_COLOR_EDITOR::EDITOR_NAME );
182
183 if( it == wxPGGlobalVars->m_mapEditorClasses.end() )
184 {
185 PG_COLOR_EDITOR* colorEditor = new PG_COLOR_EDITOR();
186 m_colorEditorInstance = static_cast<PG_COLOR_EDITOR*>( wxPropertyGrid::RegisterEditorClass( colorEditor ) );
187 }
188 else
189 {
190 m_colorEditorInstance = static_cast<PG_COLOR_EDITOR*>( it->second );
191 }
192
193 it = wxPGGlobalVars->m_mapEditorClasses.find( PG_FPID_EDITOR::BuildEditorName( m_frame ) );
194
195 if( it != wxPGGlobalVars->m_mapEditorClasses.end() )
196 {
197 m_fpEditorInstance = static_cast<PG_FPID_EDITOR*>( it->second );
198 m_fpEditorInstance->UpdateFrame( m_frame );
199 }
200 else
201 {
202 PG_FPID_EDITOR* fpEditor = new PG_FPID_EDITOR( m_frame,
203 [this]()
204 {
205 SCH_SELECTION& sel = m_frame->GetToolManager()->GetTool<SCH_SELECTION_TOOL>()->GetSelection();
206 LIB_SYMBOL* libSymbol = nullptr;
207
208 for( EDA_ITEM* item : sel )
209 {
210 if( item->Type() == SCH_SYMBOL_T )
211 {
212 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
213
214 if( !libSymbol )
215 libSymbol = symbol->GetLibSymbolRef().get();
216 else if( libSymbol != symbol->GetLibSymbolRef().get() )
217 return std::string( "" );
218 }
219 }
220
221 if( !libSymbol )
222 return std::string( "" );
223
224 wxString symbolNetlist;
225 wxArrayString pins;
226
227 for( SCH_PIN* pin : libSymbol->GetGraphicalPins( 0 /* all units */, 1 /* single bodyStyle */ ) )
228 pins.push_back( pin->GetNumber() + ' ' + pin->GetShownName() );
229
230 if( !pins.IsEmpty() )
231 symbolNetlist << EscapeString( wxJoin( pins, '\t' ), CTX_LINE );
232
233 symbolNetlist << wxS( "\r" );
234
235 wxArrayString fpFilters = libSymbol->GetFPFilters();
236
237 if( !fpFilters.IsEmpty() )
238 symbolNetlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
239
240 symbolNetlist << wxS( "\r" );
241
242 return symbolNetlist.ToStdString();
243 } );
244 m_fpEditorInstance = static_cast<PG_FPID_EDITOR*>( wxPropertyGrid::RegisterEditorClass( fpEditor ) );
245 }
246
247 it = wxPGGlobalVars->m_mapEditorClasses.find( PG_URL_EDITOR::BuildEditorName( m_frame ) );
248
249 if( it != wxPGGlobalVars->m_mapEditorClasses.end() )
250 {
251 m_urlEditorInstance = static_cast<PG_URL_EDITOR*>( it->second );
252 m_urlEditorInstance->UpdateFrame( m_frame );
253 }
254 else
255 {
256 PG_URL_EDITOR* urlEditor = new PG_URL_EDITOR( m_frame );
257 m_urlEditorInstance = static_cast<PG_URL_EDITOR*>( wxPropertyGrid::RegisterEditorClass( urlEditor ) );
258 }
259}
260
261
263{
264 m_unitEditorInstance->UpdateFrame( nullptr );
265 m_fpEditorInstance->UpdateFrame( nullptr );
266 m_urlEditorInstance->UpdateFrame( nullptr );
267}
268
269
271{
272 SCH_SELECTION_TOOL* selectionTool = m_frame->GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
273 const SELECTION& selection = selectionTool->GetSelection();
274
275 if( selection.Empty() && m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
276 {
277 SYMBOL_EDIT_FRAME* symbolFrame = static_cast<SYMBOL_EDIT_FRAME*>( m_frame );
278
279 if( symbolFrame->GetCurSymbol() )
280 {
281 aFallbackSelection.Clear();
282 aFallbackSelection.Add( symbolFrame->GetCurSymbol() );
283 return aFallbackSelection;
284 }
285 }
286
287 return selection;
288}
289
290
292{
293 SELECTION fallbackSelection;
294 const SELECTION& selection = getSelection( fallbackSelection );
295
296 return selection.Empty() ? nullptr : selection.Front();
297}
298
299
301{
302 SELECTION fallbackSelection;
303 const SELECTION& selection = getSelection( fallbackSelection );
304
305 // Will actually just be updatePropertyValues() if selection hasn't changed
306 rebuildProperties( selection );
307}
308
309
311{
312 SELECTION fallbackSelection;
313 const SELECTION& selection = getSelection( fallbackSelection );
314
315 rebuildProperties( selection );
316}
317
318
320{
321 m_currentFieldNames.clear();
322
323 for( EDA_ITEM* item : aSelection )
324 {
325 if( item->Type() != SCH_SYMBOL_T )
326 continue;
327
328 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
329
330 for( const SCH_FIELD& field : symbol->GetFields() )
331 {
332 if( field.IsPrivate() )
333 continue;
334
335 m_currentFieldNames.insert( field.GetCanonicalName() );
336 }
337 }
338
339 const wxString groupFields = _HKI( "Fields" );
340
341 for( const wxString& name : m_currentFieldNames )
342 {
343 if( !m_propMgr.GetProperty( TYPE_HASH( SCH_SYMBOL ), name ) )
344 {
345 m_propMgr.AddProperty( new SCH_SYMBOL_FIELD_PROPERTY( name ), groupFields )
346 .SetAvailableFunc( [name]( INSPECTABLE* )
347 {
349 } );
350 }
351 }
352
354}
355
356
357wxPGProperty* SCH_PROPERTIES_PANEL::createPGProperty( const PROPERTY_BASE* aProperty ) const
358{
359 wxPGProperty* prop = PGPropertyFactory( aProperty, m_frame );
360
361 if( auto colorProp = dynamic_cast<PGPROPERTY_COLOR4D*>( prop ) )
362 {
363 COLOR4D bg = m_frame->GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND );
364 colorProp->SetBackgroundColor( bg );
365 }
366
367 if( aProperty->Name() == GetCanonicalFieldName( FIELD_T::FOOTPRINT ) )
368 prop->SetEditor( PG_FPID_EDITOR::BuildEditorName( m_frame ) );
369 else if( aProperty->Name() == GetCanonicalFieldName( FIELD_T::DATASHEET ) )
370 prop->SetEditor( PG_URL_EDITOR::BuildEditorName( m_frame ) );
371
372 return prop;
373}
374
375
376PROPERTY_BASE* SCH_PROPERTIES_PANEL::getPropertyFromEvent( const wxPropertyGridEvent& aEvent ) const
377{
378 EDA_ITEM* item = const_cast<SCH_PROPERTIES_PANEL*>( this )->getFrontItem();
379
380 if( !item || !item->IsSCH_ITEM() )
381 return nullptr;
382
383 SCH_ITEM* firstItem = static_cast<SCH_ITEM*>( item );
384
385 wxCHECK_MSG( firstItem, nullptr, wxT( "getPropertyFromEvent for a property with nothing selected!") );
386
387 PROPERTY_BASE* property = m_propMgr.GetProperty( TYPE_HASH( *firstItem ), aEvent.GetPropertyName() );
388 wxCHECK_MSG( property, nullptr, wxT( "getPropertyFromEvent for a property not found on the selected item!" ) );
389
390 return property;
391}
392
393
394void SCH_PROPERTIES_PANEL::valueChanging( wxPropertyGridEvent& aEvent )
395{
397 return;
398
399 EDA_ITEM* frontItem = getFrontItem();
400
401 if( !frontItem )
402 return;
403
404 if( PROPERTY_BASE* property = getPropertyFromEvent( aEvent ) )
405 {
406 wxVariant newValue = aEvent.GetPropertyValue();
407
408 if( VALIDATOR_RESULT validationFailure = property->Validate( newValue.GetAny(), frontItem ) )
409 {
410 wxString errorMsg = wxString::Format( wxS( "%s: %s" ), wxGetTranslation( property->Name() ),
411 validationFailure->get()->Format( m_frame ) );
412 m_frame->ShowInfoBarError( errorMsg );
413 aEvent.Veto();
414 return;
415 }
416
417 aEvent.Skip();
418 }
419}
420
421
422void SCH_PROPERTIES_PANEL::valueChanged( wxPropertyGridEvent& aEvent )
423{
425 return;
426
427 SELECTION fallbackSelection;
428 const SELECTION& selection = getSelection( fallbackSelection );
429
430 wxCHECK( getPropertyFromEvent( aEvent ), /* void */ );
431
432 wxVariant newValue = aEvent.GetPropertyValue();
433 SCH_COMMIT changes( m_frame );
434 SCH_SCREEN* screen = m_frame->GetScreen();
435
436 PROPERTY_COMMIT_HANDLER handler( &changes );
437
438 for( EDA_ITEM* edaItem : selection )
439 {
440 if( !edaItem->IsSCH_ITEM() )
441 continue;
442
443 SCH_ITEM* item = static_cast<SCH_ITEM*>( edaItem );
444 PROPERTY_BASE* property = m_propMgr.GetProperty( TYPE_HASH( *item ), aEvent.GetPropertyName() );
445 wxCHECK2( property, continue );
446
447 // Editing reference text in the schematic must go through the parent symbol in order to handle
448 // symbol instance data properly.
449 if( item->Type() == SCH_FIELD_T && static_cast<SCH_FIELD*>( item )->GetId() == FIELD_T::REFERENCE
450 && m_frame->IsType( FRAME_SCH )
451 && property->Name() == wxT( "Text" ) )
452 {
453 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item->GetParentSymbol() );
454 wxCHECK2( symbol, continue );
455
456 changes.Modify( symbol, screen, RECURSE_MODE::NO_RECURSE );
457 symbol->SetRefProp( newValue.GetString() );
458 symbol->SyncOtherUnits( symbol->Schematic()->CurrentSheet(), changes, property );
459 continue;
460 }
461
462 // Editing field text in the schematic when a variant is active must use variant-aware
463 // SetText to properly store the value as a variant override.
464 if( item->Type() == SCH_FIELD_T
465 && m_frame->IsType( FRAME_SCH )
466 && property->Name() == wxT( "Text" ) )
467 {
468 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
469 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item->GetParentSymbol() );
470
471 if( symbol && symbol->Schematic() )
472 {
473 wxString variantName = symbol->Schematic()->GetCurrentVariant();
474
475 if( !variantName.IsEmpty() )
476 {
477 changes.Modify( symbol, screen, RECURSE_MODE::NO_RECURSE );
478 field->SetText( newValue.GetString(), &symbol->Schematic()->CurrentSheet(), variantName );
479 symbol->SyncOtherUnits( symbol->Schematic()->CurrentSheet(), changes, property,
480 variantName );
481 continue;
482 }
483 }
484 }
485
486 // Changing a sheet's filename field requires file operations to match the dialog behavior.
487 if( item->Type() == SCH_FIELD_T
488 && m_frame->IsType( FRAME_SCH )
489 && property->Name() == wxT( "Text" ) )
490 {
491 SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
492 SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( item->GetParent() );
493
494 if( sheet && field->GetId() == FIELD_T::SHEET_FILENAME )
495 {
496 SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( m_frame );
497
498 if( !handleSheetFilenameChange( editFrame, sheet, changes, newValue.GetString() ) )
499 {
500 UpdateData();
501 return;
502 }
503
504 continue;
505 }
506 }
507
508 if( item->Type() == SCH_TABLECELL_T )
509 changes.Modify( item->GetParent(), screen, RECURSE_MODE::NO_RECURSE );
510 else
511 changes.Modify( item, screen, RECURSE_MODE::NO_RECURSE );
512
513 item->Set( property, newValue );
514
515 if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item ) )
516 {
517 symbol->SyncOtherUnits( symbol->Schematic()->CurrentSheet(), changes, property,
518 symbol->Schematic()->GetCurrentVariant() );
519 }
520 }
521
522 changes.Push( _( "Edit Properties" ) );
523
524 // Force a repaint of the items whose properties were changed
525 // This is necessary to update field displays in the schematic view
526 for( EDA_ITEM* edaItem : selection )
527 m_frame->UpdateItem( edaItem );
528
529 // Perform grid updates as necessary based on value change
530 AfterCommit();
531
532 aEvent.Skip();
533}
534
535
537 SCH_COMMIT& aChanges,
538 const wxString& aNewFilename )
539{
540 wxString newFilename = EnsureFileExtension( aNewFilename, FILEEXT::KiCadSchematicFileExtension );
541
542 if( newFilename.IsEmpty() || !IsFullFileNameValid( newFilename ) )
543 {
544 DisplayError( aFrame, _( "A sheet must have a valid file name." ) );
545 return false;
546 }
547
548 // Normalize separators to unix notation
549 newFilename.Replace( wxT( "\\" ), wxT( "/" ) );
550
551 wxString oldFilename = aSheet->GetFileName();
552 oldFilename.Replace( wxT( "\\" ), wxT( "/" ) );
553
554 if( newFilename == oldFilename )
555 return true;
556
557 if( !aFrame->ChangeSheetFile( aSheet, newFilename ) )
558 return false;
559
560 SCH_SCREEN* currentScreen = aFrame->GetCurrentSheet().LastScreen();
561 aChanges.Modify( aSheet, currentScreen, RECURSE_MODE::NO_RECURSE );
562 aSheet->SetFileName( newFilename );
563
564 return true;
565}
566
567
568void SCH_PROPERTIES_PANEL::OnLanguageChanged( wxCommandEvent& aEvent )
569{
571
572 aEvent.Skip();
573}
574
575
576bool SCH_PROPERTIES_PANEL::getItemValue( EDA_ITEM* aItem, PROPERTY_BASE* aProperty, wxVariant& aValue )
577{
578 // For SCH_FIELD "Text" property, return the variant-aware value when a variant is active
579 if( aItem->Type() == SCH_FIELD_T
580 && m_frame->IsType( FRAME_SCH )
581 && aProperty->Name() == wxT( "Text" ) )
582 {
583 SCH_FIELD* field = static_cast<SCH_FIELD*>( aItem );
584 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( field->GetParentSymbol() );
585
586 if( symbol && symbol->Schematic() )
587 {
588 wxString variantName = symbol->Schematic()->GetCurrentVariant();
589
590 if( !variantName.IsEmpty() )
591 {
592 wxString text = field->GetText( &symbol->Schematic()->CurrentSheet(), variantName );
593 aValue = wxVariant( text );
594 return true;
595 }
596 }
597 }
598
599 return PROPERTIES_PANEL::getItemValue( aItem, aProperty, aValue );
600}
601
602
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:99
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:111
EDA_ITEM * GetParent() const
Definition eda_item.h:113
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:214
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:187
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:116
FIELD_T GetId() const
Definition sch_field.h:120
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:260
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:254
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...
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
PG_UNIT_EDITOR * m_unitEditorInstance
static std::set< wxString > m_currentFieldNames
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()
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:382
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition sch_sheet.h:376
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:53
@ 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:488
#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:176
@ SCH_TABLECELL_T
Definition typeinfo.h:170
@ SCH_FIELD_T
Definition typeinfo.h:154
Definition of file extensions used in Kicad.