50#include <wx/textdlg.h> 
   51#include <wx/filedlg.h> 
   63#define COLUMN_MARGIN 3 
   65#define COLUMN_MARGIN 15 
  111        int col = 
m_grid->GetGridCursorCol();
 
  116            menu.AppendSeparator();
 
  121            menu.AppendSeparator();
 
 
  129        int row = 
m_grid->GetGridCursorRow();
 
  130        int col = 
m_grid->GetGridCursorCol();
 
  135            wxString fpid = 
m_grid->GetCellValue( row, col );
 
  139                if( frame->ShowModal( &fpid, 
m_dlg ) )
 
  140                    m_grid->SetCellValue( row, col, fpid );
 
  147            wxString datasheet_uri = 
m_grid->GetCellValue( row, col );
 
  153            if( !
m_grid->CommitPendingChanges( 
false ) )
 
  161            m_dlg->ShowHideColumn( col, show );
 
  163            wxString fieldName = 
m_dataModel->GetColFieldName( col );
 
 
 
  227    wxGridCellAttr* attr = 
new wxGridCellAttr;
 
  228    attr->SetReadOnly( 
true );
 
  231    attr = 
new wxGridCellAttr;
 
  232    attr->SetRenderer( 
new wxGridCellBoolRenderer() );
 
  234    attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
 
  237    attr = 
new wxGridCellAttr;
 
  238    attr->SetRenderer( 
new wxGridCellBoolRenderer() );
 
  240    attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
 
  246    m_filter->SetDescriptiveText( 
_( 
"Filter" ) );
 
  248    attr = 
new wxGridCellAttr;
 
  254    m_grid->UseNativeColHeader( 
true );
 
  258    m_grid->SetSelectionMode( wxGrid::wxGridSelectCells );
 
  276        SetTitle( 
m_job->GetSettingsDialogTitle() );
 
  289        for( 
const wxString& fieldName : 
m_job->m_fieldsOrdered )
 
  292            field.
name = fieldName;
 
  293            field.
show = !fieldName.StartsWith( wxT( 
"__" ), &field.
name );
 
  296            if( ( 
m_job->m_fieldsLabels.size() > i ) && !
m_job->m_fieldsLabels[i].IsEmpty() )
 
  321        fmtPreset.
name = 
m_job->m_bomFmtPresetName;
 
  349    if( visible_column.IsEmpty() )
 
  351        visible_column = wxT( 
"0" );
 
  355    CallAfter( [
this, cfg]()
 
  382        m_parent->Schematic().AddListener( 
this );
 
  387        m_grid->EnableEditing( 
false );
 
 
  406    for( 
int i = 0; i < 
m_grid->GetNumberCols(); i++ )
 
  408        if( 
m_grid->IsColShown( i ) )
 
  410            std::string fieldName( 
m_dataModel->GetColFieldName( i ).ToUTF8() );
 
  424    m_grid->PopEventHandler( 
true );
 
 
  434    if( aIsLeftPanelCollapsed )
 
 
  449    wxGridCellAttr* attr = 
new wxGridCellAttr;
 
  450    attr->SetReadOnly( 
false );
 
  474        attr->SetAlignment( wxALIGN_RIGHT, wxALIGN_CENTER );
 
  475        attr->SetRenderer( 
new wxGridCellNumberRenderer() );
 
  480        attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
 
  493        attr->SetEditor( 
m_grid->GetDefaultEditor() );
 
 
  502    wxSize defaultDlgSize = ConvertDialogToPixels( wxSize( 600, 300 ) );
 
  505    m_grid->AutoSizeColumns( 
false );
 
  507    bool sortAscending = 
true;
 
  509    for( 
int col = 0; col < 
m_grid->GetNumberCols(); ++col )
 
  535            std::string key( 
m_dataModel->GetColFieldName( col ).ToUTF8() );
 
  545                int maxWidth = defaultDlgSize.x / 3;
 
  547                m_grid->SetColSize( col, std::clamp( textWidth, 100, maxWidth ) );
 
  557    m_grid->SetSortingColumn( sortCol, sortAscending );
 
 
  563    if( !wxDialog::TransferDataFromWindow() )
 
  573    wxCommandEvent 
dummy;
 
  576    if( selection.GetSize() == 1 )
 
  588        for( 
int row = 0; row < 
m_dataModel->GetNumberRows(); ++row )
 
  590            std::vector<SCH_REFERENCE> references = 
m_dataModel->GetRowReferences( row );
 
  595                if( ref.GetSymbol() == symbol )
 
  609                for( 
int col = 0; col < 
m_dataModel->GetNumberCols(); col++ )
 
  615                    else if( anyCol == -1 && 
m_dataModel->GetShowColumn( col ) )
 
  619                if( valueCol != -1 && 
m_dataModel->GetShowColumn( valueCol ) )
 
  620                    m_grid->GoToCell( row, valueCol );
 
  621                else if( refCol != -1 && 
m_dataModel->GetShowColumn( refCol ) )
 
  622                    m_grid->GoToCell( row, refCol );
 
  623                else if( anyCol != -1 )
 
  624                    m_grid->GoToCell( row, anyCol );
 
 
  642    if( !
m_grid->CommitPendingChanges() )
 
  645    if( !wxDialog::TransferDataFromWindow() )
 
  654    std::set<wxString> selectedVariantNames;
 
  660    if( !commit.
Empty() )
 
  662        commit.
Push( wxS( 
"Symbol Fields Table Edit" ) );  
 
  667    m_parent->SetCurrentSheet( currentSheet );
 
 
  676                                           bool show, 
bool groupBy, 
bool addedByUser )
 
  688    wxGridTableMessage msg( 
m_dataModel, wxGRIDTABLE_NOTIFY_COLS_APPENDED, 1 );
 
  689    m_grid->ProcessTableMessage( msg );
 
  692            [&]() -> std::pair<int, int>
 
 
  703    auto addMandatoryField =
 
  704            [&]( 
FIELD_T fieldId, 
bool show, 
bool groupBy )
 
  724    std::set<wxString> userFieldNames;
 
  732            if( !field.IsMandatory() && !field.IsPrivate() )
 
  733                userFieldNames.insert( field.GetName() );
 
  737    for( 
const wxString& fieldName : userFieldNames )
 
  743        if( userFieldNames.count( tfn.m_Name ) == 0 )
 
 
  751    wxTextEntryDialog dlg( 
this, 
_( 
"New field name:" ), 
_( 
"Add Field" ) );
 
  753    if( dlg.ShowModal() != wxID_OK )
 
  756    wxString fieldName = dlg.GetValue();
 
  758    if( fieldName.IsEmpty() )
 
  764    for( 
int i = 0; i < 
m_dataModel->GetNumberCols(); ++i )
 
  766        if( fieldName == 
m_dataModel->GetColFieldName( i ) )
 
  768            DisplayError( 
this, wxString::Format( 
_( 
"Field name '%s' already in use." ), fieldName ) );
 
 
  791                        DisplayError( 
this, wxString::Format( 
_( 
"The first %d fields are mandatory." ),
 
  797                return IsOK( 
this, wxString::Format( 
_( 
"Are you sure you want to remove the field '%s'?" ),
 
  803                int col = 
m_dataModel->GetFieldNameCol( fieldName );
 
 
  823    if( selectedRows.empty() )
 
  826    int row = selectedRows[0];
 
  832            DisplayError( 
this, wxString::Format( 
_( 
"The first %d fields are mandatory and names cannot be changed." ),
 
  840    int col = 
m_dataModel->GetFieldNameCol( fieldName );
 
  841    wxCHECK_RET( col != -1, wxS( 
"Existing field name missing from data model" ) );
 
  843    wxTextEntryDialog dlg( 
this, 
_( 
"New field name:" ), 
_( 
"Rename Field" ), fieldName );
 
  845    if( dlg.ShowModal() != wxID_OK )
 
  848    wxString newFieldName = dlg.GetValue();
 
  851    if( newFieldName == fieldName )
 
  855    if( 
m_dataModel->GetFieldNameCol( newFieldName ) != -1 )
 
  857         wxString confirm_msg = wxString::Format( 
_( 
"Field name %s already exists." ), newFieldName );
 
 
  884#if defined( __WXOSX__ ) || wxCHECK_VERSION( 3, 3, 0 )  
  885    wxPoint pos = aEvent.GetPosition();
 
  886    wxRect  ctrlRect = 
m_filter->GetScreenRect();
 
  887    int     buttonWidth = ctrlRect.GetHeight();         
 
  890    if( 
m_filter->IsSearchButtonVisible() && pos.x < buttonWidth )
 
  891        SetCursor( wxCURSOR_ARROW );
 
  892    else if( 
m_filter->IsCancelButtonVisible() && pos.x > ctrlRect.GetWidth() - buttonWidth )
 
  893        SetCursor( wxCURSOR_ARROW );
 
  895        SetCursor( wxCURSOR_IBEAM );
 
 
  910    switch( aEvent.GetSelection() )
 
  912    case 0: 
setScope( SCOPE::SCOPE_ALL );             
break;
 
  913    case 1: 
setScope( SCOPE::SCOPE_SHEET );           
break;
 
  914    case 2: 
setScope( SCOPE::SCOPE_SHEET_RECURSIVE ); 
break;
 
 
  936    menu.Append( 4204, 
_( 
"Include 'DNP' Symbols" ),
 
  937                 _( 
"Show symbols marked 'DNP' in the table.  This setting also controls whether or not 'DNP' " 
  938                    "symbols are included on export." ),
 
  942    menu.Append( 4205, 
_( 
"Include 'Exclude from BOM' Symbols" ),
 
  943                 _( 
"Show symbols marked 'Exclude from BOM' in the table.  Symbols marked 'Exclude from BOM' " 
  944                    "are never included on export." ),
 
  946    menu.Check( 4205, 
m_dataModel->GetIncludeExcludedFromBOM() );
 
  948    menu.AppendSeparator();
 
  950    menu.Append( 4206, 
_( 
"Highlight on Cross-probe" ),
 
  951                 _( 
"Highlight corresponding item on canvas when it is selected in the table" ),
 
  955    menu.Append( 4207, 
_( 
"Select on Cross-probe" ),
 
  956                 _( 
"Select corresponding item on canvas when it is selected in the table" ),
 
  961    int menu_id = 
m_bMenu->GetPopupMenuSelectionFromUser( menu );
 
  963    if( menu_id == 0 || menu_id == 4204 )
 
  971    else if( menu_id == 1 || menu_id == 4205 )
 
  979    else if( menu_id == 3 || menu_id == 4206 )
 
  986    else if( menu_id == 4 || menu_id == 4207 )
 
 
  998    int         sortCol = aEvent.GetCol();
 
  999    std::string key( 
m_dataModel->GetColFieldName( sortCol ).ToUTF8() );
 
 1011    if( 
m_grid->IsSortingBy( sortCol ) )
 
 1014        ascending = !
m_grid->IsSortOrderAscending();
 
 
 1032    int origPos = aEvent.GetCol();
 
 1037    for( 
int i = 0; i < 
m_grid->GetNumberCols(); i++ )
 
 1039        if( 
m_grid->IsColShown( i ) )
 
 1041            std::string fieldName( 
m_dataModel->GetColFieldName( i ).ToUTF8() );
 
 1049                int newPos = 
m_grid->GetColPos( origPos );
 
 1052                if( newPos < origPos )
 
 
 1093    int row = aEvent.GetRow();
 
 1095    wxCHECK( row < m_viewControlsGrid->GetNumberRows(),  );
 
 1097    switch( aEvent.GetCol() )
 
 1103        int      dataCol = 
m_dataModel->GetFieldNameCol( fieldName );
 
 1108            m_grid->SetColLabelValue( dataCol, label );
 
 1126        int      dataCol = 
m_dataModel->GetFieldNameCol( fieldName );
 
 1138        int      dataCol = 
m_dataModel->GetFieldNameCol( fieldName );
 
 1140        if( 
m_dataModel->ColIsQuantity( dataCol ) && value )
 
 1142            DisplayError( 
this, 
_( 
"The Quantity column cannot be grouped by." ) );
 
 1149        if( 
m_dataModel->ColIsItemNumber( dataCol ) && value )
 
 1151            DisplayError( 
this, 
_( 
"The Item Number column cannot be grouped by." ) );
 
 
 1200    if( 
m_dataModel->IsExpanderColumn( event.GetCol() ) )
 
 1202        m_grid->ClearSelection();
 
 1205        m_grid->SetGridCursor( event.GetRow(), event.GetCol() );
 
 
 1224    std::set<SCH_REFERENCE> refs;
 
 1225    std::set<SCH_ITEM*>     symbols;
 
 1228    if( aEvent.Selecting() )
 
 1230        for( 
int i = aEvent.GetTopRow(); i <= aEvent.GetBottomRow(); i++ )
 
 1237            symbols.insert( ref.GetSymbol() );
 
 1244        if( refs.size() > 0 )
 
 1248            wxString symbol_path = refs.begin()->GetFullPath();
 
 1261        std::vector<SCH_ITEM*> items( symbols.begin(), symbols.end() );
 
 1263        if( refs.size() > 0 )
 
 1264            selTool->
SyncSelection( refs.begin()->GetSheetPath(), 
nullptr, items );
 
 
 1277    int             remainingWidth = 
m_viewControlsGrid->GetSize().GetX() - showColWidth - groupByColWidth;
 
 
 1325    bool saveIncludeExcudedFromBOM = 
m_dataModel->GetIncludeExcludedFromBOM();
 
 1332    if( saveIncludeExcudedFromBOM )
 
 
 1376    wxFileName fn( 
Prj().AbsolutePath( 
m_parent->Schematic().GetFileName() ) );
 
 1379    wxFileDialog saveDlg( 
this, 
_( 
"Bill of Materials Output File" ), 
path, fn.GetFullName(),
 
 1382    if( saveDlg.ShowModal() == wxID_CANCEL )
 
 1386    wxFileName file = wxFileName( saveDlg.GetPath() );
 
 1387    wxString   defaultPath = fn.GetPathWithSep();
 
 1389    if( 
IsOK( 
this, wxString::Format( 
_( 
"Do you want to use a path relative to\n'%s'?" ), defaultPath ) ) )
 
 1391        if( !file.MakeRelativeTo( defaultPath ) )
 
 1393            DisplayErrorMessage( 
this, 
_( 
"Cannot make path relative (target volume different from schematic " 
 1394                                          "file volume)!" ) );
 
 
 1428                              _( 
"Changes have not yet been saved. Export unsaved data?" ), 
"",
 
 1429                              _( 
"OK" ), 
_( 
"Cancel" ) )
 
 1439    std::function<bool( wxString* )> textResolver =
 
 1440            [&]( wxString* token ) -> 
bool 
 1450    if( 
path.IsEmpty() )
 
 1452        DisplayError( 
this, 
_( 
"No output file specified in Export tab." ) );
 
 1459    wxFileName outputFile = wxFileName::FileName( 
path );
 
 1463                                    Prj().AbsolutePath( 
m_parent->Schematic().GetFileName() ),
 
 1466        msg.Printf( 
_( 
"Could not open/create path '%s'." ), outputFile.GetPath() );
 
 1471    wxFFile out( outputFile.GetFullPath(), 
"wb" );
 
 1473    if( !out.IsOpened() )
 
 1475        msg.Printf( 
_( 
"Could not create BOM output '%s'." ), outputFile.GetFullPath() );
 
 1484        msg.Printf( 
_( 
"Could not write BOM output '%s'." ), outputFile.GetFullPath() );
 
 1491    msg.Printf( 
_( 
"Wrote BOM output to '%s'" ), outputFile.GetFullPath() );
 
 
 1499        EndModal( wxID_CANCEL );
 
 
 1516            m_job->m_bomFmtPresetName = wxEmptyString;
 
 1521            m_job->m_bomPresetName = wxEmptyString;
 
 1537        m_job->m_fieldsOrdered.clear();
 
 1538        m_job->m_fieldsLabels.clear();
 
 1539        m_job->m_fieldsGroupBy.clear();
 
 1543            if( modelField.show )
 
 1544                m_job->m_fieldsOrdered.emplace_back( modelField.name );
 
 1546                m_job->m_fieldsOrdered.emplace_back( wxT( 
"__" ) + modelField.name );
 
 1548            m_job->m_fieldsLabels.emplace_back( modelField.label );
 
 1550            if( modelField.groupBy )
 
 1551                m_job->m_fieldsGroupBy.emplace_back( modelField.name );
 
 1554        EndModal( wxID_OK );
 
 
 1571    m_grid->CommitPendingChanges( 
true );
 
 1587    m_parent->Schematic().RemoveListener( 
this );
 
 1590    wxCommandEvent* evt = 
new wxCommandEvent( EDA_EVT_CLOSE_DIALOG_SYMBOL_FIELDS_TABLE, wxID_ANY );
 
 1592    if( wxWindow* parent = GetParent() )
 
 1593        wxQueueEvent( parent, evt );
 
 
 1599    std::vector<BOM_PRESET> ret;
 
 1601    for( 
const std::pair<const wxString, BOM_PRESET>& pair : 
m_bomPresets )
 
 1603        if( !pair.second.readOnly )
 
 1604            ret.emplace_back( pair.second );
 
 
 1616    for( 
const BOM_PRESET& preset : aPresetList )
 
 
 1634    wxCommandEvent 
dummy;
 
 
 1677    int default_idx = 0;
 
 1681        m_cbBomPresets->Append( wxGetTranslation( presetName ), (
void*) &preset );
 
 
 1706            [&]( 
const std::pair<const wxString, BOM_PRESET>& aPair )
 
 1708                const BOM_PRESET& preset = aPair.second;
 
 1711                if( !( preset.sortAsc == current.sortAsc
 
 1712                       && preset.filterString == current.filterString
 
 1713                       && preset.groupSymbols == current.groupSymbols
 
 1714                       && preset.excludeDNP == current.excludeDNP
 
 1715                       && preset.includeExcludedFromBOM == current.includeExcludedFromBOM ) )
 
 1726                if( preset.sortField != wxGetTranslation( current.
sortField ) )
 
 1730                std::vector<BOM_FIELD> 
A, 
B;
 
 1732                for( 
const BOM_FIELD& field : preset.fieldsOrdered )
 
 1734                    if( field.show || field.groupBy )
 
 1735                        A.emplace_back( field );
 
 1740                    if( field.show || field.groupBy )
 
 1741                        B.emplace_back( field );
 
 1747    if( it != m_bomPresets.end() )
 
 1751        bool     do_translate = it->second.readOnly;
 
 1752        wxString 
text = do_translate ? wxGetTranslation( it->first ) : it->first;
 
 1753        m_cbBomPresets->SetStringSelection( 
text );
 
 1757        m_cbBomPresets->SetSelection( m_cbBomPresets->GetCount() - 3 ); 
 
 1760    m_currentBomPreset = 
static_cast<BOM_PRESET*
>( m_cbBomPresets->GetClientData( m_cbBomPresets->GetSelection() ) );
 
 
 1769    wxString ui_label = aName;
 
 1773        if( presetName == aName )
 
 1775            if( preset.readOnly == 
true )
 
 1776                ui_label = wxGetTranslation( aName );
 
 
 1801    auto resetSelection =
 
 1810    if( index == count - 3 )
 
 1816    else if( index == count - 2 )
 
 1824        wxTextEntryDialog dlg( 
this, 
_( 
"BOM preset name:" ), 
_( 
"Save BOM Preset" ), 
name );
 
 1826        if( dlg.ShowModal() != wxID_OK )
 
 1832        name = dlg.GetValue();
 
 1850            wxMessageBox( 
_( 
"Default presets cannot be modified.\nPlease use a different name." ),
 
 1851                          _( 
"Error" ), wxOK | wxICON_ERROR, 
this );
 
 1858            if( !
IsOK( 
this, 
_( 
"Overwrite existing preset?" ) ) )
 
 1879    else if( index == count - 1 )
 
 1882        wxArrayString              headers;
 
 1883        std::vector<wxArrayString> items;
 
 1885        headers.Add( 
_( 
"Presets" ) );
 
 1889            if( !preset.readOnly )
 
 1893                items.emplace_back( item );
 
 1905            if( idx != wxNOT_FOUND )
 
 
 1955    for( 
int i = 0; i < 
m_dataModel->GetColsCount(); i++ )
 
 1957        const wxString& fieldName( 
m_dataModel->GetColFieldName( i ) );
 
 1978        int             col = 
m_dataModel->GetFieldNameCol( fieldName );
 
 1982            wxASSERT_MSG( 
true, 
"Fields control has a field not found in the data model." );
 
 1987        std::string        fieldNameStr( fieldName.ToUTF8() );
 
 1990        const wxString& label = 
m_dataModel->GetColLabelValue( col );
 
 1992        m_grid->SetColLabelValue( col, label );
 
 2007        bool groupBy = 
m_dataModel->GetGroupColumn( col );
 
 
 2031    std::vector<BOM_FMT_PRESET> ret;
 
 2035        if( !preset.readOnly )
 
 2036            ret.emplace_back( preset );
 
 
 2066    wxCommandEvent 
dummy;
 
 
 2108    int default_idx = 0;
 
 
 2137                            [&]( 
const std::pair<const wxString, BOM_FMT_PRESET>& aPair )
 
 2139                                return ( aPair.second.fieldDelimiter == current.fieldDelimiter
 
 2140                                         && aPair.second.stringDelimiter == current.stringDelimiter
 
 2141                                         && aPair.second.refDelimiter == current.refDelimiter
 
 2142                                         && aPair.second.refRangeDelimiter == current.refRangeDelimiter
 
 2143                                         && aPair.second.keepTabs == current.keepTabs
 
 2144                                         && aPair.second.keepLineBreaks == current.keepLineBreaks );
 
 2151        bool     do_translate = it->second.readOnly;
 
 2152        wxString 
text = do_translate ? wxGetTranslation( it->first ) : it->first;
 
 
 2171    wxString ui_label = aName;
 
 2175        if( presetName == aName )
 
 2177            if( preset.readOnly )
 
 2178                ui_label = wxGetTranslation( aName );
 
 
 2203    auto resetSelection =
 
 2212    if( index == count - 3 )
 
 2218    else if( index == count - 2 )
 
 2226        wxTextEntryDialog dlg( 
this, 
_( 
"BOM preset name:" ), 
_( 
"Save BOM Preset" ), 
name );
 
 2228        if( dlg.ShowModal() != wxID_OK )
 
 2234        name = dlg.GetValue();
 
 2252            wxMessageBox( 
_( 
"Default presets cannot be modified.\nPlease use a different name." ),
 
 2253                          _( 
"Error" ), wxOK | wxICON_ERROR, 
this );
 
 2260            if( !
IsOK( 
this, 
_( 
"Overwrite existing preset?" ) ) )
 
 2281    else if( index == count - 1 )
 
 2284        wxArrayString              headers;
 
 2285        std::vector<wxArrayString> items;
 
 2287        headers.Add( 
_( 
"Presets" ) );
 
 2289        for( std::pair<const wxString, BOM_FMT_PRESET>& pair : 
m_bomFmtPresets )
 
 2291            if( !pair.second.readOnly )
 
 2294                item.Add( pair.first );
 
 2295                items.emplace_back( item );
 
 2307            if( idx != wxNOT_FOUND )
 
 
 2362    bool modified = 
false;
 
 2365    std::vector<BOM_PRESET> presets;
 
 2369        if( !preset.readOnly )
 
 2370            presets.emplace_back( preset );
 
 2386    std::vector<BOM_FMT_PRESET> fmts;
 
 2390        if( !preset.readOnly )
 
 2391            fmts.emplace_back( preset );
 
 
 2412                                                  std::vector<SCH_ITEM*>& aSchItem )
 
 2415    m_parent->Schematic().Hierarchy().GetSymbols( allRefs );
 
 2429                AddField( field.GetCanonicalName(), field.GetName(), 
true, 
false, 
true );
 
 2435            std::set<SCH_SYMBOL*> symbols;
 
 2439                symbols.insert( ref.GetSymbol() );
 
 2444                for( 
SCH_FIELD& field : symbol->GetFields() )
 
 2445                    AddField( field.GetCanonicalName(), field.GetName(), 
true, 
false, 
true );
 
 
 2459                                                    std::vector<SCH_ITEM*>& aSchItem )
 
 
 2476                                                    std::vector<SCH_ITEM*>& aSchItem )
 
 2479    m_parent->Schematic().Hierarchy().GetSymbols( allRefs );
 
 2493                AddField( field.GetCanonicalName(), field.GetName(), 
true, 
false, 
true );
 
 2499            std::set<SCH_SYMBOL*> symbols;
 
 2503                symbols.insert( ref.GetSymbol() );
 
 2508                for( 
SCH_FIELD& field : symbol->GetFields() )
 
 2509                    AddField( field.GetCanonicalName(), field.GetName(), 
true, 
false, 
true );
 
 
 2526    if( 
m_dataModel->GetScope() != FIELDS_EDITOR_GRID_DATA_MODEL::SCOPE::SCOPE_ALL )
 
 
 2537    m_grid->Connect( wxEVT_GRID_RANGE_SELECTED,
 
 
 2545    m_grid->Disconnect( wxEVT_GRID_RANGE_SELECTED,
 
 
 2557    for( 
size_t i = 0; i < aCachedRefs.
GetCount(); i++ )
 
 
 2584            if( basePath.Path() == instance.m_Path )
 
 2592                subSheets.push_back( sheetPath );
 
 
 2610    wxTextEntryDialog dlg( 
this, 
_( 
"Add new variant name:" ), 
_( 
"New Variant" ), wxEmptyString,
 
 2611                           wxOK | wxCANCEL | wxCENTER );
 
 2613    if( dlg.ShowModal() == wxID_CANCEL )
 
 2617    if( dlg.GetValue().IsEmpty() || ( 
m_variantListBox->FindString( dlg.GetValue() ) != wxNOT_FOUND ) )
 
 2625    ctrlContents.Add( dlg.GetValue() );
 
 
 2633    wxArrayInt selections;
 
 2636    if( ( 
m_variantListBox->GetSelections( selections ) == 0 ) || ( selections[0] == 0 ) )
 
 2644    for( 
int selection : selections )
 
 2647        ctrlContents.Remove( variantName );
 
 2648        m_parent->Schematic().DeleteVariant( variantName );
 
 
 2657    wxArrayInt selections;
 
 2660    if( ( 
m_variantListBox->GetSelections( selections ) != 1 ) || ( selections[0] == 0 ) )
 
 2667    wxString oldVariantName = ctrlContents[selections[0]];
 
 2669    wxTextEntryDialog dlg( 
this, 
_( 
"Add new variant name:" ), 
_( 
"New Variant" ), oldVariantName,
 
 2670                           wxOK | wxCANCEL | wxCENTER );
 
 2672    if( dlg.ShowModal() == wxID_CANCEL )
 
 2675    wxString newVariantName = dlg.GetValue();
 
 2677    if( newVariantName.IsEmpty() || ( newVariantName == oldVariantName ) || ( newVariantName == ctrlContents[0] ) )
 
 2684    ctrlContents.Add( newVariantName );
 
 
 2702        if( selectedVariants.size() >= 1 )
 
 2703            selectedVariant = *selectedVariants.cbegin();
 
 2705        m_parent->SetCurrentVariant( selectedVariant );
 
 
 2712    std::set<wxString> retv;
 
 2714    wxArrayInt selections;
 
 2718        for( 
int selection : selections )
 
 2720            if( selection == 0 )
 
 
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
 
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
 
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...
 
wxCheckBox * m_checkKeepLineBreaks
 
STD_BITMAP_BUTTON * m_bRefreshPreview
 
STD_BITMAP_BUTTON * m_bMenu
 
wxBitmapButton * m_deleteVariantButton
 
DIALOG_SYMBOL_FIELDS_TABLE_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Symbol Fields Table"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER)
 
wxCheckBox * m_checkKeepTabs
 
wxButton * m_buttonExport
 
STD_BITMAP_BUTTON * m_removeFieldButton
 
STD_BITMAP_BUTTON * m_browseButton
 
STD_BITMAP_BUTTON * m_sidebarButton
 
wxBitmapButton * m_addVariantButton
 
wxTextCtrl * m_textOutput
 
STD_BITMAP_BUTTON * m_bRefresh
 
STD_BITMAP_BUTTON * m_renameFieldButton
 
STD_BITMAP_BUTTON * m_addFieldButton
 
wxTextCtrl * m_textStringDelimiter
 
wxChoice * m_cbBomPresets
 
wxListBox * m_variantListBox
 
wxTextCtrl * m_outputFileName
 
wxSplitterWindow * m_splitterMainWindow
 
wxTextCtrl * m_textFieldDelimiter
 
wxCheckBox * m_groupSymbolsBox
 
wxTextCtrl * m_textRefRangeDelimiter
 
WX_GRID * m_viewControlsGrid
 
wxBoxSizer * variantSizer
 
wxChoice * m_cbBomFmtPresets
 
wxBitmapButton * m_renameVariantButton
 
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 onAddVariant(wxCommandEvent &aEvent) override
 
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 OnSidebarToggle(wxCommandEvent &event) override
 
void OnOk(wxCommandEvent &aEvent) override
 
void OnGroupSymbolsToggled(wxCommandEvent &event) override
 
~DIALOG_SYMBOL_FIELDS_TABLE() 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)
 
void ShowHideColumn(int aCol, bool aShow)
 
VIEW_CONTROLS_GRID_DATA_MODEL * m_viewControlsDataModel
 
std::set< wxString > getSelectedVariants() const
 
SCH_EDIT_FRAME * m_parent
 
bool TransferDataFromWindow() override
 
SCH_REFERENCE_LIST m_symbolsList
 
void SetupColumnProperties(int aCol)
 
void setSideBarButtonLook(bool aIsLeftPanelCollapsed)
 
FIELDS_EDITOR_GRID_DATA_MODEL * m_dataModel
 
void updateBomPresetSelection(const wxString &aName)
 
void updateBomFmtPresetSelection(const wxString &aName)
 
void OnFilterText(wxCommandEvent &aEvent) override
 
std::map< FIELD_T, int > m_mandatoryFieldListIndexes
 
void OnRemoveField(wxCommandEvent &event) override
 
void OnTableCellClick(wxGridEvent &event) override
 
wxArrayString m_bomPresetMRU
 
void onVariantSelectionChange(wxCommandEvent &aEvent) override
 
void doApplyBomFmtPreset(const BOM_FMT_PRESET &aPreset)
 
void loadDefaultBomPresets()
 
void OnScope(wxCommandEvent &event) override
 
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()
 
void onDeleteVariant(wxCommandEvent &aEvent) override
 
bool TransferDataToWindow() override
 
void OnTableRangeSelected(wxGridRangeSelectEvent &aEvent)
 
void OnMenu(wxCommandEvent &event) override
 
void EnableSelectionEvents()
 
void setScope(FIELDS_EDITOR_GRID_DATA_MODEL::SCOPE aScope)
 
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 doApplyBomPreset(const BOM_PRESET &aPreset)
 
void OnPageChanged(wxNotebookEvent &event) override
 
void SetUserBomFmtPresets(std::vector< BOM_FMT_PRESET > &aPresetList)
 
void OnRegroupSymbols(wxCommandEvent &aEvent) override
 
void OnViewControlsCellChanged(wxGridEvent &aEvent) override
 
void onRenameVariant(wxCommandEvent &aEvent) override
 
void OnColSort(wxGridEvent &aEvent)
 
JOB_EXPORT_SCH_BOM * m_job
 
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 OnSizeViewControlsGrid(wxSizeEvent &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_SYMBOL_FIELDS_TABLE m_FieldEditorPanel
 
static const wxString ITEM_NUMBER_VARIABLE
 
static const wxString QUANTITY_VARIABLE
 
VIEW_CONTROLS_GRID_DATA_MODEL * m_viewControlsDataModel
 
DIALOG_SYMBOL_FIELDS_TABLE * m_dlg
 
void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent) override
 
void doPopupSelection(wxCommandEvent &event) override
 
FIELDS_EDITOR_GRID_TRICKS(DIALOG_SYMBOL_FIELDS_TABLE *aParent, WX_GRID *aGrid, VIEW_CONTROLS_GRID_DATA_MODEL *aViewFieldsData, FIELDS_EDITOR_GRID_DATA_MODEL *aDataModel, EMBEDDED_FILES *aFiles)
 
FIELDS_EDITOR_GRID_DATA_MODEL * m_dataModel
 
A general-purpose text renderer for WX_GRIDs backed by WX_GRID_TABLE_BASE tables that can handle draw...
 
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
 
GRID_TRICKS(WX_GRID *aGrid)
 
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.
 
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
 
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.
 
Holds all the data relating to one schematic.
 
bool ResolveTextVar(const SCH_SHEET_PATH *aSheetPath, wxString *token, int aDepth) const
 
wxArrayString GetVariantNamesForUI() const
Return an array of variant names for using in wxWidgets UI controls.
 
SCH_SHEET_PATH & CurrentSheet() 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.
 
SCHEMATIC & Schematic() const
 
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 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
 
VIEW_CONTROLS_GRID_TRICKS(WX_GRID *aGrid)
 
void doPopupSelection(wxCommandEvent &event) override
 
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)
 
FIELDS_EDITOR_GRID_DATA_MODEL::SCOPE SCOPE
 
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 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
 
wxString GetDefaultVariantName()
 
int SortVariantNames(const wxString &aLhs, const wxString &aRhs)
 
#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
 
static std::vector< BOM_PRESET > BuiltInPresets()
 
std::map< std::string, int > field_widths
 
wxString view_controls_visible_columns
 
A simple container for sheet instance information.
 
Hold a name of a symbol's field, field value, and default visibility.
 
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...
 
@ 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".
 
wxString GetCanonicalFieldName(FIELD_T aFieldType)
 
Definition of file extensions used in Kicad.