KiCad PCB EDA Suite
dialog_bom.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
31 #include <fctsys.h>
32 #include <pgm_base.h>
33 #include <kiface_i.h>
34 #include <confirm.h>
35 #include <gestfich.h>
36 #include <sch_edit_frame.h>
37 #include <netlist.h>
39 #include <invoke_sch_dialog.h>
40 #include <dialog_helpers.h>
41 #include <dialog_bom_base.h>
42 #include <html_messagebox.h>
43 #include <reporter.h>
44 #include <bom_plugins.h>
45 
46 #include <dialogs/dialog_bom_cfg_lexer.h>
47 
48 static constexpr wxChar BOM_TRACE[] = wxT( "BOM_GENERATORS" );
49 
50 static constexpr wxChar BOM_GENERATORS_KEY[] = wxT( "bom_plugins" );
51 static constexpr wxChar BOM_GENERATOR_SELECTED_KEY[] = wxT( "bom_plugin_selected" );
52 
53 static const char* s_bomHelpInfo =
54 #include <dialog_bom_help_html.h>
55 ;
56 
57 using namespace T_BOMCFG_T; // for the BOM_CFG_PARSER parser and its keywords
58 
59 // BOM "plugins" are not actually plugins. They are external tools
60 // (scripts or executables) called by this dialog.
61 typedef std::vector<BOM_GENERATOR_HANDLER::PTR> BOM_GENERATOR_ARRAY;
62 
63 
67 class BOM_CFG_PARSER : public DIALOG_BOM_CFG_LEXER
68 {
70 
71 public:
72  BOM_CFG_PARSER( BOM_GENERATOR_ARRAY* aGenerators, const char* aData, const wxString& aSource );
73  void Parse();
74 
75 private:
76  void parseGenerator();
77 };
78 
79 
80 BOM_CFG_PARSER::BOM_CFG_PARSER( BOM_GENERATOR_ARRAY* aGenerators, const char* aLine,
81  const wxString& aSource ) :
82  DIALOG_BOM_CFG_LEXER( aLine, aSource )
83 {
84  m_generatorsList = aGenerators;
85 }
86 
87 
89 {
90  T token;
91 
92  while( ( token = NextTok() ) != T_RIGHT )
93  {
94  if( token == T_EOF)
95  break;
96 
97  if( token == T_LEFT )
98  token = NextTok();
99 
100  if( token == T_plugins )
101  continue;
102 
103  switch( token )
104  {
105  case T_plugin: // Defines a new plugin
106  parseGenerator();
107  break;
108 
109  default:
110 // Unexpected( CurText() );
111  break;
112  }
113  }
114 }
115 
116 
118 {
119  NeedSYMBOLorNUMBER();
120  wxString name = FromUTF8();
121  auto plugin = std::make_unique<BOM_GENERATOR_HANDLER>( name );
122 
123  T token;
124 
125  while( ( token = NextTok() ) != T_RIGHT )
126  {
127  if( token == T_EOF)
128  break;
129 
130  switch( token )
131  {
132  case T_LEFT:
133  break;
134 
135  case T_cmd:
136  NeedSYMBOLorNUMBER();
137 
138  if( plugin )
139  plugin->SetCommand( FromUTF8() );
140 
141  NeedRIGHT();
142  break;
143 
144  case T_opts:
145  NeedSYMBOLorNUMBER();
146 
147  if( plugin )
148  {
149  wxString option = FromUTF8();
150 
151  if( option.StartsWith( "nickname=", &name ) )
152  plugin->SetName( name );
153  else
154  plugin->Options().Add( option );
155  }
156 
157  NeedRIGHT();
158  break;
159 
160  default:
161  Unexpected( CurText() );
162  break;
163  }
164  }
165 
166  if( plugin )
167  m_generatorsList->push_back( std::move( plugin ) );
168 }
169 
170 
171 // The main dialog frame to run scripts to build bom
173 {
174 private:
177  wxConfigBase* m_config; // to store the "plugins"
179 
180 public:
181  DIALOG_BOM( SCH_EDIT_FRAME* parent );
182  ~DIALOG_BOM();
183 
184 private:
185  void OnGeneratorSelected( wxCommandEvent& event ) override;
186  void OnRunGenerator( wxCommandEvent& event ) override;
187  void OnHelp( wxCommandEvent& event ) override;
188  void OnAddGenerator( wxCommandEvent& event ) override;
189  void OnRemoveGenerator( wxCommandEvent& event ) override;
190  void OnEditGenerator( wxCommandEvent& event ) override;
191  void OnCommandLineEdited( wxCommandEvent& event ) override;
192  void OnNameEdited( wxCommandEvent& event ) override;
193  void OnShowConsoleChanged( wxCommandEvent& event ) override;
194  void OnIdle( wxIdleEvent& event ) override;
195 
196  void pluginInit();
197  void installGeneratorsList();
198  BOM_GENERATOR_HANDLER* addGenerator( const wxString& aPath, const wxString& aName = wxEmptyString );
199  bool pluginExists( const wxString& aName );
200 
202  {
203  int idx = m_lbGenerators->GetSelection();
204 
205  if( idx < 0 || idx >= (int)m_generators.size() )
206  return nullptr;
207 
208  return m_generators[idx].get();
209  }
210 
211  wxString chooseGenerator();
212 };
213 
214 
215 // Create and show DIALOG_BOM.
217 {
218  DIALOG_BOM dlg( aCaller );
219  return dlg.ShowModal();
220 }
221 
222 
224  DIALOG_BOM_BASE( parent )
225 {
226  m_parent = parent;
228  m_initialized = false;
229 
230  m_buttonAddGenerator->SetBitmap( KiBitmap( small_plus_xpm ) );
231  m_buttonDelGenerator->SetBitmap( KiBitmap( trash_xpm ) );
232  m_buttonEdit->SetBitmap( KiBitmap( small_edit_xpm ) );
233 
235 
236 #ifndef __WINDOWS__
237  m_checkBoxShowConsole->Show( false );
238 #endif
239 
240  m_sdbSizerOK->SetLabel( _( "Generate" ) );
241  m_sdbSizerCancel->SetLabel( _( "Close" ) );
242  m_sdbSizer->Layout();
243 
245  m_sdbSizerOK->SetDefault();
246 
247  // Now all widgets have the size fixed, call FinishDialogSettings
249 }
250 
252 {
253  // Save the plugin descriptions in config.
254  // The config stores only one string, so we save the plugins inside a S-expr:
255  // ( plugins
256  // ( plugin "plugin name 1" (cmd "command line 1") )
257  // ( plugin "plugin name 2" (cmd "command line 2") (opts "option1") (opts "option2") )
258  // ....
259  // )
260 
261  STRING_FORMATTER writer;
262  writer.Print( 0, "(plugins" );
263 
264  for( auto& plugin : m_generators )
265  {
266  writer.Print( 1, "(plugin %s (cmd %s)",
267  writer.Quotew( plugin->GetFile().GetFullPath() ).c_str(),
268  writer.Quotew( plugin->GetCommand() ).c_str() );
269 
270  for( unsigned jj = 0; jj < plugin->Options().GetCount(); jj++ )
271  {
272  writer.Print( 1, "(opts %s)",
273  writer.Quotew( plugin->Options().Item( jj ) ).c_str() );
274  }
275 
276  if( !plugin->GetName().IsEmpty() )
277  {
278  wxString option = wxString::Format( "nickname=%s", plugin->GetName() );
279 
280  writer.Print( 1, "(opts %s)",
281  writer.Quotew( option ).c_str() );
282  }
283 
284  writer.Print( 0, ")" );
285  }
286 
287  writer.Print( 0, ")" );
288 
289  wxString list( FROM_UTF8( writer.GetString().c_str() ) );
290 
291  m_config->Write( BOM_GENERATORS_KEY, list );
292 
293  wxString active_plugin_name = m_lbGenerators->GetStringSelection( );
294  m_config->Write( BOM_GENERATOR_SELECTED_KEY, active_plugin_name );
295 }
296 
297 
298 // Read the initialized plugins in config and fill the list of names
300 {
301  wxString list, active_plugin_name;
302  m_config->Read( BOM_GENERATORS_KEY, &list );
303  m_config->Read( BOM_GENERATOR_SELECTED_KEY, &active_plugin_name );
304 
305  if( !list.IsEmpty() )
306  {
307  BOM_CFG_PARSER cfg_parser( &m_generators, TO_UTF8( list ), wxT( "plugins" ) );
308 
309  try
310  {
311  cfg_parser.Parse();
312  }
313  catch( const IO_ERROR& )
314  {
315 // wxLogMessage( ioe.What() );
316  }
317  catch( std::runtime_error& e )
318  {
319  DisplayError( nullptr, e.what() );
320  }
321 
322  // Populate list box
323  for( unsigned ii = 0; ii < m_generators.size(); ii++ )
324  {
325  m_lbGenerators->Append( m_generators[ii]->GetName() );
326 
327  if( active_plugin_name == m_generators[ii]->GetName() )
328  m_lbGenerators->SetSelection( ii );
329  }
330  }
331 
332  if( m_generators.empty() ) // No plugins found?
333  {
334  // Load plugins from the default locations
335  std::vector<wxString> pluginPaths = {
336 #if defined(__WXGTK__)
337  "/usr/share/kicad/plugins",
338  "/usr/local/share/kicad/plugins",
339 #elif defined(__WXMSW__)
340  wxString::Format( "%s\\scripting\\plugins", Pgm().GetExecutablePath() ),
341 #elif defined(__WXMAC__)
342  wxString::Format( "%s/plugins", GetOSXKicadDataDir() ),
343 #endif
344  };
345 
346  wxFileName pluginPath;
347 
348  for( const auto& path : pluginPaths )
349  {
350  wxLogDebug( wxString::Format( "Searching directory %s for BOM generators", path ) );
351  wxDir dir( path );
352 
353  if( !dir.IsOpened() )
354  continue;
355 
356  pluginPath.AssignDir( dir.GetName() );
357  wxString fileName;
358  bool cont = dir.GetFirst( &fileName, wxFileSelectorDefaultWildcardStr, wxDIR_FILES );
359 
360  while( cont )
361  {
362  try
363  {
364  wxLogTrace( BOM_TRACE, wxString::Format( "Checking if %s is a BOM generator", fileName ) );
365 
367  {
368  pluginPath.SetFullName( fileName );
369  addGenerator( pluginPath.GetFullPath() );
370  }
371  }
372  catch( ... ) { /* well, no big deal */ }
373 
374  cont = dir.GetNext( &fileName );
375  }
376  }
377  }
378 
379 
380  pluginInit();
381 }
382 
383 
384 BOM_GENERATOR_HANDLER* DIALOG_BOM::addGenerator( const wxString& aPath, const wxString& aName )
385 {
386  BOM_GENERATOR_HANDLER* ret = nullptr;
387  auto plugin = std::make_unique<BOM_GENERATOR_HANDLER>( aPath );
388 
389  if( !plugin )
390  return nullptr;
391 
392  if( !aName.IsEmpty() )
393  {
394  plugin->SetName( aName );
395  m_lbGenerators->Append( aName );
396  }
397  else
398  {
399  m_lbGenerators->Append( plugin->GetName() );
400  }
401 
402  ret = plugin.get();
403  m_generators.push_back( std::move( plugin ) );
404  return ret;
405 }
406 
407 
408 bool DIALOG_BOM::pluginExists( const wxString& aName )
409 {
410  for( unsigned ii = 0; ii < m_generators.size(); ii++ )
411  {
412  if( aName == m_generators[ii]->GetName() )
413  return true;
414  }
415 
416  return false;
417 }
418 
419 
420 void DIALOG_BOM::OnGeneratorSelected( wxCommandEvent& event )
421 {
422  pluginInit();
423 }
424 
425 
427 {
428  auto plugin = selectedGenerator();
429 
430  if( !plugin )
431  {
432  m_textCtrlName->SetValue( wxEmptyString );
433  m_textCtrlCommand->SetValue( wxEmptyString );
434  m_Messages->SetValue( wxEmptyString );
435  return;
436  }
437 
438  m_textCtrlName->SetValue( plugin->GetName() );
439  m_textCtrlCommand->SetValue( plugin->GetCommand() );
440  m_Messages->SetValue( plugin->GetInfo() );
441  m_Messages->SetSelection( 0, 0 );
442 
443 #ifdef __WINDOWS__
444  if( plugin->Options().Index( wxT( "show_console" ) ) == wxNOT_FOUND )
445  m_checkBoxShowConsole->SetValue( false );
446  else
447  m_checkBoxShowConsole->SetValue( true );
448 #endif
449 
450  // A plugin can be not working, so do not left the OK button enabled if
451  // the plugin is not ready to use
452  m_sdbSizerOK->Enable( plugin->IsOk() );
453 }
454 
455 
456 void DIALOG_BOM::OnRunGenerator( wxCommandEvent& event )
457 {
458  // Calculate the xml netlist filename
459  wxFileName fn = g_RootSheet->GetScreen()->GetFileName();
460 
461  fn.SetPath( wxPathOnly( Prj().GetProjectFullName() ) );
462  fn.ClearExt();
463 
464  wxString fullfilename = fn.GetFullPath();
466 
467  wxString reportmsg;
468  WX_STRING_REPORTER reporter( &reportmsg );
470 
471 #ifdef __WINDOWS__
472  if( m_checkBoxShowConsole->IsChecked() )
473  m_parent->SetExecFlags( wxEXEC_SHOW_CONSOLE );
474 #endif
475 
476  auto netlist = m_parent->CreateNetlist( false, false );
477 
478  m_parent->WriteNetListFile( netlist, -1,
479  fullfilename, 0, &reporter );
480 
481  m_Messages->SetValue( reportmsg );
482 
483  // Force focus back on the dialog
484  SetFocus();
485 }
486 
487 
488 void DIALOG_BOM::OnRemoveGenerator( wxCommandEvent& event )
489 {
490  int ii = m_lbGenerators->GetSelection();
491 
492  if( ii < 0 )
493  return;
494 
495  m_lbGenerators->Delete( ii );
496  m_generators.erase( m_generators.begin() + ii );
497 
498  // Select the next item, if exists
499  if( m_lbGenerators->GetCount() )
500  m_lbGenerators->SetSelection( std::min( ii, (int) m_lbGenerators->GetCount() - 1 ) );
501 
502  pluginInit();
503 }
504 
505 
506 void DIALOG_BOM::OnAddGenerator( wxCommandEvent& event )
507 {
508  wxString filename = chooseGenerator();
509 
510  if( filename.IsEmpty() )
511  return;
512 
513  // Creates a new plugin entry
514  wxFileName fn( filename );
515  wxString name = wxGetTextFromUser( _( "Generator nickname:" ), _( "Add Generator" ),
516  fn.GetName(), this );
517 
518  if( name.IsEmpty() )
519  return;
520 
521  // Verify if it does not exists
522  if( pluginExists( name ) )
523  {
524  wxMessageBox( wxString::Format( _( "Nickname \"%s\" already in use." ), name ) );
525  return;
526  }
527 
528  try
529  {
530  auto plugin = addGenerator( fn.GetFullPath(), name );
531 
532  if( plugin )
533  {
534  m_lbGenerators->SetSelection( m_lbGenerators->GetCount() - 1 );
535  m_textCtrlCommand->SetValue( plugin->GetCommand() );
536  pluginInit();
537  }
538  }
539  catch( const std::runtime_error& e )
540  {
541  DisplayError( this, e.what() );
542  }
543 }
544 
545 
547 {
548  static wxString lastPath;
549 
550  if( lastPath.IsEmpty() )
551  {
552 #ifndef __WXMAC__
553  lastPath = Pgm().GetExecutablePath();
554 #else
555  lastPath = GetOSXKicadDataDir() + "/plugins";
556 #endif
557  }
558 
559  wxString fullFileName = EDA_FILE_SELECTOR( _( "Generator files:" ), lastPath, wxEmptyString,
560  wxEmptyString, wxFileSelectorDefaultWildcardStr,
561  this, wxFD_OPEN, true );
562 
563  return fullFileName;
564 }
565 
566 
567 void DIALOG_BOM::OnEditGenerator( wxCommandEvent& event )
568 {
569  auto plugin = selectedGenerator();
570 
571  if( !plugin )
572  return;
573 
574  wxString pluginFile = plugin->GetFile().GetFullPath();
575 
576  if( pluginFile.Length() <= 2 ) // if name != ""
577  {
578  wxMessageBox( _( "Generator file name not found." ) );
579  return;
580  }
581 
582  AddDelimiterString( pluginFile );
583  wxString editorname = Pgm().GetEditorName();
584 
585  if( !editorname.IsEmpty() )
586  ExecuteFile( this, editorname, pluginFile );
587  else
588  wxMessageBox( _( "No text editor selected in KiCad. Please choose one." ) );
589 }
590 
591 
592 void DIALOG_BOM::OnHelp( wxCommandEvent& event )
593 {
594  HTML_MESSAGE_BOX help_Dlg( this, _( "Bill of Material Generation Help" ) );
595  help_Dlg.SetDialogSizeInDU( 500, 350 );
596 
597  wxString msg = FROM_UTF8( s_bomHelpInfo );
598  help_Dlg.m_htmlWindow->AppendToPage( msg );
599  help_Dlg.ShowModal();
600 }
601 
602 
603 void DIALOG_BOM::OnCommandLineEdited( wxCommandEvent& event )
604 {
605  auto generator = selectedGenerator();
606 
607  if( generator )
608  generator->SetCommand( m_textCtrlCommand->GetValue() );
609 }
610 
611 
612 void DIALOG_BOM::OnNameEdited( wxCommandEvent& event )
613 {
614  int ii = m_lbGenerators->GetSelection();
615 
616  if( ii < 0 )
617  return;
618 
619  m_generators[ii]->SetName( m_textCtrlName->GetValue() );
620  m_lbGenerators->SetString( ii, m_generators[ii]->GetName() );
621 }
622 
623 
624 void DIALOG_BOM::OnShowConsoleChanged( wxCommandEvent& event )
625 {
626 #ifdef __WINDOWS__
627  static constexpr wxChar OPT_SHOW_CONSOLE[] = wxT( "show_console" );
628 
629  auto plugin = selectedGenerator();
630 
631  if( !plugin )
632  return;
633 
634  if( m_checkBoxShowConsole->IsChecked() )
635  {
636  if( plugin->Options().Index( OPT_SHOW_CONSOLE ) == wxNOT_FOUND )
637  plugin->Options().Add( OPT_SHOW_CONSOLE );
638  }
639  else
640  {
641  plugin->Options().Remove( OPT_SHOW_CONSOLE );
642  }
643 #endif
644 }
645 
646 
647 void DIALOG_BOM::OnIdle( wxIdleEvent& event )
648 {
649  // On some platforms we initialize wxTextCtrls to all-selected, but we don't want that
650  // for the messages text box.
651  if( !m_initialized )
652  {
653  m_Messages->SetSelection( 0, 0 );
654  m_initialized = true;
655  }
656 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:236
wxBitmapButton * m_buttonEdit
wxBitmapButton * m_buttonAddGenerator
const wxString & GetFileName() const
Definition: sch_screen.h:123
static constexpr wxChar BOM_GENERATOR_SELECTED_KEY[]
Definition: dialog_bom.cpp:51
void OnCommandLineEdited(wxCommandEvent &event) override
Definition: dialog_bom.cpp:603
void OnEditGenerator(wxCommandEvent &event) override
Definition: dialog_bom.cpp:567
wxStdDialogButtonSizer * m_sdbSizer
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:62
This file is part of the common library TODO brief description.
DIALOG_BOM(SCH_EDIT_FRAME *parent)
Definition: dialog_bom.cpp:223
This file is part of the common library.
void Parse(void *yyp, int yymajor, ParseTOKENTYPE yyminor ParseARG_PDECL)
void OnRemoveGenerator(wxCommandEvent &event) override
Definition: dialog_bom.cpp:488
std::vector< BOM_GENERATOR_HANDLER::PTR > BOM_GENERATOR_ARRAY
Definition: dialog_bom.cpp:61
static const char * s_bomHelpInfo
Definition: dialog_bom.cpp:53
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
bool pluginExists(const wxString &aName)
Definition: dialog_bom.cpp:408
static constexpr wxChar BOM_TRACE[]
Definition: dialog_bom.cpp:48
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
Schematic editor (Eeschema) main window.
int InvokeDialogCreateBOM(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM and return whatever DIALOG_BOM::ShowModal() returns.
Definition: dialog_bom.cpp:216
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:281
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:118
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:51
void OnIdle(wxIdleEvent &event) override
Definition: dialog_bom.cpp:647
void OnGeneratorSelected(wxCommandEvent &event) override
Definition: dialog_bom.cpp:420
void OnHelp(wxCommandEvent &event) override
Definition: dialog_bom.cpp:592
wxButton * m_sdbSizerOK
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:48
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
wxTextCtrl * m_textCtrlName
void OnRunGenerator(wxCommandEvent &event) override
Definition: dialog_bom.cpp:456
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:47
wxCheckBox * m_checkBoxShowConsole
void OnNameEdited(wxCommandEvent &event) override
Definition: dialog_bom.cpp:612
Class handling a Bill of Material output generator.
Definition: bom_plugins.h:41
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
static bool IsValidGenerator(const wxString &aFile)
Returns true if a file name matches a recognized plugin format.
Definition: bom_plugins.cpp:78
Subclass of DIALOG_DISPLAY_HTML_TEXT_BASE, which is generated by wxFormBuilder.
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)
Function EDA_FILE_SELECTOR.
Definition: gestfich.cpp:52
wxTextCtrl * m_textCtrlCommand
Helper dialog and control classes.
void AddDelimiterString(wxString &string)
Function AddDelimiterString Add un " to the start and the end of string (if not already done).
Definition: gestfich.cpp:42
const std::string & GetString()
Definition: richio.h:475
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:472
void installGeneratorsList()
Definition: dialog_bom.cpp:299
Class HTML_MESSAGE_BOX.
Holds data and functions pertinent to parsing a S-expression file.
Definition: dialog_bom.cpp:67
virtual void ClearMsgPanel()
Clear all messages from the message panel.
wxTextCtrl * m_Messages
bool m_initialized
Definition: dialog_bom.cpp:178
#define _(s)
void parseGenerator()
Definition: dialog_bom.cpp:117
wxString chooseGenerator()
Definition: dialog_bom.cpp:546
BOM_GENERATOR_ARRAY * m_generatorsList
Definition: dialog_bom.cpp:69
BOM_GENERATOR_ARRAY m_generators
Definition: dialog_bom.cpp:176
Class WX_STRING_REPORTER is a wrapper for reporting to a wxString object.
Definition: reporter.h:165
void SetDialogSizeInDU(int aWidth, int aHeight)
set the dialog size, using a "logical value.
void OnAddGenerator(wxCommandEvent &event) override
Definition: dialog_bom.cpp:506
see class PGM_BASE
const char * name
Definition: DXF_plotter.cpp:61
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
NETLIST_OBJECT_LIST * CreateNetlist(bool aSilent=false, bool aSilentAnnotate=false)
Create a netlist for the current schematic.
VTBL_ENTRY const wxString & GetExecutablePath() const
Definition: pgm_base.h:232
Class DIALOG_BOM_BASE.
wxListBox * m_lbGenerators
wxButton * m_sdbSizerCancel
SCH_EDIT_FRAME * m_parent
Definition: dialog_bom.cpp:175
VTBL_ENTRY const wxString & GetEditorName(bool aCanShowFileChooser=true)
Return the preferred editor name.
Definition: pgm_base.cpp:179
static constexpr wxChar BOM_GENERATORS_KEY[]
Definition: dialog_bom.cpp:50
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
wxConfigBase * m_config
Definition: dialog_bom.cpp:177
BOM_GENERATOR_HANDLER * selectedGenerator()
Definition: dialog_bom.cpp:201
bool WriteNetListFile(NETLIST_OBJECT_LIST *aConnectedItemsList, int aFormat, const wxString &aFullFileName, unsigned aNetlistOptions, REPORTER *aReporter=NULL)
Create a netlist file.
Class STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:445
int ExecuteFile(wxWindow *frame, const wxString &ExecFile, const wxString &param, wxProcess *callback)
Function ExecuteFile calls the executable file ExecFile with the command line parameters param.
Definition: gestfich.cpp:178
void SetExecFlags(const int aFlags)
Set (adds) specified flags for next execution of external generator of the netlist or bom.
wxBitmapButton * m_buttonDelGenerator
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
void SetNetListerCommand(const wxString &aCommand)
BOM_GENERATOR_HANDLER * addGenerator(const wxString &aPath, const wxString &aName=wxEmptyString)
Definition: dialog_bom.cpp:384
void pluginInit()
Definition: dialog_bom.cpp:426
void OnShowConsoleChanged(wxCommandEvent &event) override
Definition: dialog_bom.cpp:624
#define min(a, b)
Definition: auxiliary.h:85
BOM_CFG_PARSER(BOM_GENERATOR_ARRAY *aGenerators, const char *aData, const wxString &aSource)
Definition: dialog_bom.cpp:80