49 #include <wx/filedlg.h> 50 #include <wx/textdlg.h> 78 void OnHelp( wxCommandEvent& event )
override;
85 void OnIdle( wxIdleEvent& event )
override;
119 m_initialized( false ),
120 m_helpWindow( nullptr )
143 [&]( wxCommandEvent& )
164 for(
const std::unique_ptr<BOM_GENERATOR_HANDLER>& plugin :
m_generators )
166 wxString
name = plugin->GetName();
167 wxFileName path( plugin->GetStoredPath() );
171 name = path.GetName();
174 setting.
command = plugin->GetCommand();
194 auto plugin = std::make_unique<BOM_GENERATOR_HANDLER>( setting.
path );
196 plugin->SetName( setting.
name );
198 if( !setting.
command.IsEmpty() )
199 plugin->SetCommand( setting.
command );
212 if( !
m_generators[ii]->FindFilePath().Exists( wxFILE_EXISTS_REGULAR ) )
214 wxLogTrace(
BOM_TRACE,
"BOM plugin %s not found",
216 name.Append( wxT(
" " ) +
_(
"(file missing)" ) );
218 if( active_plugin_name ==
name )
219 active_plugin_name.Clear();
224 if( active_plugin_name ==
name )
236 auto plugin = std::make_unique<BOM_GENERATOR_HANDLER>( aPath );
241 if( !aName.IsEmpty() )
243 plugin->SetName( aName );
287 if( !plugin->
FindFilePath().Exists( wxFILE_EXISTS_REGULAR ) )
293 wxString::Format(
_(
"The selected BOM generator script %s could not be found." ),
294 plugin->
GetFile().GetFullPath() );
296 if( !plugin->
GetFile().IsAbsolute() )
313 if( plugin->
Options().Index( wxT(
"show_console" ) ) == wxNOT_FOUND )
330 fn.SetPath( wxPathOnly(
Prj().GetProjectFullName() ) );
333 wxString fullfilename = fn.GetFullPath();
377 if( filename.IsEmpty() )
381 wxFileName fn( filename );
382 wxString
name = wxGetTextFromUser(
_(
"Generator nickname:" ),
_(
"Add Generator" ),
383 fn.GetName(), this );
406 catch(
const std::runtime_error& e )
415 static wxString lastPath;
417 if( lastPath.IsEmpty() )
420 wxString fullFileName =
EDA_FILE_SELECTOR(
_(
"Generator files:" ), lastPath, wxEmptyString,
421 wxEmptyString, wxFileSelectorDefaultWildcardStr,
422 this, wxFD_OPEN,
true );
435 wxString pluginFile = plugin->GetFile().GetFullPath();
437 if( pluginFile.Length() <= 2 )
439 wxMessageBox(
_(
"Generator file name not found." ) );
444 wxString editorname =
Pgm().GetEditorName();
446 if( !editorname.IsEmpty() )
449 wxMessageBox(
_(
"No text editor selected in KiCad. Please choose one." ) );
499 static constexpr wxChar OPT_SHOW_CONSOLE[] = wxT(
"show_console" );
508 if( plugin->Options().Index( OPT_SHOW_CONSOLE ) == wxNOT_FOUND )
509 plugin->Options().Add( OPT_SHOW_CONSOLE );
513 plugin->Options().Remove( OPT_SHOW_CONSOLE );
bool ReadyToNetlist(const wxString &aAnnotateMessage)
Checks if we are ready to write a netlist file for the current schematic.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
wxBitmapButton * m_buttonEdit
wxBitmapButton * m_buttonAddGenerator
void OnCommandLineEdited(wxCommandEvent &event) override
void OnEditGenerator(wxCommandEvent &event) override
wxStdDialogButtonSizer * m_sdbSizer
wxArrayString & Options()
Accessor to array of options.
bool WriteNetListFile(int aFormat, const wxString &aFullFileName, unsigned aNetlistOptions, REPORTER *aReporter=NULL)
Create a netlist file.
This file is part of the common library TODO brief description.
DIALOG_BOM(SCH_EDIT_FRAME *parent)
This file is part of the common library.
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)
void OnRemoveGenerator(wxCommandEvent &event) override
std::vector< BOM_GENERATOR_HANDLER::PTR > BOM_GENERATOR_ARRAY
const wxFileName & GetFile() const
Return the file name of the plugin.
std::vector< BOM_PLUGIN_SETTINGS > plugins
const wxString & GetInfo() const
Return plugin description stored in the plugin header file (if available).
bool pluginExists(const wxString &aName)
Schematic editor (Eeschema) main window.
int InvokeDialogCreateBOM(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM and return whatever DIALOG_BOM::ShowModal() returns.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
bool IsOk()
Return true if the plugin is ready to work, i.e.
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
void OnIdle(wxIdleEvent &event) override
void OnGeneratorSelected(wxCommandEvent &event) override
void OnHelp(wxCommandEvent &event) override
EESCHEMA_SETTINGS * eeconfig() const
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
static wxString GetUserPluginsPath()
Gets the user path for plugins.
wxTextCtrl * m_textCtrlName
void OnRunGenerator(wxCommandEvent &event) override
wxCheckBox * m_checkBoxShowConsole
void OnNameEdited(wxCommandEvent &event) override
Bill of material output generator.
wxFileName FindFilePath() const
Returns the calculated path to the plugin: if the path is already absolute and exists,...
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
wxString EDA_FILE_SELECTOR(const wxString &aTitle, const wxString &aPath, const wxString &aFileName, const wxString &aExtension, const wxString &aWildcard, wxWindow *aParent, int aStyle, const bool aKeepWorkingDirectory, const wxPoint &aPosition, wxString *aMruPath)
A helper function that wraps a call to wxFileSelector.
wxTextCtrl * m_textCtrlCommand
SCHEMATIC & Schematic() const
Helper dialog and control classes.
void AddDelimiterString(wxString &string)
Add un " to the start and the end of string (if not already done).
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
void installGeneratorsList()
virtual void ClearMsgPanel()
Clear all messages from the message panel.
const BITMAP_OPAQUE small_trash_xpm[1]
wxString chooseGenerator()
BOM_GENERATOR_ARRAY m_generators
A wrapper for reporting to a wxString object.
Some functions to handle hotkeys in KiCad.
wxHtmlWindow * m_htmlWindow
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
void ShowModeless()
Show a modeless version of the dialog (without an OK button).
void SetDialogSizeInDU(int aWidth, int aHeight)
set the dialog size, using a "logical" value.
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
const BITMAP_OPAQUE small_edit_xpm[1]
void OnAddGenerator(wxCommandEvent &event) override
const wxString & GetCommand() const
Return the command to execute the plugin.
wxListBox * m_lbGenerators
wxButton * m_sdbSizerCancel
SCH_EDIT_FRAME * m_parent
BOM_GENERATOR_HANDLER * selectedGenerator()
int ExecuteFile(wxWindow *frame, const wxString &ExecFile, const wxString ¶m, wxProcess *callback)
Call the executable file ExecFile with the command line parameters param.
void SetExecFlags(const int aFlags)
Set (adds) specified flags for next execution of external generator of the netlist or bom.
wxBitmapButton * m_buttonDelGenerator
HTML_MESSAGE_BOX * m_helpWindow
const wxString & GetName() const
Return the customisable plugin name.
void SetNetListerCommand(const wxString &aCommand)
const BITMAP_OPAQUE small_plus_xpm[1]
BOM_GENERATOR_HANDLER * addGenerator(const wxString &aPath, const wxString &aName=wxEmptyString)
static std::vector< BOM_PLUGIN_SETTINGS > DefaultBomPlugins()
void OnShowConsoleChanged(wxCommandEvent &event) override
static wxString GetStockPluginsPath()
Gets the stock (install) plugins path.