41 m_editFrame( aParent ),
86 std::vector<SCH_FIELD*> libFields;
87 std::set<wxString> fieldNames;
88 std::unique_ptr<LIB_SYMBOL> flattenedParent =
m_symbol->
GetParent().lock()->Flatten();
90 flattenedParent->GetFields( libFields );
94 if( !libField->IsMandatory() )
95 fieldNames.insert( libField->GetName() );
105 if( !libField->IsMandatory() )
106 fieldNames.insert( libField->GetName() );
109 auto isMandatoryField =
110 [&](
int listbox_idx )
124 for(
int i = (
int)
m_fieldsBox->GetCount() - 1; i >= 0; --i )
126 if( !isMandatoryField( i ) )
130 for(
const wxString& fieldName : fieldNames )
133 for(
int i = 0; i < (int)
m_fieldsBox->GetCount(); ++i )
135 if( !isMandatoryField( i ) )
143 for(
unsigned i = 0; i <
m_fieldsBox->GetCount(); ++i )
158 for(
unsigned i = 0; i <
m_fieldsBox->GetCount(); ++i )
164 std::unique_ptr<LIB_SYMBOL> flattenedParent =
m_symbol->
GetParent().lock()->Flatten();
171 std::vector<SCH_FIELD> fields;
172 std::vector<SCH_FIELD> result;
182 if( field.IsMandatory() )
183 parentField = flattenedParent->GetField( field.GetId() );
185 parentField = flattenedParent->GetField( field.GetName() );
193 field.SetText( parentField->
GetText() );
197 field.SetVisible( parentField->
IsVisible() );
204 bool visible = field.IsVisible();
207 field.SetAttributes( *parentField );
209 field.SetVisible( visible );
210 field.SetPosition( pos );
214 field.SetTextPos( parentField->
GetTextPos() );
216 else if( removeExtras )
223 result.emplace_back( std::move( field ) );
226 std::vector<SCH_FIELD*> parentFields;
228 flattenedParent->GetFields( parentFields );
230 for(
SCH_FIELD* parentField : parentFields )
237 result.emplace_back(
m_symbol, FIELD_T::USER );
240 newField->
SetName( parentField->GetCanonicalName() );
241 newField->
SetText( parentField->GetText() );
248 commit.
Push(
_(
"Update Symbol Fields" ) );
251 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
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 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(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...