51 std::vector<EMBEDDED_FILES*> embedTargets;
52 std::vector<EMBEDDED_FILES*> inheritedFiles;
56 embedTargets.push_back( footprint.GetFootprint().GetEmbeddedFiles() );
84 bool toggleCell(
int aRow,
int aCol,
bool aPreserveSelection =
false )
override
94 int row =
m_grid->GetGridCursorRow();
95 int col =
m_grid->GetGridCursorCol();
97 if( row >= 0 && col >= 0 )
102 aMenu.AppendSeparator();
111 int row =
m_grid->GetGridCursorRow();
112 int col =
m_grid->GetGridCursorCol();
116 wxString datasheetUri =
m_grid->GetCellValue( row, col );
121 if( !
m_grid->CommitPendingChanges(
false ) )
129 m_dlg->ShowHideColumn( col, show );
131 wxString fieldName =
m_dataModel->GetColFieldName( col );
157 aParent->GetSettings()->m_LibFieldEditorBom, nullptr ),
162 const wxString& libName =
m_parent->GetTargetFPID().GetLibNickname();
168 m_grid->UseNativeColHeader(
true );
176 m_grid->SetSelectionMode( wxGrid::wxGridSelectCells );
187 m_scope->Append(
_(
"Whole Library" ) );
191 wxString title = wxString::Format(
_(
"Footprint Fields Table ('%s' Library)" ), libName );
194 title += wxS(
" " ) +
_(
"[Read Only]" );
232 wxString libName =
m_parent->GetTargetFPID().GetLibNickname();
233 std::vector<wxString> footprintNames;
241 wxMessageBox( wxString::Format(
_(
"Error loading footprints from library '%s': %s" ),
242 libName, ioe.
What() ) );
246 if( footprintNames.empty() )
248 wxMessageBox( wxString::Format(
_(
"No footprints found in library '%s'." ), libName ) );
254 for(
const wxString& footprintName : footprintNames )
259 std::unique_ptr<FOOTPRINT> footprint( libMgr->
LoadFootprint( libName, footprintName,
true ) );
269 wxLogWarning( wxString::Format(
_(
"Error loading footprint '%s': %s" ), footprintName, ioe.
What() ) );
274 wxMessageBox(
_(
"No footprints could be loaded from the library." ) );
292 m_grid->PopEventHandler(
true );
311 if( !wxDialog::TransferDataToWindow() )
343 if( !
m_grid->CommitPendingChanges() )
346 if( !wxDialog::TransferDataFromWindow() )
350 bool libraryChanged =
false;
358 libraryChanged |= saved;
361 m_parent->RefreshLibraryFootprintTab( aFootprint );
372 if( !allChangesApplied )
382 auto addMandatoryField =
383 [&](
FIELD_T aFieldId,
bool aShow,
bool aGroupBy )
391 AddField( wxS(
"${FOOTPRINT_NAME}" ),
_(
"Footprint Name" ),
true,
false );
402 AddField( wxS(
"${EXCLUDE_FROM_BOM}" ),
_(
"Exclude From BOM" ),
true,
false );
403 AddField( wxS(
"${EXCLUDE_FROM_SIM}" ),
_(
"Exclude From Simulation" ),
true,
false );
404 AddField( wxS(
"${EXCLUDE_FROM_BOARD}" ),
_(
"Exclude From Board" ),
true,
false );
405 AddField( wxS(
"${EXCLUDE_FROM_POS_FILES}" ),
_(
"Exclude From Position Files" ),
true,
false );
409 std::set<wxString> userFieldNames;
413 for(
PCB_FIELD* field : ref.GetFootprint().GetFields() )
415 if( !field->IsMandatory() && !field->IsPrivate() )
416 userFieldNames.insert( field->GetName() );
420 for(
const wxString& fieldName : userFieldNames )
425 Pgm().GetCommonSettings()->m_FieldNameTemplates.GetTemplateFieldNames( TEMPLATES::SCOPE::GLOBAL ) )
427 if( userFieldNames.count( templateField.m_Name ) == 0 )
442 switch( aEvent.GetSelection() )
444 case 0:
setScope( SCOPE::SCOPE_ALL );
break;
455 _(
"Show footprints marked 'DNP' in the table. This setting also controls whether or not 'DNP' "
456 "footprints are included on export." ),
461 _(
"Show footprints marked 'Exclude from BOM' in the table. Footprints marked 'Exclude from BOM' "
462 "are never included on export." ),
467 int menuId =
m_bMenu->GetPopupMenuSelectionFromUser( menu );
500 m_grid->CommitPendingChanges(
true );
514 EndModal( wxID_CANCEL );
530 m_grid->CommitPendingChanges(
true );
551 std::vector<BOM_PRESET> presets = BOM_PRESET::BuiltInPresets();
553 for( BOM_PRESET& preset : presets )
558 for(
BOM_FIELD& field : preset.fieldsOrdered )
563 field.
label = wxS(
"Footprint Name" );
568 if( preset.name == BOM_PRESET::DefaultEditing().name )
570 preset.groupSymbols =
false;
571 preset.fieldsOrdered = {
579 { wxS(
"${EXCLUDE_FROM_BOM}" ), wxS(
"Exclude From BOM" ),
true,
false },
580 { wxS(
"${EXCLUDE_FROM_SIM}" ), wxS(
"Exclude From Simulation" ),
true,
false },
581 { wxS(
"${EXCLUDE_FROM_BOARD}" ), wxS(
"Exclude From Board" ),
true,
false },
582 { wxS(
"${EXCLUDE_FROM_POS_FILES}" ), wxS(
"Exclude From Position Files" ),
true,
false },
593 return wxEmptyString;
wxTextCtrl * m_outputFileName
wxChoice * m_cbBomFmtPresets
wxPanel * m_variantsPanel
STD_BITMAP_BUTTON * m_bMenu
WX_GRID * m_viewControlsGrid
wxChoice * m_cbBomPresets
wxCheckBox * m_groupSymbolsBox
wxSplitterWindow * m_splitter_left
void SetUserBomFmtPresets(std::vector< BOM_FMT_PRESET > &aPresetList)
wxSize GetDefaultDialogSize() const
void syncBomFmtPresetSelection()
void OnColMove(wxGridEvent &aEvent)
void OnColSort(wxGridEvent &aEvent)
void OnGridMouseMove(wxMouseEvent &aEvent)
bool savePresets(bool aSaveCurrentSettings)
void RestorePanelLayout()
void RestoreGridSelection(const std::set< KIID_PATH > &aItemKeys)
Restore a selection previously returned by SaveGridSelection().
std::map< FIELD_T, int > m_mandatoryFieldListIndexes
void onBomFmtPresetChanged(wxCommandEvent &aEvent)
void SetUserBomPresets(std::vector< BOM_PRESET > &aPresetList)
void ApplyBomFmtPreset(const wxString &aPresetName)
DIALOG_FIELDS_TABLE(wxWindow *aParent, FIELDS_TABLE_SETTINGS &aPanelSettings, FIELDS_TABLE_BOM_SETTINGS &aBomSettings, JOB_EXPORT_BOM *aJob)
FIELDS_TABLE_BOM_SETTINGS & m_cfgBomSettings
void onBomPresetChanged(wxCommandEvent &aEvent)
void SetReadOnly(bool aReadOnly)
std::set< KIID_PATH > SaveGridSelection()
Save the grid selection by stable item identity so it can survive a row rebuild.
void ApplyBomPreset(const wxString &aPresetName)
void syncBomPresetSelection()
VIEW_CONTROLS_GRID_DATA_MODEL * m_viewControlsDataModel
void AddField(const wxString &aFieldName, const wxString &aLabelValue, bool aShow, bool aGroupBy, bool aAddedByUser=false)
void ExcludeFromControlUndoRedo(wxWindow *aWindow)
Opt a control out of the dialog's generic Ctrl+Z/Ctrl+Y undo/redo.
void OptOut(wxWindow *aWindow)
Opt out of control state saving.
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
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...
FIELDS_TABLE_GRID_TRICKS(DIALOG_FIELDS_TABLE *aDialog, WX_GRID *aGrid, FIELDS_TABLE_DATA_MODEL_BASE *aDataModel)
static constexpr int FIRST_CLIENT_ID
virtual void doPopupSelection(wxCommandEvent &event)
virtual void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent)
WX_GRID * m_grid
I don't own the grid, but he owns me.
virtual bool toggleCell(int aRow, int aCol, bool aPreserveSelection=false)
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
const wxString GetUniStringLibNickname() const
static FOOTPRINT_LIBRARY_ADAPTER * FootprintLibAdapter(PROJECT *aProject)
virtual bool TextVarResolver(wxString *aToken) const
wxString GetGeneratedFieldDisplayName(const wxString &aSource)
Returns any variables unexpanded, e.g.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
This file is part of the common library.
static GRID_CELL_URL_EDITOR_CONTEXT getDatasheetContext(const std::vector< LIB_SYMBOL * > &aSymbols)
LIB_FIELDS_EDITOR_GRID_DATA_MODEL::SCOPE SCOPE
@ MYID_INCLUDE_EXCLUDED_FROM_BOM
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, PROJECT *aProject, SEARCH_STACK *aPaths, std::vector< EMBEDDED_FILES * > aFilesStack)
Open a document (file) with the suitable browser.
This file is part of the common library.
#define SHOW_FIELD_COLUMN
GRID_CELL_URL_EDITOR_CONTEXT MakeGridCellUrlEditorContext(const std::vector< EMBEDDED_FILES * > &aEmbedTargets, const std::vector< EMBEDDED_FILES * > &aAdditionalLookupFiles)
@ GRIDTRICKS_FIRST_SHOWHIDE
PGM_BASE & Pgm()
The global program "get" accessor.
Hold a name of a symbol's field, field value, and default visibility.
wxString GetDefaultFieldName(FIELD_T aFieldId, TRANSLATION aTranslation)
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...
@ DESCRIPTION
Field Description of part, i.e. "1/4W 1% Metal Film Resistor".
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
wxLogTrace helper definitions.