32 m_editFrame( aParent ),
59 std::vector<SCH_FIELD*> libFields;
60 std::set<wxString> fieldNames;
61 std::unique_ptr<LIB_SYMBOL> flattenedParent =
m_symbol->
GetParent().lock()->Flatten();
63 flattenedParent->GetFields( libFields );
67 if( !libField->IsMandatory() )
68 fieldNames.insert( libField->GetName() );
78 if( !libField->IsMandatory() )
79 fieldNames.insert( libField->GetName() );
82 auto isMandatoryField =
83 [&](
int listbox_idx )
97 for(
int i = (
int)
m_fieldsBox->GetCount() - 1; i >= 0; --i )
99 if( !isMandatoryField( i ) )
103 for(
const wxString& fieldName : fieldNames )
106 for(
int i = 0; i < (int)
m_fieldsBox->GetCount(); ++i )
108 if( !isMandatoryField( i ) )
116 for(
unsigned i = 0; i <
m_fieldsBox->GetCount(); ++i )
131 for(
unsigned i = 0; i <
m_fieldsBox->GetCount(); ++i )
137 std::unique_ptr<LIB_SYMBOL> flattenedParent =
m_symbol->
GetParent().lock()->Flatten();
144 std::vector<SCH_FIELD> fields;
145 std::vector<SCH_FIELD> result;
155 if( field.IsMandatory() )
156 parentField = flattenedParent->GetField( field.GetId() );
158 parentField = flattenedParent->GetField( field.GetName() );
166 field.SetText( parentField->
GetText() );
170 field.SetVisible( parentField->
IsVisible() );
177 bool visible = field.IsVisible();
180 field.SetAttributes( *parentField );
182 field.SetVisible( visible );
183 field.SetPosition( pos );
187 field.SetTextPos( parentField->
GetTextPos() );
189 else if( removeExtras )
196 result.emplace_back( std::move( field ) );
199 std::vector<SCH_FIELD*> parentFields;
201 flattenedParent->GetFields( parentFields );
203 for(
SCH_FIELD* parentField : parentFields )
210 result.emplace_back(
m_symbol, FIELD_T::USER );
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, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
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
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
std::map< FIELD_T, int > m_mandatoryFieldListIndexes
Index in the list control for each MANDATORY_FIELD type.
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, bool aVisibleOnly=false) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
void SetFields(const std::vector< SCH_FIELD > &aFieldsList)
Overwrite all the existing fields in this symbol with fields supplied in aFieldsList.
SCH_FIELD * GetField(const wxString &aFieldName)
Find a field within this symbol matching aFieldName; return nullptr if not found.
void CopyFields(std::vector< SCH_FIELD > &aList)
Create a copy of the SCH_FIELDs, sorted in ordinal order.
LIB_SYMBOL_REF & GetParent()
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
void SetName(const wxString &aName)
void SetText(const wxString &aText) override
The symbol library editor main window.
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(FIELD_T aFieldId, bool aTranslateForHI)
Return a default symbol field name for a mandatory field type.
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...