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-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Wayne Stambaugh <[email protected]>
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 <refdes_utils.h>
29#include <core/kicad_algo.h>
31#include <sch_symbol.h>
32#include <sch_edit_frame.h>
33#include <sch_screen.h>
34#include <schematic.h>
35#include <template_fieldnames.h>
37
38bool g_selectRefDes = false;
39bool g_selectValue = false;
40 // { change, update }
41bool g_removeExtraFields[2] = { false, false };
42bool g_resetEmptyFields[2] = { false, false };
43bool g_resetFieldText[2] = { true, true };
44bool g_resetFieldVisibilities[2] = { true, false };
45bool g_resetFieldEffects[2] = { true, false };
46bool g_resetFieldPositions[2] = { true, false };
47bool g_resetAttributes[2] = { true, false };
48
49
51 MODE aMode ) :
53 m_symbol( aSymbol),
54 m_mode( aMode )
55{
56 wxASSERT( aParent );
57
58 if( m_mode == MODE::UPDATE )
59 {
60 m_newIdSizer->Show( false );
61 }
62 else
63 {
64 m_matchAll->SetLabel( _( "Change all symbols in schematic" ) );
65 SetTitle( _( "Change Symbols" ) );
66 m_matchSizer->FindItem( m_matchAll )->Show( false );
67 }
68
69 if( m_symbol )
70 {
71 SCH_SHEET_PATH* currentSheet = &aParent->Schematic().CurrentSheet();
72
73 if( m_mode == MODE::CHANGE )
74 m_matchBySelection->SetLabel( _( "Change selected symbol(s)" ) );
75
76 m_newId->ChangeValue( UnescapeString( m_symbol->GetLibId().Format() ) );
77 m_specifiedReference->ChangeValue( m_symbol->GetRef( currentSheet ) );
78 m_specifiedValue->ChangeValue( m_symbol->GetValueFieldText( false ) );
79 m_specifiedId->ChangeValue( UnescapeString( m_symbol->GetLibId().Format() ) );
80 }
81 else
82 {
83 m_matchSizer->FindItem( m_matchBySelection )->Show( false );
84 }
85
88
89 if( m_mode == MODE::CHANGE )
90 {
91 m_matchByReference->SetLabel( _( "Change symbols matching reference designator:" ) );
92 m_matchByValue->SetLabel( _( "Change symbols matching value:" ) );
93 m_matchById->SetLabel( _( "Change symbols matching library identifier:" ) );
94 }
95
96 m_matchSizer->SetEmptyCellSize( wxSize( 0, 0 ) );
97 m_matchSizer->Layout();
98
99 for( int i = 0; i < MANDATORY_FIELDS; ++i )
100 {
102
103 if( i == REFERENCE_FIELD )
104 m_fieldsBox->Check( i, g_selectRefDes );
105 else if( i == VALUE_FIELD )
106 m_fieldsBox->Check( i, g_selectValue );
107 else
108 m_fieldsBox->Check( i, true );
109 }
110
112 m_messagePanel->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
113
114 if( aSymbol && aSymbol->IsSelected() )
115 {
116 m_matchBySelection->SetValue( true );
117 }
118 else
119 {
120 if( aMode == MODE::UPDATE )
121 m_matchAll->SetValue( true );
122 else
123 m_matchByReference->SetValue( true );
124 }
125
127
128 if( m_mode == MODE::CHANGE )
129 {
130 m_updateFieldsSizer->GetStaticBox()->SetLabel( _( "Update Fields" ) );
131 m_removeExtraBox->SetLabel( _( "Remove fields if not in new symbol" ) );
132 m_resetEmptyFields->SetLabel( _( "Reset fields if empty in new symbol" ) );
133 m_resetFieldText->SetLabel( _( "Update field text" ) );
134 m_resetFieldVisibilities->SetLabel( _( "Update field visibilities" ) );
135 m_resetFieldEffects->SetLabel( _( "Update field sizes and styles" ) );
136 m_resetFieldPositions->SetLabel( _( "Update field positions" ) );
137 m_resetAttributes->SetLabel( _( "Update symbol attributes" ) );
138 }
139
140 m_removeExtraBox->SetValue( g_removeExtraFields[ (int) m_mode ] );
141 m_resetEmptyFields->SetValue( g_resetEmptyFields[ (int) m_mode ] );
142 m_resetFieldText->SetValue( g_resetFieldText[ (int) m_mode ] );
144 m_resetFieldEffects->SetValue( g_resetFieldEffects[ (int) m_mode ] );
146 m_resetAttributes->SetValue( g_resetAttributes[ (int) m_mode ] );
147
148 // DIALOG_SHIM needs a unique hash_key because classname is not sufficient
149 // because the update and change versions of this dialog have different controls.
150 m_hash_key = TO_UTF8( GetTitle() );
151
152 wxString okLabel = m_mode == MODE::CHANGE ? _( "Change" ) : _( "Update" );
153
154 SetupStandardButtons( { { wxID_OK, okLabel },
155 { wxID_CANCEL, _( "Close" ) } } );
156
157 // Now all widgets have the size fixed, call FinishDialogSettings
159}
160
161
162void DIALOG_CHANGE_SYMBOLS::onMatchByAll( wxCommandEvent& aEvent )
163{
165}
166
167
168void DIALOG_CHANGE_SYMBOLS::onMatchBySelected( wxCommandEvent& aEvent )
169{
171}
172
173
174void DIALOG_CHANGE_SYMBOLS::onMatchByReference( wxCommandEvent& aEvent )
175{
177 m_specifiedReference->SetFocus();
178}
179
180
181void DIALOG_CHANGE_SYMBOLS::onMatchByValue( wxCommandEvent& aEvent )
182{
184 m_specifiedValue->SetFocus();
185}
186
187
188void DIALOG_CHANGE_SYMBOLS::onMatchById( wxCommandEvent& aEvent )
189{
191 m_specifiedId->SetFocus();
192}
193
194
196{
198 event.Skip(); // Mandatory in wxFocusEvent
199}
200
201
203{
205 event.Skip(); // Mandatory in wxFocusEvent
206}
207
208
210{
212 event.Skip(); // Mandatory in wxFocusEvent
213}
214
215
217{
219 g_selectValue = m_fieldsBox->IsChecked( VALUE_FIELD );
220
221 g_removeExtraFields[ (int) m_mode ] = m_removeExtraBox->GetValue();
222 g_resetEmptyFields[ (int) m_mode ] = m_resetEmptyFields->GetValue();
223 g_resetFieldText[ (int) m_mode ] = m_resetFieldText->GetValue();
225 g_resetFieldEffects[ (int) m_mode ] = m_resetFieldEffects->GetValue();
227 g_resetAttributes[ (int) m_mode ] = m_resetAttributes->GetValue();
228}
229
230
231wxString getLibIdValue( const wxTextCtrl* aCtrl )
232{
233 wxString rawValue = aCtrl->GetValue();
234 wxString itemName;
235 wxString libName = rawValue.BeforeFirst( ':', &itemName );
236
237 return EscapeString( libName, CTX_LIBID ) + ':' + EscapeString( itemName, CTX_LIBID );
238}
239
240
242{
243 wxString newName = getLibIdValue( m_specifiedId );
244
246
247 if( frame->ShowModal( &newName, this ) )
248 {
249 m_specifiedId->SetValue( UnescapeString( newName ) );
251 }
252
253 frame->Destroy();
254}
255
256
258{
259 wxString newName = getLibIdValue( m_newId );
260
262
263 if( frame->ShowModal( &newName, this ) )
264 {
265 m_newId->SetValue( UnescapeString( newName ) );
267 }
268
269 frame->Destroy();
270}
271
272
274{
275 SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
276
277 wxCHECK( frame, /* void */ );
278
279 SCH_SHEET_LIST hierarchy = frame->Schematic().GetSheets();
280
281 // Load non-mandatory fields from all matching symbols and their library symbols
282 std::vector<SCH_FIELD*> fields;
283 std::vector<LIB_FIELD*> libFields;
284 std::set<wxString> fieldNames;
285
286 for( SCH_SHEET_PATH& instance : hierarchy )
287 {
288 SCH_SCREEN* screen = instance.LastScreen();
289
290 wxCHECK2( screen, continue );
291
292 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
293 {
294 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
295
296 wxCHECK2( symbol, continue );
297
298 if( !isMatch( symbol, &instance ) )
299 continue;
300
301 fields.clear();
302 symbol->GetFields( fields, false );
303
304 for( unsigned i = MANDATORY_FIELDS; i < fields.size(); ++i )
305 fieldNames.insert( fields[i]->GetName() );
306
307 if( m_mode == MODE::UPDATE && symbol->GetLibId().IsValid() )
308 {
309 LIB_SYMBOL* libSymbol = frame->GetLibSymbol( symbol->GetLibId() );
310
311 if( libSymbol )
312 {
313 std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->Flatten();
314
315 flattenedSymbol->GetFields( libFields );
316
317 for( unsigned i = MANDATORY_FIELDS; i < libFields.size(); ++i )
318 fieldNames.insert( libFields[i]->GetName() );
319
320 libFields.clear(); // flattenedSymbol is about to go out of scope...
321 }
322 }
323 }
324 }
325
326 // Load non-mandatory fields from the change-to library symbol
327 if( m_mode == MODE::CHANGE )
328 {
329 LIB_ID newId;
330
331 newId.Parse( getLibIdValue( m_newId ) );
332
333 if( newId.IsValid() )
334 {
335 LIB_SYMBOL* libSymbol = frame->GetLibSymbol( newId );
336
337 if( libSymbol )
338 {
339 std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->Flatten();
340
341 flattenedSymbol->GetFields( libFields );
342
343 for( unsigned i = MANDATORY_FIELDS; i < libFields.size(); ++i )
344 fieldNames.insert( libFields[i]->GetName() );
345
346 libFields.clear(); // flattenedSymbol is about to go out of scope...
347 }
348 }
349 }
350
351 // Update the listbox widget
352 for( unsigned i = m_fieldsBox->GetCount() - 1; i >= MANDATORY_FIELDS; --i )
353 m_fieldsBox->Delete( i );
354
355 for( const wxString& fieldName : fieldNames )
356 m_fieldsBox->Append( fieldName );
357
358 for( unsigned i = MANDATORY_FIELDS; i < m_fieldsBox->GetCount(); ++i )
359 m_fieldsBox->Check( i, true );
360}
361
362
364{
365 for( unsigned i = 0; i < m_fieldsBox->GetCount(); ++i )
366 m_fieldsBox->Check( i, aCheck );
367}
368
369
370void DIALOG_CHANGE_SYMBOLS::onOkButtonClicked( wxCommandEvent& aEvent )
371{
372 wxBusyCursor dummy;
373 SCH_EDIT_FRAME* parent = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
374
375 wxCHECK( parent, /* void */ );
376
378 m_messagePanel->Flush( false );
379
380 // Create the set of fields to be updated. Use non translated (canonical) names
381 // for mandatory fields
382 m_updateFields.clear();
383
384 for( unsigned i = 0; i < m_fieldsBox->GetCount(); ++i )
385 {
386 if( m_fieldsBox->IsChecked( i ) )
387 {
388 if( i < MANDATORY_FIELDS )
389 {
390 LIB_FIELD dummy_field( i );
391 m_updateFields.insert( dummy_field.GetCanonicalName() );
392 }
393 else
394 m_updateFields.insert( m_fieldsBox->GetString( i ) );
395 }
396 }
397
399 {
400 parent->TestDanglingEnds(); // This will also redraw the changed symbols.
401 parent->OnModify();
402 }
403
404 m_messagePanel->Flush( false );
405}
406
407
409{
410 LIB_ID id;
411
412 wxCHECK( aSymbol, false );
413
414 SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
415
416 wxCHECK( frame, false );
417
418 if( m_matchAll->GetValue() )
419 {
420 return true;
421 }
422 else if( m_matchBySelection->GetValue() )
423 {
424 return aSymbol == m_symbol || aSymbol->IsSelected();
425 }
426 else if( m_matchByReference->GetValue() )
427 {
428 return WildCompareString( m_specifiedReference->GetValue(),
429 aSymbol->GetRef( aInstance, false ), false );
430 }
431 else if( m_matchByValue->GetValue() )
432 {
433 return WildCompareString( m_specifiedValue->GetValue(),
434 aSymbol->GetValueFieldText( false ), false );
435 }
436 else if( m_matchById )
437 {
438 id.Parse( getLibIdValue( m_specifiedId ) );
439 return aSymbol->GetLibId() == id;
440 }
441
442 return false;
443}
444
445
446
447
449{
450 SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
451
452 wxCHECK( frame, false );
453
454 LIB_ID newId;
455 wxString msg;
456 int matchesProcessed = 0;
457 SCH_SYMBOL* symbol = nullptr;
458 SCH_SHEET_LIST hierarchy = frame->Schematic().GetSheets();
459
460 if( m_mode == MODE::CHANGE )
461 {
462 newId.Parse( getLibIdValue( m_newId ) );
463
464 if( !newId.IsValid() )
465 return false;
466 }
467
468 std::map<SCH_SYMBOL*, SYMBOL_CHANGE_INFO> symbols;
469
470 for( SCH_SHEET_PATH& instance : hierarchy )
471 {
472 SCH_SCREEN* screen = instance.LastScreen();
473
474 wxCHECK2( screen, continue );
475
476 // Fetch all the symbols that meet the change criteria.
477 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
478 {
479 symbol = static_cast<SCH_SYMBOL*>( item );
480
481 wxCHECK2( symbol, continue );
482
483 if( !isMatch( symbol, &instance ) )
484 continue;
485
486 if( m_mode == MODE::UPDATE )
487 newId = symbol->GetLibId();
488
489 auto it = symbols.find( symbol );
490
491 if( it == symbols.end() )
492 {
494
495 info.m_Instances.emplace_back( instance );
496 info.m_LibId = newId;
497 symbols.insert( { symbol, info } );
498 }
499 else
500 {
501 it->second.m_Instances.emplace_back( instance );
502 }
503 }
504 }
505
506 matchesProcessed += processSymbols( symbols );
507
509
510 return matchesProcessed;
511}
512
513
515 SYMBOL_CHANGE_INFO>& aSymbols )
516{
517 wxCHECK( !aSymbols.empty(), 0 );
518
519 int matchesProcessed = 0;
520 SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
521 wxString msg;
522
523 wxCHECK( frame, 0 );
524
525 std::map<SCH_SYMBOL*, SYMBOL_CHANGE_INFO> symbols = aSymbols;
526 std::map<SCH_SYMBOL*, SYMBOL_CHANGE_INFO>::iterator it = symbols.begin();
527
528 // Remove all symbols that don't have a valid library symbol link or enough units to
529 // satify the library symbol update.
530 while( it != symbols.end() )
531 {
532 SCH_SYMBOL* symbol = it->first;
533
534 wxCHECK2( symbol && it->second.m_LibId.IsValid(), continue );
535
536 LIB_SYMBOL* libSymbol = frame->GetLibSymbol( it->second.m_LibId );
537
538 if( !libSymbol )
539 {
540 msg = getSymbolReferences( *symbol, it->second.m_LibId );
541 msg << wxT( ": " ) << _( "*** symbol not found ***" );
543 it = symbols.erase( it );
544 continue;
545 }
546
547 std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->Flatten();
548
549 if( flattenedSymbol->GetUnitCount() < symbol->GetUnit() )
550 {
551 msg = getSymbolReferences( *symbol, it->second.m_LibId );
552 msg << wxT( ": " ) << _( "*** new symbol has too few units ***" );
554 it = symbols.erase( it );
555 }
556 else
557 {
558 ++it;
559 }
560 }
561
562 bool appendUndo = false;
563
564 // Removing the symbol needs to be done before the LIB_SYMBOL is changed to prevent stale
565 // library symbols in the schematic file.
566 for( const auto& [ symbol, symbol_change_info ] : symbols )
567 {
568 wxCHECK( symbol && !symbol_change_info.m_Instances.empty(), 0 );
569
570 SCH_SCREEN* screen = symbol_change_info.m_Instances[0].LastScreen();
571
572 wxCHECK( screen, 0 );
573
574 screen->Remove( symbol );
575 frame->SaveCopyInUndoList( screen, symbol, UNDO_REDO::CHANGED, appendUndo );
576 appendUndo = true;
577 }
578
579 for( const auto& [ symbol, symbol_change_info ] : symbols )
580 {
581 if( symbol_change_info.m_LibId != symbol->GetLibId() )
582 symbol->SetLibId( symbol_change_info.m_LibId );
583
584 LIB_SYMBOL* libSymbol = frame->GetLibSymbol( symbol_change_info.m_LibId );
585 std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->Flatten();
586 SCH_SCREEN* screen = symbol_change_info.m_Instances[0].LastScreen();
587
588 symbol->SetLibSymbol( flattenedSymbol.release() );
589
590 if( m_resetAttributes->GetValue() )
591 {
592 symbol->SetIncludeInBom( libSymbol->GetIncludeInBom() );
593 symbol->SetIncludeOnBoard( libSymbol->GetIncludeOnBoard() );
594 }
595
596 bool removeExtras = m_removeExtraBox->GetValue();
597 bool resetVis = m_resetFieldVisibilities->GetValue();
598 bool resetEffects = m_resetFieldEffects->GetValue();
599 bool resetPositions = m_resetFieldPositions->GetValue();
600
601 for( unsigned i = 0; i < symbol->GetFields().size(); ++i )
602 {
603 SCH_FIELD& field = symbol->GetFields()[i];
604 LIB_FIELD* libField = nullptr;
605
606 // Mandatory fields always exist in m_updateFields, but these names can be translated.
607 // so use GetCanonicalName().
609 continue;
610
611 if( i < MANDATORY_FIELDS )
612 libField = libSymbol->GetFieldById( (int) i );
613 else
614 libField = libSymbol->FindField( field.GetName() );
615
616 if( libField )
617 {
618 bool resetText = libField->GetText().IsEmpty() ? m_resetEmptyFields->GetValue()
619 : m_resetFieldText->GetValue();
620
621 if( resetText )
622 {
623 if( i == REFERENCE_FIELD )
624 {
625 for( const SCH_SHEET_PATH& instance : symbol_change_info.m_Instances )
626 {
627 symbol->SetRef( &instance,
628 UTIL::GetRefDesUnannotated( libField->GetText() ) );
629 }
630 }
631 else if( i == VALUE_FIELD )
632 {
633 symbol->SetValueFieldText( UnescapeString( libField->GetText() ) );
634 }
635 else if( i == FOOTPRINT_FIELD )
636 {
637 symbol->SetFootprintFieldText( libField->GetText() );
638 }
639 else
640 {
641 field.SetText( libField->GetText() );
642 }
643 }
644
645 if( resetVis )
646 field.SetVisible( libField->IsVisible() );
647
648 if( resetEffects )
649 {
650 // Careful: the visible bit and position are also set by SetAttributes()
651 bool visible = field.IsVisible();
652 VECTOR2I pos = field.GetPosition();
653
654 field.SetAttributes( *libField );
655
656 field.SetVisible( visible );
657 field.SetPosition( pos );
658 field.SetNameShown( libField->IsNameShown() );
659 field.SetCanAutoplace( libField->CanAutoplace() );
660 }
661
662 if( resetPositions )
663 field.SetTextPos( symbol->GetPosition() + libField->GetTextPos() );
664 }
665 else if( i >= MANDATORY_FIELDS && removeExtras )
666 {
667 symbol->RemoveField( field.GetName() );
668 i--;
669 }
670 }
671
672 std::vector<LIB_FIELD*> libFields;
673 libSymbol->GetFields( libFields );
674
675 for( unsigned i = MANDATORY_FIELDS; i < libFields.size(); ++i )
676 {
677 const LIB_FIELD& libField = *libFields[i];
678
679 if( !alg::contains( m_updateFields, libField.GetCanonicalName() ) )
680 continue;
681
682 if( !symbol->FindField( libField.GetName(), false ) )
683 {
684 wxString fieldName = libField.GetCanonicalName();
685 SCH_FIELD newField( VECTOR2I( 0, 0 ), symbol->GetFieldCount(), symbol,
686 fieldName );
687 SCH_FIELD* schField = symbol->AddField( newField );
688
689 // Careful: the visible bit and position are also set by SetAttributes()
690 schField->SetAttributes( libField );
691 schField->SetText( libField.GetText() );
692 schField->SetTextPos( symbol->GetPosition() + libField.GetTextPos() );
693 }
694
695 if( resetPositions && frame->eeconfig()->m_AutoplaceFields.enable )
696 symbol->AutoAutoplaceFields( screen );
697 }
698
699 symbol->SetSchSymbolLibraryName( wxEmptyString );
700 screen->Append( symbol );
701 frame->GetCanvas()->GetView()->Update( symbol );
702
703 msg = getSymbolReferences( *symbol, symbol_change_info.m_LibId );
704 msg += wxS( ": OK" );
706 matchesProcessed +=1;
707 }
708
709 return matchesProcessed;
710}
711
712
714{
715 wxString msg;
716 wxString references;
717 LIB_ID oldId = aSymbol.GetLibId();
718
719 for( const SCH_SYMBOL_INSTANCE& instance : aSymbol.GetInstanceReferences() )
720 {
721 if( references.IsEmpty() )
722 references = instance.m_Reference;
723 else
724 references += wxT( " " ) + instance.m_Reference;
725 }
726
727 if( m_mode == MODE::UPDATE )
728 {
729 if( aSymbol.GetInstanceReferences().size() == 1 )
730 {
731 msg.Printf( _( "Update symbol %s from '%s' to '%s'" ),
732 references,
733 UnescapeString( oldId.Format() ),
734 UnescapeString( aNewId.Format() ) );
735 }
736 else
737 {
738 msg.Printf( _( "Update symbols %s from '%s' to '%s'" ),
739 references,
740 UnescapeString( oldId.Format() ),
741 UnescapeString( aNewId.Format() ) );
742 }
743 }
744 else
745 {
746 if( aSymbol.GetInstanceReferences().size() == 1 )
747 {
748 msg.Printf( _( "Change symbol %s from '%s' to '%s'" ),
749 references,
750 UnescapeString( oldId.Format() ),
751 UnescapeString( aNewId.Format() ) );
752 }
753 else
754 {
755 msg.Printf( _( "Change symbols %s from '%s' to '%s'" ),
756 references,
757 UnescapeString( oldId.Format() ),
758 UnescapeString( aNewId.Format() ) );
759 }
760 }
761
762 return msg;
763}
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:106
@ small_library
Class DIALOG_CHANGE_SYMBOLS_BASE.
WX_HTML_REPORT_PANEL * m_messagePanel
void onNewLibIDKillFocus(wxFocusEvent &event) override
void onMatchBySelected(wxCommandEvent &aEvent) override
MODE m_mode
Set of field names that should have values updated.
wxString getSymbolReferences(SCH_SYMBOL &aSymbol, const LIB_ID &aNewId)
bool isMatch(SCH_SYMBOL *aSymbol, SCH_SHEET_PATH *aInstance)
void onOkButtonClicked(wxCommandEvent &aEvent) override
std::set< wxString > m_updateFields
void onMatchById(wxCommandEvent &aEvent) override
void launchMatchIdSymbolBrowser(wxCommandEvent &aEvent) override
void onMatchByReference(wxCommandEvent &aEvent) override
void onMatchByValue(wxCommandEvent &aEvent) override
DIALOG_CHANGE_SYMBOLS(SCH_EDIT_FRAME *aParent, SCH_SYMBOL *aSymbol, MODE aMode=MODE::UPDATE)
void onMatchTextKillFocus(wxFocusEvent &event) override
void onMatchIDKillFocus(wxFocusEvent &event) override
int processSymbols(const std::map< SCH_SYMBOL *, SYMBOL_CHANGE_INFO > &aSymbols)
void launchNewIdSymbolBrowser(wxCommandEvent &aEvent) override
void onMatchByAll(wxCommandEvent &aEvent) override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
std::string m_hash_key
Definition: dialog_shim.h:203
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
bool IsSelected() const
Definition: eda_item.h:106
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:208
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
void SetAttributes(const EDA_TEXT &aSrc)
Set the text attributes from another instance.
Definition: eda_text.cpp:266
virtual bool IsVisible() const
Definition: eda_text.h:136
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:373
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:219
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:165
AUTOPLACE_FIELDS m_AutoplaceFields
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:238
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1591
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:66
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...
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:394
Field object used in symbol libraries.
Definition: lib_field.h:61
bool CanAutoplace() const
Definition: lib_field.h:183
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: lib_field.cpp:476
bool IsNameShown() const
Definition: lib_field.h:180
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:485
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:50
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:172
UTF8 Format() const
Definition: lib_id.cpp:117
Define a library symbol object.
Definition: lib_symbol.h:99
LIB_FIELD * GetFieldById(int aId) const
Return pointer to the requested field.
bool GetIncludeOnBoard() const
Definition: lib_symbol.h:649
void GetFields(std::vector< LIB_FIELD * > &aList)
Return a list of fields within this symbol.
LIB_FIELD * FindField(const wxString &aFieldName)
Find a field within this symbol matching aFieldName and returns it or NULL if not found.
bool GetIncludeInBom() const
Definition: lib_symbol.h:641
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:453
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:122
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:86
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
EESCHEMA_SETTINGS * eeconfig() const
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
Schematic editor (Eeschema) main window.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
Create a copy of the current schematic item, and put it in the undo list.
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
VECTOR2I GetPosition() const override
Definition: sch_field.cpp:1068
void SetCanAutoplace(bool aCanPlace)
Definition: sch_field.h:162
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
Definition: sch_field.cpp:836
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:804
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_field.cpp:1048
void SetNameShown(bool aShown=true)
Definition: sch_field.h:159
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Definition: sch_screen.cpp:145
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:109
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:307
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
Schematic symbol object.
Definition: sch_symbol.h:81
int GetUnit() const
Definition: sch_symbol.h:228
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstanceReferences()
Definition: sch_symbol.h:140
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:674
const wxString GetValueFieldText(bool aResolve) const
Definition: sch_symbol.cpp:835
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:175
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:901
void Clear()
return the number of messages matching the given severity mask.
void SetLazyUpdate(bool aLazyUpdate)
Forces updating the HTML page, after the report is built in lazy mode If aSort = true,...
void SetFileName(const wxString &aReportFileName)
void Report(const wxString &aText, SEVERITY aSeverity, REPORTER::LOCATION aLocation=REPORTER::LOC_BODY)
Reports the string.
void Flush(bool aSort=false)
Set the visible severity filter.
bool g_resetFieldEffects[2]
bool g_selectRefDes
bool g_resetFieldPositions[2]
bool g_resetAttributes[2]
bool g_removeExtraFields[2]
bool g_resetFieldVisibilities[2]
bool g_resetEmptyFields[2]
wxString getLibIdValue(const wxTextCtrl *aCtrl)
bool g_resetFieldText[2]
bool g_selectValue
#define _(s)
@ FRAME_SCH_VIEWER_MODAL
Definition: frame_type.h:37
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
wxString GetRefDesUnannotated(const wxString &aSource)
Return an unannotated refdes from either a prefix or an existing refdes.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
Collection of utility functions for component reference designators (refdes)
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_ACTION
std::vector< FAB_LAYER_COLOR > dummy
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.
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_LIBID
Definition: string_utils.h:55
A simple container for schematic symbol instance information.
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
#define DO_TRANSLATE
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
@ SCH_SYMBOL_T
Definition: typeinfo.h:156
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590