50#include <wx/filedlg.h> 
   53#include <wx/textdlg.h> 
   86                            { wxID_CANCEL, 
_( 
"Close" )    } } );
 
   94            [&]( wxCommandEvent& )
 
 
  115    for( 
const std::unique_ptr<BOM_GENERATOR_HANDLER>& plugin : 
m_generators )
 
  117        wxString   
name = plugin->GetName();
 
  118        wxFileName 
path( plugin->GetStoredPath() );
 
  125        setting.
command = plugin->GetCommand();
 
 
  145        auto plugin = std::make_unique<BOM_GENERATOR_HANDLER>( setting.
path );
 
  147        plugin->SetName( setting.
name );
 
  149        if( !setting.
command.IsEmpty() )
 
  150            plugin->SetCommand( setting.
command );
 
  163            if( !
m_generators[ii]->FindFilePath().Exists( wxFILE_EXISTS_REGULAR ) )
 
  165                wxLogTrace( 
BOM_TRACE, wxS( 
"BOM plugin %s not found" ),
 
  167                name.Append( wxT( 
" " ) + 
_( 
"(file missing)" ) );
 
  169                if( active_plugin_name == 
name )
 
  170                    active_plugin_name.Clear();
 
  175            if( active_plugin_name == 
name )
 
 
  187    auto plugin = std::make_unique<BOM_GENERATOR_HANDLER>( aPath );
 
  189    if( !plugin->IsOk() )
 
  192    if( !aName.IsEmpty() )
 
  194        plugin->SetName( aName );
 
 
  238    if( !plugin->
FindFilePath().Exists( wxFILE_EXISTS_REGULAR ) )
 
  244                wxString::Format( 
_( 
"The selected BOM generator script %s could not be found." ),
 
  245                                  plugin->
GetFile().GetFullPath() );
 
  247        if( !plugin->
GetFile().IsAbsolute() )
 
  249            msg.Append( wxString::Format( 
_( 
"\n\nSearched:\n\t%s\n\t%s" ),
 
  264    if( plugin->
Options().Index( wxT( 
"show_console" ) ) == wxNOT_FOUND )
 
 
  279    wxFileName fn = 
m_parent->Schematic().GetFileName();
 
  283    wxString fullfilename = fn.GetFullPath();
 
  291        m_parent->SetExecFlags( wxEXEC_SHOW_CONSOLE );
 
  296    if( 
m_parent->ReadyToNetlist( 
_( 
"Generating BOM requires a fully annotated schematic." ) ) )
 
 
  332    if( filename.IsEmpty() )
 
  336    wxFileName fn( filename );
 
  337    wxString 
name = wxGetTextFromUser( 
_( 
"Generator nickname:" ), 
_( 
"Add Generator" ),
 
  338                                       fn.GetName(), 
this );
 
  346        wxMessageBox( wxString::Format( 
_( 
"Nickname '%s' already in use." ), 
name ) );
 
  361    catch( 
const std::runtime_error& e )
 
 
  370    static wxString lastPath;
 
  372    if( lastPath.IsEmpty() )
 
  375    wxString fullFileName = wxFileSelector( 
_( 
"Generator File" ), lastPath, wxEmptyString,
 
  376                                            wxEmptyString, wxFileSelectorDefaultWildcardStr,
 
 
  390    wxString pluginFile = plugin->GetFile().GetFullPath();
 
  392    if( pluginFile.Length() <= 2 )      
 
  394        wxMessageBox( 
_( 
"Generator file name not found." ) );
 
  400    if( !editorname.IsEmpty() )
 
  403        wxMessageBox( 
_( 
"No text editor selected in KiCad.  Please choose one." ) );
 
 
  453    static constexpr wxChar OPT_SHOW_CONSOLE[] = wxT( 
"show_console" );
 
  462        if( plugin->Options().Index( OPT_SHOW_CONSOLE ) == wxNOT_FOUND )
 
  463            plugin->Options().Add( OPT_SHOW_CONSOLE );
 
  467        plugin->Options().Remove( OPT_SHOW_CONSOLE );
 
 
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
 
Bill of material output generator.
 
const wxString & GetInfo() const
Return plugin description stored in the plugin header file (if available).
 
const wxFileName & GetFile() const
Return the file name of the plugin.
 
bool IsOk()
Return true if the plugin is ready to work, i.e.
 
wxArrayString & Options()
Accessor to array of options.
 
const wxString & GetName() const
Return the customisable plugin name.
 
wxFileName FindFilePath() const
Returns the calculated path to the plugin: if the path is already absolute and exists,...
 
const wxString & GetCommand() const
Return the command to execute the plugin.
 
STD_BITMAP_BUTTON * m_buttonEdit
 
wxTextCtrl * m_textCtrlName
 
STD_BITMAP_BUTTON * m_buttonAddGenerator
 
STD_BITMAP_BUTTON * m_buttonDelGenerator
 
DIALOG_BOM_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Bill of Materials"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
 
wxCheckBox * m_checkBoxShowConsole
 
wxTextCtrl * m_textCtrlCommand
 
wxListBox * m_lbGenerators
 
void OnEditGenerator(wxCommandEvent &event) override
 
SCH_EDIT_FRAME * m_parent
 
void OnRemoveGenerator(wxCommandEvent &event) override
 
void installGeneratorsList()
 
BOM_GENERATOR_HANDLER * selectedGenerator()
 
bool pluginExists(const wxString &aName)
 
BOM_GENERATOR_HANDLER * addGenerator(const wxString &aPath, const wxString &aName=wxEmptyString)
 
void OnIdle(wxIdleEvent &event) override
 
void OnHelp(wxCommandEvent &event) override
 
void OnCommandLineEdited(wxCommandEvent &event) override
 
wxString chooseGenerator()
 
void OnGeneratorSelected(wxCommandEvent &event) override
 
void OnNameEdited(wxCommandEvent &event) override
 
void OnRunGenerator(wxCommandEvent &event) override
 
HTML_MESSAGE_BOX * m_helpWindow
 
void OnShowConsoleChanged(wxCommandEvent &event) override
 
BOM_GENERATOR_ARRAY m_generators
 
DIALOG_BOM(SCH_EDIT_FRAME *parent)
 
void OnAddGenerator(wxCommandEvent &event) override
 
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
 
void SetupStandardButtons(std::map< int, wxString > aLabels={})
 
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
 
static std::vector< BOM_PLUGIN_SETTINGS > DefaultBomPlugins()
 
static wxString GetUserPluginsPath()
Gets the user path for plugins.
 
static wxString GetStockPluginsPath()
Gets the stock (install) plugins path.
 
virtual const wxString & GetTextEditor(bool aCanShowFileChooser=true)
Return the path to the preferred text editor application.
 
Schematic editor (Eeschema) main window.
 
A wrapper for reporting to a wxString object.
 
const wxString & GetMessages() const
 
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
 
This file is part of the common library.
 
int InvokeDialogCreateBOM(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM and return whatever DIALOG_BOM::ShowModal() returns.
 
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
 
Some functions to handle hotkeys in KiCad.
 
PGM_BASE & Pgm()
The global program "get" accessor.
 
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)
 
std::vector< BOM_PLUGIN_SETTINGS > plugins