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  return true;
507 }
508 
509 
510 void DIALOG_SYMBOL_PROPERTIES::OnEditSpiceModel( wxCommandEvent& event )
511 {
512 #ifdef KICAD_SPICE
513  int diff = m_fields->size();
514 
515  DIALOG_SPICE_MODEL dialog( this, *m_symbol, m_fields );
516 
517  if( dialog.ShowModal() != wxID_OK )
518  return;
519 
520  diff = (int) m_fields->size() - diff;
521 
522  if( diff > 0 )
523  {
524  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, diff );
525  m_fieldsGrid->ProcessTableMessage( msg );
526  }
527  else if( diff < 0 )
528  {
529  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, -diff );
530  m_fieldsGrid->ProcessTableMessage( msg );
531  }
532 
533  OnModify();
534  m_fieldsGrid->ForceRefresh();
535 #endif /* KICAD_SPICE */
536 }
537 
538 
540 {
541  // Running the Footprint Browser gums up the works and causes the automatic cancel
542  // stuff to no longer work. So we do it here ourselves.
543  EndQuasiModal( wxID_CANCEL );
544 }
545 
546 
548 {
549  wxString msg;
550  LIB_ID id;
551 
552  if( !m_fieldsGrid->CommitPendingChanges() || !m_fieldsGrid->Validate() )
553  return false;
554 
556  {
557  DisplayErrorMessage( this, _( "References must start with a letter." ) );
558 
561  m_delayedSelection = false;
562 
563  return false;
564  }
565 
566  // Check for missing field names.
567  for( size_t i = MANDATORY_FIELDS; i < m_fields->size(); ++i )
568  {
569  SCH_FIELD& field = m_fields->at( i );
570  wxString fieldName = field.GetName( false );
571 
572  if( fieldName.IsEmpty() )
573  {
574  DisplayErrorMessage( this, _( "Fields must have a name." ) );
575 
577  m_delayedFocusRow = i;
578  m_delayedSelection = false;
579 
580  return false;
581  }
582  }
583 
584  return true;
585 }
586 
587 
589 {
590  if( !wxDialog::TransferDataFromWindow() ) // Calls our Validate() method.
591  return false;
592 
594  return false;
595 
597  return false;
598 
599  SCH_SCREEN* currentScreen = GetParent()->GetScreen();
600  SCHEMATIC& schematic = GetParent()->Schematic();
601 
602  wxCHECK( currentScreen, false );
603 
604  // This needs to be done before the LIB_ID is changed to prevent stale library symbols in
605  // the schematic file.
606  currentScreen->Remove( m_symbol );
607 
608  wxString msg;
609 
610  // save old cmp in undo list if not already in edit, or moving ...
611  if( m_symbol->GetEditFlags() == 0 )
612  GetParent()->SaveCopyInUndoList( currentScreen, m_symbol, UNDO_REDO::CHANGED, false );
613 
614  // Save current flags which could be modified by next change settings
615  EDA_ITEM_FLAGS flags = m_symbol->GetFlags();
616 
617  // For symbols with multiple shapes (De Morgan representation) Set the selected shape:
618  if( m_cbAlternateSymbol->IsEnabled() && m_cbAlternateSymbol->GetValue() )
619  m_symbol->SetConvert( LIB_ITEM::LIB_CONVERT::DEMORGAN );
620  else
621  m_symbol->SetConvert( LIB_ITEM::LIB_CONVERT::BASE );
622 
623  //Set the part selection in multiple part per package
624  int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1;
625  m_symbol->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection );
626  m_symbol->SetUnit( unit_selection );
627 
628  switch( m_orientationCtrl->GetSelection() )
629  {
630  case 0: m_symbol->SetOrientation( SYM_ORIENT_0 ); break;
631  case 1: m_symbol->SetOrientation( SYM_ORIENT_90 ); break;
632  case 2: m_symbol->SetOrientation( SYM_ORIENT_270 ); break;
633  case 3: m_symbol->SetOrientation( SYM_ORIENT_180 ); break;
634  }
635 
636  switch( m_mirrorCtrl->GetSelection() )
637  {
638  case 0: break;
639  case 1: m_symbol->SetOrientation( SYM_MIRROR_X ); break;
640  case 2: m_symbol->SetOrientation( SYM_MIRROR_Y ); break;
641  }
642 
643  if( m_part )
644  {
645  m_part->SetShowPinNames( m_ShowPinNameButt->GetValue() );
646  m_part->SetShowPinNumbers( m_ShowPinNumButt->GetValue() );
647  }
648 
649  // Restore m_Flag modified by SetUnit() and other change settings
650  m_symbol->ClearFlags();
651  m_symbol->SetFlags( flags );
652 
653  // change all field positions from relative to absolute
654  for( unsigned i = 0; i < m_fields->size(); ++i )
655  m_fields->at( i ).Offset( m_symbol->GetPosition() );
656 
658 
659  if( entry && entry->IsPower() )
660  m_fields->at( VALUE_FIELD ).SetText( m_symbol->GetLibId().GetLibItemName() );
661 
662  // Push all fields to the symbol -except- for those which are TEMPLATE_FIELDNAMES
663  // with empty values.
664  SCH_FIELDS& fields = m_symbol->GetFields();
665 
666  fields.clear();
667 
668  for( size_t i = 0; i < m_fields->size(); ++i )
669  {
670  SCH_FIELD& field = m_fields->at( i );
671  bool emptyTemplateField = false;
672 
673  if( i >= MANDATORY_FIELDS )
674  {
675  for( const TEMPLATE_FIELDNAME& fieldname :
677  {
678  if( field.GetName() == fieldname.m_Name && field.GetText().IsEmpty() )
679  {
680  emptyTemplateField = true;
681  break;
682  }
683  }
684  }
685 
686  if( !emptyTemplateField )
687  fields.push_back( field );
688  }
689 
690  // Reference has a specific initialization, depending on the current active sheet
691  // because for a given symbol, in a complex hierarchy, there are more than one
692  // reference.
693  m_symbol->SetRef( &GetParent()->GetCurrentSheet(), m_fields->at( REFERENCE_FIELD ).GetText() );
694 
695  // Similar for Value and Footprint, except that the GUI behaviour is that they are kept
696  // in sync between multiple instances.
697  m_symbol->SetValue( m_fields->at( VALUE_FIELD ).GetText() );
698  m_symbol->SetFootprint( m_fields->at( FOOTPRINT_FIELD ).GetText() );
699 
700  m_symbol->SetIncludeInBom( !m_cbExcludeFromBom->IsChecked() );
702 
703  // Update any assignments
704  if( m_dataModel )
705  {
706  for( const SCH_PIN& model_pin : *m_dataModel )
707  {
708  // map from the edited copy back to the "real" pin in the symbol.
709  SCH_PIN* src_pin = m_symbol->GetPin( model_pin.GetLibPin() );
710  src_pin->SetAlt( model_pin.GetAlt() );
711  }
712  }
713 
714  // Keep fields other than the reference, include/exclude flags, and alternate pin assignements
715  // in sync in multi-unit parts.
716  if( m_symbol->GetUnitCount() > 1 && m_symbol->IsAnnotated( &GetParent()->GetCurrentSheet() ) )
717  {
718  wxString ref = m_symbol->GetRef( &GetParent()->GetCurrentSheet() );
719  int unit = m_symbol->GetUnit();
720  LIB_ID libId = m_symbol->GetLibId();
721 
722  for( SCH_SHEET_PATH& sheet : GetParent()->Schematic().GetSheets() )
723  {
724  SCH_SCREEN* screen = sheet.LastScreen();
725  std::vector<SCH_SYMBOL*> otherUnits;
726  constexpr bool appendUndo = true;
727 
728  CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
729 
730  for( SCH_SYMBOL* otherUnit : otherUnits )
731  {
732  GetParent()->SaveCopyInUndoList( screen, otherUnit, UNDO_REDO::CHANGED,
733  appendUndo );
734  otherUnit->SetValue( m_fields->at( VALUE_FIELD ).GetText() );
735  otherUnit->SetFootprint( m_fields->at( FOOTPRINT_FIELD ).GetText() );
736 
737  for( size_t ii = DATASHEET_FIELD; ii < m_fields->size(); ++ii )
738  {
739  SCH_FIELD* otherField = otherUnit->FindField( m_fields->at( ii ).GetName() );
740 
741  if( otherField )
742  {
743  otherField->SetText( m_fields->at( ii ).GetText() );
744  }
745  else
746  {
747  SCH_FIELD* newField = otherUnit->AddField( m_fields->at( ii ) );
748  const_cast<KIID&>( newField->m_Uuid ) = KIID();
749  }
750  }
751 
752  for( size_t ii = otherUnit->GetFields().size() - 1; ii > DATASHEET_FIELD; ii-- )
753  {
754  SCH_FIELD& otherField = otherUnit->GetFields().at( ii );
755 
756  if( !m_symbol->FindField( otherField.GetName() ) )
757  otherUnit->GetFields().erase( otherUnit->GetFields().begin() + ii );
758  }
759 
760  otherUnit->SetIncludeInBom( !m_cbExcludeFromBom->IsChecked() );
761  otherUnit->SetIncludeOnBoard( !m_cbExcludeFromBoard->IsChecked() );
762 
763  if( m_dataModel )
764  {
765  for( const SCH_PIN& model_pin : *m_dataModel )
766  {
767  SCH_PIN* src_pin = otherUnit->GetPin( model_pin.GetNumber() );
768 
769  if( src_pin )
770  src_pin->SetAlt( model_pin.GetAlt() );
771  }
772  }
773 
774  GetParent()->UpdateItem( otherUnit, false, true );
775  }
776  }
777  }
778 
779  currentScreen->Append( m_symbol );
781  GetParent()->UpdateItem( m_symbol, false, true );
782  GetParent()->OnModify();
783 
784  // This must go after OnModify() so that the connectivity graph will have been updated.
786 
787  return true;
788 }
789 
790 
792 {
793  wxGridCellEditor* editor = m_fieldsGrid->GetCellEditor( event.GetRow(), event.GetCol() );
794  wxControl* control = editor->GetControl();
795 
796  if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) )
797  {
798  event.Veto();
799  m_delayedFocusRow = event.GetRow();
800  m_delayedFocusColumn = event.GetCol();
801  m_delayedSelection = false;
802  }
803  else if( event.GetCol() == FDC_NAME )
804  {
805  wxString newName = event.GetString();
806 
807  for( int i = 0; i < m_fieldsGrid->GetNumberRows(); ++i )
808  {
809  if( i == event.GetRow() )
810  continue;
811 
812  if( newName.CmpNoCase( m_fieldsGrid->GetCellValue( i, FDC_NAME ) ) == 0 )
813  {
814  DisplayError( this, wxString::Format( _( "Field name '%s' already in use." ),
815  newName ) );
816  event.Veto();
817  m_delayedFocusRow = event.GetRow();
818  m_delayedFocusColumn = event.GetCol();
819  m_delayedSelection = false;
820  }
821  }
822  }
823 
824  editor->DecRef();
825 }
826 
827 
829 {
830  if( aEvent.GetRow() == REFERENCE_FIELD && aEvent.GetCol() == FDC_VALUE )
831  m_delayedSelection= true;
832 
834  wxSizeEvent *evt = new wxSizeEvent();
835  evt->SetSize( wxSize( m_width, -1 ) );
836 
837  wxQueueEvent( m_fieldsGrid, evt );
838 
839 }
840 
841 
842 void DIALOG_SYMBOL_PROPERTIES::OnAddField( wxCommandEvent& event )
843 {
845  return;
846 
847  SCHEMATIC_SETTINGS& settings = m_symbol->Schematic()->Settings();
848  int fieldID = m_fields->size();
849  SCH_FIELD newField( wxPoint( 0, 0 ), fieldID, m_symbol,
851 
852  newField.SetTextAngle( m_fields->at( REFERENCE_FIELD ).GetTextAngle() );
853  newField.SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
854 
855  m_fields->push_back( newField );
856 
857  // notify the grid
858  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
859  m_fieldsGrid->ProcessTableMessage( msg );
860 
861  m_fieldsGrid->MakeCellVisible( (int) m_fields->size() - 1, 0 );
862  m_fieldsGrid->SetGridCursor( (int) m_fields->size() - 1, 0 );
863 
864  m_fieldsGrid->EnableCellEditControl();
865  m_fieldsGrid->ShowCellEditControl();
866 
867  OnModify();
868 }
869 
870 
871 void DIALOG_SYMBOL_PROPERTIES::OnDeleteField( wxCommandEvent& event )
872 {
873  wxArrayInt selectedRows = m_fieldsGrid->GetSelectedRows();
874 
875  if( selectedRows.empty() && m_fieldsGrid->GetGridCursorRow() >= 0 )
876  selectedRows.push_back( m_fieldsGrid->GetGridCursorRow() );
877 
878  if( selectedRows.empty() )
879  return;
880 
881  for( int row : selectedRows )
882  {
883  if( row < MANDATORY_FIELDS )
884  {
885  DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
886  MANDATORY_FIELDS ) );
887  return;
888  }
889  }
890 
891  m_fieldsGrid->CommitPendingChanges( true /* quiet mode */ );
892 
893  // Reverse sort so deleting a row doesn't change the indexes of the other rows.
894  selectedRows.Sort( []( int* first, int* second ) { return *second - *first; } );
895 
896  for( int row : selectedRows )
897  {
898  m_fields->erase( m_fields->begin() + row );
899 
900  // notify the grid
901  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
902  m_fieldsGrid->ProcessTableMessage( msg );
903 
904  if( m_fieldsGrid->GetNumberRows() > 0 )
905  {
906  m_fieldsGrid->MakeCellVisible( std::max( 0, row-1 ), m_fieldsGrid->GetGridCursorCol() );
907  m_fieldsGrid->SetGridCursor( std::max( 0, row-1 ), m_fieldsGrid->GetGridCursorCol() );
908  }
909  }
910 
911  OnModify();
912 }
913 
914 
915 void DIALOG_SYMBOL_PROPERTIES::OnMoveUp( wxCommandEvent& event )
916 {
918  return;
919 
920  int i = m_fieldsGrid->GetGridCursorRow();
921 
922  if( i > MANDATORY_FIELDS )
923  {
924  SCH_FIELD tmp = m_fields->at( (unsigned) i );
925  m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
926  m_fields->insert( m_fields->begin() + i - 1, tmp );
927  m_fieldsGrid->ForceRefresh();
928 
929  m_fieldsGrid->SetGridCursor( i - 1, m_fieldsGrid->GetGridCursorCol() );
930  m_fieldsGrid->MakeCellVisible( m_fieldsGrid->GetGridCursorRow(),
931  m_fieldsGrid->GetGridCursorCol() );
932 
933  OnModify();
934  }
935  else
936  {
937  wxBell();
938  }
939 }
940 
941 
942 void DIALOG_SYMBOL_PROPERTIES::OnMoveDown( wxCommandEvent& event )
943 {
945  return;
946 
947  int i = m_fieldsGrid->GetGridCursorRow();
948 
949  if( i >= MANDATORY_FIELDS && i < m_fieldsGrid->GetNumberRows() - 1 )
950  {
951  SCH_FIELD tmp = m_fields->at( (unsigned) i );
952  m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
953  m_fields->insert( m_fields->begin() + i + 1, tmp );
954  m_fieldsGrid->ForceRefresh();
955 
956  m_fieldsGrid->SetGridCursor( i + 1, m_fieldsGrid->GetGridCursorCol() );
957  m_fieldsGrid->MakeCellVisible( m_fieldsGrid->GetGridCursorRow(),
958  m_fieldsGrid->GetGridCursorCol() );
959 
960  OnModify();
961  }
962  else
963  {
964  wxBell();
965  }
966 }
967 
968 
970 {
971  if( TransferDataFromWindow() )
973 }
974 
975 
977 {
978  if( TransferDataFromWindow() )
980 }
981 
982 
984 {
985  if( TransferDataFromWindow() )
987 }
988 
989 
991 {
992  if( TransferDataFromWindow() )
994 }
995 
996 
998 {
999  int row = aEvent.GetRow();
1000 
1001  if( m_pinGrid->GetCellValue( row, COL_ALT_NAME ) == m_dataModel->GetValue( row, COL_BASE_NAME ) )
1002  m_dataModel->SetValue( row, COL_ALT_NAME, wxEmptyString );
1003 
1004  // These are just to get the cells refreshed
1007 
1008  OnModify();
1009 }
1010 
1011 
1013 {
1014  int sortCol = aEvent.GetCol();
1015  bool ascending;
1016 
1017  // This is bonkers, but wxWidgets doesn't tell us ascending/descending in the
1018  // event, and if we ask it will give us pre-event info.
1019  if( m_pinGrid->IsSortingBy( sortCol ) )
1020  // same column; invert ascending
1021  ascending = !m_pinGrid->IsSortOrderAscending();
1022  else
1023  // different column; start with ascending
1024  ascending = true;
1025 
1026  m_dataModel->SortRows( sortCol, ascending );
1027 }
1028 
1029 
1031 {
1032  wxGridUpdateLocker deferRepaintsTillLeavingScope;
1033 
1034  m_width = aWidth;
1035 
1036  // Account for scroll bars
1037  int fieldsWidth = aWidth - ( m_fieldsGrid->GetSize().x - m_fieldsGrid->GetClientSize().x );
1038  int pinTblWidth = aWidth - ( m_pinGrid->GetSize().x - m_pinGrid->GetClientSize().x );
1039 
1040  m_fieldsGrid->AutoSizeColumn( 0 );
1041 
1042  int fixedColsWidth = m_fieldsGrid->GetColSize( 0 );
1043 
1044  for( int i = 2; i < m_fieldsGrid->GetNumberCols(); i++ )
1045  fixedColsWidth += m_fieldsGrid->GetColSize( i );
1046 
1047  int colSize = std::max( fieldsWidth - fixedColsWidth, -1 );
1048  colSize = ( colSize == 0 ) ? -1 : colSize; // don't hide the column!
1049 
1050  m_fieldsGrid->SetColSize( 1, colSize );
1051 
1052  // Stretch the Base Name and Alternate Assignment columns to fit.
1053  for( int i = 0; i < COL_COUNT; ++i )
1054  {
1055  if( i != COL_BASE_NAME && i != COL_ALT_NAME )
1056  pinTblWidth -= m_pinGrid->GetColSize( i );
1057  }
1058 
1059  // Why? I haven't a clue....
1060  pinTblWidth += 22;
1061 
1062  m_pinGrid->SetColSize( COL_BASE_NAME, pinTblWidth / 2 );
1063  m_pinGrid->SetColSize( COL_ALT_NAME, pinTblWidth / 2 );
1064 }
1065 
1066 
1067 void DIALOG_SYMBOL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
1068 {
1069  wxString shownColumns = m_fieldsGrid->GetShownColumns();
1070 
1071  if( shownColumns != m_shownColumns )
1072  {
1073  m_shownColumns = shownColumns;
1074 
1075  if( !m_fieldsGrid->IsCellEditControlShown() )
1076  AdjustGridColumns( m_fieldsGrid->GetRect().GetWidth() );
1077  }
1078 
1079  // Handle a delayed focus
1080  if( m_delayedFocusRow >= 0 )
1081  {
1082  m_fieldsGrid->SetFocus();
1085 
1086  m_fieldsGrid->EnableCellEditControl( true );
1087  m_fieldsGrid->ShowCellEditControl();
1088 
1089  m_delayedFocusRow = -1;
1090  m_delayedFocusColumn = -1;
1091  }
1092 
1093  // Handle a delayed selection
1094  if( m_delayedSelection )
1095  {
1096  wxGridCellEditor* cellEditor = m_fieldsGrid->GetCellEditor( REFERENCE_FIELD, FDC_VALUE );
1097 
1098  if( wxTextEntry* txt = dynamic_cast<wxTextEntry*>( cellEditor->GetControl() ) )
1100 
1101  cellEditor->DecRef(); // we're done; must release
1102 
1103  m_delayedSelection = false;
1104  }
1105 }
1106 
1107 
1108 void DIALOG_SYMBOL_PROPERTIES::OnSizeGrid( wxSizeEvent& event )
1109 {
1110  int new_size = event.GetSize().GetX();
1111 
1112  if( m_width != new_size )
1113  {
1114  AdjustGridColumns( new_size );
1115  Layout();
1116  }
1117 
1118  // Always propagate for a grid repaint (needed if the height changes, as well as width)
1119  event.Skip();
1120 }
1121 
1122 
1123 void DIALOG_SYMBOL_PROPERTIES::OnInitDlg( wxInitDialogEvent& event )
1124 {
1126 
1127  // Now all widgets have the size fixed, call FinishDialogSettings
1129 }
1130 
1131 
1132 void DIALOG_SYMBOL_PROPERTIES::OnCheckBox( wxCommandEvent& event )
1133 {
1134  OnModify();
1135 }
1136 
1137 
1138 void DIALOG_SYMBOL_PROPERTIES::OnChoice( wxCommandEvent& event )
1139 {
1140  OnModify();
1141 }
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:354
Holds all the data relating to one schematic.
Definition: schematic.h:59
const std::vector< BITMAPS > & PinShapeIcons()
Definition: pin_type.cpp:213
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:393
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:172
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:624
TEMPLATES m_TemplateFieldNames
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:741
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:663
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:459
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:495
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:93
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:464
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:675
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:570
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:165
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:139
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:664
virtual void SetVisible(bool aVisible)
Definition: eda_text.h:206
Definition: kiid.h:44
void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
Definition: lib_symbol.h:579
const wxArrayString & PinShapeNames()
Definition: pin_type.cpp:204
bool IsEmptyCell(int row, int col) override
static int Compare(const wxString &lhs, const wxString &rhs)
Field Value of part, i.e. "3.3K".
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:124
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:425
void OnEditSymbol(wxCommandEvent &) override
SCHEMATIC & Schematic() const
const wxArrayString & PinTypeNames()
Definition: pin_type.cpp:186
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:226
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
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true)
Search for a SCH_FIELD with aFieldName.
Definition: sch_symbol.cpp:773
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:471
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:154
void SetConvert(int aConvert)
Definition: sch_symbol.cpp:370
const KIID m_Uuid
Definition: eda_item.h:474
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:540
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:153
void EndQuasiModal(int retCode)
void SetIncludeOnBoard(bool aIncludeOnBoard)
Definition: sch_symbol.h:667
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:870
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:504
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:645
These settings were stored in SCH_BASE_FRAME previously.
bool GetIncludeOnBoard() const
Definition: sch_symbol.h:666
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:196
void OnUpdateUI(wxUpdateUIEvent &event) override
static bool IsReferenceStringValid(const wxString &aReferenceString)
Test for an acceptable reference string.
Definition: sch_symbol.cpp:498
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:224
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:195
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:148
void SetValue(int aRow, int aCol, const wxString &aValue) override
Field Name Module PCB, i.e. "16DIP300".