KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_lib_symbol_properties.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
25
26#include <pgm_base.h>
27#include <eeschema_settings.h>
28#include <bitmaps.h>
29#include <confirm.h>
31#include <kiway.h>
32#include <symbol_edit_frame.h>
34#include <math/util.h> // for KiROUND
35#include <sch_symbol.h>
36#include <kiplatform/ui.h>
38#include <widgets/wx_grid.h>
40#include <string_utils.h>
41#include <project_sch.h>
42#include <refdes_utils.h>
43#include <dialog_sim_model.h>
44#include <vector>
45
50
51#include <wx/clipbrd.h>
52#include <wx/msgdlg.h>
53
54
58
59
61 LIB_SYMBOL* aLibEntry ) :
63 m_Parent( aParent ),
64 m_libEntry( aLibEntry ),
66 m_delayedFocusCtrl( nullptr ),
67 m_delayedFocusGrid( nullptr ),
72{
73 std::vector<const EMBEDDED_FILES*> inheritedEmbeddedFiles;
74
75 if( std::shared_ptr<LIB_SYMBOL> parent = m_libEntry->GetParent().lock() )
76 {
77 while( parent )
78 {
79 inheritedEmbeddedFiles.push_back( parent->GetEmbeddedFiles() );
80 parent = parent->GetParent().lock();
81 }
82 }
83
84 m_embeddedFiles = new PANEL_EMBEDDED_FILES( m_NoteBook, m_libEntry, 0, std::move( inheritedEmbeddedFiles ) );
85 m_NoteBook->AddPage( m_embeddedFiles, _( "Embedded Files" ) );
86
87 m_fields = new FIELDS_GRID_TABLE( this, aParent, m_grid, m_libEntry, { m_embeddedFiles->GetLocalFiles() } );
88 m_grid->SetTable( m_fields );
89 m_grid->OverrideMinSize( 1.0, 1.0 );
90 m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this, { m_embeddedFiles->GetLocalFiles() },
91 [&]( wxCommandEvent& aEvent )
92 {
93 OnAddField( aEvent );
94 } ) );
95 m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
96
97 // Load the FIELDS_GRID_TABLE -- ensure we are calling the overloaded push_back method
98 std::vector<SCH_FIELD> fields;
99 m_libEntry->CopyFields( fields );
100
101 for( const SCH_FIELD& f : fields )
102 m_fields->push_back( f );
103
104 if( std::shared_ptr<LIB_SYMBOL> parent = m_libEntry->GetParent().lock() )
105 addInheritedFields( parent );
106
107 m_grid->ShowHideColumns( "0 1 2 3 4 5 6 7" );
108
109 m_SymbolNameCtrl->SetValidator( FIELD_VALIDATOR( FIELD_T::VALUE ) );
110
111 m_unitNamesGrid->PushEventHandler( new GRID_TRICKS( m_unitNamesGrid ) );
112 m_unitNamesGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
113
114 m_bodyStyleNamesGrid->PushEventHandler( new GRID_TRICKS( m_bodyStyleNamesGrid,
115 [this]( wxCommandEvent& aEvent )
116 {
117 OnAddBodyStyle( aEvent );
118 } ) );
119 m_bodyStyleNamesGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
120
121 m_jumperGroupsGrid->SetupColumnAutosizer( 0 );
122 m_jumperGroupsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
123
124 m_jumperGroupsGrid->PushEventHandler( new GRID_TRICKS( m_jumperGroupsGrid,
125 [this]( wxCommandEvent& aEvent )
126 {
127 OnAddJumperGroup( aEvent );
128 } ) );
129
130 // Configure button logos
131 m_bpAdd->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
132 m_bpMoveUp->SetBitmap( KiBitmapBundle( BITMAPS::small_up ) );
133 m_bpMoveDown->SetBitmap( KiBitmapBundle( BITMAPS::small_down ) );
134 m_bpDelete->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
135
136 m_bpAddBodyStyle->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
137 m_bpMoveUpBodyStyle->SetBitmap( KiBitmapBundle( BITMAPS::small_up ) );
138 m_bpMoveDownBodyStyle->SetBitmap( KiBitmapBundle( BITMAPS::small_down ) );
139 m_bpDeleteBodyStyle->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
140
141 m_addFilterButton->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
142 m_editFilterButton->SetBitmap( KiBitmapBundle( BITMAPS::small_edit ) );
143 m_deleteFilterButton->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
144
145 m_bpAddJumperGroup->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
146 m_bpRemoveJumperGroup->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
147
148 SetupStandardButtons();
149
150 if( aParent->IsSymbolFromLegacyLibrary() && !aParent->IsSymbolFromSchematic() )
151 {
152 m_stdSizerButtonCancel->SetDefault();
153 m_stdSizerButtonOK->SetLabel( _( "Read Only" ) );
154 m_stdSizerButtonOK->Enable( false );
155 }
156
157 // wxFormBuilder doesn't include this event...
158 m_grid->Bind( wxEVT_GRID_CELL_CHANGING, &DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging, this );
159 m_grid->Bind( wxEVT_GRID_CELL_CHANGED, &DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanged, this );
160 m_grid->GetGridWindow()->Bind( wxEVT_MOTION, &DIALOG_LIB_SYMBOL_PROPERTIES::OnGridMotion, this );
161
162
163 // Forward the delete button to the tricks
164 m_deleteFilterButton->Bind( wxEVT_BUTTON,
165 [&]( wxCommandEvent& aEvent )
166 {
167 wxCommandEvent cmdEvent( EDA_EVT_LISTBOX_DELETE );
168 m_fpFilterTricks->ProcessEvent( cmdEvent );
169 } );
170
171 // When the filter tricks modifies something, update ourselves
172 m_FootprintFilterListBox->Bind( EDA_EVT_LISTBOX_CHANGED,
173 [&]( wxCommandEvent& aEvent )
174 {
175 OnModify();
176 } );
177
179 {
180 if( ( m_lastLayout == DIALOG_LIB_SYMBOL_PROPERTIES::LAST_LAYOUT::ALIAS && aLibEntry->IsRoot() )
181 || ( m_lastLayout == DIALOG_LIB_SYMBOL_PROPERTIES::LAST_LAYOUT::PARENT && aLibEntry->IsDerived() ) )
182 {
183 resetSize();
184 }
185 }
186
187 m_lastLayout = ( aLibEntry->IsDerived() ) ? DIALOG_LIB_SYMBOL_PROPERTIES::LAST_LAYOUT::ALIAS
189
190 m_grid->GetParent()->Layout();
191 syncControlStates( m_libEntry->IsDerived() );
192 Layout();
193
194 finishDialogSettings();
195}
196
197
199{
200 m_lastOpenedPage = m_NoteBook->GetSelection( );
201
202 // Prevents crash bug in wxGrid's d'tor
203 m_grid->DestroyTable( m_fields );
204
205 m_grid->Unbind( wxEVT_GRID_CELL_CHANGING, &DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging, this );
206 m_grid->Unbind( wxEVT_GRID_CELL_CHANGED, &DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanged, this );
207 m_grid->GetGridWindow()->Unbind( wxEVT_MOTION, &DIALOG_LIB_SYMBOL_PROPERTIES::OnGridMotion, this );
208
209 // Delete the GRID_TRICKS.
210 m_grid->PopEventHandler( true );
211 m_unitNamesGrid->PopEventHandler( true );
212 m_bodyStyleNamesGrid->PopEventHandler( true );
213 m_jumperGroupsGrid->PopEventHandler( true );
214}
215
216
217void DIALOG_LIB_SYMBOL_PROPERTIES::addInheritedFields( const std::shared_ptr<LIB_SYMBOL>& aParent )
218{
219 if( std::shared_ptr<LIB_SYMBOL> ancestor = aParent->GetParent().lock() )
220 addInheritedFields( ancestor );
221
222 std::vector<SCH_FIELD*> parentFields;
223 aParent->GetFields( parentFields );
224
225 for( SCH_FIELD* parentField : parentFields )
226 {
227 bool found = false;
228
229 if( parentField->IsMandatory() )
230 continue; // Don't inherit mandatory fields
231
232 for( size_t ii = 0; ii < m_fields->size(); ++ii )
233 {
234 SCH_FIELD& field = m_fields->at( ii );
235
236 if( field.IsMandatory() )
237 continue; // Don't inherit mandatory fields
238
239 if( field.GetCanonicalName() == parentField->GetCanonicalName() )
240 {
241 m_fields->SetFieldInherited( ii, *parentField );
242 found = true;
243 break;
244 }
245 }
246
247 if( !found )
248 m_fields->AddInheritedField( *parentField );
249 }
250}
251
252
254{
255 if( !wxDialog::TransferDataToWindow() )
256 return false;
257
258 std::set<wxString> defined;
259
260 for( SCH_FIELD& field : *m_fields )
261 defined.insert( field.GetName() );
262
263 // Add in any template fieldnames not yet defined:
264 // Read global fieldname templates
266 {
267 TEMPLATES templateMgr;
268
269 if( !cfg->m_Drawing.field_names.IsEmpty() )
270 templateMgr.AddTemplateFieldNames( cfg->m_Drawing.field_names );
271
272 for( const TEMPLATE_FIELDNAME& templateFieldname : templateMgr.GetTemplateFieldNames() )
273 {
274 if( defined.count( templateFieldname.m_Name ) <= 0 )
275 {
276 SCH_FIELD field( m_libEntry, FIELD_T::USER, templateFieldname.m_Name );
277 field.SetVisible( templateFieldname.m_Visible );
278 m_fields->push_back( field );
279 m_addedTemplateFields.insert( templateFieldname.m_Name );
280 }
281 }
282 }
283
284 // The Y axis for components in library file is from bottom to top while the screen axis is top
285 // to bottom.However it is nowhandled by the lib file parser/writer.
286
287 // notify the grid
288 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->GetNumberRows() );
289 m_grid->ProcessTableMessage( msg );
290
291 m_SymbolNameCtrl->ChangeValue( UnescapeString( m_libEntry->GetName() ) );
292
293 m_KeywordCtrl->ChangeValue( m_libEntry->GetKeyWords() );
294 m_unitSpinCtrl->SetValue( m_libEntry->GetUnitCount() );
295 m_OptionPartsInterchangeable->SetValue( !m_libEntry->UnitsLocked() || m_libEntry->GetUnitCount() == 1 );
296
298
299 for( int unit = 0; unit < m_libEntry->GetUnitCount(); unit++ )
300 {
301 if( m_libEntry->GetUnitDisplayNames().contains( unit + 1 ) )
302 m_unitNamesGrid->SetCellValue( unit, 1, m_libEntry->GetUnitDisplayNames().at( unit + 1 ) );
303 }
304
305 if( m_libEntry->HasDeMorganBodyStyles() )
306 {
307 m_radioDeMorgan->SetValue( true );
308 }
309 else if( m_libEntry->IsMultiBodyStyle() )
310 {
311 m_radioCustom->SetValue( true );
312
313 for( const wxString& name : m_libEntry->GetBodyStyleNames() )
314 {
315 int row = m_bodyStyleNamesGrid->GetNumberRows();
316 m_bodyStyleNamesGrid->AppendRows( 1 );
317 m_bodyStyleNamesGrid->SetCellValue( row, 0, name );
318 }
319 }
320 else
321 {
322 m_radioSingle->SetValue( true );
323 }
324
325 m_OptionPower->SetValue( m_libEntry->IsPower() );
326 m_OptionLocalPower->SetValue( m_libEntry->IsLocalPower() );
327
328 if( m_libEntry->IsPower() )
329 {
330 m_spiceFieldsButton->Hide();
331 m_OptionLocalPower->Enable();
332 }
333 else
334 {
335 m_OptionLocalPower->Enable( false );
336 }
337
338 m_excludeFromSimCheckBox->SetValue( m_libEntry->GetExcludedFromSim() );
339 m_excludeFromBomCheckBox->SetValue( m_libEntry->GetExcludedFromBOM() );
340 m_excludeFromBoardCheckBox->SetValue( m_libEntry->GetExcludedFromBoard() );
341 m_excludeFromPosFilesCheckBox->SetValue( m_libEntry->GetExcludedFromPosFiles() );
342
343 m_ShowPinNumButt->SetValue( m_libEntry->GetShowPinNumbers() );
344 m_ShowPinNameButt->SetValue( m_libEntry->GetShowPinNames() );
345 m_PinsNameInsideButt->SetValue( m_libEntry->GetPinNameOffset() != 0 );
346 m_pinNameOffset.ChangeValue( m_libEntry->GetPinNameOffset() );
347
348 wxArrayString tmp = m_libEntry->GetFPFilters();
349 m_FootprintFilterListBox->Append( tmp );
350
351 m_cbDuplicatePinsAreJumpers->SetValue( m_libEntry->GetDuplicatePinNumbersAreJumpers() );
352
353 std::set<wxString> availablePins;
354
355 for( const SCH_PIN* pin : m_libEntry->GetGraphicalPins( 0, 0 ) )
356 availablePins.insert( pin->GetNumber() );
357
358 for( const std::set<wxString>& group : m_libEntry->JumperPinGroups() )
359 {
360 wxString groupTxt;
361
362 for( const wxString& pinNumber : group )
363 {
364 if( !groupTxt.IsEmpty() )
365 groupTxt << ", ";
366
367 groupTxt << pinNumber;
368 }
369
370 m_jumperGroupsGrid->AppendRows( 1 );
371 m_jumperGroupsGrid->SetCellValue( m_jumperGroupsGrid->GetNumberRows() - 1, 0, groupTxt );
372 }
373
374 // Populate the list of root parts for inherited objects.
375 if( m_libEntry->IsDerived() )
376 {
377 wxArrayString symbolNames;
378 wxString libName = m_Parent->GetCurLib();
379
380 // Someone forgot to set the current library in the editor frame window.
381 wxCHECK( !libName.empty(), false );
382
383 m_Parent->GetLibManager().GetSymbolNames( libName, symbolNames );
384
385 // Sort the list of symbols for easier search
386 symbolNames.Sort(
387 []( const wxString& a, const wxString& b ) -> int
388 {
389 return StrNumCmp( a, b, true );
390 } );
391
392 // Don't allow a symbol to be derived from itself
393 if( symbolNames.Index( m_libEntry->GetName() ) != wxNOT_FOUND )
394 symbolNames.Remove( m_libEntry->GetName() );
395
396 // Don't allow a symbol to be derived from any of its descendants (would create
397 // circular inheritance)
398 wxArrayString descendants;
399 m_Parent->GetLibManager().GetDerivedSymbolNames( m_libEntry->GetName(), libName, descendants );
400
401 for( const wxString& descendant : descendants )
402 {
403 if( symbolNames.Index( descendant ) != wxNOT_FOUND )
404 symbolNames.Remove( descendant );
405 }
406
407 m_inheritanceSelectCombo->Append( symbolNames );
408
409 if( std::shared_ptr<LIB_SYMBOL> rootSymbol = m_libEntry->GetParent().lock() )
410 {
411 wxString parentName = UnescapeString( rootSymbol->GetName() );
412 int selection = m_inheritanceSelectCombo->FindString( parentName );
413
414 if( selection == wxNOT_FOUND )
415 return false;
416
417 m_inheritanceSelectCombo->SetSelection( selection );
418 }
419
421 }
422
423 m_NoteBook->SetSelection( (unsigned) m_lastOpenedPage );
424
425 m_embeddedFiles->TransferDataToWindow();
426
427 return true;
428}
429
430
432{
433 if( !m_grid->CommitPendingChanges() )
434 return false;
435
436 // Symbol reference can be empty because it inherits from the parent symbol.
437 if( m_libEntry->IsRoot() )
438 {
439 SCH_FIELD* field = m_fields->GetField( FIELD_T::REFERENCE );
440
441 if( UTIL::GetRefDesPrefix( field->GetText() ).IsEmpty() )
442 {
443 if( m_NoteBook->GetSelection() != 0 )
444 m_NoteBook->SetSelection( 0 );
445
446 m_delayedErrorMessage = _( "References must start with a letter." );
451
452 return false;
453 }
454 }
455
456 // Check for missing field names.
457 for( int ii = 0; ii < (int) m_fields->size(); ++ii )
458 {
459 SCH_FIELD& field = m_fields->at( ii );
460
461 if( field.IsMandatory() )
462 continue;
463
464 wxString fieldName = field.GetName( false );
465
466 if( fieldName.IsEmpty() && !field.GetText().IsEmpty() )
467 {
468 if( m_NoteBook->GetSelection() != 0 )
469 m_NoteBook->SetSelection( 0 );
470
471 m_delayedErrorMessage = _( "Fields must have a name." );
476
477 return false;
478 }
479 }
480
481 // Verify that the parent name is set if the symbol is inherited
482 if( m_libEntry->IsDerived() )
483 {
484 wxString parentName = m_inheritanceSelectCombo->GetValue();
485
486 if( parentName.IsEmpty() )
487 {
488 m_delayedErrorMessage = _( "Derived symbol must have a parent selected" );
489 return false;
490 }
491 }
492
493 /*
494 * Confirm destructive actions.
495 */
496
497 if( m_unitSpinCtrl->GetValue() < m_libEntry->GetUnitCount() )
498 {
499 if( !IsOK( this, _( "Delete extra units from symbol?" ) ) )
500 return false;
501 }
502
503 int bodyStyleCount = 0;
504
505 if( m_radioSingle->GetValue() )
506 {
507 bodyStyleCount = 1;
508 }
509 if( m_radioDeMorgan->GetValue() )
510 {
511 bodyStyleCount = 2;
512 }
513 else if( m_radioCustom->GetValue() )
514 {
515 for( int ii = 0; ii < m_bodyStyleNamesGrid->GetNumberRows(); ++ii )
516 {
517 if( !m_bodyStyleNamesGrid->GetCellValue( ii, 0 ).IsEmpty() )
518 bodyStyleCount++;
519 }
520 }
521
522 if( bodyStyleCount == 0 )
523 {
524 m_delayedErrorMessage = _( "Symbol must have at least 1 body style" );
525 return false;
526 }
527
528 if( bodyStyleCount < m_libEntry->GetBodyStyleCount() )
529 {
530 if( !IsOK( this, _( "Delete extra body styles from symbol?" ) ) )
531 return false;
532 }
533
534 return true;
535}
536
537
539{
540 if( !m_grid->CommitPendingChanges()
541 || !m_unitNamesGrid->CommitPendingChanges()
542 || !m_bodyStyleNamesGrid->CommitPendingChanges()
543 || !m_jumperGroupsGrid->CommitPendingChanges()
544 || !m_embeddedFiles->TransferDataFromWindow() )
545 {
546 return false;
547 }
548
549 wxString newName = EscapeString( m_SymbolNameCtrl->GetValue(), CTX_LIBID );
550 wxString oldName = m_libEntry->GetName();
551
552 if( newName.IsEmpty() )
553 {
554 wxMessageBox( _( "Symbol must have a name." ) );
555 return false;
556 }
557
559
560 if( oldName != newName )
561 {
562 wxString libName = m_Parent->GetCurLib();
563
564 if( m_Parent->GetLibManager().SymbolNameInUse( newName, libName ) )
565 {
566 wxString msg;
567
568 msg.Printf( _( "Symbol name '%s' already in use in library '%s'." ),
569 UnescapeString( newName ),
570 libName );
571 DisplayErrorMessage( this, msg );
572 return false;
573 }
574
575 opType = UNDO_REDO::LIB_RENAME;
576 }
577
578 m_Parent->SaveCopyInUndoList( _( "Edit Symbol Properties" ), m_libEntry, opType );
579
580 // The Y axis for components in lib is from bottom to top while the screen axis is top
581 // to bottom: we must change the y coord sign when writing back to the library
582 std::vector<SCH_FIELD> fieldsToSave;
583 int ordinal = 42; // Arbitrarily larger than any mandatory FIELD_T ids.
584
585 for( size_t ii = 0; ii < m_fields->size(); ++ii )
586 {
587 SCH_FIELD& field = m_fields->at( ii );
588
589 if( !field.IsMandatory() )
590 field.SetOrdinal( ordinal++ );
591
592 wxString fieldName = field.GetCanonicalName();
593
594 if( m_fields->IsInherited( ii ) && field == m_fields->ParentField( ii ) )
595 continue; // Skip inherited fields
596
597 if( field.GetText().IsEmpty() )
598 {
599 if( fieldName.IsEmpty() || m_addedTemplateFields.contains( fieldName ) )
600 continue; // Skip empty fields that are not mandatory or template fields
601 }
602 else if( fieldName.IsEmpty() )
603 {
604 field.SetName( _( "untitled" ) ); // Set a default name for unnamed fields
605 }
606
607 fieldsToSave.push_back( field );
608 }
609
610 m_libEntry->SetFields( fieldsToSave );
611
612 // Update the parent for inherited symbols
613 if( m_libEntry->IsDerived() )
614 {
615 wxString parentName = EscapeString( m_inheritanceSelectCombo->GetValue(), CTX_LIBID );
616
617 // The parentName was verified to be non-empty in the Validator
618 wxString libName = m_Parent->GetCurLib();
619
620 // Get the parent from the libManager based on the name set in the inheritance combo box.
621 LIB_SYMBOL* newParent = m_Parent->GetLibManager().GetSymbol( parentName, libName );
622
623 // Verify that the requested parent exists
624 wxCHECK( newParent, false );
625
626 m_libEntry->SetParent( newParent );
627 }
628
629 m_libEntry->SetName( newName );
630 m_libEntry->SetKeyWords( m_KeywordCtrl->GetValue() );
631 m_libEntry->SetUnitCount( m_unitSpinCtrl->GetValue(), true );
632 m_libEntry->LockUnits( m_libEntry->GetUnitCount() > 1 && !m_OptionPartsInterchangeable->GetValue() );
633
634 m_libEntry->GetUnitDisplayNames().clear();
635
636 for( int row = 0; row < m_unitNamesGrid->GetNumberRows(); row++ )
637 {
638 if( !m_unitNamesGrid->GetCellValue( row, 1 ).IsEmpty() )
639 m_libEntry->GetUnitDisplayNames()[row+1] = m_unitNamesGrid->GetCellValue( row, 1 );
640 }
641
642 if( m_radioSingle->GetValue() )
643 {
644 m_libEntry->SetHasDeMorganBodyStyles( false );
645 m_libEntry->SetBodyStyleCount( 1, false, false );
646 m_libEntry->SetBodyStyleNames( {} );
647 }
648 else if( m_radioDeMorgan->GetValue() )
649 {
650 m_libEntry->SetHasDeMorganBodyStyles( true );
651 m_libEntry->SetBodyStyleCount( 2, false, true );
652 m_libEntry->SetBodyStyleNames( {} );
653 }
654 else
655 {
656 std::vector<wxString> bodyStyleNames;
657
658 for( int row = 0; row < m_bodyStyleNamesGrid->GetNumberRows(); ++row )
659 {
660 if( !m_bodyStyleNamesGrid->GetCellValue( row, 0 ).IsEmpty() )
661 bodyStyleNames.push_back( m_bodyStyleNamesGrid->GetCellValue( row, 0 ) );
662 }
663
664 m_libEntry->SetHasDeMorganBodyStyles( false );
665 m_libEntry->SetBodyStyleCount( bodyStyleNames.size(), true, true );
666 m_libEntry->SetBodyStyleNames( bodyStyleNames );
667 }
668
669 if( m_OptionPower->GetValue() )
670 {
671 if( m_OptionLocalPower->GetValue() )
672 m_libEntry->SetLocalPower();
673 else
674 m_libEntry->SetGlobalPower();
675
676 // Power symbols must have value matching name for now
677 m_libEntry->GetValueField().SetText( newName );
678 }
679 else
680 {
681 m_libEntry->SetNormal();
682 }
683
684 m_libEntry->SetExcludedFromSim( m_excludeFromSimCheckBox->GetValue() );
685 m_libEntry->SetExcludedFromBOM( m_excludeFromBomCheckBox->GetValue() );
686 m_libEntry->SetExcludedFromBoard( m_excludeFromBoardCheckBox->GetValue() );
687 m_libEntry->SetExcludedFromPosFiles( m_excludeFromPosFilesCheckBox->GetValue() );
688
689 m_libEntry->SetShowPinNumbers( m_ShowPinNumButt->GetValue() );
690 m_libEntry->SetShowPinNames( m_ShowPinNameButt->GetValue() );
691
692 if( m_PinsNameInsideButt->GetValue() )
693 {
694 int offset = KiROUND( (double) m_pinNameOffset.GetValue() );
695
696 // We interpret an offset of 0 as "outside", so make sure it's non-zero
697 m_libEntry->SetPinNameOffset( offset == 0 ? 20 : offset );
698 }
699 else
700 {
701 m_libEntry->SetPinNameOffset( 0 ); // pin text outside the body (name is on the pin)
702 }
703
704 m_libEntry->SetFPFilters( m_FootprintFilterListBox->GetStrings());
705
706 m_libEntry->SetDuplicatePinNumbersAreJumpers( m_cbDuplicatePinsAreJumpers->GetValue() );
707
708 std::set<wxString> availablePins;
709
710 for( const SCH_PIN* pin : m_libEntry->GetGraphicalPins( 0, 0 ) )
711 availablePins.insert( pin->GetNumber() );
712
713 std::vector<std::set<wxString>>& jumpers = m_libEntry->JumperPinGroups();
714 jumpers.clear();
715
716 for( int ii = 0; ii < m_jumperGroupsGrid->GetNumberRows(); ++ii )
717 {
718 wxStringTokenizer tokenizer( m_jumperGroupsGrid->GetCellValue( ii, 0 ), ", \t\r\n", wxTOKEN_STRTOK );
719 std::set<wxString>& group = jumpers.emplace_back();
720
721 while( tokenizer.HasMoreTokens() )
722 {
723 wxString token = tokenizer.GetNextToken();
724
725 if( token.IsEmpty() )
726 continue;
727
728 if( !availablePins.count( token ) )
729 {
730 wxString msg;
731 msg.Printf( _( "Pin '%s' in jumper pin group %d does not exist in this symbol." ),
732 token, ii + 1 );
733 DisplayErrorMessage( this, msg );
734 return false;
735 }
736
737 group.insert( token );
738 }
739 }
740
741 m_Parent->UpdateAfterSymbolProperties( &oldName );
742
743 return true;
744}
745
746
747void DIALOG_LIB_SYMBOL_PROPERTIES::OnBodyStyle( wxCommandEvent& event )
748{
749 m_bodyStyleNamesGrid->Enable( m_radioCustom->GetValue() );
750
751 m_bpAddBodyStyle->Enable( m_radioCustom->GetValue() );
752 m_bpMoveUpBodyStyle->Enable( m_radioCustom->GetValue() );
753 m_bpMoveDownBodyStyle->Enable( m_radioCustom->GetValue() );
754 m_bpDeleteBodyStyle->Enable( m_radioCustom->GetValue() );
755}
756
757
759{
760 aEvent.Skip();
761
762 wxPoint pos = aEvent.GetPosition();
763 wxPoint unscolled_pos = m_grid->CalcUnscrolledPosition( pos );
764 int row = m_grid->YToRow( unscolled_pos.y );
765 int col = m_grid->XToCol( unscolled_pos.x );
766
767 if( row == wxNOT_FOUND || col == wxNOT_FOUND || !m_fields->IsInherited( row ) )
768 {
769 m_grid->SetToolTip( "" );
770 return;
771 }
772
773 m_grid->SetToolTip( wxString::Format( _( "This field is inherited from '%s'." ),
774 m_fields->ParentField( row ).GetName() ) );
775}
776
777
779{
780 wxGridCellEditor* editor = m_grid->GetCellEditor( event.GetRow(), event.GetCol() );
781 wxControl* control = editor->GetControl();
782
783 if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) )
784 {
785 event.Veto();
786
788 m_delayedFocusRow = event.GetRow();
789 m_delayedFocusColumn = event.GetCol();
791 }
792 else if( event.GetCol() == FDC_NAME )
793 {
794 wxString newName = event.GetString();
795
796 for( int i = 0; i < m_grid->GetNumberRows(); ++i )
797 {
798 if( i == event.GetRow() )
799 continue;
800
801 if( newName.CmpNoCase( m_grid->GetCellValue( i, FDC_NAME ) ) == 0 )
802 {
803 DisplayError( this, wxString::Format( _( "The name '%s' is already in use." ), newName ) );
804 event.Veto();
805 m_delayedFocusRow = event.GetRow();
806 m_delayedFocusColumn = event.GetCol();
807 }
808 }
809 }
810
811 editor->DecRef();
812}
813
814
816{
817 m_grid->ForceRefresh();
818 OnModify();
819}
820
821
823{
824 if( m_OptionPower->IsChecked() )
825 m_grid->SetCellValue( m_fields->GetFieldRow( FIELD_T::VALUE ), FDC_VALUE, m_SymbolNameCtrl->GetValue() );
826
827 OnModify();
828}
829
830
832{
833 if( !m_delayedFocusCtrl )
834 {
835 // If the validation fails and we throw up a dialog then GTK will give us another
836 // KillFocus event and we end up in infinite recursion. So we use m_delayedFocusCtrl
837 // as a re-entrancy block and then clear it again if validation passes.
840
841 if( m_SymbolNameCtrl->GetValidator()->Validate( m_SymbolNameCtrl ) )
842 {
843 m_delayedFocusCtrl = nullptr;
845 }
846 }
847
848 event.Skip();
849}
850
851
852void DIALOG_LIB_SYMBOL_PROPERTIES::OnAddField( wxCommandEvent& event )
853{
854 m_grid->OnAddRow(
855 [&]() -> std::pair<int, int>
856 {
857 SYMBOL_EDITOR_SETTINGS* settings = m_Parent->GetSettings();
859
860 newField.SetTextSize( VECTOR2I( schIUScale.MilsToIU( settings->m_Defaults.text_size ),
861 schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) );
862 newField.SetVisible( false );
863
864 m_fields->push_back( newField );
865
866 // notify the grid
867 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
868 m_grid->ProcessTableMessage( msg );
869 OnModify();
870
871 return { m_fields->size() - 1, FDC_NAME };
872 } );
873}
874
875
877{
878 m_grid->OnDeleteRows(
879 [&]( int row )
880 {
881 if( row < m_fields->GetMandatoryRowCount() )
882 {
883 DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
884 m_fields->GetMandatoryRowCount() ) );
885 return false;
886 }
887
888 return true;
889 },
890 [&]( int row )
891 {
892 if( !m_fields->EraseRow( row ) )
893 return;
894
895 // notify the grid
896 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
897 m_grid->ProcessTableMessage( msg );
898 } );
899
900 OnModify();
901}
902
903
904void DIALOG_LIB_SYMBOL_PROPERTIES::OnMoveUp( wxCommandEvent& event )
905{
906 m_grid->OnMoveRowUp(
907 [&]( int row )
908 {
909 return row > m_fields->GetMandatoryRowCount();
910 },
911 [&]( int row )
912 {
913 m_fields->SwapRows( row, row - 1 );
914 m_grid->ForceRefresh();
915 OnModify();
916 } );
917}
918
919
920void DIALOG_LIB_SYMBOL_PROPERTIES::OnMoveDown( wxCommandEvent& event )
921{
922 m_grid->OnMoveRowDown(
923 [&]( int row )
924 {
925 return row >= m_fields->GetMandatoryRowCount();
926 },
927 [&]( int row )
928 {
929 m_fields->SwapRows( row, row + 1 );
930 m_grid->ForceRefresh();
931 OnModify();
932 } );
933}
934
935
937{
938 m_bodyStyleNamesGrid->OnAddRow(
939 [&]() -> std::pair<int, int>
940 {
941 m_bodyStyleNamesGrid->AppendRows( 1 );
942 OnModify();
943
944 return { m_bodyStyleNamesGrid->GetNumberRows() - 1, 0 };
945 } );
946}
947
948
950{
951 m_bodyStyleNamesGrid->OnDeleteRows(
952 [&]( int row )
953 {
954 m_bodyStyleNamesGrid->DeleteRows( row );
955 } );
956
957 OnModify();
958}
959
960
962{
963 m_bodyStyleNamesGrid->OnMoveRowUp(
964 [&]( int row )
965 {
966 m_bodyStyleNamesGrid->SwapRows( row, row - 1 );
967 OnModify();
968 } );
969}
970
971
973{
974 m_bodyStyleNamesGrid->OnMoveRowDown(
975 [&]( int row )
976 {
977 m_bodyStyleNamesGrid->SwapRows( row, row + 1 );
978 OnModify();
979 } );
980}
981
982
984{
985 if( !m_grid->CommitPendingChanges() )
986 return;
987
988 m_grid->ClearSelection();
989
990 std::vector<SCH_FIELD> fields;
991
992 for( const SCH_FIELD& field : *m_fields )
993 fields.emplace_back( field );
994
995 DIALOG_SIM_MODEL dialog( this, m_parentFrame, *m_libEntry, fields );
996
997 if( dialog.ShowModal() != wxID_OK )
998 return;
999
1000 // Add in any new fields
1001 for( const SCH_FIELD& editedField : fields )
1002 {
1003 bool found = false;
1004
1005 for( SCH_FIELD& existingField : *m_fields )
1006 {
1007 if( existingField.GetName() == editedField.GetName() )
1008 {
1009 found = true;
1010 existingField.SetText( editedField.GetText() );
1011 break;
1012 }
1013 }
1014
1015 if( !found )
1016 {
1017 m_fields->emplace_back( editedField );
1018 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
1019 m_grid->ProcessTableMessage( msg );
1020 }
1021 }
1022
1023 // Remove any deleted fields
1024 for( int ii = (int) m_fields->size() - 1; ii >= 0; --ii )
1025 {
1026 SCH_FIELD& existingField = m_fields->at( ii );
1027 bool found = false;
1028
1029 for( SCH_FIELD& editedField : fields )
1030 {
1031 if( editedField.GetName() == existingField.GetName() )
1032 {
1033 found = true;
1034 break;
1035 }
1036 }
1037
1038 if( !found )
1039 {
1040 m_grid->ClearSelection();
1041 m_fields->erase( m_fields->begin() + ii );
1042
1043 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, ii, 1 );
1044 m_grid->ProcessTableMessage( msg );
1045 }
1046 }
1047
1048 OnModify();
1049 m_grid->ForceRefresh();
1050}
1051
1052
1054{
1055 int idx = m_FootprintFilterListBox->HitTest( event.GetPosition() );
1056 wxCommandEvent dummy;
1057
1058 if( idx >= 0 )
1060 else
1062}
1063
1064
1066{
1067 // Running the Footprint Browser gums up the works and causes the automatic cancel
1068 // stuff to no longer work. So we do it here ourselves.
1069 EndQuasiModal( wxID_CANCEL );
1070}
1071
1072
1074{
1075 wxString filterLine;
1076 WX_TEXT_ENTRY_DIALOG dlg( this, _( "Filter:" ), _( "Add Footprint Filter" ), filterLine );
1077
1078 if( dlg.ShowModal() == wxID_CANCEL || dlg.GetValue().IsEmpty() )
1079 return;
1080
1081 filterLine = dlg.GetValue();
1082 filterLine.Replace( wxT( " " ), wxT( "_" ) );
1083
1084 // duplicate filters do no harm, so don't be a nanny.
1085 m_FootprintFilterListBox->Append( filterLine );
1086 m_FootprintFilterListBox->SetSelection( (int) m_FootprintFilterListBox->GetCount() - 1 );
1087
1088 OnModify();
1089}
1090
1091
1093{
1094 wxArrayInt selections;
1095 int n = m_FootprintFilterListBox->GetSelections( selections );
1096
1097 if( n > 0 )
1098 {
1099 // Just edit the first one
1100 int idx = selections[0];
1101 wxString filter = m_FootprintFilterListBox->GetString( idx );
1102
1103 WX_TEXT_ENTRY_DIALOG dlg( this, _( "Filter:" ), _( "Edit Footprint Filter" ), filter );
1104
1105 if( dlg.ShowModal() == wxID_OK && !dlg.GetValue().IsEmpty() )
1106 {
1107 m_FootprintFilterListBox->SetString( (unsigned) idx, dlg.GetValue() );
1108 OnModify();
1109 }
1110 }
1111}
1112
1113
1114void DIALOG_LIB_SYMBOL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
1115{
1116 m_OptionPartsInterchangeable->Enable( m_unitSpinCtrl->GetValue() > 1 );
1117 m_pinNameOffset.Enable( m_PinsNameInsideButt->GetValue() );
1118
1119 if( m_grid->IsCellEditControlShown() )
1120 {
1121 int row = m_grid->GetGridCursorRow();
1122 int col = m_grid->GetGridCursorCol();
1123
1124 if( row == m_fields->GetFieldRow( FIELD_T::VALUE ) && col == FDC_VALUE && m_OptionPower->IsChecked() )
1125 {
1126 wxGridCellEditor* editor = m_grid->GetCellEditor( row, col );
1127 m_SymbolNameCtrl->ChangeValue( editor->GetValue() );
1128 editor->DecRef();
1129 }
1130 }
1131
1132 // Handle shown columns changes
1133 std::bitset<64> shownColumns = m_grid->GetShownColumns();
1134
1135 if( shownColumns != m_shownColumns )
1136 {
1137 m_shownColumns = shownColumns;
1138
1139 if( !m_grid->IsCellEditControlShown() )
1140 m_grid->SetGridWidthsDirty();
1141 }
1142
1143 // Handle a delayed focus. The delay allows us to:
1144 // a) change focus when the error was triggered from within a killFocus handler
1145 // b) show the correct notebook page in the background before the error dialog comes up
1146 // when triggered from an OK or a notebook page change
1147
1148 if( m_delayedFocusPage >= 0 && m_NoteBook->GetSelection() != m_delayedFocusPage )
1149 {
1150 m_NoteBook->ChangeSelection( (unsigned) m_delayedFocusPage );
1151 m_delayedFocusPage = -1;
1152 }
1153
1154 if( !m_delayedErrorMessage.IsEmpty() )
1155 {
1156 // We will re-enter this routine when the error dialog is displayed, so make
1157 // sure we don't keep putting up more dialogs.
1158 wxString msg = m_delayedErrorMessage;
1159 m_delayedErrorMessage = wxEmptyString;
1160
1161 // Do not use DisplayErrorMessage(); it screws up window order on Mac
1162 DisplayError( nullptr, msg );
1163 }
1164
1165 if( m_delayedFocusCtrl )
1166 {
1167 m_delayedFocusCtrl->SetFocus();
1168
1169 if( wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_delayedFocusCtrl ) )
1170 textEntry->SelectAll();
1171
1172 m_delayedFocusCtrl = nullptr;
1173 }
1174 else if( m_delayedFocusGrid )
1175 {
1176 m_delayedFocusGrid->SetFocus();
1179
1180 m_delayedFocusGrid->EnableCellEditControl( true );
1181 m_delayedFocusGrid->ShowCellEditControl();
1182
1183 m_delayedFocusGrid = nullptr;
1184 m_delayedFocusRow = -1;
1186 }
1187}
1188
1189
1191{
1192 bSizerLowerBasicPanel->Show( !aIsAlias );
1193 m_inheritanceSelectCombo->Enable( aIsAlias );
1194 m_inheritsStaticText->Enable( aIsAlias );
1195 m_grid->ForceRefresh();
1196}
1197
1198
1200{
1201 if( m_OptionPower->IsChecked() )
1202 {
1203 m_excludeFromSimCheckBox->SetValue( true );
1204 m_excludeFromBomCheckBox->SetValue( true );
1205 m_excludeFromBoardCheckBox->SetValue( true );
1206 m_excludeFromPosFilesCheckBox->SetValue( true );
1207 m_excludeFromBomCheckBox->Enable( false );
1208 m_excludeFromBoardCheckBox->Enable( false );
1209 m_excludeFromSimCheckBox->Enable( false );
1210 m_excludeFromPosFilesCheckBox->Enable( false );
1211 m_spiceFieldsButton->Show( false );
1212 m_OptionLocalPower->Enable( true );
1213 }
1214 else
1215 {
1216 m_excludeFromBomCheckBox->Enable( true );
1217 m_excludeFromBoardCheckBox->Enable( true );
1218 m_excludeFromSimCheckBox->Enable( true );
1219 m_excludeFromPosFilesCheckBox->Enable( true );
1220 m_spiceFieldsButton->Show( true );
1221 m_OptionLocalPower->Enable( false );
1222 }
1223
1224 OnModify();
1225}
1226
1227
1228void DIALOG_LIB_SYMBOL_PROPERTIES::OnText( wxCommandEvent& event )
1229{
1230 OnModify();
1231}
1232
1233
1234void DIALOG_LIB_SYMBOL_PROPERTIES::OnCombobox( wxCommandEvent& event )
1235{
1236 OnModify();
1237}
1238
1239
1240void DIALOG_LIB_SYMBOL_PROPERTIES::OnCheckBox( wxCommandEvent& event )
1241{
1242 OnModify();
1243}
1244
1245
1247{
1248 m_unitNamesGrid->CommitPendingChanges( true /* aQuietMode */ );
1249
1250 int extra = m_unitNamesGrid->GetNumberRows() - m_unitSpinCtrl->GetValue();
1251 int needed = m_unitSpinCtrl->GetValue() - m_unitNamesGrid->GetNumberRows();
1252
1253 if( extra > 0 )
1254 {
1255 m_unitNamesGrid->DeleteRows( m_unitNamesGrid->GetNumberRows() - extra, extra );
1256 return true;
1257 }
1258
1259 if( needed > 0 )
1260 {
1261 m_unitNamesGrid->AppendRows( needed );
1262
1263 for( int row = m_unitNamesGrid->GetNumberRows() - needed; row < m_unitNamesGrid->GetNumberRows(); ++row )
1264 m_unitNamesGrid->SetCellValue( row, 0, LIB_SYMBOL::LetterSubReference( row + 1, 'A' ) );
1265
1266 return true;
1267 }
1268
1269 return false;
1270}
1271
1272
1274{
1275 if( updateUnitCount() )
1276 OnModify();
1277}
1278
1279
1281{
1282 // wait for kill focus to update unit count
1283}
1284
1285
1287{
1288 if( updateUnitCount() )
1289 OnModify();
1290}
1291
1292
1294{
1295 if( updateUnitCount() )
1296 OnModify();
1297}
1298
1299
1301{
1302 if( !m_grid->CommitPendingChanges() )
1303 aEvent.Veto();
1304}
1305
1306
1308{
1309 m_jumperGroupsGrid->OnAddRow(
1310 [&]() -> std::pair<int, int>
1311 {
1312 m_jumperGroupsGrid->AppendRows( 1 );
1313 OnModify();
1314
1315 return { m_jumperGroupsGrid->GetNumberRows() - 1, 0 };
1316 } );
1317}
1318
1319
1321{
1322 m_jumperGroupsGrid->OnDeleteRows(
1323 [&]( int row )
1324 {
1325 m_jumperGroupsGrid->DeleteRows( row, 1 );
1326 } );
1327
1328 OnModify();
1329}
1330
1331
const char * name
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:127
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:110
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:990
DIALOG_LIB_SYMBOL_PROPERTIES_BASE(wxWindow *parent, wxWindowID id=ID_LIBEDIT_NOTEBOOK, const wxString &title=_("Library Symbol Properties"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
void OnSymbolNameKillFocus(wxFocusEvent &event) override
void OnUnitSpinCtrlText(wxCommandEvent &event) override
std::unique_ptr< LISTBOX_TRICKS > m_fpFilterTricks
void OnPageChanging(wxNotebookEvent &event) override
void OnBodyStyle(wxCommandEvent &event) override
DIALOG_LIB_SYMBOL_PROPERTIES(SYMBOL_EDIT_FRAME *parent, LIB_SYMBOL *aLibEntry)
void OnUpdateUI(wxUpdateUIEvent &event) override
void OnBodyStyleMoveUp(wxCommandEvent &event) override
void OnCancelButtonClick(wxCommandEvent &event) override
void OnEditFootprintFilter(wxCommandEvent &event) override
void OnDeleteField(wxCommandEvent &event) override
void OnCombobox(wxCommandEvent &event) override
void OnFpFilterDClick(wxMouseEvent &event) override
void OnUnitSpinCtrlEnter(wxCommandEvent &event) override
void OnAddBodyStyle(wxCommandEvent &event) override
void OnMoveUp(wxCommandEvent &event) override
void OnDeleteBodyStyle(wxCommandEvent &event) override
void OnAddJumperGroup(wxCommandEvent &event) override
void OnText(wxCommandEvent &event) override
void OnUnitSpinCtrlKillFocus(wxFocusEvent &event) override
void OnMoveDown(wxCommandEvent &event) override
void OnAddFootprintFilter(wxCommandEvent &event) override
void OnCheckBox(wxCommandEvent &event) override
void OnSymbolNameText(wxCommandEvent &event) override
void OnBodyStyleMoveDown(wxCommandEvent &event) override
void OnRemoveJumperGroup(wxCommandEvent &event) override
void onPowerCheckBox(wxCommandEvent &aEvent) override
void OnAddField(wxCommandEvent &event) override
void OnEditSpiceModel(wxCommandEvent &event) override
void addInheritedFields(const std::shared_ptr< LIB_SYMBOL > &aParent)
void OnUnitSpinCtrl(wxSpinEvent &event) override
void EndQuasiModal(int retCode)
EDA_BASE_FRAME * m_parentFrame
int ShowModal() override
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition eda_text.cpp:532
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:385
void push_back(const SCH_FIELD &field)
A text control validator used for validating the text allowed in fields.
Definition validators.h:142
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition grid_tricks.h:61
Define a library symbol object.
Definition lib_symbol.h:83
static wxString LetterSubReference(int aUnit, wxChar aInitialLetter)
void SetOrdinal(int aOrdinal)
Definition sch_field.h:136
bool IsMandatory() const
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:126
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetName(const wxString &aName)
The symbol library editor main window.
void AddTemplateFieldNames(const wxString &aSerializedFieldNames)
Add a serialized list of template field names.
const std::vector< TEMPLATE_FIELDNAME > & GetTemplateFieldNames()
Return a template field name list for read only access.
A KICAD version of wxTextEntryDialog which supports the various improvements/work-arounds from DIALOG...
wxString GetValue() const
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition confirm.cpp:278
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:221
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition confirm.cpp:196
This file is part of the common library.
#define _(s)
@ FDC_NAME
@ FDC_VALUE
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.
STL namespace.
see class PGM_BASE
Collection of utility functions for component reference designators (refdes)
T * GetAppSettings(const char *aFilename)
std::vector< FAB_LAYER_COLOR > dummy
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_LIBID
Hold a name of a symbol's field, field value, and default visibility.
wxString GetUserFieldName(int aFieldNdx, bool aTranslateForHI)
#define DO_TRANSLATE
@ USER
The field ID hasn't been set yet; field is invalid.
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
KIBIS_PIN * pin
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687