KiCad PCB EDA Suite
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-2021 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 <bitmaps.h>
27 #include <wx/tooltip.h>
28 #include <grid_tricks.h>
29 #include <confirm.h>
30 #include <kiface_base.h>
31 #include <pin_numbers.h>
32 #include <string_utils.h>
33 #include <menus_helpers.h>
35 #include <widgets/grid_combobox.h>
36 #include <widgets/wx_grid.h>
38 #include <ee_collectors.h>
39 #include <symbol_library.h>
40 #include <fields_grid_table.h>
41 #include <sch_edit_frame.h>
42 #include <sch_reference_list.h>
43 #include <schematic.h>
44 #include <tool/tool_manager.h>
45 #include <tool/actions.h>
46 
47 #ifdef KICAD_SPICE
48 #include <dialog_spice_model.h>
49 #endif /* KICAD_SPICE */
50 
51 
53 {
59 
60  COL_COUNT // keep as last
61 };
62 
63 
64 class SCH_PIN_TABLE_DATA_MODEL : public wxGridTableBase, public std::vector<SCH_PIN>
65 {
66 protected:
67  std::vector<wxGridCellAttr*> m_nameAttrs;
68  wxGridCellAttr* m_readOnlyAttr;
69  wxGridCellAttr* m_typeAttr;
70  wxGridCellAttr* m_shapeAttr;
71 
72 public:
74  m_readOnlyAttr( nullptr ),
75  m_typeAttr( nullptr ),
76  m_shapeAttr( nullptr )
77  {
78  }
79 
81  {
82  for( wxGridCellAttr* attr : m_nameAttrs )
83  attr->DecRef();
84 
85  m_readOnlyAttr->DecRef();
86  m_typeAttr->DecRef();
87  m_shapeAttr->DecRef();
88  }
89 
90  void BuildAttrs()
91  {
92  m_readOnlyAttr = new wxGridCellAttr;
93  m_readOnlyAttr->SetReadOnly( true );
94 
95  for( const SCH_PIN& pin : *this )
96  {
97  LIB_PIN* lib_pin = pin.GetLibPin();
98  wxGridCellAttr* attr = nullptr;
99 
100  if( lib_pin->GetAlternates().empty() )
101  {
102  attr = new wxGridCellAttr;
103  attr->SetReadOnly( true );
104  }
105  else
106  {
107  wxArrayString choices;
108  choices.push_back( lib_pin->GetName() );
109 
110  for( const std::pair<const wxString, LIB_PIN::ALT>& alt : lib_pin->GetAlternates() )
111  choices.push_back( alt.first );
112 
113  attr = new wxGridCellAttr();
114  attr->SetEditor( new GRID_CELL_COMBOBOX( choices ) );
115  }
116 
117  m_nameAttrs.push_back( attr );
118  }
119 
120  m_typeAttr = new wxGridCellAttr;
122  PinTypeNames() ) );
123  m_typeAttr->SetReadOnly( true );
124 
125  m_shapeAttr = new wxGridCellAttr;
127  PinShapeNames() ) );
128  m_shapeAttr->SetReadOnly( true );
129  }
130 
131  int GetNumberRows() override { return (int) size(); }
132  int GetNumberCols() override { return COL_COUNT; }
133 
134  wxString GetColLabelValue( int aCol ) override
135  {
136  switch( aCol )
137  {
138  case COL_NUMBER: return _( "Number" );
139  case COL_BASE_NAME: return _( "Base Name" );
140  case COL_ALT_NAME: return _( "Alternate Assignment" );
141  case COL_TYPE: return _( "Electrical Type" );
142  case COL_SHAPE: return _( "Graphic Style" );
143  default: wxFAIL; return wxEmptyString;
144  }
145  }
146 
147  bool IsEmptyCell( int row, int col ) override
148  {
149  return false; // don't allow adjacent cell overflow, even if we are actually empty
150  }
151 
152  wxString GetValue( int aRow, int aCol ) override
153  {
154  return GetValue( at( aRow ), aCol );
155  }
156 
157  static wxString GetValue( const SCH_PIN& aPin, int aCol )
158  {
159  switch( aCol )
160  {
161  case COL_NUMBER: return aPin.GetNumber();
162  case COL_BASE_NAME: return aPin.GetLibPin()->GetName();
163  case COL_ALT_NAME: return aPin.GetAlt();
164  case COL_TYPE: return PinTypeNames()[static_cast<int>( aPin.GetType() )];
165  case COL_SHAPE: return PinShapeNames()[static_cast<int>( aPin.GetShape() )];
166  default: wxFAIL; return wxEmptyString;
167  }
168  }
169 
170  wxGridCellAttr* GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind ) override
171  {
172  switch( aCol )
173  {
174  case COL_NUMBER:
175  case COL_BASE_NAME:
176  m_readOnlyAttr->IncRef();
177  return m_readOnlyAttr;
178 
179  case COL_ALT_NAME:
180  m_nameAttrs[ aRow ]->IncRef();
181  return m_nameAttrs[ aRow ];
182 
183  case COL_TYPE:
184  m_typeAttr->IncRef();
185  return m_typeAttr;
186 
187  case COL_SHAPE:
188  m_shapeAttr->IncRef();
189  return m_shapeAttr;
190 
191  default:
192  wxFAIL;
193  return nullptr;
194  }
195  }
196 
197  void SetValue( int aRow, int aCol, const wxString &aValue ) override
198  {
199  switch( aCol )
200  {
201  case COL_ALT_NAME:
202  if( aValue == at( aRow ).GetLibPin()->GetName() )
203  at( aRow ).SetAlt( wxEmptyString );
204  else
205  at( aRow ).SetAlt( aValue );
206  break;
207 
208  case COL_NUMBER:
209  case COL_BASE_NAME:
210  case COL_TYPE:
211  case COL_SHAPE:
212  // Read-only.
213  break;
214 
215  default:
216  wxFAIL;
217  break;
218  }
219  }
220 
221  static bool compare( const SCH_PIN& lhs, const SCH_PIN& rhs, int sortCol, bool ascending )
222  {
223  wxString lhStr = GetValue( lhs, sortCol );
224  wxString rhStr = GetValue( rhs, sortCol );
225 
226  if( lhStr == rhStr )
227  {
228  // Secondary sort key is always COL_NUMBER
229  sortCol = COL_NUMBER;
230  lhStr = GetValue( lhs, sortCol );
231  rhStr = GetValue( rhs, sortCol );
232  }
233 
234  bool res;
235 
236  // N.B. To meet the iterator sort conditions, we cannot simply invert the truth
237  // to get the opposite sort. i.e. ~(a<b) != (a>b)
238  auto cmp = [ ascending ]( const auto a, const auto b )
239  {
240  if( ascending )
241  return a < b;
242  else
243  return b < a;
244  };
245 
246  switch( sortCol )
247  {
248  case COL_NUMBER:
249  case COL_BASE_NAME:
250  case COL_ALT_NAME:
251  res = cmp( PIN_NUMBERS::Compare( lhStr, rhStr ), 0 );
252  break;
253  case COL_TYPE:
254  case COL_SHAPE:
255  res = cmp( lhStr.CmpNoCase( rhStr ), 0 );
256  break;
257  default:
258  res = cmp( StrNumCmp( lhStr, rhStr ), 0 );
259  break;
260  }
261 
262  return res;
263  }
264 
265  void SortRows( int aSortCol, bool ascending )
266  {
267  std::sort( begin(), end(),
268  [ aSortCol, ascending ]( const SCH_PIN& lhs, const SCH_PIN& rhs ) -> bool
269  {
270  return compare( lhs, rhs, aSortCol, ascending );
271  } );
272  }
273 };
274 
275 
277  SCH_SYMBOL* aSymbol ) :
279  m_symbol( nullptr ),
280  m_part( nullptr ),
281  m_fields( nullptr ),
282  m_dataModel( nullptr )
283 {
284  m_symbol = aSymbol;
285  m_part = m_symbol->GetLibSymbolRef().get();
286 
287  // GetLibSymbolRef() now points to the cached part in the schematic, which should always be
288  // there for usual cases, but can be null when opening old schematics not storing the part
289  // so we need to handle m_part == nullptr
290  // wxASSERT( m_part );
291 
292  m_fields = new FIELDS_GRID_TABLE<SCH_FIELD>( this, aParent, m_fieldsGrid, m_part );
293 
294  m_width = 0;
297  m_delayedSelection = true;
298 
299 #ifndef KICAD_SPICE
300  m_spiceFieldsButton->Hide();
301 #endif /* not KICAD_SPICE */
302 
303  // disable some options inside the edit dialog which can cause problems while dragging
304  if( m_symbol->IsDragging() )
305  {
306  m_orientationLabel->Disable();
307  m_orientationCtrl->Disable();
308  m_mirrorLabel->Disable();
309  m_mirrorCtrl->Disable();
310  }
311 
312  // Give a bit more room for combobox editors
313  m_fieldsGrid->SetDefaultRowSize( m_fieldsGrid->GetDefaultRowSize() + 4 );
314  m_pinGrid->SetDefaultRowSize( m_pinGrid->GetDefaultRowSize() + 4 );
315 
317  m_fieldsGrid->PushEventHandler( new FIELDS_GRID_TRICKS( m_fieldsGrid, this ) );
318  m_fieldsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
319 
320  // Show/hide columns according to user's preference
321  EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
322 
323  if( cfg )
324  {
327  }
328 
329  if( m_part && m_part->HasConversion() )
330  {
331  // DeMorgan conversions are a subclass of alternate pin assignments, so don't allow
332  // free-form alternate assignments as well. (We won't know how to map the alternates
333  // back and forth when the conversion is changed.)
334  m_pinTablePage->Disable();
335  m_pinTablePage->SetToolTip( _( "Alternate pin assignments are not available for De Morgan "
336  "symbols." ) );
337  }
338  else
339  {
341 
342  // Make a copy of the pins for editing
343  for( const std::unique_ptr<SCH_PIN>& pin : m_symbol->GetRawPins() )
344  m_dataModel->push_back( *pin );
345 
346  m_dataModel->SortRows( COL_NUMBER, true );
348 
350  }
351 
352  m_pinGrid->PushEventHandler( new GRID_TRICKS( m_pinGrid ) );
353  m_pinGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
354 
355  wxToolTip::Enable( true );
356  m_stdDialogButtonSizerOK->SetDefault();
357 
358  // Configure button logos
359  m_bpAdd->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
360  m_bpDelete->SetBitmap( KiBitmap( BITMAPS::small_trash ) );
361  m_bpMoveUp->SetBitmap( KiBitmap( BITMAPS::small_up ) );
362  m_bpMoveDown->SetBitmap( KiBitmap( BITMAPS::small_down ) );
363 
364  // wxFormBuilder doesn't include this event...
365  m_fieldsGrid->Connect( wxEVT_GRID_CELL_CHANGING,
366  wxGridEventHandler( DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging ),
367  nullptr, this );
368 
369  m_pinGrid->Connect( wxEVT_GRID_COL_SORT,
370  wxGridEventHandler( DIALOG_SYMBOL_PROPERTIES::OnPinTableColSort ),
371  nullptr, this );
372 
374 }
375 
376 
378 {
379  EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
380 
381  if( cfg )
383 
384  // Prevents crash bug in wxGrid's d'tor
386 
387  if( m_dataModel )
389 
390  m_fieldsGrid->Disconnect( wxEVT_GRID_CELL_CHANGING,
391  wxGridEventHandler( DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging ),
392  nullptr, this );
393 
394  m_pinGrid->Disconnect( wxEVT_GRID_COL_SORT,
395  wxGridEventHandler( DIALOG_SYMBOL_PROPERTIES::OnPinTableColSort ),
396  nullptr, this );
397 
398  // Delete the GRID_TRICKS.
399  m_fieldsGrid->PopEventHandler( true );
400  m_pinGrid->PopEventHandler( true );
401 }
402 
403 
405 {
406  return dynamic_cast<SCH_EDIT_FRAME*>( wxDialog::GetParent() );
407 }
408 
409 
411 {
412  if( !wxDialog::TransferDataToWindow() )
413  return false;
414 
415  std::set<wxString> defined;
416 
417  // Push a copy of each field into m_updateFields
418  for( int i = 0; i < m_symbol->GetFieldCount(); ++i )
419  {
420  SCH_FIELD field( m_symbol->GetFields()[i] );
421 
422  // change offset to be symbol-relative
423  field.Offset( -m_symbol->GetPosition() );
424 
425  defined.insert( field.GetName() );
426  m_fields->push_back( field );
427  }
428 
429  // Add in any template fieldnames not yet defined:
430  for( const TEMPLATE_FIELDNAME& templateFieldname :
431  GetParent()->Schematic().Settings().m_TemplateFieldNames.GetTemplateFieldNames() )
432  {
433  if( defined.count( templateFieldname.m_Name ) <= 0 )
434  {
435  SCH_FIELD field( wxPoint( 0, 0 ), -1, m_symbol, templateFieldname.m_Name );
436  field.SetVisible( templateFieldname.m_Visible );
437  m_fields->push_back( field );
438  }
439  }
440 
441  // notify the grid
442  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->size() );
443  m_fieldsGrid->ProcessTableMessage( msg );
444  AdjustGridColumns( m_fieldsGrid->GetRect().GetWidth() );
445 
446  // If a multi-unit symbol, set up the unit selector and interchangeable checkbox.
447  if( m_symbol->GetUnitCount() > 1 )
448  {
449  for( int ii = 1; ii <= m_symbol->GetUnitCount(); ii++ )
450  m_unitChoice->Append( LIB_SYMBOL::SubReference( ii, false ) );
451 
452  if( m_symbol->GetUnit() <= ( int )m_unitChoice->GetCount() )
453  m_unitChoice->SetSelection( m_symbol->GetUnit() - 1 );
454  }
455  else
456  {
457  m_unitLabel->Enable( false );
458  m_unitChoice->Enable( false );
459  }
460 
461  if( m_part && m_part->HasConversion() )
462  {
463  if( m_symbol->GetConvert() > LIB_ITEM::LIB_CONVERT::BASE )
464  m_cbAlternateSymbol->SetValue( true );
465  }
466  else
467  {
468  m_cbAlternateSymbol->Enable( false );
469  }
470 
471  // Set the symbol orientation and mirroring.
472  int orientation = m_symbol->GetOrientation() & ~( SYM_MIRROR_X | SYM_MIRROR_Y );
473 
474  switch( orientation )
475  {
476  default:
477  case SYM_ORIENT_0: m_orientationCtrl->SetSelection( 0 ); break;
478  case SYM_ORIENT_90: m_orientationCtrl->SetSelection( 1 ); break;
479  case SYM_ORIENT_270: m_orientationCtrl->SetSelection( 2 ); break;
480  case SYM_ORIENT_180: m_orientationCtrl->SetSelection( 3 ); break;
481  }
482 
483  int mirror = m_symbol->GetOrientation() & ( SYM_MIRROR_X | SYM_MIRROR_Y );
484 
485  switch( mirror )
486  {
487  default: m_mirrorCtrl->SetSelection( 0 ) ; break;
488  case SYM_MIRROR_X: m_mirrorCtrl->SetSelection( 1 ); break;
489  case SYM_MIRROR_Y: m_mirrorCtrl->SetSelection( 2 ); break;
490  }
491 
494 
495  if( m_part )
496  {
497  m_ShowPinNumButt->SetValue( m_part->ShowPinNumbers() );
498  m_ShowPinNameButt->SetValue( m_part->ShowPinNames() );
499  }
500 
501  // Set the symbol's library name.
502  m_tcLibraryID->SetValue( UnescapeString( m_symbol->GetLibId().Format() ) );
503 
504  Layout();
505 
506  // Workaround to fix an annoying issue on wxGTK: in some cases selecting a field
507  // to change its value make this value invisible. It happens until the dialog is resized.
508  // So I am guessing there is a problem when initializing sizers settings
509  // Do not create issues on other OS
510  wxSafeYield(); // slice of time to handle events generated when creating the
511  // dialog, especially size events
512  m_fieldsGrid->Layout(); // Force recalculating all sizers in m_fieldsGrid
513 
514  return true;
515 }
516 
517 
518 void DIALOG_SYMBOL_PROPERTIES::OnEditSpiceModel( wxCommandEvent& event )
519 {
520 #ifdef KICAD_SPICE
521  int diff = m_fields->size();
522 
523  DIALOG_SPICE_MODEL dialog( this, *m_symbol, m_fields );
524 
525  if( dialog.ShowModal() != wxID_OK )
526  return;
527 
528  diff = (int) m_fields->size() - diff;
529 
530  if( diff > 0 )
531  {
532  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, diff );
533  m_fieldsGrid->ProcessTableMessage( msg );
534  }
535  else if( diff < 0 )
536  {
537  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, -diff );
538  m_fieldsGrid->ProcessTableMessage( msg );
539  }
540 
541  OnModify();
542  m_fieldsGrid->ForceRefresh();
543 #endif /* KICAD_SPICE */
544 }
545 
546 
548 {
549  // Running the Footprint Browser gums up the works and causes the automatic cancel
550  // stuff to no longer work. So we do it here ourselves.
551  EndQuasiModal( wxID_CANCEL );
552 }
553 
554 
556 {
557  wxString msg;
558  LIB_ID id;
559 
560  if( !m_fieldsGrid->CommitPendingChanges() || !m_fieldsGrid->Validate() )
561  return false;
562 
564  {
565  DisplayErrorMessage( this, _( "References must start with a letter." ) );
566 
569  m_delayedSelection = false;
570 
571  return false;
572  }
573 
574  // Check for missing field names.
575  for( size_t i = MANDATORY_FIELDS; i < m_fields->size(); ++i )
576  {
577  SCH_FIELD& field = m_fields->at( i );
578  wxString fieldName = field.GetName( false );
579 
580  if( fieldName.IsEmpty() )
581  {
582  DisplayErrorMessage( this, _( "Fields must have a name." ) );
583 
585  m_delayedFocusRow = i;
586  m_delayedSelection = false;
587 
588  return false;
589  }
590  }
591 
592  return true;
593 }
594 
595 
597 {
598  if( !wxDialog::TransferDataFromWindow() ) // Calls our Validate() method.
599  return false;
600 
602  return false;
603 
605  return false;
606 
607  SCH_SCREEN* currentScreen = GetParent()->GetScreen();
608  SCHEMATIC& schematic = GetParent()->Schematic();
609 
610  wxCHECK( currentScreen, false );
611 
612  // This needs to be done before the LIB_ID is changed to prevent stale library symbols in
613  // the schematic file.
614  currentScreen->Remove( m_symbol );
615 
616  wxString msg;
617 
618  // save old cmp in undo list if not already in edit, or moving ...
619  if( m_symbol->GetEditFlags() == 0 )
620  GetParent()->SaveCopyInUndoList( currentScreen, m_symbol, UNDO_REDO::CHANGED, false );
621 
622  // Save current flags which could be modified by next change settings
623  EDA_ITEM_FLAGS flags = m_symbol->GetFlags();
624 
625  // For symbols with multiple shapes (De Morgan representation) Set the selected shape:
626  if( m_cbAlternateSymbol->IsEnabled() && m_cbAlternateSymbol->GetValue() )
627  m_symbol->SetConvert( LIB_ITEM::LIB_CONVERT::DEMORGAN );
628  else
629  m_symbol->SetConvert( LIB_ITEM::LIB_CONVERT::BASE );
630 
631  //Set the part selection in multiple part per package
632  int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1;
633  m_symbol->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection );
634  m_symbol->SetUnit( unit_selection );
635 
636  switch( m_orientationCtrl->GetSelection() )
637  {
638  case 0: m_symbol->SetOrientation( SYM_ORIENT_0 ); break;
639  case 1: m_symbol->SetOrientation( SYM_ORIENT_90 ); break;
640  case 2: m_symbol->SetOrientation( SYM_ORIENT_270 ); break;
641  case 3: m_symbol->SetOrientation( SYM_ORIENT_180 ); break;
642  }
643 
644  switch( m_mirrorCtrl->GetSelection() )
645  {
646  case 0: break;
647  case 1: m_symbol->SetOrientation( SYM_MIRROR_X ); break;
648  case 2: m_symbol->SetOrientation( SYM_MIRROR_Y ); break;
649  }
650 
651  if( m_part )
652  {
653  m_part->SetShowPinNames( m_ShowPinNameButt->GetValue() );
654  m_part->SetShowPinNumbers( m_ShowPinNumButt->GetValue() );
655  }
656 
657  // Restore m_Flag modified by SetUnit() and other change settings
658  m_symbol->ClearFlags();
659  m_symbol->SetFlags( flags );
660 
661  // change all field positions from relative to absolute
662  for( unsigned i = 0; i < m_fields->size(); ++i )
663  m_fields->at( i ).Offset( m_symbol->GetPosition() );
664 
666 
667  if( entry && entry->IsPower() )
668  m_fields->at( VALUE_FIELD ).SetText( m_symbol->GetLibId().GetLibItemName() );
669 
670  // Push all fields to the symbol -except- for those which are TEMPLATE_FIELDNAMES
671  // with empty values.
672  SCH_FIELDS& fields = m_symbol->GetFields();
673 
674  fields.clear();
675 
676  for( size_t i = 0; i < m_fields->size(); ++i )
677  {
678  SCH_FIELD& field = m_fields->at( i );
679  bool emptyTemplateField = false;
680 
681  if( i >= MANDATORY_FIELDS )
682  {
683  for( const TEMPLATE_FIELDNAME& fieldname :
685  {
686  if( field.GetName() == fieldname.m_Name && field.GetText().IsEmpty() )
687  {
688  emptyTemplateField = true;
689  break;
690  }
691  }
692  }
693 
694  if( !emptyTemplateField )
695  fields.push_back( field );
696  }
697 
698  // Reference has a specific initialization, depending on the current active sheet
699  // because for a given symbol, in a complex hierarchy, there are more than one
700  // reference.
701  m_symbol->SetRef( &GetParent()->GetCurrentSheet(), m_fields->at( REFERENCE_FIELD ).GetText() );
702 
703  // Similar for Value and Footprint, except that the GUI behaviour is that they are kept
704  // in sync between multiple instances.
705  m_symbol->SetValue( m_fields->at( VALUE_FIELD ).GetText() );
706  m_symbol->SetFootprint( m_fields->at( FOOTPRINT_FIELD ).GetText() );
707 
708  m_symbol->SetIncludeInBom( !m_cbExcludeFromBom->IsChecked() );
710 
711  // The value, footprint and datasheet fields and exclude from bill of materials setting
712  // should be kept in sync in multi-unit parts.
713  if( m_symbol->GetUnitCount() > 1 && m_symbol->IsAnnotated( &GetParent()->GetCurrentSheet() ) )
714  {
715  wxString ref = m_symbol->GetRef( &GetParent()->GetCurrentSheet() );
716  int unit = m_symbol->GetUnit();
717  LIB_ID libId = m_symbol->GetLibId();
718 
719  for( SCH_SHEET_PATH& sheet : GetParent()->Schematic().GetSheets() )
720  {
721  SCH_SCREEN* screen = sheet.LastScreen();
722  std::vector<SCH_SYMBOL*> otherUnits;
723  constexpr bool appendUndo = true;
724 
725  CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
726 
727  for( SCH_SYMBOL* otherUnit : otherUnits )
728  {
729  GetParent()->SaveCopyInUndoList( screen, otherUnit, UNDO_REDO::CHANGED,
730  appendUndo );
731  otherUnit->SetValue( m_fields->at( VALUE_FIELD ).GetText() );
732  otherUnit->SetFootprint( m_fields->at( FOOTPRINT_FIELD ).GetText() );
733  otherUnit->GetField( DATASHEET_FIELD )->SetText( m_fields->at( DATASHEET_FIELD ).GetText() );
734  otherUnit->SetIncludeInBom( !m_cbExcludeFromBom->IsChecked() );
735  otherUnit->SetIncludeOnBoard( !m_cbExcludeFromBoard->IsChecked() );
736  GetParent()->UpdateItem( otherUnit, false, true );
737  }
738  }
739  }
740 
741  // Update any assignments
742  if( m_dataModel )
743  {
744  for( const SCH_PIN& model_pin : *m_dataModel )
745  {
746  // map from the edited copy back to the "real" pin in the symbol.
747  SCH_PIN* src_pin = m_symbol->GetPin( model_pin.GetLibPin() );
748  src_pin->SetAlt( model_pin.GetAlt() );
749  }
750  }
751 
752  currentScreen->Append( m_symbol );
754  GetParent()->UpdateItem( m_symbol, false, true );
755  GetParent()->OnModify();
756 
757  // This must go after OnModify() so that the connectivity graph will have been updated.
759 
760  return true;
761 }
762 
763 
765 {
766  wxGridCellEditor* editor = m_fieldsGrid->GetCellEditor( event.GetRow(), event.GetCol() );
767  wxControl* control = editor->GetControl();
768 
769  if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) )
770  {
771  event.Veto();
772  m_delayedFocusRow = event.GetRow();
773  m_delayedFocusColumn = event.GetCol();
774  m_delayedSelection = false;
775  }
776  else if( event.GetCol() == FDC_NAME )
777  {
778  wxString newName = event.GetString();
779 
780  for( int i = 0; i < m_fieldsGrid->GetNumberRows(); ++i )
781  {
782  if( i == event.GetRow() )
783  continue;
784 
785  if( newName.CmpNoCase( m_fieldsGrid->GetCellValue( i, FDC_NAME ) ) == 0 )
786  {
787  DisplayError( this, wxString::Format( _( "Field name '%s' already in use." ),
788  newName ) );
789  event.Veto();
790  m_delayedFocusRow = event.GetRow();
791  m_delayedFocusColumn = event.GetCol();
792  m_delayedSelection = false;
793  }
794  }
795  }
796 
797  editor->DecRef();
798 }
799 
800 
802 {
803  if( aEvent.GetRow() == REFERENCE_FIELD && aEvent.GetCol() == FDC_VALUE )
804  m_delayedSelection= true;
805 }
806 
807 
808 void DIALOG_SYMBOL_PROPERTIES::OnAddField( wxCommandEvent& event )
809 {
811  return;
812 
813  SCHEMATIC_SETTINGS& settings = m_symbol->Schematic()->Settings();
814  int fieldID = m_fields->size();
815  SCH_FIELD newField( wxPoint( 0, 0 ), fieldID, m_symbol,
817 
818  newField.SetTextAngle( m_fields->at( REFERENCE_FIELD ).GetTextAngle() );
819  newField.SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
820 
821  m_fields->push_back( newField );
822 
823  // notify the grid
824  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
825  m_fieldsGrid->ProcessTableMessage( msg );
826 
827  m_fieldsGrid->MakeCellVisible( (int) m_fields->size() - 1, 0 );
828  m_fieldsGrid->SetGridCursor( (int) m_fields->size() - 1, 0 );
829 
830  m_fieldsGrid->EnableCellEditControl();
831  m_fieldsGrid->ShowCellEditControl();
832 
833  OnModify();
834 }
835 
836 
837 void DIALOG_SYMBOL_PROPERTIES::OnDeleteField( wxCommandEvent& event )
838 {
839  wxArrayInt selectedRows = m_fieldsGrid->GetSelectedRows();
840 
841  if( selectedRows.empty() && m_fieldsGrid->GetGridCursorRow() >= 0 )
842  selectedRows.push_back( m_fieldsGrid->GetGridCursorRow() );
843 
844  if( selectedRows.empty() )
845  return;
846 
847  for( int row : selectedRows )
848  {
849  if( row < MANDATORY_FIELDS )
850  {
851  DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
852  MANDATORY_FIELDS ) );
853  return;
854  }
855  }
856 
857  m_fieldsGrid->CommitPendingChanges( true /* quiet mode */ );
858 
859  // Reverse sort so deleting a row doesn't change the indexes of the other rows.
860  selectedRows.Sort( []( int* first, int* second ) { return *second - *first; } );
861 
862  for( int row : selectedRows )
863  {
864  m_fields->erase( m_fields->begin() + row );
865 
866  // notify the grid
867  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
868  m_fieldsGrid->ProcessTableMessage( msg );
869 
870  if( m_fieldsGrid->GetNumberRows() > 0 )
871  {
872  m_fieldsGrid->MakeCellVisible( std::max( 0, row-1 ), m_fieldsGrid->GetGridCursorCol() );
873  m_fieldsGrid->SetGridCursor( std::max( 0, row-1 ), m_fieldsGrid->GetGridCursorCol() );
874  }
875  }
876 
877  OnModify();
878 }
879 
880 
881 void DIALOG_SYMBOL_PROPERTIES::OnMoveUp( wxCommandEvent& event )
882 {
884  return;
885 
886  int i = m_fieldsGrid->GetGridCursorRow();
887 
888  if( i > MANDATORY_FIELDS )
889  {
890  SCH_FIELD tmp = m_fields->at( (unsigned) i );
891  m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
892  m_fields->insert( m_fields->begin() + i - 1, tmp );
893  m_fieldsGrid->ForceRefresh();
894 
895  m_fieldsGrid->SetGridCursor( i - 1, m_fieldsGrid->GetGridCursorCol() );
896  m_fieldsGrid->MakeCellVisible( m_fieldsGrid->GetGridCursorRow(),
897  m_fieldsGrid->GetGridCursorCol() );
898 
899  OnModify();
900  }
901  else
902  {
903  wxBell();
904  }
905 }
906 
907 
908 void DIALOG_SYMBOL_PROPERTIES::OnMoveDown( wxCommandEvent& event )
909 {
911  return;
912 
913  int i = m_fieldsGrid->GetGridCursorRow();
914 
915  if( i >= MANDATORY_FIELDS && i < m_fieldsGrid->GetNumberRows() - 1 )
916  {
917  SCH_FIELD tmp = m_fields->at( (unsigned) i );
918  m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
919  m_fields->insert( m_fields->begin() + i + 1, tmp );
920  m_fieldsGrid->ForceRefresh();
921 
922  m_fieldsGrid->SetGridCursor( i + 1, m_fieldsGrid->GetGridCursorCol() );
923  m_fieldsGrid->MakeCellVisible( m_fieldsGrid->GetGridCursorRow(),
924  m_fieldsGrid->GetGridCursorCol() );
925 
926  OnModify();
927  }
928  else
929  {
930  wxBell();
931  }
932 }
933 
934 
936 {
937  if( TransferDataFromWindow() )
939 }
940 
941 
943 {
944  if( TransferDataFromWindow() )
946 }
947 
948 
950 {
951  if( TransferDataFromWindow() )
953 }
954 
955 
957 {
958  if( TransferDataFromWindow() )
960 }
961 
962 
964 {
965  int row = aEvent.GetRow();
966 
967  if( m_pinGrid->GetCellValue( row, COL_ALT_NAME ) == m_dataModel->GetValue( row, COL_BASE_NAME ) )
968  m_dataModel->SetValue( row, COL_ALT_NAME, wxEmptyString );
969 
970  // These are just to get the cells refreshed
973 
974  OnModify();
975 }
976 
977 
979 {
980  int sortCol = aEvent.GetCol();
981  bool ascending;
982 
983  // This is bonkers, but wxWidgets doesn't tell us ascending/descending in the
984  // event, and if we ask it will give us pre-event info.
985  if( m_pinGrid->IsSortingBy( sortCol ) )
986  // same column; invert ascending
987  ascending = !m_pinGrid->IsSortOrderAscending();
988  else
989  // different column; start with ascending
990  ascending = true;
991 
992  m_dataModel->SortRows( sortCol, ascending );
993 }
994 
995 
997 {
998  wxGridUpdateLocker deferRepaintsTillLeavingScope;
999 
1000  m_width = aWidth;
1001 
1002  // Account for scroll bars
1003  int fieldsWidth = aWidth - ( m_fieldsGrid->GetSize().x - m_fieldsGrid->GetClientSize().x );
1004  int pinTblWidth = aWidth - ( m_pinGrid->GetSize().x - m_pinGrid->GetClientSize().x );
1005 
1006  m_fieldsGrid->AutoSizeColumn( 0 );
1007 
1008  int fixedColsWidth = m_fieldsGrid->GetColSize( 0 );
1009 
1010  for( int i = 2; i < m_fieldsGrid->GetNumberCols(); i++ )
1011  fixedColsWidth += m_fieldsGrid->GetColSize( i );
1012 
1013  int colSize = std::max( fieldsWidth - fixedColsWidth, -1 );
1014  colSize = ( colSize == 0 ) ? -1 : colSize; // don't hide the column!
1015 
1016  m_fieldsGrid->SetColSize( 1, colSize );
1017 
1018  // Stretch the Base Name and Alternate Assignment columns to fit.
1019  for( int i = 0; i < COL_COUNT; ++i )
1020  {
1021  if( i != COL_BASE_NAME && i != COL_ALT_NAME )
1022  pinTblWidth -= m_pinGrid->GetColSize( i );
1023  }
1024 
1025  // Why? I haven't a clue....
1026  pinTblWidth += 22;
1027 
1028  m_pinGrid->SetColSize( COL_BASE_NAME, pinTblWidth / 2 );
1029  m_pinGrid->SetColSize( COL_ALT_NAME, pinTblWidth / 2 );
1030 }
1031 
1032 
1033 void DIALOG_SYMBOL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
1034 {
1035  wxString shownColumns = m_fieldsGrid->GetShownColumns();
1036 
1037  if( shownColumns != m_shownColumns )
1038  {
1039  m_shownColumns = shownColumns;
1040 
1041  if( !m_fieldsGrid->IsCellEditControlShown() )
1042  AdjustGridColumns( m_fieldsGrid->GetRect().GetWidth() );
1043  }
1044 
1045  // Handle a delayed focus
1046  if( m_delayedFocusRow >= 0 )
1047  {
1048  m_fieldsGrid->SetFocus();
1051 
1052  m_fieldsGrid->EnableCellEditControl( true );
1053  m_fieldsGrid->ShowCellEditControl();
1054 
1055  m_delayedFocusRow = -1;
1056  m_delayedFocusColumn = -1;
1057  }
1058 
1059  // Handle a delayed selection
1060  if( m_delayedSelection )
1061  {
1062  wxGridCellEditor* cellEditor = m_fieldsGrid->GetCellEditor( REFERENCE_FIELD, FDC_VALUE );
1063 
1064  if( wxTextEntry* txt = dynamic_cast<wxTextEntry*>( cellEditor->GetControl() ) )
1066 
1067  cellEditor->DecRef(); // we're done; must release
1068 
1069  m_delayedSelection = false;
1070  }
1071 }
1072 
1073 
1074 void DIALOG_SYMBOL_PROPERTIES::OnSizeGrid( wxSizeEvent& event )
1075 {
1076  int new_size = event.GetSize().GetX();
1077 
1078  if( m_width != new_size )
1079  {
1080  AdjustGridColumns( new_size );
1081  Layout();
1082  }
1083 
1084  // Always propagate for a grid repaint (needed if the height changes, as well as width)
1085  event.Skip();
1086 }
1087 
1088 
1089 void DIALOG_SYMBOL_PROPERTIES::OnInitDlg( wxInitDialogEvent& event )
1090 {
1092 
1093  // Now all widgets have the size fixed, call FinishDialogSettings
1095 }
1096 
1097 
1098 void DIALOG_SYMBOL_PROPERTIES::OnCheckBox( wxCommandEvent& event )
1099 {
1100  OnModify();
1101 }
1102 
1103 
1104 void DIALOG_SYMBOL_PROPERTIES::OnChoice( wxCommandEvent& event )
1105 {
1106  OnModify();
1107 }
Field Reference of part, i.e. "IC21".
void OnChoice(wxCommandEvent &event) override
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
void SortRows(int aSortCol, bool ascending)
wxString GetColLabelValue(int aCol) override
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
Definition: ui_common.cpp:185
void Offset(const wxPoint &aOffset)
Definition: eda_text.h:273
wxString GetValue(int aRow, int aCol) override
LIB_PIN * GetLibPin() const
Definition: sch_pin.h:59
const UTF8 & GetLibItemName() const
Definition: lib_id.h:104
bool Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:273
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:292
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
void OnModify()
void SetUnit(int aUnit)
Change the unit number to aUnit.
Definition: sch_symbol.cpp:333
Holds all the data relating to one schematic.
Definition: schematic.h:59
const std::vector< BITMAPS > & PinShapeIcons()
Definition: pin_type.cpp:210
This file is part of the common library.
int GetUnitCount() const
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:372
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
Definition: wx_grid.cpp:136
Class DIALOG_SYMBOL_PROPERTIES_BASE.
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:167
DIALOG_SYMBOL_PROPERTIES(SCH_EDIT_FRAME *aParent, SCH_SYMBOL *aSymbol)
void SetValue(const SCH_SHEET_PATH *sheet, const wxString &aValue)
Definition: sch_symbol.cpp:596
TEMPLATES m_TemplateFieldNames
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:713
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:104
wxString GetAlt() const
Definition: sch_pin.h:64
bool ShowPinNumbers() const
Definition: lib_symbol.h:588
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition: grid_tricks.h:55
bool GetIncludeInBom() const
Definition: sch_symbol.h:662
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
void OnGridEditorShown(wxGridEvent &event) override
Schematic editor (Eeschema) main window.
bool IsPower() const
Definition: lib_symbol.cpp:444
wxString GetNumber() const
Definition: sch_pin.h:122
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)
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:258
std::vector< SCH_FIELD > SCH_FIELDS
A container for several SCH_FIELD items.
Definition: sch_symbol.h:63
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:480
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:72
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:443
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
Define a library symbol object.
Definition: lib_symbol.h:96
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
Definition: sch_symbol.cpp:647
void OnEditSpiceModel(wxCommandEvent &event) override
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
Definition: sch_symbol.cpp:549
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:205
bool IsDragging() const
Definition: eda_item.h:120
name of datasheet
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:164
void OnAddField(wxCommandEvent &event) override
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:104
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool HasConversion() const
Test if symbol has more than one body conversion type (DeMorgan).
void SetIncludeInBom(bool aIncludeInBom)
Definition: sch_symbol.h:663
virtual void SetVisible(bool aVisible)
Definition: eda_text.h:206
void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
Definition: lib_symbol.h:579
const wxArrayString & PinShapeNames()
Definition: pin_type.cpp:201
bool IsEmptyCell(int row, int col) override
static int Compare(const wxString &lhs, const wxString &rhs)
Field Value of part, i.e. "3.3K".
void OnGridCellChanging(wxGridEvent &event)
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
void OnMoveUp(wxCommandEvent &event) override
void OnPinTableColSort(wxGridEvent &aEvent)
const wxString & GetName() const
Definition: lib_pin.h:106
void OnSizeGrid(wxSizeEvent &event) override
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:424
void OnEditSymbol(wxCommandEvent &) override
SCHEMATIC & Schematic() const
const wxArrayString & PinTypeNames()
Definition: pin_type.cpp:183
Definition for symbol library class.
bool ShowPinNames() const
Definition: lib_symbol.h:580
#define _(s)
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
static wxString GetValue(const SCH_PIN &aPin, int aCol)
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:153
void OnInitDlg(wxInitDialogEvent &event) override
GRAPHIC_PINSHAPE GetShape() const
Definition: sch_pin.cpp:122
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslate=true)
Return a default symbol field name for field aFieldNdx for all components.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:157
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:190
void OnPinTableCellEdited(wxGridEvent &event) override
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
UTF8 Format() const
Definition: lib_id.cpp:116
wxString UnescapeString(const wxString &aSource)
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins()
Definition: sch_symbol.h:470
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:154
void SetConvert(int aConvert)
Definition: sch_symbol.cpp:349
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:519
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
wxString GetShownColumns()
Get a tokenized string containing the shown column indexes.
Definition: wx_grid.cpp:117
void EndQuasiModal(int retCode)
void SetIncludeOnBoard(bool aIncludeOnBoard)
Definition: sch_symbol.h:666
std::map< wxString, ALT > & GetAlternates()
Definition: lib_pin.h:132
Schematic symbol object.
Definition: sch_symbol.h:78
void OnDeleteField(wxCommandEvent &event) override
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:146
SCH_PIN_TABLE_DATA_MODEL * m_dataModel
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
Definition: sch_symbol.cpp:842
ELECTRICAL_PINTYPE GetType() const
Definition: sch_pin.cpp:113
void SetAlt(const wxString &aAlt)
Definition: sch_pin.h:65
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:483
wxString GetName(bool aUseDefaultName=true) const
Return the field name.
Definition: sch_field.cpp:678
void OnMoveDown(wxCommandEvent &event) override
void OnCheckBox(wxCommandEvent &event) override
std::vector< wxGridCellAttr * > m_nameAttrs
void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
Definition: lib_symbol.h:587
wxPoint GetPosition() const override
Definition: sch_symbol.h:644
These settings were stored in SCH_BASE_FRAME previously.
bool GetIncludeOnBoard() const
Definition: sch_symbol.h:665
Hold a name of a symbol's field, field value, and default visibility.
int GetOrientation()
Get the display symbol orientation.
static bool compare(const SCH_PIN &lhs, const SCH_PIN &rhs, int sortCol, bool ascending)
void OnExchangeSymbol(wxCommandEvent &) override
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
void OnEditLibrarySymbol(wxCommandEvent &) override
void OnCancelButtonClick(wxCommandEvent &event) override
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
FIELDS_GRID_TABLE< SCH_FIELD > * m_fields
virtual void SetTextAngle(double aAngle)
Definition: eda_text.h:188
int GetUnit() const
Definition: sch_symbol.h:195
void OnUpdateUI(wxUpdateUIEvent &event) override
static bool IsReferenceStringValid(const wxString &aReferenceString)
Test for an acceptable reference string.
Definition: sch_symbol.cpp:477
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind) override
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
void OnUpdateSymbol(wxCommandEvent &) override
int GetConvert() const
Definition: sch_symbol.h:223
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames()
Return a template field name list for read only access.
const std::vector< BITMAPS > & PinTypeIcons()
Definition: pin_type.cpp:192
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:147
void SetValue(int aRow, int aCol, const wxString &aValue) override
Field Name Module PCB, i.e. "16DIP300".