64 m_matchAll->SetLabel(
_(
"Change all symbols in schematic" ) );
65 SetTitle(
_(
"Change Symbols" ) );
93 m_matchById->SetLabel(
_(
"Change symbols matching library identifier:" ) );
155 { wxID_CANCEL,
_(
"Close" ) } } );
233 wxString rawValue = aCtrl->GetValue();
235 wxString libName = rawValue.BeforeFirst(
':', &itemName );
282 std::vector<SCH_FIELD*> fields;
283 std::vector<LIB_FIELD*> libFields;
284 std::set<wxString> fieldNames;
290 wxCHECK2( screen,
continue );
296 wxCHECK2( symbol,
continue );
298 if( !
isMatch( symbol, &instance ) )
305 fieldNames.insert( fields[i]->GetName() );
313 std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->
Flatten();
315 flattenedSymbol->GetFields( libFields );
318 fieldNames.insert( libFields[i]->GetName() );
339 std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->
Flatten();
341 flattenedSymbol->GetFields( libFields );
344 fieldNames.insert( libFields[i]->GetName() );
355 for(
const wxString& fieldName : fieldNames )
365 for(
unsigned i = 0; i <
m_fieldsBox->GetCount(); ++i )
384 for(
unsigned i = 0; i <
m_fieldsBox->GetCount(); ++i )
412 wxCHECK( aSymbol,
false );
416 wxCHECK( frame,
false );
429 aSymbol->
GetRef( aInstance,
false ),
false );
452 wxCHECK( frame,
false );
456 int matchesProcessed = 0;
468 std::map<SCH_SYMBOL*, SYMBOL_CHANGE_INFO> symbols;
474 wxCHECK2( screen,
continue );
481 wxCHECK2( symbol,
continue );
483 if( !
isMatch( symbol, &instance ) )
489 auto it = symbols.find( symbol );
491 if( it == symbols.end() )
495 info.m_Instances.emplace_back( instance );
496 info.m_LibId = newId;
497 symbols.insert( { symbol,
info } );
501 it->second.m_Instances.emplace_back( instance );
510 return matchesProcessed;
517 wxCHECK( !aSymbols.empty(), 0 );
519 int matchesProcessed = 0;
525 std::map<SCH_SYMBOL*, SYMBOL_CHANGE_INFO> symbols = aSymbols;
526 std::map<SCH_SYMBOL*, SYMBOL_CHANGE_INFO>::iterator it = symbols.begin();
530 while( it != symbols.end() )
534 wxCHECK2( symbol && it->second.m_LibId.IsValid(),
continue );
541 msg << wxT(
": " ) <<
_(
"*** symbol not found ***" );
543 it = symbols.erase( it );
547 std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->
Flatten();
549 if( flattenedSymbol->GetUnitCount() < symbol->
GetUnit() )
552 msg << wxT(
": " ) <<
_(
"*** new symbol has too few units ***" );
554 it = symbols.erase( it );
562 bool appendUndo =
false;
566 for(
const auto& [ symbol, symbol_change_info ] : symbols )
568 wxCHECK( symbol && !symbol_change_info.m_Instances.empty(), 0 );
570 SCH_SCREEN* screen = symbol_change_info.m_Instances[0].LastScreen();
572 wxCHECK( screen, 0 );
579 for(
const auto& [ symbol, symbol_change_info ] : symbols )
581 if( symbol_change_info.m_LibId != symbol->GetLibId() )
582 symbol->SetLibId( 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();
588 symbol->SetLibSymbol( flattenedSymbol.release() );
601 for(
unsigned i = 0; i < symbol->GetFields().size(); ++i )
603 SCH_FIELD& field = symbol->GetFields()[i];
625 for(
const SCH_SHEET_PATH& instance : symbol_change_info.m_Instances )
627 symbol->SetRef( &instance,
637 symbol->SetFootprintFieldText( libField->
GetText() );
667 symbol->RemoveField( field.
GetName() );
672 std::vector<LIB_FIELD*> libFields;
677 const LIB_FIELD& libField = *libFields[i];
682 if( !symbol->FindField( libField.
GetName(),
false ) )
687 SCH_FIELD* schField = symbol->AddField( newField );
696 symbol->AutoAutoplaceFields( screen );
699 symbol->SetSchSymbolLibraryName( wxEmptyString );
704 msg += wxS(
": OK" );
706 matchesProcessed +=1;
709 return matchesProcessed;
721 if( references.IsEmpty() )
722 references = instance.m_Reference;
724 references += wxT(
" " ) + instance.m_Reference;
731 msg.Printf(
_(
"Update symbol %s from '%s' to '%s'" ),
738 msg.Printf(
_(
"Update symbols %s from '%s' to '%s'" ),
748 msg.Printf(
_(
"Change symbol %s from '%s' to '%s'" ),
755 msg.Printf(
_(
"Change symbols %s from '%s' to '%s'" ),
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Class DIALOG_CHANGE_SYMBOLS_BASE.
wxBitmapButton * m_newIdBrowserButton
wxCheckListBox * m_fieldsBox
wxTextCtrl * m_specifiedValue
wxBitmapButton * m_matchIdBrowserButton
wxCheckBox * m_removeExtraBox
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
wxRadioButton * m_matchAll
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)
int processMatchingSymbols()
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
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
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={})
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.
void SetAttributes(const EDA_TEXT &aSrc)
Set the text attributes from another instance.
virtual bool IsVisible() const
void SetTextPos(const VECTOR2I &aPoint)
virtual void SetVisible(bool aVisible)
virtual void SetText(const wxString &aText)
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.
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.
Field object used in symbol libraries.
bool CanAutoplace() const
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
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.
LIB_FIELD * GetFieldById(int aId) const
Return pointer to the requested field.
bool GetIncludeOnBoard() const
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
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
SCH_SHEET_PATH & CurrentSheet() const override
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
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,...
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
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.
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.
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstanceReferences()
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
const wxString GetValueFieldText(bool aResolve) const
const LIB_ID & GetLibId() const
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
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)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
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.
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:...
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 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".