51#include <wx/textdlg.h>
52#include <wx/filedlg.h>
63#define COLUMN_MARGIN 3
65#define COLUMN_MARGIN 15
81 wxDataViewListCtrl* aFieldsCtrl,
95 _(
"Browse for footprint" ) );
96 menu.AppendSeparator();
101 _(
"Show datasheet in browser" ) );
102 menu.AppendSeparator();
117 if( frame->ShowModal( &fpid,
m_dlg ) )
125 wxString datasheet_uri =
m_grid->GetCellValue(
m_grid->GetGridCursorRow(),
147 for(
int row = 0; row <
m_fieldsCtrl->GetItemCount(); row++ )
173 m_currentBomPreset( nullptr ),
174 m_lastSelectedBomPreset( nullptr ),
176 m_schSettings( parent->Schematic().Settings() )
195 m_fieldsCtrl->AppendTextColumn(
_(
"Field" ), wxDATAVIEW_CELL_INERT, 0, wxALIGN_LEFT, 0 );
196 m_fieldsCtrl->AppendTextColumn(
_(
"Label" ), wxDATAVIEW_CELL_EDITABLE, 0, wxALIGN_LEFT, 0 );
197 m_fieldsCtrl->AppendToggleColumn(
_(
"Show" ), wxDATAVIEW_CELL_ACTIVATABLE, 0,
199 m_fieldsCtrl->AppendToggleColumn(
_(
"Group By" ), wxDATAVIEW_CELL_ACTIVATABLE, 0,
204 m_fieldsCtrl->AppendTextColumn(
_(
"Name" ), wxDATAVIEW_CELL_INERT, 0, wxALIGN_LEFT, 0 );
220 m_filter->SetDescriptiveText(
_(
"Filter" ) );
232 for(
int row = 0; row <
m_fieldsCtrl->GetItemCount(); ++row )
255 m_grid->UseNativeColHeader(
true );
259 m_grid->SetSelectionMode( wxGrid::wxGridSelectCells );
266 m_grid->SetDefaultRowSize(
m_grid->GetDefaultRowSize() + 4 );
305 case SCOPE::SCOPE_SHEET_RECURSIVE:
m_radioRecursive->SetValue(
true );
break;
313 m_grid->Connect( wxEVT_GRID_COL_SORT,
315 m_grid->Connect( wxEVT_GRID_COL_MOVE,
329 wxGridCellAttr* attr =
new wxGridCellAttr;
330 attr->SetReadOnly(
false );
336 m_grid->SetColAttr( aCol, attr );
341 m_grid->SetColAttr( aCol, attr );
348 m_grid->SetColAttr( aCol, attr );
353 m_grid->SetColAttr( aCol, attr );
354 m_grid->SetColFormatNumber( aCol );
358 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
359 m_grid->SetColAttr( aCol, attr );
360 m_grid->SetColFormatBool( aCol );
365 m_grid->SetColAttr( aCol, attr );
369 attr->SetEditor(
m_grid->GetDefaultEditor() );
370 m_grid->SetColAttr( aCol, attr );
371 m_grid->SetColFormatCustom( aCol, wxGRID_VALUE_STRING );
379 wxSize defaultDlgSize = ConvertDialogToPixels( wxSize( 600, 300 ) );
382 m_grid->AutoSizeColumns(
false );
384 bool sortAscending =
true;
386 for(
int col = 0; col <
m_grid->GetNumberCols(); ++col )
422 int maxWidth = defaultDlgSize.x / 3;
424 m_grid->SetColSize( col, std::clamp( textWidth, 100, maxWidth ) );
434 m_grid->SetSortingColumn( sortCol, sortAscending );
441 m_grid->Disconnect( wxEVT_GRID_COL_SORT,
444 m_grid->Disconnect( wxEVT_GRID_COL_SORT,
449 m_grid->PopEventHandler(
true );
457 if( !wxDialog::TransferDataFromWindow() )
467 if( selection.GetSize() == 1 )
486 if( ref.GetSymbol() == symbol )
511 m_grid->GoToCell( row, valueCol );
513 m_grid->GoToCell( row, refCol );
514 else if( anyCol != -1 )
515 m_grid->GoToCell( row, anyCol );
536 if( !wxDialog::TransferDataFromWindow() )
550 commit.
Push( wxS(
"Symbol Fields Table Edit" ) );
564 bool show,
bool groupBy,
bool addedByUser )
576 wxVector<wxVariant> fieldsCtrlRow;
577 std::string key( aFieldName.ToUTF8() );
580 fieldsCtrlRow.push_back( wxVariant( aFieldName ) );
581 fieldsCtrlRow.push_back( wxVariant( aLabelValue ) );
582 fieldsCtrlRow.push_back( wxVariant( show ) );
583 fieldsCtrlRow.push_back( wxVariant( groupBy ) );
584 fieldsCtrlRow.push_back( wxVariant( aFieldName ) );
588 wxGridTableMessage msg(
m_dataModel, wxGRIDTABLE_NOTIFY_COLS_APPENDED, 1 );
589 m_grid->ProcessTableMessage( msg );
599 bool groupBy =
false;
624 std::set<wxString> userFieldNames;
631 userFieldNames.insert( symbol->
GetFields()[j].GetName() );
634 for(
const wxString& fieldName : userFieldNames )
641 if( userFieldNames.count( templateFieldname.m_Name ) == 0 )
652 wxTextEntryDialog dlg(
this,
_(
"New field name:" ),
_(
"Add Field" ) );
654 if( dlg.ShowModal() != wxID_OK )
657 wxString fieldName = dlg.GetValue();
659 if( fieldName.IsEmpty() )
669 DisplayError(
this, wxString::Format(
_(
"Field name '%s' already in use." ),
691 wxCHECK_RET( row != -1, wxS(
"Some user defined field must be selected first" ) );
692 wxCHECK_RET( row >=
MANDATORY_FIELDS, wxS(
"Mandatory fields cannot be removed" ) );
697 wxString confirm_msg = wxString::Format(
_(
"Are you sure you want to remove the field '%s'?" ),
700 if( !
IsOK(
this, confirm_msg ) )
722 wxGridTableMessage msg(
m_dataModel, wxGRIDTABLE_NOTIFY_COLS_DELETED, col, 1 );
724 m_grid->ProcessTableMessage( msg );
738 wxCHECK_RET( row != -1, wxS(
"Some user defined field must be selected first" ) );
739 wxCHECK_RET( row >=
MANDATORY_FIELDS, wxS(
"Mandatory fields cannot be renamed" ) );
740 wxCHECK_RET( !fieldName.IsEmpty(), wxS(
"Field must have a name" ) );
743 wxCHECK_RET( col != -1, wxS(
"Existing field name missing from data model" ) );
745 wxTextEntryDialog dlg(
this,
_(
"New field name:" ),
_(
"Rename Field" ) );
747 if( dlg.ShowModal() != wxID_OK )
750 wxString newFieldName = dlg.GetValue();
753 if( newFieldName == fieldName )
759 wxString confirm_msg = wxString::Format(
_(
"Field name %s already exists." ),
787 wxPoint pos = aEvent.GetPosition();
788 wxRect ctrlRect =
m_filter->GetScreenRect();
789 int buttonWidth = ctrlRect.GetHeight();
792 if(
m_filter->IsSearchButtonVisible() && pos.x < buttonWidth )
793 SetCursor( wxCURSOR_ARROW );
794 else if(
m_filter->IsCancelButtonVisible() && pos.x > ctrlRect.GetWidth() - buttonWidth )
795 SetCursor( wxCURSOR_ARROW );
797 SetCursor( wxCURSOR_IBEAM );
819 wxDataViewItem item =
event.GetItem();
821 int col =
event.GetColumn();
836 m_grid->ShowCol( dataCol );
838 m_grid->HideCol( dataCol );
852 DisplayError(
this,
_(
"The Quantity column cannot be grouped by." ) );
860 DisplayError(
this,
_(
"The Item Number column cannot be grouped by." ) );
914 int sortCol = aEvent.GetCol();
927 if(
m_grid->IsSortingBy( sortCol ) )
930 ascending = !
m_grid->IsSortOrderAscending();
948 int origPos = aEvent.GetCol();
953 for(
int i = 0; i <
m_grid->GetNumberCols(); i++ )
955 if(
m_grid->IsColShown( i ) )
965 int newPos =
m_grid->GetColPos( origPos );
984 wxDataViewItem item = aEvent.GetItem();
1009 int col = aEvent.GetRowOrCol();
1047 m_grid->ClearSelection();
1050 m_grid->SetGridCursor( event.GetRow(), event.GetCol() );
1066 std::set<SCH_REFERENCE> refs;
1067 std::set<SCH_ITEM*> symbols;
1070 if( aEvent.Selecting() )
1072 for(
int i = aEvent.GetTopRow(); i <= aEvent.GetBottomRow(); i++ )
1079 symbols.insert( ref.GetSymbol() );
1086 if( refs.size() > 0 )
1089 wxString symbol_path = refs.begin()->GetFullPath();
1104 std::vector<SCH_ITEM*> items( symbols.begin(), symbols.end() );
1106 if( refs.size() > 0 )
1107 selTool->
SyncSelection( refs.begin()->GetSheetPath(),
nullptr, items );
1220 wxFileDialog saveDlg(
this,
_(
"Bill of Materials Output File" ),
path, fn.GetFullName(),
1223 if( saveDlg.ShowModal() == wxID_CANCEL )
1227 wxFileName file = wxFileName( saveDlg.GetPath() );
1228 wxString defaultPath = fn.GetPathWithSep();
1230 msg.Printf(
_(
"Do you want to use a path relative to\n'%s'?" ), defaultPath );
1232 wxMessageDialog dialog(
this, msg,
_(
"BOM Output File" ),
1233 wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
1235 if( dialog.ShowModal() == wxID_YES )
1237 if( !file.MakeRelativeTo( defaultPath ) )
1239 wxMessageBox(
_(
"Cannot make path relative (target volume different from schematic "
1241 _(
"BOM Output File" ), wxOK | wxICON_ERROR );
1254 _(
"Changes have not yet been saved. Export unsaved data?" ),
"",
1255 _(
"OK" ),
_(
"Cancel" ) )
1265 std::function<bool( wxString* )> textResolver =
1266 [&]( wxString* token ) ->
bool
1276 if(
path.IsEmpty() )
1278 DisplayError(
this,
_(
"No output file specified in Export tab." ) );
1285 wxFileName outputFile = wxFileName::FileName(
path );
1292 msg.Printf(
_(
"Could not open/create path '%s'." ), outputFile.GetPath() );
1297 wxFFile out( outputFile.GetFullPath(),
"wb" );
1299 if( !out.IsOpened() )
1301 msg.Printf(
_(
"Could not create BOM output '%s'." ), outputFile.GetFullPath() );
1310 msg.Printf(
_(
"Could not write BOM output '%s'." ), outputFile.GetFullPath() );
1316 msg.Printf(
_(
"Wrote BOM output to '%s'" ), outputFile.GetFullPath() );
1379 for(
int i = 0; i <
m_grid->GetNumberCols(); i++ )
1381 if(
m_grid->IsColShown( i ) )
1390 wxCommandEvent* evt =
new wxCommandEvent( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, wxID_ANY );
1392 if( wxWindow* parent = GetParent() )
1393 wxQueueEvent( parent, evt );
1399 std::vector<BOM_PRESET> ret;
1401 for(
const std::pair<const wxString, BOM_PRESET>& pair :
m_bomPresets )
1403 if( !pair.second.readOnly )
1404 ret.emplace_back( pair.second );
1416 for(
const BOM_PRESET& preset : aPresetList )
1434 wxCommandEvent
dummy;
1479 int default_idx = 0;
1481 for( std::pair<const wxString, BOM_PRESET>& pair :
m_bomPresets )
1484 static_cast<void*
>( &pair.second ) );
1510 [&](
const std::pair<const wxString, BOM_PRESET>& aPair )
1512 const BOM_PRESET& preset = aPair.second;
1515 if( !( preset.sortAsc == current.sortAsc
1516 && preset.filterString == current.filterString
1517 && preset.groupSymbols == current.groupSymbols
1518 && preset.excludeDNP == current.excludeDNP
1519 && preset.includeExcludedFromBOM
1520 == current.includeExcludedFromBOM ) )
1532 if( preset.sortField != wxGetTranslation( current.
sortField ) )
1536 std::vector<BOM_FIELD>
A,
B;
1538 for(
const BOM_FIELD& field : preset.fieldsOrdered )
1540 if( field.show || field.groupBy )
1541 A.emplace_back( field );
1546 if( field.show || field.groupBy )
1547 B.emplace_back( field );
1553 if( it != m_bomPresets.end() )
1557 bool do_translate = it->second.
readOnly;
1558 wxString
text = do_translate ? wxGetTranslation( it->first ) : it->first;
1559 m_cbBomPresets->SetStringSelection(
text );
1563 m_cbBomPresets->SetSelection( m_cbBomPresets->GetCount() - 3 );
1566 m_currentBomPreset =
static_cast<BOM_PRESET*
>(
1567 m_cbBomPresets->GetClientData( m_cbBomPresets->GetSelection() ) );
1577 wxString ui_label = aName;
1579 for( std::pair<const wxString, BOM_PRESET>& pair :
m_bomPresets )
1581 if( pair.first != aName )
1584 if( pair.second.readOnly ==
true )
1585 ui_label = wxGetTranslation( aName );
1609 auto resetSelection =
1618 if( index == count - 3 )
1624 else if( index == count - 2 )
1632 wxTextEntryDialog dlg(
this,
_(
"BOM preset name:" ),
_(
"Save BOM Preset" ),
name );
1634 if( dlg.ShowModal() != wxID_OK )
1640 name = dlg.GetValue();
1658 wxMessageBox(
_(
"Default presets cannot be modified.\nPlease use a different name." ),
1659 _(
"Error" ), wxOK | wxICON_ERROR,
this );
1666 if( !
IsOK(
this,
_(
"Overwrite existing preset?" ) ) )
1685 else if( index == count - 1 )
1688 wxArrayString headers;
1689 std::vector<wxArrayString> items;
1691 headers.Add(
_(
"Presets" ) );
1693 for( std::pair<const wxString, BOM_PRESET>& pair :
m_bomPresets )
1695 if( !pair.second.readOnly )
1698 item.Add( pair.first );
1699 items.emplace_back( item );
1711 if( idx != wxNOT_FOUND )
1758 for(
int i = 0; i <
m_dataModel->GetColsCount(); i++ )
1763 for(
int j = 0; j <
m_fieldsCtrl->GetItemCount(); j++ )
1778 for(
int i = 0; i <
m_fieldsCtrl->GetItemCount(); i++ )
1785 wxASSERT_MSG(
true,
"Fields control has a field not found in the data model." );
1790 std::string fieldNameStr( fieldName.ToUTF8() );
1795 m_grid->SetColLabelValue( col, label );
1832 std::vector<BOM_FMT_PRESET> ret;
1834 for(
const std::pair<const wxString, BOM_FMT_PRESET>& pair :
m_bomFmtPresets )
1836 if( !pair.second.readOnly )
1837 ret.emplace_back( pair.second );
1867 wxCommandEvent
dummy;
1911 int default_idx = 0;
1913 for( std::pair<const wxString, BOM_FMT_PRESET>& pair :
m_bomFmtPresets )
1916 static_cast<void*
>( &pair.second ) );
1943 [&](
const std::pair<const wxString, BOM_FMT_PRESET>& aPair )
1945 return ( aPair.second.fieldDelimiter == current.fieldDelimiter
1946 && aPair.second.stringDelimiter == current.stringDelimiter
1947 && aPair.second.refDelimiter == current.refDelimiter
1948 && aPair.second.refRangeDelimiter == current.refRangeDelimiter
1949 && aPair.second.keepTabs == current.keepTabs
1950 && aPair.second.keepLineBreaks == current.keepLineBreaks );
1957 bool do_translate = it->second.readOnly;
1958 wxString
text = do_translate ? wxGetTranslation( it->first ) : it->first;
1978 wxString ui_label = aName;
1980 for( std::pair<const wxString, BOM_FMT_PRESET>& pair :
m_bomFmtPresets )
1982 if( pair.first != aName )
1985 if( pair.second.readOnly ==
true )
1986 ui_label = wxGetTranslation( aName );
2011 auto resetSelection =
2020 if( index == count - 3 )
2026 else if( index == count - 2 )
2034 wxTextEntryDialog dlg(
this,
_(
"BOM preset name:" ),
_(
"Save BOM Preset" ),
name );
2036 if( dlg.ShowModal() != wxID_OK )
2042 name = dlg.GetValue();
2060 wxMessageBox(
_(
"Default presets cannot be modified.\nPlease use a different name." ),
2061 _(
"Error" ), wxOK | wxICON_ERROR,
this );
2068 if( !
IsOK(
this,
_(
"Overwrite existing preset?" ) ) )
2087 else if( index == count - 1 )
2090 wxArrayString headers;
2091 std::vector<wxArrayString> items;
2093 headers.Add(
_(
"Presets" ) );
2095 for( std::pair<const wxString, BOM_FMT_PRESET>& pair :
m_bomFmtPresets )
2097 if( !pair.second.readOnly )
2100 item.Add( pair.first );
2101 items.emplace_back( item );
2113 if( idx != wxNOT_FOUND )
2166 bool modified =
false;
2169 std::vector<BOM_PRESET> presets;
2171 for(
const std::pair<const wxString, BOM_PRESET>& pair :
m_bomPresets )
2173 if( !pair.second.readOnly )
2174 presets.emplace_back( pair.second );
2191 std::vector<BOM_FMT_PRESET> fmts;
2193 for(
const std::pair<const wxString, BOM_FMT_PRESET>& pair :
m_bomFmtPresets )
2195 if( !pair.second.readOnly )
2196 fmts.emplace_back( pair.second );
2217 std::vector<SCH_ITEM*>& aSchItem )
2234 AddField( field.GetCanonicalName(), field.GetName(),
true,
false, true );
2240 std::set<SCH_SYMBOL*> symbols;
2244 symbols.insert( ref.GetSymbol() );
2249 for(
SCH_FIELD& field : symbol->GetFields() )
2250 AddField( field.GetCanonicalName(), field.GetName(),
true,
false,
true );
2264 std::vector<SCH_ITEM*>& aSchItem )
2286 std::vector<SCH_ITEM*>& aSchItem )
2303 AddField( field.GetCanonicalName(), field.GetName(),
true,
false, true );
2309 std::set<SCH_SYMBOL*> symbols;
2313 symbols.insert( ref.GetSymbol() );
2318 for(
SCH_FIELD& field : symbol->GetFields() )
2319 AddField( field.GetCanonicalName(), field.GetName(),
true,
false,
true );
2348 wxEVT_GRID_RANGE_SELECTED,
2357 wxEVT_GRID_RANGE_SELECTED,
2369 for(
size_t i = 0; i < aCachedRefs.
GetCount(); i++ )
2396 if( basePath.Path() == instance.m_Path )
2404 subSheets.push_back( sheetPath );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
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
wxStaticText * m_bomPresetsLabel
wxCheckBox * m_checkKeepTabs
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
wxStaticText * m_labelBomExportPresets
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
void OnRemoveField(wxCommandEvent &event) override
void OnTableCellClick(wxGridEvent &event) override
DIALOG_SYMBOL_FIELDS_TABLE(SCH_EDIT_FRAME *parent)
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 OnFieldsCtrlSelectionChanged(wxDataViewEvent &event) override
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
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)
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
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
wxString GetColFieldName(int aCol)
int GetFieldNameCol(wxString aFieldName)
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)
static const wxString ITEM_NUMBER_VARIABLE
void SetIncludeExcludedFromBOM(bool include)
int GetDataWidth(int aCol)
void UpdateReferences(const SCH_REFERENCE_LIST &aRefs)
void ApplyData(std::function< void(SCH_SYMBOL &, SCH_SHEET_PATH &)> symbolChangeHandler)
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)
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
FIELDS_EDITOR_GRID_TRICKS(DIALOG_SHIM *aParent, WX_GRID *aGrid, wxDataViewListCtrl *aFieldsCtrl, FIELDS_EDITOR_GRID_DATA_MODEL *aDataModel)
void doPopupSelection(wxCommandEvent &event) override
FIELDS_EDITOR_GRID_DATA_MODEL * m_dataModel
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.
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.
SCH_SHEET_PATH & CurrentSheet() const override
void RemoveListener(SCHEMATIC_LISTENER *aListener)
Remove the specified listener.
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
SCH_SHEET_LIST Hierarchy() const override
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
void SyncView()
Mark all items for refresh.
EESCHEMA_SETTINGS * eeconfig() const
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
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.
void FocusOnItem(SCH_ITEM *aItem)
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
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...
SCH_SCREEN * LastScreen()
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
int GetFieldCount() const
Return the number of fields in this symbol.
bool IsMissingLibSymbol() const
Check to see if the library symbol is set to the dummy library symbol.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
bool IsPower() const override
const TEMPLATE_FIELDNAMES & 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.
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 IsTextVar(const wxString &aSource)
Returns true if the string is a text var, e.g starts with ${.
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
wxString GetTextVars(const wxString &aSource)
Returns any variables unexpanded, e.g.
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 DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
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.
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, EMBEDDED_FILES *aFiles)
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 wxFont GetInfoFont(wxWindow *aWindow)
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...
std::vector< FAB_LAYER_COLOR > dummy
static BOM_FMT_PRESET CSV()
static std::vector< BOM_FMT_PRESET > BuiltInPresets()
wxString refRangeDelimiter
static BOM_PRESET DefaultEditing()
std::vector< BOM_FIELD > fieldsOrdered
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.
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
Definition for symbol library class.
wxString GetCanonicalFieldName(int idx)
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 5 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
Definition of file extensions used in Kicad.