41 m_editFrame( aParent ),
85 std::vector<SCH_FIELD*> libFields;
86 std::set<wxString> fieldNames;
87 std::unique_ptr<LIB_SYMBOL> flattenedParent =
m_symbol->
GetParent().lock()->Flatten();
89 flattenedParent->GetFields( libFields );
92 fieldNames.insert( libFields[i]->GetName() );
100 fieldNames.insert( libFields[i]->GetName() );
108 for(
const wxString& fieldName : fieldNames )
118 for(
unsigned i = 0; i <
m_fieldsBox->GetCount(); ++i )
133 for(
unsigned i = 0; i <
m_fieldsBox->GetCount(); ++i )
139 std::unique_ptr<LIB_SYMBOL> flattenedParent =
m_symbol->
GetParent().lock()->Flatten();
146 std::vector<SCH_FIELD> fields;
147 std::vector<SCH_FIELD> result;
157 parentField = flattenedParent->FindField( field.GetName() );
165 field.SetText( parentField->
GetText() );
169 field.SetVisible( parentField->
IsVisible() );
176 bool visible = field.IsVisible();
179 field.SetAttributes( *parentField );
181 field.SetVisible( visible );
182 field.SetPosition( pos );
186 field.SetTextPos( parentField->
GetTextPos() );
188 else if( removeExtras )
195 result.emplace_back( std::move( field ) );
198 std::vector<SCH_FIELD*> parentFields;
199 int idx = result.size();
201 flattenedParent->GetFields( parentFields );
203 for(
SCH_FIELD* parentField : parentFields )
210 result.emplace_back(
m_symbol, idx++ );
213 newField->
SetName( parentField->GetCanonicalName() );
214 newField->
SetText( parentField->GetText() );
221 commit.
Push(
_(
"Update Symbol Fields" ) );
224 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
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...
Class DIALOG_UPDATE_SYMBOL_FIELDS_BASE.
wxCheckBox * m_resetFieldText
wxCheckBox * m_resetFieldEffects
wxCheckBox * m_resetFieldPositions
wxTextCtrl * m_parentSymbolReadOnly
wxCheckBox * m_resetEmptyFields
wxCheckBox * m_resetFieldVisibilities
wxCheckListBox * m_fieldsBox
wxCheckBox * m_removeExtraBox
~DIALOG_UPDATE_SYMBOL_FIELDS() override
void checkAll(bool aCheck)
void onOkButtonClicked(wxCommandEvent &aEvent) override
DIALOG_UPDATE_SYMBOL_FIELDS(SYMBOL_EDIT_FRAME *aParent, LIB_SYMBOL *aSymbol)
LIB_SYMBOL * m_symbol
Set of field names that should have values updated.
std::set< wxString > m_updateFields
SYMBOL_EDIT_FRAME * m_editFrame
const VECTOR2I & GetTextPos() const
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual bool IsVisible() const
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
Define a library symbol object.
void GetFields(std::vector< SCH_FIELD * > &aList)
Return a list of fields within this symbol.
void SetFields(const std::vector< SCH_FIELD > &aFieldsList)
Overwrite all the existing fields in this symbol with fields supplied in aFieldsList.
SCH_FIELD * FindField(const wxString &aFieldName, bool aCaseInsensitive=false)
Find a field within this symbol matching aFieldName and returns it or NULL if not found.
LIB_SYMBOL_REF & GetParent()
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
void SetName(const wxString &aName)
void SetText(const wxString &aText) override
The symbol library editor main window.
bool g_removeExtraLibFields
bool g_resetLibFieldEffects
bool g_resetLibFieldVisibilities
bool g_resetLibFieldPositions
bool g_resetEmptyLibFields
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
@ MANDATORY_FIELDS
The first 5 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.