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, 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 <sch_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 WX_GRID_TABLE_BASE, 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 SCH_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, SCH_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 aKind ) override
199 {
200 switch( aCol )
201 {
202 case COL_NUMBER:
203 case COL_BASE_NAME:
204 m_readOnlyAttr->IncRef();
205 return enhanceAttr( m_readOnlyAttr, aRow, aCol, aKind );
206
207 case COL_ALT_NAME:
208 m_nameAttrs[ aRow ]->IncRef();
209 return enhanceAttr( m_nameAttrs[ aRow ], aRow, aCol, aKind );
210
211 case COL_TYPE:
212 m_typeAttr->IncRef();
213 return enhanceAttr( m_typeAttr, aRow, aCol, aKind );
214
215 case COL_SHAPE:
216 m_shapeAttr->IncRef();
217 return enhanceAttr( m_shapeAttr, aRow, aCol, aKind );
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_lastRequestedFieldsSize( 0, 0 ),
317 m_lastRequestedPinsSize( 0, 0 ),
318 m_editorShown( false ),
319 m_fields( nullptr ),
320 m_dataModel( nullptr )
321{
322 m_symbol = aSymbol;
324
325 // GetLibSymbolRef() now points to the cached part in the schematic, which should always be
326 // there for usual cases, but can be null when opening old schematics not storing the part
327 // so we need to handle m_part == nullptr
328 // wxASSERT( m_part );
329
330 m_fields = new FIELDS_GRID_TABLE( this, aParent, m_fieldsGrid, m_symbol );
331
332 // Give a bit more room for combobox editors
333 m_fieldsGrid->SetDefaultRowSize( m_fieldsGrid->GetDefaultRowSize() + 4 );
334 m_pinGrid->SetDefaultRowSize( m_pinGrid->GetDefaultRowSize() + 4 );
335
337 m_fieldsGrid->PushEventHandler( new FIELDS_GRID_TRICKS( m_fieldsGrid, this,
338 { &aParent->Schematic(), m_part },
339 [&]( wxCommandEvent& aEvent )
340 {
341 OnAddField( aEvent );
342 } ) );
343 m_fieldsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
344
345 // Show/hide columns according to user's preference
346 if( EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ) )
347 {
348 m_fieldsGrid->ShowHideColumns( cfg->m_Appearance.edit_symbol_visible_columns );
350 }
351
353 {
354 // DeMorgan conversions are a subclass of alternate pin assignments, so don't allow
355 // free-form alternate assignments as well. (We won't know how to map the alternates
356 // back and forth when the conversion is changed.)
357 m_pinTablePage->Disable();
358 m_pinTablePage->SetToolTip( _( "Alternate pin assignments are not available for De Morgan "
359 "symbols." ) );
360 }
361 else
362 {
364
365 // Make a copy of the pins for editing
366 for( const std::unique_ptr<SCH_PIN>& pin : m_symbol->GetRawPins() )
367 m_dataModel->push_back( *pin );
368
371
373 }
374
375 if( m_part && m_part->IsPower() )
376 m_spiceFieldsButton->Hide();
377
378 m_pinGrid->PushEventHandler( new GRID_TRICKS( m_pinGrid ) );
379 m_pinGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
380
381 wxFont infoFont = KIUI::GetSmallInfoFont( this );
382 m_libraryIDLabel->SetFont( infoFont );
383 m_tcLibraryID->SetFont( infoFont );
384 m_tcLibraryID->SetBackgroundColour( KIPLATFORM::UI::GetDialogBGColour() );
385
386 wxToolTip::Enable( true );
388
389 // Configure button logos
390 m_bpAdd->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
391 m_bpDelete->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
392 m_bpMoveUp->SetBitmap( KiBitmapBundle( BITMAPS::small_up ) );
393 m_bpMoveDown->SetBitmap( KiBitmapBundle( BITMAPS::small_down ) );
394
395 // wxFormBuilder doesn't include this event...
396 m_fieldsGrid->Bind( wxEVT_GRID_CELL_CHANGING, &DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging, this );
397 m_pinGrid->Bind( wxEVT_GRID_COL_SORT, &DIALOG_SYMBOL_PROPERTIES::OnPinTableColSort, this );
398 Bind( SYMBOL_DELAY_FOCUS, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedFocus, this );
399 Bind( SYMBOL_DELAY_SELECTION, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedSelection, this );
400
401 wxCommandEvent* evt = new wxCommandEvent( SYMBOL_DELAY_SELECTION );
402 evt->SetClientData( new VECTOR2I( 0, FDC_VALUE ) );
403 QueueEvent( evt );
404 evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
405 evt->SetClientData( new VECTOR2I( 0, FDC_VALUE ) );
406 QueueEvent( evt );
407
409}
410
411
413{
414 if( EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ) )
415 {
416 cfg->m_Appearance.edit_symbol_visible_columns = m_fieldsGrid->GetShownColumnsAsString();
417 cfg->m_Appearance.edit_symbol_width = GetSize().x;
418 cfg->m_Appearance.edit_symbol_height = GetSize().y;
419 }
420
421 // Prevents crash bug in wxGrid's d'tor
423
424 if( m_dataModel )
426
427 m_fieldsGrid->Unbind( wxEVT_GRID_CELL_CHANGING, &DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging, this );
428 m_pinGrid->Unbind( wxEVT_GRID_COL_SORT, &DIALOG_SYMBOL_PROPERTIES::OnPinTableColSort, this );
429 Unbind( SYMBOL_DELAY_FOCUS, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedFocus, this );
430 Unbind( SYMBOL_DELAY_SELECTION, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedSelection, this );
431
432 // Delete the GRID_TRICKS.
433 m_fieldsGrid->PopEventHandler( true );
434 m_pinGrid->PopEventHandler( true );
435}
436
437
439{
440 return dynamic_cast<SCH_EDIT_FRAME*>( wxDialog::GetParent() );
441}
442
443
445{
446 if( !wxDialog::TransferDataToWindow() )
447 return false;
448
449 std::set<wxString> defined;
450
451 // Push a copy of each field into m_updateFields
452 for( SCH_FIELD& srcField : m_symbol->GetFields() )
453 {
454 SCH_FIELD field( srcField );
455
456 // change offset to be symbol-relative
457 field.Offset( -m_symbol->GetPosition() );
458
459 field.SetText( m_symbol->Schematic()->ConvertKIIDsToRefs( field.GetText() ) );
460
461 defined.insert( field.GetName() );
462 m_fields->push_back( field );
463 }
464
465 // Add in any template fieldnames not yet defined:
466 for( const TEMPLATE_FIELDNAME& templateFieldname :
467 GetParent()->Schematic().Settings().m_TemplateFieldNames.GetTemplateFieldNames() )
468 {
469 if( defined.count( templateFieldname.m_Name ) <= 0 )
470 {
471 SCH_FIELD field( m_symbol, FIELD_T::USER, templateFieldname.m_Name );
472 field.SetVisible( templateFieldname.m_Visible );
473 m_fields->push_back( field );
474 }
475 }
476
477 // notify the grid
478 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->GetNumberRows() );
479 m_fieldsGrid->ProcessTableMessage( msg );
481
482 // If a multi-unit symbol, set up the unit selector and interchangeable checkbox.
483 if( m_symbol->GetUnitCount() > 1 )
484 {
485 // Ensure symbol unit is the currently selected unit (mandatory in complex hierarchies)
486 // from the current sheet path, because it can be modified by previous calculations
487 m_symbol->SetUnit( m_symbol->GetUnitSelection( &GetParent()->GetCurrentSheet() ) );
488
489 for( int ii = 1; ii <= m_symbol->GetUnitCount(); ii++ )
490 {
491 if( m_symbol->HasUnitDisplayName( ii ) )
492 m_unitChoice->Append( m_symbol->GetUnitDisplayName( ii ) );
493 else
494 m_unitChoice->Append( m_symbol->SubReference( ii, false ) );
495 }
496
497 if( m_symbol->GetUnit() <= ( int )m_unitChoice->GetCount() )
498 m_unitChoice->SetSelection( m_symbol->GetUnit() - 1 );
499 }
500 else
501 {
502 m_unitLabel->Enable( false );
503 m_unitChoice->Enable( false );
504 }
505
507 {
508 if( m_symbol->GetBodyStyle() > BODY_STYLE::BASE )
509 m_cbAlternateSymbol->SetValue( true );
510 }
511 else
512 {
513 m_cbAlternateSymbol->Enable( false );
514 }
515
516 // Set the symbol orientation and mirroring.
517 int orientation = m_symbol->GetOrientation() & ~( SYM_MIRROR_X | SYM_MIRROR_Y );
518
519 switch( orientation )
520 {
521 default:
522 case SYM_ORIENT_0: m_orientationCtrl->SetSelection( 0 ); break;
523 case SYM_ORIENT_90: m_orientationCtrl->SetSelection( 1 ); break;
524 case SYM_ORIENT_270: m_orientationCtrl->SetSelection( 2 ); break;
525 case SYM_ORIENT_180: m_orientationCtrl->SetSelection( 3 ); break;
526 }
527
528 int mirror = m_symbol->GetOrientation() & ( SYM_MIRROR_X | SYM_MIRROR_Y );
529
530 switch( mirror )
531 {
532 default: m_mirrorCtrl->SetSelection( 0 ) ; break;
533 case SYM_MIRROR_X: m_mirrorCtrl->SetSelection( 1 ); break;
534 case SYM_MIRROR_Y: m_mirrorCtrl->SetSelection( 2 ); break;
535 }
536
540 m_cbDNP->SetValue( m_symbol->GetDNP() );
541
542 if( m_part )
543 {
546 }
547
548 // Set the symbol's library name.
550
551 Layout();
552 m_fieldsGrid->Layout();
553 wxSafeYield();
554
555 return true;
556}
557
558
560{
562 return;
563
564 m_fieldsGrid->ClearSelection();
565
566 std::vector<SCH_FIELD> fields;
567
568 for( const SCH_FIELD& field : *m_fields )
569 fields.emplace_back( field );
570
571 DIALOG_SIM_MODEL dialog( this, m_parentFrame, *m_symbol, fields );
572
573 if( dialog.ShowModal() != wxID_OK )
574 return;
575
576 // Add in any new fields
577 for( const SCH_FIELD& editedField : fields )
578 {
579 bool found = false;
580
581 for( SCH_FIELD& existingField : *m_fields )
582 {
583 if( existingField.GetName() == editedField.GetName() )
584 {
585 found = true;
586 existingField.SetText( editedField.GetText() );
587 break;
588 }
589 }
590
591 if( !found )
592 {
593 m_fields->emplace_back( editedField );
594 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
595 m_fieldsGrid->ProcessTableMessage( msg );
596 }
597 }
598
599 // Remove any deleted fields
600 for( int ii = (int) m_fields->size() - 1; ii >= 0; --ii )
601 {
602 SCH_FIELD& existingField = m_fields->at( ii );
603 bool found = false;
604
605 for( SCH_FIELD& editedField : fields )
606 {
607 if( editedField.GetName() == existingField.GetName() )
608 {
609 found = true;
610 break;
611 }
612 }
613
614 if( !found )
615 {
616 m_fields->erase( m_fields->begin() + ii );
617 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, ii, 1 );
618 m_fieldsGrid->ClearSelection();
619 m_fieldsGrid->ProcessTableMessage( msg );
620 }
621 }
622
623 OnModify();
624 m_fieldsGrid->ForceRefresh();
625}
626
627
629{
630 // Running the Footprint Browser gums up the works and causes the automatic cancel
631 // stuff to no longer work. So we do it here ourselves.
632 EndQuasiModal( wxID_CANCEL );
633}
634
635
637{
638 LIB_ID id;
639
640 if( !m_fieldsGrid->CommitPendingChanges() || !m_fieldsGrid->Validate() )
641 return false;
642
643 // Check for missing field names.
644 for( size_t i = 0; i < m_fields->size(); ++i )
645 {
646 SCH_FIELD& field = m_fields->at( i );
647
648 if( field.IsMandatory() )
649 continue;
650
651 wxString fieldName = field.GetName( false );
652
653 if( fieldName.IsEmpty() )
654 {
655 DisplayErrorMessage( this, _( "Fields must have a name." ) );
656
657 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
658 evt->SetClientData( new VECTOR2I( i, FDC_VALUE ) );
659 QueueEvent( evt );
660
661 return false;
662 }
663 }
664
665 return true;
666}
667
668
670{
671 if( !wxDialog::TransferDataFromWindow() ) // Calls our Validate() method.
672 return false;
673
675 return false;
676
678 return false;
679
680 SCH_COMMIT commit( GetParent() );
681 SCH_SCREEN* currentScreen = GetParent()->GetScreen();
682 bool replaceOnCurrentScreen;
683 wxCHECK( currentScreen, false );
684
685 // This needs to be done before the LIB_ID is changed to prevent stale library symbols in
686 // the schematic file.
687 replaceOnCurrentScreen = currentScreen->Remove( m_symbol );
688
689 // save old cmp in undo list if not already in edit, or moving ...
690 if( m_symbol->GetEditFlags() == 0 )
691 commit.Modify( m_symbol, currentScreen );
692
693 // Save current flags which could be modified by next change settings
695
696 // For symbols with multiple shapes (De Morgan representation) Set the selected shape:
697 if( m_cbAlternateSymbol->IsEnabled() && m_cbAlternateSymbol->GetValue() )
698 m_symbol->SetBodyStyle( BODY_STYLE::DEMORGAN );
699 else
700 m_symbol->SetBodyStyle( BODY_STYLE::BASE );
701
702 //Set the part selection in multiple part per package
703 int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1;
704 m_symbol->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection );
705 m_symbol->SetUnit( unit_selection );
706
707 switch( m_orientationCtrl->GetSelection() )
708 {
709 case 0: m_symbol->SetOrientation( SYM_ORIENT_0 ); break;
710 case 1: m_symbol->SetOrientation( SYM_ORIENT_90 ); break;
711 case 2: m_symbol->SetOrientation( SYM_ORIENT_270 ); break;
712 case 3: m_symbol->SetOrientation( SYM_ORIENT_180 ); break;
713 }
714
715 switch( m_mirrorCtrl->GetSelection() )
716 {
717 case 0: break;
718 case 1: m_symbol->SetOrientation( SYM_MIRROR_X ); break;
719 case 2: m_symbol->SetOrientation( SYM_MIRROR_Y ); break;
720 }
721
724
725 // Restore m_Flag modified by SetUnit() and other change settings from the dialog
727 m_symbol->SetFlags( flags );
728
729 // change all field positions from relative to absolute
730 for( SCH_FIELD& field : *m_fields )
731 {
732 field.Offset( m_symbol->GetPosition() );
733 field.SetText( m_symbol->Schematic()->ConvertRefsToKIIDs( field.GetText() ) );
734 }
735
736 SCH_FIELDS& fields = m_symbol->GetFields();
737 fields.clear();
738
739 for( SCH_FIELD& field : *m_fields )
740 {
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 int ordinal = 42; // Arbitrarily larger than any mandatory FIELD_T ids.
752
753 for( SCH_FIELD& field : fields )
754 {
755 if( !field.IsMandatory() )
756 field.SetOrdinal( ordinal++ );
757 }
758
759 // Reference has a specific initialization, depending on the current active sheet
760 // because for a given symbol, in a complex hierarchy, there are more than one
761 // reference.
762 m_symbol->SetRef( &GetParent()->GetCurrentSheet(),
763 m_fields->GetField( FIELD_T::REFERENCE )->GetText() );
764
765 // Similar for Value and Footprint, except that the GUI behavior is that they are kept
766 // in sync between multiple instances.
767 m_symbol->SetValueFieldText( m_fields->GetField( FIELD_T::VALUE )->GetText() );
768 m_symbol->SetFootprintFieldText( m_fields->GetField( FIELD_T::FOOTPRINT )->GetText() );
769
773 m_symbol->SetDNP( m_cbDNP->IsChecked() );
774
775 // Update any assignments
776 if( m_dataModel )
777 {
778 for( const SCH_PIN& model_pin : *m_dataModel )
779 {
780 // map from the edited copy back to the "real" pin in the symbol.
781 SCH_PIN* src_pin = m_symbol->GetPin( model_pin.GetNumber() );
782
783 if( src_pin )
784 src_pin->SetAlt( model_pin.GetAlt() );
785 }
786 }
787
788 // Keep fields other than the reference, include/exclude flags, and alternate pin assignements
789 // in sync in multi-unit parts.
790 m_symbol->SyncOtherUnits( GetParent()->GetCurrentSheet(), commit, nullptr );
791
792 if( replaceOnCurrentScreen )
793 currentScreen->Append( m_symbol );
794
795 if( !commit.Empty() )
796 commit.Push( _( "Edit Symbol Properties" ) );
797
798 return true;
799}
800
801
803{
804 wxGridCellEditor* editor = m_fieldsGrid->GetCellEditor( event.GetRow(), event.GetCol() );
805 wxControl* control = editor->GetControl();
806
807 if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) )
808 {
809 event.Veto();
810 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
811 evt->SetClientData( new VECTOR2I( event.GetRow(), event.GetCol() ) );
812 QueueEvent( evt );
813 }
814 else if( event.GetCol() == FDC_NAME )
815 {
816 wxString newName = event.GetString();
817
818 for( int i = 0; i < m_fieldsGrid->GetNumberRows(); ++i )
819 {
820 if( i == event.GetRow() )
821 continue;
822
823 if( newName.CmpNoCase( m_fieldsGrid->GetCellValue( i, FDC_NAME ) ) == 0 )
824 {
825 DisplayError( this, wxString::Format( _( "Field name '%s' already in use." ),
826 newName ) );
827 event.Veto();
828 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
829 evt->SetClientData( new VECTOR2I( event.GetRow(), event.GetCol() ) );
830 QueueEvent( evt );
831 }
832 }
833 }
834
835 editor->DecRef();
836}
837
838
840{
841 if( m_fields->at( aEvent.GetRow() ).GetId() == FIELD_T::REFERENCE
842 && aEvent.GetCol() == FDC_VALUE )
843 {
844 wxCommandEvent* evt = new wxCommandEvent( SYMBOL_DELAY_SELECTION );
845 evt->SetClientData( new VECTOR2I( aEvent.GetRow(), aEvent.GetCol() ) );
846 QueueEvent( evt );
847 }
848
849 m_editorShown = true;
850}
851
852
854{
855 m_editorShown = false;
856}
857
858
859void DIALOG_SYMBOL_PROPERTIES::OnAddField( wxCommandEvent& event )
860{
862 return;
863
864 SCH_FIELD newField( m_symbol, FIELD_T::USER, GetUserFieldName( (int) m_fields->size(), DO_TRANSLATE ) );
865
866 newField.SetTextAngle( m_fields->GetField( FIELD_T::REFERENCE )->GetTextAngle() );
867 newField.SetVisible( false );
868
869 m_fields->push_back( newField );
870
871 // notify the grid
872 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
873 m_fieldsGrid->ProcessTableMessage( msg );
874
875 m_fieldsGrid->MakeCellVisible( (int) m_fields->size() - 1, 0 );
876 m_fieldsGrid->SetGridCursor( (int) m_fields->size() - 1, 0 );
877
878 m_fieldsGrid->EnableCellEditControl();
879 m_fieldsGrid->ShowCellEditControl();
880
881 OnModify();
882}
883
884
885void DIALOG_SYMBOL_PROPERTIES::OnDeleteField( wxCommandEvent& event )
886{
887 wxArrayInt selectedRows = m_fieldsGrid->GetSelectedRows();
888
889 if( selectedRows.empty() && m_fieldsGrid->GetGridCursorRow() >= 0 )
890 selectedRows.push_back( m_fieldsGrid->GetGridCursorRow() );
891
892 if( selectedRows.empty() )
893 return;
894
895 for( int row : selectedRows )
896 {
897 if( row < m_fields->GetMandatoryRowCount() )
898 {
899 DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
901 return;
902 }
903 }
904
905 m_fieldsGrid->CommitPendingChanges( true /* quiet mode */ );
906
907 // Reverse sort so deleting a row doesn't change the indexes of the other rows.
908 selectedRows.Sort( []( int* first, int* second ) { return *second - *first; } );
909
910 for( int row : selectedRows )
911 {
912 m_fieldsGrid->ClearSelection();
913 m_fields->erase( m_fields->begin() + row );
914
915 // notify the grid
916 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
917 m_fieldsGrid->ProcessTableMessage( msg );
918
919 if( m_fieldsGrid->GetNumberRows() > 0 )
920 {
921 m_fieldsGrid->MakeCellVisible( std::max( 0, row-1 ), m_fieldsGrid->GetGridCursorCol() );
922 m_fieldsGrid->SetGridCursor( std::max( 0, row-1 ), m_fieldsGrid->GetGridCursorCol() );
923 }
924 }
925
926 OnModify();
927}
928
929
930void DIALOG_SYMBOL_PROPERTIES::OnMoveUp( wxCommandEvent& event )
931{
933 return;
934
935 int i = m_fieldsGrid->GetGridCursorRow();
936
937 if( i > m_fields->GetMandatoryRowCount() )
938 {
939 SCH_FIELD tmp = m_fields->at( (unsigned) i );
940 m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
941 m_fields->insert( m_fields->begin() + i - 1, tmp );
942 m_fieldsGrid->ForceRefresh();
943
944 m_fieldsGrid->SetGridCursor( i - 1, m_fieldsGrid->GetGridCursorCol() );
945 m_fieldsGrid->MakeCellVisible( m_fieldsGrid->GetGridCursorRow(),
946 m_fieldsGrid->GetGridCursorCol() );
947
948 OnModify();
949 }
950 else
951 {
952 wxBell();
953 }
954}
955
956
957void DIALOG_SYMBOL_PROPERTIES::OnMoveDown( wxCommandEvent& event )
958{
960 return;
961
962 int i = m_fieldsGrid->GetGridCursorRow();
963
964 if( i >= m_fields->GetMandatoryRowCount() && i < m_fieldsGrid->GetNumberRows() - 1 )
965 {
966 SCH_FIELD tmp = m_fields->at( (unsigned) i );
967 m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
968 m_fields->insert( m_fields->begin() + i + 1, tmp );
969 m_fieldsGrid->ForceRefresh();
970
971 m_fieldsGrid->SetGridCursor( i + 1, m_fieldsGrid->GetGridCursorCol() );
972 m_fieldsGrid->MakeCellVisible( m_fieldsGrid->GetGridCursorRow(),
973 m_fieldsGrid->GetGridCursorCol() );
974
975 OnModify();
976 }
977 else
978 {
979 wxBell();
980 }
981}
982
983
985{
988}
989
990
992{
995}
996
997
999{
1002}
1003
1004
1006{
1009}
1010
1011
1013{
1014 int row = aEvent.GetRow();
1015
1016 if( m_pinGrid->GetCellValue( row, COL_ALT_NAME )
1017 == m_dataModel->GetValue( row, COL_BASE_NAME ) )
1018 {
1019 m_dataModel->SetValue( row, COL_ALT_NAME, wxEmptyString );
1020 }
1021
1022 // These are just to get the cells refreshed
1025
1026 OnModify();
1027}
1028
1029
1031{
1032 int sortCol = aEvent.GetCol();
1033 bool ascending;
1034
1035 // This is bonkers, but wxWidgets doesn't tell us ascending/descending in the
1036 // event, and if we ask it will give us pre-event info.
1037 if( m_pinGrid->IsSortingBy( sortCol ) )
1038 // same column; invert ascending
1039 ascending = !m_pinGrid->IsSortOrderAscending();
1040 else
1041 // different column; start with ascending
1042 ascending = true;
1043
1044 m_dataModel->SortRows( sortCol, ascending );
1046}
1047
1048
1050{
1051 wxGridUpdateLocker deferRepaintsTillLeavingScope( m_fieldsGrid );
1052
1053 // Account for scroll bars
1054 int fieldsWidth = KIPLATFORM::UI::GetUnobscuredSize( m_fieldsGrid ).x;
1055
1056 m_fieldsGrid->AutoSizeColumn( 0 );
1057 m_fieldsGrid->SetColSize( 0, std::max( 72, m_fieldsGrid->GetColSize( 0 ) ) );
1058
1059 int fixedColsWidth = m_fieldsGrid->GetColSize( 0 );
1060
1061 for( int i = 2; i < m_fieldsGrid->GetNumberCols(); i++ )
1062 fixedColsWidth += m_fieldsGrid->GetColSize( i );
1063
1064 m_fieldsGrid->SetColSize( 1, std::max( 120, fieldsWidth - fixedColsWidth ) );
1065}
1066
1067
1069{
1070 wxGridUpdateLocker deferRepaintsTillLeavingScope( m_pinGrid );
1071
1072 // Account for scroll bars
1073 int pinTblWidth = KIPLATFORM::UI::GetUnobscuredSize( m_pinGrid ).x;
1074
1075 // Stretch the Base Name and Alternate Assignment columns to fit.
1076 for( int i = 0; i < COL_COUNT; ++i )
1077 {
1078 if( i != COL_BASE_NAME && i != COL_ALT_NAME )
1079 pinTblWidth -= m_pinGrid->GetColSize( i );
1080 }
1081
1082 m_pinGrid->SetColSize( COL_BASE_NAME, pinTblWidth / 2 );
1083 m_pinGrid->SetColSize( COL_ALT_NAME, pinTblWidth / 2 );
1084}
1085
1086
1087void DIALOG_SYMBOL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
1088{
1089 std::bitset<64> shownColumns = m_fieldsGrid->GetShownColumns();
1090
1091 if( shownColumns != m_shownColumns )
1092 {
1093 m_shownColumns = shownColumns;
1094
1095 if( !m_fieldsGrid->IsCellEditControlShown() )
1097 }
1098}
1099
1100
1102{
1103 VECTOR2I *loc = static_cast<VECTOR2I*>( event.GetClientData() );
1104
1105 wxCHECK_RET( loc, wxT( "Missing focus cell location" ) );
1106
1107 // Handle a delayed focus
1108
1109 m_fieldsGrid->SetFocus();
1110 m_fieldsGrid->MakeCellVisible( loc->x, loc->y );
1111 m_fieldsGrid->SetGridCursor( loc->x, loc->y );
1112
1113 m_fieldsGrid->EnableCellEditControl( true );
1114 m_fieldsGrid->ShowCellEditControl();
1115
1116 delete loc;
1117}
1118
1119
1121{
1122 VECTOR2I *loc = static_cast<VECTOR2I*>( event.GetClientData() );
1123
1124 wxCHECK_RET( loc, wxT( "Missing focus cell location" ) );
1125
1126 // Handle a delayed selection
1127 wxGridCellEditor* cellEditor = m_fieldsGrid->GetCellEditor( loc->x, loc->y );
1128
1129 if( wxTextEntry* txt = dynamic_cast<wxTextEntry*>( cellEditor->GetControl() ) )
1131
1132 cellEditor->DecRef(); // we're done; must release
1133}
1134
1136{
1137 wxSize new_size = event.GetSize();
1138
1139 if( ( !m_editorShown || m_lastRequestedFieldsSize != new_size ) && m_fieldsSize != new_size )
1140 {
1141 m_fieldsSize = new_size;
1142
1144 }
1145
1146 // We store this value to check whether the dialog is changing size. This might indicate
1147 // that the user is scaling the dialog with a grid-cell-editor shown. Some editors do not
1148 // close (at least on GTK) when the user drags a dialog corner
1149 m_lastRequestedFieldsSize = new_size;
1150
1151 // Always propagate for a grid repaint (needed if the height changes, as well as width)
1152 event.Skip();
1153}
1154
1155
1157{
1158 wxSize new_size = event.GetSize();
1159
1160 if( ( !m_editorShown || m_lastRequestedPinsSize != new_size ) && m_pinsSize != new_size )
1161 {
1162 m_pinsSize = new_size;
1163
1165 }
1166
1167 // We store this value to check whether the dialog is changing size. This might indicate
1168 // that the user is scaling the dialog with a grid-cell-editor shown. Some editors do not
1169 // close (at least on GTK) when the user drags a dialog corner
1170 m_lastRequestedPinsSize = new_size;
1171
1172 // Always propagate for a grid repaint (needed if the height changes, as well as width)
1173 event.Skip();
1174}
1175
1176
1177void DIALOG_SYMBOL_PROPERTIES::OnInitDlg( wxInitDialogEvent& event )
1178{
1180
1181 // Now all widgets have the size fixed, call FinishDialogSettings
1183
1184 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
1185
1186 if( cfg && cfg->m_Appearance.edit_symbol_width > 0 && cfg->m_Appearance.edit_symbol_height > 0 )
1188}
1189
1190
1191void DIALOG_SYMBOL_PROPERTIES::OnCheckBox( wxCommandEvent& event )
1192{
1193 OnModify();
1194}
1195
1196
1197void DIALOG_SYMBOL_PROPERTIES::OnUnitChoice( wxCommandEvent& event )
1198{
1199 if( m_dataModel )
1200 {
1201 EDA_ITEM_FLAGS flags = m_symbol->GetFlags();
1202
1203 int unit_selection = m_unitChoice->GetSelection() + 1;
1204
1205 // We need to select a new unit to build the new unit pin list
1206 // but we should not change the symbol, so the initial unit will be selected
1207 // after rebuilding the pin list
1208 int old_unit = m_symbol->GetUnit();
1209 m_symbol->SetUnit( unit_selection );
1210
1211 // Rebuild a copy of the pins of the new unit for editing
1212 m_dataModel->clear();
1213
1214 for( const std::unique_ptr<SCH_PIN>& pin : m_symbol->GetRawPins() )
1215 m_dataModel->push_back( *pin );
1216
1219
1220 m_symbol->SetUnit( old_unit );
1221
1222 // Restore m_Flag modified by SetUnit()
1224 m_symbol->SetFlags( flags );
1225 }
1226
1227 OnModify();
1228}
1229
1230
1232{
1233 event.Enable( m_symbol && m_symbol->GetLibSymbolRef() );
1234}
1235
1236
1238{
1239 event.Enable( m_symbol && m_symbol->GetLibSymbolRef() );
1240}
1241
1242
1243void DIALOG_SYMBOL_PROPERTIES::OnPageChanging( wxBookCtrlEvent& aEvent )
1244{
1246 aEvent.Veto();
1247
1249 aEvent.Veto();
1250}
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition: bitmap.cpp:110
bool Empty() const
Definition: commit.h:150
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:107
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...
EDA_BASE_FRAME * m_parentFrame
Definition: dialog_shim.h:212
int ShowModal() override
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
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 OnExchangeSymbol(wxCommandEvent &) override
virtual void onUpdateEditSymbol(wxUpdateUIEvent &event) override
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:147
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:141
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:143
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:144
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:144
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:97
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:596
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:386
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:299
SCH_FIELD * GetField(FIELD_T aFieldId)
int GetNumberRows() override
int GetMandatoryRowCount() const
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
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:119
bool IsPower() const override
Definition: lib_symbol.cpp:470
bool HasAlternateBodyStyle() const override
Test if symbol has more than one body conversion type (DeMorgan).
static int Compare(const wxString &lhs, const wxString &rhs)
wxString ConvertKIIDsToRefs(const wxString &aSource) const
Definition: schematic.cpp:586
wxString ConvertRefsToKIIDs(const wxString &aSource) const
Definition: schematic.cpp:516
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Definition: sch_commit.cpp:464
Schematic editor (Eeschema) main window.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCHEMATIC & Schematic() const
bool IsMandatory() const
Definition: sch_field.cpp:1366
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:1106
void SetText(const wxString &aText) override
Definition: sch_field.cpp:1092
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:218
int GetBodyStyle() const
Definition: sch_item.h:246
int GetUnit() const
Definition: sch_item.h:242
virtual void SetUnit(int aUnit)
Definition: sch_item.h:241
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
void SetAlt(const wxString &aAlt)
Set the name of the alternate pin.
Definition: sch_pin.cpp:429
const std::map< wxString, ALT > & GetAlternates() const
Definition: sch_pin.h:133
ALT GetAlt(const wxString &aAlt)
Definition: sch_pin.h:147
SCH_PIN * GetLibPin() const
Definition: sch_pin.h:88
const wxString & GetName() const
Definition: sch_pin.cpp:397
const wxString & GetNumber() const
Definition: sch_pin.h:123
GRAPHIC_PINSHAPE GetShape() const
Definition: sch_pin.cpp:270
ELECTRICAL_PINTYPE GetType() const
Definition: sch_pin.cpp:305
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Definition: sch_screen.cpp:156
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:326
Schematic symbol object.
Definition: sch_symbol.h:75
wxString GetUnitDisplayName(int aUnit) const
Return the display name for a given unit aUnit.
Definition: sch_symbol.cpp:444
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins()
Definition: sch_symbol.h:643
void SetShowPinNumbers(bool aShow) override
Set or clear the pin number visibility flag.
wxString SubReference(int aUnit, bool aAddSeparator=true) const
Definition: sch_symbol.cpp:669
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:730
void SetBodyStyle(int aBodyStyle) override
Definition: sch_symbol.cpp:413
void SetShowPinNames(bool aShow) override
Set or clear the pin name visibility flag.
void SyncOtherUnits(const SCH_SHEET_PATH &aSourceSheet, SCH_COMMIT &aCommit, PROPERTY_BASE *aProperty)
Keep fields other than the reference, include/exclude flags, and alternate pin assignments in sync in...
Definition: sch_symbol.cpp:908
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:592
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
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:746
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:777
const LIB_ID & GetLibId() const override
Definition: sch_symbol.h:164
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:678
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
int GetUnitCount() const override
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:435
int GetOrientation() const override
Get the display symbol orientation.
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
Definition: sch_symbol.cpp:694
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:183
bool HasUnitDisplayName(int aUnit) const
Return true if the given unit aUnit has a display name set.
Definition: sch_symbol.cpp:452
void SetBitmap(const wxBitmapBundle &aBmp)
void SetExcludedFromBoard(bool aExcludeFromBoard) override
Set or clear exclude from board netlist flag.
Definition: symbol.h:186
void SetDNP(bool aDNP) override
Definition: symbol.h:193
void SetExcludedFromSim(bool aExcludeFromSim) override
Set or clear the exclude from simulation flag.
Definition: symbol.h:170
bool GetExcludedFromBoard() const override
Definition: symbol.h:187
void SetExcludedFromBOM(bool aExcludeFromBOM) override
Set or clear the exclude from schematic bill of materials flag.
Definition: symbol.h:180
virtual bool GetShowPinNames() const
Definition: symbol.h:159
bool GetDNP() const override
Set or clear the 'Do Not Populate' flag.
Definition: symbol.h:192
virtual bool GetShowPinNumbers() const
Definition: symbol.h:165
bool GetExcludedFromBOM() const override
Definition: symbol.h:181
bool GetExcludedFromSim() const override
Definition: symbol.h:175
wxGridCellAttr * enhanceAttr(wxGridCellAttr *aInputAttr, int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind)
Definition: wx_grid.cpp:45
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
Definition: wx_grid.cpp:499
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:275
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:454
wxString GetShownColumnsAsString()
Get a tokenized string containing the shown column indexes.
Definition: wx_grid.cpp:469
std::bitset< 64 > GetShownColumns()
Definition: wx_grid.cpp:488
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:649
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:194
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:170
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
@ FDC_NAME
@ FDC_VALUE
wxColour GetDialogBGColour()
Definition: wxgtk/ui.cpp:61
wxSize GetUnobscuredSize(const wxWindow *aWindow)
Tries to determine the size of the viewport of a scrollable widget (wxDataViewCtrl,...
Definition: wxgtk/ui.cpp:252
KICOMMON_API wxFont GetSmallInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:162
KICOMMON_API void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
Definition: ui_common.cpp:236
const std::vector< BITMAPS > & PinTypeIcons()
Definition: pin_type.cpp:167
const wxArrayString & PinTypeNames()
Definition: pin_type.cpp:158
const wxArrayString & PinShapeNames()
Definition: pin_type.cpp:176
const std::vector< BITMAPS > & PinShapeIcons()
Definition: pin_type.cpp:185
std::vector< SCH_FIELD > SCH_FIELDS
A container for several SCH_FIELD items.
Definition: sch_symbol.h:63
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:42
@ SYM_MIRROR_Y
Definition: symbol.h:44
@ SYM_ORIENT_180
Definition: symbol.h:41
@ SYM_MIRROR_X
Definition: symbol.h:43
@ SYM_ORIENT_90
Definition: symbol.h:40
@ SYM_ORIENT_0
Definition: symbol.h:39
Definition for symbol library class.
wxString GetUserFieldName(int aFieldNdx, bool aTranslateForHI)
#define DO_TRANSLATE
VECTOR3I res
VECTOR2I end
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695