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 #include <make_unique.h>
46 
47 #include <dialogs/dialog_bom_cfg_lexer.h>
48 
49 static constexpr wxChar BOM_TRACE[] = wxT( "BOM_GENERATORS" );
50 
51 static constexpr wxChar BOM_GENERATORS_KEY[] = wxT( "bom_plugins" );
52 static constexpr wxChar BOM_GENERATOR_SELECTED_KEY[] = wxT( "bom_plugin_selected" );
53 
54 static const char* s_bomHelpInfo =
55 #include <dialog_bom_help_html.h>
56 ;
57 
58 using namespace T_BOMCFG_T; // for the BOM_CFG_PARSER parser and its keywords
59 
60 // BOM "plugins" are not actually plugins. They are external tools
61 // (scripts or executables) called by this dialog.
62 typedef std::vector<BOM_GENERATOR_HANDLER::PTR> BOM_GENERATOR_ARRAY;
63 
64 
68 class BOM_CFG_PARSER : public DIALOG_BOM_CFG_LEXER
69 {
71 
72 public:
73  BOM_CFG_PARSER( BOM_GENERATOR_ARRAY* aGenerators, const char* aData, const wxString& aSource );
74  void Parse();
75 
76 private:
77  void parseGenerator();
78 };
79 
80 
81 BOM_CFG_PARSER::BOM_CFG_PARSER( BOM_GENERATOR_ARRAY* aGenerators, const char* aLine,
82  const wxString& aSource ) :
83  DIALOG_BOM_CFG_LEXER( aLine, aSource )
84 {
85  m_generatorsList = aGenerators;
86 }
87 
88 
90 {
91  T token;
92 
93  while( ( token = NextTok() ) != T_RIGHT )
94  {
95  if( token == T_EOF)
96  break;
97 
98  if( token == T_LEFT )
99  token = NextTok();
100 
101  if( token == T_plugins )
102  continue;
103 
104  switch( token )
105  {
106  case T_plugin: // Defines a new plugin
107  parseGenerator();
108  break;
109 
110  default:
111 // Unexpected( CurText() );
112  break;
113  }
114  }
115 }
116 
117 
119 {
120  NeedSYMBOLorNUMBER();
121  wxString name = FromUTF8();
122  auto plugin = std::make_unique<BOM_GENERATOR_HANDLER>( name );
123 
124  T token;
125 
126  while( ( token = NextTok() ) != T_RIGHT )
127  {
128  if( token == T_EOF)
129  break;
130 
131  switch( token )
132  {
133  case T_LEFT:
134  break;
135 
136  case T_cmd:
137  NeedSYMBOLorNUMBER();
138 
139  if( plugin )
140  plugin->SetCommand( FromUTF8() );
141 
142  NeedRIGHT();
143  break;
144 
145  case T_opts:
146  NeedSYMBOLorNUMBER();
147 
148  if( plugin )
149  {
150  wxString option = FromUTF8();
151 
152  if( option.StartsWith( "nickname=", &name ) )
153  plugin->SetName( name );
154  else
155  plugin->Options().Add( option );
156  }
157 
158  NeedRIGHT();
159  break;
160 
161  default:
162  Unexpected( CurText() );
163  break;
164  }
165  }
166 
167  if( plugin )
168  m_generatorsList->push_back( std::move( plugin ) );
169 }
170 
171 
172 // The main dialog frame to run scripts to build bom
174 {
175 private:
178  wxConfigBase* m_config; // to store the "plugins"
180 
181 public:
182  DIALOG_BOM( SCH_EDIT_FRAME* parent );
183  ~DIALOG_BOM();
184 
185 private:
186  void OnGeneratorSelected( wxCommandEvent& event ) override;
187  void OnRunGenerator( wxCommandEvent& event ) override;
188  void OnHelp( wxCommandEvent& event ) override;
189  void OnAddGenerator( wxCommandEvent& event ) override;
190  void OnRemoveGenerator( wxCommandEvent& event ) override;
191  void OnEditGenerator( wxCommandEvent& event ) override;
192  void OnCommandLineEdited( wxCommandEvent& event ) override;
193  void OnNameEdited( wxCommandEvent& event ) override;
194  void OnShowConsoleChanged( wxCommandEvent& event ) override;
195  void OnIdle( wxIdleEvent& event ) override;
196 
197  void pluginInit();
198  void installGeneratorsList();
199  BOM_GENERATOR_HANDLER* addGenerator( const wxString& aPath, const wxString& aName = wxEmptyString );
200  bool pluginExists( const wxString& aName );
201 
203  {
204  int idx = m_lbGenerators->GetSelection();
205 
206  if( idx < 0 || idx >= (int)m_generators.size() )
207  return nullptr;
208 
209  return m_generators[idx].get();
210  }
211 
212  wxString chooseGenerator();
213 };
214 
215 
216 // Create and show DIALOG_BOM.
218 {
219  DIALOG_BOM dlg( aCaller );
220  return dlg.ShowModal();
221 }
222 
223 
225  DIALOG_BOM_BASE( parent )
226 {
227  m_parent = parent;
229  m_initialized = false;
230 
231  m_buttonAddGenerator->SetBitmap( KiBitmap( small_plus_xpm ) );
232  m_buttonDelGenerator->SetBitmap( KiBitmap( trash_xpm ) );
233  m_buttonEdit->SetBitmap( KiBitmap( small_edit_xpm ) );
234 
236 
237 #ifndef __WINDOWS__
238  m_checkBoxShowConsole->Show( false );
239 #endif
240 
241  m_sdbSizerOK->SetLabel( _( "Generate" ) );
242  m_sdbSizerCancel->SetLabel( _( "Close" ) );
243  m_sdbSizer->Layout();
244 
246  m_sdbSizerOK->SetDefault();
247 
248  // Now all widgets have the size fixed, call FinishDialogSettings
250 }
251 
253 {
254  // Save the plugin descriptions in config.
255  // The config stores only one string, so we save the plugins inside a S-expr:
256  // ( plugins
257  // ( plugin "plugin name 1" (cmd "command line 1") )
258  // ( plugin "plugin name 2" (cmd "command line 2") (opts "option1") (opts "option2") )
259  // ....
260  // )
261 
262  STRING_FORMATTER writer;
263  writer.Print( 0, "(plugins" );
264 
265  for( auto& plugin : m_generators )
266  {
267  writer.Print( 1, "(plugin %s (cmd %s)",
268  writer.Quotew( plugin->GetFile().GetFullPath() ).c_str(),
269  writer.Quotew( plugin->GetCommand() ).c_str() );
270 
271  for( unsigned jj = 0; jj < plugin->Options().GetCount(); jj++ )
272  {
273  writer.Print( 1, "(opts %s)",
274  writer.Quotew( plugin->Options().Item( jj ) ).c_str() );
275  }
276 
277  if( !plugin->GetName().IsEmpty() )
278  {
279  wxString option = wxString::Format( "nickname=%s", plugin->GetName() );
280 
281  writer.Print( 1, "(opts %s)",
282  writer.Quotew( option ).c_str() );
283  }
284 
285  writer.Print( 0, ")" );
286  }
287 
288  writer.Print( 0, ")" );
289 
290  wxString list( FROM_UTF8( writer.GetString().c_str() ) );
291 
292  m_config->Write( BOM_GENERATORS_KEY, list );
293 
294  wxString active_plugin_name = m_lbGenerators->GetStringSelection( );
295  m_config->Write( BOM_GENERATOR_SELECTED_KEY, active_plugin_name );
296 }
297 
298 
299 // Read the initialized plugins in config and fill the list of names
301 {
302  wxString list, active_plugin_name;
303  m_config->Read( BOM_GENERATORS_KEY, &list );
304  m_config->Read( BOM_GENERATOR_SELECTED_KEY, &active_plugin_name );
305 
306  if( !list.IsEmpty() )
307  {
308  BOM_CFG_PARSER cfg_parser( &m_generators, TO_UTF8( list ), wxT( "plugins" ) );
309 
310  try
311  {
312  cfg_parser.Parse();
313  }
314  catch( const IO_ERROR& )
315  {
316 // wxLogMessage( ioe.What() );
317  }
318  catch( std::runtime_error& e )
319  {
320  DisplayError( nullptr, e.what() );
321  }
322 
323  // Populate list box
324  for( unsigned ii = 0; ii < m_generators.size(); ii++ )
325  {
326  m_lbGenerators->Append( m_generators[ii]->GetName() );
327 
328  if( active_plugin_name == m_generators[ii]->GetName() )
329  m_lbGenerators->SetSelection( ii );
330  }
331  }
332 
333  if( m_generators.empty() ) // No plugins found?
334  {
335  // Load plugins from the default locations
336  std::vector<wxString> pluginPaths = {
337 #if defined(__WXGTK__)
338  "/usr/share/kicad/plugins",
339  "/usr/local/share/kicad/plugins",
340 #elif defined(__WXMSW__)
341  wxString::Format( "%s\\scripting\\plugins", Pgm().GetExecutablePath() ),
342 #elif defined(__WXMAC__)
343  wxString::Format( "%s/plugins", GetOSXKicadDataDir() ),
344 #endif
345  };
346 
347  wxFileName pluginPath;
348 
349  for( const auto& path : pluginPaths )
350  {
351  wxLogDebug( wxString::Format( "Searching directory %s for BOM generators", path ) );
352  wxDir dir( path );
353 
354  if( !dir.IsOpened() )
355  continue;
356 
357  pluginPath.AssignDir( dir.GetName() );
358  wxString fileName;
359  bool cont = dir.GetFirst( &fileName, wxFileSelectorDefaultWildcardStr, wxDIR_FILES );
360 
361  while( cont )
362  {
363  try
364  {
365  wxLogTrace( BOM_TRACE, wxString::Format( "Checking if %s is a BOM generator", fileName ) );
366 
368  {
369  pluginPath.SetFullName( fileName );
370  addGenerator( pluginPath.GetFullPath() );
371  }
372  }
373  catch( ... ) { /* well, no big deal */ }
374 
375  cont = dir.GetNext( &fileName );
376  }
377  }
378  }
379 
380 
381  pluginInit();
382 }
383 
384 
385 BOM_GENERATOR_HANDLER* DIALOG_BOM::addGenerator( const wxString& aPath, const wxString& aName )
386 {
387  BOM_GENERATOR_HANDLER* ret = nullptr;
388  auto plugin = std::make_unique<BOM_GENERATOR_HANDLER>( aPath );
389 
390  if( !plugin )
391  return nullptr;
392 
393  if( !aName.IsEmpty() )
394  {
395  plugin->SetName( aName );
396  m_lbGenerators->Append( aName );
397  }
398  else
399  {
400  m_lbGenerators->Append( plugin->GetName() );
401  }
402 
403  ret = plugin.get();
404  m_generators.push_back( std::move( plugin ) );
405  return ret;
406 }
407 
408 
409 bool DIALOG_BOM::pluginExists( const wxString& aName )
410 {
411  for( unsigned ii = 0; ii < m_generators.size(); ii++ )
412  {
413  if( aName == m_generators[ii]->GetName() )
414  return true;
415  }
416 
417  return false;
418 }
419 
420 
421 void DIALOG_BOM::OnGeneratorSelected( wxCommandEvent& event )
422 {
423  pluginInit();
424 }
425 
426 
428 {
429  auto plugin = selectedGenerator();
430 
431  if( !plugin )
432  {
433  m_textCtrlName->SetValue( wxEmptyString );
434  m_textCtrlCommand->SetValue( wxEmptyString );
435  m_Messages->SetValue( wxEmptyString );
436  return;
437  }
438 
439  m_textCtrlName->SetValue( plugin->GetName() );
440  m_textCtrlCommand->SetValue( plugin->GetCommand() );
441  m_Messages->SetValue( plugin->GetInfo() );
442  m_Messages->SetSelection( 0, 0 );
443 
444 #ifdef __WINDOWS__
445  if( plugin->Options().Index( wxT( "show_console" ) ) == wxNOT_FOUND )
446  m_checkBoxShowConsole->SetValue( false );
447  else
448  m_checkBoxShowConsole->SetValue( true );
449 #endif
450 
451  // A plugin can be not working, so do not left the OK button enabled if
452  // the plugin is not ready to use
453  m_sdbSizerOK->Enable( plugin->IsOk() );
454 }
455 
456 
457 void DIALOG_BOM::OnRunGenerator( wxCommandEvent& event )
458 {
459  // Calculate the xml netlist filename
460  wxFileName fn = g_RootSheet->GetScreen()->GetFileName();
461 
462  fn.SetPath( wxPathOnly( Prj().GetProjectFullName() ) );
463  fn.ClearExt();
464 
465  wxString fullfilename = fn.GetFullPath();
467 
468  wxString reportmsg;
469  WX_STRING_REPORTER reporter( &reportmsg );
471 
472 #ifdef __WINDOWS__
473  if( m_checkBoxShowConsole->IsChecked() )
474  m_parent->SetExecFlags( wxEXEC_SHOW_CONSOLE );
475 #endif
476 
477  auto netlist = m_parent->CreateNetlist( false, false );
478 
479  m_parent->WriteNetListFile( netlist, -1,
480  fullfilename, 0, &reporter );
481 
482  m_Messages->SetValue( reportmsg );
483 
484  // Force focus back on the dialog
485  SetFocus();
486 }
487 
488 
489 void DIALOG_BOM::OnRemoveGenerator( wxCommandEvent& event )
490 {
491  int ii = m_lbGenerators->GetSelection();
492 
493  if( ii < 0 )
494  return;
495 
496  m_lbGenerators->Delete( ii );
497  m_generators.erase( m_generators.begin() + ii );
498 
499  // Select the next item, if exists
500  if( m_lbGenerators->GetCount() )
501  m_lbGenerators->SetSelection( std::min( ii, (int) m_lbGenerators->GetCount() - 1 ) );
502 
503  pluginInit();
504 }
505 
506 
507 void DIALOG_BOM::OnAddGenerator( wxCommandEvent& event )
508 {
509  wxString filename = chooseGenerator();
510 
511  if( filename.IsEmpty() )
512  return;
513 
514  // Creates a new plugin entry
515  wxFileName fn( filename );
516  wxString name = wxGetTextFromUser( _( "Generator nickname:" ), _( "Add Generator" ),
517  fn.GetName(), this );
518 
519  if( name.IsEmpty() )
520  return;
521 
522  // Verify if it does not exists
523  if( pluginExists( name ) )
524  {
525  wxMessageBox( wxString::Format( _( "Nickname \"%s\" already in use." ), name ) );
526  return;
527  }
528 
529  try
530  {
531  auto plugin = addGenerator( fn.GetFullPath(), name );
532 
533  if( plugin )
534  {
535  m_lbGenerators->SetSelection( m_lbGenerators->GetCount() - 1 );
536  m_textCtrlCommand->SetValue( plugin->GetCommand() );
537  pluginInit();
538  }
539  }
540  catch( const std::runtime_error& e )
541  {
542  DisplayError( this, e.what() );
543  }
544 }
545 
546 
548 {
549  static wxString lastPath;
550 
551  if( lastPath.IsEmpty() )
552  {
553 #ifndef __WXMAC__
554  lastPath = Pgm().GetExecutablePath();
555 #else
556  lastPath = GetOSXKicadDataDir() + "/plugins";
557 #endif
558  }
559 
560  wxString fullFileName = EDA_FILE_SELECTOR( _( "Generator files:" ), lastPath, wxEmptyString,
561  wxEmptyString, wxFileSelectorDefaultWildcardStr,
562  this, wxFD_OPEN, true );
563 
564  return fullFileName;
565 }
566 
567 
568 void DIALOG_BOM::OnEditGenerator( wxCommandEvent& event )
569 {
570  auto plugin = selectedGenerator();
571 
572  if( !plugin )
573  return;
574 
575  wxString pluginFile = plugin->GetFile().GetFullPath();
576 
577  if( pluginFile.Length() <= 2 ) // if name != ""
578  {
579  wxMessageBox( _( "Generator file name not found." ) );
580  return;
581  }
582 
583  AddDelimiterString( pluginFile );
584  wxString editorname = Pgm().GetEditorName();
585 
586  if( !editorname.IsEmpty() )
587  ExecuteFile( this, editorname, pluginFile );
588  else
589  wxMessageBox( _( "No text editor selected in KiCad. Please choose one." ) );
590 }
591 
592 
593 void DIALOG_BOM::OnHelp( wxCommandEvent& event )
594 {
595  HTML_MESSAGE_BOX help_Dlg( this, _( "Bill of Material Generation Help" ) );
596  help_Dlg.SetDialogSizeInDU( 500, 350 );
597 
598  wxString msg = FROM_UTF8( s_bomHelpInfo );
599  help_Dlg.m_htmlWindow->AppendToPage( msg );
600  help_Dlg.ShowModal();
601 }
602 
603 
604 void DIALOG_BOM::OnCommandLineEdited( wxCommandEvent& event )
605 {
606  auto generator = selectedGenerator();
607 
608  if( generator )
609  generator->SetCommand( m_textCtrlCommand->GetValue() );
610 }
611 
612 
613 void DIALOG_BOM::OnNameEdited( wxCommandEvent& event )
614 {
615  int ii = m_lbGenerators->GetSelection();
616 
617  if( ii < 0 )
618  return;
619 
620  m_generators[ii]->SetName( m_textCtrlName->GetValue() );
621  m_lbGenerators->SetString( ii, m_generators[ii]->GetName() );
622 }
623 
624 
625 void DIALOG_BOM::OnShowConsoleChanged( wxCommandEvent& event )
626 {
627 #ifdef __WINDOWS__
628  static constexpr wxChar OPT_SHOW_CONSOLE[] = wxT( "show_console" );
629 
630  auto plugin = selectedGenerator();
631 
632  if( !plugin )
633  return;
634 
635  if( m_checkBoxShowConsole->IsChecked() )
636  {
637  if( plugin->Options().Index( OPT_SHOW_CONSOLE ) == wxNOT_FOUND )
638  plugin->Options().Add( OPT_SHOW_CONSOLE );
639  }
640  else
641  {
642  plugin->Options().Remove( OPT_SHOW_CONSOLE );
643  }
644 #endif
645 }
646 
647 
648 void DIALOG_BOM::OnIdle( wxIdleEvent& event )
649 {
650  // On some platforms we initialize wxTextCtrls to all-selected, but we don't want that
651  // for the messages text box.
652  if( !m_initialized )
653  {
654  m_Messages->SetSelection( 0, 0 );
655  m_initialized = true;
656  }
657 }
wxBitmapButton * m_buttonEdit
wxBitmapButton * m_buttonAddGenerator
const wxString & GetFileName() const
Definition: sch_screen.h:118
static constexpr wxChar BOM_GENERATOR_SELECTED_KEY[]
Definition: dialog_bom.cpp:52
void OnCommandLineEdited(wxCommandEvent &event) override
Definition: dialog_bom.cpp:604
void OnEditGenerator(wxCommandEvent &event) override
Definition: dialog_bom.cpp:568
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:224
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:489
std::vector< BOM_GENERATOR_HANDLER::PTR > BOM_GENERATOR_ARRAY
Definition: dialog_bom.cpp:62
static const char * s_bomHelpInfo
Definition: dialog_bom.cpp:54
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:409
static constexpr wxChar BOM_TRACE[]
Definition: dialog_bom.cpp:49
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:217
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:268
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:116
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:51
void OnIdle(wxIdleEvent &event) override
Definition: dialog_bom.cpp:648
void OnGeneratorSelected(wxCommandEvent &event) override
Definition: dialog_bom.cpp:421
void OnHelp(wxCommandEvent &event) override
Definition: dialog_bom.cpp:593
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:457
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:47
wxCheckBox * m_checkBoxShowConsole
void OnNameEdited(wxCommandEvent &event) override
Definition: dialog_bom.cpp:613
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:82
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:44
const std::string & GetString()
Definition: richio.h:475
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:472
void installGeneratorsList()
Definition: dialog_bom.cpp:300
Class HTML_MESSAGE_BOX.
Holds data and functions pertinent to parsing a S-expression file.
Definition: dialog_bom.cpp:68
virtual void ClearMsgPanel()
Clear all messages from the message panel.
wxTextCtrl * m_Messages
bool m_initialized
Definition: dialog_bom.cpp:179
#define _(s)
void parseGenerator()
Definition: dialog_bom.cpp:118
wxString chooseGenerator()
Definition: dialog_bom.cpp:547
BOM_GENERATOR_ARRAY * m_generatorsList
Definition: dialog_bom.cpp:70
BOM_GENERATOR_ARRAY m_generators
Definition: dialog_bom.cpp:177
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:507
see class PGM_BASE
Implementation of std::make_unique for pre C++14 compilation environments.
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:229
Class DIALOG_BOM_BASE.
wxListBox * m_lbGenerators
wxButton * m_sdbSizerCancel
SCH_EDIT_FRAME * m_parent
Definition: dialog_bom.cpp:176
VTBL_ENTRY const wxString & GetEditorName(bool aCanShowFileChooser=true)
Return the preferred editor name.
Definition: pgm_base.cpp:178
static constexpr wxChar BOM_GENERATORS_KEY[]
Definition: dialog_bom.cpp:51
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:178
BOM_GENERATOR_HANDLER * selectedGenerator()
Definition: dialog_bom.cpp:202
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:208
void SetExecFlags(const int aFlags)
Set (adds) specified flags for next execution of external generator of the netlist or bom.
wxBitmapButton * m_buttonDelGenerator
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:243
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:385
void pluginInit()
Definition: dialog_bom.cpp:427
void OnShowConsoleChanged(wxCommandEvent &event) override
Definition: dialog_bom.cpp:625
#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:81