68 m_matchAll->SetLabel(
_(
"Change all symbols in schematic" ) );
69 SetTitle(
_(
"Change Symbols" ) );
97 m_matchById->SetLabel(
_(
"Change symbols matching library identifier:" ) );
160 { wxID_CANCEL,
_(
"Close" ) } } );
239 wxString rawValue = aCtrl->GetValue();
241 wxString libName = rawValue.BeforeFirst(
':', &itemName );
253 if( frame->ShowModal( &newName,
this ) )
270 if( frame->ShowModal( &newName,
this ) )
288 std::vector<SCH_FIELD*> fields;
289 std::vector<SCH_FIELD*> libFields;
290 std::set<wxString> fieldNames;
296 wxCHECK2( screen,
continue );
302 wxCHECK2( symbol,
continue );
304 if( !
isMatch( symbol, &instance ) )
311 fieldNames.insert( fields[i]->GetName() );
319 std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->
Flatten();
321 flattenedSymbol->GetFields( libFields );
324 fieldNames.insert( libFields[i]->GetName() );
345 std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->
Flatten();
347 flattenedSymbol->GetFields( libFields );
350 fieldNames.insert( libFields[i]->GetName() );
358 wxArrayInt checkedItems;
359 wxArrayString checkedNames;
363 for(
int ii : checkedItems )
364 checkedNames.push_back(
m_fieldsBox->GetString( ii ) );
366 bool allChecked =
true;
368 for(
unsigned ii = 0; ii <
m_fieldsBox->GetCount(); ++ii )
380 for(
const wxString& fieldName : fieldNames )
392 for(
unsigned i = 0; i <
m_fieldsBox->GetCount(); ++i )
413 for(
unsigned i = 0; i <
m_fieldsBox->GetCount(); ++i )
440 wxCHECK( aSymbol,
false );
444 wxCHECK( frame,
false );
480 wxCHECK( frame,
false );
484 int matchesProcessed = 0;
495 std::map<SCH_SYMBOL*, SYMBOL_CHANGE_INFO> symbols;
501 wxCHECK2( screen,
continue );
508 wxCHECK2( symbol,
continue );
510 if( !
isMatch( symbol, &instance ) )
516 auto it = symbols.find( symbol );
518 if( it == symbols.end() )
522 info.m_Instances.emplace_back( instance );
523 info.m_LibId = newId;
524 symbols.insert( { symbol,
info } );
528 it->second.m_Instances.emplace_back( instance );
533 if( symbols.size() > 0 )
541 return matchesProcessed;
549 wxCHECK( !aSymbols.empty(), 0 );
551 int matchesProcessed = 0;
557 std::map<SCH_SYMBOL*, SYMBOL_CHANGE_INFO> symbols = aSymbols;
558 std::map<SCH_SYMBOL*, SYMBOL_CHANGE_INFO>::iterator it = symbols.begin();
562 while( it != symbols.end() )
566 wxCHECK2( symbol && it->second.m_LibId.IsValid(),
continue );
573 msg << wxT(
": " ) <<
_(
"*** symbol not found ***" );
575 it = symbols.erase( it );
579 std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->
Flatten();
581 if( flattenedSymbol->GetUnitCount() < symbol->
GetUnit() )
584 msg << wxT(
": " ) <<
_(
"*** new symbol has too few units ***" );
586 it = symbols.erase( it );
596 for(
const auto& [ symbol, symbol_change_info ] : symbols )
598 wxCHECK( symbol && !symbol_change_info.m_Instances.empty(), 0 );
600 SCH_SCREEN* screen = symbol_change_info.m_Instances[0].LastScreen();
602 wxCHECK( screen, 0 );
606 aCommit->
Modified( symbol, symbol_copy, screen );
614 if( connectionGraph )
618 for(
const auto& [ symbol, symbol_change_info ] : symbols )
621 wxString initialLibLinkName =
UnescapeString( symbol->GetLibId().Format() );
623 if( symbol_change_info.m_LibId != symbol->GetLibId() )
624 symbol->SetLibId( symbol_change_info.m_LibId );
627 std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->
Flatten();
628 SCH_SCREEN* screen = symbol_change_info.m_Instances[0].LastScreen();
630 symbol->SetLibSymbol( flattenedSymbol.release() );
636 symbol->SetExcludedFromSim( symbol->GetLibSymbolRef()->GetExcludedFromSim() );
637 symbol->SetExcludedFromBOM( symbol->GetLibSymbolRef()->GetExcludedFromBOM() );
638 symbol->SetExcludedFromBoard( symbol->GetLibSymbolRef()->GetExcludedFromBoard() );
643 symbol->SetShowPinNames( symbol->GetLibSymbolRef()->GetShowPinNames() );
644 symbol->SetShowPinNumbers( symbol->GetLibSymbolRef()->GetShowPinNumbers() );
652 for(
unsigned i = 0; i < symbol->GetFields().size(); ++i )
654 SCH_FIELD& field = symbol->GetFields()[i];
663 libField = symbol->GetLibSymbolRef()->GetFieldById( (
int) i );
665 libField = symbol->GetLibSymbolRef()->FindField( field.
GetName() );
678 for(
const SCH_SHEET_PATH& instance : symbol_change_info.m_Instances )
680 wxString ref = symbol->GetRef( &instance );
684 ref.Printf( wxS(
"%s%d" ), prefix, number );
688 symbol->SetRef( &instance, ref );
694 || !symbol->IsPower() )
699 symbol->SetFootprintFieldText( libField->
GetText() );
729 symbol->RemoveField( field.
GetName() );
734 std::vector<SCH_FIELD*> libFields;
735 symbol->GetLibSymbolRef()->GetFields( libFields );
739 const SCH_FIELD& libField = *libFields[i];
744 if( !symbol->FindField( libField.
GetName(),
false ) )
749 SCH_FIELD* schField = symbol->AddField( newField );
758 symbol->AutoAutoplaceFields( screen );
761 symbol->SetSchSymbolLibraryName( wxEmptyString );
765 symbol->AutoAutoplaceFields( screen );
770 msg += wxS(
": OK" );
772 matchesProcessed +=1;
775 return matchesProcessed;
781 const wxString* aOldLibLinkName )
787 wxString oldLibLinkName;
789 if( aOldLibLinkName )
790 oldLibLinkName = *aOldLibLinkName;
796 wxCHECK( parent, msg );
803 if( !sheets.
HasPath( instance.m_Path ) )
806 if( references.IsEmpty() )
807 references = instance.m_Reference;
809 references += wxT(
" " ) + instance.m_Reference;
816 msg.Printf(
_(
"Update symbol %s from '%s' to '%s'" ),
823 msg.Printf(
_(
"Update symbols %s from '%s' to '%s'" ),
833 msg.Printf(
_(
"Change symbol %s from '%s' to '%s'" ),
840 msg.Printf(
_(
"Change symbols %s from '%s' to '%s'" ),
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
COMMIT & Modified(EDA_ITEM *aItem, EDA_ITEM *aCopy, BASE_SCREEN *aScreen=nullptr)
Calculate the connectivity of a schematic and generates netlists.
void ExchangeItem(SCH_ITEM *aOldItem, SCH_ITEM *aNewItem)
Replace all references to #aOldItem with #aNewItem in the graph.
Class DIALOG_CHANGE_SYMBOLS_BASE.
wxCheckListBox * m_fieldsBox
STD_BITMAP_BUTTON * m_newIdBrowserButton
wxTextCtrl * m_specifiedValue
wxCheckBox * m_removeExtraBox
wxCheckBox * m_resetCustomPower
wxRadioButton * m_matchBySelection
wxCheckBox * m_resetFieldPositions
wxRadioButton * m_matchByValue
wxRadioButton * m_matchByReference
wxCheckBox * m_resetFieldEffects
wxCheckBox * m_resetFieldText
wxStaticBoxSizer * m_updateFieldsSizer
wxCheckBox * m_resetAttributes
wxTextCtrl * m_specifiedReference
wxGridBagSizer * m_matchSizer
WX_HTML_REPORT_PANEL * m_messagePanel
wxCheckBox * m_resetFieldVisibilities
wxTextCtrl * m_specifiedId
wxRadioButton * m_matchById
wxCheckBox * m_resetEmptyFields
wxBoxSizer * m_newIdSizer
wxCheckBox * m_resetPinTextVisibility
wxRadioButton * m_matchAll
STD_BITMAP_BUTTON * m_matchIdBrowserButton
void onNewLibIDKillFocus(wxFocusEvent &event) override
void onMatchBySelected(wxCommandEvent &aEvent) override
MODE m_mode
Set of field names that should have values updated.
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() override
int processMatchingSymbols(SCH_COMMIT *aCommit)
DIALOG_CHANGE_SYMBOLS(SCH_EDIT_FRAME *aParent, SCH_SYMBOL *aSymbol, MODE aMode=MODE::UPDATE)
void checkAll(bool aCheck)
void onMatchTextKillFocus(wxFocusEvent &event) override
void onMatchIDKillFocus(wxFocusEvent &event) override
wxString getSymbolReferences(SCH_SYMBOL &aSymbol, const LIB_ID &aNewId, const wxString *aOldLibLinkName=nullptr)
void launchNewIdSymbolBrowser(wxCommandEvent &aEvent) override
void onMatchByAll(wxCommandEvent &aEvent) override
int processSymbols(SCH_COMMIT *aCommit, const std::map< SCH_SYMBOL *, SYMBOL_CHANGE_INFO > &aSymbols)
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
const VECTOR2I & GetTextPos() const
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual bool IsVisible() const
void SetTextPos(const VECTOR2I &aPoint)
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
virtual void SetVisible(bool aVisible)
AUTOPLACE_FIELDS m_AutoplaceFields
EE_TYPE OfType(KICAD_T aType) const
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...
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.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
A logical library item identifier and consists of various portions much like a URI.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
bool IsValid() const
Check if this LID_ID is valid.
Define a library symbol object.
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
SCH_SHEET_PATH & CurrentSheet() const override
CONNECTION_GRAPH * ConnectionGraph() const override
SCH_SHEET_LIST BuildUnorderedSheetList() const
SCH_SHEET_LIST BuildSheetListSortedByPageNumbers() const override
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.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
Schematic editor (Eeschema) main window.
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
VECTOR2I GetPosition() const override
void SetCanAutoplace(bool aCanPlace)
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetPosition(const VECTOR2I &aPosition) override
bool CanAutoplace() const
void SetText(const wxString &aText) override
void SetNameShown(bool aShown=true)
Base class for any item which can be embedded within the SCHEMATIC container class,...
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
SCHEMATIC * Schematic() const
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
bool HasPath(const KIID_PATH &aPath) const
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.
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
const LIB_ID & GetLibId() const override
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
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_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_resetCustomPower[2]
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.
wxString GetRefDesUnannotated(const wxString &aSource)
Return an unannotated refdes from either a prefix or an existing refdes.
int GetRefDesNumber(const wxString &aRefDes)
Get the numeric suffix from a refdes - e.g.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Collection of utility functions for component reference designators (refdes)
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:...
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
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.
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 5 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
VECTOR2< int32_t > VECTOR2I