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) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2018 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 <wx/ffile.h>
38 #include <netlist.h>
40 #include <invoke_sch_dialog.h>
41 #include <dialog_helpers.h>
42 #include <dialog_bom_base.h>
43 #include <html_messagebox.h>
44 #include <reporter.h>
45 
46 #define BOM_PLUGINS_KEY wxT("bom_plugins")
47 #define BOM_PLUGIN_SELECTED_KEY wxT("bom_plugin_selected")
48 
49 const char * s_bomHelpInfo =
50 #include <dialog_bom_help_html.h>
51 ;
52 
53 #include <dialog_bom_cfg_lexer.h>
54 
55 using namespace T_BOMCFG_T;
56 
61 struct BOM_PLUGIN
62 {
63  wxString Name;
64  wxString Command;
65  wxArrayString Options;
66 };
67 
71 WX_DECLARE_OBJARRAY( BOM_PLUGIN, BOM_PLUGIN_ARRAY );
72 #include <wx/arrimpl.cpp>
73 WX_DEFINE_OBJARRAY( BOM_PLUGIN_ARRAY )
74 
75 
79 class BOM_CFG_PARSER : public DIALOG_BOM_CFG_LEXER
80 {
81  BOM_PLUGIN_ARRAY* m_pluginsList;
82 
83 public:
84  BOM_CFG_PARSER( BOM_PLUGIN_ARRAY* aPlugins, const char* aData, const wxString& aSource );
85  void Parse();
86 
87 private:
88  void parsePlugin();
89 };
90 
91 
92 BOM_CFG_PARSER::BOM_CFG_PARSER( BOM_PLUGIN_ARRAY* aPlugins, const char* aLine,
93  const wxString& aSource ) :
94  DIALOG_BOM_CFG_LEXER( aLine, aSource )
95 {
96  m_pluginsList = aPlugins;
97 }
98 
99 
101 {
102  T token;
103 
104  while( ( token = NextTok() ) != T_RIGHT )
105  {
106  if( token == T_EOF)
107  break;
108 
109  if( token == T_LEFT )
110  token = NextTok();
111 
112  if( token == T_plugins )
113  continue;
114 
115  switch( token )
116  {
117  case T_plugin: // Defines a new plugin
118  parsePlugin();
119  break;
120 
121  default:
122 // Unexpected( CurText() );
123  break;
124  }
125  }
126 }
127 
129 {
130  BOM_PLUGIN plugin;
131 
132  NeedSYMBOLorNUMBER();
133  plugin.Name = FromUTF8();
134 
135  T token;
136  while( ( token = NextTok() ) != T_RIGHT )
137  {
138  if( token == T_EOF)
139  break;
140 
141  switch( token )
142  {
143  case T_LEFT:
144  break;
145 
146  case T_cmd:
147  NeedSYMBOLorNUMBER();
148  plugin.Command = FromUTF8();
149  NeedRIGHT();
150  break;
151 
152  case T_opts:
153  NeedSYMBOLorNUMBER();
154  plugin.Options.Add( FromUTF8() );
155  NeedRIGHT();
156  break;
157 
158  default:
159  Unexpected( CurText() );
160  break;
161  }
162  }
163 
164  if( ! plugin.Name.IsEmpty() )
165  m_pluginsList->Add( plugin );
166 }
167 
168 
169 // The main dialog frame to run scripts to build bom
171 {
172 private:
174  BOM_PLUGIN_ARRAY m_plugins;
175  wxConfigBase* m_config; // to store the "plugins"
177 
178 public:
179  DIALOG_BOM( SCH_EDIT_FRAME* parent );
180  ~DIALOG_BOM();
181 
182 private:
183  void OnPluginSelected( wxCommandEvent& event ) override;
184  void OnRunPlugin( wxCommandEvent& event ) override;
185  void OnHelp( wxCommandEvent& event ) override;
186  void OnAddPlugin( wxCommandEvent& event ) override;
187  void OnRemovePlugin( wxCommandEvent& event ) override;
188  void OnEditPlugin( wxCommandEvent& event ) override;
189  void OnCommandLineEdited( wxCommandEvent& event ) override;
190  void OnNameEdited( wxCommandEvent& event ) override;
191  void OnShowConsoleChanged( wxCommandEvent& event ) override;
192  void OnIdle( wxIdleEvent& event ) override;
193 
194  void pluginInit();
195  void installPluginsList();
196 
197  wxString getPluginFileName( const wxString& aCommand );
198 
199  /*
200  * Display the text found between the keyword @package (compatible with doxygen comments)
201  * and the end of comment block (""" in python, --> in xml)
202  */
203  void displayPluginInfo( FILE * aFile, const wxString& aFilename );
204 
205  wxString choosePlugin();
206 };
207 
208 
209 // Create and show DIALOG_BOM.
211 {
212  DIALOG_BOM dlg( aCaller );
213  return dlg.ShowModal();
214 }
215 
216 
218  DIALOG_BOM_BASE( parent )
219 {
220  m_parent = parent;
222  m_initialized = false;
223 
224  m_buttonAddPlugin->SetBitmap( KiBitmap( plus_xpm ) );
225  m_buttonDelPlugin->SetBitmap( KiBitmap( delete_xpm ) );
226  m_buttonEdit->SetBitmap( KiBitmap( small_edit_xpm ) );
227 
229 
230 #ifndef __WINDOWS__
231  m_checkBoxShowConsole->Show( false );
232 #endif
233 
234  m_sdbSizer1OK->SetLabel( _( "Generate" ) );
235  m_sdbSizer1Cancel->SetLabel( _( "Close" ) );
236  m_sdbSizer1->Layout();
237 
239  m_sdbSizer1OK->SetDefault();
240 
241  // Now all widgets have the size fixed, call FinishDialogSettings
243 }
244 
246 {
247  // Save the plugin descriptions in config.
248  // The config stores only one string, so we save the plugins inside a S-expr:
249  // ( plugins
250  // ( plugin "plugin name 1" (cmd "command line 1") )
251  // ( plugin "plugin name 2" (cmd "command line 2") (opts "option1") (opts "option2") )
252  // ....
253  // )
254 
255  STRING_FORMATTER writer;
256  writer.Print( 0, "(plugins" );
257 
258  for( unsigned ii = 0; ii < m_plugins.GetCount(); ii++ )
259  {
260  writer.Print( 1, "(plugin %s (cmd %s)",
261  writer.Quotew( m_plugins.Item( ii ).Name ).c_str(),
262  writer.Quotew( m_plugins.Item( ii ).Command ).c_str() );
263 
264  for( unsigned jj = 0; jj < m_plugins.Item( ii ).Options.GetCount(); jj++ )
265  {
266  writer.Print( 1, "(opts %s)",
267  writer.Quotew( m_plugins.Item( ii ).Options.Item( jj ) ).c_str() );
268  }
269 
270  writer.Print( 0, ")" );
271  }
272 
273  writer.Print( 0, ")" );
274 
275  wxString list( FROM_UTF8( writer.GetString().c_str() ) );
276 
277  m_config->Write( BOM_PLUGINS_KEY, list );
278 
279  wxString active_plugin_name = m_lbPlugins->GetStringSelection( );
280  m_config->Write( BOM_PLUGIN_SELECTED_KEY, active_plugin_name );
281 
282 }
283 
284 // Read the initialized plugins in config and fill the list of names
286 {
287  wxString list, active_plugin_name;
288  m_config->Read( BOM_PLUGINS_KEY, &list );
289  m_config->Read( BOM_PLUGIN_SELECTED_KEY, &active_plugin_name );
290 
291  if( !list.IsEmpty() )
292  {
293  BOM_CFG_PARSER cfg_parser( &m_plugins, TO_UTF8( list ), wxT( "plugins" ) );
294  try
295  {
296  cfg_parser.Parse();
297  }
298  catch( const IO_ERROR& )
299  {
300 // wxLogMessage( ioe.What() );
301  }
302  }
303 
304  // Populate list box
305  for( unsigned ii = 0; ii < m_plugins.GetCount(); ii++ )
306  {
307  m_lbPlugins->Append( m_plugins.Item( ii ).Name );
308 
309  if( active_plugin_name == m_plugins.Item( ii ).Name )
310  m_lbPlugins->SetSelection( ii );
311  }
312 
313  pluginInit();
314 }
315 
316 
317 void DIALOG_BOM::OnPluginSelected( wxCommandEvent& event )
318 {
319  pluginInit();
320 }
321 
322 
324 {
325  int ii = m_lbPlugins->GetSelection();
326 
327  if( ii < 0 )
328  {
329  m_textCtrlName->SetValue( wxEmptyString );
330  m_textCtrlCommand->SetValue( wxEmptyString );
331  return;
332  }
333 
334  m_textCtrlName->SetValue( m_plugins.Item( ii ).Name );
335  m_textCtrlCommand->SetValue( m_plugins.Item( ii ).Command );
336 
337 #ifdef __WINDOWS__
338  if( m_plugins.Item( ii ).Options.Index( wxT( "show_console" ) ) == wxNOT_FOUND )
339  m_checkBoxShowConsole->SetValue( false );
340  else
341  m_checkBoxShowConsole->SetValue( true );
342 #endif
343 
344  wxString pluginName = getPluginFileName( m_textCtrlCommand->GetValue() );
345 
346  if( pluginName.IsEmpty() )
347  return;
348 
349  FILE* pluginFile = wxFopen( pluginName, "rt" );
350 
351  if( !pluginFile )
352  {
353  DisplayError( this, wxString::Format( _( "Failed to open file \"%s\"." ), pluginName ) );
354  return;
355  }
356 
357  displayPluginInfo( pluginFile, pluginName );
358 }
359 
360 
361 void DIALOG_BOM::displayPluginInfo( FILE * aFile, const wxString& aFilename )
362 {
363  m_Messages->Clear();
364 
365  // Display the text found between the keyword @package (compatible with doxygen comments)
366  // and the end of comment block (""" in python, --> in xml)
367 
368  wxString data;
369  wxFFile fdata( aFile ); // dtor will close the file
370 
371  if( !fdata.ReadAll( &data ) )
372  return;
373 
374  wxString header( wxT( "@package" ) );
375  wxString endsection;
376 
377  wxFileName fn( aFilename );
378 
379  if( fn.GetExt().IsSameAs( wxT( "py" ), false ) )
380  endsection = wxT( "\"\"\"" );
381  else if( fn.GetExt().IsSameAs( wxT( "xsl" ), false ) )
382  endsection = wxT( "-->" );
383  else
384  // If this is not a python or xsl file, then we don't know how to find the info
385  return;
386 
387  // Extract substring between @package and endsection
388  int strstart = data.Find( header );
389 
390  if( strstart == wxNOT_FOUND )
391  return;
392 
393  strstart += header.Length();
394  int strend = data.find( endsection, strstart );
395 
396  if( strend == wxNOT_FOUND)
397  return;
398 
399  // Remove empty line if any
400  while( data[strstart] < ' ' )
401  strstart++;
402 
403  m_Messages->SetValue( data.SubString( strstart, strend-1 ) );
404  m_Messages->SetSelection( 0, 0 );
405 }
406 
407 
408 // run the plugin command line
409 void DIALOG_BOM::OnRunPlugin( wxCommandEvent& event )
410 {
411  // Calculate the xml netlist filename
412  wxFileName fn = g_RootSheet->GetScreen()->GetFileName();
413 
414  fn.SetPath( wxPathOnly( Prj().GetProjectFullName() ) );
415  fn.ClearExt();
416 
417  wxString fullfilename = fn.GetFullPath();
419 
420  wxString reportmsg;
421  WX_STRING_REPORTER reporter( &reportmsg );
423 
424 #ifdef __WINDOWS__
425  if( m_checkBoxShowConsole->IsChecked() )
426  m_parent->SetExecFlags( wxEXEC_SHOW_CONSOLE );
427 #endif
428 
429  m_parent->CreateNetlist( -1, fullfilename, 0, &reporter, false );
430 
431  m_Messages->SetValue( reportmsg );
432 }
433 
434 
435 void DIALOG_BOM::OnRemovePlugin( wxCommandEvent& event )
436 {
437  int ii = m_lbPlugins->GetSelection();
438 
439  if( ii < 0 )
440  return;
441 
442  m_lbPlugins->Delete( ii );
443 
444  m_plugins.RemoveAt( ii );
445 
446  // Select the next item, if exists
447  if( m_lbPlugins->GetCount() )
448  m_lbPlugins->SetSelection( std::min( ii, (int) m_lbPlugins->GetCount() - 1 ) );
449 
450  pluginInit();
451 }
452 
453 
454 void DIALOG_BOM::OnAddPlugin( wxCommandEvent& event )
455 {
456  wxString cmdLine = choosePlugin();
457  BOM_PLUGIN newPlugin;
458 
459  if( cmdLine.IsEmpty() )
460  return;
461 
462  // Creates a new plugin entry
463  wxFileName fn( getPluginFileName( cmdLine ) );
464  wxString name = wxGetTextFromUser( _("Plugin nickname:" ), _("Add Plugin"), fn.GetName(), this );
465 
466  if( name.IsEmpty() )
467  return;
468 
469  // Verify if it does not exists
470  for( unsigned ii = 0; ii < m_plugins.GetCount(); ii++ )
471  {
472  if( name == m_plugins.Item( ii ).Name )
473  {
474  wxMessageBox( wxString::Format( _("Nickname \"%s\" already in use."), name ) );
475  return;
476  }
477  }
478 
479  // Append the new plugin
480  newPlugin.Name = name;
481  newPlugin.Command = wxEmptyString;
482  m_plugins.Add( newPlugin );
483  m_lbPlugins->Append( name );
484  m_lbPlugins->SetSelection( m_lbPlugins->GetCount() - 1 );
485  m_textCtrlCommand->SetValue( cmdLine );
486 
487  pluginInit();
488 }
489 
490 /*
491  * Browse plugin files, and set m_CommandStringCtrl field
492  */
494 {
495  wxString mask = wxT( "*" );
496 #ifndef __WXMAC__
497  wxString path = Pgm().GetExecutablePath();
498 #else
499  wxString path = GetOSXKicadDataDir() + wxT( "/plugins" );
500 #endif
501 
502  wxString fullFileName = EDA_FILE_SELECTOR( _( "Plugin files:" ),
503  path,
504  wxEmptyString,
505  wxEmptyString,
506  mask,
507  this,
508  wxFD_OPEN,
509  true );
510  if( fullFileName.IsEmpty() )
511  return wxEmptyString;
512 
513  // Creates a default command line,
514  // suitable to run the external tool xslproc or python
515  // The default command line depending on plugin extension, currently
516  // "xsl" or "exe" or "py" or "pyw"
517  wxString cmdLine;
518  wxFileName fn( fullFileName );
519  wxString ext = fn.GetExt();
520 
521  // Python requires on Windows the path of the script ends by '/' instead of '\'
522  // otherwise import does not find modules in the same folder as the python script
523  // We cannot change all '\' to '/' in command line because it causes issues with files
524  // that are stored on network resources and pointed to using the Windows
525  // Universal Naming Convention format. (full filename starting by \\server\)
526  //
527  // I hope changing the last separator only to '/' will work.
528 #ifdef __WINDOWS__
529  if( ext == wxT("py" ) || ext == wxT("pyw" ) )
530  {
531  wxString sc_path = fn.GetPathWithSep();
532  sc_path.RemoveLast();
533  fullFileName = sc_path +'/' + fn.GetFullName();;
534  }
535 #endif
536 
537  if( ext == "xsl" )
538  cmdLine.Printf( "xsltproc -o \"%%O\" \"%s\" \"%%I\"", GetChars( fullFileName ) );
539  else if( ext == "exe" )
540  cmdLine.Printf( "\"%s\" < \"%%I\" > \"%%O\"", GetChars( fullFileName ) );
541  else if( ext == "py" )
542  cmdLine.Printf( "python \"%s\" \"%%I\" \"%%O\"", GetChars( fullFileName ) );
543  else if( ext == "pyw" )
544 #ifdef __WINDOWS__
545  cmdLine.Printf( "pythonw \"%s\" \"%%I\" \"%%O\"", GetChars( fullFileName ) );
546 #else
547  cmdLine.Printf( "python \"%s\" \"%%I\" \"%%O\"", GetChars( fullFileName ) );
548 #endif
549  else
550  cmdLine.Printf( "\"%s\"", GetChars( fullFileName ) );
551 
552  return cmdLine;
553 }
554 
555 
556 wxString DIALOG_BOM::getPluginFileName( const wxString& aCommand )
557 {
558  wxString pluginName;
559 
560  // Try to find the plugin name.
561  // This is possible if the name ends by .py or .pyw or .xsl or .exe
562  int pos = -1;
563 
564  if( (pos = aCommand.Find( wxT(".pyw") )) != wxNOT_FOUND )
565  pos += 3;
566  else if( (pos = aCommand.Find( wxT(".py") )) != wxNOT_FOUND )
567  pos += 2;
568  else if( (pos = aCommand.Find( wxT(".xsl") )) != wxNOT_FOUND )
569  pos += 3;
570  else if( (pos = aCommand.Find( wxT(".exe") )) != wxNOT_FOUND )
571  pos += 3;
572 
573  // the end of plugin name is at position pos.
574  if( pos > 0 )
575  {
576  // Be sure this is the end of the name: the next char is " or space
577  int eos = aCommand[pos+1];
578 
579  if( eos == ' '|| eos == '\"' )
580  {
581  // search for the starting point of the name
582  int jj = pos-1;
583  while( jj >= 0 )
584  if( aCommand[jj] != eos )
585  jj--;
586  else
587  break;
588 
589  // extract the name
590  if( jj >= 0 )
591  {
592  eos = aCommand[jj];
593 
594  if( eos == ' '|| eos == '\"' ) // do not include delimiters
595  jj++;
596 
597  pluginName = aCommand.SubString( jj, pos );
598  }
599  }
600  }
601 
602  // Using a format like %P is possible in plugin name, so expand it
603  wxString prj_dir = Prj().GetProjectPath();
604 
605  if( prj_dir.EndsWith( '/' ) || prj_dir.EndsWith( '\\' ) )
606  prj_dir.RemoveLast();
607 
608  pluginName.Replace( wxT( "%P" ), prj_dir.GetData(), true );
609 
610  return pluginName;
611 }
612 
613 void DIALOG_BOM::OnEditPlugin( wxCommandEvent& event )
614 {
615  wxString pluginName = getPluginFileName( m_textCtrlCommand->GetValue() );
616 
617  if( pluginName.Length() <= 2 ) // if name != ""
618  {
619  wxMessageBox( _("Plugin file name not found.") );
620  return;
621  }
622 
623  AddDelimiterString( pluginName );
624  wxString editorname = Pgm().GetEditorName();
625 
626  if( !editorname.IsEmpty() )
627  ExecuteFile( this, editorname, pluginName );
628  else
629  wxMessageBox( _( "No text editor selected in KiCad. Please choose one." ) );
630 }
631 
632 
633 void DIALOG_BOM::OnHelp( wxCommandEvent& event )
634 {
635  HTML_MESSAGE_BOX help_Dlg( this, _("Bom Generation Help") );
636  help_Dlg.SetDialogSizeInDU( 500, 350 );
637 
638  wxString msg = FROM_UTF8(s_bomHelpInfo);
639  help_Dlg.m_htmlWindow->AppendToPage( msg );
640  help_Dlg.ShowModal();
641 }
642 
643 
644 void DIALOG_BOM::OnCommandLineEdited( wxCommandEvent& event )
645 {
646  int ii = m_lbPlugins->GetSelection();
647 
648  if( ii < 0 )
649  return;
650 
651  m_plugins.Item( ii ).Command = m_textCtrlCommand->GetValue();
652 }
653 
654 
655 void DIALOG_BOM::OnNameEdited( wxCommandEvent& event )
656 {
657  int ii = m_lbPlugins->GetSelection();
658 
659  if( ii < 0 )
660  return;
661 
662  m_plugins.Item( ii ).Name = m_textCtrlName->GetValue();
663  m_lbPlugins->SetString( ii, m_plugins.Item( ii ).Name );
664 }
665 
666 void DIALOG_BOM::OnShowConsoleChanged( wxCommandEvent& event )
667 {
668 #ifdef __WINDOWS__
669  int ii = m_lbPlugins->GetSelection();
670 
671  if( ii < 0 )
672  return;
673 
674  if( m_checkBoxShowConsole->IsChecked() )
675  {
676  if( m_plugins.Item( ii ).Options.Index( wxT( "show_console" ) ) == wxNOT_FOUND )
677  m_plugins.Item( ii ).Options.Add( wxT( "show_console" ) );
678  }
679  else
680  {
681  m_plugins.Item( ii ).Options.Remove( wxT( "show_console" ) );
682  }
683 #endif
684 }
685 
686 
687 void DIALOG_BOM::OnIdle( wxIdleEvent& event )
688 {
689  // On some platforms we initialize wxTextCtrls to all-selected, but we don't want that
690  // for the messages text box.
691  if( !m_initialized )
692  {
693  m_Messages->SetSelection( 0, 0 );
694  m_initialized = true;
695  }
696 }
void OnPluginSelected(wxCommandEvent &event) override
Definition: dialog_bom.cpp:317
wxBitmapButton * m_buttonEdit
wxBitmapButton * m_buttonAddPlugin
void OnCommandLineEdited(wxCommandEvent &event) override
Definition: dialog_bom.cpp:644
wxArrayString Options
Definition: dialog_bom.cpp:65
void Parse(void *yyp, int yymajor, ParseTOKENTYPE yyminorParseARG_PDECL)
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:53
This file is part of the common library TODO brief description.
DIALOG_BOM(SCH_EDIT_FRAME *parent)
Definition: dialog_bom.cpp:217
Structure BOM_PLUGIN holds data of the BOM plugin.
Definition: dialog_bom.cpp:61
This file is part of the common library.
VTBL_ENTRY const wxString & GetExecutablePath() const
Definition: pgm_base.h:190
const char * s_bomHelpInfo
Definition: dialog_bom.cpp:49
#define BOM_PLUGIN_SELECTED_KEY
Definition: dialog_bom.cpp:47
wxString getPluginFileName(const wxString &aCommand)
Definition: dialog_bom.cpp:556
wxStdDialogButtonSizer * m_sdbSizer1
const wxString & GetFileName() const
Definition: sch_screen.h:120
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
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:210
void OnRunPlugin(wxCommandEvent &event) override
Definition: dialog_bom.cpp:409
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:279
WX_DECLARE_OBJARRAY(BOM_PLUGIN, BOM_PLUGIN_ARRAY)
Define wxArray of BOM_PLUGIN.
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:86
void OnRemovePlugin(wxCommandEvent &event) override
Definition: dialog_bom.cpp:435
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
void OnIdle(wxIdleEvent &event) override
Definition: dialog_bom.cpp:687
void OnHelp(wxCommandEvent &event) override
Definition: dialog_bom.cpp:633
wxListBox * m_lbPlugins
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:78
wxString Name
Definition: dialog_bom.cpp:63
wxTextCtrl * m_textCtrlName
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
wxCheckBox * m_checkBoxShowConsole
void OnNameEdited(wxCommandEvent &event) override
Definition: dialog_bom.cpp:655
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
void OnEditPlugin(wxCommandEvent &event) override
Definition: dialog_bom.cpp:613
Helper dialog and control classes.
wxString choosePlugin()
Definition: dialog_bom.cpp:493
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
void AddDelimiterString(wxString &string)
Function AddDelimiterString Add un " to the start and the end of string (if not already done)...
Definition: gestfich.cpp:44
#define BOM_PLUGINS_KEY
Definition: dialog_bom.cpp:46
wxBitmapButton * m_buttonDelPlugin
const std::string & GetString()
Definition: richio.h:475
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:482
Class HTML_MESSAGE_BOX.
BOM_PLUGIN_ARRAY * m_pluginsList
Definition: dialog_bom.cpp:81
Class BOM_CFG_READER_PARSER holds data and functions pertinent to parsing a S-expression file...
Definition: dialog_bom.cpp:79
wxTextCtrl * m_Messages
bool m_initialized
Definition: dialog_bom.cpp:176
wxButton * m_sdbSizer1OK
Class WX_STRING_REPORTER is a wrapper for reporting to a wxString object.
Definition: reporter.h:163
void SetDialogSizeInDU(int aWidth, int aHeight)
set the dialog size, using a "logical value.
BOM_PLUGIN_ARRAY m_plugins
Definition: dialog_bom.cpp:174
void parsePlugin()
Definition: dialog_bom.cpp:128
void OnAddPlugin(wxCommandEvent &event) override
Definition: dialog_bom.cpp:454
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
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
void displayPluginInfo(FILE *aFile, const wxString &aFilename)
Definition: dialog_bom.cpp:361
wxButton * m_sdbSizer1Cancel
bool CreateNetlist(int aFormat, const wxString &aFullFileName, unsigned aNetlistOptions, REPORTER *aReporter=NULL, bool silent=false)
Create a netlist for the current schematic.
wxString Command
Definition: dialog_bom.cpp:64
Class DIALOG_BOM_BASE.
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
void installPluginsList()
Definition: dialog_bom.cpp:285
SCH_EDIT_FRAME * m_parent
Definition: dialog_bom.cpp:173
VTBL_ENTRY const wxString & GetEditorName(bool aCanShowFileChooser=true)
Return the preferred editor name.
Definition: pgm_base.cpp:180
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:175
BOM_CFG_PARSER(BOM_PLUGIN_ARRAY *aPlugins, const char *aData, const wxString &aSource)
Definition: dialog_bom.cpp:92
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...
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:233
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)
void ClearMsgPanel(void)
Clear all messages from the message panel.
Definition: draw_frame.cpp:845
void pluginInit()
Definition: dialog_bom.cpp:323
void OnShowConsoleChanged(wxCommandEvent &event) override
Definition: dialog_bom.cpp:666
#define min(a, b)
Definition: auxiliary.h:85