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 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, &aParent->Schematic(),
338 [&]( wxCommandEvent& aEvent )
339 {
340 OnAddField( aEvent );
341 } ) );
342 m_fieldsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
343
344 // Show/hide columns according to user's preference
345 if( EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ) )
346 {
347 m_fieldsGrid->ShowHideColumns( cfg->m_Appearance.edit_symbol_visible_columns );
349 }
350
352 {
353 // DeMorgan conversions are a subclass of alternate pin assignments, so don't allow
354 // free-form alternate assignments as well. (We won't know how to map the alternates
355 // back and forth when the conversion is changed.)
356 m_pinTablePage->Disable();
357 m_pinTablePage->SetToolTip( _( "Alternate pin assignments are not available for De Morgan "
358 "symbols." ) );
359 }
360 else
361 {
363
364 // Make a copy of the pins for editing
365 for( const std::unique_ptr<SCH_PIN>& pin : m_symbol->GetRawPins() )
366 m_dataModel->push_back( *pin );
367
370
372 }
373
374 if( m_part && m_part->IsPower() )
375 m_spiceFieldsButton->Hide();
376
377 m_pinGrid->PushEventHandler( new GRID_TRICKS( m_pinGrid ) );
378 m_pinGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
379
380 m_tcLibraryID->SetBackgroundColour( KIPLATFORM::UI::GetDialogBGColour() );
381
382 wxToolTip::Enable( true );
384
385 // Configure button logos
386 m_bpAdd->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
387 m_bpDelete->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
388 m_bpMoveUp->SetBitmap( KiBitmapBundle( BITMAPS::small_up ) );
389 m_bpMoveDown->SetBitmap( KiBitmapBundle( BITMAPS::small_down ) );
390
391 // wxFormBuilder doesn't include this event...
392 m_fieldsGrid->Bind( wxEVT_GRID_CELL_CHANGING, &DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging,
393 this );
394 m_pinGrid->Bind( wxEVT_GRID_COL_SORT, &DIALOG_SYMBOL_PROPERTIES::OnPinTableColSort, this );
395 Bind( SYMBOL_DELAY_FOCUS, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedFocus, this );
396 Bind( SYMBOL_DELAY_SELECTION, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedSelection, this );
397
398 QueueEvent( new wxCommandEvent( SYMBOL_DELAY_SELECTION ) );
399 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
400 evt->SetClientData( new VECTOR2I( REFERENCE_FIELD, FDC_VALUE ) );
401 QueueEvent( evt );
402
404}
405
406
408{
409 if( EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ) )
410 {
411 cfg->m_Appearance.edit_symbol_visible_columns = m_fieldsGrid->GetShownColumnsAsString();
412 cfg->m_Appearance.edit_symbol_width = GetSize().x;
413 cfg->m_Appearance.edit_symbol_height = GetSize().y;
414 }
415
416 // Prevents crash bug in wxGrid's d'tor
418
419 if( m_dataModel )
421
422 m_fieldsGrid->Unbind( wxEVT_GRID_CELL_CHANGING, &DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging,
423 this );
424 m_pinGrid->Unbind( wxEVT_GRID_COL_SORT, &DIALOG_SYMBOL_PROPERTIES::OnPinTableColSort, this );
425 Unbind( SYMBOL_DELAY_FOCUS, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedFocus, this );
426 Unbind( SYMBOL_DELAY_SELECTION, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedSelection, this );
427
428 // Delete the GRID_TRICKS.
429 m_fieldsGrid->PopEventHandler( true );
430 m_pinGrid->PopEventHandler( true );
431}
432
433
435{
436 return dynamic_cast<SCH_EDIT_FRAME*>( wxDialog::GetParent() );
437}
438
439
441{
442 if( !wxDialog::TransferDataToWindow() )
443 return false;
444
445 std::set<wxString> defined;
446
447 // Push a copy of each field into m_updateFields
448 for( int i = 0; i < m_symbol->GetFieldCount(); ++i )
449 {
450 SCH_FIELD field( m_symbol->GetFields()[i] );
451
452 // change offset to be symbol-relative
453 field.Offset( -m_symbol->GetPosition() );
454
455 field.SetText( m_symbol->Schematic()->ConvertKIIDsToRefs( field.GetText() ) );
456
457 defined.insert( field.GetName() );
458 m_fields->push_back( field );
459 }
460
461 // Add in any template fieldnames not yet defined:
462 for( const TEMPLATE_FIELDNAME& templateFieldname :
463 GetParent()->Schematic().Settings().m_TemplateFieldNames.GetTemplateFieldNames() )
464 {
465 if( defined.count( templateFieldname.m_Name ) <= 0 )
466 {
467 SCH_FIELD field( VECTOR2I( 0, 0 ), -1, m_symbol, templateFieldname.m_Name );
468 field.SetVisible( templateFieldname.m_Visible );
469 m_fields->push_back( field );
470 }
471 }
472
473 // notify the grid
474 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->size() );
475 m_fieldsGrid->ProcessTableMessage( msg );
477
478 // If a multi-unit symbol, set up the unit selector and interchangeable checkbox.
479 if( m_symbol->GetUnitCount() > 1 )
480 {
481 // Ensure symbol unit is the currently selected unit (mandatory in complex hierarchies)
482 // from the current sheet path, because it can be modified by previous calculations
483 m_symbol->SetUnit( m_symbol->GetUnitSelection( &GetParent()->GetCurrentSheet() ) );
484
485 for( int ii = 1; ii <= m_symbol->GetUnitCount(); ii++ )
486 {
487 if( m_symbol->HasUnitDisplayName( ii ) )
488 m_unitChoice->Append( m_symbol->GetUnitDisplayName( ii ) );
489 else
490 m_unitChoice->Append( m_symbol->SubReference( ii, false ) );
491 }
492
493 if( m_symbol->GetUnit() <= ( int )m_unitChoice->GetCount() )
494 m_unitChoice->SetSelection( m_symbol->GetUnit() - 1 );
495 }
496 else
497 {
498 m_unitLabel->Enable( false );
499 m_unitChoice->Enable( false );
500 }
501
503 {
504 if( m_symbol->GetBodyStyle() > BODY_STYLE::BASE )
505 m_cbAlternateSymbol->SetValue( true );
506 }
507 else
508 {
509 m_cbAlternateSymbol->Enable( false );
510 }
511
512 // Set the symbol orientation and mirroring.
513 int orientation = m_symbol->GetOrientation() & ~( SYM_MIRROR_X | SYM_MIRROR_Y );
514
515 switch( orientation )
516 {
517 default:
518 case SYM_ORIENT_0: m_orientationCtrl->SetSelection( 0 ); break;
519 case SYM_ORIENT_90: m_orientationCtrl->SetSelection( 1 ); break;
520 case SYM_ORIENT_270: m_orientationCtrl->SetSelection( 2 ); break;
521 case SYM_ORIENT_180: m_orientationCtrl->SetSelection( 3 ); break;
522 }
523
524 int mirror = m_symbol->GetOrientation() & ( SYM_MIRROR_X | SYM_MIRROR_Y );
525
526 switch( mirror )
527 {
528 default: m_mirrorCtrl->SetSelection( 0 ) ; break;
529 case SYM_MIRROR_X: m_mirrorCtrl->SetSelection( 1 ); break;
530 case SYM_MIRROR_Y: m_mirrorCtrl->SetSelection( 2 ); break;
531 }
532
536 m_cbDNP->SetValue( m_symbol->GetDNP() );
537
538 if( m_part )
539 {
542 }
543
544 // Set the symbol's library name.
546
547 Layout();
548 m_fieldsGrid->Layout();
549 wxSafeYield();
550
551 return true;
552}
553
554
556{
558 return;
559
560 std::vector<SCH_FIELD> fields;
561
562 for( const SCH_FIELD& field : *m_fields )
563 fields.emplace_back( field );
564
565 DIALOG_SIM_MODEL dialog( this, m_parentFrame, *m_symbol, fields );
566
567 if( dialog.ShowModal() != wxID_OK )
568 return;
569
570 // Add in any new fields
571 for( const SCH_FIELD& editedField : fields )
572 {
573 bool found = false;
574
575 for( SCH_FIELD& existingField : *m_fields )
576 {
577 if( existingField.GetName() == editedField.GetName() )
578 {
579 found = true;
580 existingField.SetText( editedField.GetText() );
581 break;
582 }
583 }
584
585 if( !found )
586 {
587 m_fields->emplace_back( editedField );
588 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
589 m_fieldsGrid->ProcessTableMessage( msg );
590 }
591 }
592
593 // Remove any deleted fields
594 for( int ii = (int) m_fields->size() - 1; ii >= 0; --ii )
595 {
596 SCH_FIELD& existingField = m_fields->at( ii );
597 bool found = false;
598
599 for( SCH_FIELD& editedField : fields )
600 {
601 if( editedField.GetName() == existingField.GetName() )
602 {
603 found = true;
604 break;
605 }
606 }
607
608 if( !found )
609 {
610 m_fields->erase( m_fields->begin() + ii );
611 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, ii, 1 );
612 m_fieldsGrid->ClearSelection();
613 m_fieldsGrid->ProcessTableMessage( msg );
614 }
615 }
616
617 OnModify();
618 m_fieldsGrid->ForceRefresh();
619}
620
621
623{
624 // Running the Footprint Browser gums up the works and causes the automatic cancel
625 // stuff to no longer work. So we do it here ourselves.
626 EndQuasiModal( wxID_CANCEL );
627}
628
629
631{
632 LIB_ID id;
633
634 if( !m_fieldsGrid->CommitPendingChanges() || !m_fieldsGrid->Validate() )
635 return false;
636
638 {
639 DisplayErrorMessage( this, _( "References must start with a letter." ) );
640
641 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
642 evt->SetClientData( new VECTOR2I( REFERENCE_FIELD, FDC_VALUE ) );
643 QueueEvent( evt );
644
645 return false;
646 }
647
648 // Check for missing field names.
649 for( size_t i = MANDATORY_FIELDS; i < m_fields->size(); ++i )
650 {
651 SCH_FIELD& field = m_fields->at( i );
652 wxString fieldName = field.GetName( false );
653
654 if( fieldName.IsEmpty() )
655 {
656 DisplayErrorMessage( this, _( "Fields must have a name." ) );
657
658 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
659 evt->SetClientData( new VECTOR2I( i, FDC_VALUE ) );
660 QueueEvent( evt );
661
662 return false;
663 }
664 }
665
666 return true;
667}
668
669
671{
672 if( !wxDialog::TransferDataFromWindow() ) // Calls our Validate() method.
673 return false;
674
676 return false;
677
679 return false;
680
681 SCH_COMMIT commit( GetParent() );
682 SCH_SCREEN* currentScreen = GetParent()->GetScreen();
683 bool replaceOnCurrentScreen;
684 wxCHECK( currentScreen, false );
685
686 // This needs to be done before the LIB_ID is changed to prevent stale library symbols in
687 // the schematic file.
688 replaceOnCurrentScreen = currentScreen->Remove( m_symbol );
689
690 // save old cmp in undo list if not already in edit, or moving ...
691 if( m_symbol->GetEditFlags() == 0 )
692 commit.Modify( m_symbol, currentScreen );
693
694 // Save current flags which could be modified by next change settings
696
697 // For symbols with multiple shapes (De Morgan representation) Set the selected shape:
698 if( m_cbAlternateSymbol->IsEnabled() && m_cbAlternateSymbol->GetValue() )
699 m_symbol->SetBodyStyle( BODY_STYLE::DEMORGAN );
700 else
701 m_symbol->SetBodyStyle( BODY_STYLE::BASE );
702
703 //Set the part selection in multiple part per package
704 int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1;
705 m_symbol->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection );
706 m_symbol->SetUnit( unit_selection );
707
708 switch( m_orientationCtrl->GetSelection() )
709 {
710 case 0: m_symbol->SetOrientation( SYM_ORIENT_0 ); break;
711 case 1: m_symbol->SetOrientation( SYM_ORIENT_90 ); break;
712 case 2: m_symbol->SetOrientation( SYM_ORIENT_270 ); break;
713 case 3: m_symbol->SetOrientation( SYM_ORIENT_180 ); break;
714 }
715
716 switch( m_mirrorCtrl->GetSelection() )
717 {
718 case 0: break;
719 case 1: m_symbol->SetOrientation( SYM_MIRROR_X ); break;
720 case 2: m_symbol->SetOrientation( SYM_MIRROR_Y ); break;
721 }
722
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( SCH_FIELD& field : *m_fields )
732 {
733 field.Offset( m_symbol->GetPosition() );
734 field.SetText( m_symbol->Schematic()->ConvertRefsToKIIDs( field.GetText() ) );
735 }
736
737 SCH_FIELDS& fields = m_symbol->GetFields();
738 fields.clear();
739
740 for( SCH_FIELD& field : *m_fields )
741 {
742 const wxString& fieldName = field.GetCanonicalName();
743
744 if( fieldName.IsEmpty() && field.GetText().IsEmpty() )
745 continue;
746 else if( fieldName.IsEmpty() )
747 field.SetName( _( "untitled" ) );
748
749 fields.push_back( field );
750 }
751
752 // Reference has a specific initialization, depending on the current active sheet
753 // because for a given symbol, in a complex hierarchy, there are more than one
754 // reference.
755 m_symbol->SetRef( &GetParent()->GetCurrentSheet(), m_fields->at( REFERENCE_FIELD ).GetText() );
756
757 // Similar for Value and Footprint, except that the GUI behavior is that they are kept
758 // in sync between multiple instances.
759 m_symbol->SetValueFieldText( m_fields->at( VALUE_FIELD ).GetText() );
761
765 m_symbol->SetDNP( m_cbDNP->IsChecked() );
766
767 // Update any assignments
768 if( m_dataModel )
769 {
770 for( const SCH_PIN& model_pin : *m_dataModel )
771 {
772 // map from the edited copy back to the "real" pin in the symbol.
773 SCH_PIN* src_pin = m_symbol->GetPin( model_pin.GetNumber() );
774
775 if( src_pin )
776 src_pin->SetAlt( model_pin.GetAlt() );
777 }
778 }
779
780 // Keep fields other than the reference, include/exclude flags, and alternate pin assignements
781 // in sync in multi-unit parts.
782 m_symbol->SyncOtherUnits( GetParent()->GetCurrentSheet(), commit, nullptr );
783
784 if( replaceOnCurrentScreen )
785 currentScreen->Append( m_symbol );
786
787 if( !commit.Empty() )
788 commit.Push( _( "Edit Symbol Properties" ) );
789
790 return true;
791}
792
793
795{
796 wxGridCellEditor* editor = m_fieldsGrid->GetCellEditor( event.GetRow(), event.GetCol() );
797 wxControl* control = editor->GetControl();
798
799 if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) )
800 {
801 event.Veto();
802 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
803 evt->SetClientData( new VECTOR2I( event.GetRow(), event.GetCol() ) );
804 QueueEvent( evt );
805 }
806 else if( event.GetCol() == FDC_NAME )
807 {
808 wxString newName = event.GetString();
809
810 for( int i = 0; i < m_fieldsGrid->GetNumberRows(); ++i )
811 {
812 if( i == event.GetRow() )
813 continue;
814
815 if( newName.CmpNoCase( m_fieldsGrid->GetCellValue( i, FDC_NAME ) ) == 0 )
816 {
817 DisplayError( this, wxString::Format( _( "Field name '%s' already in use." ),
818 newName ) );
819 event.Veto();
820 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
821 evt->SetClientData( new VECTOR2I( event.GetRow(), event.GetCol() ) );
822 QueueEvent( evt );
823 }
824 }
825 }
826
827 editor->DecRef();
828}
829
830
832{
833 if( aEvent.GetRow() == REFERENCE_FIELD && aEvent.GetCol() == FDC_VALUE )
834 QueueEvent( new wxCommandEvent( SYMBOL_DELAY_SELECTION ) );
835
836 m_editorShown = true;
837}
838
839
841{
842 m_editorShown = false;
843}
844
845
846void DIALOG_SYMBOL_PROPERTIES::OnAddField( wxCommandEvent& event )
847{
849 return;
850
852 int fieldID = (int) m_fields->size();
853 SCH_FIELD newField( VECTOR2I( 0, 0 ), fieldID, m_symbol,
855 DO_TRANSLATE ) );
856
857 newField.SetTextAngle( m_fields->at( REFERENCE_FIELD ).GetTextAngle() );
858 newField.SetTextSize( VECTOR2I( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
859
860 m_fields->push_back( newField );
861
862 // notify the grid
863 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
864 m_fieldsGrid->ProcessTableMessage( msg );
865
866 m_fieldsGrid->MakeCellVisible( (int) m_fields->size() - 1, 0 );
867 m_fieldsGrid->SetGridCursor( (int) m_fields->size() - 1, 0 );
868
869 m_fieldsGrid->EnableCellEditControl();
870 m_fieldsGrid->ShowCellEditControl();
871
872 OnModify();
873}
874
875
876void DIALOG_SYMBOL_PROPERTIES::OnDeleteField( wxCommandEvent& event )
877{
878 wxArrayInt selectedRows = m_fieldsGrid->GetSelectedRows();
879
880 if( selectedRows.empty() && m_fieldsGrid->GetGridCursorRow() >= 0 )
881 selectedRows.push_back( m_fieldsGrid->GetGridCursorRow() );
882
883 if( selectedRows.empty() )
884 return;
885
886 for( int row : selectedRows )
887 {
888 if( row < MANDATORY_FIELDS )
889 {
890 DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
892 return;
893 }
894 }
895
896 m_fieldsGrid->CommitPendingChanges( true /* quiet mode */ );
897 m_fieldsGrid->ClearSelection();
898
899 // Reverse sort so deleting a row doesn't change the indexes of the other rows.
900 selectedRows.Sort( []( int* first, int* second ) { return *second - *first; } );
901
902 for( int row : selectedRows )
903 {
904 m_fields->erase( m_fields->begin() + row );
905
906 // notify the grid
907 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
908 m_fieldsGrid->ProcessTableMessage( msg );
909
910 if( m_fieldsGrid->GetNumberRows() > 0 )
911 {
912 m_fieldsGrid->MakeCellVisible( std::max( 0, row-1 ), m_fieldsGrid->GetGridCursorCol() );
913 m_fieldsGrid->SetGridCursor( std::max( 0, row-1 ), m_fieldsGrid->GetGridCursorCol() );
914 }
915 }
916
917 OnModify();
918}
919
920
921void DIALOG_SYMBOL_PROPERTIES::OnMoveUp( wxCommandEvent& event )
922{
924 return;
925
926 int i = m_fieldsGrid->GetGridCursorRow();
927
928 if( i > MANDATORY_FIELDS )
929 {
930 SCH_FIELD tmp = m_fields->at( (unsigned) i );
931 m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
932 m_fields->insert( m_fields->begin() + i - 1, tmp );
933 m_fieldsGrid->ForceRefresh();
934
935 m_fieldsGrid->SetGridCursor( i - 1, m_fieldsGrid->GetGridCursorCol() );
936 m_fieldsGrid->MakeCellVisible( m_fieldsGrid->GetGridCursorRow(),
937 m_fieldsGrid->GetGridCursorCol() );
938
939 OnModify();
940 }
941 else
942 {
943 wxBell();
944 }
945}
946
947
948void DIALOG_SYMBOL_PROPERTIES::OnMoveDown( wxCommandEvent& event )
949{
951 return;
952
953 int i = m_fieldsGrid->GetGridCursorRow();
954
955 if( i >= MANDATORY_FIELDS && i < m_fieldsGrid->GetNumberRows() - 1 )
956 {
957 SCH_FIELD tmp = m_fields->at( (unsigned) i );
958 m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
959 m_fields->insert( m_fields->begin() + i + 1, tmp );
960 m_fieldsGrid->ForceRefresh();
961
962 m_fieldsGrid->SetGridCursor( i + 1, m_fieldsGrid->GetGridCursorCol() );
963 m_fieldsGrid->MakeCellVisible( m_fieldsGrid->GetGridCursorRow(),
964 m_fieldsGrid->GetGridCursorCol() );
965
966 OnModify();
967 }
968 else
969 {
970 wxBell();
971 }
972}
973
974
976{
979}
980
981
983{
986}
987
988
990{
993}
994
995
997{
1000}
1001
1002
1004{
1005 int row = aEvent.GetRow();
1006
1007 if( m_pinGrid->GetCellValue( row, COL_ALT_NAME )
1008 == m_dataModel->GetValue( row, COL_BASE_NAME ) )
1009 {
1010 m_dataModel->SetValue( row, COL_ALT_NAME, wxEmptyString );
1011 }
1012
1013 // These are just to get the cells refreshed
1016
1017 OnModify();
1018}
1019
1020
1022{
1023 int sortCol = aEvent.GetCol();
1024 bool ascending;
1025
1026 // This is bonkers, but wxWidgets doesn't tell us ascending/descending in the
1027 // event, and if we ask it will give us pre-event info.
1028 if( m_pinGrid->IsSortingBy( sortCol ) )
1029 // same column; invert ascending
1030 ascending = !m_pinGrid->IsSortOrderAscending();
1031 else
1032 // different column; start with ascending
1033 ascending = true;
1034
1035 m_dataModel->SortRows( sortCol, ascending );
1037}
1038
1039
1041{
1042 wxGridUpdateLocker deferRepaintsTillLeavingScope( m_fieldsGrid );
1043
1044 // Account for scroll bars
1045 int fieldsWidth = KIPLATFORM::UI::GetUnobscuredSize( m_fieldsGrid ).x;
1046
1047 m_fieldsGrid->AutoSizeColumn( 0 );
1048 m_fieldsGrid->SetColSize( 0, std::max( 72, m_fieldsGrid->GetColSize( 0 ) ) );
1049
1050 int fixedColsWidth = m_fieldsGrid->GetColSize( 0 );
1051
1052 for( int i = 2; i < m_fieldsGrid->GetNumberCols(); i++ )
1053 fixedColsWidth += m_fieldsGrid->GetColSize( i );
1054
1055 m_fieldsGrid->SetColSize( 1, std::max( 120, fieldsWidth - fixedColsWidth ) );
1056}
1057
1058
1060{
1061 wxGridUpdateLocker deferRepaintsTillLeavingScope( m_pinGrid );
1062
1063 // Account for scroll bars
1064 int pinTblWidth = KIPLATFORM::UI::GetUnobscuredSize( m_pinGrid ).x;
1065
1066 // Stretch the Base Name and Alternate Assignment columns to fit.
1067 for( int i = 0; i < COL_COUNT; ++i )
1068 {
1069 if( i != COL_BASE_NAME && i != COL_ALT_NAME )
1070 pinTblWidth -= m_pinGrid->GetColSize( i );
1071 }
1072
1073 m_pinGrid->SetColSize( COL_BASE_NAME, pinTblWidth / 2 );
1074 m_pinGrid->SetColSize( COL_ALT_NAME, pinTblWidth / 2 );
1075}
1076
1077
1078void DIALOG_SYMBOL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
1079{
1080 std::bitset<64> shownColumns = m_fieldsGrid->GetShownColumns();
1081
1082 if( shownColumns != m_shownColumns )
1083 {
1084 m_shownColumns = shownColumns;
1085
1086 if( !m_fieldsGrid->IsCellEditControlShown() )
1088 }
1089}
1090
1091
1093{
1094 VECTOR2I *loc = static_cast<VECTOR2I*>( event.GetClientData() );
1095
1096 wxCHECK_RET( loc, wxT( "Missing focus cell location" ) );
1097
1098 // Handle a delayed focus
1099
1100 m_fieldsGrid->SetFocus();
1101 m_fieldsGrid->MakeCellVisible( loc->x, loc->y );
1102 m_fieldsGrid->SetGridCursor( loc->x, loc->y );
1103
1104 m_fieldsGrid->EnableCellEditControl( true );
1105 m_fieldsGrid->ShowCellEditControl();
1106
1107 delete loc;
1108}
1109
1110
1112{
1113 // Handle a delayed selection
1114 wxGridCellEditor* cellEditor = m_fieldsGrid->GetCellEditor( REFERENCE_FIELD, FDC_VALUE );
1115
1116 if( wxTextEntry* txt = dynamic_cast<wxTextEntry*>( cellEditor->GetControl() ) )
1118
1119 cellEditor->DecRef(); // we're done; must release
1120}
1121
1123{
1124 wxSize new_size = event.GetSize();
1125
1126 if( ( !m_editorShown || m_lastRequestedFieldsSize != new_size ) && m_fieldsSize != new_size )
1127 {
1128 m_fieldsSize = new_size;
1129
1131 }
1132
1133 // We store this value to check whether the dialog is changing size. This might indicate
1134 // that the user is scaling the dialog with a grid-cell-editor shown. Some editors do not
1135 // close (at least on GTK) when the user drags a dialog corner
1136 m_lastRequestedFieldsSize = new_size;
1137
1138 // Always propagate for a grid repaint (needed if the height changes, as well as width)
1139 event.Skip();
1140}
1141
1142
1144{
1145 wxSize new_size = event.GetSize();
1146
1147 if( ( !m_editorShown || m_lastRequestedPinsSize != new_size ) && m_pinsSize != new_size )
1148 {
1149 m_pinsSize = new_size;
1150
1152 }
1153
1154 // We store this value to check whether the dialog is changing size. This might indicate
1155 // that the user is scaling the dialog with a grid-cell-editor shown. Some editors do not
1156 // close (at least on GTK) when the user drags a dialog corner
1157 m_lastRequestedPinsSize = new_size;
1158
1159 // Always propagate for a grid repaint (needed if the height changes, as well as width)
1160 event.Skip();
1161}
1162
1163
1164void DIALOG_SYMBOL_PROPERTIES::OnInitDlg( wxInitDialogEvent& event )
1165{
1167
1168 // Now all widgets have the size fixed, call FinishDialogSettings
1170
1171 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
1172
1173 if( cfg && cfg->m_Appearance.edit_symbol_width > 0 && cfg->m_Appearance.edit_symbol_height > 0 )
1175}
1176
1177
1178void DIALOG_SYMBOL_PROPERTIES::OnCheckBox( wxCommandEvent& event )
1179{
1180 OnModify();
1181}
1182
1183
1184void DIALOG_SYMBOL_PROPERTIES::OnUnitChoice( wxCommandEvent& event )
1185{
1186 if( m_dataModel )
1187 {
1188 EDA_ITEM_FLAGS flags = m_symbol->GetFlags();
1189
1190 int unit_selection = m_unitChoice->GetSelection() + 1;
1191
1192 // We need to select a new unit to build the new unit pin list
1193 // but we should not change the symbol, so the initial unit will be selected
1194 // after rebuilding the pin list
1195 int old_unit = m_symbol->GetUnit();
1196 m_symbol->SetUnit( unit_selection );
1197
1198 // Rebuild a copy of the pins of the new unit for editing
1199 m_dataModel->clear();
1200
1201 for( const std::unique_ptr<SCH_PIN>& pin : m_symbol->GetRawPins() )
1202 m_dataModel->push_back( *pin );
1203
1206
1207 m_symbol->SetUnit( old_unit );
1208
1209 // Restore m_Flag modified by SetUnit()
1211 m_symbol->SetFlags( flags );
1212 }
1213
1214 OnModify();
1215}
1216
1217
1219{
1220 event.Enable( m_symbol && m_symbol->GetLibSymbolRef() );
1221}
1222
1223
1225{
1226 event.Enable( m_symbol && m_symbol->GetLibSymbolRef() );
1227}
1228
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:105
bool Empty() const
Returns status of an item.
Definition: commit.h:144
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:228
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
void OnExchangeSymbol(wxCommandEvent &) override
virtual void onUpdateEditSymbol(wxUpdateUIEvent &event) override
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:133
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:127
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:129
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:130
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition: eda_text.cpp:373
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:94
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:436
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:244
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:204
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:118
bool IsPower() const override
Definition: lib_symbol.cpp:389
bool HasAlternateBodyStyle() const override
Test if symbol has more than one body conversion type (DeMorgan).
static int Compare(const wxString &lhs, const wxString &rhs)
These are loaded from Eeschema settings but then overwritten by the project settings.
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:297
wxString ConvertKIIDsToRefs(const wxString &aSource) const
Definition: schematic.cpp:555
wxString ConvertRefsToKIIDs(const wxString &aSource) const
Definition: schematic.cpp:488
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:406
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
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:1220
void SetText(const wxString &aText) override
Definition: sch_field.cpp:1205
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:150
int GetBodyStyle() const
Definition: sch_item.h:232
int GetUnit() const
Definition: sch_item.h:229
virtual void SetUnit(int aUnit)
Definition: sch_item.h:228
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)
Definition: sch_pin.h:135
ALT GetAlt(const wxString &aAlt)
Definition: sch_pin.h:129
SCH_PIN * GetLibPin() const
Definition: sch_pin.h:80
const wxString & GetName() const
Definition: sch_pin.cpp:353
std::map< wxString, ALT > & GetAlternates()
Definition: sch_pin.h:121
const wxString & GetNumber() const
Definition: sch_pin.h:111
GRAPHIC_PINSHAPE GetShape() const
Definition: sch_pin.cpp:258
ELECTRICAL_PINTYPE GetType() const
Definition: sch_pin.cpp:291
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Definition: sch_screen.cpp:152
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:322
Schematic symbol object.
Definition: sch_symbol.h:106
wxString GetUnitDisplayName(int aUnit) const
Return the display name for a given unit aUnit.
Definition: sch_symbol.cpp:475
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins()
Definition: sch_symbol.h:682
void SetShowPinNumbers(bool aShow) override
Set or clear the pin number visibility flag.
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:611
wxString SubReference(int aUnit, bool aAddSeparator=true) const
Definition: sch_symbol.cpp:851
static bool IsReferenceStringValid(const wxString &aReferenceString)
Test for an acceptable reference string.
Definition: sch_symbol.cpp:768
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:912
void SetBodyStyle(int aBodyStyle) override
Definition: sch_symbol.cpp:438
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 assignements in sync i...
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:774
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:928
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:822
const LIB_ID & GetLibId() const override
Definition: sch_symbol.h:195
int GetOrientation() const
Get the display symbol orientation.
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:860
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:466
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:982
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
Definition: sch_symbol.cpp:876
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:214
bool HasUnitDisplayName(int aUnit) const
Return true if the given unit aUnit has a display name set.
Definition: sch_symbol.cpp:483
void SetBitmap(const wxBitmapBundle &aBmp)
void SetDNP(bool aDNP)
Definition: symbol.h:154
bool GetExcludedFromBoard() const
Definition: symbol.h:148
bool GetExcludedFromBOM() const
Definition: symbol.h:142
void SetExcludedFromSim(bool aExcludeFromSim) override
Set or clear the exclude from simulation flag.
Definition: symbol.h:135
bool GetDNP() const
Set or clear the 'Do Not Populate' flaga.
Definition: symbol.h:153
virtual bool GetShowPinNames() const
Definition: symbol.h:124
void SetExcludedFromBOM(bool aExcludeFromBOM)
Set or clear the exclude from schematic bill of materials flag.
Definition: symbol.h:141
void SetExcludedFromBoard(bool aExcludeFromBoard)
Set or clear exclude from board netlist flag.
Definition: symbol.h:147
virtual bool GetShowPinNumbers() const
Definition: symbol.h:130
bool GetExcludedFromSim() const override
Definition: symbol.h:136
wxGridCellAttr * enhanceAttr(wxGridCellAttr *aInputAttr, int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind)
Definition: wx_grid.cpp:42
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
Definition: wx_grid.cpp:444
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:267
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:400
wxString GetShownColumnsAsString()
Get a tokenized string containing the shown column indexes.
Definition: wx_grid.cpp:414
std::bitset< 64 > GetShownColumns()
Definition: wx_grid.cpp:433
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:594
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:170
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:195
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:195
KICOMMON_API void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
Definition: ui_common.cpp:228
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
std::vector< SCH_FIELD > SCH_FIELDS
A container for several SCH_FIELD items.
Definition: sch_symbol.h:67
@ SYM_ORIENT_270
Definition: sch_symbol.h:85
@ SYM_MIRROR_Y
Definition: sch_symbol.h:87
@ SYM_ORIENT_180
Definition: sch_symbol.h:84
@ SYM_MIRROR_X
Definition: sch_symbol.h:86
@ SYM_ORIENT_90
Definition: sch_symbol.h:83
@ SYM_ORIENT_0
Definition: sch_symbol.h:82
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
@ 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< int32_t > VECTOR2I
Definition: vector2d.h:676