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 (C) 2004-2023 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 <memory>
27
28#include <bitmaps.h>
29#include <wx/tooltip.h>
30#include <grid_tricks.h>
31#include <confirm.h>
32#include <kiface_base.h>
33#include <pin_numbers.h>
34#include <string_utils.h>
35#include <kiplatform/ui.h>
40#include <ee_collectors.h>
41#include <symbol_library.h>
42#include <fields_grid_table.h>
43#include <sch_edit_frame.h>
44#include <sch_reference_list.h>
45#include <schematic.h>
46#include <sch_commit.h>
47#include <tool/tool_manager.h>
48#include <tool/actions.h>
49
50#include <dialog_sim_model.h>
51
52
53wxDEFINE_EVENT( SYMBOL_DELAY_FOCUS, wxCommandEvent );
54wxDEFINE_EVENT( SYMBOL_DELAY_SELECTION, wxCommandEvent );
55
57{
63
64 COL_COUNT // keep as last
65};
66
67
68class SCH_PIN_TABLE_DATA_MODEL : public wxGridTableBase, public std::vector<SCH_PIN>
69{
70public:
72 m_readOnlyAttr( nullptr ),
73 m_typeAttr( nullptr ),
74 m_shapeAttr( nullptr )
75 {
76 }
77
79 {
80 for( wxGridCellAttr* attr : m_nameAttrs )
81 attr->DecRef();
82
83 m_readOnlyAttr->DecRef();
84 m_typeAttr->DecRef();
85 m_shapeAttr->DecRef();
86 }
87
89 {
90 for( wxGridCellAttr* attr : m_nameAttrs )
91 attr->DecRef();
92
93 m_nameAttrs.clear();
94
95 if( m_readOnlyAttr )
96 m_readOnlyAttr->DecRef();
97
98 m_readOnlyAttr = new wxGridCellAttr;
99 m_readOnlyAttr->SetReadOnly( true );
100
101 for( const SCH_PIN& pin : *this )
102 {
103 LIB_PIN* lib_pin = pin.GetLibPin();
104 wxGridCellAttr* attr = nullptr;
105
106 if( lib_pin->GetAlternates().empty() )
107 {
108 attr = new wxGridCellAttr;
109 attr->SetReadOnly( true );
110 attr->SetBackgroundColour( KIPLATFORM::UI::GetDialogBGColour() );
111 }
112 else
113 {
114 wxArrayString choices;
115 choices.push_back( lib_pin->GetName() );
116
117 for( const std::pair<const wxString, LIB_PIN::ALT>& alt : lib_pin->GetAlternates() )
118 choices.push_back( alt.first );
119
120 attr = new wxGridCellAttr();
121 attr->SetEditor( new GRID_CELL_COMBOBOX( choices ) );
122 }
123
124 m_nameAttrs.push_back( attr );
125 }
126
127 if( m_typeAttr )
128 m_typeAttr->DecRef();
129
130 m_typeAttr = new wxGridCellAttr;
132 PinTypeNames() ) );
133 m_typeAttr->SetReadOnly( true );
134
135 if( m_shapeAttr )
136 m_shapeAttr->DecRef();
137
138 m_shapeAttr = new wxGridCellAttr;
140 PinShapeNames() ) );
141 m_shapeAttr->SetReadOnly( true );
142 }
143
144 int GetNumberRows() override { return (int) size(); }
145 int GetNumberCols() override { return COL_COUNT; }
146
147 wxString GetColLabelValue( int aCol ) override
148 {
149 switch( aCol )
150 {
151 case COL_NUMBER: return _( "Number" );
152 case COL_BASE_NAME: return _( "Base Name" );
153 case COL_ALT_NAME: return _( "Alternate Assignment" );
154 case COL_TYPE: return _( "Electrical Type" );
155 case COL_SHAPE: return _( "Graphic Style" );
156 default: wxFAIL; return wxEmptyString;
157 }
158 }
159
160 bool IsEmptyCell( int row, int col ) override
161 {
162 return false; // don't allow adjacent cell overflow, even if we are actually empty
163 }
164
165 bool CanSetValueAs( int aRow, int aCol, const wxString& aTypeName ) override
166 {
167 // Don't accept random values; must use the popup to change to a known alternate
168 return false;
169 }
170
171 wxString GetValue( int aRow, int aCol ) override
172 {
173 return GetValue( at( aRow ), aCol );
174 }
175
176 static wxString GetValue( const SCH_PIN& aPin, int aCol )
177 {
178 if( aCol == COL_ALT_NAME )
179 {
180 if( aPin.GetLibPin()->GetAlternates().empty() )
181 return wxEmptyString;
182 else if( aPin.GetAlt().IsEmpty() )
183 return aPin.GetName();
184 else
185 return aPin.GetAlt();
186 }
187
188 switch( aCol )
189 {
190 case COL_NUMBER: return aPin.GetNumber();
191 case COL_BASE_NAME: return aPin.GetLibPin()->GetName();
192 case COL_TYPE: return PinTypeNames()[static_cast<int>( aPin.GetType() )];
193 case COL_SHAPE: return PinShapeNames()[static_cast<int>( aPin.GetShape() )];
194 default: wxFAIL; return wxEmptyString;
195 }
196 }
197
198 wxGridCellAttr* GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind ) override
199 {
200 switch( aCol )
201 {
202 case COL_NUMBER:
203 case COL_BASE_NAME:
204 m_readOnlyAttr->IncRef();
205 return m_readOnlyAttr;
206
207 case COL_ALT_NAME:
208 m_nameAttrs[ aRow ]->IncRef();
209 return m_nameAttrs[ aRow ];
210
211 case COL_TYPE:
212 m_typeAttr->IncRef();
213 return m_typeAttr;
214
215 case COL_SHAPE:
216 m_shapeAttr->IncRef();
217 return m_shapeAttr;
218
219 default:
220 wxFAIL;
221 return nullptr;
222 }
223 }
224
225 void SetValue( int aRow, int aCol, const wxString &aValue ) override
226 {
227 switch( aCol )
228 {
229 case COL_ALT_NAME:
230 if( aValue == at( aRow ).GetLibPin()->GetName() )
231 at( aRow ).SetAlt( wxEmptyString );
232 else
233 at( aRow ).SetAlt( aValue );
234 break;
235
236 case COL_NUMBER:
237 case COL_BASE_NAME:
238 case COL_TYPE:
239 case COL_SHAPE:
240 // Read-only.
241 break;
242
243 default:
244 wxFAIL;
245 break;
246 }
247 }
248
249 static bool compare( const SCH_PIN& lhs, const SCH_PIN& rhs, int sortCol, bool ascending )
250 {
251 wxString lhStr = GetValue( lhs, sortCol );
252 wxString rhStr = GetValue( rhs, sortCol );
253
254 if( lhStr == rhStr )
255 {
256 // Secondary sort key is always COL_NUMBER
257 sortCol = COL_NUMBER;
258 lhStr = GetValue( lhs, sortCol );
259 rhStr = GetValue( rhs, sortCol );
260 }
261
262 bool res;
263
264 // N.B. To meet the iterator sort conditions, we cannot simply invert the truth
265 // to get the opposite sort. i.e. ~(a<b) != (a>b)
266 auto cmp = [ ascending ]( const auto a, const auto b )
267 {
268 if( ascending )
269 return a < b;
270 else
271 return b < a;
272 };
273
274 switch( sortCol )
275 {
276 case COL_NUMBER:
277 case COL_BASE_NAME:
278 case COL_ALT_NAME:
279 res = cmp( PIN_NUMBERS::Compare( lhStr, rhStr ), 0 );
280 break;
281 case COL_TYPE:
282 case COL_SHAPE:
283 res = cmp( lhStr.CmpNoCase( rhStr ), 0 );
284 break;
285 default:
286 res = cmp( StrNumCmp( lhStr, rhStr ), 0 );
287 break;
288 }
289
290 return res;
291 }
292
293 void SortRows( int aSortCol, bool ascending )
294 {
295 std::sort( begin(), end(),
296 [ aSortCol, ascending ]( const SCH_PIN& lhs, const SCH_PIN& rhs ) -> bool
297 {
298 return compare( lhs, rhs, aSortCol, ascending );
299 } );
300 }
301
302protected:
303 std::vector<wxGridCellAttr*> m_nameAttrs;
304 wxGridCellAttr* m_readOnlyAttr;
305 wxGridCellAttr* m_typeAttr;
306 wxGridCellAttr* m_shapeAttr;
307};
308
309
311 SCH_SYMBOL* aSymbol ) :
313 m_symbol( nullptr ),
314 m_part( nullptr ),
315 m_fieldsSize( 0, 0 ),
316 m_lastRequestedSize( 0, 0 ),
317 m_editorShown( false ),
318 m_fields( nullptr ),
319 m_dataModel( nullptr )
320{
321 m_symbol = aSymbol;
323
324 // GetLibSymbolRef() now points to the cached part in the schematic, which should always be
325 // there for usual cases, but can be null when opening old schematics not storing the part
326 // so we need to handle m_part == nullptr
327 // wxASSERT( m_part );
328
330
331 // Give a bit more room for combobox editors
332 m_fieldsGrid->SetDefaultRowSize( m_fieldsGrid->GetDefaultRowSize() + 4 );
333 m_pinGrid->SetDefaultRowSize( m_pinGrid->GetDefaultRowSize() + 4 );
334
336 m_fieldsGrid->PushEventHandler( new FIELDS_GRID_TRICKS( m_fieldsGrid, this,
337 [&]( wxCommandEvent& aEvent )
338 {
339 OnAddField( aEvent );
340 } ) );
341 m_fieldsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
342
343 // Show/hide columns according to user's preference
344 if( EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ) )
345 {
346 m_fieldsGrid->ShowHideColumns( cfg->m_Appearance.edit_symbol_visible_columns );
348 }
349
350 if( m_part && m_part->HasConversion() )
351 {
352 // DeMorgan conversions are a subclass of alternate pin assignments, so don't allow
353 // free-form alternate assignments as well. (We won't know how to map the alternates
354 // back and forth when the conversion is changed.)
355 m_pinTablePage->Disable();
356 m_pinTablePage->SetToolTip( _( "Alternate pin assignments are not available for De Morgan "
357 "symbols." ) );
358 }
359 else
360 {
362
363 // Make a copy of the pins for editing
364 for( const std::unique_ptr<SCH_PIN>& pin : m_symbol->GetRawPins() )
365 m_dataModel->push_back( *pin );
366
369
371 }
372
373 if( m_part && m_part->IsPower() )
374 m_spiceFieldsButton->Hide();
375
376 m_pinGrid->PushEventHandler( new GRID_TRICKS( m_pinGrid ) );
377 m_pinGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
378
379 m_tcLibraryID->SetBackgroundColour( KIPLATFORM::UI::GetDialogBGColour() );
380
381 wxToolTip::Enable( true );
383
384 // Configure button logos
385 m_bpAdd->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
386 m_bpDelete->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
387 m_bpMoveUp->SetBitmap( KiBitmapBundle( BITMAPS::small_up ) );
388 m_bpMoveDown->SetBitmap( KiBitmapBundle( BITMAPS::small_down ) );
389
390 // wxFormBuilder doesn't include this event...
391 m_fieldsGrid->Bind( wxEVT_GRID_CELL_CHANGING, &DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging,
392 this );
393 m_pinGrid->Bind( wxEVT_GRID_COL_SORT, &DIALOG_SYMBOL_PROPERTIES::OnPinTableColSort, this );
394 Bind( SYMBOL_DELAY_FOCUS, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedFocus, this );
395 Bind( SYMBOL_DELAY_SELECTION, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedSelection, this );
396
397 QueueEvent( new wxCommandEvent( SYMBOL_DELAY_SELECTION ) );
398 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
399 evt->SetClientData( new VECTOR2I( REFERENCE_FIELD, FDC_VALUE ) );
400 QueueEvent( evt );
401
403}
404
405
407{
408 if( EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ) )
409 {
410 cfg->m_Appearance.edit_symbol_visible_columns = m_fieldsGrid->GetShownColumnsAsString();
411 cfg->m_Appearance.edit_symbol_width = GetSize().x;
412 cfg->m_Appearance.edit_symbol_height = GetSize().y;
413 }
414
415 // Prevents crash bug in wxGrid's d'tor
417
418 if( m_dataModel )
420
421 m_fieldsGrid->Unbind( wxEVT_GRID_CELL_CHANGING, &DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging,
422 this );
423 m_pinGrid->Unbind( wxEVT_GRID_COL_SORT, &DIALOG_SYMBOL_PROPERTIES::OnPinTableColSort, this );
424 Unbind( SYMBOL_DELAY_FOCUS, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedFocus, this );
425 Unbind( SYMBOL_DELAY_SELECTION, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedSelection, this );
426
427 // Delete the GRID_TRICKS.
428 m_fieldsGrid->PopEventHandler( true );
429 m_pinGrid->PopEventHandler( true );
430}
431
432
434{
435 return dynamic_cast<SCH_EDIT_FRAME*>( wxDialog::GetParent() );
436}
437
438
440{
441 if( !wxDialog::TransferDataToWindow() )
442 return false;
443
444 std::set<wxString> defined;
445
446 // Push a copy of each field into m_updateFields
447 for( int i = 0; i < m_symbol->GetFieldCount(); ++i )
448 {
449 SCH_FIELD field( m_symbol->GetFields()[i] );
450
451 // change offset to be symbol-relative
452 field.Offset( -m_symbol->GetPosition() );
453
454 defined.insert( field.GetName() );
455 m_fields->push_back( field );
456 }
457
458 // Add in any template fieldnames not yet defined:
459 for( const TEMPLATE_FIELDNAME& templateFieldname :
460 GetParent()->Schematic().Settings().m_TemplateFieldNames.GetTemplateFieldNames() )
461 {
462 if( defined.count( templateFieldname.m_Name ) <= 0 )
463 {
464 SCH_FIELD field( VECTOR2I( 0, 0 ), -1, m_symbol, templateFieldname.m_Name );
465 field.SetVisible( templateFieldname.m_Visible );
466 m_fields->push_back( field );
467 }
468 }
469
470 // notify the grid
471 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->size() );
472 m_fieldsGrid->ProcessTableMessage( msg );
474
475 // If a multi-unit symbol, set up the unit selector and interchangeable checkbox.
476 if( m_symbol->GetUnitCount() > 1 )
477 {
478 // Ensure symbol unit is the currently selected unit (mandatory in complex hierarchies)
479 // from the current sheet path, because it can be modified by previous calculations
480 m_symbol->UpdateUnit( m_symbol->GetUnitSelection( &GetParent()->GetCurrentSheet() ) );
481
482 for( int ii = 1; ii <= m_symbol->GetUnitCount(); ii++ )
483 {
484 if( m_symbol->HasUnitDisplayName( ii ) )
485 m_unitChoice->Append( m_symbol->GetUnitDisplayName( ii ) );
486 else
487 m_unitChoice->Append( m_symbol->SubReference( ii, false ) );
488 }
489
490 if( m_symbol->GetUnit() <= ( int )m_unitChoice->GetCount() )
491 m_unitChoice->SetSelection( m_symbol->GetUnit() - 1 );
492 }
493 else
494 {
495 m_unitLabel->Enable( false );
496 m_unitChoice->Enable( false );
497 }
498
499 if( m_part && m_part->HasConversion() )
500 {
502 m_cbAlternateSymbol->SetValue( true );
503 }
504 else
505 {
506 m_cbAlternateSymbol->Enable( false );
507 }
508
509 // Set the symbol orientation and mirroring.
510 int orientation = m_symbol->GetOrientation() & ~( SYM_MIRROR_X | SYM_MIRROR_Y );
511
512 switch( orientation )
513 {
514 default:
515 case SYM_ORIENT_0: m_orientationCtrl->SetSelection( 0 ); break;
516 case SYM_ORIENT_90: m_orientationCtrl->SetSelection( 1 ); break;
517 case SYM_ORIENT_270: m_orientationCtrl->SetSelection( 2 ); break;
518 case SYM_ORIENT_180: m_orientationCtrl->SetSelection( 3 ); break;
519 }
520
521 int mirror = m_symbol->GetOrientation() & ( SYM_MIRROR_X | SYM_MIRROR_Y );
522
523 switch( mirror )
524 {
525 default: m_mirrorCtrl->SetSelection( 0 ) ; break;
526 case SYM_MIRROR_X: m_mirrorCtrl->SetSelection( 1 ); break;
527 case SYM_MIRROR_Y: m_mirrorCtrl->SetSelection( 2 ); break;
528 }
529
533 m_cbDNP->SetValue( m_symbol->GetDNP() );
534
535 if( m_part )
536 {
537 m_ShowPinNumButt->SetValue( m_part->ShowPinNumbers() );
538 m_ShowPinNameButt->SetValue( m_part->ShowPinNames() );
539 }
540
541 // Set the symbol's library name.
543
544 Layout();
545 m_fieldsGrid->Layout();
546 wxSafeYield();
547
548 return true;
549}
550
551
553{
555 return;
556
557 std::vector<SCH_FIELD> fields;
558
559 for( const SCH_FIELD& field : *m_fields )
560 fields.emplace_back( field );
561
562 DIALOG_SIM_MODEL dialog( this, *m_symbol, fields );
563
564 if( dialog.ShowModal() != wxID_OK )
565 return;
566
567 // Add in any new fields
568 for( const SCH_FIELD& editedField : fields )
569 {
570 bool found = false;
571
572 for( SCH_FIELD& existingField : *m_fields )
573 {
574 if( existingField.GetName() == editedField.GetName() )
575 {
576 found = true;
577 existingField.SetText( editedField.GetText() );
578 break;
579 }
580 }
581
582 if( !found )
583 {
584 m_fields->emplace_back( editedField );
585 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
586 m_fieldsGrid->ProcessTableMessage( msg );
587 }
588 }
589
590 // Remove any deleted fields
591 for( int ii = (int) m_fields->size() - 1; ii >= 0; --ii )
592 {
593 SCH_FIELD& existingField = m_fields->at( ii );
594 bool found = false;
595
596 for( SCH_FIELD& editedField : fields )
597 {
598 if( editedField.GetName() == existingField.GetName() )
599 {
600 found = true;
601 break;
602 }
603 }
604
605 if( !found )
606 {
607 m_fields->erase( m_fields->begin() + ii );
608 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, ii, 1 );
609 m_fieldsGrid->ClearSelection();
610 m_fieldsGrid->ProcessTableMessage( msg );
611 }
612 }
613
614 OnModify();
615 m_fieldsGrid->ForceRefresh();
616}
617
618
620{
621 // Running the Footprint Browser gums up the works and causes the automatic cancel
622 // stuff to no longer work. So we do it here ourselves.
623 EndQuasiModal( wxID_CANCEL );
624}
625
626
628{
629 LIB_ID id;
630
631 if( !m_fieldsGrid->CommitPendingChanges() || !m_fieldsGrid->Validate() )
632 return false;
633
635 {
636 DisplayErrorMessage( this, _( "References must start with a letter." ) );
637
638 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
639 evt->SetClientData( new VECTOR2I( REFERENCE_FIELD, FDC_VALUE ) );
640 QueueEvent( evt );
641
642 return false;
643 }
644
645 // Check for missing field names.
646 for( size_t i = MANDATORY_FIELDS; i < m_fields->size(); ++i )
647 {
648 SCH_FIELD& field = m_fields->at( i );
649 wxString fieldName = field.GetName( false );
650
651 if( fieldName.IsEmpty() )
652 {
653 DisplayErrorMessage( this, _( "Fields must have a name." ) );
654
655 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
656 evt->SetClientData( new VECTOR2I( i, FDC_VALUE ) );
657 QueueEvent( evt );
658
659 return false;
660 }
661 }
662
663 return true;
664}
665
666
668{
669 if( !wxDialog::TransferDataFromWindow() ) // Calls our Validate() method.
670 return false;
671
673 return false;
674
676 return false;
677
678 SCH_COMMIT commit( GetParent() );
679 SCH_SCREEN* currentScreen = GetParent()->GetScreen();
680 bool replaceOnCurrentScreen;
681 wxCHECK( currentScreen, false );
682
683 // This needs to be done before the LIB_ID is changed to prevent stale library symbols in
684 // the schematic file.
685 replaceOnCurrentScreen = currentScreen->Remove( m_symbol );
686
687 // save old cmp in undo list if not already in edit, or moving ...
688 if( m_symbol->GetEditFlags() == 0 )
689 commit.Modify( m_symbol, currentScreen );
690
691 // Save current flags which could be modified by next change settings
693
694 // For symbols with multiple shapes (De Morgan representation) Set the selected shape:
695 if( m_cbAlternateSymbol->IsEnabled() && m_cbAlternateSymbol->GetValue() )
697 else
699
700 //Set the part selection in multiple part per package
701 int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1;
702 m_symbol->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection );
703 m_symbol->SetUnit( unit_selection );
704
705 switch( m_orientationCtrl->GetSelection() )
706 {
707 case 0: m_symbol->SetOrientation( SYM_ORIENT_0 ); break;
708 case 1: m_symbol->SetOrientation( SYM_ORIENT_90 ); break;
709 case 2: m_symbol->SetOrientation( SYM_ORIENT_270 ); break;
710 case 3: m_symbol->SetOrientation( SYM_ORIENT_180 ); break;
711 }
712
713 switch( m_mirrorCtrl->GetSelection() )
714 {
715 case 0: break;
716 case 1: m_symbol->SetOrientation( SYM_MIRROR_X ); break;
717 case 2: m_symbol->SetOrientation( SYM_MIRROR_Y ); break;
718 }
719
720 if( m_part )
721 {
724 }
725
726 // Restore m_Flag modified by SetUnit() and other change settings from the dialog
728 m_symbol->SetFlags( flags );
729
730 // change all field positions from relative to absolute
731 for( unsigned i = 0; i < m_fields->size(); ++i )
732 m_fields->at( i ).Offset( m_symbol->GetPosition() );
733
734 SCH_FIELDS& fields = m_symbol->GetFields();
735
736 fields.clear();
737
738 for( size_t ii = 0; ii < m_fields->size(); ++ii )
739 {
740 SCH_FIELD& field = m_fields->at( ii );
741 const wxString& fieldName = field.GetCanonicalName();
742
743 if( fieldName.IsEmpty() && field.GetText().IsEmpty() )
744 continue;
745 else if( fieldName.IsEmpty() )
746 field.SetName( _( "untitled" ) );
747
748 fields.push_back( field );
749 }
750
751 // Reference has a specific initialization, depending on the current active sheet
752 // because for a given symbol, in a complex hierarchy, there are more than one
753 // reference.
754 m_symbol->SetRef( &GetParent()->GetCurrentSheet(), m_fields->at( REFERENCE_FIELD ).GetText() );
755
756 // Similar for Value and Footprint, except that the GUI behavior is that they are kept
757 // in sync between multiple instances.
758 m_symbol->SetValueFieldText( m_fields->at( VALUE_FIELD ).GetText() );
760
764 m_symbol->SetDNP( m_cbDNP->IsChecked() );
765
766 // Update any assignments
767 if( m_dataModel )
768 {
769 for( const SCH_PIN& model_pin : *m_dataModel )
770 {
771 // map from the edited copy back to the "real" pin in the symbol.
772 SCH_PIN* src_pin = m_symbol->GetPin( model_pin.GetNumber() );
773
774 if( src_pin )
775 src_pin->SetAlt( model_pin.GetAlt() );
776 }
777 }
778
779 // Keep fields other than the reference, include/exclude flags, and alternate pin assignements
780 // in sync in multi-unit parts.
781 if( m_symbol->GetUnitCount() > 1 && m_symbol->IsAnnotated( &GetParent()->GetCurrentSheet() ) )
782 {
783 wxString ref = m_symbol->GetRef( &GetParent()->GetCurrentSheet() );
784 int unit = m_symbol->GetUnit();
785 LIB_ID libId = m_symbol->GetLibId();
786
787 for( SCH_SHEET_PATH& sheet : GetParent()->Schematic().GetSheets() )
788 {
789 SCH_SCREEN* screen = sheet.LastScreen();
790 std::vector<SCH_SYMBOL*> otherUnits;
791
792 CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
793
794 for( SCH_SYMBOL* otherUnit : otherUnits )
795 {
796 commit.Modify( otherUnit, screen );
797 otherUnit->SetValueFieldText( m_fields->at( VALUE_FIELD ).GetText() );
798 otherUnit->SetFootprintFieldText( m_fields->at( FOOTPRINT_FIELD ).GetText() );
799
800 for( size_t ii = DATASHEET_FIELD; ii < m_fields->size(); ++ii )
801 {
802 SCH_FIELD* otherField = otherUnit->FindField( m_fields->at( ii ).GetName() );
803
804 if( otherField )
805 {
806 otherField->SetText( m_fields->at( ii ).GetText() );
807 }
808 else
809 {
810 SCH_FIELD newField( m_fields->at( ii ) );
811 const_cast<KIID&>( newField.m_Uuid ) = KIID();
812
813 newField.Offset( -m_symbol->GetPosition() );
814 newField.Offset( otherUnit->GetPosition() );
815
816 newField.SetParent( otherUnit );
817 otherUnit->AddField( newField );
818 }
819 }
820
821 for( size_t ii = otherUnit->GetFields().size() - 1; ii > DATASHEET_FIELD; ii-- )
822 {
823 SCH_FIELD& otherField = otherUnit->GetFields().at( ii );
824
825 if( !m_symbol->FindField( otherField.GetName() ) )
826 otherUnit->GetFields().erase( otherUnit->GetFields().begin() + ii );
827 }
828
829 otherUnit->SetExcludedFromSim( m_cbExcludeFromSim->IsChecked() );
830 otherUnit->SetExcludedFromBOM( m_cbExcludeFromBom->IsChecked() );
831 otherUnit->SetExcludedFromBoard( m_cbExcludeFromBoard->IsChecked() );
832 otherUnit->SetDNP( m_cbDNP->IsChecked() );
833
834 if( m_dataModel )
835 {
836 for( const SCH_PIN& model_pin : *m_dataModel )
837 {
838 SCH_PIN* src_pin = otherUnit->GetPin( model_pin.GetNumber() );
839
840 if( src_pin )
841 src_pin->SetAlt( model_pin.GetAlt() );
842 }
843 }
844 }
845 }
846 }
847
848 if( replaceOnCurrentScreen )
849 currentScreen->Append( m_symbol );
850
851 if( !commit.Empty() )
852 commit.Push( _( "Edit Symbol Properties" ) );
853
854 return true;
855}
856
857
859{
860 wxGridCellEditor* editor = m_fieldsGrid->GetCellEditor( event.GetRow(), event.GetCol() );
861 wxControl* control = editor->GetControl();
862
863 if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) )
864 {
865 event.Veto();
866 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
867 evt->SetClientData( new VECTOR2I( event.GetRow(), event.GetCol() ) );
868 QueueEvent( evt );
869 }
870 else if( event.GetCol() == FDC_NAME )
871 {
872 wxString newName = event.GetString();
873
874 for( int i = 0; i < m_fieldsGrid->GetNumberRows(); ++i )
875 {
876 if( i == event.GetRow() )
877 continue;
878
879 if( newName.CmpNoCase( m_fieldsGrid->GetCellValue( i, FDC_NAME ) ) == 0 )
880 {
881 DisplayError( this, wxString::Format( _( "Field name '%s' already in use." ),
882 newName ) );
883 event.Veto();
884 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
885 evt->SetClientData( new VECTOR2I( event.GetRow(), event.GetCol() ) );
886 QueueEvent( evt );
887 }
888 }
889 }
890
891 editor->DecRef();
892}
893
894
896{
897 if( aEvent.GetRow() == REFERENCE_FIELD && aEvent.GetCol() == FDC_VALUE )
898 QueueEvent( new wxCommandEvent( SYMBOL_DELAY_SELECTION ) );
899
900 m_editorShown = true;
901}
902
903
905{
906 m_editorShown = false;
907}
908
909
910void DIALOG_SYMBOL_PROPERTIES::OnAddField( wxCommandEvent& event )
911{
913 return;
914
916 int fieldID = (int) m_fields->size();
917 SCH_FIELD newField( VECTOR2I( 0, 0 ), fieldID, m_symbol,
919 DO_TRANSLATE ) );
920
921 newField.SetTextAngle( m_fields->at( REFERENCE_FIELD ).GetTextAngle() );
922 newField.SetTextSize( VECTOR2I( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
923
924 m_fields->push_back( newField );
925
926 // notify the grid
927 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
928 m_fieldsGrid->ProcessTableMessage( msg );
929
930 m_fieldsGrid->MakeCellVisible( (int) m_fields->size() - 1, 0 );
931 m_fieldsGrid->SetGridCursor( (int) m_fields->size() - 1, 0 );
932
933 m_fieldsGrid->EnableCellEditControl();
934 m_fieldsGrid->ShowCellEditControl();
935
936 OnModify();
937}
938
939
940void DIALOG_SYMBOL_PROPERTIES::OnDeleteField( wxCommandEvent& event )
941{
942 wxArrayInt selectedRows = m_fieldsGrid->GetSelectedRows();
943
944 if( selectedRows.empty() && m_fieldsGrid->GetGridCursorRow() >= 0 )
945 selectedRows.push_back( m_fieldsGrid->GetGridCursorRow() );
946
947 if( selectedRows.empty() )
948 return;
949
950 for( int row : selectedRows )
951 {
952 if( row < MANDATORY_FIELDS )
953 {
954 DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
956 return;
957 }
958 }
959
960 m_fieldsGrid->CommitPendingChanges( true /* quiet mode */ );
961 m_fieldsGrid->ClearSelection();
962
963 // Reverse sort so deleting a row doesn't change the indexes of the other rows.
964 selectedRows.Sort( []( int* first, int* second ) { return *second - *first; } );
965
966 for( int row : selectedRows )
967 {
968 m_fields->erase( m_fields->begin() + row );
969
970 // notify the grid
971 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
972 m_fieldsGrid->ProcessTableMessage( msg );
973
974 if( m_fieldsGrid->GetNumberRows() > 0 )
975 {
976 m_fieldsGrid->MakeCellVisible( std::max( 0, row-1 ), m_fieldsGrid->GetGridCursorCol() );
977 m_fieldsGrid->SetGridCursor( std::max( 0, row-1 ), m_fieldsGrid->GetGridCursorCol() );
978 }
979 }
980
981 OnModify();
982}
983
984
985void DIALOG_SYMBOL_PROPERTIES::OnMoveUp( wxCommandEvent& event )
986{
988 return;
989
990 int i = m_fieldsGrid->GetGridCursorRow();
991
992 if( i > MANDATORY_FIELDS )
993 {
994 SCH_FIELD tmp = m_fields->at( (unsigned) i );
995 m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
996 m_fields->insert( m_fields->begin() + i - 1, tmp );
997 m_fieldsGrid->ForceRefresh();
998
999 m_fieldsGrid->SetGridCursor( i - 1, m_fieldsGrid->GetGridCursorCol() );
1000 m_fieldsGrid->MakeCellVisible( m_fieldsGrid->GetGridCursorRow(),
1001 m_fieldsGrid->GetGridCursorCol() );
1002
1003 OnModify();
1004 }
1005 else
1006 {
1007 wxBell();
1008 }
1009}
1010
1011
1012void DIALOG_SYMBOL_PROPERTIES::OnMoveDown( wxCommandEvent& event )
1013{
1015 return;
1016
1017 int i = m_fieldsGrid->GetGridCursorRow();
1018
1019 if( i >= MANDATORY_FIELDS && i < m_fieldsGrid->GetNumberRows() - 1 )
1020 {
1021 SCH_FIELD tmp = m_fields->at( (unsigned) i );
1022 m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
1023 m_fields->insert( m_fields->begin() + i + 1, tmp );
1024 m_fieldsGrid->ForceRefresh();
1025
1026 m_fieldsGrid->SetGridCursor( i + 1, m_fieldsGrid->GetGridCursorCol() );
1027 m_fieldsGrid->MakeCellVisible( m_fieldsGrid->GetGridCursorRow(),
1028 m_fieldsGrid->GetGridCursorCol() );
1029
1030 OnModify();
1031 }
1032 else
1033 {
1034 wxBell();
1035 }
1036}
1037
1038
1040{
1043}
1044
1045
1047{
1050}
1051
1052
1054{
1057}
1058
1059
1061{
1064}
1065
1066
1068{
1069 int row = aEvent.GetRow();
1070
1071 if( m_pinGrid->GetCellValue( row, COL_ALT_NAME )
1072 == m_dataModel->GetValue( row, COL_BASE_NAME ) )
1073 {
1074 m_dataModel->SetValue( row, COL_ALT_NAME, wxEmptyString );
1075 }
1076
1077 // These are just to get the cells refreshed
1080
1081 OnModify();
1082}
1083
1084
1086{
1087 int sortCol = aEvent.GetCol();
1088 bool ascending;
1089
1090 // This is bonkers, but wxWidgets doesn't tell us ascending/descending in the
1091 // event, and if we ask it will give us pre-event info.
1092 if( m_pinGrid->IsSortingBy( sortCol ) )
1093 // same column; invert ascending
1094 ascending = !m_pinGrid->IsSortOrderAscending();
1095 else
1096 // different column; start with ascending
1097 ascending = true;
1098
1099 m_dataModel->SortRows( sortCol, ascending );
1101}
1102
1103
1105{
1106 wxGridUpdateLocker deferRepaintsTillLeavingScope( m_fieldsGrid );
1107
1108 // Account for scroll bars
1109 int fieldsWidth = KIPLATFORM::UI::GetUnobscuredSize( m_fieldsGrid ).x;
1110
1111 m_fieldsGrid->AutoSizeColumn( 0 );
1112 m_fieldsGrid->SetColSize( 0, std::max( 72, m_fieldsGrid->GetColSize( 0 ) ) );
1113
1114 int fixedColsWidth = m_fieldsGrid->GetColSize( 0 );
1115
1116 for( int i = 2; i < m_fieldsGrid->GetNumberCols(); i++ )
1117 fixedColsWidth += m_fieldsGrid->GetColSize( i );
1118
1119 m_fieldsGrid->SetColSize( 1, std::max( 120, fieldsWidth - fixedColsWidth ) );
1120}
1121
1122
1124{
1125 wxGridUpdateLocker deferRepaintsTillLeavingScope( m_pinGrid );
1126
1127 // Account for scroll bars
1128 int pinTblWidth = KIPLATFORM::UI::GetUnobscuredSize( m_pinGrid ).x;
1129
1130 // Stretch the Base Name and Alternate Assignment columns to fit.
1131 for( int i = 0; i < COL_COUNT; ++i )
1132 {
1133 if( i != COL_BASE_NAME && i != COL_ALT_NAME )
1134 pinTblWidth -= m_pinGrid->GetColSize( i );
1135 }
1136
1137 m_pinGrid->SetColSize( COL_BASE_NAME, pinTblWidth / 2 );
1138 m_pinGrid->SetColSize( COL_ALT_NAME, pinTblWidth / 2 );
1139}
1140
1141
1142void DIALOG_SYMBOL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
1143{
1144 std::bitset<64> shownColumns = m_fieldsGrid->GetShownColumns();
1145
1146 if( shownColumns != m_shownColumns )
1147 {
1148 m_shownColumns = shownColumns;
1149
1150 if( !m_fieldsGrid->IsCellEditControlShown() )
1152 }
1153}
1154
1155
1157{
1158 VECTOR2I *loc = static_cast<VECTOR2I*>( event.GetClientData() );
1159
1160 wxCHECK_RET( loc, wxT( "Missing focus cell location" ) );
1161
1162 // Handle a delayed focus
1163
1164 m_fieldsGrid->SetFocus();
1165 m_fieldsGrid->MakeCellVisible( loc->x, loc->y );
1166 m_fieldsGrid->SetGridCursor( loc->x, loc->y );
1167
1168 m_fieldsGrid->EnableCellEditControl( true );
1169 m_fieldsGrid->ShowCellEditControl();
1170
1171 delete loc;
1172}
1173
1174
1176{
1177 // Handle a delayed selection
1178 wxGridCellEditor* cellEditor = m_fieldsGrid->GetCellEditor( REFERENCE_FIELD, FDC_VALUE );
1179
1180 if( wxTextEntry* txt = dynamic_cast<wxTextEntry*>( cellEditor->GetControl() ) )
1182
1183 cellEditor->DecRef(); // we're done; must release
1184}
1185
1187{
1188 wxSize new_size = event.GetSize();
1189
1190 if( ( !m_editorShown || m_lastRequestedSize != new_size ) && m_fieldsSize != new_size )
1191 {
1192 m_fieldsSize = new_size;
1193
1195 }
1196
1197 // We store this value to check whether the dialog is changing size. This might indicate
1198 // that the user is scaling the dialog with an editor shown. Some editors do not close
1199 // (at least on GTK) when the user drags a dialog corner
1200 m_lastRequestedSize = new_size;
1201
1202 // Always propagate for a grid repaint (needed if the height changes, as well as width)
1203 event.Skip();
1204}
1205
1206
1208{
1209 wxSize new_size = event.GetSize();
1210
1211 if( m_pinsSize != new_size )
1212 {
1213 m_pinsSize = new_size;
1214
1216 }
1217
1218 // Always propagate for a grid repaint (needed if the height changes, as well as width)
1219 event.Skip();
1220}
1221
1222
1223void DIALOG_SYMBOL_PROPERTIES::OnInitDlg( wxInitDialogEvent& event )
1224{
1226
1227 // Now all widgets have the size fixed, call FinishDialogSettings
1229
1230 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
1231
1232 if( cfg && cfg->m_Appearance.edit_symbol_width > 0 && cfg->m_Appearance.edit_symbol_height > 0 )
1234}
1235
1236
1237void DIALOG_SYMBOL_PROPERTIES::OnCheckBox( wxCommandEvent& event )
1238{
1239 OnModify();
1240}
1241
1242
1243void DIALOG_SYMBOL_PROPERTIES::OnUnitChoice( wxCommandEvent& event )
1244{
1245 if( m_dataModel )
1246 {
1247 EDA_ITEM_FLAGS flags = m_symbol->GetFlags();
1248
1249 int unit_selection = m_unitChoice->GetSelection() + 1;
1250
1251 // We need to select a new unit to build the new unit pin list
1252 // but we should not change the symbol, so the initial unit will be selected
1253 // after rebuilding the pin list
1254 int old_unit = m_symbol->GetUnit();
1255 m_symbol->SetUnit( unit_selection );
1256
1257 // Rebuild a copy of the pins of the new unit for editing
1258 m_dataModel->clear();
1259
1260 for( const std::unique_ptr<SCH_PIN>& pin : m_symbol->GetRawPins() )
1261 m_dataModel->push_back( *pin );
1262
1265
1266 m_symbol->SetUnit( old_unit );
1267
1268 // Restore m_Flag modified by SetUnit()
1270 m_symbol->SetFlags( flags );
1271 }
1272
1273 OnModify();
1274}
1275
1276
1278{
1279 event.Enable( m_symbol && m_symbol->GetLibSymbolRef() );
1280}
1281
1282
1284{
1285 event.Enable( m_symbol && m_symbol->GetLibSymbolRef() );
1286}
1287
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Definition: bitmap.cpp:110
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition: commit.h:103
bool Empty() const
Returns status of an item.
Definition: commit.h:142
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void EndQuasiModal(int retCode)
void OnModify()
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Class DIALOG_SYMBOL_PROPERTIES_BASE.
void OnSizePinsGrid(wxSizeEvent &event) override
void OnPinTableCellEdited(wxGridEvent &event) override
void OnGridEditorShown(wxGridEvent &event) override
void OnUpdateUI(wxUpdateUIEvent &event) override
void OnEditSymbol(wxCommandEvent &) override
void OnCancelButtonClick(wxCommandEvent &event) override
virtual void onUpdateEditLibrarySymbol(wxUpdateUIEvent &event) override
SCH_PIN_TABLE_DATA_MODEL * m_dataModel
void OnMoveDown(wxCommandEvent &event) override
void OnSizeFieldsGrid(wxSizeEvent &event) override
void OnPinTableColSort(wxGridEvent &aEvent)
void OnMoveUp(wxCommandEvent &event) override
void OnDeleteField(wxCommandEvent &event) override
void OnInitDlg(wxInitDialogEvent &event) override
void OnAddField(wxCommandEvent &event) override
void OnGridEditorHidden(wxGridEvent &event) override
void OnUnitChoice(wxCommandEvent &event) override
void OnEditSpiceModel(wxCommandEvent &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
FIELDS_GRID_TABLE< SCH_FIELD > * m_fields
void OnExchangeSymbol(wxCommandEvent &) override
virtual void onUpdateEditSymbol(wxUpdateUIEvent &event) override
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:129
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:123
const KIID m_Uuid
Definition: eda_item.h:482
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:125
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:126
void SetTextSize(VECTOR2I aNewSize)
Definition: eda_text.cpp:358
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:95
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:419
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:229
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:205
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition: grid_tricks.h:61
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:95
Definition: kiid.h:49
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
UTF8 Format() const
Definition: lib_id.cpp:118
@ BASE
Definition: lib_item.h:77
@ DEMORGAN
Definition: lib_item.h:77
std::map< wxString, ALT > & GetAlternates()
Definition: lib_pin.h:142
const wxString & GetName() const
Definition: lib_pin.h:106
void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
Definition: lib_symbol.h:632
bool IsPower() const
Definition: lib_symbol.cpp:704
bool ShowPinNames() const
Definition: lib_symbol.h:633
void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
Definition: lib_symbol.h:640
bool HasConversion() const
Test if symbol has more than one body conversion type (DeMorgan).
bool ShowPinNumbers() const
Definition: lib_symbol.h:641
static int Compare(const wxString &lhs, const wxString &rhs)
These settings were stored in SCH_BASE_FRAME previously.
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:287
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
Definition: sch_commit.cpp:353
Schematic editor (Eeschema) main window.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:52
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
Definition: sch_field.cpp:1032
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:1000
void SetName(const wxString &aName)
Definition: sch_field.cpp:979
void SetText(const wxString &aText) override
Definition: sch_field.cpp:989
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:113
virtual void SetExcludedFromSim(bool aExclude)
Definition: sch_item.h:210
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)
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind) override
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
void SetAlt(const wxString &aAlt)
Definition: sch_pin.h:65
wxString GetAlt() const
Definition: sch_pin.h:64
wxString GetName() const
Definition: sch_pin.cpp:85
LIB_PIN * GetLibPin() const
Definition: sch_pin.h:59
wxString GetNumber() const
Definition: sch_pin.h:142
GRAPHIC_PINSHAPE GetShape() const
Definition: sch_pin.cpp:126
ELECTRICAL_PINTYPE GetType() const
Definition: sch_pin.cpp:117
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Definition: sch_screen.cpp:150
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:320
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:81
int GetUnitCount() const
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:473
void SetConvert(int aConvert)
Definition: sch_symbol.cpp:454
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins()
Definition: sch_symbol.h:537
int GetUnit() const
Definition: sch_symbol.h:228
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:476
void SetDNP(bool aDNP)
Definition: sch_symbol.h:746
void UpdateUnit(int aUnit)
Change the unit number to aUnit without setting any internal flags.
Definition: sch_symbol.cpp:448
wxString SubReference(int aUnit, bool aAddSeparator=true) const
Definition: sch_symbol.cpp:857
static bool IsReferenceStringValid(const wxString &aReferenceString)
Test for an acceptable reference string.
Definition: sch_symbol.cpp:774
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:918
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true, bool aCaseInsensitive=false)
Search for a SCH_FIELD with aFieldName.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:738
void SetExcludedFromSim(bool aExclude) override
Definition: sch_symbol.h:737
int GetConvert() const
Definition: sch_symbol.h:270
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
Definition: sch_symbol.cpp:780
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
void SetFootprintFieldText(const wxString &aFootprint)
Definition: sch_symbol.cpp:934
bool GetExcludedFromBOM() const
Definition: sch_symbol.h:739
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:700
bool GetExcludedFromSim() const override
Definition: sch_symbol.h:736
bool HasUnitDisplayName(int aUnit)
Return true if the given unit aUnit has a display name set.
Definition: sch_symbol.cpp:490
void SetExcludedFromBOM(bool aIncludeInBOM)
Definition: sch_symbol.h:740
int GetOrientation() const
Get the display symbol orientation.
bool IsAnnotated(const SCH_SHEET_PATH *aSheet)
Check if the symbol has a valid annotation (reference) for the given sheet path.
Definition: sch_symbol.cpp:816
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:866
void SetUnit(int aUnit)
Change the unit number to aUnit.
Definition: sch_symbol.cpp:442
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:175
wxString GetUnitDisplayName(int aUnit)
Return the display name for a given unit aUnit.
Definition: sch_symbol.cpp:482
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
bool GetExcludedFromBoard() const
Definition: sch_symbol.h:742
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:988
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
Definition: sch_symbol.cpp:882
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:192
void SetExcludedFromBoard(bool aIncludeOnBoard)
Definition: sch_symbol.h:743
bool GetDNP() const
Definition: sch_symbol.h:745
void SetBitmap(const wxBitmapBundle &aBmp)
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
Definition: wx_grid.cpp:298
void SetTable(wxGridTableBase *table, bool aTakeOwnership=false)
Hide wxGrid's SetTable() method with one which doesn't mess up the grid column widths when setting th...
Definition: wx_grid.cpp:156
void DestroyTable(wxGridTableBase *aTable)
Work-around for a bug in wxGrid which crashes when deleting the table if the cell edit control was no...
Definition: wx_grid.cpp:254
wxString GetShownColumnsAsString()
Get a tokenized string containing the shown column indexes.
Definition: wx_grid.cpp:268
std::bitset< 64 > GetShownColumns()
Definition: wx_grid.cpp:287
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:448
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:280
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:305
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_EDIT_LIBRARY_SYMBOL
#define _(s)
std::uint32_t EDA_ITEM_FLAGS
void CollectOtherUnits(const wxString &aRef, int aUnit, const LIB_ID &aLibId, SCH_SHEET_PATH &aSheet, std::vector< SCH_SYMBOL * > *otherUnits)
@ FDC_NAME
@ FDC_VALUE
wxColour GetDialogBGColour()
Definition: gtk/ui.cpp:61
wxSize GetUnobscuredSize(const wxWindow *aWindow)
Tries to determine the size of the viewport of a scrollable widget (wxDataViewCtrl,...
Definition: gtk/ui.cpp:195
void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
Definition: ui_common.cpp:225
const std::vector< BITMAPS > & PinTypeIcons()
Definition: pin_type.cpp:162
const wxArrayString & PinTypeNames()
Definition: pin_type.cpp:153
const wxArrayString & PinShapeNames()
Definition: pin_type.cpp:171
const std::vector< BITMAPS > & PinShapeIcons()
Definition: pin_type.cpp:180
@ SYM_ORIENT_270
@ SYM_MIRROR_Y
@ SYM_ORIENT_180
@ SYM_MIRROR_X
@ SYM_ORIENT_90
@ SYM_ORIENT_0
std::vector< SCH_FIELD > SCH_FIELDS
A container for several SCH_FIELD items.
Definition: sch_symbol.h:69
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.
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
Definition for symbol library class.
#define DO_TRANSLATE
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 5 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
VECTOR3I res
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588