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  *
6  * @author Wayne Stambaugh <stambaughw@gmail.com>
7  *
8  * This program is free software: you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by the
10  * Free Software Foundation, either version 3 of the License, or (at your
11  * option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include <algorithm>
23 
24 #include <bitmaps.h>
25 #include <kicad_string.h> // WildCompareString
26 #include <kiway.h>
27 #include <lib_id.h>
28 
29 #include <core/kicad_algo.h>
30 #include <dialog_change_symbols.h>
31 #include <sch_symbol.h>
32 #include <sch_edit_frame.h>
33 #include <sch_screen.h>
34 #include <sch_sheet_path.h>
35 #include <schematic.h>
36 #include <template_fieldnames.h>
37 #include <wx_html_report_panel.h>
38 
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" ) );
77 
78  m_newId->AppendText( FROM_UTF8( m_symbol->GetLibId().Format().c_str() ) );
79  m_specifiedReference->ChangeValue( m_symbol->GetRef( currentSheet ) );
80  m_specifiedValue->ChangeValue( m_symbol->GetValue( currentSheet, false ) );
81  m_specifiedId->ChangeValue( FROM_UTF8( m_symbol->GetLibId().Format().c_str() ) );
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 
210 {
212  g_selectValue = m_fieldsBox->IsChecked( VALUE_FIELD );
213 
214  g_removeExtraFields[ (int) m_mode ] = m_removeExtraBox->GetValue();
215  g_resetEmptyFields[ (int) m_mode ] = m_resetEmptyFields->GetValue();
216  g_resetFieldText[ (int) m_mode ] = m_resetFieldText->GetValue();
218  g_resetFieldEffects[ (int) m_mode ] = m_resetFieldEffects->GetValue();
219  g_resetFieldPositions[ (int) m_mode ] = m_resetFieldPositions->GetValue();
220  g_resetAttributes[ (int) m_mode ] = m_resetAttributes->GetValue();
221 }
222 
223 
225 {
226  wxString newName = m_specifiedId->GetValue();
227 
228  KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH_VIEWER_MODAL, true );
229 
230  if( frame->ShowModal( &newName, this ) )
231  {
232  m_specifiedId->SetValue( newName );
234  }
235 
236  frame->Destroy();
237 }
238 
239 
241 {
242  wxString newName = m_newId->GetValue();
243 
244  KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH_VIEWER_MODAL, true );
245 
246  if( frame->ShowModal( &newName, this ) )
247  {
248  m_newId->SetValue( newName );
250  }
251 
252  frame->Destroy();
253 }
254 
255 
257 {
258  SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
259 
260  wxCHECK( frame, /* void */ );
261 
262  SCH_SHEET_LIST hierarchy = frame->Schematic().GetSheets();
263 
264  // Load non-mandatory fields from all matching symbols and their library parts
265  std::vector<SCH_FIELD*> fields;
266  std::vector<LIB_FIELD*> libFields;
267  std::set<wxString> fieldNames;
268 
269  for( SCH_SHEET_PATH& instance : hierarchy )
270  {
271  SCH_SCREEN* screen = instance.LastScreen();
272 
273  wxCHECK2( screen, continue );
274 
275  for( SCH_ITEM* item : screen->Items().OfType( SCH_COMPONENT_T ) )
276  {
277  SCH_COMPONENT* symbol = dynamic_cast<SCH_COMPONENT*>( item );
278 
279  wxCHECK2( symbol, continue );
280 
281  if( !isMatch( symbol, &instance ) )
282  continue;
283 
284  fields.clear();
285  symbol->GetFields( fields, false );
286 
287  for( unsigned i = MANDATORY_FIELDS; i < fields.size(); ++i )
288  fieldNames.insert( fields[i]->GetName() );
289 
290  if( m_mode == MODE::UPDATE && symbol->GetLibId().IsValid() )
291  {
292  LIB_PART* libSymbol = frame->GetLibPart( symbol->GetLibId() );
293 
294  if( libSymbol )
295  {
296  std::unique_ptr<LIB_PART> flattenedPart = libSymbol->Flatten();
297 
298  flattenedPart->GetFields( libFields );
299 
300  for( unsigned i = MANDATORY_FIELDS; i < libFields.size(); ++i )
301  fieldNames.insert( libFields[i]->GetName() );
302 
303  libFields.clear(); // flattenedPart is about to go out of scope...
304  }
305  }
306  }
307  }
308 
309  // Load non-mandatory fields from the change-to library part
310  if( m_mode == MODE::CHANGE )
311  {
312  LIB_ID newId;
313 
314  newId.Parse( m_newId->GetValue() );
315 
316  if( newId.IsValid() )
317  {
318  LIB_PART* libSymbol = frame->GetLibPart( newId );
319 
320  if( libSymbol )
321  {
322  std::unique_ptr<LIB_PART> flattenedPart = libSymbol->Flatten();
323 
324  flattenedPart->GetFields( libFields );
325 
326  for( unsigned i = MANDATORY_FIELDS; i < libFields.size(); ++i )
327  fieldNames.insert( libFields[i]->GetName() );
328 
329  libFields.clear(); // flattenedPart is about to go out of scope...
330  }
331  }
332  }
333 
334  // Update the listbox widget
335  for( unsigned i = m_fieldsBox->GetCount() - 1; i >= MANDATORY_FIELDS; --i )
336  m_fieldsBox->Delete( i );
337 
338  for( const wxString& fieldName : fieldNames )
339  m_fieldsBox->Append( fieldName );
340 
341  for( unsigned i = MANDATORY_FIELDS; i < m_fieldsBox->GetCount(); ++i )
342  m_fieldsBox->Check( i, true );
343 }
344 
345 
347 {
348  for( unsigned i = 0; i < m_fieldsBox->GetCount(); ++i )
349  m_fieldsBox->Check( i, aCheck );
350 }
351 
352 
353 void DIALOG_CHANGE_SYMBOLS::onOkButtonClicked( wxCommandEvent& aEvent )
354 {
355  wxBusyCursor dummy;
356  SCH_EDIT_FRAME* parent = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
357 
358  wxCHECK( parent, /* void */ );
359 
361  m_messagePanel->Flush( false );
362 
363  // Create the set of fields to be updated
364  m_updateFields.clear();
365 
366  for( unsigned i = 0; i < m_fieldsBox->GetCount(); ++i )
367  {
368  if( m_fieldsBox->IsChecked( i ) )
369  m_updateFields.insert( m_fieldsBox->GetString( i ) );
370  }
371 
372  if( processMatchingSymbols() )
373  {
374  parent->TestDanglingEnds(); // This will also redraw the changed symbols.
375  parent->OnModify();
376  }
377 
378  m_messagePanel->Flush( false );
379 }
380 
381 
383 {
384  LIB_ID id;
385 
386  wxCHECK( aSymbol, false );
387 
388  SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
389 
390  wxCHECK( frame, false );
391 
392  if( m_matchAll->GetValue() )
393  {
394  return true;
395  }
396  else if( m_matchBySelection->GetValue() )
397  {
398  return aSymbol == m_symbol;
399  }
400  else if( m_matchByReference->GetValue() )
401  {
402  return WildCompareString( m_specifiedReference->GetValue(),
403  aSymbol->GetRef( aInstance, false ), false );
404  }
405  else if( m_matchByValue->GetValue() )
406  {
407  return WildCompareString( m_specifiedValue->GetValue(),
408  aSymbol->GetValue( aInstance, false ), false );
409  }
410  else if( m_matchById )
411  {
412  id.Parse( m_specifiedId->GetValue() );
413  return aSymbol->GetLibId() == id;
414  }
415 
416  return false;
417 }
418 
419 
421 {
422  SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
423 
424  wxCHECK( frame, false );
425 
426  LIB_ID newId;
427  bool appendToUndo = false;
428  bool changed = false;
429  SCH_SHEET_LIST hierarchy = frame->Schematic().GetSheets();
430 
431  if( m_mode == MODE::CHANGE )
432  {
433  newId.Parse( m_newId->GetValue() );
434 
435  if( !newId.IsValid() )
436  return false;
437  }
438 
439  for( SCH_SHEET_PATH& instance : hierarchy )
440  {
441  SCH_SCREEN* screen = instance.LastScreen();
442 
443  wxCHECK2( screen, continue );
444 
445  std::vector<SCH_COMPONENT*> components;
446 
447  for( SCH_ITEM* item : screen->Items().OfType( SCH_COMPONENT_T ) )
448  components.push_back( static_cast<SCH_COMPONENT*>( item ) );
449 
450  for( SCH_COMPONENT* symbol : components )
451  {
452  if( !isMatch( symbol, &instance ) )
453  continue;
454 
455  if( m_mode == MODE::UPDATE )
456  {
457  if( processSymbol( symbol, &instance, symbol->GetLibId(), appendToUndo ) )
458  changed = true;
459  }
460  else
461  {
462  if( processSymbol( symbol, &instance, newId, appendToUndo ) )
463  changed = true;
464  }
465 
466  if( changed )
467  appendToUndo = true;
468  }
469  }
470 
472 
473  return changed;
474 }
475 
476 
478  const LIB_ID& aNewId, bool aAppendToUndo )
479 {
480  wxCHECK( aSymbol, false );
481  wxCHECK( aNewId.IsValid(), false );
482 
483  SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
484  SCH_SCREEN* screen = aInstance->LastScreen();
485 
486  wxCHECK( frame, false );
487 
488  LIB_ID oldId = aSymbol->GetLibId();
489  wxString msg;
490  wxString references;
491 
492  for( SYMBOL_INSTANCE_REFERENCE instance : aSymbol->GetInstanceReferences() )
493  {
494  if( references.IsEmpty() )
495  references = instance.m_Reference;
496  else
497  references += " " + instance.m_Reference;
498  }
499 
500  if( m_mode == MODE::UPDATE )
501  {
502  if( aSymbol->GetInstanceReferences().size() == 1 )
503  {
504  msg.Printf( _( "Update symbol %s from '%s' to '%s'" ),
505  references,
506  oldId.Format().c_str(),
507  aNewId.Format().c_str() );
508  }
509  else
510  {
511  msg.Printf( _( "Update symbols %s from '%s' to '%s'" ),
512  references,
513  oldId.Format().c_str(),
514  aNewId.Format().c_str() );
515  }
516  }
517  else
518  {
519  if( aSymbol->GetInstanceReferences().size() == 1 )
520  {
521  msg.Printf( _( "Change symbol %s from '%s' to '%s'" ),
522  references,
523  oldId.Format().c_str(),
524  aNewId.Format().c_str() );
525  }
526  else
527  {
528  msg.Printf( _( "Change symbols %s from '%s' to '%s'" ),
529  references,
530  oldId.Format().c_str(),
531  aNewId.Format().c_str() );
532  }
533  }
534 
535  LIB_PART* libSymbol = frame->GetLibPart( aNewId );
536 
537  if( !libSymbol )
538  {
539  msg << ": " << _( "*** symbol not found ***" );
541  return false;
542  }
543 
544  std::unique_ptr<LIB_PART> flattenedSymbol = libSymbol->Flatten();
545 
546  if( flattenedSymbol->GetUnitCount() < aSymbol->GetUnit() )
547  {
548  msg << ": " << _( "*** new symbol has too few units ***" );
550  return false;
551  }
552 
553  // Removing the symbol needs to be done before the LIB_PART is changed to prevent stale
554  // library symbols in the schematic file.
555  screen->Remove( aSymbol );
556  frame->SaveCopyInUndoList( screen, aSymbol, UNDO_REDO::CHANGED, aAppendToUndo );
557 
558  if( aNewId != aSymbol->GetLibId() )
559  aSymbol->SetLibId( aNewId );
560 
561  aSymbol->SetLibSymbol( flattenedSymbol.release() );
562 
563  if( m_resetAttributes->GetValue() )
564  {
565  aSymbol->SetIncludeInBom( libSymbol->GetIncludeInBom() );
566  aSymbol->SetIncludeOnBoard( libSymbol->GetIncludeOnBoard() );
567  }
568 
569  bool removeExtras = m_removeExtraBox->GetValue();
570  bool resetVis = m_resetFieldVisibilities->GetValue();
571  bool resetEffects = m_resetFieldEffects->GetValue();
572  bool resetPositions = m_resetFieldPositions->GetValue();
573 
574  for( unsigned i = 0; i < aSymbol->GetFields().size(); ++i )
575  {
576  SCH_FIELD& field = aSymbol->GetFields()[i];
577  LIB_FIELD* libField = nullptr;
578 
579  if( !alg::contains( m_updateFields, field.GetName() ) )
580  continue;
581 
582  if( i < MANDATORY_FIELDS )
583  libField = libSymbol->GetFieldById( (int) i );
584  else
585  libField = libSymbol->FindField( field.GetName() );
586 
587  if( libField )
588  {
589  bool resetText = libField->GetText().IsEmpty() ? m_resetEmptyFields->GetValue()
590  : m_resetFieldText->GetValue();
591 
592  if( resetText )
593  {
594  if( i == REFERENCE_FIELD )
595  aSymbol->SetRef( aInstance, libField->GetText() );
596  else if( i == VALUE_FIELD )
597  aSymbol->SetValue( aInstance, libField->GetText() );
598  else if( i == FOOTPRINT_FIELD )
599  aSymbol->SetFootprint( aInstance, libField->GetText() );
600  else
601  field.SetText( libField->GetText() );
602  }
603 
604  if( resetVis )
605  field.SetVisible( libField->IsVisible() );
606 
607  if( resetEffects )
608  {
609  // Careful: the visible bit and position are also in Effects
610  bool visible = field.IsVisible();
611  wxPoint pos = field.GetPosition();
612 
613  field.SetEffects( *libField );
614 
615  field.SetVisible( visible );
616  field.SetPosition( pos );
617  }
618 
619  if( resetPositions )
620  field.SetTextPos( aSymbol->GetPosition() + libField->GetTextPos() );
621  }
622  else if( i >= MANDATORY_FIELDS && removeExtras )
623  {
624  aSymbol->RemoveField( field.GetName() );
625  i--;
626  }
627  }
628 
629  std::vector<LIB_FIELD*> libFields;
630  libSymbol->GetFields( libFields );
631 
632  for( unsigned i = MANDATORY_FIELDS; i < libFields.size(); ++i )
633  {
634  const LIB_FIELD& libField = *libFields[i];
635 
636  if( !alg::contains( m_updateFields, libField.GetName() ) )
637  continue;
638 
639  if( !aSymbol->FindField( libField.GetName(), false ) )
640  {
641  wxString fieldName = libField.GetCanonicalName();
642  SCH_FIELD newField( wxPoint( 0, 0), aSymbol->GetFieldCount(), aSymbol, fieldName );
643  SCH_FIELD* schField = aSymbol->AddField( newField );
644 
645  schField->SetEffects( libField );
646  schField->SetText( libField.GetText() );
647  schField->SetTextPos( aSymbol->GetPosition() + libField.GetTextPos() );
648  }
649  }
650 
651  aSymbol->SetSchSymbolLibraryName( wxEmptyString );
652  screen->Append( aSymbol );
653  frame->GetCanvas()->GetView()->Update( aSymbol );
654 
655  msg += ": OK";
657 
658  return true;
659 }
660 
661 
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.
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:219
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
void SetLazyUpdate(bool aLazyUpdate)
Forces updating the HTML page, after the report is built in lazy mode If aSort = true,...
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:61
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true)
Search for a SCH_FIELD with aFieldName.
Definition: sch_symbol.cpp:756
bool g_resetAttributes[2]
bool Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:243
void SetLibSymbol(LIB_PART *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:243
void SetLibId(const LIB_ID &aName)
Definition: sch_symbol.cpp:224
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:56
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
void onMatchByReference(wxCommandEvent &aEvent) override
bool IsSelected() const
Definition: eda_item.h:172
void SetIncludeInBom(bool aIncludeInBom)
Definition: sch_symbol.h:699
std::string m_hash_key
Definition: dialog_shim.h:200
bool IsVisible() const
Definition: eda_text.h:193
void SetEffects(const EDA_TEXT &aSrc)
Set the text effects from another instance.
Definition: eda_text.cpp:137
wxPoint GetPosition() const override
Definition: sch_field.cpp:671
Field object used in symbol libraries.
Definition: lib_field.h:59
void Flush(bool aSort=false)
Set the visible severity filter.
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:253
void SetVisible(bool aVisible)
Definition: eda_text.h:192
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
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:345
bool g_removeExtraFields[2]
Schematic editor (Eeschema) main window.
LIB_PART * GetLibPart(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
void SetSchSymbolLibraryName(const wxString &aName)
The name of the symbol in the schematic library symbol list.
Definition: sch_symbol.h:201
void SetIncludeOnBoard(bool aIncludeOnBoard)
Definition: sch_symbol.h:702
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:168
wxString GetName(bool aUseDefaultName=true) const
Returns the field name.
Definition: lib_field.cpp:364
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populates a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:724
const char * c_str() const
Definition: utf8.h:102
void onMatchByAll(wxCommandEvent &aEvent) override
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]
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:82
int GetUnit() const
Definition: sch_symbol.h:236
bool g_resetFieldEffects[2]
LIB_FIELD * FindField(const wxString &aFieldName)
Find a field within this part matching aFieldName and returns it or NULL if not found.
Definition: lib_symbol.cpp:953
Field Value of part, i.e. "3.3K".
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
const wxString GetValue(const SCH_SHEET_PATH *sheet, bool aResolve) const
Definition: sch_symbol.cpp:588
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
Class DIALOG_CHANGE_SYMBOLS_BASE.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
DIALOG_CHANGE_SYMBOLS(SCH_EDIT_FRAME *aParent, SCH_COMPONENT *aSymbol, MODE aMode=MODE::UPDATE)
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.
Definition: string.cpp:499
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:373
SCHEMATIC & Schematic() const
Define a library symbol object.
Definition: lib_symbol.h:93
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
Definition: sch_symbol.cpp:734
A simple container for schematic symbol instance information.
void GetFields(std::vector< LIB_FIELD * > &aList)
Return a list of fields within this part.
Definition: lib_symbol.cpp:905
void onMatchBySelected(wxCommandEvent &aEvent) override
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...
const BITMAP_OPAQUE small_library_xpm[1]
std::unique_ptr< LIB_PART > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:334
void launchMatchIdSymbolBrowser(wxCommandEvent &aEvent) override
LIB_FIELD * GetFieldById(int aId) const
Return pointer to the requested field.
Definition: lib_symbol.cpp:939
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:81
bool g_selectValue
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:457
UTF8 Format() const
Definition: lib_id.cpp:233
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...
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:477
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:111
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:122
bool g_resetFieldText[2]
void launchNewIdSymbolBrowser(wxCommandEvent &aEvent) override
SCH_SCREEN * LastScreen()
void Clear()
return the number of messages matching the given severity mask.
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:127
WX_HTML_REPORT_PANEL * m_messagePanel
#define _(s)
Definition: 3d_actions.cpp:33
void onMatchById(wxCommandEvent &aEvent) override
wxString GetName(bool aUseDefaultName=true) const
Function GetName returns the field name.
Definition: sch_field.cpp:505
bool isMatch(SCH_COMPONENT *aSymbol, SCH_SHEET_PATH *aInstance)
EE_RTREE & Items()
Definition: sch_screen.h:162
Schematic symbol object.
Definition: sch_symbol.h:78
wxPoint GetPosition() const override
Definition: sch_symbol.h:680
bool GetIncludeOnBoard() const
Definition: lib_symbol.h:587
void RemoveField(const wxString &aFieldName)
Removes a user field from the symbol.
Definition: sch_symbol.cpp:743
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
bool g_selectRefDes
const wxPoint & GetTextPos() const
Definition: eda_text.h:254
SCH_SHEET_PATH & GetCurrentSheet() const
bool g_resetFieldPositions[2]
void onMatchTextKillFocus(wxFocusEvent &event) override
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...
bool processSymbol(SCH_COMPONENT *aSymbol, const SCH_SHEET_PATH *aInstance, const LIB_ID &aNewId, bool aAppendToUndo)
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:141
void SetValue(const SCH_SHEET_PATH *sheet, const wxString &aValue)
Definition: sch_symbol.cpp:609
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
void SetFileName(const wxString &aReportFileName)
const std::vector< SYMBOL_INSTANCE_REFERENCE > & GetInstanceReferences()
Definition: sch_symbol.h:164
bool GetIncludeInBom() const
Definition: lib_symbol.h:579
void onOkButtonClicked(wxCommandEvent &aEvent) override
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:188
void SetPosition(const wxPoint &aPosition) override
Definition: sch_field.cpp:650
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:196
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
Definition: sch_symbol.cpp:659
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:427
Field Name Module PCB, i.e. "16DIP300".