KiCad PCB EDA Suite
eeschema/dialogs/dialog_netlist.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) 2013-2017 Jean-Pierre Charras, jp.charras@wanadoo.fr
5  * Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 /* Functions relative to the dialog creating the netlist for Pcbnew. The dialog is a notebook
27  * with 4 fixed netlist formats:
28  * Pcbnew
29  * ORCADPCB2
30  * CADSTAR
31  * SPICE
32  * and up to CUSTOMPANEL_COUNTMAX user programmable formats. These external converters are
33  * referred to as plugins, but they are really just external binaries.
34  */
35 
36 #include <fctsys.h>
37 #include <pgm_base.h>
38 #include <kiface_i.h>
39 #include <gestfich.h>
40 #include <sch_edit_frame.h>
41 #include <general.h>
42 #include <netlist.h>
43 #include <dialogs/dialog_netlist_base.h>
45 #include <invoke_sch_dialog.h>
47 
48 #include <eeschema_id.h>
49 #include <wx/regex.h>
50 
51 
52 #define CUSTOMPANEL_COUNTMAX 8 // Max number of netlist plugins
53 
54 
55 /* panel (notebook page) identifiers */
57  PANELPCBNEW = 0, /* Handle Netlist format Pcbnew */
58  PANELORCADPCB2, /* Handle Netlist format OracdPcb2 */
59  PANELCADSTAR, /* Handle Netlist format CadStar */
60  PANELSPICE, /* Handle Netlist format Pspice */
61  PANELCUSTOMBASE /* First auxiliary panel (custom netlists).
62  * others use PANELCUSTOMBASE+1, PANELCUSTOMBASE+2.. */
63 };
64 
65 
66 /* wxPanels for creating the NoteBook pages for each netlist format: */
67 class NETLIST_PAGE_DIALOG : public wxPanel
68 {
69 public:
71  wxCheckBox* m_IsCurrentFormat;
72  // opt to reformat passive component values (e.g. 1M -> 1Meg):
73  wxCheckBox* m_AdjustPassiveValues;
74  wxTextCtrl* m_CommandStringCtrl;
75  wxTextCtrl* m_TitleStringCtrl;
76  wxBoxSizer* m_LeftBoxSizer;
77  wxBoxSizer* m_RightBoxSizer;
79  wxBoxSizer* m_LowBoxSizer;
80 
81 private:
82  wxString m_pageNetFmtName;
83 
84 public:
91  NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& title,
92  NETLIST_TYPE_ID id_NetType );
94 
100  const wxString GetPageNetFmtName() { return m_pageNetFmtName; }
101 };
102 
103 
104 /* Dialog frame for creating netlists */
106 {
107  friend class NETLIST_PAGE_DIALOG;
108 
109 public:
113 
114 protected:
116  wxConfigBase* m_config;
117 
118 public:
119  // Constructor and destructor
120  NETLIST_DIALOG( SCH_EDIT_FRAME* parent );
122 
123 private:
124  void InstallCustomPages();
125  NETLIST_PAGE_DIALOG* AddOneCustomPage( const wxString & aTitle,
126  const wxString & aCommandString,
127  NETLIST_TYPE_ID aNetTypeId );
128  void InstallPageSpice();
129  bool TransferDataFromWindow() override;
130  void NetlistUpdateOpt();
131 
132  // Called when changing the notebook page (and therefore the current netlist format)
133  void OnNetlistTypeSelection( wxNotebookEvent& event ) override;
134 
135  // called when checking the "Default format" wxCheckBox in the current page of the notbook
136  void SelectDefaultNetlistType( wxCommandEvent& event );
137 
142  void OnAddGenerator( wxCommandEvent& event ) override;
143 
148  void OnDelGenerator( wxCommandEvent& event ) override;
149 
155 
164  const wxString UserNetlistTypeName( bool first_item );
165 
175  bool FilenamePrms( NETLIST_TYPE_ID aType,
176  wxString * aExt, wxString * aWildCard );
177 
178  DECLARE_EVENT_TABLE()
179 };
180 
181 
183 {
184 private:
186 
187 public:
189 
190  const wxString GetGeneratorTitle() { return m_textCtrlName->GetValue(); }
191  const wxString GetGeneratorTCommandLine() { return m_textCtrlCommand->GetValue(); }
192 
193 private:
198  void OnOKClick( wxCommandEvent& event ) override;
199 
200  /*
201  * Browse plugin files, and set m_CommandStringCtrl field
202  */
203  void OnBrowseGenerators( wxCommandEvent& event ) override;
204 };
205 
206 
207 /* Event id for notebook page buttons: */
213 };
214 
215 
216 // keywords for configuration:
217 #define CUSTOM_NETLIST_TITLE wxT( "CustomNetlistTitle" )
218 #define CUSTOM_NETLIST_COMMAND wxT( "CustomNetlistCommand" )
219 #define NETLIST_USE_DEFAULT_NETNAME wxT( "NetlistUseDefaultNetname" )
220 #define NETLIST_PSPICE_USE_NETNAME wxT( "SpiceUseNetNames" )
221 
222 
223 BEGIN_EVENT_TABLE( NETLIST_DIALOG, NETLIST_DIALOG_BASE )
225 END_EVENT_TABLE()
226 
227 
228 
230  const wxString& title,
231  NETLIST_TYPE_ID id_NetType ) :
232  wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL )
233 {
234  m_IdNetType = id_NetType;
235  m_pageNetFmtName = title;
236  m_CommandStringCtrl = NULL;
237  m_TitleStringCtrl = NULL;
238  m_IsCurrentFormat = NULL;
239  m_AdjustPassiveValues = NULL;
240 
241  wxString netfmtName = ((NETLIST_DIALOG*)parent->GetParent())->m_DefaultNetFmtName;
242 
243  bool selected = m_pageNetFmtName == netfmtName;
244 
245  parent->AddPage( this, title, selected );
246 
247  wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxVERTICAL );
248  SetSizer( MainBoxSizer );
249  wxBoxSizer* UpperBoxSizer = new wxBoxSizer( wxHORIZONTAL );
250  m_LowBoxSizer = new wxBoxSizer( wxVERTICAL );
251  MainBoxSizer->Add( UpperBoxSizer, 0, wxGROW | wxALL, 5 );
252  MainBoxSizer->Add( m_LowBoxSizer, 0, wxGROW | wxALL, 5 );
253 
254  m_LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
255  m_RightBoxSizer = new wxBoxSizer( wxVERTICAL );
256  m_RightOptionsBoxSizer = new wxBoxSizer( wxVERTICAL );
257  UpperBoxSizer->Add( m_LeftBoxSizer, 0, wxGROW | wxALL, 5 );
258  UpperBoxSizer->Add( m_RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
259  UpperBoxSizer->Add( m_RightOptionsBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
260 
261  wxStaticText* text = new wxStaticText( this, -1, _( "Options:" ) );
262  m_LeftBoxSizer->Add( text, 0, wxGROW | wxBOTTOM | wxRIGHT, 5 );
263 
264  m_IsCurrentFormat = new wxCheckBox( this, ID_CURRENT_FORMAT_IS_DEFAULT, _( "Default format" ) );
265  m_LeftBoxSizer->Add( m_IsCurrentFormat, 0, wxGROW | wxBOTTOM | wxRIGHT, 5 );
266  m_IsCurrentFormat->SetValue( selected );
267 
268  if( selected )
269  ((NETLIST_DIALOG*)parent->GetParent())->m_asFormatSelected = true;
270 }
271 
272 
273 
275  NETLIST_DIALOG_BASE( parent )
276 {
277  m_Parent = parent;
279 
280  long tmp;
281  m_config->Read( NETLIST_USE_DEFAULT_NETNAME, &tmp, 0l );
283 
284  for( NETLIST_PAGE_DIALOG*& page : m_PanelNetType)
285  page = NULL;
286 
287  // Add notebook pages:
288  m_asFormatSelected = false; // Will be set to true, if a format is selected
289 
290  m_PanelNetType[PANELPCBNEW] = new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "Pcbnew" ),
291  NET_TYPE_PCBNEW );
292 
293  m_PanelNetType[PANELORCADPCB2] = new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "OrcadPCB2" ),
295 
296  m_PanelNetType[PANELCADSTAR] = new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "CadStar" ),
298 
301 
302  // Ensure a netlist format is selected:
303  if( !m_asFormatSelected )
304  {
305  m_PanelNetType[PANELPCBNEW]->m_IsCurrentFormat->SetValue( true );
306  m_NoteBook->SetSelection( PANELPCBNEW );
308  // call OnNetlistTypeSelection to update some widgets.
309  // SetSelection() do nothing if the current page is already PANELPCBNEW
310  wxNotebookEvent event;
311  OnNetlistTypeSelection( event );
312  }
313 
314  // We use a sdbSizer here to get the order right, which is platform-dependent
315  m_sdbSizer2OK->SetLabel( _( "Export Netlist" ) );
316  m_sdbSizer2Cancel->SetLabel( _( "Close" ) );
317  m_buttonSizer->Layout();
318 
319  m_sdbSizer2OK->SetDefault();
320 
321  // Now all widgets have the size fixed, call FinishDialogSettings
323 }
324 
325 
326 const wxString NETLIST_DIALOG::UserNetlistTypeName( bool first_item )
327 {
328  static int index;
329 
330  if( first_item )
331  index = 0;
332  else
333  index++;
334 
335  wxString msg = CUSTOM_NETLIST_TITLE;
336  msg << index + 1;
337 
338  return m_config->Read( msg );
339 }
340 
341 
343 {
345  new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "Spice" ), NET_TYPE_SPICE );
346 
347  page->m_AdjustPassiveValues = new wxCheckBox( page, ID_USE_NETCODE_AS_NETNAME,
348  _( "Reformat passive symbol values" ) );
349  page->m_AdjustPassiveValues->SetToolTip( _( "Reformat passive symbol values e.g. 1M -> 1Meg" ) );
351  page->m_LeftBoxSizer->Add( page->m_AdjustPassiveValues, 0, wxGROW | wxBOTTOM | wxRIGHT, 5 );
352 }
353 
354 
356 {
357  int ii;
358  wxString title;
359  NETLIST_PAGE_DIALOG* currPage;
360 
361  for( ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ )
362  {
363  title = UserNetlistTypeName( ii == 0 ? true : false );
364 
365  if( title.IsEmpty() )
366  break; // No more panel to install
367 
368  // Install a plugin panel
369  wxString msg = CUSTOM_NETLIST_COMMAND;
370  msg << ii + 1;
371  wxString command = m_config->Read( msg );
372 
373  currPage = AddOneCustomPage( title, command, (NETLIST_TYPE_ID)(NET_TYPE_CUSTOM1 + ii) );
374  m_PanelNetType[PANELCUSTOMBASE + ii] = currPage;
375  }
376 }
377 
378 
380  const wxString & aCommandString,
381  NETLIST_TYPE_ID aNetTypeId )
382 {
383  NETLIST_PAGE_DIALOG* currPage = new NETLIST_PAGE_DIALOG( m_NoteBook, aTitle, aNetTypeId );
384 
385  currPage->m_LowBoxSizer->Add( new wxStaticText( currPage, -1, _( "Title:" ) ), 0,
386  wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
387 
388  currPage->m_TitleStringCtrl = new wxTextCtrl( currPage, -1, aTitle,
389  wxDefaultPosition, wxDefaultSize );
390 
391  currPage->m_TitleStringCtrl->SetInsertionPoint( 1 );
392  currPage->m_LowBoxSizer->Add( currPage->m_TitleStringCtrl, 0,
393  wxGROW | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
394 
395  currPage->m_LowBoxSizer->Add( new wxStaticText( currPage, -1, _( "Netlist command:" ) ), 0,
396  wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
397 
398  currPage->m_CommandStringCtrl = new wxTextCtrl( currPage, -1, aCommandString,
399  wxDefaultPosition, wxDefaultSize );
400 
401  currPage->m_CommandStringCtrl->SetInsertionPoint( 1 );
402  currPage->m_LowBoxSizer->Add( currPage->m_CommandStringCtrl, 0,
403  wxGROW | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
404 
405  return currPage;
406 }
407 
408 
409 void NETLIST_DIALOG::SelectDefaultNetlistType( wxCommandEvent& event )
410 {
411  for( NETLIST_PAGE_DIALOG*& page : m_PanelNetType)
412  {
413  if( page )
414  page->m_IsCurrentFormat->SetValue( false );
415  }
416 
417  NETLIST_PAGE_DIALOG* currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
418 
419  if( currPage == NULL )
420  return;
421 
424  currPage->m_IsCurrentFormat->SetValue( true );
425 }
426 
427 
428 void NETLIST_DIALOG::OnNetlistTypeSelection( wxNotebookEvent& event )
429 {
430  NETLIST_PAGE_DIALOG* currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
431 
432  if( currPage == NULL )
433  return;
434 
435  m_buttonDelGenerator->Enable( currPage->m_IdNetType >= NET_TYPE_CUSTOM1 );
436 }
437 
438 
440 {
441  bool adjust = m_PanelNetType[ PANELSPICE ]->m_AdjustPassiveValues->IsChecked();
442 
444  m_Parent->SetNetListFormatName( wxEmptyString );
445 
446  for( NETLIST_PAGE_DIALOG*& page : m_PanelNetType)
447  {
448  if( page == NULL )
449  break;
450 
451  if( page->m_IsCurrentFormat->GetValue() == true )
452  m_Parent->SetNetListFormatName( page->GetPageNetFmtName() );
453  }
454 }
455 
456 
458 {
459  wxFileName fn;
460  wxString fileWildcard;
461  wxString fileExt;
462  wxString title = _( "Save Netlist File" );
463 
465 
466  NETLIST_PAGE_DIALOG* currPage;
467  currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
468 
469  unsigned netlist_opt = 0;
470 
471  // Calculate the netlist filename
472  fn = g_RootSheet->GetScreen()->GetFileName();
473  FilenamePrms( currPage->m_IdNetType, &fileExt, &fileWildcard );
474 
475  // Set some parameters
476  switch( currPage->m_IdNetType )
477  {
478  case NET_TYPE_SPICE:
479  // Set spice netlist options:
480  if( currPage->m_AdjustPassiveValues->GetValue() )
481  netlist_opt |= NET_ADJUST_PASSIVE_VALS;
482  break;
483 
484  case NET_TYPE_CADSTAR:
485  break;
486 
487  case NET_TYPE_PCBNEW:
488  break;
489 
490  case NET_TYPE_ORCADPCB2:
491  break;
492 
493  default: // custom, NET_TYPE_CUSTOM1 and greater
494  {
495  wxString command = currPage->m_CommandStringCtrl->GetValue();
496  wxRegEx extRE( wxT( ".*\\.([[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]]?)\\.xslt?\".*" ) );
497 
498  if( extRE.Matches( command ) )
499  fileExt = extRE.GetMatch( command, 1 );
500 
501  title.Printf( _( "%s Export" ), currPage->m_TitleStringCtrl->GetValue().GetData() );
502  }
503  break;
504  }
505 
506  fn.SetExt( fileExt );
507 
508  if( fn.GetPath().IsEmpty() )
509  fn.SetPath( wxPathOnly( Prj().GetProjectFullName() ) );
510 
511  wxString fullpath = fn.GetFullPath();
512  wxString fullname = fn.GetFullName();
513  wxString path = fn.GetPath();
514 
515  // fullname does not and should not include the path, per wx docs.
516  wxFileDialog dlg( this, title, path, fullname, fileWildcard, wxFD_SAVE );
517 
518  if( dlg.ShowModal() == wxID_CANCEL )
519  return false;
520 
521  fullpath = dlg.GetPath(); // directory + filename
522 
524 
525  if( currPage->m_CommandStringCtrl )
526  m_Parent->SetNetListerCommand( currPage->m_CommandStringCtrl->GetValue() );
527  else
528  m_Parent->SetNetListerCommand( wxEmptyString );
529 
530  auto netlist = m_Parent->CreateNetlist( false, false );
531 
532  if( netlist == nullptr )
533  wxMessageBox( _( "Schematic netlist not available" ) );
534  else
535  m_Parent->WriteNetListFile( netlist, currPage->m_IdNetType, fullpath, netlist_opt, NULL );
536 
538 
539  return true;
540 }
541 
542 
543 bool NETLIST_DIALOG::FilenamePrms( NETLIST_TYPE_ID aType, wxString * aExt, wxString * aWildCard )
544 {
545  wxString fileExt;
546  wxString fileWildcard;
547  bool ret = true;
548 
549  switch( aType )
550  {
551  case NET_TYPE_SPICE:
552  fileExt = wxT( "cir" );
553  fileWildcard = SpiceNetlistFileWildcard();
554  break;
555 
556  case NET_TYPE_CADSTAR:
557  fileExt = wxT( "frp" );
558  fileWildcard = CadstarNetlistFileWildcard();
559  break;
560 
561  case NET_TYPE_PCBNEW:
562  case NET_TYPE_ORCADPCB2:
563  fileExt = NetlistFileExtension;
564  fileWildcard = NetlistFileWildcard();
565  break;
566 
567  default: // custom, NET_TYPE_CUSTOM1 and greater
568  fileWildcard = AllFilesWildcard();
569  ret = false;
570  }
571 
572  if( aExt )
573  *aExt = fileExt;
574 
575  if( aWildCard )
576  *aWildCard = fileWildcard;
577 
578  return ret;
579 }
580 
581 
583 {
584  wxString msg;
585 
587 
588  // Update existing custom pages
589  int jj = 0;
590  for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ )
591  {
593 
594  if( currPage == NULL )
595  break;
596 
597  wxString title = currPage->m_TitleStringCtrl->GetValue();
598 
599  if( title.IsEmpty() )
600  continue;
601 
602  msg = CUSTOM_NETLIST_TITLE;
603  msg << jj + 1;
604  m_config->Write( msg, title );
605 
606  wxString Command = currPage->m_CommandStringCtrl->GetValue();
608  msg << jj + 1;
609  m_config->Write( msg, Command );
610  jj++;
611  }
612 
613  // Ensure all other pages are void
614  for( ; jj < CUSTOMPANEL_COUNTMAX; jj++ )
615  {
616  msg = CUSTOM_NETLIST_TITLE;
617  msg << jj + 1;
618  m_config->Write( msg, wxEmptyString );
619 
621  msg << jj + 1;
622  m_config->Write( msg, wxEmptyString );
623  }
624 }
625 
626 
627 void NETLIST_DIALOG::OnDelGenerator( wxCommandEvent& event )
628 {
629  NETLIST_PAGE_DIALOG* currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
630 
631  currPage->m_CommandStringCtrl->SetValue( wxEmptyString );
632  currPage->m_TitleStringCtrl->SetValue( wxEmptyString );
633 
634  if( currPage->m_IsCurrentFormat->IsChecked() )
635  {
636  currPage->m_IsCurrentFormat->SetValue( false );
637  m_PanelNetType[PANELPCBNEW]->m_IsCurrentFormat->SetValue( true );
638  }
639 
641  EndModal( NET_PLUGIN_CHANGE );
642 }
643 
644 
645 void NETLIST_DIALOG::OnAddGenerator( wxCommandEvent& event )
646 {
647  NETLIST_DIALOG_ADD_GENERATOR dlg( this );
648 
649  if( dlg.ShowModal() != wxID_OK )
650  return;
651 
652  // Creates a new custom plugin page
653  wxString title = dlg.GetGeneratorTitle();
654 
655  // Verify it does not exists
656  int netTypeId = PANELCUSTOMBASE; // the first not used type id
657  NETLIST_PAGE_DIALOG* currPage;
658 
659  for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ )
660  {
661  netTypeId = PANELCUSTOMBASE + ii;
662  currPage = m_PanelNetType[ii + PANELCUSTOMBASE];
663 
664  if( currPage == NULL )
665  break;
666 
667  if( currPage->GetPageNetFmtName() == title )
668  {
669  wxMessageBox( _("This plugin already exists.") );
670  return;
671  }
672  }
673 
674  wxString cmd = dlg.GetGeneratorTCommandLine();
675  currPage = AddOneCustomPage( title,cmd, (NETLIST_TYPE_ID)netTypeId );
676  m_PanelNetType[netTypeId] = currPage;
678 
679  // Close and reopen dialog to rebuild the dialog after changes
680  EndModal( NET_PLUGIN_CHANGE );
681 }
682 
683 
686 {
687  m_Parent = parent;
688  m_sdbSizerOK->SetDefault();
689  GetSizer()->SetSizeHints( this );
690 }
691 
692 
693 void NETLIST_DIALOG_ADD_GENERATOR::OnOKClick( wxCommandEvent& event )
694 {
695  if( m_textCtrlCommand->GetValue() == wxEmptyString )
696  {
697  wxMessageBox( _( "Error. You must provide a command String" ) );
698  return;
699  }
700 
701  if( m_textCtrlName->GetValue() == wxEmptyString )
702  {
703  wxMessageBox( _( "Error. You must provide a Title" ) );
704  return;
705  }
706 
707  EndModal( wxID_OK );
708 }
709 
710 
712 {
713  wxString FullFileName, Path;
714 
715 #ifndef __WXMAC__
716  Path = Pgm().GetExecutablePath();
717 #else
718  Path = GetOSXKicadDataDir() + wxT( "/plugins" );
719 #endif
720  FullFileName = EDA_FILE_SELECTOR( _( "Generator files:" ), Path, FullFileName,
721  wxEmptyString, wxFileSelectorDefaultWildcardStr,
722  this, wxFD_OPEN, true );
723  if( FullFileName.IsEmpty() )
724  return;
725 
726  // Creates a default command line, suitable for external tool xslproc or python, based on
727  // the plugin extension ("xsl" or "exe" or "py")
728  wxString cmdLine;
729  wxFileName fn( FullFileName );
730  wxString ext = fn.GetExt();
731 
732  if( ext == wxT("xsl" ) )
733  cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), GetChars(FullFileName) );
734  else if( ext == wxT("exe" ) || ext.IsEmpty() )
735  cmdLine.Printf(wxT("\"%s\" > \"%%O\" < \"%%I\""), GetChars(FullFileName) );
736  else if( ext == wxT("py" ) || ext.IsEmpty() )
737  cmdLine.Printf(wxT("python \"%s\" \"%%I\" \"%%O\""), GetChars(FullFileName) );
738  else
739  cmdLine.Printf(wxT("\"%s\""), GetChars(FullFileName) );
740 
741  m_textCtrlCommand->SetValue( cmdLine );
742 
743  /* Get a title for this page */
744  wxString title = m_textCtrlName->GetValue();
745 
746  if( title.IsEmpty() )
747  wxMessageBox( _( "Do not forget to choose a title for this netlist control page" ) );
748 }
749 
750 
752 {
753  NETLIST_DIALOG dlg( aCaller );
754 
755  wxString curr_default_netformat = aCaller->GetNetListFormatName();
756 
757  int ret = dlg.ShowModal();
758 
759  // Update the default netlist and store it in prj config if it was explicitely changed.
760  aCaller->SetNetListFormatName( dlg.m_DefaultNetFmtName ); // can have temporary changed
761 
762  if( curr_default_netformat != dlg.m_DefaultNetFmtName )
763  aCaller->SaveProjectSettings( false );
764 
765  return ret;
766 }
const std::string NetlistFileExtension
void OnDelGenerator(wxCommandEvent &event) override
Function OnDelGenerator Remove a panel relative to a netlist plugin.
const wxString & GetFileName() const
Definition: sch_screen.h:123
This file is part of the common library TODO brief description.
bool FilenamePrms(NETLIST_TYPE_ID aType, wxString *aExt, wxString *aWildCard)
Function FilenamePrms returns the filename extension and the wildcard string for this curr or a void ...
NETLIST_PAGE_DIALOG(wxNotebook *parent, const wxString &title, NETLIST_TYPE_ID id_NetType)
Constructor to create a setup page for one netlist format.
wxString SpiceNetlistFileWildcard()
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...
const wxString & GetNetListFormatName() const
void OnOKClick(wxCommandEvent &event) override
Function OnOKClick Validate info relative to a new netlist plugin.
void OnAddGenerator(wxCommandEvent &event) override
Function OnAddGenerator Add a new panel for a new netlist plugin.
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
Schematic editor (Eeschema) main window.
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:281
void SetSpiceAdjustPassiveValues(bool aEnable)
wxString AllFilesWildcard()
#define CUSTOM_NETLIST_COMMAND
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
void SaveProjectSettings(bool aAskForSave) override
Save changes to the project settings to the project (.pro) file.
NETLIST_TYPE_ID
netlist types
Definition: netlist.h:35
#define NETLIST_USE_DEFAULT_NETNAME
Class NETLIST_DIALOG_ADD_GENERATOR_BASE.
void WriteCurrentNetlistSetup()
Function WriteCurrentNetlistSetup Write the current netlist options setup in the configuration.
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:47
NETLIST_DIALOG(SCH_EDIT_FRAME *parent)
#define CUSTOMPANEL_COUNTMAX
wxString NetlistFileWildcard()
PROJECT & Prj() const
Function Prj returns 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)
Function EDA_FILE_SELECTOR.
Definition: gestfich.cpp:52
Definition of file extensions used in Kicad.
const wxString UserNetlistTypeName(bool first_item)
Function UserNetlistTypeName to retrieve user netlist type names.
#define CUSTOM_NETLIST_TITLE
void OnBrowseGenerators(wxCommandEvent &event) override
virtual void ClearMsgPanel()
Clear all messages from the message panel.
#define _(s)
NETLIST_PAGE_DIALOG * m_PanelNetType[4+CUSTOMPANEL_COUNTMAX]
NETLIST_PAGE_DIALOG * AddOneCustomPage(const wxString &aTitle, const wxString &aCommandString, NETLIST_TYPE_ID aNetTypeId)
void SetNetListFormatName(const wxString &aFormat)
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:101
see class PGM_BASE
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:222
#define NET_PLUGIN_CHANGE
Create and shows NETLIST_DIALOG and returns whatever NETLIST_DIALOG::ShowModal() returns.
bool GetSpiceAjustPassiveValues() const
bool WriteNetListFile(NETLIST_OBJECT_LIST *aConnectedItemsList, int aFormat, const wxString &aFullFileName, unsigned aNetlistOptions, REPORTER *aReporter=NULL)
Create a netlist file.
void SetNetListerCommand(const wxString &aCommand)
void OnNetlistTypeSelection(wxNotebookEvent &event) override
const wxString GetPageNetFmtName()
function GetPageNetFmtName
int InvokeDialogNetList(SCH_EDIT_FRAME *aCaller)
void SelectDefaultNetlistType(wxCommandEvent &event)
wxString CadstarNetlistFileWildcard()