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 
53 
54 #define CUSTOMPANEL_COUNTMAX 8 // Max number of netlist plugins
55 
56 
57 /* panel (notebook page) identifiers */
59  PANELPCBNEW = 0, /* Handle Netlist format Pcbnew */
60  PANELORCADPCB2, /* Handle Netlist format OracdPcb2 */
61  PANELCADSTAR, /* Handle Netlist format CadStar */
62  PANELSPICE, /* Handle Netlist format Pspice */
63  PANELCUSTOMBASE /* First auxiliary panel (custom netlists).
64  * others use PANELCUSTOMBASE+1, PANELCUSTOMBASE+2.. */
65 };
66 
67 
68 /* wxPanels for creating the NoteBook pages for each netlist format: */
69 class NETLIST_PAGE_DIALOG : public wxPanel
70 {
71 public:
73  // opt to reformat passive component values (e.g. 1M -> 1Meg):
74  wxCheckBox* m_AdjustPassiveValues;
75  wxTextCtrl* m_CommandStringCtrl;
76  wxTextCtrl* m_TitleStringCtrl;
77  wxBoxSizer* m_LeftBoxSizer;
78  wxBoxSizer* m_RightBoxSizer;
80  wxBoxSizer* m_LowBoxSizer;
81 
82 private:
83  wxString m_pageNetFmtName;
84 
85 public:
92  NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& title,
93  NETLIST_TYPE_ID id_NetType );
95 
101  const wxString GetPageNetFmtName() { return m_pageNetFmtName; }
102 };
103 
104 
105 /* Dialog frame for creating netlists */
107 {
108  friend class NETLIST_PAGE_DIALOG;
109 
110 public:
114 
115 public:
116  // Constructor and destructor
117  NETLIST_DIALOG( SCH_EDIT_FRAME* parent );
119 
120 private:
121  void InstallCustomPages();
122  NETLIST_PAGE_DIALOG* AddOneCustomPage( const wxString & aTitle,
123  const wxString & aCommandString,
124  NETLIST_TYPE_ID aNetTypeId );
125  void InstallPageSpice();
126  bool TransferDataFromWindow() override;
127  void NetlistUpdateOpt();
128 
129  // Called when changing the notebook page (and therefore the current netlist format)
130  void OnNetlistTypeSelection( wxNotebookEvent& event ) override;
131 
136  void OnAddGenerator( wxCommandEvent& event ) override;
137 
142  void OnDelGenerator( wxCommandEvent& event ) override;
143 
147  void OnRunExternSpiceCommand( wxCommandEvent& event );
148 
152  void OnRunSpiceButtUI( wxUpdateUIEvent& event );
153 
159 
169  bool FilenamePrms( NETLIST_TYPE_ID aType,
170  wxString * aExt, wxString * aWildCard );
171 
173 };
174 
175 
177 {
178 private:
180 
181 public:
183 
184  const wxString GetGeneratorTitle() { return m_textCtrlName->GetValue(); }
185  const wxString GetGeneratorTCommandLine() { return m_textCtrlCommand->GetValue(); }
186 
187 private:
192  void OnOKClick( wxCommandEvent& event ) override;
193 
194  /*
195  * Browse plugin files, and set m_CommandStringCtrl field
196  */
197  void OnBrowseGenerators( wxCommandEvent& event ) override;
198 };
199 
200 
201 /* Event id for notebook page buttons: */
206 };
207 
208 
209 BEGIN_EVENT_TABLE( NETLIST_DIALOG, NETLIST_DIALOG_BASE )
212 END_EVENT_TABLE()
213 
214 
215 
216 NETLIST_PAGE_DIALOG::NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& title,
217  NETLIST_TYPE_ID id_NetType ) :
218  wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL )
219 {
220  m_IdNetType = id_NetType;
221  m_pageNetFmtName = title;
222  m_CommandStringCtrl = NULL;
223  m_TitleStringCtrl = NULL;
224  m_AdjustPassiveValues = NULL;
225 
226  wxString netfmtName = static_cast<NETLIST_DIALOG*>( parent->GetParent() )->m_DefaultNetFmtName;
227 
228  bool selected = m_pageNetFmtName == netfmtName;
229 
230  parent->AddPage( this, title, selected );
231 
232  wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxVERTICAL );
233  SetSizer( MainBoxSizer );
234  wxBoxSizer* UpperBoxSizer = new wxBoxSizer( wxHORIZONTAL );
235  m_LowBoxSizer = new wxBoxSizer( wxVERTICAL );
236  MainBoxSizer->Add( UpperBoxSizer, 0, wxGROW | wxALL, 5 );
237  MainBoxSizer->Add( m_LowBoxSizer, 0, wxGROW | wxALL, 5 );
238 
239  m_LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
240  m_RightBoxSizer = new wxBoxSizer( wxVERTICAL );
241  m_RightOptionsBoxSizer = new wxBoxSizer( wxVERTICAL );
242  UpperBoxSizer->Add( m_LeftBoxSizer, 0, wxGROW | wxALL, 5 );
243  UpperBoxSizer->Add( m_RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
244  UpperBoxSizer->Add( m_RightOptionsBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
245 }
246 
247 
248 
250  NETLIST_DIALOG_BASE( parent )
251 {
252  m_Parent = parent;
253 
255 
257 
258  for( NETLIST_PAGE_DIALOG*& page : m_PanelNetType)
259  page = NULL;
260 
261  // Add notebook pages:
263  NET_TYPE_PCBNEW );
264 
265  m_PanelNetType[PANELORCADPCB2] = new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "OrcadPCB2" ),
267 
268  m_PanelNetType[PANELCADSTAR] = new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "CadStar" ),
270 
273 
274  // We use a sdbSizer here to get the order right, which is platform-dependent
275  m_sdbSizer2OK->SetLabel( _( "Export Netlist" ) );
276  m_sdbSizer2Cancel->SetLabel( _( "Close" ) );
277  m_buttonSizer->Layout();
278 
279  m_sdbSizer2OK->SetDefault();
280 
281  // Now all widgets have the size fixed, call FinishDialogSettings
283 }
284 
285 
286 void NETLIST_DIALOG::OnRunExternSpiceCommand( wxCommandEvent& event )
287 {
288  // Run the external spice simulator command
290 
292  wxString simulatorCommand = settings.m_SpiceCommandString;
293 
294  unsigned netlist_opt = 0;
295 
296  // Calculate the netlist filename and options
297  wxFileName fn = m_Parent->Schematic().GetFileName();
298  fn.SetExt( wxT( "cir" ) );
299 
300  if( settings.m_SpiceAdjustPassiveValues )
301  netlist_opt |= NET_ADJUST_PASSIVE_VALS;
302 
303  // Build the command line
304  wxString commandLine = simulatorCommand;
305  commandLine.Replace( "%I", fn.GetFullPath(), true );
306 
307  if( m_Parent->ReadyToNetlist( _( "Simulator requires a fully annotated schematic." ) ) )
308  {
309  m_Parent->WriteNetListFile( NET_TYPE_SPICE, fn.GetFullPath(), netlist_opt, nullptr );
310  wxExecute( commandLine, wxEXEC_ASYNC );
311  }
312 }
313 
314 
315 void NETLIST_DIALOG::OnRunSpiceButtUI( wxUpdateUIEvent& aEvent )
316 {
317  bool disable = m_PanelNetType[PANELSPICE]->m_CommandStringCtrl->IsEmpty();
318  aEvent.Enable( !disable );
319 }
320 
321 
323 {
325  new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "Spice" ), NET_TYPE_SPICE );
326 
328 
329  page->m_AdjustPassiveValues = new wxCheckBox( page, ID_USE_NETCODE_AS_NETNAME,
330  _( "Reformat passive symbol values" ) );
331  page->m_AdjustPassiveValues->SetToolTip( _( "Reformat passive symbol values e.g. 1M -> 1Meg" ) );
332  page->m_AdjustPassiveValues->SetValue( settings.m_SpiceAdjustPassiveValues );
333  page->m_LeftBoxSizer->Add( page->m_AdjustPassiveValues, 0, wxGROW | wxBOTTOM | wxRIGHT, 5 );
334 
335  wxString simulatorCommand = settings.m_SpiceCommandString;
336  wxStaticText* spice_label = new wxStaticText( page, -1, _( "External simulator command:" ) );
337  spice_label->SetToolTip( _( "Enter the command line to run spice\n"
338  "Usually <path to spice binary> %I\n"
339  "%I will be replaced by the actual spice netlist name") );
340  page->m_LowBoxSizer->Add( spice_label, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
341 
342  page->m_CommandStringCtrl = new wxTextCtrl( page, -1, simulatorCommand,
343  wxDefaultPosition, wxDefaultSize );
344 
345  page->m_CommandStringCtrl->SetInsertionPoint( 1 );
346  page->m_LowBoxSizer->Add( page->m_CommandStringCtrl, 0,
347  wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
348 
349  // Add button to run spice command
350  wxButton* button = new wxButton( page, ID_RUN_SIMULATOR,
351  _( "Create Netlist and Run Simulator Command" ) );
352  page->m_LowBoxSizer->Add( button, 0, wxGROW | wxBOTTOM | wxLEFT | wxRIGHT, 5 );
353 }
354 
355 
357 {
358  NETLIST_PAGE_DIALOG* currPage;
359 
360  auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
361  wxASSERT( cfg );
362 
363  if( cfg )
364  {
365  for( size_t i = 0;
366  i < CUSTOMPANEL_COUNTMAX && i < cfg->m_NetlistPanel.custom_command_titles.size();
367  i++ )
368  {
369  // pairs of (title, command) are stored
370  wxString title = cfg->m_NetlistPanel.custom_command_titles[i];
371 
372  if( i >= cfg->m_NetlistPanel.custom_command_paths.size() )
373  break; // No more panel to install
374 
375  wxString command = cfg->m_NetlistPanel.custom_command_paths[i];
376 
377  currPage = AddOneCustomPage( title, command,
378  static_cast<NETLIST_TYPE_ID>( NET_TYPE_CUSTOM1 + i ) );
379 
380  m_PanelNetType[PANELCUSTOMBASE + i] = currPage;
381  }
382  }
383 }
384 
385 
387  const wxString & aCommandString,
388  NETLIST_TYPE_ID aNetTypeId )
389 {
390  NETLIST_PAGE_DIALOG* currPage = new NETLIST_PAGE_DIALOG( m_NoteBook, aTitle, aNetTypeId );
391 
392  currPage->m_LowBoxSizer->Add( new wxStaticText( currPage, -1, _( "Title:" ) ), 0,
393  wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
394 
395  currPage->m_TitleStringCtrl = new wxTextCtrl( currPage, -1, aTitle,
396  wxDefaultPosition, wxDefaultSize );
397 
398  currPage->m_TitleStringCtrl->SetInsertionPoint( 1 );
399  currPage->m_LowBoxSizer->Add( currPage->m_TitleStringCtrl, 0,
400  wxGROW | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
401 
402  currPage->m_LowBoxSizer->Add( new wxStaticText( currPage, -1, _( "Netlist command:" ) ), 0,
403  wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
404 
405  currPage->m_CommandStringCtrl = new wxTextCtrl( currPage, -1, aCommandString,
406  wxDefaultPosition, wxDefaultSize );
407 
408  currPage->m_CommandStringCtrl->SetInsertionPoint( 1 );
409  currPage->m_LowBoxSizer->Add( currPage->m_CommandStringCtrl, 0,
410  wxGROW | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
411 
412  return currPage;
413 }
414 
415 
416 void NETLIST_DIALOG::OnNetlistTypeSelection( wxNotebookEvent& event )
417 {
418  NETLIST_PAGE_DIALOG* currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
419 
420  if( currPage == NULL )
421  return;
422 
424 
425  m_buttonDelGenerator->Enable( currPage->m_IdNetType >= NET_TYPE_CUSTOM1 );
426 }
427 
428 
430 {
431  bool adjust = m_PanelNetType[ PANELSPICE ]->m_AdjustPassiveValues->IsChecked();
432  wxString spice_cmd_string = m_PanelNetType[ PANELSPICE ]->m_CommandStringCtrl->GetValue();
433 
435 
436  settings.m_SpiceAdjustPassiveValues = adjust;
437  settings.m_SpiceCommandString = spice_cmd_string;
438  settings.m_NetFormatName = wxEmptyString;
440 }
441 
442 
444 {
445  wxFileName fn;
446  wxString fileWildcard;
447  wxString fileExt;
448  wxString title = _( "Save Netlist File" );
449 
451 
452  NETLIST_PAGE_DIALOG* currPage;
453  currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
454 
455  unsigned netlist_opt = 0;
456 
457  // Calculate the netlist filename
458  fn = m_Parent->Schematic().GetFileName();
459  FilenamePrms( currPage->m_IdNetType, &fileExt, &fileWildcard );
460 
461  // Set some parameters
462  switch( currPage->m_IdNetType )
463  {
464  case NET_TYPE_SPICE:
465  // Set spice netlist options:
466  if( currPage->m_AdjustPassiveValues->GetValue() )
467  netlist_opt |= NET_ADJUST_PASSIVE_VALS;
468  break;
469 
470  case NET_TYPE_CADSTAR:
471  break;
472 
473  case NET_TYPE_PCBNEW:
474  break;
475 
476  case NET_TYPE_ORCADPCB2:
477  break;
478 
479  default: // custom, NET_TYPE_CUSTOM1 and greater
480  {
481  wxString command = currPage->m_CommandStringCtrl->GetValue();
482  wxRegEx extRE( wxT( ".*\\.([[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]]?)\\.xslt?\".*" ) );
483 
484  if( extRE.Matches( command ) )
485  fileExt = extRE.GetMatch( command, 1 );
486 
487  title.Printf( _( "%s Export" ), currPage->m_TitleStringCtrl->GetValue().GetData() );
488  }
489  break;
490  }
491 
492  fn.SetExt( fileExt );
493 
494  if( fn.GetPath().IsEmpty() )
495  fn.SetPath( wxPathOnly( Prj().GetProjectFullName() ) );
496 
497  wxString fullpath = fn.GetFullPath();
498  wxString fullname = fn.GetFullName();
499  wxString path = fn.GetPath();
500 
501  // fullname does not and should not include the path, per wx docs.
502  wxFileDialog dlg( this, title, path, fullname, fileWildcard, wxFD_SAVE );
503 
504  if( dlg.ShowModal() == wxID_CANCEL )
505  return false;
506 
507  fullpath = dlg.GetPath(); // directory + filename
508 
510 
511  if( currPage->m_CommandStringCtrl )
512  m_Parent->SetNetListerCommand( currPage->m_CommandStringCtrl->GetValue() );
513  else
514  m_Parent->SetNetListerCommand( wxEmptyString );
515 
516  if( m_Parent->ReadyToNetlist( _( "Exporting netlist requires a fully annotated schematic." ) ) )
517  m_Parent->WriteNetListFile( currPage->m_IdNetType, fullpath, netlist_opt, nullptr );
518 
520 
521  return true;
522 }
523 
524 
525 bool NETLIST_DIALOG::FilenamePrms( NETLIST_TYPE_ID aType, wxString * aExt, wxString * aWildCard )
526 {
527  wxString fileExt;
528  wxString fileWildcard;
529  bool ret = true;
530 
531  switch( aType )
532  {
533  case NET_TYPE_SPICE:
534  fileExt = wxT( "cir" );
535  fileWildcard = SpiceNetlistFileWildcard();
536  break;
537 
538  case NET_TYPE_CADSTAR:
539  fileExt = wxT( "frp" );
540  fileWildcard = CadstarNetlistFileWildcard();
541  break;
542 
543  case NET_TYPE_PCBNEW:
544  case NET_TYPE_ORCADPCB2:
545  fileExt = NetlistFileExtension;
546  fileWildcard = NetlistFileWildcard();
547  break;
548 
549  default: // custom, NET_TYPE_CUSTOM1 and greater
550  fileWildcard = AllFilesWildcard();
551  ret = false;
552  }
553 
554  if( aExt )
555  *aExt = fileExt;
556 
557  if( aWildCard )
558  *aWildCard = fileWildcard;
559 
560  return ret;
561 }
562 
563 
565 {
566  wxString msg;
567 
569 
570  EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
571  wxASSERT( cfg );
572 
573  if( cfg )
574  {
577 
578  // Update existing custom pages
579  for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ )
580  {
582 
583  if( currPage == NULL )
584  break;
585 
586  wxString title = currPage->m_TitleStringCtrl->GetValue();
587 
588  if( title.IsEmpty() )
589  continue;
590 
591  cfg->m_NetlistPanel.custom_command_titles.emplace_back( title.ToStdString() );
592  cfg->m_NetlistPanel.custom_command_paths.emplace_back(
593  currPage->m_CommandStringCtrl->GetValue().ToStdString() );
594  }
595  }
596 }
597 
598 
599 void NETLIST_DIALOG::OnDelGenerator( wxCommandEvent& event )
600 {
601  NETLIST_PAGE_DIALOG* currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
602 
603  currPage->m_CommandStringCtrl->SetValue( wxEmptyString );
604  currPage->m_TitleStringCtrl->SetValue( wxEmptyString );
606 
608  EndModal( NET_PLUGIN_CHANGE );
609 }
610 
611 
612 void NETLIST_DIALOG::OnAddGenerator( wxCommandEvent& event )
613 {
614  NETLIST_DIALOG_ADD_GENERATOR dlg( this );
615 
616  if( dlg.ShowModal() != wxID_OK )
617  return;
618 
619  // Creates a new custom plugin page
620  wxString title = dlg.GetGeneratorTitle();
621 
622  // Verify it does not exists
623  int netTypeId = PANELCUSTOMBASE; // the first not used type id
624  NETLIST_PAGE_DIALOG* currPage;
625 
626  for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ )
627  {
628  netTypeId = PANELCUSTOMBASE + ii;
629  currPage = m_PanelNetType[ii + PANELCUSTOMBASE];
630 
631  if( currPage == NULL )
632  break;
633 
634  if( currPage->GetPageNetFmtName() == title )
635  {
636  wxMessageBox( _("This plugin already exists.") );
637  return;
638  }
639  }
640 
641  wxString cmd = dlg.GetGeneratorTCommandLine();
642  currPage = AddOneCustomPage( title,cmd, (NETLIST_TYPE_ID)netTypeId );
643  m_PanelNetType[netTypeId] = currPage;
645 
646  // Close and reopen dialog to rebuild the dialog after changes
647  EndModal( NET_PLUGIN_CHANGE );
648 }
649 
650 
653 {
654  m_Parent = parent;
655  m_sdbSizerOK->SetDefault();
656  GetSizer()->SetSizeHints( this );
657 }
658 
659 
660 void NETLIST_DIALOG_ADD_GENERATOR::OnOKClick( wxCommandEvent& event )
661 {
662  if( m_textCtrlCommand->GetValue() == wxEmptyString )
663  {
664  wxMessageBox( _( "Error. You must provide a command String" ) );
665  return;
666  }
667 
668  if( m_textCtrlName->GetValue() == wxEmptyString )
669  {
670  wxMessageBox( _( "Error. You must provide a Title" ) );
671  return;
672  }
673 
674  EndModal( wxID_OK );
675 }
676 
677 
679 {
680  wxString FullFileName, Path;
681 
682 #ifndef __WXMAC__
683  Path = Pgm().GetExecutablePath();
684 #else
685  Path = PATHS::GetOSXKicadDataDir() + wxT( "/plugins" );
686 #endif
687  FullFileName = EDA_FILE_SELECTOR( _( "Generator files:" ), Path, FullFileName,
688  wxEmptyString, wxFileSelectorDefaultWildcardStr,
689  this, wxFD_OPEN, true );
690  if( FullFileName.IsEmpty() )
691  return;
692 
693  // Creates a default command line, suitable for external tool xslproc or python, based on
694  // the plugin extension ("xsl" or "exe" or "py")
695  wxString cmdLine;
696  wxFileName fn( FullFileName );
697  wxString ext = fn.GetExt();
698 
699  if( ext == wxT("xsl" ) )
700  cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), FullFileName );
701  else if( ext == wxT("exe" ) || ext.IsEmpty() )
702  cmdLine.Printf(wxT("\"%s\" > \"%%O\" < \"%%I\""), FullFileName );
703  else if( ext == wxT("py" ) || ext.IsEmpty() )
704  cmdLine.Printf(wxT("python \"%s\" \"%%I\" \"%%O\""), FullFileName );
705  else
706  cmdLine.Printf(wxT("\"%s\""), FullFileName );
707 
708  m_textCtrlCommand->SetValue( cmdLine );
709 
710  /* Get a title for this page */
711  wxString title = m_textCtrlName->GetValue();
712 
713  if( title.IsEmpty() )
714  wxMessageBox( _( "Do not forget to choose a title for this netlist control page" ) );
715 }
716 
717 
719 {
720  NETLIST_DIALOG dlg( aCaller );
721 
722  SCHEMATIC_SETTINGS& settings = aCaller->Schematic().Settings();
723 
724  wxString curr_default_netformat = settings.m_NetFormatName;
725 
726  int ret = dlg.ShowModal();
727 
728  // Update the default netlist and store it in prj config if it was explicitely changed.
729  settings.m_NetFormatName = dlg.m_DefaultNetFmtName; // can have temporary changed
730 
731  if( curr_default_netformat != dlg.m_DefaultNetFmtName )
732  aCaller->SaveProjectSettings();
733 
734  return ret;
735 }
const std::string NetlistFileExtension
void OnDelGenerator(wxCommandEvent &event) override
Function OnDelGenerator Remove a panel relative to a netlist plugin.
bool ReadyToNetlist(const wxString &aAnnotateMessage)
Checks if we are ready to write a netlist file for the current schematic.
void OnRunExternSpiceCommand(wxCommandEvent &event)
Run the external spice simulator command.
bool WriteNetListFile(int aFormat, const wxString &aFullFileName, unsigned aNetlistOptions, REPORTER *aReporter=NULL)
Create a netlist file.
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)
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()
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:125
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.
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()
Function WriteCurrentNetlistSetup Write the current netlist options setup in the configuration.
#define NULL
NETLIST_DIALOG(SCH_EDIT_FRAME *parent)
#define CUSTOMPANEL_COUNTMAX
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:119
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
const wxString GetPageNetFmtName()
function GetPageNetFmtName
int InvokeDialogNetList(SCH_EDIT_FRAME *aCaller)
wxString CadstarNetlistFileWildcard()