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-2021 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 <pgm_base.h>
37 #include <kiface_i.h>
38 #include <gestfich.h>
39 #include <sch_edit_frame.h>
40 #include <general.h>
41 #include <netlist.h>
42 #include <dialogs/dialog_netlist_base.h>
44 #include <invoke_sch_dialog.h>
46 #include <eeschema_settings.h>
47 #include <schematic.h>
48 #include <paths.h>
49 
50 #include <eeschema_id.h>
51 #include <wx/regex.h>
52 #include <wx/filedlg.h>
53 #include <wx/msgdlg.h>
54 
55 
56 
57 #define CUSTOMPANEL_COUNTMAX 8 // Max number of netlist plugins
58 
59 
60 /* panel (notebook page) identifiers */
62  PANELPCBNEW = 0, /* Handle Netlist format Pcbnew */
63  PANELORCADPCB2, /* Handle Netlist format OracdPcb2 */
64  PANELCADSTAR, /* Handle Netlist format CadStar */
65  PANELSPICE, /* Handle Netlist format Pspice */
66  PANELCUSTOMBASE /* First auxiliary panel (custom netlists).
67  * others use PANELCUSTOMBASE+1, PANELCUSTOMBASE+2.. */
68 };
69 
70 
71 /* wxPanels for creating the NoteBook pages for each netlist format: */
72 class NETLIST_PAGE_DIALOG : public wxPanel
73 {
74 
75 public:
85  NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& title,
86  NETLIST_TYPE_ID id_NetType );
88 
92  const wxString GetPageNetFmtName() { return m_pageNetFmtName; }
93 
95  // opt to reformat passive component values (e.g. 1M -> 1Meg):
96  wxCheckBox* m_AdjustPassiveValues;
97  wxTextCtrl* m_CommandStringCtrl;
98  wxTextCtrl* m_TitleStringCtrl;
99  wxBoxSizer* m_LeftBoxSizer;
100  wxBoxSizer* m_RightBoxSizer;
102  wxBoxSizer* m_LowBoxSizer;
103 
104 private:
106 };
107 
108 
109 /* Dialog frame for creating netlists */
111 {
112 public:
113  NETLIST_DIALOG( SCH_EDIT_FRAME* parent );
115 
116 private:
117  friend class NETLIST_PAGE_DIALOG;
118 
119  void InstallCustomPages();
120  NETLIST_PAGE_DIALOG* AddOneCustomPage( const wxString & aTitle,
121  const wxString & aCommandString,
122  NETLIST_TYPE_ID aNetTypeId );
123  void InstallPageSpice();
124  bool TransferDataFromWindow() override;
125  void NetlistUpdateOpt();
126 
127  // Called when changing the notebook page (and therefore the current netlist format)
128  void OnNetlistTypeSelection( wxNotebookEvent& event ) override;
129 
133  void OnAddGenerator( wxCommandEvent& event ) override;
134 
138  void OnDelGenerator( wxCommandEvent& event ) override;
139 
143  void OnRunExternSpiceCommand( wxCommandEvent& event );
144 
148  void OnRunSpiceButtUI( wxUpdateUIEvent& event );
149 
154 
164  bool FilenamePrms( NETLIST_TYPE_ID aType, wxString* aExt, wxString* aWildCard );
165 
167 
168 public:
172 };
173 
174 
176 {
177 public:
179 
180  const wxString GetGeneratorTitle() { return m_textCtrlName->GetValue(); }
181  const wxString GetGeneratorTCommandLine() { return m_textCtrlCommand->GetValue(); }
182 
183 private:
187  void OnOKClick( wxCommandEvent& event ) override;
188 
189  /*
190  * Browse plugin files, and set m_CommandStringCtrl field
191  */
192  void OnBrowseGenerators( wxCommandEvent& event ) override;
193 
195 };
196 
197 
198 /* Event id for notebook page buttons: */
203 };
204 
205 
206 BEGIN_EVENT_TABLE( NETLIST_DIALOG, NETLIST_DIALOG_BASE )
209 END_EVENT_TABLE()
210 
211 
212 
213 NETLIST_PAGE_DIALOG::NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& title,
214  NETLIST_TYPE_ID id_NetType ) :
215  wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL )
216 {
217  m_IdNetType = id_NetType;
218  m_pageNetFmtName = title;
222 
223  wxString netfmtName = static_cast<NETLIST_DIALOG*>( parent->GetParent() )->m_DefaultNetFmtName;
224 
225  bool selected = m_pageNetFmtName == netfmtName;
226 
227  parent->AddPage( this, title, selected );
228 
229  wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxVERTICAL );
230  SetSizer( MainBoxSizer );
231  wxBoxSizer* UpperBoxSizer = new wxBoxSizer( wxHORIZONTAL );
232  m_LowBoxSizer = new wxBoxSizer( wxVERTICAL );
233  MainBoxSizer->Add( UpperBoxSizer, 0, wxGROW | wxALL, 5 );
234  MainBoxSizer->Add( m_LowBoxSizer, 0, wxGROW | wxALL, 5 );
235 
236  m_LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
237  m_RightBoxSizer = new wxBoxSizer( wxVERTICAL );
238  m_RightOptionsBoxSizer = new wxBoxSizer( wxVERTICAL );
239  UpperBoxSizer->Add( m_LeftBoxSizer, 0, wxGROW | wxALL, 5 );
240  UpperBoxSizer->Add( m_RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
241  UpperBoxSizer->Add( m_RightOptionsBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
242 }
243 
244 
245 
247  NETLIST_DIALOG_BASE( parent )
248 {
249  m_Parent = parent;
250 
252 
254 
255  for( NETLIST_PAGE_DIALOG*& page : m_PanelNetType)
256  page = NULL;
257 
258  // Add notebook pages:
260  NET_TYPE_PCBNEW );
261 
262  m_PanelNetType[PANELORCADPCB2] = new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "OrcadPCB2" ),
264 
265  m_PanelNetType[PANELCADSTAR] = new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "CadStar" ),
267 
270 
271  // We use a sdbSizer here to get the order right, which is platform-dependent
272  m_sdbSizer2OK->SetLabel( _( "Export Netlist" ) );
273  m_sdbSizer2Cancel->SetLabel( _( "Close" ) );
274  m_buttonSizer->Layout();
275 
276  m_sdbSizer2OK->SetDefault();
277 
278  // Now all widgets have the size fixed, call FinishDialogSettings
280 }
281 
282 
283 void NETLIST_DIALOG::OnRunExternSpiceCommand( wxCommandEvent& event )
284 {
285  // Run the external spice simulator command
287 
289  wxString simulatorCommand = settings.m_SpiceCommandString;
290 
291  unsigned netlist_opt = 0;
292 
293  // Calculate the netlist filename and options
294  wxFileName fn = m_Parent->Schematic().GetFileName();
295  fn.SetExt( wxT( "cir" ) );
296 
297  if( settings.m_SpiceAdjustPassiveValues )
298  netlist_opt |= NET_ADJUST_PASSIVE_VALS;
299 
300  // Build the command line
301  wxString commandLine = simulatorCommand;
302  commandLine.Replace( "%I", fn.GetFullPath(), true );
303 
304  if( m_Parent->ReadyToNetlist( _( "Simulator requires a fully annotated schematic." ) ) )
305  {
306  m_Parent->WriteNetListFile( NET_TYPE_SPICE, fn.GetFullPath(), netlist_opt, nullptr );
307  wxExecute( commandLine, wxEXEC_ASYNC );
308  }
309 }
310 
311 
312 void NETLIST_DIALOG::OnRunSpiceButtUI( wxUpdateUIEvent& aEvent )
313 {
314  bool disable = m_PanelNetType[PANELSPICE]->m_CommandStringCtrl->IsEmpty();
315  aEvent.Enable( !disable );
316 }
317 
318 
320 {
322  new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "Spice" ), NET_TYPE_SPICE );
323 
325 
326  page->m_AdjustPassiveValues = new wxCheckBox( page, ID_USE_NETCODE_AS_NETNAME,
327  _( "Reformat passive symbol values" ) );
328  page->m_AdjustPassiveValues->SetToolTip( _( "Reformat passive symbol values e.g. 1M -> 1Meg" ) );
329  page->m_AdjustPassiveValues->SetValue( settings.m_SpiceAdjustPassiveValues );
330  page->m_LeftBoxSizer->Add( page->m_AdjustPassiveValues, 0, wxGROW | wxBOTTOM | wxRIGHT, 5 );
331 
332  wxString simulatorCommand = settings.m_SpiceCommandString;
333  wxStaticText* spice_label = new wxStaticText( page, -1, _( "External simulator command:" ) );
334  spice_label->SetToolTip( _( "Enter the command line to run spice\n"
335  "Usually <path to spice binary> %I\n"
336  "%I will be replaced by the actual spice netlist name") );
337  page->m_LowBoxSizer->Add( spice_label, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
338 
339  page->m_CommandStringCtrl = new wxTextCtrl( page, -1, simulatorCommand,
340  wxDefaultPosition, wxDefaultSize );
341 
342  page->m_CommandStringCtrl->SetInsertionPoint( 1 );
343  page->m_LowBoxSizer->Add( page->m_CommandStringCtrl, 0,
344  wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
345 
346  // Add button to run spice command
347  wxButton* button = new wxButton( page, ID_RUN_SIMULATOR,
348  _( "Create Netlist and Run Simulator Command" ) );
349  page->m_LowBoxSizer->Add( button, 0, wxGROW | wxBOTTOM | wxLEFT | wxRIGHT, 5 );
350 }
351 
352 
354 {
355  NETLIST_PAGE_DIALOG* currPage;
356 
357  auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
358  wxASSERT( cfg );
359 
360  if( cfg )
361  {
362  for( size_t i = 0;
363  i < CUSTOMPANEL_COUNTMAX && i < cfg->m_NetlistPanel.custom_command_titles.size();
364  i++ )
365  {
366  // pairs of (title, command) are stored
367  wxString title = cfg->m_NetlistPanel.custom_command_titles[i];
368 
369  if( i >= cfg->m_NetlistPanel.custom_command_paths.size() )
370  break; // No more panel to install
371 
372  wxString command = cfg->m_NetlistPanel.custom_command_paths[i];
373 
374  currPage = AddOneCustomPage( title, command,
375  static_cast<NETLIST_TYPE_ID>( NET_TYPE_CUSTOM1 + i ) );
376 
377  m_PanelNetType[PANELCUSTOMBASE + i] = currPage;
378  }
379  }
380 }
381 
382 
384  const wxString & aCommandString,
385  NETLIST_TYPE_ID aNetTypeId )
386 {
387  NETLIST_PAGE_DIALOG* currPage = new NETLIST_PAGE_DIALOG( m_NoteBook, aTitle, aNetTypeId );
388 
389  currPage->m_LowBoxSizer->Add( new wxStaticText( currPage, -1, _( "Title:" ) ), 0,
390  wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
391 
392  currPage->m_TitleStringCtrl = new wxTextCtrl( currPage, -1, aTitle,
393  wxDefaultPosition, wxDefaultSize );
394 
395  currPage->m_TitleStringCtrl->SetInsertionPoint( 1 );
396  currPage->m_LowBoxSizer->Add( currPage->m_TitleStringCtrl, 0,
397  wxGROW | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
398 
399  currPage->m_LowBoxSizer->Add( new wxStaticText( currPage, -1, _( "Netlist command:" ) ), 0,
400  wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
401 
402  currPage->m_CommandStringCtrl = new wxTextCtrl( currPage, -1, aCommandString,
403  wxDefaultPosition, wxDefaultSize );
404 
405  currPage->m_CommandStringCtrl->SetInsertionPoint( 1 );
406  currPage->m_LowBoxSizer->Add( currPage->m_CommandStringCtrl, 0,
407  wxGROW | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
408 
409  return currPage;
410 }
411 
412 
413 void NETLIST_DIALOG::OnNetlistTypeSelection( wxNotebookEvent& event )
414 {
415  NETLIST_PAGE_DIALOG* currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
416 
417  if( currPage == NULL )
418  return;
419 
421 
422  m_buttonDelGenerator->Enable( currPage->m_IdNetType >= NET_TYPE_CUSTOM1 );
423 }
424 
425 
427 {
428  bool adjust = m_PanelNetType[ PANELSPICE ]->m_AdjustPassiveValues->IsChecked();
429  wxString spice_cmd_string = m_PanelNetType[ PANELSPICE ]->m_CommandStringCtrl->GetValue();
430 
432 
433  settings.m_SpiceAdjustPassiveValues = adjust;
434  settings.m_SpiceCommandString = spice_cmd_string;
435  settings.m_NetFormatName = wxEmptyString;
437 }
438 
439 
441 {
442  wxFileName fn;
443  wxString fileWildcard;
444  wxString fileExt;
445  wxString title = _( "Save Netlist File" );
446 
448 
449  NETLIST_PAGE_DIALOG* currPage;
450  currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
451 
452  unsigned netlist_opt = 0;
453 
454  // Calculate the netlist filename
455  fn = m_Parent->Schematic().GetFileName();
456  FilenamePrms( currPage->m_IdNetType, &fileExt, &fileWildcard );
457 
458  // Set some parameters
459  switch( currPage->m_IdNetType )
460  {
461  case NET_TYPE_SPICE:
462  // Set spice netlist options:
463  if( currPage->m_AdjustPassiveValues->GetValue() )
464  netlist_opt |= NET_ADJUST_PASSIVE_VALS;
465  break;
466 
467  case NET_TYPE_CADSTAR:
468  break;
469 
470  case NET_TYPE_PCBNEW:
471  break;
472 
473  case NET_TYPE_ORCADPCB2:
474  break;
475 
476  default: // custom, NET_TYPE_CUSTOM1 and greater
477  {
478  wxString command = currPage->m_CommandStringCtrl->GetValue();
479  wxRegEx extRE( wxT( ".*\\.([[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]]?)\\.xslt?\".*" ) );
480 
481  if( extRE.Matches( command ) )
482  fileExt = extRE.GetMatch( command, 1 );
483 
484  title.Printf( _( "%s Export" ), currPage->m_TitleStringCtrl->GetValue().GetData() );
485  }
486  break;
487  }
488 
489  fn.SetExt( fileExt );
490 
491  if( fn.GetPath().IsEmpty() )
492  fn.SetPath( wxPathOnly( Prj().GetProjectFullName() ) );
493 
494  wxString fullpath = fn.GetFullPath();
495  wxString fullname = fn.GetFullName();
496  wxString path = fn.GetPath();
497 
498  // fullname does not and should not include the path, per wx docs.
499  wxFileDialog dlg( this, title, path, fullname, fileWildcard, wxFD_SAVE );
500 
501  if( dlg.ShowModal() == wxID_CANCEL )
502  return false;
503 
504  fullpath = dlg.GetPath(); // directory + filename
505 
507 
508  if( currPage->m_CommandStringCtrl )
509  m_Parent->SetNetListerCommand( currPage->m_CommandStringCtrl->GetValue() );
510  else
511  m_Parent->SetNetListerCommand( wxEmptyString );
512 
513  if( m_Parent->ReadyToNetlist( _( "Exporting netlist requires a fully annotated schematic." ) ) )
514  m_Parent->WriteNetListFile( currPage->m_IdNetType, fullpath, netlist_opt, nullptr );
515 
517 
518  return true;
519 }
520 
521 
522 bool NETLIST_DIALOG::FilenamePrms( NETLIST_TYPE_ID aType, wxString * aExt, wxString * aWildCard )
523 {
524  wxString fileExt;
525  wxString fileWildcard;
526  bool ret = true;
527 
528  switch( aType )
529  {
530  case NET_TYPE_SPICE:
531  fileExt = wxT( "cir" );
532  fileWildcard = SpiceNetlistFileWildcard();
533  break;
534 
535  case NET_TYPE_CADSTAR:
536  fileExt = wxT( "frp" );
537  fileWildcard = CadstarNetlistFileWildcard();
538  break;
539 
540  case NET_TYPE_PCBNEW:
541  case NET_TYPE_ORCADPCB2:
542  fileExt = NetlistFileExtension;
543  fileWildcard = NetlistFileWildcard();
544  break;
545 
546  default: // custom, NET_TYPE_CUSTOM1 and greater
547  fileWildcard = AllFilesWildcard();
548  ret = false;
549  }
550 
551  if( aExt )
552  *aExt = fileExt;
553 
554  if( aWildCard )
555  *aWildCard = fileWildcard;
556 
557  return ret;
558 }
559 
560 
562 {
563  wxString msg;
564 
566 
567  EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
568  wxASSERT( cfg );
569 
570  if( cfg )
571  {
574 
575  // Update existing custom pages
576  for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ )
577  {
579 
580  if( currPage == NULL )
581  break;
582 
583  wxString title = currPage->m_TitleStringCtrl->GetValue();
584 
585  if( title.IsEmpty() )
586  continue;
587 
588  cfg->m_NetlistPanel.custom_command_titles.emplace_back( title.ToStdString() );
589  cfg->m_NetlistPanel.custom_command_paths.emplace_back(
590  currPage->m_CommandStringCtrl->GetValue().ToStdString() );
591  }
592  }
593 }
594 
595 
596 void NETLIST_DIALOG::OnDelGenerator( wxCommandEvent& event )
597 {
598  NETLIST_PAGE_DIALOG* currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
599 
600  currPage->m_CommandStringCtrl->SetValue( wxEmptyString );
601  currPage->m_TitleStringCtrl->SetValue( wxEmptyString );
603 
605  EndModal( NET_PLUGIN_CHANGE );
606 }
607 
608 
609 void NETLIST_DIALOG::OnAddGenerator( wxCommandEvent& event )
610 {
611  NETLIST_DIALOG_ADD_GENERATOR dlg( this );
612 
613  if( dlg.ShowModal() != wxID_OK )
614  return;
615 
616  // Creates a new custom plugin page
617  wxString title = dlg.GetGeneratorTitle();
618 
619  // Verify it does not exists
620  int netTypeId = PANELCUSTOMBASE; // the first not used type id
621  NETLIST_PAGE_DIALOG* currPage;
622 
623  for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ )
624  {
625  netTypeId = PANELCUSTOMBASE + ii;
626  currPage = m_PanelNetType[ii + PANELCUSTOMBASE];
627 
628  if( currPage == NULL )
629  break;
630 
631  if( currPage->GetPageNetFmtName() == title )
632  {
633  wxMessageBox( _("This plugin already exists.") );
634  return;
635  }
636  }
637 
638  wxString cmd = dlg.GetGeneratorTCommandLine();
639  currPage = AddOneCustomPage( title,cmd, (NETLIST_TYPE_ID)netTypeId );
640  m_PanelNetType[netTypeId] = currPage;
642 
643  // Close and reopen dialog to rebuild the dialog after changes
644  EndModal( NET_PLUGIN_CHANGE );
645 }
646 
647 
650 {
651  m_Parent = parent;
652  m_sdbSizerOK->SetDefault();
653  GetSizer()->SetSizeHints( this );
654 }
655 
656 
657 void NETLIST_DIALOG_ADD_GENERATOR::OnOKClick( wxCommandEvent& event )
658 {
659  if( m_textCtrlCommand->GetValue() == wxEmptyString )
660  {
661  wxMessageBox( _( "Error. You must provide a command String" ) );
662  return;
663  }
664 
665  if( m_textCtrlName->GetValue() == wxEmptyString )
666  {
667  wxMessageBox( _( "Error. You must provide a Title" ) );
668  return;
669  }
670 
671  EndModal( wxID_OK );
672 }
673 
674 
676 {
677  wxString FullFileName, Path;
678 
679 #ifndef __WXMAC__
680  Path = Pgm().GetExecutablePath();
681 #else
682  Path = PATHS::GetOSXKicadDataDir() + wxT( "/plugins" );
683 #endif
684  FullFileName = EDA_FILE_SELECTOR( _( "Generator files:" ), Path, FullFileName,
685  wxEmptyString, wxFileSelectorDefaultWildcardStr,
686  this, wxFD_OPEN, true );
687  if( FullFileName.IsEmpty() )
688  return;
689 
690  // Creates a default command line, suitable for external tool xslproc or python, based on
691  // the plugin extension ("xsl" or "exe" or "py")
692  wxString cmdLine;
693  wxFileName fn( FullFileName );
694  wxString ext = fn.GetExt();
695 
696  if( ext == wxT("xsl" ) )
697  cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), FullFileName );
698  else if( ext == wxT("exe" ) || ext.IsEmpty() )
699  cmdLine.Printf(wxT("\"%s\" > \"%%O\" < \"%%I\""), FullFileName );
700  else if( ext == wxT("py" ) || ext.IsEmpty() )
701  cmdLine.Printf(wxT("python \"%s\" \"%%I\" \"%%O\""), FullFileName );
702  else
703  cmdLine.Printf(wxT("\"%s\""), FullFileName );
704 
705  m_textCtrlCommand->SetValue( cmdLine );
706 
707  /* Get a title for this page */
708  wxString title = m_textCtrlName->GetValue();
709 
710  if( title.IsEmpty() )
711  wxMessageBox( _( "Do not forget to choose a title for this netlist control page" ) );
712 }
713 
714 
716 {
717  NETLIST_DIALOG dlg( aCaller );
718 
719  SCHEMATIC_SETTINGS& settings = aCaller->Schematic().Settings();
720 
721  wxString curr_default_netformat = settings.m_NetFormatName;
722 
723  int ret = dlg.ShowModal();
724 
725  // Update the default netlist and store it in prj config if it was explicitly changed.
726  settings.m_NetFormatName = dlg.m_DefaultNetFmtName; // can have temporary changed
727 
728  if( curr_default_netformat != dlg.m_DefaultNetFmtName )
729  aCaller->SaveProjectSettings();
730 
731  return ret;
732 }
const std::string NetlistFileExtension
void OnDelGenerator(wxCommandEvent &event) override
Remove a panel relative to a netlist plugin.
bool ReadyToNetlist(const wxString &aAnnotateMessage)
Check if we are ready to write a netlist file for the current schematic.
void OnRunExternSpiceCommand(wxCommandEvent &event)
Run the external spice simulator command.
This file is part of the common library TODO brief description.
void SaveProjectSettings() override
Save changes to the project settings to the project (.pro) file.
bool FilenamePrms(NETLIST_TYPE_ID aType, wxString *aExt, wxString *aWildCard)
Return the filename extension and the wildcard string for this page or a void name if there is no def...
NETLIST_PAGE_DIALOG(wxNotebook *parent, const wxString &title, NETLIST_TYPE_ID id_NetType)
Create a setup page for one netlist format.
wxString SpiceNetlistFileWildcard()
EVT_UPDATE_UI(ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadFootprintFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:129
void OnOKClick(wxCommandEvent &event) override
Validate info relative to a new netlist plugin.
void OnAddGenerator(wxCommandEvent &event) override
Add a new panel for a new netlist plugin.
Schematic editor (Eeschema) main window.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
wxString AllFilesWildcard()
NETLIST_TYPE_ID
netlist types
Definition: netlist.h:35
Class NETLIST_DIALOG_ADD_GENERATOR_BASE.
std::vector< wxString > custom_command_titles
void WriteCurrentNetlistSetup()
Write the current netlist options setup in the configuration.
#define NULL
NETLIST_DIALOG(SCH_EDIT_FRAME *parent)
#define CUSTOMPANEL_COUNTMAX
bool WriteNetListFile(int aFormat, const wxString &aFullFileName, unsigned aNetlistOptions, REPORTER *aReporter=nullptr)
Create a netlist file.
wxString NetlistFileWildcard()
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
wxString EDA_FILE_SELECTOR(const wxString &aTitle, const wxString &aPath, const wxString &aFileName, const wxString &aExtension, const wxString &aWildcard, wxWindow *aParent, int aStyle, const bool aKeepWorkingDirectory, const wxPoint &aPosition, wxString *aMruPath)
A helper function that wraps a call to wxFileSelector.
Definition: gestfich.cpp:52
SCHEMATIC & Schematic() const
Definition of file extensions used in Kicad.
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:123
void OnBrowseGenerators(wxCommandEvent &event) override
virtual void ClearMsgPanel()
Clear all messages from the message panel.
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
NETLIST_PAGE_DIALOG * m_PanelNetType[4+CUSTOMPANEL_COUNTMAX]
NETLIST_PAGE_DIALOG * AddOneCustomPage(const wxString &aTitle, const wxString &aCommandString, NETLIST_TYPE_ID aNetTypeId)
see class PGM_BASE
#define _(s)
Definition: 3d_actions.cpp:33
#define NET_PLUGIN_CHANGE
Create and shows NETLIST_DIALOG and returns whatever NETLIST_DIALOG::ShowModal() returns.
These settings were stored in SCH_BASE_FRAME previously.
void OnRunSpiceButtUI(wxUpdateUIEvent &event)
Enable (if the command line is not empty or disable the button to run spice command.
std::vector< wxString > custom_command_paths
void SetNetListerCommand(const wxString &aCommand)
void OnNetlistTypeSelection(wxNotebookEvent &event) override
PANEL_NETLIST m_NetlistPanel
int InvokeDialogNetList(SCH_EDIT_FRAME *aCaller)
wxString CadstarNetlistFileWildcard()