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 );
93 if( !libField->IsMandatory() )
94 fieldNames.insert( libField->GetName() );
104 if( !libField->IsMandatory() )
105 fieldNames.insert( libField->GetName() );
114 for(
const wxString& fieldName : fieldNames )
124 for(
unsigned i = 0; i <
m_fieldsBox->GetCount(); ++i )
139 for(
unsigned i = 0; i <
m_fieldsBox->GetCount(); ++i )
145 std::unique_ptr<LIB_SYMBOL> flattenedParent =
m_symbol->
GetParent().lock()->Flatten();
152 std::vector<SCH_FIELD> fields;
153 std::vector<SCH_FIELD> result;
163 parentField = flattenedParent->FindField( field.GetName() );
171 field.SetText( parentField->
GetText() );
175 field.SetVisible( parentField->
IsVisible() );
182 bool visible = field.IsVisible();
185 field.SetAttributes( *parentField );
187 field.SetVisible( visible );
188 field.SetPosition( pos );
192 field.SetTextPos( parentField->
GetTextPos() );
194 else if( removeExtras )
201 result.emplace_back( std::move( field ) );
204 std::vector<SCH_FIELD*> parentFields;
205 int idx = result.size();
207 flattenedParent->GetFields( parentFields );
209 for(
SCH_FIELD* parentField : parentFields )
216 result.emplace_back(
m_symbol, idx++ );
219 newField->
SetName( parentField->GetCanonicalName() );
220 newField->
SetText( parentField->GetText() );
227 commit.
Push(
_(
"Update Symbol Fields" ) );
230 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Modify a given item in the model.
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)
Select or deselect all fields in the listbox widget.
void onOkButtonClicked(wxCommandEvent &aEvent) override
DIALOG_UPDATE_SYMBOL_FIELDS(SYMBOL_EDIT_FRAME *aParent, LIB_SYMBOL *aSymbol)
std::set< wxString > m_updateFields
Set of field names that should have values updated.
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 SetFields(const std::vector< SCH_FIELD > &aFieldsList)
Overwrite all the existing fields in this symbol with fields supplied in aFieldsList.
void GetFields(std::vector< SCH_FIELD * > &aList, bool aVisibleOnly=false) override
Return a list of fields within this symbol.
void CopyFields(std::vector< SCH_FIELD > &aList)
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
Execute the changes.
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)
wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI)
Return a default symbol field name for field aFieldNdx for all components.
@ MANDATORY_FIELD_COUNT
The first 5 are mandatory, and must be instantiated in SCH_COMPONENT, LIB_PART, and FOOTPRINT constru...