51#include <wx/textdlg.h>
52#include <wx/filedlg.h>
64#define COLUMN_MARGIN 3
66#define COLUMN_MARGIN 15
93 int col =
m_grid->GetGridCursorCol();
98 menu.AppendSeparator();
103 menu.AppendSeparator();
111 int row =
m_grid->GetGridCursorRow();
112 int col =
m_grid->GetGridCursorCol();
117 wxString fpid =
m_grid->GetCellValue( row, col );
121 if( frame->ShowModal( &fpid,
m_dlg ) )
122 m_grid->SetCellValue( row, col, fpid );
129 wxString datasheet_uri =
m_grid->GetCellValue( row, col );
150 for( row = 0; row <
m_fieldsCtrl->GetItemCount(); row++ )
179 m_currentBomPreset( nullptr ),
180 m_lastSelectedBomPreset( nullptr ),
182 m_schSettings( parent->Schematic().Settings() ),
196 m_fieldsCtrl->AppendTextColumn(
_(
"Field" ), wxDATAVIEW_CELL_INERT, 0, wxALIGN_LEFT, 0 );
197 m_fieldsCtrl->AppendTextColumn(
_(
"Column Label" ), wxDATAVIEW_CELL_EDITABLE, 0, wxALIGN_LEFT, 0 );
202 m_fieldsCtrl->AppendToggleColumn(
_(
"Show Column" ), wxDATAVIEW_CELL_ACTIVATABLE, 0, wxALIGN_CENTER, 0 );
203 m_fieldsCtrl->AppendToggleColumn(
_(
"Group By" ), wxDATAVIEW_CELL_ACTIVATABLE, 0, wxALIGN_CENTER, 0 );
205 m_fieldsCtrl->AppendToggleColumn(
_(
"Show\nColumn" ), wxDATAVIEW_CELL_ACTIVATABLE, 0, wxALIGN_CENTER, 0 );
206 m_fieldsCtrl->AppendToggleColumn(
_(
"Group\nBy" ), wxDATAVIEW_CELL_ACTIVATABLE, 0, wxALIGN_CENTER, 0 );
211 m_fieldsCtrl->AppendTextColumn(
_(
"Name" ), wxDATAVIEW_CELL_INERT, 0, wxALIGN_LEFT, 0 );
239 m_filter->SetDescriptiveText(
_(
"Filter" ) );
241 wxGridCellAttr* attr =
new wxGridCellAttr;
253 for(
int row = 0; row <
m_fieldsCtrl->GetItemCount(); ++row )
275 m_grid->UseNativeColHeader(
true );
279 m_grid->SetSelectionMode( wxGrid::wxGridSelectCells );
309 field.
name = fieldName;
310 field.
show = !fieldName.StartsWith( wxT(
"__" ), &field.
name );
377 case SCOPE::SCOPE_SHEET_RECURSIVE:
m_radioRecursive->SetValue(
true );
break;
405 m_grid->EnableEditing(
false );
416 wxGridCellAttr* attr =
new wxGridCellAttr;
417 attr->SetReadOnly(
false );
440 attr->SetAlignment( wxALIGN_RIGHT, wxALIGN_CENTER );
441 attr->SetRenderer(
new wxGridCellNumberRenderer() );
446 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
458 attr->SetEditor(
m_grid->GetDefaultEditor() );
467 wxSize defaultDlgSize = ConvertDialogToPixels( wxSize( 600, 300 ) );
470 m_grid->AutoSizeColumns(
false );
472 bool sortAscending =
true;
474 for(
int col = 0; col <
m_grid->GetNumberCols(); ++col )
510 int maxWidth = defaultDlgSize.x / 3;
512 m_grid->SetColSize( col, std::clamp( textWidth, 100, maxWidth ) );
522 m_grid->SetSortingColumn( sortCol, sortAscending );
535 m_grid->PopEventHandler(
true );
543 if( !wxDialog::TransferDataFromWindow() )
553 if( selection.GetSize() == 1 )
572 if( ref.GetSymbol() == symbol )
597 m_grid->GoToCell( row, valueCol );
599 m_grid->GoToCell( row, refCol );
600 else if( anyCol != -1 )
601 m_grid->GoToCell( row, anyCol );
622 if( !wxDialog::TransferDataFromWindow() )
636 commit.
Push( wxS(
"Symbol Fields Table Edit" ) );
650 bool show,
bool groupBy,
bool addedByUser )
662 wxVector<wxVariant> fieldsCtrlRow;
663 std::string key( aFieldName.ToUTF8() );
666 fieldsCtrlRow.push_back( wxVariant( aFieldName ) );
667 fieldsCtrlRow.push_back( wxVariant( aLabelValue ) );
668 fieldsCtrlRow.push_back( wxVariant( show ) );
669 fieldsCtrlRow.push_back( wxVariant( groupBy ) );
670 fieldsCtrlRow.push_back( wxVariant( aFieldName ) );
674 wxGridTableMessage msg(
m_dataModel, wxGRIDTABLE_NOTIFY_COLS_APPENDED, 1 );
675 m_grid->ProcessTableMessage( msg );
681 auto addMandatoryField =
682 [&](
FIELD_T fieldId,
bool show,
bool groupBy )
691 addMandatoryField( FIELD_T::REFERENCE,
true,
true );
692 addMandatoryField( FIELD_T::VALUE,
true,
true );
693 addMandatoryField( FIELD_T::FOOTPRINT,
true,
true );
694 addMandatoryField( FIELD_T::DATASHEET,
true,
false );
695 addMandatoryField( FIELD_T::DESCRIPTION,
false,
false );
702 std::set<wxString> userFieldNames;
710 if( !field.IsMandatory() && !field.IsPrivate() )
711 userFieldNames.insert( field.GetName() );
715 for(
const wxString& fieldName : userFieldNames )
721 if( userFieldNames.count( tfn.m_Name ) == 0 )
729 wxTextEntryDialog dlg(
this,
_(
"New field name:" ),
_(
"Add Field" ) );
731 if( dlg.ShowModal() != wxID_OK )
734 wxString fieldName = dlg.GetValue();
736 if( fieldName.IsEmpty() )
746 DisplayError(
this, wxString::Format(
_(
"Field name '%s' already in use." ), fieldName ) );
775 DisplayError(
this, wxString::Format(
_(
"The first %d fields are mandatory." ),
784 wxString confirm_msg = wxString::Format(
_(
"Are you sure you want to remove the field '%s'?" ),
787 if( !
IsOK(
this, confirm_msg ) )
804 wxGridTableMessage msg(
m_dataModel, wxGRIDTABLE_NOTIFY_COLS_DELETED, col, 1 );
806 m_grid->ProcessTableMessage( msg );
827 DisplayError(
this, wxString::Format(
_(
"The first %d fields are mandatory and names cannot be changed." ),
836 wxCHECK_RET( col != -1, wxS(
"Existing field name missing from data model" ) );
838 wxTextEntryDialog dlg(
this,
_(
"New field name:" ),
_(
"Rename Field" ), fieldName );
840 if( dlg.ShowModal() != wxID_OK )
843 wxString newFieldName = dlg.GetValue();
846 if( newFieldName == fieldName )
852 wxString confirm_msg = wxString::Format(
_(
"Field name %s already exists." ), newFieldName );
879 wxPoint pos = aEvent.GetPosition();
880 wxRect ctrlRect =
m_filter->GetScreenRect();
881 int buttonWidth = ctrlRect.GetHeight();
884 if(
m_filter->IsSearchButtonVisible() && pos.x < buttonWidth )
885 SetCursor( wxCURSOR_ARROW );
886 else if(
m_filter->IsCancelButtonVisible() && pos.x > ctrlRect.GetWidth() - buttonWidth )
887 SetCursor( wxCURSOR_ARROW );
889 SetCursor( wxCURSOR_IBEAM );
895 wxDataViewItem item =
event.GetItem();
897 int col =
event.GetColumn();
912 m_grid->ShowCol( dataCol );
914 m_grid->HideCol( dataCol );
928 DisplayError(
this,
_(
"The Quantity column cannot be grouped by." ) );
936 DisplayError(
this,
_(
"The Item Number column cannot be grouped by." ) );
990 int sortCol = aEvent.GetCol();
1003 if(
m_grid->IsSortingBy( sortCol ) )
1006 ascending = !
m_grid->IsSortOrderAscending();
1024 int origPos = aEvent.GetCol();
1029 for(
int i = 0; i <
m_grid->GetNumberCols(); i++ )
1031 if(
m_grid->IsColShown( i ) )
1041 int newPos =
m_grid->GetColPos( origPos );
1044 if( newPos < origPos )
1065 wxDataViewItem item = aEvent.GetItem();
1074 m_grid->SetColLabelValue( col, label );
1094 int col = aEvent.GetRowOrCol();
1135 m_grid->ClearSelection();
1138 m_grid->SetGridCursor( event.GetRow(), event.GetCol() );
1155 std::set<SCH_REFERENCE> refs;
1156 std::set<SCH_ITEM*> symbols;
1159 if( aEvent.Selecting() )
1161 for(
int i = aEvent.GetTopRow(); i <= aEvent.GetBottomRow(); i++ )
1168 symbols.insert( ref.GetSymbol() );
1175 if( refs.size() > 0 )
1179 wxString symbol_path = refs.begin()->GetFullPath();
1193 std::vector<SCH_ITEM*> items( symbols.begin(), symbols.end() );
1195 if( refs.size() > 0 )
1196 selTool->
SyncSelection( refs.begin()->GetSheetPath(),
nullptr, items );
1308 wxFileDialog saveDlg(
this,
_(
"Bill of Materials Output File" ),
path, fn.GetFullName(),
1311 if( saveDlg.ShowModal() == wxID_CANCEL )
1315 wxFileName file = wxFileName( saveDlg.GetPath() );
1316 wxString defaultPath = fn.GetPathWithSep();
1318 if(
IsOK(
this, wxString::Format(
_(
"Do you want to use a path relative to\n'%s'?" ), defaultPath ) ) )
1320 if( !file.MakeRelativeTo( defaultPath ) )
1322 DisplayErrorMessage(
this,
_(
"Cannot make path relative (target volume different from schematic "
1323 "file volume)!" ) );
1336 _(
"Changes have not yet been saved. Export unsaved data?" ),
"",
1337 _(
"OK" ),
_(
"Cancel" ) )
1347 std::function<bool( wxString* )> textResolver =
1348 [&]( wxString* token ) ->
bool
1358 if(
path.IsEmpty() )
1360 DisplayError(
this,
_(
"No output file specified in Export tab." ) );
1367 wxFileName outputFile = wxFileName::FileName(
path );
1374 msg.Printf(
_(
"Could not open/create path '%s'." ), outputFile.GetPath() );
1379 wxFFile out( outputFile.GetFullPath(),
"wb" );
1381 if( !out.IsOpened() )
1383 msg.Printf(
_(
"Could not create BOM output '%s'." ), outputFile.GetFullPath() );
1392 msg.Printf(
_(
"Could not write BOM output '%s'." ), outputFile.GetFullPath() );
1399 msg.Printf(
_(
"Wrote BOM output to '%s'" ), outputFile.GetFullPath() );
1407 EndModal( wxID_CANCEL );
1452 if( modelField.show )
1459 if( modelField.groupBy )
1463 EndModal( wxID_OK );
1523 for(
int i = 0; i <
m_grid->GetNumberCols(); i++ )
1525 if(
m_grid->IsColShown( i ) )
1534 wxCommandEvent* evt =
new wxCommandEvent( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, wxID_ANY );
1536 if( wxWindow* parent = GetParent() )
1537 wxQueueEvent( parent, evt );
1543 std::vector<BOM_PRESET> ret;
1545 for(
const std::pair<const wxString, BOM_PRESET>& pair :
m_bomPresets )
1547 if( !pair.second.readOnly )
1548 ret.emplace_back( pair.second );
1560 for(
const BOM_PRESET& preset : aPresetList )
1578 wxCommandEvent
dummy;
1623 int default_idx = 0;
1625 for( std::pair<const wxString, BOM_PRESET>& pair :
m_bomPresets )
1628 static_cast<void*
>( &pair.second ) );
1654 [&](
const std::pair<const wxString, BOM_PRESET>& aPair )
1656 const BOM_PRESET& preset = aPair.second;
1659 if( !( preset.sortAsc == current.sortAsc
1660 && preset.filterString == current.filterString
1661 && preset.groupSymbols == current.groupSymbols
1662 && preset.excludeDNP == current.excludeDNP
1663 && preset.includeExcludedFromBOM == current.includeExcludedFromBOM ) )
1674 if( preset.sortField != wxGetTranslation( current.
sortField ) )
1678 std::vector<BOM_FIELD>
A,
B;
1680 for(
const BOM_FIELD& field : preset.fieldsOrdered )
1682 if( field.show || field.groupBy )
1683 A.emplace_back( field );
1688 if( field.show || field.groupBy )
1689 B.emplace_back( field );
1695 if( it != m_bomPresets.end() )
1699 bool do_translate = it->second.
readOnly;
1700 wxString
text = do_translate ? wxGetTranslation( it->first ) : it->first;
1701 m_cbBomPresets->SetStringSelection(
text );
1705 m_cbBomPresets->SetSelection( m_cbBomPresets->GetCount() - 3 );
1708 m_currentBomPreset =
static_cast<BOM_PRESET*
>( m_cbBomPresets->GetClientData( m_cbBomPresets->GetSelection() ) );
1717 wxString ui_label = aName;
1719 for( std::pair<const wxString, BOM_PRESET>& pair :
m_bomPresets )
1721 if( pair.first != aName )
1724 if( pair.second.readOnly ==
true )
1725 ui_label = wxGetTranslation( aName );
1749 auto resetSelection =
1758 if( index == count - 3 )
1764 else if( index == count - 2 )
1772 wxTextEntryDialog dlg(
this,
_(
"BOM preset name:" ),
_(
"Save BOM Preset" ),
name );
1774 if( dlg.ShowModal() != wxID_OK )
1780 name = dlg.GetValue();
1798 wxMessageBox(
_(
"Default presets cannot be modified.\nPlease use a different name." ),
1799 _(
"Error" ), wxOK | wxICON_ERROR,
this );
1806 if( !
IsOK(
this,
_(
"Overwrite existing preset?" ) ) )
1827 else if( index == count - 1 )
1830 wxArrayString headers;
1831 std::vector<wxArrayString> items;
1833 headers.Add(
_(
"Presets" ) );
1837 if( !preset.readOnly )
1841 items.emplace_back( item );
1853 if( idx != wxNOT_FOUND )
1903 for(
int i = 0; i <
m_dataModel->GetColsCount(); i++ )
1908 for(
int j = 0; j <
m_fieldsCtrl->GetItemCount(); j++ )
1923 for(
int i = 0; i <
m_fieldsCtrl->GetItemCount(); i++ )
1930 wxASSERT_MSG(
true,
"Fields control has a field not found in the data model." );
1935 std::string fieldNameStr( fieldName.ToUTF8() );
1940 m_grid->SetColLabelValue( col, label );
1977 std::vector<BOM_FMT_PRESET> ret;
1981 if( !preset.readOnly )
1982 ret.emplace_back( preset );
2012 wxCommandEvent
dummy;
2056 int default_idx = 0;
2058 for( std::pair<const wxString, BOM_FMT_PRESET>& pair :
m_bomFmtPresets )
2061 static_cast<void*
>( &pair.second ) );
2087 [&](
const std::pair<const wxString, BOM_FMT_PRESET>& aPair )
2089 return ( aPair.second.fieldDelimiter == current.fieldDelimiter
2090 && aPair.second.stringDelimiter == current.stringDelimiter
2091 && aPair.second.refDelimiter == current.refDelimiter
2092 && aPair.second.refRangeDelimiter == current.refRangeDelimiter
2093 && aPair.second.keepTabs == current.keepTabs
2094 && aPair.second.keepLineBreaks == current.keepLineBreaks );
2101 bool do_translate = it->second.readOnly;
2102 wxString
text = do_translate ? wxGetTranslation( it->first ) : it->first;
2122 wxString ui_label = aName;
2129 if( preset.readOnly )
2130 ui_label = wxGetTranslation( aName );
2154 auto resetSelection =
2163 if( index == count - 3 )
2169 else if( index == count - 2 )
2177 wxTextEntryDialog dlg(
this,
_(
"BOM preset name:" ),
_(
"Save BOM Preset" ),
name );
2179 if( dlg.ShowModal() != wxID_OK )
2185 name = dlg.GetValue();
2203 wxMessageBox(
_(
"Default presets cannot be modified.\nPlease use a different name." ),
2204 _(
"Error" ), wxOK | wxICON_ERROR,
this );
2211 if( !
IsOK(
this,
_(
"Overwrite existing preset?" ) ) )
2232 else if( index == count - 1 )
2235 wxArrayString headers;
2236 std::vector<wxArrayString> items;
2238 headers.Add(
_(
"Presets" ) );
2240 for( std::pair<const wxString, BOM_FMT_PRESET>& pair :
m_bomFmtPresets )
2242 if( !pair.second.readOnly )
2245 item.Add( pair.first );
2246 items.emplace_back( item );
2258 if( idx != wxNOT_FOUND )
2314 bool modified =
false;
2317 std::vector<BOM_PRESET> presets;
2321 if( !preset.readOnly )
2322 presets.emplace_back( preset );
2338 std::vector<BOM_FMT_PRESET> fmts;
2342 if( !preset.readOnly )
2343 fmts.emplace_back( preset );
2364 std::vector<SCH_ITEM*>& aSchItem )
2381 AddField( field.GetCanonicalName(), field.GetName(),
true,
false, true );
2387 std::set<SCH_SYMBOL*> symbols;
2391 symbols.insert( ref.GetSymbol() );
2396 for(
SCH_FIELD& field : symbol->GetFields() )
2397 AddField( field.GetCanonicalName(), field.GetName(),
true,
false,
true );
2411 std::vector<SCH_ITEM*>& aSchItem )
2428 std::vector<SCH_ITEM*>& aSchItem )
2445 AddField( field.GetCanonicalName(), field.GetName(),
true,
false, true );
2451 std::set<SCH_SYMBOL*> symbols;
2455 symbols.insert( ref.GetSymbol() );
2460 for(
SCH_FIELD& field : symbol->GetFields() )
2461 AddField( field.GetCanonicalName(), field.GetName(),
true,
false,
true );
2489 m_grid->Connect( wxEVT_GRID_RANGE_SELECTED,
2497 m_grid->Disconnect( wxEVT_GRID_RANGE_SELECTED,
2509 for(
size_t i = 0; i < aCachedRefs.
GetCount(); i++ )
2536 if( basePath.Path() == instance.m_Path )
2544 subSheets.push_back( sheetPath );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
int vertPixelsFromDU(int y) const
Convert an integer number of dialog units to pixels, vertically.
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={})
int horizPixelsFromDU(int x) const
Convert an integer number of dialog units to pixels, horizontally.
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Class DIALOG_SYMBOL_FIELDS_TABLE_BASE.
wxRadioButton * m_radioRecursive
wxCheckBox * m_checkShowExcluded
wxCheckBox * m_checkKeepLineBreaks
STD_BITMAP_BUTTON * m_bRefreshPreview
wxRadioButton * m_radioOff
wxCheckBox * m_checkKeepTabs
wxButton * m_buttonExport
STD_BITMAP_BUTTON * m_removeFieldButton
STD_BITMAP_BUTTON * m_browseButton
wxRadioButton * m_radioSelect
wxTextCtrl * m_textOutput
STD_BITMAP_BUTTON * m_bRefresh
STD_BITMAP_BUTTON * m_renameFieldButton
STD_BITMAP_BUTTON * m_addFieldButton
wxTextCtrl * m_textStringDelimiter
wxChoice * m_cbBomPresets
wxTextCtrl * m_outputFileName
wxSplitterWindow * m_splitterMainWindow
wxDataViewListCtrl * m_fieldsCtrl
wxCheckBox * m_checkExcludeDNP
wxRadioButton * m_radioCurrentSheet
wxTextCtrl * m_textFieldDelimiter
wxCheckBox * m_groupSymbolsBox
wxRadioButton * m_radioHighlight
wxTextCtrl * m_textRefRangeDelimiter
wxRadioButton * m_radioProject
wxChoice * m_cbBomFmtPresets
wxTextCtrl * m_textRefDelimiter
void OnTableColSize(wxGridSizeEvent &event) override
void OnSaveAndContinue(wxCommandEvent &aEvent) override
void OnSchItemsRemoved(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aSchItem) override
BOM_FMT_PRESET * m_currentBomFmtPreset
void OnPreviewRefresh(wxCommandEvent &event) override
void OnAddField(wxCommandEvent &event) override
SCH_REFERENCE_LIST getSheetSymbolReferences(SCH_SHEET &aSheet)
void SetUserBomPresets(std::vector< BOM_PRESET > &aPresetList)
void OnOk(wxCommandEvent &aEvent) override
void OnGroupSymbolsToggled(wxCommandEvent &event) override
void OnColumnItemToggled(wxDataViewEvent &event) override
void OnColMove(wxGridEvent &aEvent)
void OnSchItemsAdded(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aSchItem) override
void loadDefaultBomFmtPresets()
std::map< wxString, BOM_PRESET > m_bomPresets
void OnSchItemsChanged(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aSchItem) override
void ApplyBomFmtPreset(const wxString &aPresetName)
SCH_EDIT_FRAME * m_parent
bool TransferDataFromWindow() override
SCH_REFERENCE_LIST m_symbolsList
void SetupColumnProperties(int aCol)
FIELDS_EDITOR_GRID_DATA_MODEL * m_dataModel
void updateBomPresetSelection(const wxString &aName)
void OnTableItemContextMenu(wxGridEvent &event) override
void updateBomFmtPresetSelection(const wxString &aName)
void OnFilterText(wxCommandEvent &aEvent) override
void OnScopeChanged(wxCommandEvent &aEvent) override
std::map< FIELD_T, int > m_mandatoryFieldListIndexes
void OnRemoveField(wxCommandEvent &event) override
void OnTableCellClick(wxGridEvent &event) override
void OnShowExcludedToggled(wxCommandEvent &event) override
wxArrayString m_bomPresetMRU
void OnColLabelChange(wxDataViewEvent &aEvent)
void doApplyBomFmtPreset(const BOM_FMT_PRESET &aPreset)
void loadDefaultBomPresets()
void onBomPresetChanged(wxCommandEvent &aEvent)
void OnTableValueChanged(wxGridEvent &event) override
void OnExport(wxCommandEvent &aEvent) override
void OnClose(wxCloseEvent &aEvent) override
void OnSchSheetChanged(SCHEMATIC &aSch) override
void syncBomFmtPresetSelection()
void DisableSelectionEvents()
bool TransferDataToWindow() override
void OnTableRangeSelected(wxGridRangeSelectEvent &aEvent)
void EnableSelectionEvents()
std::vector< BOM_FMT_PRESET > GetUserBomFmtPresets() const
wxArrayString m_bomFmtPresetMRU
void OnCancel(wxCommandEvent &aEvent) override
void OnFilterMouseMoved(wxMouseEvent &event) override
std::map< wxString, BOM_FMT_PRESET > m_bomFmtPresets
DIALOG_SYMBOL_FIELDS_TABLE(SCH_EDIT_FRAME *parent, JOB_EXPORT_SCH_BOM *aJob=nullptr)
BOM_FMT_PRESET GetCurrentBomFmtSettings()
Returns a formatting configuration corresponding to the values in the UI controls of the dialog.
void savePresetsToSchematic()
void SetupAllColumnProperties()
void AddField(const wxString &displayName, const wxString &aCanonicalName, bool show, bool groupBy, bool addedByUser=false)
SCH_REFERENCE_LIST getSymbolReferences(SCH_SYMBOL *aSymbol, SCH_REFERENCE_LIST &aCachedRefs)
SCHEMATIC_SETTINGS & m_schSettings
void syncBomPresetSelection()
void OnSizeFieldList(wxSizeEvent &event) override
void doApplyBomPreset(const BOM_PRESET &aPreset)
void OnPageChanged(wxNotebookEvent &event) override
void SetUserBomFmtPresets(std::vector< BOM_FMT_PRESET > &aPresetList)
void OnRegroupSymbols(wxCommandEvent &aEvent) override
void OnColSort(wxGridEvent &aEvent)
JOB_EXPORT_SCH_BOM * m_job
virtual ~DIALOG_SYMBOL_FIELDS_TABLE()
std::vector< BOM_PRESET > GetUserBomPresets() const
void OnOutputFileBrowseClicked(wxCommandEvent &event) override
void LoadFieldNames()
Construct the rows of m_fieldsCtrl and the columns of m_dataModel from a union of all field names in ...
void onBomFmtPresetChanged(wxCommandEvent &aEvent)
void ApplyBomPreset(const wxString &aPresetName)
void OnExcludeDNPToggled(wxCommandEvent &event) override
void rebuildBomFmtPresetsWidget()
BOM_PRESET * m_lastSelectedBomPreset
void rebuildBomPresetsWidget()
BOM_PRESET * m_currentBomPreset
BOM_FMT_PRESET * m_lastSelectedBomFmtPreset
void OnRenameField(wxCommandEvent &event) override
virtual void ClearFocus()
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
EDA_ITEM * GetParent() const
wxString GetTextSelection(int aColumn=0)
Return the selected text from aColumn in the wxListCtrl in the dialog.
void SetListLabel(const wxString &aLabel)
PANEL_FIELD_EDITOR m_FieldEditorPanel
int GetFieldNameCol(const wxString &aFieldName) const
wxString GetColFieldName(int aCol)
void ApplyBomPreset(const BOM_PRESET &preset)
std::vector< SCH_REFERENCE > GetRowReferences(int aRow) const
void SetGroupingEnabled(bool group)
bool ColIsItemNumber(int aCol)
int GetNumberCols() override
bool ColIsQuantity(int aCol)
bool GetGroupColumn(int aCol)
wxString GetColLabelValue(int aCol) override
BOM_PRESET GetBomSettings()
void SetScope(SCOPE aScope)
bool ColIsReference(int aCol)
bool GetGroupingEnabled()
void SetPath(const SCH_SHEET_PATH &aPath)
int GetNumberRows() override
void RenameColumn(int aCol, const wxString &newName)
wxString Export(const BOM_FMT_PRESET &settings)
void AddColumn(const wxString &aFieldName, const wxString &aLabel, bool aAddedByUser)
void SetSorting(int aCol, bool ascending)
void ExpandCollapseRow(int aRow)
void SetFilter(const wxString &aFilter)
void SetColAttr(wxGridCellAttr *aAttr, int aCol) override
static const wxString ITEM_NUMBER_VARIABLE
void ApplyData(SCH_COMMIT &aCommit, TEMPLATES &aTemplateFieldnames)
void SetIncludeExcludedFromBOM(bool include)
int GetDataWidth(int aCol)
void UpdateReferences(const SCH_REFERENCE_LIST &aRefs)
void RemoveColumn(int aCol)
const wxString & GetFilter()
static const wxString QUANTITY_VARIABLE
bool ColIsValue(int aCol)
void SetGroupColumn(int aCol, bool group)
void SetExcludeDNP(bool exclude)
void RemoveSymbol(const SCH_SYMBOL &aSymbol)
std::vector< BOM_FIELD > GetFieldsOrdered()
bool ColIsAttribute(int aCol)
bool GetShowColumn(int aCol)
void SetColLabelValue(int aCol, const wxString &aLabel) override
void MoveColumn(int aCol, int aNewPos)
void RemoveReferences(const SCH_REFERENCE_LIST &aRefs)
bool GetIncludeExcludedFromBOM()
void SetShowColumn(int aCol, bool show)
void AddReferences(const SCH_REFERENCE_LIST &aRefs)
wxDataViewListCtrl * m_fieldsCtrl
void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent) override
void doPopupSelection(wxCommandEvent &event) override
FIELDS_EDITOR_GRID_DATA_MODEL * m_dataModel
FIELDS_EDITOR_GRID_TRICKS(DIALOG_SHIM *aParent, WX_GRID *aGrid, wxDataViewListCtrl *aFieldsCtrl, FIELDS_EDITOR_GRID_DATA_MODEL *aDataModel, EMBEDDED_FILES *aFiles)
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
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.
bool m_includeExcludedFromBOM
std::vector< wxString > m_fieldsLabels
std::vector< wxString > m_fieldsOrdered
wxString GetSettingsDialogTitle() const override
wxString m_refRangeDelimiter
std::vector< wxString > m_fieldsGroupBy
wxString m_stringDelimiter
wxString m_fieldDelimiter
wxString m_bomFmtPresetName
void SetConfiguredOutputPath(const wxString &aPath)
Sets the configured output path for the job, this path is always saved to file.
wxString GetConfiguredOutputPath() const
Returns the configured output path for the job.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
static REPORTER & GetInstance()
static SEARCH_STACK * SchSearchS(PROJECT *aProject)
Accessor for Eeschema search stack.
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
wxString m_BomExportFileName
BOM_FMT_PRESET m_BomFmtSettings
List of stored BOM format presets.
TEMPLATES m_TemplateFieldNames
std::vector< BOM_PRESET > m_BomPresets
std::vector< BOM_FMT_PRESET > m_BomFmtPresets
BOM_PRESET m_BomSettings
List of stored BOM presets.
Holds all the data relating to one schematic.
void RemoveListener(SCHEMATIC_LISTENER *aListener)
Remove the specified listener.
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
void AddListener(SCHEMATIC_LISTENER *aListener)
Add a listener to the schematic to receive calls whenever something on the schematic has been modifie...
bool ResolveTextVar(const SCH_SHEET_PATH *aSheetPath, wxString *token, int aDepth) const
SCH_SHEET_PATH & CurrentSheet() const
void SyncView()
Mark all items for refresh.
EESCHEMA_SETTINGS * eeconfig() const
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Handle actions specific to the schematic editor.
Schematic editor (Eeschema) main window.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
bool SaveProject(bool aSaveAs=false)
Save the currently-open schematic (including its hierarchy) and associated project.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void AddItem(const SCH_REFERENCE &aItem)
A helper to define a symbol's reference designator in a schematic.
void Split()
Attempt to split the reference designator into a name (U) and number (1).
SCH_SYMBOL * GetSymbol() const
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
void GetSheetsWithinPath(std::vector< SCH_SHEET_PATH > &aSheets, const SCH_SHEET_PATH &aSheetPath) const
Add a SCH_SHEET_PATH object to aSheets for each sheet in the list that are contained within aSheetPat...
void GetSymbolsWithinPath(SCH_REFERENCE_LIST &aReferences, const SCH_SHEET_PATH &aSheetPath, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets that are contained wi...
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
const std::vector< SCH_SHEET_INSTANCE > & GetInstances() const
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
bool IsMissingLibSymbol() const
Check to see if the library symbol is set to the dummy library symbol.
bool IsPower() const override
const std::vector< TEMPLATE_FIELDNAME > & GetTemplateFieldNames()
Return a template field name list for read only access.
void SetTable(wxGridTableBase *table, bool aTakeOwnership=false)
Hide wxGrid's SetTable() method with one which doesn't mess up the grid column widths when setting th...
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
wxString GetGeneratedFieldDisplayName(const wxString &aSource)
Returns any variables unexpanded, e.g.
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, int aFlags)
bool EnsureFileDirectoryExists(wxFileName *aTargetFullFileName, const wxString &aBaseFilename, REPORTER *aReporter)
Make aTargetFullFileName absolute and create the path of this file if it doesn't yet exist.
bool IsGeneratedField(const wxString &aSource)
Returns true if the string is generated, e.g contains a single text var reference.
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aDetailedMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll)
Display a warning dialog with aMessage and returns the user response.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
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.
wxDEFINE_EVENT(EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, wxCommandEvent)
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 DISPLAY_NAME_COLUMN
#define FIELD_NAME_COLUMN
#define SHOW_FIELD_COLUMN
@ FRAME_FOOTPRINT_CHOOSER
@ GRIDTRICKS_FIRST_SHOWHIDE
@ GRIDTRICKS_FIRST_CLIENT_ID
static const std::string CsvFileExtension
static wxString CsvFileWildcard()
KICOMMON_API wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
std::vector< FAB_LAYER_COLOR > dummy
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
static BOM_FMT_PRESET CSV()
static std::vector< BOM_FMT_PRESET > BuiltInPresets()
wxString refRangeDelimiter
static BOM_PRESET DefaultEditing()
std::vector< BOM_FIELD > fieldsOrdered
bool includeExcludedFromBOM
static std::vector< BOM_PRESET > BuiltInPresets()
std::map< std::string, int > field_widths
A simple container for sheet instance information.
Hold a name of a symbol's field, field value, and default visibility.
Definition for symbol library class.
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...
wxString GetCanonicalFieldName(FIELD_T aFieldType)
Definition of file extensions used in Kicad.