KiCad PCB EDA Suite
dialog_change_symbols.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) 2020-2021 CERN
5  * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * @author Wayne Stambaugh <stambaughw@gmail.com>
8  *
9  * This program is free software: you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License as published by the
11  * Free Software Foundation, either version 3 of the License, or (at your
12  * option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include <algorithm>
24 
25 #include <bitmaps.h>
26 #include <string_utils.h> // WildCompareString
27 #include <kiway.h>
28 #include <lib_id.h>
29 #include <refdes_utils.h>
30 #include <core/kicad_algo.h>
31 #include <dialog_change_symbols.h>
32 #include <sch_symbol.h>
33 #include <sch_edit_frame.h>
34 #include <sch_screen.h>
35 #include <sch_sheet_path.h>
36 #include <schematic.h>
37 #include <template_fieldnames.h>
38 #include <wx_html_report_panel.h>
39 
40 bool g_selectRefDes = false;
41 bool g_selectValue = false;
42  // { change, update }
43 bool g_removeExtraFields[2] = { false, false };
44 bool g_resetEmptyFields[2] = { false, false };
45 bool g_resetFieldText[2] = { true, true };
46 bool g_resetFieldVisibilities[2] = { true, false };
47 bool g_resetFieldEffects[2] = { true, false };
48 bool g_resetFieldPositions[2] = { true, false };
49 bool g_resetAttributes[2] = { true, false };
50 
51 
53  MODE aMode ) :
54  DIALOG_CHANGE_SYMBOLS_BASE( aParent ),
55  m_symbol( aSymbol),
56  m_mode( aMode )
57 {
58  wxASSERT( aParent );
59 
60  if( m_mode == MODE::UPDATE )
61  {
62  m_newIdSizer->Show( false );
63  }
64  else
65  {
66  m_matchAll->SetLabel( _( "Change all symbols in schematic" ) );
67  SetTitle( _( "Change Symbols" ) );
68  m_matchSizer->FindItem( m_matchAll )->Show( false );
69  }
70 
71  if( m_symbol )
72  {
73  SCH_SHEET_PATH* currentSheet = &aParent->Schematic().CurrentSheet();
74 
75  if( m_mode == MODE::CHANGE )
76  m_matchBySelection->SetLabel( _( "Change selected symbol(s)" ) );
77 
78  m_newId->ChangeValue( UnescapeString( m_symbol->GetLibId().Format() ) );
79  m_specifiedReference->ChangeValue( m_symbol->GetRef( currentSheet ) );
80  m_specifiedValue->ChangeValue( m_symbol->GetValue( currentSheet, false ) );
81  m_specifiedId->ChangeValue( UnescapeString( m_symbol->GetLibId().Format() ) );
82  }
83  else
84  {
85  m_matchSizer->FindItem( m_matchBySelection )->Show( false );
86  }
87 
90 
91  if( m_mode == MODE::CHANGE )
92  {
93  m_matchByReference->SetLabel( _( "Change symbols matching reference designator:" ) );
94  m_matchByValue->SetLabel( _( "Change symbols matching value:" ) );
95  m_matchById->SetLabel( _( "Change symbols matching library identifier:" ) );
96  }
97 
98  m_matchSizer->SetEmptyCellSize( wxSize( 0, 0 ) );
99  m_matchSizer->Layout();
100 
101  for( int i = 0; i < MANDATORY_FIELDS; ++i )
102  {
104 
105  if( i == REFERENCE_FIELD )
106  m_fieldsBox->Check( i, g_selectRefDes );
107  else if( i == VALUE_FIELD )
108  m_fieldsBox->Check( i, g_selectValue );
109  else
110  m_fieldsBox->Check( i, true );
111  }
112 
113  m_messagePanel->SetLazyUpdate( true );
114  m_messagePanel->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
115 
116  if( aSymbol && aSymbol->IsSelected() )
117  {
118  m_matchBySelection->SetValue( true );
119  }
120  else
121  {
122  if( aMode == MODE::UPDATE )
123  m_matchAll->SetValue( true );
124  else
125  m_matchByReference->SetValue( true );
126  }
127 
129 
130  if( m_mode == MODE::CHANGE )
131  {
132  m_updateFieldsSizer->GetStaticBox()->SetLabel( _( "Update Fields" ) );
133  m_removeExtraBox->SetLabel( _( "Remove fields if not in new symbol" ) );
134  m_resetEmptyFields->SetLabel( _( "Reset fields if empty in new symbol" ) );
135  m_resetFieldText->SetLabel( _( "Update field text" ) );
136  m_resetFieldVisibilities->SetLabel( _( "Update field visibilities" ) );
137  m_resetFieldEffects->SetLabel( _( "Update field sizes and styles" ) );
138  m_resetFieldPositions->SetLabel( _( "Update field positions" ) );
139  m_resetAttributes->SetLabel( _( "Update symbol attributes" ) );
140  }
141 
142  m_removeExtraBox->SetValue( g_removeExtraFields[ (int) m_mode ] );
143  m_resetEmptyFields->SetValue( g_resetEmptyFields[ (int) m_mode ] );
144  m_resetFieldText->SetValue( g_resetFieldText[ (int) m_mode ] );
146  m_resetFieldEffects->SetValue( g_resetFieldEffects[ (int) m_mode ] );
147  m_resetFieldPositions->SetValue( g_resetFieldPositions[ (int) m_mode ] );
148  m_resetAttributes->SetValue( g_resetAttributes[ (int) m_mode ] );
149 
150  // DIALOG_SHIM needs a unique hash_key because classname is not sufficient
151  // because the update and change versions of this dialog have different controls.
152  m_hash_key = TO_UTF8( GetTitle() );
153 
154  // Ensure m_closeButton (with id = wxID_CANCEL) has the right label
155  // (to fix automatic renaming of button label )
156  m_sdbSizerCancel->SetLabel( _( "Close" ) );
157 
158  if( m_mode == MODE::CHANGE )
159  m_sdbSizerOK->SetLabel( _( "Change" ) );
160  else
161  m_sdbSizerOK->SetLabel( _( "Update" ) );
162 
163  m_sdbSizerOK->SetDefault();
164 
165  // Now all widgets have the size fixed, call FinishDialogSettings
167 }
168 
169 
170 void DIALOG_CHANGE_SYMBOLS::onMatchByAll( wxCommandEvent& aEvent )
171 {
173 }
174 
175 
176 void DIALOG_CHANGE_SYMBOLS::onMatchBySelected( wxCommandEvent& aEvent )
177 {
179 }
180 
181 
182 void DIALOG_CHANGE_SYMBOLS::onMatchByReference( wxCommandEvent& aEvent )
183 {
185  m_specifiedReference->SetFocus();
186 }
187 
188 
189 void DIALOG_CHANGE_SYMBOLS::onMatchByValue( wxCommandEvent& aEvent )
190 {
192  m_specifiedValue->SetFocus();
193 }
194 
195 
196 void DIALOG_CHANGE_SYMBOLS::onMatchById( wxCommandEvent& aEvent )
197 {
199  m_specifiedId->SetFocus();
200 }
201 
202 
204 {
206 }
207 
208 
209 void DIALOG_CHANGE_SYMBOLS::onMatchIDKillFocus( wxFocusEvent& event )
210 {
212 }
213 
214 
216 {
218 }
219 
220 
222 {
224  g_selectValue = m_fieldsBox->IsChecked( VALUE_FIELD );
225 
226  g_removeExtraFields[ (int) m_mode ] = m_removeExtraBox->GetValue();
227  g_resetEmptyFields[ (int) m_mode ] = m_resetEmptyFields->GetValue();
228  g_resetFieldText[ (int) m_mode ] = m_resetFieldText->GetValue();
230  g_resetFieldEffects[ (int) m_mode ] = m_resetFieldEffects->GetValue();
231  g_resetFieldPositions[ (int) m_mode ] = m_resetFieldPositions->GetValue();
232  g_resetAttributes[ (int) m_mode ] = m_resetAttributes->GetValue();
233 }
234 
235 
236 wxString getLibIdValue( const wxTextCtrl* aCtrl )
237 {
238  wxString rawValue = aCtrl->GetValue();
239  wxString itemName;
240  wxString libName = rawValue.BeforeFirst( ':', &itemName );
241 
242  return EscapeString( libName, CTX_LIBID ) + ':' + EscapeString( itemName, CTX_LIBID );
243 }
244 
245 
247 {
248  wxString newName = getLibIdValue( m_specifiedId );
249 
250  KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH_VIEWER_MODAL, true );
251 
252  if( frame->ShowModal( &newName, this ) )
253  {
254  m_specifiedId->SetValue( UnescapeString( newName ) );
256  }
257 
258  frame->Destroy();
259 }
260 
261 
263 {
264  wxString newName = getLibIdValue( m_newId );
265 
266  KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH_VIEWER_MODAL, true );
267 
268  if( frame->ShowModal( &newName, this ) )
269  {
270  m_newId->SetValue( UnescapeString( newName ) );
272  }
273 
274  frame->Destroy();
275 }
276 
277 
279 {
280  SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
281 
282  wxCHECK( frame, /* void */ );
283 
284  SCH_SHEET_LIST hierarchy = frame->Schematic().GetSheets();
285 
286  // Load non-mandatory fields from all matching symbols and their library symbols
287  std::vector<SCH_FIELD*> fields;
288  std::vector<LIB_FIELD*> libFields;
289  std::set<wxString> fieldNames;
290 
291  for( SCH_SHEET_PATH& instance : hierarchy )
292  {
293  SCH_SCREEN* screen = instance.LastScreen();
294 
295  wxCHECK2( screen, continue );
296 
297  for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
298  {
299  SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
300 
301  wxCHECK2( symbol, continue );
302 
303  if( !isMatch( symbol, &instance ) )
304  continue;
305 
306  fields.clear();
307  symbol->GetFields( fields, false );
308 
309  for( unsigned i = MANDATORY_FIELDS; i < fields.size(); ++i )
310  fieldNames.insert( fields[i]->GetName() );
311 
312  if( m_mode == MODE::UPDATE && symbol->GetLibId().IsValid() )
313  {
314  LIB_SYMBOL* libSymbol = frame->GetLibSymbol( symbol->GetLibId() );
315 
316  if( libSymbol )
317  {
318  std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->Flatten();
319 
320  flattenedSymbol->GetFields( libFields );
321 
322  for( unsigned i = MANDATORY_FIELDS; i < libFields.size(); ++i )
323  fieldNames.insert( libFields[i]->GetName() );
324 
325  libFields.clear(); // flattenedSymbol is about to go out of scope...
326  }
327  }
328  }
329  }
330 
331  // Load non-mandatory fields from the change-to library symbol
332  if( m_mode == MODE::CHANGE )
333  {
334  LIB_ID newId;
335 
336  newId.Parse( getLibIdValue( m_newId ) );
337 
338  if( newId.IsValid() )
339  {
340  LIB_SYMBOL* libSymbol = frame->GetLibSymbol( newId );
341 
342  if( libSymbol )
343  {
344  std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->Flatten();
345 
346  flattenedSymbol->GetFields( libFields );
347 
348  for( unsigned i = MANDATORY_FIELDS; i < libFields.size(); ++i )
349  fieldNames.insert( libFields[i]->GetName() );
350 
351  libFields.clear(); // flattenedSymbol is about to go out of scope...
352  }
353  }
354  }
355 
356  // Update the listbox widget
357  for( unsigned i = m_fieldsBox->GetCount() - 1; i >= MANDATORY_FIELDS; --i )
358  m_fieldsBox->Delete( i );
359 
360  for( const wxString& fieldName : fieldNames )
361  m_fieldsBox->Append( fieldName );
362 
363  for( unsigned i = MANDATORY_FIELDS; i < m_fieldsBox->GetCount(); ++i )
364  m_fieldsBox->Check( i, true );
365 }
366 
367 
369 {
370  for( unsigned i = 0; i < m_fieldsBox->GetCount(); ++i )
371  m_fieldsBox->Check( i, aCheck );
372 }
373 
374 
375 void DIALOG_CHANGE_SYMBOLS::onOkButtonClicked( wxCommandEvent& aEvent )
376 {
377  wxBusyCursor dummy;
378  SCH_EDIT_FRAME* parent = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
379 
380  wxCHECK( parent, /* void */ );
381 
383  m_messagePanel->Flush( false );
384 
385  // Create the set of fields to be updated
386  m_updateFields.clear();
387 
388  for( unsigned i = 0; i < m_fieldsBox->GetCount(); ++i )
389  {
390  if( m_fieldsBox->IsChecked( i ) )
391  m_updateFields.insert( m_fieldsBox->GetString( i ) );
392  }
393 
394  if( processMatchingSymbols() )
395  {
396  parent->TestDanglingEnds(); // This will also redraw the changed symbols.
397  parent->OnModify();
398  }
399 
400  m_messagePanel->Flush( false );
401 }
402 
403 
405 {
406  LIB_ID id;
407 
408  wxCHECK( aSymbol, false );
409 
410  SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
411 
412  wxCHECK( frame, false );
413 
414  if( m_matchAll->GetValue() )
415  {
416  return true;
417  }
418  else if( m_matchBySelection->GetValue() )
419  {
420  return aSymbol == m_symbol || aSymbol->IsSelected();
421  }
422  else if( m_matchByReference->GetValue() )
423  {
424  return WildCompareString( m_specifiedReference->GetValue(),
425  aSymbol->GetRef( aInstance, false ), false );
426  }
427  else if( m_matchByValue->GetValue() )
428  {
429  return WildCompareString( m_specifiedValue->GetValue(),
430  aSymbol->GetValue( aInstance, false ), false );
431  }
432  else if( m_matchById )
433  {
434  id.Parse( getLibIdValue( m_specifiedId ) );
435  return aSymbol->GetLibId() == id;
436  }
437 
438  return false;
439 }
440 
441 
443 {
444  SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
445 
446  wxCHECK( frame, false );
447 
448  LIB_ID newId;
449  bool appendToUndo = false;
450  bool changed = false;
451  SCH_SHEET_LIST hierarchy = frame->Schematic().GetSheets();
452 
453  if( m_mode == MODE::CHANGE )
454  {
455  newId.Parse( getLibIdValue( m_newId ) );
456 
457  if( !newId.IsValid() )
458  return false;
459  }
460 
461  for( SCH_SHEET_PATH& instance : hierarchy )
462  {
463  SCH_SCREEN* screen = instance.LastScreen();
464 
465  wxCHECK2( screen, continue );
466 
467  std::vector<SCH_SYMBOL*> symbols;
468 
469  for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
470  symbols.push_back( static_cast<SCH_SYMBOL*>( item ) );
471 
472  for( SCH_SYMBOL* symbol : symbols )
473  {
474  if( !isMatch( symbol, &instance ) )
475  continue;
476 
477  if( m_mode == MODE::UPDATE )
478  {
479  if( processSymbol( symbol, &instance, symbol->GetLibId(), appendToUndo ) )
480  changed = true;
481  }
482  else
483  {
484  if( processSymbol( symbol, &instance, newId, appendToUndo ) )
485  changed = true;
486  }
487 
488  if( changed )
489  appendToUndo = true;
490  }
491  }
492 
494 
495  return changed;
496 }
497 
498 
500  const LIB_ID& aNewId, bool aAppendToUndo )
501 {
502  wxCHECK( aSymbol, false );
503  wxCHECK( aNewId.IsValid(), false );
504 
505  SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
506  SCH_SCREEN* screen = aInstance->LastScreen();
507 
508  wxCHECK( frame, false );
509 
510  LIB_ID oldId = aSymbol->GetLibId();
511  wxString msg;
512  wxString references;
513 
514  for( SYMBOL_INSTANCE_REFERENCE instance : aSymbol->GetInstanceReferences() )
515  {
516  if( references.IsEmpty() )
517  references = instance.m_Reference;
518  else
519  references += " " + instance.m_Reference;
520  }
521 
522  if( m_mode == MODE::UPDATE )
523  {
524  if( aSymbol->GetInstanceReferences().size() == 1 )
525  {
526  msg.Printf( _( "Update symbol %s from '%s' to '%s'" ),
527  references,
528  UnescapeString( oldId.Format() ),
529  UnescapeString( aNewId.Format() ) );
530  }
531  else
532  {
533  msg.Printf( _( "Update symbols %s from '%s' to '%s'" ),
534  references,
535  UnescapeString( oldId.Format() ),
536  UnescapeString( aNewId.Format() ) );
537  }
538  }
539  else
540  {
541  if( aSymbol->GetInstanceReferences().size() == 1 )
542  {
543  msg.Printf( _( "Change symbol %s from '%s' to '%s'" ),
544  references,
545  UnescapeString( oldId.Format() ),
546  UnescapeString( aNewId.Format() ) );
547  }
548  else
549  {
550  msg.Printf( _( "Change symbols %s from '%s' to '%s'" ),
551  references,
552  UnescapeString( oldId.Format() ),
553  UnescapeString( aNewId.Format() ) );
554  }
555  }
556 
557  LIB_SYMBOL* libSymbol = frame->GetLibSymbol( aNewId );
558 
559  if( !libSymbol )
560  {
561  msg << ": " << _( "*** symbol not found ***" );
563  return false;
564  }
565 
566  std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->Flatten();
567 
568  if( flattenedSymbol->GetUnitCount() < aSymbol->GetUnit() )
569  {
570  msg << ": " << _( "*** new symbol has too few units ***" );
572  return false;
573  }
574 
575  // Removing the symbol needs to be done before the LIB_SYMBOL is changed to prevent stale
576  // library symbols in the schematic file.
577  screen->Remove( aSymbol );
578  frame->SaveCopyInUndoList( screen, aSymbol, UNDO_REDO::CHANGED, aAppendToUndo );
579 
580  if( aNewId != aSymbol->GetLibId() )
581  aSymbol->SetLibId( aNewId );
582 
583  aSymbol->SetLibSymbol( flattenedSymbol.release() );
584 
585  if( m_resetAttributes->GetValue() )
586  {
587  aSymbol->SetIncludeInBom( libSymbol->GetIncludeInBom() );
588  aSymbol->SetIncludeOnBoard( libSymbol->GetIncludeOnBoard() );
589  }
590 
591  bool removeExtras = m_removeExtraBox->GetValue();
592  bool resetVis = m_resetFieldVisibilities->GetValue();
593  bool resetEffects = m_resetFieldEffects->GetValue();
594  bool resetPositions = m_resetFieldPositions->GetValue();
595 
596  for( unsigned i = 0; i < aSymbol->GetFields().size(); ++i )
597  {
598  SCH_FIELD& field = aSymbol->GetFields()[i];
599  LIB_FIELD* libField = nullptr;
600 
601  if( !alg::contains( m_updateFields, field.GetName() ) )
602  continue;
603 
604  if( i < MANDATORY_FIELDS )
605  libField = libSymbol->GetFieldById( (int) i );
606  else
607  libField = libSymbol->FindField( field.GetName() );
608 
609  if( libField )
610  {
611  bool resetText = libField->GetText().IsEmpty() ? m_resetEmptyFields->GetValue()
612  : m_resetFieldText->GetValue();
613 
614  if( resetText )
615  {
616  if( i == REFERENCE_FIELD )
617  aSymbol->SetRef( aInstance, UTIL::GetRefDesUnannotated( libField->GetText() ) );
618  else if( i == VALUE_FIELD )
619  aSymbol->SetValue( aInstance, UnescapeString( libField->GetText() ) );
620  else if( i == FOOTPRINT_FIELD )
621  aSymbol->SetFootprint( aInstance, libField->GetText() );
622  else
623  field.SetText( libField->GetText() );
624  }
625 
626  if( resetVis )
627  field.SetVisible( libField->IsVisible() );
628 
629  if( resetEffects )
630  {
631  // Careful: the visible bit and position are also in Effects
632  bool visible = field.IsVisible();
633  wxPoint pos = field.GetPosition();
634 
635  field.SetEffects( *libField );
636 
637  field.SetVisible( visible );
638  field.SetPosition( pos );
639  }
640 
641  if( resetPositions )
642  field.SetTextPos( aSymbol->GetPosition() + libField->GetTextPos() );
643  }
644  else if( i >= MANDATORY_FIELDS && removeExtras )
645  {
646  aSymbol->RemoveField( field.GetName() );
647  i--;
648  }
649  }
650 
651  std::vector<LIB_FIELD*> libFields;
652  libSymbol->GetFields( libFields );
653 
654  for( unsigned i = MANDATORY_FIELDS; i < libFields.size(); ++i )
655  {
656  const LIB_FIELD& libField = *libFields[i];
657 
658  if( !alg::contains( m_updateFields, libField.GetName() ) )
659  continue;
660 
661  if( !aSymbol->FindField( libField.GetName(), false ) )
662  {
663  wxString fieldName = libField.GetCanonicalName();
664  SCH_FIELD newField( wxPoint( 0, 0), aSymbol->GetFieldCount(), aSymbol, fieldName );
665  SCH_FIELD* schField = aSymbol->AddField( newField );
666 
667  schField->SetEffects( libField );
668  schField->SetText( libField.GetText() );
669  schField->SetTextPos( aSymbol->GetPosition() + libField.GetTextPos() );
670  }
671  }
672 
673  aSymbol->SetSchSymbolLibraryName( wxEmptyString );
674  screen->Append( aSymbol );
675  frame->GetCanvas()->GetView()->Update( aSymbol );
676 
677  msg += ": OK";
679 
680  return true;
681 }
682 
683 
Field Reference of part, i.e. "IC21".
virtual bool ShowModal(wxString *aResult=nullptr, wxWindow *aResultantFocusWindow=nullptr)
Show this wxFrame as if it were a modal dialog, with all other instantiated wxFrames disabled until t...
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
LIB_FIELD * FindField(const wxString &aFieldName)
Find a field within this symbol matching aFieldName and returns it or NULL if not found.
Definition: lib_symbol.cpp:953
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:216
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
void SetLazyUpdate(bool aLazyUpdate)
Forces updating the HTML page, after the report is built in lazy mode If aSort = true,...
wxString GetRefDesUnannotated(const wxString &aSource)
Return an unannotated refdes from either a prefix or an existing refdes.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:64
bool g_resetAttributes[2]
bool Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:271
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
void onMatchByReference(wxCommandEvent &aEvent) override
bool IsSelected() const
Definition: eda_item.h:123
wxString getLibIdValue(const wxTextCtrl *aCtrl)
std::string m_hash_key
Definition: dialog_shim.h:199
void SetEffects(const EDA_TEXT &aSrc)
Set the text effects from another instance.
Definition: eda_text.cpp:129
wxPoint GetPosition() const override
Definition: sch_field.cpp:709
Field object used in symbol libraries.
Definition: lib_field.h:59
void SetValue(const SCH_SHEET_PATH *sheet, const wxString &aValue)
Definition: sch_symbol.cpp:594
void Flush(bool aSort=false)
Set the visible severity filter.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:711
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:246
Collection of utility functions for component reference designators (refdes)
bool GetIncludeOnBoard() const
Definition: lib_symbol.h:593
void onNewLibIDKillFocus(wxFocusEvent &event) override
bool g_resetEmptyFields[2]
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:382
bool g_removeExtraFields[2]
Schematic editor (Eeschema) main window.
void SetLibId(const LIB_ID &aName)
Definition: sch_symbol.cpp:238
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:441
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:159
Define a library symbol object.
Definition: lib_symbol.h:96
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
Definition: sch_symbol.cpp:645
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:257
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:332
wxString GetName(bool aUseDefaultName=true) const
Return the field name.
Definition: lib_field.cpp:362
void GetFields(std::vector< LIB_FIELD * > &aList)
Return a list of fields within this symbol.
Definition: lib_symbol.cpp:905
void onMatchByAll(wxCommandEvent &aEvent) override
const std::vector< SYMBOL_INSTANCE_REFERENCE > & GetInstanceReferences()
Definition: sch_symbol.h:123
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
std::set< wxString > m_updateFields
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
bool g_resetFieldVisibilities[2]
void SetIncludeInBom(bool aIncludeInBom)
Definition: sch_symbol.h:660
virtual void SetVisible(bool aVisible)
Definition: eda_text.h:185
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
Definition: sch_symbol.cpp:721
bool g_resetFieldEffects[2]
Field Value of part, i.e. "3.3K".
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:114
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
virtual bool IsVisible() const
Definition: eda_text.h:186
Class DIALOG_CHANGE_SYMBOLS_BASE.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:421
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
Definition: lib_field.cpp:371
SCHEMATIC & Schematic() const
A simple container for schematic symbol instance information.
void onMatchBySelected(wxCommandEvent &aEvent) override
#define _(s)
void SetSchSymbolLibraryName(const wxString &aName)
The name of the symbol in the schematic library symbol list.
Definition: sch_symbol.h:160
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslate=true)
Return a default symbol field name for field aFieldNdx for all components.
void onMatchIDKillFocus(wxFocusEvent &event) override
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void launchMatchIdSymbolBrowser(wxCommandEvent &aEvent) 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
const wxString GetValue(const SCH_SHEET_PATH *sheet, bool aResolve) const
Return the instance-specific value for the given sheet path.
Definition: sch_symbol.cpp:573
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true)
Search for a SCH_FIELD with aFieldName.
Definition: sch_symbol.cpp:743
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
bool g_selectValue
UTF8 Format() const
Definition: lib_id.cpp:116
wxString UnescapeString(const wxString &aSource)
void Report(const wxString &aText, SEVERITY aSeverity, REPORTER::LOCATION aLocation=REPORTER::LOC_BODY)
Reports the string.
void onMatchByValue(wxCommandEvent &aEvent) override
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...
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:49
void SetIncludeOnBoard(bool aIncludeOnBoard)
Definition: sch_symbol.h:663
LIB_FIELD * GetFieldById(int aId) const
Return pointer to the requested field.
Definition: lib_symbol.cpp:939
bool g_resetFieldText[2]
void launchNewIdSymbolBrowser(wxCommandEvent &aEvent) override
Schematic symbol object.
Definition: sch_symbol.h:78
bool processSymbol(SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH *aInstance, const LIB_ID &aNewId, bool aAppendToUndo)
SCH_SCREEN * LastScreen()
void Clear()
return the number of messages matching the given severity mask.
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:144
WX_HTML_REPORT_PANEL * m_messagePanel
void onMatchById(wxCommandEvent &aEvent) override
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:481
wxString GetName(bool aUseDefaultName=true) const
Return the field name.
Definition: sch_field.cpp:544
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
wxPoint GetPosition() const override
Definition: sch_symbol.h:641
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
bool g_selectRefDes
bool WildCompareString(const wxString &pattern, const wxString &string_to_tst, bool case_sensitive)
Compare a string against wild card (* and ?) pattern using the usual rules.
const wxPoint & GetTextPos() const
Definition: eda_text.h:247
SCH_SHEET_PATH & GetCurrentSheet() const
bool g_resetFieldPositions[2]
void onMatchTextKillFocus(wxFocusEvent &event) override
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
MODE m_mode
Set of field names that should have values updated.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
int GetUnit() const
Definition: sch_symbol.h:195
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:121
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
void SetFileName(const wxString &aReportFileName)
bool isMatch(SCH_SYMBOL *aSymbol, SCH_SHEET_PATH *aInstance)
void onOkButtonClicked(wxCommandEvent &aEvent) override
void SetPosition(const wxPoint &aPosition) override
Definition: sch_field.cpp:689
void RemoveField(const wxString &aFieldName)
Remove a user field from the symbol.
Definition: sch_symbol.cpp:730
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:193
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
DIALOG_CHANGE_SYMBOLS(SCH_EDIT_FRAME *aParent, SCH_SYMBOL *aSymbol, MODE aMode=MODE::UPDATE)
bool GetIncludeInBom() const
Definition: lib_symbol.h:585
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:147
Field Name Module PCB, i.e. "16DIP300".