67 std::set<LIB_SYMBOL*> visited;
92 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
93 m_libEntry->AppendParentEmbeddedFiles( embeddedFilesStack );
107 [
this](
const wxString& aFootprintName )
119 m_grid->OverrideMinSize( 1.0, 1.0 );
121 [&]( wxCommandEvent& aEvent )
125 m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
128 std::vector<SCH_FIELD> fields;
134 if( std::shared_ptr<LIB_SYMBOL> parent =
m_libEntry->GetParent().lock() )
137 int minWidth = wxSystemSettings::GetMetric( wxSYS_VSCROLL_X );
139 for(
int ii = 0; ii <= 7; ++ii )
141 if(
m_grid->IsColShown( ii ) )
142 minWidth +=
m_grid->GetColSize( ii );
145 m_grid->SetMinSize( wxSize( minWidth, -1 ) );
149 m_grid->SetColSize( 13, 48 );
150 m_grid->SetColSize( 14, 136 );
151 m_grid->SetColSize( 15, 62 );
152 m_grid->SetupColumnAutosizer( 1 );
154 m_grid->ShowHideColumns(
"0 1 2 3 4 5 6 7" );
163 [
this]( wxCommandEvent& aEvent )
174 [
this]( wxCommandEvent& aEvent )
224 m_grid->GetParent()->Layout();
237 for(
size_t page = 0; page <
m_NoteBook->GetPageCount(); ++page )
260 m_grid->PopEventHandler(
true );
269 if( std::shared_ptr<LIB_SYMBOL> ancestor = aParent->GetParent().lock() )
273 std::vector<SCH_FIELD*> parentFields;
274 aParent->GetFields( parentFields );
276 for(
SCH_FIELD* parentField : parentFields )
279 if( parentField->IsMandatory() && parentField->GetText().IsEmpty() )
284 for(
size_t ii = 0; ii <
m_fields->size(); ++ii )
289 if( parentField->IsMandatory() )
290 match = field.
GetId() == parentField->GetId();
302 if( !found && !parentField->IsMandatory() )
310 if( !wxDialog::TransferDataToWindow() )
313 std::set<wxString> defined;
316 defined.insert( field.GetName() );
320 Pgm().GetCommonSettings()->m_FieldNameTemplates.GetTemplateFieldNames( TEMPLATES::SCOPE::GLOBAL ) )
322 if( defined.count( templateFieldname.m_Name ) <= 0 )
325 field.
SetVisible( templateFieldname.m_Visible );
335 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
m_fields->GetNumberRows() );
336 m_grid->ProcessTableMessage( msg );
344 auto hasOwnKeyWords = [](
const LIB_SYMBOL& aSymbol )
346 return !aSymbol.GetRawKeyWords().IsEmpty();
365 std::shared_ptr<LIB_SYMBOL> root =
m_libEntry->GetRootSymbol();
366 const std::map<int, wxString>& unitNames = root->GetUnitDisplayNames();
368 for(
int unit = 0; unit <
m_libEntry->GetUnitCount(); unit++ )
370 if( unitNames.contains( unit + 1 ) )
419 wxArrayString fpFilters =
m_libEntry->GetFPFilters();
420 wxString fpFiltersSource;
426 auto hasOwnFilters = [](
const LIB_SYMBOL& aSymbol )
428 return !aSymbol.GetRawFPFilters().IsEmpty();
441 std::set<wxString> availablePins;
444 availablePins.insert(
pin->GetNumber() );
450 for(
const wxString& pinNumber :
group.GetNames() )
452 if( !groupTxt.IsEmpty() )
455 groupTxt << pinNumber;
465 wxArrayString symbolNames;
466 wxString libName =
m_libEntry->GetLibNickname();
468 if( !libName.empty() )
470 m_Parent->GetLibManager().GetSymbolNames( libName, symbolNames );
473 symbolNames.Sort( [](
const wxString& a,
const wxString& b ) ->
int
479 if( symbolNames.Index(
m_libEntry->GetName() ) != wxNOT_FOUND )
484 wxArrayString descendants;
485 m_Parent->GetLibManager().GetDerivedSymbolNames(
m_libEntry->GetName(), libName, descendants );
487 for(
const wxString& descendant : descendants )
489 if( symbolNames.Index( descendant ) != wxNOT_FOUND )
490 symbolNames.Remove( descendant );
495 if( std::shared_ptr<LIB_SYMBOL> rootSymbol =
m_libEntry->GetParent().lock() )
500 if( selection != wxNOT_FOUND )
512 m_grid->SetMinVisibleRows(
this, 4 );
523 for(
size_t page = 0; page <
m_NoteBook->GetPageCount(); ++page )
527 targetPage = (int) page;
541 if( !
m_grid->CommitPendingChanges() )
565 for(
int ii = 0; ii < (int)
m_fields->size(); ++ii )
572 wxString fieldName = field.
GetName(
false );
574 if( fieldName.IsEmpty() && !field.
GetText().IsEmpty() )
594 if( parentName.IsEmpty() )
604 std::set<wxString> seenSubRefs;
610 if( subRef.IsEmpty() )
618 if( !seenSubRefs.insert( subRef.Upper() ).second )
635 if( !
IsOK(
this,
_(
"Delete extra units from symbol?" ) ) )
639 int bodyStyleCount = 0;
667 if( bodyStyleCount < m_libEntry->GetBodyStyleCount() )
669 if( !
IsOK(
this,
_(
"Delete extra body styles from symbol?" ) ) )
679 if( !
m_grid->CommitPendingChanges()
692 if( newName.IsEmpty() )
694 wxMessageBox(
_(
"Symbol must have a name." ) );
700 if( oldName != newName )
702 wxString libName =
m_libEntry->GetLibNickname();
704 if( !libName.empty() &&
m_Parent->GetLibManager().SymbolNameInUse( newName, libName ) )
706 DisplayErrorMessage(
this, wxString::Format(
_(
"Symbol name '%s' already in use in library '%s'." ),
721 if( editingCurrentSymbol )
726 std::vector<SCH_FIELD> fieldsToSave;
729 for(
size_t ii = 0; ii <
m_fields->size(); ++ii )
745 emptyField.
SetText( wxEmptyString );
746 fieldsToSave.push_back( emptyField );
752 if( field.
GetText().IsEmpty() )
757 else if( fieldName.IsEmpty() )
762 fieldsToSave.push_back( field );
771 wxString libName =
m_libEntry->GetLibNickname();
777 wxCHECK( newParent,
false );
804 m_libEntry->SetBodyStyleCount( 1,
false,
false );
805 m_libEntry->SetHasDeMorganBodyStyles(
false );
810 m_libEntry->SetBodyStyleCount( 2,
false,
true );
816 std::vector<wxString> bodyStyleNames;
824 m_libEntry->SetBodyStyleCount( bodyStyleNames.size(),
true,
true );
825 m_libEntry->SetHasDeMorganBodyStyles(
false );
826 m_libEntry->SetBodyStyleNames( bodyStyleNames );
855 m_libEntry->SetPinNameOffset( offset == 0 ? 20 : offset );
872 wxStringTokenizer tokenizer(
m_jumperGroupsGrid->GetCellValue( ii, 0 ),
", \t\r\n", wxTOKEN_STRTOK );
873 std::set<wxString> names;
875 while( tokenizer.HasMoreTokens() )
877 wxString token = tokenizer.GetNextToken();
879 if( token.IsEmpty() )
884 DisplayErrorMessage(
this, wxString::Format(
_(
"Pin '%s' in jumper pin group %d does not exist "
891 names.insert( token );
904 if( editingCurrentSymbol )
905 m_Parent->UpdateAfterSymbolProperties( &oldName );
919 if( !
pin->GetAlternates().empty() )
920 pinNumbersWithAlternates.
insert(
pin->GetNumber() );
923 if( pinNumbersWithAlternates.
size() )
926 wxString::Format(
_(
"(Pins %s.)" ), pinNumbersWithAlternates.
GetSummary() ) );
941 wxPoint pos = aEvent.GetPosition();
942 wxPoint unscolled_pos =
m_grid->CalcUnscrolledPosition( pos );
943 int row =
m_grid->YToRow( unscolled_pos.y );
944 int col =
m_grid->XToCol( unscolled_pos.x );
946 if( row == wxNOT_FOUND || col == wxNOT_FOUND || !
m_fields->IsInherited( row ) )
952 m_grid->SetToolTip( wxString::Format(
_(
"This field is inherited from '%s'." ),
m_fields->InheritedFrom( row ) ) );
958 wxGridCellEditor*
editor =
m_grid->GetCellEditor( event.GetRow(), event.GetCol() );
959 wxControl* control =
editor->GetControl();
961 if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) )
970 else if( event.GetCol() ==
FDC_NAME )
972 wxString newName =
event.GetString();
974 for(
int i = 0; i <
m_grid->GetNumberRows(); ++i )
976 if( i == event.GetRow() )
981 DisplayErrorMessage(
this, wxString::Format(
_(
"The name '%s' is already in use." ), newName ) );
1030 [&]() -> std::pair<int, int>
1042 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
1043 m_grid->ProcessTableMessage( msg );
1056 if( row < m_fields->GetMandatoryRowCount() )
1059 m_fields->GetMandatoryRowCount() ) );
1071 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
1072 m_grid->ProcessTableMessage( msg );
1084 return row >
m_fields->GetMandatoryRowCount();
1088 m_fields->SwapRows( row, row - 1 );
1100 return row >=
m_fields->GetMandatoryRowCount();
1104 m_fields->SwapRows( row, row + 1 );
1114 [&]() -> std::pair<int, int>
1160 if( !
m_grid->CommitPendingChanges() )
1163 m_grid->ClearSelection();
1165 std::vector<SCH_FIELD> fields;
1168 fields.emplace_back( field );
1176 for(
const SCH_FIELD& editedField : fields )
1182 if( existingField.GetName() == editedField.GetName() )
1185 existingField.SetText( editedField.GetText() );
1192 m_fields->emplace_back( editedField );
1193 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
1194 m_grid->ProcessTableMessage( msg );
1199 for(
int ii = (
int)
m_fields->size() - 1; ii >= 0; --ii )
1206 if( editedField.GetName() == existingField.
GetName() )
1215 m_grid->ClearSelection();
1221 wxGridTableMessage msg(
m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, ii, 1 );
1222 m_grid->ProcessTableMessage( msg );
1267 std::bitset<64> shownColumns =
m_grid->GetShownColumns();
1273 if( !
m_grid->IsCellEditControlShown() )
1274 m_grid->SetGridWidthsDirty();
1304 textEntry->SelectAll();
1433 for(
int row =
m_unitNamesGrid->GetNumberRows() - needed; row < m_unitNamesGrid->GetNumberRows(); ++row )
1472 if( !
m_grid->CommitPendingChanges() )
1480 [&]() -> std::pair<int, int>
constexpr EDA_IU_SCALE schIUScale
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
wxBoxSizer * bPinMapPageSizer
WX_GRID * m_jumperGroupsGrid
STD_BITMAP_BUTTON * m_bpAddBodyStyle
wxButton * m_spiceFieldsButton
STD_BITMAP_BUTTON * m_bpAddJumperGroup
DIALOG_LIB_SYMBOL_PROPERTIES_BASE(wxWindow *parent, wxWindowID id=ID_LIBEDIT_NOTEBOOK, const wxString &title=_("Library Symbol Properties"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxTextCtrl * m_KeywordCtrl
STD_BITMAP_BUTTON * m_bpAdd
WX_GRID * m_bodyStyleNamesGrid
wxButton * m_stdSizerButtonOK
wxBoxSizer * bSizerLowerBasicPanel
STD_BITMAP_BUTTON * m_bpDelete
wxCheckBox * m_PinsNameInsideButt
wxRadioButton * m_radioSingle
STD_BITMAP_BUTTON * m_bpMoveDownBodyStyle
wxStaticText * m_nameOffsetUnits
wxComboBox * m_inheritanceSelectCombo
STD_BITMAP_BUTTON * m_bpDeleteBodyStyle
wxCheckBox * m_ShowPinNumButt
wxCheckBox * m_OptionPower
wxRadioButton * m_radioDeMorgan
wxStaticText * m_nameOffsetLabel
wxCheckBox * m_excludeFromBoardCheckBox
wxCheckBox * m_cbDuplicatePinsAreJumpers
STD_BITMAP_BUTTON * m_bpMoveUpBodyStyle
STD_BITMAP_BUTTON * m_bpMoveDown
wxButton * m_stdSizerButtonCancel
WX_GRID * m_unitNamesGrid
wxCheckBox * m_OptionLocalPower
wxTextCtrl * m_nameOffsetCtrl
wxCheckBox * m_excludeFromPosFilesCheckBox
wxCheckBox * m_excludeFromBomCheckBox
STD_BITMAP_BUTTON * m_bpRemoveJumperGroup
wxSpinCtrl * m_unitSpinCtrl
wxCheckBox * m_OptionPartsInterchangeable
wxCheckBox * m_excludeFromSimCheckBox
wxRadioButton * m_radioCustom
STD_BITMAP_BUTTON * m_bpMoveUp
wxTextCtrl * m_SymbolNameCtrl
wxStaticText * m_inheritsStaticText
wxCheckBox * m_ShowPinNameButt
void syncBodyStyleControls()
void OnSymbolNameKillFocus(wxFocusEvent &event) override
void OnUnitSpinCtrlText(wxCommandEvent &event) override
void OnPageChanging(wxNotebookEvent &event) override
wxString m_delayedErrorMessage
void OnBodyStyle(wxCommandEvent &event) override
wxString m_keywordsSource
Ancestor supplying the keywords while the symbol leaves them empty.
FIELDS_GRID_TABLE * m_fields
WX_GRID * m_delayedFocusGrid
std::set< wxString > m_addedTemplateFields
DIALOG_LIB_SYMBOL_PROPERTIES(SYMBOL_EDIT_FRAME *parent, LIB_SYMBOL *aLibEntry)
wxControl * m_delayedFocusCtrl
void OnUpdateUI(wxUpdateUIEvent &event) override
static LAST_LAYOUT m_lastLayout
void OnBodyStyleMoveUp(wxCommandEvent &event) override
void OnCancelButtonClick(wxCommandEvent &event) override
PANEL_EMBEDDED_FILES * m_embeddedFiles
void OnDeleteField(wxCommandEvent &event) override
bool TransferDataFromWindow() override
void OnCombobox(wxCommandEvent &event) override
void OnUnitSpinCtrlEnter(wxCommandEvent &event) override
void OnAddBodyStyle(wxCommandEvent &event) override
void OnGridCellChanged(wxGridEvent &event)
std::bitset< 64 > m_shownColumns
void OnMoveUp(wxCommandEvent &event) override
void OnDeleteBodyStyle(wxCommandEvent &event) override
void OnAddJumperGroup(wxCommandEvent &event) override
SYMBOL_EDIT_FRAME * m_Parent
void OnText(wxCommandEvent &event) override
PANEL_SYMBOL_PIN_MAP * m_pinMapPanel
void OnGridMotion(wxMouseEvent &event)
void OnUnitSpinCtrlKillFocus(wxFocusEvent &event) override
~DIALOG_LIB_SYMBOL_PROPERTIES()
static int m_lastOpenedPage
wxArrayString m_inheritedFpFilters
bool canAssignFootprintToField()
void OnMoveDown(wxCommandEvent &event) override
void SelectPinMapPage()
Switch the notebook to the Pin Map page (issue #2282).
PANEL_FOOTPRINT_FILTERS * m_fpFiltersPanel
bool m_forcePinMapPage
When set by SelectPinMapPage(), TransferDataToWindow opens the Pin Map page instead of the remembered...
void syncControlStates(bool aIsAlias)
void OnCheckBox(wxCommandEvent &event) override
void OnSymbolNameText(wxCommandEvent &event) override
void assignFootprintToField(const wxString &aFootprintName)
void OnBodyStyleMoveDown(wxCommandEvent &event) override
void OnRemoveJumperGroup(wxCommandEvent &event) override
bool TransferDataToWindow() override
void OnGridCellChanging(wxGridEvent &event)
void onPowerCheckBox(wxCommandEvent &aEvent) override
void syncKeywordsToolTip()
void OnAddField(wxCommandEvent &event) override
void OnEditSpiceModel(wxCommandEvent &event) override
void addInheritedFields(const std::shared_ptr< LIB_SYMBOL > &aParent)
UNIT_BINDER m_pinNameOffset
void OnUnitSpinCtrl(wxSpinEvent &event) override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void resetSize()
Clear the existing dialog size and position.
void EndDialogShim(int aReturnCode)
A mode agnostic way to close a dialog.
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
EDA_BASE_FRAME * m_parentFrame
virtual void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
virtual void SetVisible(bool aVisible)
A text control validator used for validating the text allowed in fields.
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Represents an (ordered) list of JUMPER_GROUP objects.
void Add(JUMPER_GROUP aGroup)
Add a JUMPER_GROUP to the set.
Represents a group of jumper pins or pads, keyed by name.
static std::optional< JUMPER_GROUP > Make(std::set< wxString > aNames)
Factory method to create a JUMPER_GROUP from a set of names.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Define a library symbol object.
std::weak_ptr< LIB_SYMBOL > & GetParent()
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
static wxString LetterSubReference(int aUnit, wxChar aInitialLetter)
Composed widget that edits a symbol's named pin maps and the footprint each is bound to.
container_type::size_type size() const
void insert(value_type const &v)
wxString GetSummary() const
void SetOrdinal(int aOrdinal, FIELD_T aType)
virtual const wxString & GetText() const override
Return the string associated with the text object.
wxString GetUntranslatedName() const
Get the untranslated field name for storage, variable look-up, etc.
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetName(const wxString &aName)
void SetText(const wxString &aText) override
The symbol library editor main window.
bool IsSymbolFromLegacyLibrary() const
bool IsSymbolFromSchematic() const
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
bool(*)(const LIB_SYMBOL &) HAS_OWN_VALUE
Reports whether a symbol sets its own value for some inheritable property.
static std::shared_ptr< LIB_SYMBOL > ancestorDefining(const LIB_SYMBOL *aSymbol, HAS_OWN_VALUE aHasOwn)
Return the nearest ancestor of aSymbol that sets its own value, as reported by aHasOwn,...
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.
PGM_BASE & Pgm()
The global program "get" accessor.
Collection of utility functions for component reference designators (refdes)
#define NO_BODY_STYLES_WITH_ALTERNATE_PIN_FUNCTIONS
int StrNumCmp(const wxString &aString1, const wxString &aString2, CMP_T aCaseSensitivity)
Compare two strings with alphanumerical content.
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:...
Hold a name of a symbol's field, field value, and default visibility.
bool FieldNamesAreDuplicates(const wxString &aLhs, const wxString &aRhs, std::initializer_list< FIELD_T > aMandatoryFields)
Test whether two field names should be treated as duplicates for the purposes of field name uniquenes...
wxString GetUserFieldName(int aFieldNdx, TRANSLATION aTranslation)
@ USER
The field ID hasn't been set yet; field is invalid.
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...
VECTOR2< int32_t > VECTOR2I