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/checkbox.h>
52 #include <wx/filedlg.h>
53 #include <wx/msgdlg.h>
54 #include <wx/regex.h>
55 
56 
57 
58 #define CUSTOMPANEL_COUNTMAX 8 // Max number of netlist plugins
59 
60 
61 /* panel (notebook page) identifiers */
63  PANELPCBNEW = 0, /* Handle Netlist format Pcbnew */
64  PANELORCADPCB2, /* Handle Netlist format OracdPcb2 */
65  PANELCADSTAR, /* Handle Netlist format CadStar */
66  PANELSPICE, /* Handle Netlist format Pspice */
67  PANELCUSTOMBASE /* First auxiliary panel (custom netlists).
68  * others use PANELCUSTOMBASE+1, PANELCUSTOMBASE+2.. */
69 };
70 
71 
72 /* wxPanels for creating the NoteBook pages for each netlist format: */
73 class NETLIST_PAGE_DIALOG : public wxPanel
74 {
75 
76 public:
86  NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& title,
87  NETLIST_TYPE_ID id_NetType );
89 
93  const wxString GetPageNetFmtName() { return m_pageNetFmtName; }
94 
96  // opt to reformat passive component values (e.g. 1M -> 1Meg):
97  wxCheckBox* m_AdjustPassiveValues;
98  wxTextCtrl* m_CommandStringCtrl;
99  wxTextCtrl* m_TitleStringCtrl;
100  wxBoxSizer* m_LeftBoxSizer;
101  wxBoxSizer* m_RightBoxSizer;
103  wxBoxSizer* m_LowBoxSizer;
104 
105 private:
107 };
108 
109 
110 /* Dialog frame for creating netlists */
112 {
113 public:
114  NETLIST_DIALOG( SCH_EDIT_FRAME* parent );
116 
117 private:
118  friend class NETLIST_PAGE_DIALOG;
119 
120  void InstallCustomPages();
121  NETLIST_PAGE_DIALOG* AddOneCustomPage( const wxString & aTitle,
122  const wxString & aCommandString,
123  NETLIST_TYPE_ID aNetTypeId );
124  void InstallPageSpice();
125  bool TransferDataFromWindow() override;
126  void NetlistUpdateOpt();
127 
128  // Called when changing the notebook page (and therefore the current netlist format)
129  void OnNetlistTypeSelection( wxNotebookEvent& event ) override;
130 
134  void OnAddGenerator( wxCommandEvent& event ) override;
135 
139  void OnDelGenerator( wxCommandEvent& event ) override;
140 
144  void OnRunExternSpiceCommand( wxCommandEvent& event );
145 
149  void OnRunSpiceButtUI( wxUpdateUIEvent& event );
150 
155 
165  bool FilenamePrms( NETLIST_TYPE_ID aType, wxString* aExt, wxString* aWildCard );
166 
168 
169 public:
173 };
174 
175 
177 {
178 public:
180 
181  const wxString GetGeneratorTitle() { return m_textCtrlName->GetValue(); }
182  const wxString GetGeneratorTCommandLine() { return m_textCtrlCommand->GetValue(); }
183 
184  bool TransferDataFromWindow() override;
185 
186 private:
187  /*
188  * Browse plugin files, and set m_CommandStringCtrl field
189  */
190  void OnBrowseGenerators( wxCommandEvent& event ) override;
191 
193 };
194 
195 
196 /* Event id for notebook page buttons: */
201 };
202 
203 
204 BEGIN_EVENT_TABLE( NETLIST_DIALOG, NETLIST_DIALOG_BASE )
207 END_EVENT_TABLE()
208 
209 
210 NETLIST_PAGE_DIALOG::NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& title,
211  NETLIST_TYPE_ID id_NetType ) :
212  wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL )
213 {
214  m_IdNetType = id_NetType;
215  m_pageNetFmtName = title;
216  m_CommandStringCtrl = nullptr;
217  m_TitleStringCtrl = nullptr;
218  m_AdjustPassiveValues = nullptr;
219 
220  wxString netfmtName = static_cast<NETLIST_DIALOG*>( parent->GetParent() )->m_DefaultNetFmtName;
221 
222  bool selected = m_pageNetFmtName == netfmtName;
223 
224  parent->AddPage( this, title, selected );
225 
226  wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxVERTICAL );
227  SetSizer( MainBoxSizer );
228  wxBoxSizer* UpperBoxSizer = new wxBoxSizer( wxHORIZONTAL );
229  m_LowBoxSizer = new wxBoxSizer( wxVERTICAL );
230  MainBoxSizer->Add( UpperBoxSizer, 0, wxGROW | wxALL, 5 );
231  MainBoxSizer->Add( m_LowBoxSizer, 0, wxGROW | wxALL, 5 );
232 
233  m_LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
234  m_RightBoxSizer = new wxBoxSizer( wxVERTICAL );
235  m_RightOptionsBoxSizer = new wxBoxSizer( wxVERTICAL );
236  UpperBoxSizer->Add( m_LeftBoxSizer, 0, wxGROW | wxALL, 5 );
237  UpperBoxSizer->Add( m_RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
238  UpperBoxSizer->Add( m_RightOptionsBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
239 }
240 
241 
243  NETLIST_DIALOG_BASE( parent )
244 {
245  m_Parent = parent;
246 
248 
250 
251  for( NETLIST_PAGE_DIALOG*& page : m_PanelNetType)
252  page = nullptr;
253 
254  // Add notebook pages:
256  NET_TYPE_PCBNEW );
257 
258  m_PanelNetType[PANELORCADPCB2] = new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "OrcadPCB2" ),
260 
261  m_PanelNetType[PANELCADSTAR] = new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "CadStar" ),
263 
266 
267  // We use a sdbSizer here to get the order right, which is platform-dependent
268  m_sdbSizer2OK->SetLabel( _( "Export Netlist" ) );
269  m_sdbSizer2Cancel->SetLabel( _( "Close" ) );
270  m_buttonSizer->Layout();
271 
272  m_sdbSizer2OK->SetDefault();
273 
274  // Now all widgets have the size fixed, call FinishDialogSettings
276 }
277 
278 
279 void NETLIST_DIALOG::OnRunExternSpiceCommand( wxCommandEvent& event )
280 {
281  // Run the external spice simulator command
283 
285  wxString simulatorCommand = settings.m_SpiceCommandString;
286 
287  unsigned netlist_opt = 0;
288 
289  // Calculate the netlist filename and options
290  wxFileName fn = m_Parent->Schematic().GetFileName();
291  fn.SetExt( wxT( "cir" ) );
292 
293  if( settings.m_SpiceAdjustPassiveValues )
294  netlist_opt |= NET_ADJUST_PASSIVE_VALS;
295 
296  // Build the command line
297  wxString commandLine = simulatorCommand;
298  commandLine.Replace( "%I", fn.GetFullPath(), true );
299 
300  if( m_Parent->ReadyToNetlist( _( "Simulator requires a fully annotated schematic." ) ) )
301  {
302  m_Parent->WriteNetListFile( NET_TYPE_SPICE, fn.GetFullPath(), netlist_opt, nullptr );
303  wxExecute( commandLine, wxEXEC_ASYNC );
304  }
305 }
306 
307 
308 void NETLIST_DIALOG::OnRunSpiceButtUI( wxUpdateUIEvent& aEvent )
309 {
310  bool disable = m_PanelNetType[PANELSPICE]->m_CommandStringCtrl->IsEmpty();
311  aEvent.Enable( !disable );
312 }
313 
314 
316 {
318  new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "Spice" ), NET_TYPE_SPICE );
319 
321 
322  page->m_AdjustPassiveValues = new wxCheckBox( page, ID_USE_NETCODE_AS_NETNAME,
323  _( "Reformat passive symbol values" ) );
324  page->m_AdjustPassiveValues->SetToolTip( _( "Reformat passive symbol values e.g. 1M -> 1Meg" ) );
325  page->m_AdjustPassiveValues->SetValue( settings.m_SpiceAdjustPassiveValues );
326  page->m_LeftBoxSizer->Add( page->m_AdjustPassiveValues, 0, wxGROW | wxBOTTOM | wxRIGHT, 5 );
327 
328  wxString simulatorCommand = settings.m_SpiceCommandString;
329  wxStaticText* spice_label = new wxStaticText( page, -1, _( "External simulator command:" ) );
330  spice_label->SetToolTip( _( "Enter the command line to run spice\n"
331  "Usually <path to spice binary> %I\n"
332  "%I will be replaced by the actual spice netlist name" ) );
333  page->m_LowBoxSizer->Add( spice_label, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
334 
335  page->m_CommandStringCtrl = new wxTextCtrl( page, -1, simulatorCommand,
336  wxDefaultPosition, wxDefaultSize );
337 
338  page->m_CommandStringCtrl->SetInsertionPoint( 1 );
339  page->m_LowBoxSizer->Add( page->m_CommandStringCtrl, 0,
340  wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
341 
342  // Add button to run spice command
343  wxButton* button = new wxButton( page, ID_RUN_SIMULATOR,
344  _( "Create Netlist and Run Simulator Command" ) );
345  page->m_LowBoxSizer->Add( button, 0, wxGROW | wxBOTTOM | wxLEFT | wxRIGHT, 5 );
346 }
347 
348 
350 {
351  NETLIST_PAGE_DIALOG* currPage;
352 
353  auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
354  wxASSERT( cfg );
355 
356  if( cfg )
357  {
358  for( size_t i = 0;
359  i < CUSTOMPANEL_COUNTMAX && i < cfg->m_NetlistPanel.custom_command_titles.size();
360  i++ )
361  {
362  // pairs of (title, command) are stored
363  wxString title = cfg->m_NetlistPanel.custom_command_titles[i];
364 
365  if( i >= cfg->m_NetlistPanel.custom_command_paths.size() )
366  break; // No more panel to install
367 
368  wxString command = cfg->m_NetlistPanel.custom_command_paths[i];
369 
370  currPage = AddOneCustomPage( title, command,
371  static_cast<NETLIST_TYPE_ID>( NET_TYPE_CUSTOM1 + i ) );
372 
373  m_PanelNetType[PANELCUSTOMBASE + i] = currPage;
374  }
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::OnNetlistTypeSelection( wxNotebookEvent& event )
410 {
411  NETLIST_PAGE_DIALOG* currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
412 
413  if( currPage == nullptr )
414  return;
415 
417 
418  m_buttonDelGenerator->Enable( currPage->m_IdNetType >= NET_TYPE_CUSTOM1 );
419 }
420 
421 
423 {
424  bool adjust = m_PanelNetType[ PANELSPICE ]->m_AdjustPassiveValues->IsChecked();
425  wxString spice_cmd_string = m_PanelNetType[ PANELSPICE ]->m_CommandStringCtrl->GetValue();
426 
428 
429  settings.m_SpiceAdjustPassiveValues = adjust;
430  settings.m_SpiceCommandString = spice_cmd_string;
431  settings.m_NetFormatName = wxEmptyString;
433 }
434 
435 
437 {
438  wxFileName fn;
439  wxString fileWildcard;
440  wxString fileExt;
441  wxString title = _( "Save Netlist File" );
442 
444 
445  NETLIST_PAGE_DIALOG* currPage;
446  currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
447 
448  unsigned netlist_opt = 0;
449 
450  // Calculate the netlist filename
451  fn = m_Parent->Schematic().GetFileName();
452  FilenamePrms( currPage->m_IdNetType, &fileExt, &fileWildcard );
453 
454  // Set some parameters
455  switch( currPage->m_IdNetType )
456  {
457  case NET_TYPE_SPICE:
458  // Set spice netlist options:
459  if( currPage->m_AdjustPassiveValues->GetValue() )
460  netlist_opt |= NET_ADJUST_PASSIVE_VALS;
461  break;
462 
463  case NET_TYPE_CADSTAR:
464  break;
465 
466  case NET_TYPE_PCBNEW:
467  break;
468 
469  case NET_TYPE_ORCADPCB2:
470  break;
471 
472  default: // custom, NET_TYPE_CUSTOM1 and greater
473  {
474  wxString command = currPage->m_CommandStringCtrl->GetValue();
475  wxRegEx extRE( wxT( ".*\\.([[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]]?)\\.xslt?\".*" ) );
476 
477  if( extRE.Matches( command ) )
478  fileExt = extRE.GetMatch( command, 1 );
479 
480  title.Printf( _( "%s Export" ), currPage->m_TitleStringCtrl->GetValue().GetData() );
481  break;
482  }
483  }
484 
485  fn.SetExt( fileExt );
486 
487  if( fn.GetPath().IsEmpty() )
488  fn.SetPath( wxPathOnly( Prj().GetProjectFullName() ) );
489 
490  wxString fullpath = fn.GetFullPath();
491  wxString fullname = fn.GetFullName();
492  wxString path = fn.GetPath();
493 
494  // full name does not and should not include the path, per wx docs.
495  wxFileDialog dlg( this, title, path, fullname, fileWildcard, wxFD_SAVE );
496 
497  if( dlg.ShowModal() == wxID_CANCEL )
498  return false;
499 
500  fullpath = dlg.GetPath(); // directory + filename
501 
503 
504  if( currPage->m_CommandStringCtrl )
505  m_Parent->SetNetListerCommand( currPage->m_CommandStringCtrl->GetValue() );
506  else
507  m_Parent->SetNetListerCommand( wxEmptyString );
508 
509  if( m_Parent->ReadyToNetlist( _( "Exporting netlist requires a fully annotated schematic." ) ) )
510  m_Parent->WriteNetListFile( currPage->m_IdNetType, fullpath, netlist_opt, nullptr );
511 
513 
514  return true;
515 }
516 
517 
518 bool NETLIST_DIALOG::FilenamePrms( NETLIST_TYPE_ID aType, wxString * aExt, wxString * aWildCard )
519 {
520  wxString fileExt;
521  wxString fileWildcard;
522  bool ret = true;
523 
524  switch( aType )
525  {
526  case NET_TYPE_SPICE:
527  fileExt = wxT( "cir" );
528  fileWildcard = SpiceNetlistFileWildcard();
529  break;
530 
531  case NET_TYPE_CADSTAR:
532  fileExt = wxT( "frp" );
533  fileWildcard = CadstarNetlistFileWildcard();
534  break;
535 
536  case NET_TYPE_PCBNEW:
537  case NET_TYPE_ORCADPCB2:
538  fileExt = NetlistFileExtension;
539  fileWildcard = NetlistFileWildcard();
540  break;
541 
542  default: // custom, NET_TYPE_CUSTOM1 and greater
543  fileWildcard = AllFilesWildcard();
544  ret = false;
545  }
546 
547  if( aExt )
548  *aExt = fileExt;
549 
550  if( aWildCard )
551  *aWildCard = fileWildcard;
552 
553  return ret;
554 }
555 
556 
558 {
559  wxString msg;
560 
562 
563  EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
564  wxASSERT( cfg );
565 
566  if( cfg )
567  {
570 
571  // Update existing custom pages
572  for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ )
573  {
575 
576  if( currPage == nullptr )
577  break;
578 
579  wxString title = currPage->m_TitleStringCtrl->GetValue();
580 
581  if( title.IsEmpty() )
582  continue;
583 
584  cfg->m_NetlistPanel.custom_command_titles.emplace_back( title.ToStdString() );
585  cfg->m_NetlistPanel.custom_command_paths.emplace_back(
586  currPage->m_CommandStringCtrl->GetValue().ToStdString() );
587  }
588  }
589 }
590 
591 
592 void NETLIST_DIALOG::OnDelGenerator( wxCommandEvent& event )
593 {
594  NETLIST_PAGE_DIALOG* currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
595 
596  currPage->m_CommandStringCtrl->SetValue( wxEmptyString );
597  currPage->m_TitleStringCtrl->SetValue( wxEmptyString );
599 
601 
602  if( IsQuasiModal() )
604  else
605  EndDialog( 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 == nullptr )
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  if( IsQuasiModal() )
645  else
646  EndDialog( NET_PLUGIN_CHANGE );
647 }
648 
649 
652 {
653  m_Parent = parent;
654  m_sdbSizerOK->SetDefault();
655  GetSizer()->SetSizeHints( this );
656 }
657 
658 
660 {
661  if( !wxDialog::TransferDataFromWindow() )
662  return false;
663 
664  if( m_textCtrlCommand->GetValue() == wxEmptyString )
665  {
666  wxMessageBox( _( "You must provide a netlist generator command string" ) );
667  return false;
668  }
669 
670  if( m_textCtrlName->GetValue() == wxEmptyString )
671  {
672  wxMessageBox( _( "You must provide a netlist generator title" ) );
673  return false;
674  }
675 
676  return true;
677 }
678 
679 
681 {
682  wxString FullFileName, Path;
683 
684 #ifndef __WXMAC__
685  Path = Pgm().GetExecutablePath();
686 #else
687  Path = PATHS::GetOSXKicadDataDir() + wxT( "/plugins" );
688 #endif
689 
690  FullFileName = wxFileSelector( _( "Generator File" ), Path, FullFileName,
691  wxEmptyString, wxFileSelectorDefaultWildcardStr,
692  wxFD_OPEN, this );
693 
694  if( FullFileName.IsEmpty() )
695  return;
696 
697  // Creates a default command line, suitable for external tool xslproc or python, based on
698  // the plugin extension ("xsl" or "exe" or "py")
699  wxString cmdLine;
700  wxFileName fn( FullFileName );
701  wxString ext = fn.GetExt();
702 
703  if( ext == wxT( "xsl" ) )
704  cmdLine.Printf( wxT( "xsltproc -o \"%%O\" \"%s\" \"%%I\"" ), FullFileName );
705  else if( ext == wxT( "exe" ) || ext.IsEmpty() )
706  cmdLine.Printf( wxT( "\"%s\" > \"%%O\" < \"%%I\"" ), FullFileName );
707  else if( ext == wxT( "py" ) || ext.IsEmpty() )
708  cmdLine.Printf( wxT( "python \"%s\" \"%%I\" \"%%O\"" ), FullFileName );
709  else
710  cmdLine.Printf( wxT( "\"%s\"" ), FullFileName );
711 
712  m_textCtrlCommand->SetValue( cmdLine );
713 
714  /* Get a title for this page */
715  wxString title = m_textCtrlName->GetValue();
716 
717  if( title.IsEmpty() )
718  wxMessageBox( _( "Do not forget to choose a title for this netlist control page" ) );
719 }
720 
721 
723 {
724  NETLIST_DIALOG dlg( aCaller );
725 
726  SCHEMATIC_SETTINGS& settings = aCaller->Schematic().Settings();
727 
728  wxString curr_default_netformat = settings.m_NetFormatName;
729 
730  int ret = dlg.ShowModal();
731 
732  // Update the default netlist and store it in prj config if it was explicitly changed.
733  settings.m_NetFormatName = dlg.m_DefaultNetFmtName; // can have temporary changed
734 
735  if( curr_default_netformat != dlg.m_DefaultNetFmtName )
736  aCaller->SaveProjectSettings();
737 
738  return ret;
739 }
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:167
bool IsQuasiModal() const
Definition: dialog_shim.h:106
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.
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.
SCHEMATIC & Schematic() const
Definition of file extensions used in Kicad.
#define _(s)
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:161
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]
void EndQuasiModal(int retCode)
NETLIST_PAGE_DIALOG * AddOneCustomPage(const wxString &aTitle, const wxString &aCommandString, NETLIST_TYPE_ID aNetTypeId)
see class PGM_BASE
#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()