KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_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, see <https://www.gnu.org/licenses/>.
18 */
19
21
22#include <algorithm>
23#include <memory>
24
25#include <bitmaps.h>
26#include <wx/tooltip.h>
27#include <wx/uiaction.h>
28#include <grid_tricks.h>
29#include <confirm.h>
30#include <kiface_base.h>
31#include <pin_numbers.h>
32#include <string_utils.h>
33#include <template_fieldnames.h>
34#include <kiplatform/ui.h>
40#include <sch_collectors.h>
41#include <fields_grid_table.h>
42#include <sch_edit_frame.h>
43#include <sch_reference_list.h>
44#include <schematic.h>
45#include <sch_commit.h>
46#include <sch_sheet_path.h>
47#include <tool/tool_manager.h>
48#include <tools/sch_actions.h>
49
50#include <dialog_sim_model.h>
53
54
55wxDEFINE_EVENT( SYMBOL_DELAY_FOCUS, wxCommandEvent );
56wxDEFINE_EVENT( SYMBOL_DELAY_SELECTION, wxCommandEvent );
57
58
69
70
71class SCH_PIN_TABLE_DATA_MODEL : public WX_GRID_TABLE_BASE, public std::vector<SCH_PIN>
72{
73public:
75 m_readOnlyAttr( nullptr ),
76 m_typeAttr( nullptr ),
77 m_shapeAttr( nullptr )
78 {
79 }
80
82 {
83 for( wxGridCellAttr* attr : m_nameAttrs )
84 attr->DecRef();
85
86 m_readOnlyAttr->DecRef();
87 m_typeAttr->DecRef();
88 m_shapeAttr->DecRef();
89 }
90
92 {
93 for( wxGridCellAttr* attr : m_nameAttrs )
94 attr->DecRef();
95
96 m_nameAttrs.clear();
97
98 if( m_readOnlyAttr )
99 m_readOnlyAttr->DecRef();
100
101 m_readOnlyAttr = new wxGridCellAttr;
102 m_readOnlyAttr->SetReadOnly( true );
103
104 for( const SCH_PIN& pin : *this )
105 {
106 SCH_PIN* lib_pin = pin.GetLibPin();
107 wxGridCellAttr* attr = nullptr;
108
109 if( !lib_pin || lib_pin->GetAlternates().empty() )
110 {
111 attr = new wxGridCellAttr;
112 attr->SetReadOnly( true );
113 attr->SetBackgroundColour( KIPLATFORM::UI::GetDialogBGColour() );
114 }
115 else
116 {
117 wxArrayString choices;
118 choices.push_back( lib_pin->GetName() );
119
120 for( const std::pair<const wxString, SCH_PIN::ALT>& alt : lib_pin->GetAlternates() )
121 choices.push_back( alt.first );
122
123 attr = new wxGridCellAttr();
124 attr->SetEditor( new GRID_CELL_COMBOBOX( choices ) );
125 }
126
127 m_nameAttrs.push_back( attr );
128 }
129
130 if( m_typeAttr )
131 m_typeAttr->DecRef();
132
133 m_typeAttr = new wxGridCellAttr;
135 m_typeAttr->SetReadOnly( true );
136
137 if( m_shapeAttr )
138 m_shapeAttr->DecRef();
139
140 m_shapeAttr = new wxGridCellAttr;
142 m_shapeAttr->SetReadOnly( true );
143 }
144
145 int GetNumberRows() override { return (int) size(); }
146 int GetNumberCols() override { return COL_COUNT; }
147
148 wxString GetColLabelValue( int aCol ) override
149 {
150 switch( aCol )
151 {
152 case COL_NUMBER: return _( "Number" );
153 case COL_BASE_NAME: return _( "Base Name" );
154 case COL_ALT_NAME: return _( "Alternate Assignment" );
155 case COL_TYPE: return _( "Electrical Type" );
156 case COL_SHAPE: return _( "Graphic Style" );
157 default: wxFAIL; return wxEmptyString;
158 }
159 }
160
161 bool IsEmptyCell( int row, int col ) override
162 {
163 return false; // don't allow adjacent cell overflow, even if we are actually empty
164 }
165
166 bool CanSetValueAs( int aRow, int aCol, const wxString& aTypeName ) override
167 {
168 // Don't accept random values; must use the popup to change to a known alternate
169 return false;
170 }
171
172 wxString GetValue( int aRow, int aCol ) override
173 {
174 return GetValue( at( aRow ), aCol );
175 }
176
177 static wxString GetValue( const SCH_PIN& aPin, int aCol )
178 {
179 if( aCol == COL_ALT_NAME )
180 {
181 if( !aPin.GetLibPin() || aPin.GetLibPin()->GetAlternates().empty() )
182 return wxEmptyString;
183 else if( aPin.GetAlt().IsEmpty() )
184 return aPin.GetName();
185 else
186 return aPin.GetAlt();
187 }
188
189 switch( aCol )
190 {
191 case COL_NUMBER: return aPin.GetNumber();
192 case COL_BASE_NAME: return aPin.GetBaseName();
193 case COL_TYPE: return PinTypeNames()[static_cast<int>( aPin.GetType() )];
194 case COL_SHAPE: return PinShapeNames()[static_cast<int>( aPin.GetShape() )];
195 default: wxFAIL; return wxEmptyString;
196 }
197 }
198
199 wxGridCellAttr* GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind ) override
200 {
201 switch( aCol )
202 {
203 case COL_NUMBER:
204 case COL_BASE_NAME:
205 m_readOnlyAttr->IncRef();
206 return enhanceAttr( m_readOnlyAttr, aRow, aCol, aKind );
207
208 case COL_ALT_NAME:
209 m_nameAttrs[ aRow ]->IncRef();
210 return enhanceAttr( m_nameAttrs[ aRow ], aRow, aCol, aKind );
211
212 case COL_TYPE:
213 m_typeAttr->IncRef();
214 return enhanceAttr( m_typeAttr, aRow, aCol, aKind );
215
216 case COL_SHAPE:
217 m_shapeAttr->IncRef();
218 return enhanceAttr( m_shapeAttr, aRow, aCol, aKind );
219
220 default:
221 wxFAIL;
222 return nullptr;
223 }
224 }
225
226 void SetValue( int aRow, int aCol, const wxString &aValue ) override
227 {
228 SCH_PIN& pin = at( aRow );
229
230 switch( aCol )
231 {
232 case COL_ALT_NAME:
233 if( pin.GetLibPin() && aValue == pin.GetLibPin()->GetName() )
234 pin.SetAlt( wxEmptyString );
235 else
236 pin.SetAlt( aValue );
237 break;
238
239 case COL_NUMBER:
240 case COL_BASE_NAME:
241 case COL_TYPE:
242 case COL_SHAPE:
243 // Read-only.
244 break;
245
246 default:
247 wxFAIL;
248 break;
249 }
250 }
251
252 static bool compare( const SCH_PIN& lhs, const SCH_PIN& rhs, int sortCol, bool ascending )
253 {
254 wxString lhStr = GetValue( lhs, sortCol );
255 wxString rhStr = GetValue( rhs, sortCol );
256
257 if( lhStr == rhStr )
258 {
259 // Secondary sort key is always COL_NUMBER
260 sortCol = COL_NUMBER;
261 lhStr = GetValue( lhs, sortCol );
262 rhStr = GetValue( rhs, sortCol );
263 }
264
265 bool res;
266
267 // N.B. To meet the iterator sort conditions, we cannot simply invert the truth
268 // to get the opposite sort. i.e. ~(a<b) != (a>b)
269 auto cmp = [ ascending ]( const auto a, const auto b )
270 {
271 if( ascending )
272 return a < b;
273 else
274 return b < a;
275 };
276
277 switch( sortCol )
278 {
279 case COL_NUMBER:
280 case COL_BASE_NAME:
281 case COL_ALT_NAME:
282 res = cmp( PIN_NUMBERS::Compare( lhStr, rhStr ), 0 );
283 break;
284 case COL_TYPE:
285 case COL_SHAPE:
286 res = cmp( lhStr.CmpNoCase( rhStr ), 0 );
287 break;
288 default:
289 res = cmp( StrNumCmp( lhStr, rhStr ), 0 );
290 break;
291 }
292
293 return res;
294 }
295
296 void SortRows( int aSortCol, bool ascending )
297 {
298 std::sort( begin(), end(),
299 [ aSortCol, ascending ]( const SCH_PIN& lhs, const SCH_PIN& rhs ) -> bool
300 {
301 return compare( lhs, rhs, aSortCol, ascending );
302 } );
303 }
304
305protected:
306 std::vector<wxGridCellAttr*> m_nameAttrs;
307 wxGridCellAttr* m_readOnlyAttr;
308 wxGridCellAttr* m_typeAttr;
309 wxGridCellAttr* m_shapeAttr;
310};
311
312
315 m_symbol( nullptr ),
316 m_part( nullptr ),
318 m_editorShown( false ),
319 m_fields( nullptr ),
320 m_dataModel( nullptr ),
321 m_embeddedFiles( nullptr ),
322 m_pinMapPanel( nullptr )
323{
324 m_symbol = aSymbol;
325 m_part = m_symbol->GetLibSymbolRef().get();
326
327 // GetLibSymbolRef() now points to the cached part in the schematic, which should always be
328 // there for usual cases, but can be null when opening old schematics not storing the part
329 // so we need to handle m_part == nullptr
330 // wxASSERT( m_part );
331
332 m_fields = new FIELDS_GRID_TABLE( this, aParent, m_fieldsGrid, m_symbol );
333 m_fieldsGrid->SetTable( m_fields );
334 m_fieldsGrid->OverrideMinSize( 1.0, 1.0 );
335 m_fieldsGrid->PushEventHandler( new FIELDS_GRID_TRICKS( m_fieldsGrid, this,
336 { &aParent->Schematic(), m_part },
337 [&]( wxCommandEvent& aEvent )
338 {
339 OnAddField( aEvent );
340 } ) );
341 m_fieldsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
342
343 int minWidth = wxSystemSettings::GetMetric( wxSYS_VSCROLL_X );
344
345 for( int ii = 0; ii <= 7; ++ii )
346 {
347 if( m_fieldsGrid->IsColShown( ii ) )
348 minWidth += m_fieldsGrid->GetColSize( ii );
349 }
350
351 m_fieldsGrid->SetMinSize( wxSize( minWidth, -1 ) );
352
353 // Putting too many columns in wxFormBuilder results in the minimum dialog size getting set too
354 // large (even with the m_grid->SetMinSize() call above).
355 m_fieldsGrid->SetColSize( 13, 48 ); // "Color"
356 m_fieldsGrid->SetColSize( 14, 136 ); // "Allow Autoplace"
357 m_fieldsGrid->SetupColumnAutosizer( 1 );
358
359 m_fieldsGrid->ShowHideColumns( "0 1 2 3 4 5 6 7" );
360 m_shownColumns = m_fieldsGrid->GetShownColumns();
361
362 if( m_symbol->GetEmbeddedFiles() )
363 {
364 m_embeddedFiles = new PANEL_EMBEDDED_FILES( m_notebook1, m_symbol->GetEmbeddedFiles() );
365 m_notebook1->AddPage( m_embeddedFiles, _( "Embedded Files" ) );
366 }
367
369 bPinMapPageSizer->Add( m_pinMapPanel, 1, wxEXPAND, 5 );
370
371 if( m_part && m_part->IsMultiBodyStyle() )
372 {
373 wxSizer* altPinDefsSizer = m_pinGrid->GetContainingSizer();
374
375 // Multiple body styles are a superclass of alternate pin assignments, so don't allow free-form
376 // alternate assignments as well. (We won't know how to map the alternates back and forth when
377 // the body style is changed.)
378 wxStaticText* hint = new wxStaticText( m_pinTablePage, wxID_ANY, NO_PIN_FUNCTIONS_WITH_MULTIPLE_BODY_STYLES );
379 hint->SetFont( KIUI::GetControlFont( this ).Italic() );
380 altPinDefsSizer->AddStretchSpacer( 1 );
381 altPinDefsSizer->Add( hint, 0, wxALIGN_CENTER_HORIZONTAL );
382 altPinDefsSizer->AddStretchSpacer( 2 );
383 m_pinGrid->Hide();
384 altPinDefsSizer->Layout();
385 }
386 else
387 {
389
390 // Make a copy of the pins for editing
391 for( const std::unique_ptr<SCH_PIN>& pin : m_symbol->GetRawPins() )
392 m_dataModel->push_back( *pin );
393
394 m_dataModel->SortRows( COL_NUMBER, true );
395 m_dataModel->BuildAttrs();
396
397 m_pinGrid->SetTable( m_dataModel );
398 }
399
400 if( m_part && m_part->IsPower() )
401 m_spiceFieldsButton->Hide();
402
403 m_pinGrid->PushEventHandler( new GRID_TRICKS( m_pinGrid ) );
404 m_pinGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
405
406 wxFont infoFont = KIUI::GetSmallInfoFont( this );
407 m_libraryIDLabel->SetFont( infoFont );
408 m_tcLibraryID->SetFont( infoFont );
409 m_tcLibraryID->SetBackgroundColour( KIPLATFORM::UI::GetDialogBGColour() );
410
411 wxToolTip::Enable( true );
413
414 // Configure button logos
419
420 // wxFormBuilder doesn't include this event...
421 m_fieldsGrid->Bind( wxEVT_GRID_CELL_CHANGING, &DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging, this );
422 m_pinGrid->Bind( wxEVT_GRID_COL_SORT, &DIALOG_SYMBOL_PROPERTIES::OnPinTableColSort, this );
423 Bind( SYMBOL_DELAY_FOCUS, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedFocus, this );
424 Bind( SYMBOL_DELAY_SELECTION, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedSelection, this );
425
426 wxCommandEvent* evt = new wxCommandEvent( SYMBOL_DELAY_SELECTION );
427 evt->SetClientData( new VECTOR2I( 0, FDC_VALUE ) );
428 QueueEvent( evt );
429
430 evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
431 evt->SetClientData( new VECTOR2I( 0, FDC_VALUE ) );
432 QueueEvent( evt );
433
434 // Remind user that they are editing the current variant.
435 wxString variantName = aParent->Schematic().GetCurrentVariant();
436
437 if( !variantName.IsEmpty() )
438 {
439 SetTitle( GetTitle() + wxS( " - " ) + variantName + _( " Design Variant" ) );
440
441 m_changeSymbolBtn->SetLabel( _( "Set Variant Symbol..." ) );
442
443 SCH_SHEET_PATH& currentSheet = aParent->GetCurrentSheet();
444 std::optional<SCH_SYMBOL_VARIANT> existingVariant =
445 aSymbol->GetVariant( currentSheet, variantName );
446
447 bool hasVariantSymbol = existingVariant.has_value() && existingVariant->m_SymbolOverride.has_value();
448
449 m_clearVariantSymbolBtn->Show( hasVariantSymbol );
450 }
451 else
452 {
454 }
455
456 Layout();
457 m_fieldsGrid->Layout();
458
459 if( GetSizer() )
460 GetSizer()->Fit( this );
461
463}
464
465
467{
468 // Prevents crash bug in wxGrid's d'tor
469 m_fieldsGrid->DestroyTable( m_fields );
470
471 if( m_dataModel )
472 m_pinGrid->DestroyTable( m_dataModel );
473
474 m_fieldsGrid->Unbind( wxEVT_GRID_CELL_CHANGING, &DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging, this );
475 m_pinGrid->Unbind( wxEVT_GRID_COL_SORT, &DIALOG_SYMBOL_PROPERTIES::OnPinTableColSort, this );
476 Unbind( SYMBOL_DELAY_FOCUS, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedFocus, this );
477 Unbind( SYMBOL_DELAY_SELECTION, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedSelection, this );
478
479 // Delete the GRID_TRICKS.
480 m_fieldsGrid->PopEventHandler( true );
481 m_pinGrid->PopEventHandler( true );
482}
483
484
486{
487 return dynamic_cast<SCH_EDIT_FRAME*>( wxDialog::GetParent() );
488}
489
490
495
496
498{
499 if( !wxDialog::TransferDataToWindow() )
500 return false;
501
502 const SCHEMATIC& schematic = GetParent()->Schematic();
503 SCH_SHEET_PATH& sheetPath = schematic.CurrentSheet();
504 wxString variantName = schematic.GetCurrentVariant();
505 std::optional<SCH_SYMBOL_VARIANT> variant = m_symbol->GetVariant( sheetPath, variantName );
506 std::set<wxString> defined;
507
508 std::vector<SCH_FIELD*> orderedFields;
509 m_symbol->GetFields( orderedFields, false );
510
511 // Push a copy of each field into m_updateFields
512 for( SCH_FIELD* srcField : orderedFields )
513 {
514 SCH_FIELD field( *srcField );
515
516 // change offset to be symbol-relative
517 field.Offset( -m_symbol->GetPosition() );
518 field.SetText( schematic.ConvertKIIDsToRefs( m_symbol->GetFieldText( field.GetName(), &sheetPath,
519 variantName ) ) );
520
521 defined.insert( field.GetName() );
522 m_fields->push_back( field );
523 }
524
525 // Add in any template fieldnames not yet defined:
526 for( const TEMPLATE_FIELDNAME& templateFieldname :
528 {
529 if( defined.count( templateFieldname.m_Name ) <= 0 )
530 {
531 SCH_FIELD field( m_symbol, FIELD_T::USER, templateFieldname.m_Name );
532 field.SetVisible( templateFieldname.m_Visible );
533 m_fields->push_back( field );
534 }
535 }
536
537 // notify the grid
538 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->GetNumberRows() );
539 m_fieldsGrid->ProcessTableMessage( msg );
540
541 // If a multi-unit symbol, set up the unit selector and interchangeable checkbox.
542 if( m_symbol->IsMultiUnit() )
543 {
544 // Ensure symbol unit is the currently selected unit (mandatory in complex hierarchies)
545 // from the current sheet path, because it can be modified by previous calculations
546 m_symbol->SetUnit( m_symbol->GetUnitSelection( &sheetPath ) );
547
548 for( int ii = 1; ii <= m_symbol->GetUnitCount(); ii++ )
549 m_unitChoice->Append( m_symbol->GetUnitDisplayName( ii, false ) );
550
551 if( m_symbol->GetUnit() <= ( int )m_unitChoice->GetCount() )
552 m_unitChoice->SetSelection( m_symbol->GetUnit() - 1 );
553 }
554 else
555 {
556 m_unitLabel->Enable( false );
557 m_unitChoice->Enable( false );
558 }
559
560 if( m_part && m_part->IsMultiBodyStyle() )
561 {
562 if( m_part->HasDeMorganBodyStyles() )
563 {
564 m_bodyStyleChoice->Append( _( "Standard" ) );
565 m_bodyStyleChoice->Append( _( "Alternate" ) );
566 }
567 else
568 {
569 wxASSERT( (int)m_part->GetBodyStyleNames().size() == m_part->GetBodyStyleCount() );
570
571 for( int ii = 0; ii < m_part->GetBodyStyleCount(); ii++ )
572 {
573 try
574 {
575 m_bodyStyleChoice->Append( m_part->GetBodyStyleNames().at( ii ) );
576 }
577 catch( ... )
578 {
579 m_bodyStyleChoice->Append( wxT( "???" ) );
580 }
581 }
582 }
583
584 if( m_symbol->GetBodyStyle() <= (int) m_bodyStyleChoice->GetCount() )
585 m_bodyStyleChoice->SetSelection( m_symbol->GetBodyStyle() - 1 );
586 }
587 else
588 {
589 m_bodyStyle->Enable( false );
590 m_bodyStyleChoice->Enable( false );
591 }
592
593 // Set the symbol orientation and mirroring.
594 int orientation = m_symbol->GetOrientation() & ~( SYM_MIRROR_X | SYM_MIRROR_Y );
595
596 switch( orientation )
597 {
598 default:
599 case SYM_ORIENT_0: m_orientationCtrl->SetSelection( 0 ); break;
600 case SYM_ORIENT_90: m_orientationCtrl->SetSelection( 1 ); break;
601 case SYM_ORIENT_270: m_orientationCtrl->SetSelection( 2 ); break;
602 case SYM_ORIENT_180: m_orientationCtrl->SetSelection( 3 ); break;
603 }
604
605 int mirror = m_symbol->GetOrientation() & ( SYM_MIRROR_X | SYM_MIRROR_Y );
606
607 switch( mirror )
608 {
609 default: m_mirrorCtrl->SetSelection( 0 ) ; break;
610 case SYM_MIRROR_X: m_mirrorCtrl->SetSelection( 1 ); break;
611 case SYM_MIRROR_Y: m_mirrorCtrl->SetSelection( 2 ); break;
612 }
613
614 m_cbExcludeFromSim->SetValue( m_symbol->GetExcludedFromSim( &sheetPath, variantName ) );
615 m_cbExcludeFromBom->SetValue( m_symbol->GetExcludedFromBOM( &sheetPath, variantName ) );
616 m_cbExcludeFromBoard->SetValue( m_symbol->GetExcludedFromBoard( &sheetPath, variantName ) );
617 m_cbExcludeFromPosFiles->SetValue( m_symbol->GetExcludedFromPosFiles( &sheetPath, variantName ) );
618 m_cbDNP->SetValue( m_symbol->GetDNP( &sheetPath, variantName ) );
619
620 switch( m_symbol->GetPassthroughMode() )
621 {
622 case SCH_SYMBOL::PASSTHROUGH_MODE::DEFAULT: m_choicePassthrough->SetSelection( 0 ); break;
623 case SCH_SYMBOL::PASSTHROUGH_MODE::BLOCK: m_choicePassthrough->SetSelection( 1 ); break;
624 case SCH_SYMBOL::PASSTHROUGH_MODE::FORCE: m_choicePassthrough->SetSelection( 2 ); break;
625 }
626
627 if( m_part )
628 {
629 m_ShowPinNumButt->SetValue( m_part->GetShowPinNumbers() );
630 m_ShowPinNameButt->SetValue( m_part->GetShowPinNames() );
631 }
632
633 // Set the symbol's library name.
634 m_tcLibraryID->SetValue( UnescapeString( m_symbol->GetLibId().Format() ) );
635
636 if( m_embeddedFiles && !m_embeddedFiles->TransferDataToWindow() )
637 return false;
638
639 m_pinMapPanel->SetSymbol( m_part );
640 m_pinMapPanel->TransferDataToWindow();
641
642 m_fieldsGrid->Layout();
643 Layout();
644 m_fieldsGrid->SetMinVisibleRows( this, 4 );
645
646 // Always open on the General page, unless the caller explicitly asked for the Pin Map
647 // tab (the Edit Pin Map button). This overrides DIALOG_SHIM's remembered-tab restore.
648 int targetPage = 0;
649
651 {
652 for( size_t page = 0; page < m_notebook1->GetPageCount(); ++page )
653 {
654 if( m_notebook1->GetPage( page ) == m_pinMapPage )
655 {
656 targetPage = (int) page;
657 break;
658 }
659 }
660 }
661
662 m_notebook1->ChangeSelection( targetPage );
663
664 return true;
665}
666
667
669{
670 if( !m_fieldsGrid->CommitPendingChanges() )
671 return;
672
673 m_fieldsGrid->ClearSelection();
674
675 std::vector<SCH_FIELD> fields;
676
677 for( const SCH_FIELD& field : *m_fields )
678 fields.emplace_back( field );
679
680 DIALOG_SIM_MODEL dialog( this, m_parentFrame, *m_symbol, fields );
681
682 if( dialog.ShowModal() != wxID_OK )
683 return;
684
685 // Add in any new fields
686 for( const SCH_FIELD& editedField : fields )
687 {
688 bool found = false;
689
690 for( SCH_FIELD& existingField : *m_fields )
691 {
692 if( existingField.GetName() == editedField.GetName() )
693 {
694 found = true;
695 existingField.SetText( editedField.GetText() );
696 break;
697 }
698 }
699
700 if( !found )
701 {
702 m_fields->emplace_back( editedField );
703 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
704 m_fieldsGrid->ProcessTableMessage( msg );
705 }
706 }
707
708 // Remove any deleted fields
709 for( int ii = (int) m_fields->size() - 1; ii >= 0; --ii )
710 {
711 SCH_FIELD& existingField = m_fields->at( ii );
712 bool found = false;
713
714 for( SCH_FIELD& editedField : fields )
715 {
716 if( editedField.GetName() == existingField.GetName() )
717 {
718 found = true;
719 break;
720 }
721 }
722
723 if( !found )
724 {
725 m_fieldsGrid->ClearSelection();
726 m_fields->erase( m_fields->begin() + ii );
727
728 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, ii, 1 );
729 m_fieldsGrid->ProcessTableMessage( msg );
730 }
731 }
732
733 OnModify();
734 m_fieldsGrid->ForceRefresh();
735}
736
737
739{
740 // Running the Footprint Browser gums up the works and causes the automatic cancel
741 // stuff to no longer work. So we do it here ourselves.
742 EndDialogShim( wxID_CANCEL );
743}
744
745
747{
748 LIB_ID id;
749
750 if( !m_fieldsGrid->CommitPendingChanges() || !m_fieldsGrid->Validate() )
751 return false;
752
753 // Check for missing field names.
754 for( size_t i = 0; i < m_fields->size(); ++i )
755 {
756 SCH_FIELD& field = m_fields->at( i );
757
758 if( field.IsMandatory() )
759 continue;
760
761 wxString fieldName = field.GetName( false );
762
763 if( fieldName.IsEmpty() )
764 {
765 DisplayErrorMessage( this, _( "Fields must have a name." ) );
766
767 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
768 evt->SetClientData( new VECTOR2I( i, FDC_VALUE ) );
769 QueueEvent( evt );
770
771 return false;
772 }
773 }
774
775 return true;
776}
777
778
780{
781 if( !wxDialog::TransferDataFromWindow() ) // Calls our Validate() method.
782 return false;
783
784 if( m_embeddedFiles && !m_embeddedFiles->TransferDataFromWindow() )
785 return false;
786
787 if( !m_fieldsGrid->CommitPendingChanges() )
788 return false;
789
790 if( !m_pinGrid->CommitPendingChanges() )
791 return false;
792
793 if( !m_pinMapPanel->CommitPendingChanges() )
794 return false;
795
796 SCH_COMMIT commit( GetParent() );
797 SCH_SCREEN* currentScreen = GetParent()->GetScreen();
798 SCH_SHEET_PATH currentSheet = GetParent()->Schematic().CurrentSheet();
799 wxString currentVariant = GetParent()->Schematic().GetCurrentVariant();
800 bool replaceOnCurrentScreen;
801
802 wxCHECK( currentScreen, false );
803
804 // This needs to be done before the LIB_ID is changed to prevent stale library symbols in
805 // the schematic file.
806 replaceOnCurrentScreen = currentScreen->Remove( m_symbol );
807
808 // save old cmp in undo list if not already in edit, or moving ...
809 if( m_symbol->GetEditFlags() == 0 )
810 commit.Modify( m_symbol, currentScreen );
811
812 // Apply pin-map edits after the undo snapshot so undo restores them (issue #2282).
813 if( m_part )
814 {
815 m_pinMapPanel->ApplyToSymbol( m_part );
816 GetParent()->Schematic().SyncLibSymbolPinMaps( m_symbol->GetSchSymbolLibraryName(), *m_part, &commit );
817 }
818
819 // Save current flags which could be modified by next change settings
820 EDA_ITEM_FLAGS flags = m_symbol->GetFlags();
821
822 //Set the part selection in multiple part per package
823 int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1;
824 m_symbol->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection );
825 m_symbol->SetUnit( unit_selection );
826
827 int bodyStyle_selection = m_bodyStyleChoice->IsEnabled() ? m_bodyStyleChoice->GetSelection() + 1 : 1;
828 m_symbol->SetBodyStyle( bodyStyle_selection );
829
830 switch( m_orientationCtrl->GetSelection() )
831 {
832 case 0: m_symbol->SetOrientation( SYM_ORIENT_0 ); break;
833 case 1: m_symbol->SetOrientation( SYM_ORIENT_90 ); break;
834 case 2: m_symbol->SetOrientation( SYM_ORIENT_270 ); break;
835 case 3: m_symbol->SetOrientation( SYM_ORIENT_180 ); break;
836 }
837
838 switch( m_mirrorCtrl->GetSelection() )
839 {
840 case 0: break;
841 case 1: m_symbol->SetOrientation( SYM_MIRROR_X ); break;
842 case 2: m_symbol->SetOrientation( SYM_MIRROR_Y ); break;
843 }
844
845 m_symbol->SetShowPinNames( m_ShowPinNameButt->GetValue() );
846 m_symbol->SetShowPinNumbers( m_ShowPinNumButt->GetValue() );
847
848 // Restore m_Flag modified by SetUnit() and other change settings from the dialog
849 m_symbol->ClearFlags();
850 m_symbol->SetFlags( flags );
851
852 // change all field positions from relative to absolute
853 for( SCH_FIELD& field : *m_fields )
854 field.Offset( m_symbol->GetPosition() );
855
856 int ordinal = 42; // Arbitrarily larger than any mandatory FIELD_T ids.
857
858 for( SCH_FIELD& field : *m_fields )
859 {
860 const wxString& fieldName = field.GetUntranslatedName();
861
862 if( fieldName.IsEmpty() && field.GetText().IsEmpty() )
863 continue;
864 else if( fieldName.IsEmpty() )
865 field.SetName( _( "untitled" ) );
866
867 if( !field.IsMandatory() )
868 field.SetOrdinal( ordinal++, FIELD_T::USER );
869
870 const SCH_FIELD* existingField = m_symbol->GetField( fieldName );
871 SCH_FIELD* tmp;
872
873 if( !existingField )
874 {
875 tmp = m_symbol->AddField( field );
876 tmp->SetParent( m_symbol );
877 }
878 else
879 {
880 wxString defaultText = m_symbol->Schematic()->ConvertRefsToKIIDs( existingField->GetText() );
881 tmp = const_cast<SCH_FIELD*>( existingField );
882
883 *tmp = field;
884
885 if( !currentVariant.IsEmpty() )
886 {
887 // Restore the default field text for existing fields.
888 tmp->SetText( defaultText, &currentSheet );
889
890 wxString variantText = m_symbol->Schematic()->ConvertRefsToKIIDs( field.GetText() );
891 tmp->SetText( variantText, &currentSheet, currentVariant );
892 }
893 }
894 }
895
896 for( int ii = (int) m_symbol->GetFields().size() - 1; ii >= 0; ii-- )
897 {
898 SCH_FIELD& symbolField = m_symbol->GetFields()[ii];
899
900 if( symbolField.IsMandatory() )
901 continue;
902
903 bool found = false;
904
905 for( const SCH_FIELD& editedField : *m_fields )
906 {
907 if( editedField.GetName() == symbolField.GetName() )
908 {
909 found = true;
910 break;
911 }
912 }
913
914 if( !found )
915 m_symbol->RemoveField( symbolField.GetName() );
916 }
917
918 std::stable_sort( m_symbol->GetFields().begin(), m_symbol->GetFields().end(),
919 []( const SCH_FIELD& lhs, const SCH_FIELD& rhs )
920 {
921 return lhs.GetOrdinal() < rhs.GetOrdinal();
922 } );
923
924 if( currentVariant.IsEmpty() )
925 {
926 // Reference has a specific initialization, depending on the current active sheet
927 // because for a given symbol, in a complex hierarchy, there are more than one
928 // reference.
929 m_symbol->SetRef( &GetParent()->GetCurrentSheet(), m_fields->GetField( FIELD_T::REFERENCE )->GetText() );
930 }
931
932 m_symbol->SetExcludedFromSim( m_cbExcludeFromSim->IsChecked(), &currentSheet, currentVariant );
933 m_symbol->SetExcludedFromBOM( m_cbExcludeFromBom->IsChecked(), &currentSheet, currentVariant );
934 m_symbol->SetExcludedFromBoard( m_cbExcludeFromBoard->IsChecked(), &currentSheet, currentVariant );
935 m_symbol->SetExcludedFromPosFiles( m_cbExcludeFromPosFiles->IsChecked(), &currentSheet, currentVariant );
936 m_symbol->SetDNP( m_cbDNP->IsChecked(), &currentSheet, currentVariant );
937
938 switch( m_choicePassthrough->GetSelection() )
939 {
940 case 0: m_symbol->SetPassthroughMode( SCH_SYMBOL::PASSTHROUGH_MODE::DEFAULT ); break;
941 case 1: m_symbol->SetPassthroughMode( SCH_SYMBOL::PASSTHROUGH_MODE::BLOCK ); break;
942 case 2: m_symbol->SetPassthroughMode( SCH_SYMBOL::PASSTHROUGH_MODE::FORCE ); break;
943 default: break;
944 }
945
946 // Update any assignments
947 if( m_dataModel )
948 {
949 for( const SCH_PIN& model_pin : *m_dataModel )
950 {
951 // map from the edited copy back to the "real" pin(s) in the symbol.
952 for( SCH_PIN* src_pin : m_symbol->GetPinsByNumber( model_pin.GetNumber() ) )
953 src_pin->SetAlt( model_pin.GetAlt() );
954 }
955 }
956
957 // Keep fields other than the reference, include/exclude flags, and alternate pin assignements
958 // in sync in multi-unit parts.
959 m_symbol->SyncOtherUnits( currentSheet, commit, nullptr, currentVariant );
960
961 if( replaceOnCurrentScreen )
962 currentScreen->Append( m_symbol );
963
964 if( !commit.Empty() )
965 commit.Push( _( "Edit Symbol Properties" ) );
966
967 return true;
968}
969
970
972{
973 wxGridCellEditor* editor = m_fieldsGrid->GetCellEditor( event.GetRow(), event.GetCol() );
974 wxControl* control = editor->GetControl();
975
976 if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) )
977 {
978 event.Veto();
979 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
980 evt->SetClientData( new VECTOR2I( event.GetRow(), event.GetCol() ) );
981 QueueEvent( evt );
982 }
983 else if( event.GetCol() == FDC_NAME )
984 {
985 wxString newName = event.GetString();
986
987 for( int i = 0; i < m_fieldsGrid->GetNumberRows(); ++i )
988 {
989 if( i == event.GetRow() )
990 continue;
991
992 if( FieldNamesAreDuplicates( newName, m_fieldsGrid->GetCellValue( i, FDC_NAME ) ) )
993 {
994 DisplayErrorMessage( this, wxString::Format( _( "Field name '%s' already in use." ), newName ) );
995 event.Veto();
996 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
997 evt->SetClientData( new VECTOR2I( event.GetRow(), event.GetCol() ) );
998 QueueEvent( evt );
999 }
1000 }
1001 }
1002
1003 editor->DecRef();
1004}
1005
1006
1008{
1009 if( m_fields->at( aEvent.GetRow() ).GetId() == FIELD_T::REFERENCE
1010 && aEvent.GetCol() == FDC_VALUE )
1011 {
1012 wxCommandEvent* evt = new wxCommandEvent( SYMBOL_DELAY_SELECTION );
1013 evt->SetClientData( new VECTOR2I( aEvent.GetRow(), aEvent.GetCol() ) );
1014 QueueEvent( evt );
1015 }
1016
1017 m_editorShown = true;
1018}
1019
1020
1022{
1023 m_editorShown = false;
1024}
1025
1026
1027void DIALOG_SYMBOL_PROPERTIES::OnAddField( wxCommandEvent& event )
1028{
1029 m_fieldsGrid->OnAddRow(
1030 [&]() -> std::pair<int, int>
1031 {
1033
1034 newField.SetTextAngle( m_fields->GetField( FIELD_T::REFERENCE )->GetTextAngle() );
1035 newField.SetVisible( false );
1036
1037 m_fields->push_back( newField );
1038
1039 // notify the grid
1040 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
1041 m_fieldsGrid->ProcessTableMessage( msg );
1042 OnModify();
1043
1044 return { m_fields->size() - 1, FDC_NAME };
1045 } );
1046}
1047
1048
1049void DIALOG_SYMBOL_PROPERTIES::OnDeleteField( wxCommandEvent& event )
1050{
1051 m_fieldsGrid->OnDeleteRows(
1052 [&]( int row )
1053 {
1054 if( row < m_fields->GetMandatoryRowCount() )
1055 {
1056 DisplayErrorMessage( this, wxString::Format( _( "The first %d fields are mandatory." ),
1057 m_fields->GetMandatoryRowCount() ) );
1058 return false;
1059 }
1060
1061 return true;
1062 },
1063 [&]( int row )
1064 {
1065 m_fields->erase( m_fields->begin() + row );
1066
1067 // notify the grid
1068 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
1069 m_fieldsGrid->ProcessTableMessage( msg );
1070 } );
1071
1072 OnModify();
1073}
1074
1075
1076void DIALOG_SYMBOL_PROPERTIES::OnMoveUp( wxCommandEvent& event )
1077{
1078 m_fieldsGrid->OnMoveRowUp(
1079 [&]( int row )
1080 {
1081 return row > m_fields->GetMandatoryRowCount();
1082 },
1083 [&]( int row )
1084 {
1085 std::swap( *( m_fields->begin() + row ), *( m_fields->begin() + row - 1 ) );
1086 m_fieldsGrid->ForceRefresh();
1087 OnModify();
1088 } );
1089}
1090
1091
1092void DIALOG_SYMBOL_PROPERTIES::OnMoveDown( wxCommandEvent& event )
1093{
1094 m_fieldsGrid->OnMoveRowDown(
1095 [&]( int row )
1096 {
1097 return row >= m_fields->GetMandatoryRowCount();
1098 },
1099 [&]( int row )
1100 {
1101 std::swap( *( m_fields->begin() + row ), *( m_fields->begin() + row + 1 ) );
1102 m_fieldsGrid->ForceRefresh();
1103 OnModify();
1104 } );
1105}
1106
1107
1113
1114
1120
1121
1127
1128
1130{
1131 if( !TransferDataFromWindow() )
1132 return;
1133
1134 if( !GetParent()->Schematic().GetCurrentVariant().IsEmpty() )
1136 else
1138}
1139
1140
1146
1147
1149{
1150 int row = aEvent.GetRow();
1151
1152 if( m_pinGrid->GetCellValue( row, COL_ALT_NAME ) == m_dataModel->GetValue( row, COL_BASE_NAME ) )
1153 m_dataModel->SetValue( row, COL_ALT_NAME, wxEmptyString );
1154
1155 // These are just to get the cells refreshed
1156 m_dataModel->SetValue( row, COL_TYPE, m_dataModel->GetValue( row, COL_TYPE ) );
1157 m_dataModel->SetValue( row, COL_SHAPE, m_dataModel->GetValue( row, COL_SHAPE ) );
1158
1159 OnModify();
1160}
1161
1162
1164{
1165 int sortCol = aEvent.GetCol();
1166 bool ascending;
1167
1168 // This is bonkers, but wxWidgets doesn't tell us ascending/descending in the
1169 // event, and if we ask it will give us pre-event info.
1170 if( m_pinGrid->IsSortingBy( sortCol ) )
1171 // same column; invert ascending
1172 ascending = !m_pinGrid->IsSortOrderAscending();
1173 else
1174 // different column; start with ascending
1175 ascending = true;
1176
1177 m_dataModel->SortRows( sortCol, ascending );
1178 m_dataModel->BuildAttrs();
1179}
1180
1181
1183{
1184 wxGridUpdateLocker deferRepaintsTillLeavingScope( m_pinGrid );
1185
1186 // Account for scroll bars
1187 int pinTblWidth = KIPLATFORM::UI::GetUnobscuredSize( m_pinGrid ).x;
1188
1189 // Stretch the Base Name and Alternate Assignment columns to fit.
1190 for( int i = 0; i < COL_COUNT; ++i )
1191 {
1192 if( i != COL_BASE_NAME && i != COL_ALT_NAME )
1193 pinTblWidth -= m_pinGrid->GetColSize( i );
1194 }
1195
1196 if( pinTblWidth > 2 )
1197 {
1198 m_pinGrid->SetColSize( COL_BASE_NAME, pinTblWidth / 2 );
1199 m_pinGrid->SetColSize( COL_ALT_NAME, pinTblWidth / 2 );
1200 }
1201}
1202
1203
1204void DIALOG_SYMBOL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
1205{
1206 std::bitset<64> shownColumns = m_fieldsGrid->GetShownColumns();
1207
1208 if( shownColumns != m_shownColumns )
1209 {
1210 m_shownColumns = shownColumns;
1211
1212 if( !m_fieldsGrid->IsCellEditControlShown() )
1213 m_fieldsGrid->SetGridWidthsDirty();
1214 }
1215}
1216
1217
1219{
1220 VECTOR2I *loc = static_cast<VECTOR2I*>( event.GetClientData() );
1221
1222 wxCHECK_RET( loc, wxT( "Missing focus cell location" ) );
1223
1224 // Run the AutoColumnSizer before setting focus (as it will clear any shown cell edit control
1225 // if it has to resize that column).
1226 m_fieldsGrid->RecomputeGridWidths();
1227
1228 // Handle a delayed focus
1229
1230 m_fieldsGrid->SetFocus();
1231 m_fieldsGrid->MakeCellVisible( loc->x, loc->y );
1232 m_fieldsGrid->SetGridCursor( loc->x, loc->y );
1233
1234 delete loc;
1235
1236 CallAfter(
1237 [this]()
1238 {
1239 m_fieldsGrid->EnableCellEditControl( true );
1240 } );
1241}
1242
1243
1245{
1246 VECTOR2I *loc = static_cast<VECTOR2I*>( event.GetClientData() );
1247
1248 wxCHECK_RET( loc, wxT( "Missing focus cell location" ) );
1249
1250 // Handle a delayed selection
1251 wxGridCellEditor* cellEditor = m_fieldsGrid->GetCellEditor( loc->x, loc->y );
1252
1253 if( wxTextEntry* txt = dynamic_cast<wxTextEntry*>( cellEditor->GetControl() ) )
1255
1256 cellEditor->DecRef(); // we're done; must release
1257 delete loc;
1258}
1259
1260
1262{
1263 wxSize new_size = event.GetSize();
1264
1265 if( ( !m_editorShown || m_lastRequestedPinsSize != new_size ) && m_pinsSize != new_size )
1266 {
1267 m_pinsSize = new_size;
1268
1270 }
1271
1272 // We store this value to check whether the dialog is changing size. This might indicate
1273 // that the user is scaling the dialog with a grid-cell-editor shown. Some editors do not
1274 // close (at least on GTK) when the user drags a dialog corner
1275 m_lastRequestedPinsSize = new_size;
1276
1277 // Always propagate for a grid repaint (needed if the height changes, as well as width)
1278 event.Skip();
1279}
1280
1281
1282void DIALOG_SYMBOL_PROPERTIES::OnCheckBox( wxCommandEvent& event )
1283{
1284 OnModify();
1285}
1286
1287
1288void DIALOG_SYMBOL_PROPERTIES::OnUnitChoice( wxCommandEvent& event )
1289{
1290 if( m_dataModel )
1291 {
1292 EDA_ITEM_FLAGS flags = m_symbol->GetFlags();
1293
1294 int unit_selection = m_unitChoice->GetSelection() + 1;
1295
1296 // We need to select a new unit to build the new unit pin list
1297 // but we should not change the symbol, so the initial unit will be selected
1298 // after rebuilding the pin list
1299 int old_unit = m_symbol->GetUnit();
1300 m_symbol->SetUnit( unit_selection );
1301
1302 // Rebuild a copy of the pins of the new unit for editing
1303 m_dataModel->clear();
1304
1305 for( const std::unique_ptr<SCH_PIN>& pin : m_symbol->GetRawPins() )
1306 m_dataModel->push_back( *pin );
1307
1308 m_dataModel->SortRows( COL_NUMBER, true );
1309 m_dataModel->BuildAttrs();
1310
1311 m_symbol->SetUnit( old_unit );
1312
1313 // Restore m_Flag modified by SetUnit()
1314 m_symbol->ClearFlags();
1315 m_symbol->SetFlags( flags );
1316 }
1317
1318 OnModify();
1319}
1320
1321
1323{
1324 event.Enable( m_symbol && m_symbol->GetLibSymbolRef() );
1325}
1326
1327
1329{
1330 event.Enable( m_symbol && m_symbol->GetLibSymbolRef() );
1331}
1332
1333
1334void DIALOG_SYMBOL_PROPERTIES::OnPageChanging( wxBookCtrlEvent& aEvent )
1335{
1336 if( !m_fieldsGrid->CommitPendingChanges() )
1337 aEvent.Veto();
1338
1339 if( !m_pinGrid->CommitPendingChanges() )
1340 aEvent.Veto();
1341}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:106
bool Empty() const
Definition commit.h:142
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:102
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void EndDialogShim(int aReturnCode)
A mode agnostic way to close a dialog.
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
EDA_BASE_FRAME * m_parentFrame
int ShowModal() override
DIALOG_SYMBOL_PROPERTIES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Symbol Properties"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU)
void OnSizePinsGrid(wxSizeEvent &event) override
void OnPinTableCellEdited(wxGridEvent &event) override
void OnGridEditorShown(wxGridEvent &event) override
void OnClearVariantSymbol(wxCommandEvent &) override
void OnUpdateUI(wxUpdateUIEvent &event) override
void OnEditSymbol(wxCommandEvent &) override
void OnCancelButtonClick(wxCommandEvent &event) override
virtual void onUpdateEditLibrarySymbol(wxUpdateUIEvent &event) override
PANEL_SYMBOL_PIN_MAP * m_pinMapPanel
SCH_PIN_TABLE_DATA_MODEL * m_dataModel
void OnMoveDown(wxCommandEvent &event) override
void OnPinTableColSort(wxGridEvent &aEvent)
void OnMoveUp(wxCommandEvent &event) override
void OnDeleteField(wxCommandEvent &event) override
void OnAddField(wxCommandEvent &event) override
void OnGridEditorHidden(wxGridEvent &event) override
PANEL_EMBEDDED_FILES * m_embeddedFiles
void OnUnitChoice(wxCommandEvent &event) override
void OnEditSpiceModel(wxCommandEvent &event) override
void OnPageChanging(wxNotebookEvent &event) override
DIALOG_SYMBOL_PROPERTIES(SCH_EDIT_FRAME *aParent, SCH_SYMBOL *aSymbol)
void HandleDelayedFocus(wxCommandEvent &event)
void HandleDelayedSelection(wxCommandEvent &event)
void OnCheckBox(wxCommandEvent &event) override
void OnGridCellChanging(wxGridEvent &event)
void OnEditLibrarySymbol(wxCommandEvent &) override
void OnUpdateSymbol(wxCommandEvent &) override
void SelectPinMapPage()
Select the Pin Map page so the dialog opens directly on the pin-to-pad mapping editor (issue #2282).
void OnExchangeSymbol(wxCommandEvent &) override
virtual void onUpdateEditSymbol(wxUpdateUIEvent &event) override
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:153
virtual void Offset(const VECTOR2I &aOffset)
Definition eda_text.cpp:558
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:342
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition eda_text.cpp:263
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition grid_tricks.h:57
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
Composed widget that edits a symbol's named pin maps and the footprint each is bound to.
static int Compare(const wxString &lhs, const wxString &rhs)
TEMPLATES m_TemplateFieldNames
Project and global field name templates shared by project editors.
virtual PROJECT_FILE & GetProjectFile() const
Definition project.h:201
Holds all the data relating to one schematic.
Definition schematic.h:148
wxString ConvertKIIDsToRefs(const wxString &aSource) const
void SyncLibSymbolPinMaps(const wxString &aSchLibSymbolName, const LIB_SYMBOL &aSource, SCH_COMMIT *aCommit)
PROJECT & Project() const
Return a reference to the project this schematic is part of.
Definition schematic.h:170
wxString GetCurrentVariant() const
Return the current variant being edited.
SCH_SHEET_PATH & CurrentSheet() const
Definition schematic.h:303
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Schematic editor (Eeschema) main window.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
bool IsMandatory() const
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:138
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetText(const wxString &aText) override
bool IsEmptyCell(int row, int col) override
wxString GetValue(int aRow, int aCol) override
std::vector< wxGridCellAttr * > m_nameAttrs
static bool compare(const SCH_PIN &lhs, const SCH_PIN &rhs, int sortCol, bool ascending)
void SortRows(int aSortCol, bool ascending)
bool CanSetValueAs(int aRow, int aCol, const wxString &aTypeName) override
static wxString GetValue(const SCH_PIN &aPin, int aCol)
wxString GetColLabelValue(int aCol) override
void SetValue(int aRow, int aCol, const wxString &aValue) override
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind) override
const std::map< wxString, ALT > & GetAlternates() const
Definition sch_pin.h:217
ALT GetAlt(const wxString &aAlt)
Definition sch_pin.h:231
SCH_PIN * GetLibPin() const
Definition sch_pin.h:107
const wxString & GetName() const
Definition sch_pin.cpp:503
const wxString & GetBaseName() const
Get the name without any alternates.
Definition sch_pin.cpp:512
const wxString & GetNumber() const
Definition sch_pin.h:142
GRAPHIC_PINSHAPE GetShape() const
Definition sch_pin.cpp:376
ELECTRICAL_PINTYPE GetType() const
Definition sch_pin.cpp:411
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Schematic symbol object.
Definition sch_symbol.h:75
std::optional< SCH_SYMBOL_VARIANT > GetVariant(const SCH_SHEET_PATH &aInstance, const wxString &aVariantName) const
const std::vector< TEMPLATE_FIELDNAME > & GetResolvedTemplateFieldNames()
Return the resolved project and global template field name list for read only access.
wxGridCellAttr * enhanceAttr(wxGridCellAttr *aInputAttr, int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind)
Definition wx_grid.cpp:43
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:217
This file is part of the common library.
wxDEFINE_EVENT(SYMBOL_DELAY_FOCUS, wxCommandEvent)
@ SYMBOL_PROPS_EDIT_SCHEMATIC_SYMBOL
@ SYMBOL_PROPS_WANT_EXCHANGE_SYMBOL
@ SYMBOL_PROPS_WANT_UPDATE_SYMBOL
@ SYMBOL_PROPS_WANT_SET_VARIANT_SYMBOL
@ SYMBOL_PROPS_EDIT_LIBRARY_SYMBOL
@ SYMBOL_PROPS_WANT_CLEAR_VARIANT_SYMBOL
#define _(s)
std::uint32_t EDA_ITEM_FLAGS
@ FDC_NAME
@ FDC_VALUE
wxColour GetDialogBGColour()
Definition wxgtk/ui.cpp:64
wxSize GetUnobscuredSize(const wxWindow *aWindow)
Tries to determine the size of the viewport of a scrollable widget (wxDataViewCtrl,...
Definition wxgtk/ui.cpp:367
KICOMMON_API wxFont GetSmallInfoFont(wxWindow *aWindow)
KICOMMON_API wxFont GetControlFont(wxWindow *aWindow)
KICOMMON_API void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
const std::vector< BITMAPS > & PinTypeIcons()
Definition pin_type.cpp:158
const wxArrayString & PinTypeNames()
Definition pin_type.cpp:149
const wxArrayString & PinShapeNames()
Definition pin_type.cpp:167
const std::vector< BITMAPS > & PinShapeIcons()
Definition pin_type.cpp:176
#define NO_PIN_FUNCTIONS_WITH_MULTIPLE_BODY_STYLES
Definition sch_actions.h:33
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
wxString UnescapeString(const wxString &aSource)
Hold a name of a symbol's field, field value, and default visibility.
@ SYM_ORIENT_270
Definition symbol.h:38
@ SYM_MIRROR_Y
Definition symbol.h:40
@ SYM_ORIENT_180
Definition symbol.h:37
@ SYM_MIRROR_X
Definition symbol.h:39
@ SYM_ORIENT_90
Definition symbol.h:36
@ SYM_ORIENT_0
Definition symbol.h:35
bool FieldNamesAreDuplicates(const wxString &aLhs, const wxString &aRhs, std::initializer_list< FIELD_T > aMandatoryFields)
Test whether two field names should be treated as duplicates for the purposes of field name uniquenes...
wxString GetUserFieldName(int aFieldNdx, TRANSLATION aTranslation)
@ USER
The field ID hasn't been set yet; field is invalid.
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ TRANSLATED
KIBIS_PIN * pin
VECTOR3I res
VECTOR2I end
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683