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();
235 if( footprintNames.empty() )
237 wxMessageBox( wxString::Format(
_(
"No footprints found in library '%s'." ), libName ) );
243 for(
const wxString& footprintName : footprintNames )
248 std::unique_ptr<FOOTPRINT> footprint( libMgr->
LoadFootprint( libName, footprintName,
true ) );
258 wxLogWarning( wxString::Format(
_(
"Error loading footprint '%s': %s" ), footprintName, ioe.
What() ) );
263 wxMessageBox(
_(
"No footprints could be loaded from the library." ) );
281 m_grid->PopEventHandler(
true );
300 if( !wxDialog::TransferDataToWindow() )
332 if( !
m_grid->CommitPendingChanges() )
335 if( !wxDialog::TransferDataFromWindow() )
339 bool libraryChanged =
false;
347 libraryChanged |= saved;
350 m_parent->RefreshLibraryFootprintTab( aFootprint );
361 if( !allChangesApplied )
371 auto addMandatoryField =
372 [&](
FIELD_T aFieldId,
bool aShow,
bool aGroupBy )
380 AddField( wxS(
"${FOOTPRINT_NAME}" ),
_(
"Footprint Name" ),
true,
false );
391 AddField( wxS(
"${EXCLUDE_FROM_BOM}" ),
_(
"Exclude From BOM" ),
true,
false );
392 AddField( wxS(
"${EXCLUDE_FROM_SIM}" ),
_(
"Exclude From Simulation" ),
true,
false );
393 AddField( wxS(
"${EXCLUDE_FROM_BOARD}" ),
_(
"Exclude From Board" ),
true,
false );
394 AddField( wxS(
"${EXCLUDE_FROM_POS_FILES}" ),
_(
"Exclude From Position Files" ),
true,
false );
398 std::set<wxString> userFieldNames;
402 for(
PCB_FIELD* field : ref.GetFootprint().GetFields() )
404 if( !field->IsMandatory() && !field->IsPrivate() )
405 userFieldNames.insert( field->GetName() );
409 for(
const wxString& fieldName : userFieldNames )
414 Pgm().GetCommonSettings()->m_FieldNameTemplates.GetTemplateFieldNames( TEMPLATES::SCOPE::GLOBAL ) )
416 if( userFieldNames.count( templateField.m_Name ) == 0 )
431 switch( aEvent.GetSelection() )
433 case 0:
setScope( SCOPE::SCOPE_ALL );
break;
444 _(
"Show footprints marked 'DNP' in the table. This setting also controls whether or not 'DNP' "
445 "footprints are included on export." ),
450 _(
"Show footprints marked 'Exclude from BOM' in the table. Footprints marked 'Exclude from BOM' "
451 "are never included on export." ),
456 int menuId =
m_bMenu->GetPopupMenuSelectionFromUser( menu );
489 m_grid->CommitPendingChanges(
true );
503 EndModal( wxID_CANCEL );
519 m_grid->CommitPendingChanges(
true );
540 std::vector<BOM_PRESET> presets = BOM_PRESET::BuiltInPresets();
542 for( BOM_PRESET& preset : presets )
547 for(
BOM_FIELD& field : preset.fieldsOrdered )
552 field.
label = wxS(
"Footprint Name" );
557 if( preset.name == BOM_PRESET::DefaultEditing().name )
559 preset.groupSymbols =
false;
560 preset.fieldsOrdered = {
568 { wxS(
"${EXCLUDE_FROM_BOM}" ), wxS(
"Exclude From BOM" ),
true,
false },
569 { wxS(
"${EXCLUDE_FROM_SIM}" ), wxS(
"Exclude From Simulation" ),
true,
false },
570 { wxS(
"${EXCLUDE_FROM_BOARD}" ), wxS(
"Exclude From Board" ),
true,
false },
571 { wxS(
"${EXCLUDE_FROM_POS_FILES}" ), wxS(
"Exclude From Position Files" ),
true,
false },
582 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.