53#include <wx/checkbox.h>
54#include <wx/filedlg.h>
57#include <wx/txtstrm.h>
62#define CUSTOMPANEL_COUNTMAX 8
164 wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
177 aParent->AddPage(
this, aTitle,
false );
179 wxBoxSizer* MainBoxSizer =
new wxBoxSizer( wxVERTICAL );
180 SetSizer( MainBoxSizer );
181 wxBoxSizer* UpperBoxSizer =
new wxBoxSizer( wxHORIZONTAL );
183 MainBoxSizer->Add( UpperBoxSizer, 0, wxEXPAND | wxALL, 5 );
190 UpperBoxSizer->Add(
m_RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
213 wxStaticText* label =
nullptr;
216 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in KiCad format" ) );
221 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in OrcadPCB2 format" ) );
226 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in Allegro format" ) );
231 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in CadStar format" ) );
236 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in PADS format" ) );
250 { wxID_CANCEL,
_(
"Close" ) } } );
254 SetTitle(
m_job->GetSettingsDialogTitle() );
293 wxStaticText* label =
new wxStaticText( pg, wxID_ANY,
_(
"Export netlist in SPICE format" ) );
297 pg->
m_CurSheetAsRoot->SetToolTip(
_(
"Export netlist only for the current sheet" ) );
301 pg->
m_SaveAllVoltages->SetToolTip(
_(
"Write a directive to save all voltages (.save all)" ) );
305 pg->
m_SaveAllCurrents->SetToolTip(
_(
"Write a directive to save all currents (.probe alli)" ) );
310 "(.probe p(<item>))" ) );
314 pg->
m_SaveAllEvents->SetToolTip(
_(
"If not set, write a directive to prevent the saving of digital event data "
321 "Usually '<path to SPICE binary> \"%I\"'\n"
322 "%I will be replaced by the netlist filepath" ) );
338 wxStaticText* label =
new wxStaticText( pg, wxID_ANY,
_(
"Export netlist as a SPICE .subckt model" ) );
339 pg->m_LeftBoxSizer->Add( label, 0, wxBOTTOM, 10 );
342 pg->m_CurSheetAsRoot->SetToolTip(
_(
"Export netlist only for the current sheet" ) );
343 pg->m_LeftBoxSizer->Add( pg->m_CurSheetAsRoot, 0, wxEXPAND | wxBOTTOM | wxRIGHT, 5 );
368 const wxString& aCommandString,
373 pg->
m_LowBoxSizer->Add(
new wxStaticText( pg, wxID_ANY,
_(
"Title:" ) ), 0,
374 wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 5 );
385 pg->
m_LowBoxSizer->Add(
new wxStaticText( pg, wxID_ANY,
_(
"Netlist command:" ) ), 0,
386 wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 5 );
408 wxString fileWildcard;
410 wxString title =
_(
"Save Netlist File" );
418 m_job->format = format;
435 bool runExternalSpiceCommand =
false;
436 unsigned netlist_opt = 0;
495 if( runExternalSpiceCommand )
498 fullpath = fn.GetFullPath();
502 fn.SetExt( fileExt );
504 if( fn.GetPath().IsEmpty() )
505 fn.SetPath( wxPathOnly(
Prj().GetProjectFullName() ) );
507 wxString fullname = fn.GetFullName();
508 wxString
path = fn.GetPath();
511 wxFileDialog dlg(
this, title,
path, fullname, fileWildcard, wxFD_SAVE );
513 if( dlg.ShowModal() == wxID_CANCEL )
516 fullpath = dlg.GetPath();
527 if( !
m_editFrame->ReadyToNetlist(
_(
"Exporting netlist requires a fully annotated schematic." ) ) )
532 if( runExternalSpiceCommand )
536 commandLine.Replace( wxS(
"%I" ), fullpath,
true );
537 commandLine.Trim(
true ).Trim(
false );
539 if( !commandLine.IsEmpty() )
541 wxProcess*
process =
new wxProcess( GetEventHandler(), wxID_ANY );
543 wxExecute( commandLine, wxEXEC_ASYNC,
process );
548 std::this_thread::sleep_for( std::chrono::seconds( 1 ) );
550 if(
process->IsInputAvailable() )
552 wxInputStream* in =
process->GetInputStream();
553 wxTextInputStream textstream( *in );
555 while( in->CanRead() )
557 wxString line = textstream.ReadLine();
559 if( !line.IsEmpty() )
564 if(
process->IsErrorAvailable() )
566 wxInputStream* err =
process->GetErrorStream();
567 wxTextInputStream textstream( *err );
569 while( err->CanRead() )
571 wxString line = textstream.ReadLine();
573 if( !line.IsEmpty() )
575 if( line.EndsWith( wxS(
"failed with error 2!" ) ) )
578 reporter.
Report(
_(
"Note: command line is usually: "
579 "<tt><path to SPICE binary> \"%I\"</tt>" ),
582 else if( line.EndsWith( wxS(
"failed with error 8!" ) ) )
584 reporter.
Report(
_(
"external simulator has the wrong format or "
587 else if( line.EndsWith(
"failed with error 13!" ) )
608 return !runExternalSpiceCommand;
615 wxString fileWildcard;
660 *aWildCard = fileWildcard;
678 wxString title = currPage->m_TitleStringCtrl->GetValue();
679 wxString command = currPage->m_CommandStringCtrl->GetValue();
681 if( title.IsEmpty() || command.IsEmpty() )
725 wxMessageBox(
_(
"This plugin already exists." ) );
739 wxMessageBox(
_(
"Maximum number of plugins already added to dialog." ) );
768 if( !wxDialog::TransferDataFromWindow() )
773 wxMessageBox(
_(
"You must provide a netlist generator title" ) );
783 wxString FullFileName, Path;
788 Path = PATHS::GetOSXKicadDataDir() + wxT(
"/plugins" );
791 FullFileName = wxFileSelector(
_(
"Generator File" ), Path, FullFileName, wxEmptyString,
792 wxFileSelectorDefaultWildcardStr, wxFD_OPEN,
this );
794 if( FullFileName.IsEmpty() )
800 wxFileName fn( FullFileName );
801 wxString ext = fn.GetExt();
803 if( ext == wxT(
"xsl" ) )
804 cmdLine.Printf( wxT(
"xsltproc -o \"%%O\" \"%s\" \"%%I\"" ), FullFileName );
805 else if( ext == wxT(
"exe" ) || ext.IsEmpty() )
806 cmdLine.Printf( wxT(
"\"%s\" > \"%%O\" < \"%%I\"" ), FullFileName );
807 else if( ext == wxT(
"py" ) || ext.IsEmpty() )
808 cmdLine.Printf( wxT(
"python \"%s\" \"%%I\" \"%%O\"" ), FullFileName );
810 cmdLine.Printf( wxT(
"\"%s\"" ), FullFileName );
825 if( currPage ==
nullptr )
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
wxStaticText * m_staticTextOutputPath
DIALOG_EXPORT_NETLIST_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Export Netlist"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxButton * m_buttonDelGenerator
WX_HTML_REPORT_PANEL * m_MessagesBox
wxTextCtrl * m_outputPath
wxButton * m_buttonAddGenerator
void OnDelGenerator(wxCommandEvent &event) override
Remove a panel relative to a netlist plugin.
void WriteCurrentNetlistSetup()
Write the current netlist options setup in the configuration.
EXPORT_NETLIST_PAGE * AddOneCustomPage(const wxString &aTitle, const wxString &aCommandString, NETLIST_TYPE_ID aNetTypeId)
void InstallPageSpiceModel()
bool TransferDataFromWindow() override
std::vector< EXPORT_NETLIST_PAGE * > m_PanelNetType
void InstallCustomPages()
SCH_EDIT_FRAME * m_editFrame
JOB_EXPORT_SCH_NETLIST * m_job
void OnAddGenerator(wxCommandEvent &event) override
Add a new panel for a new netlist plugin.
void OnNetlistTypeSelection(wxNotebookEvent &event) override
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...
DIALOG_EXPORT_NETLIST(SCH_EDIT_FRAME *aEditFrame)
void updateGeneratorButtons()
void SetupStandardButtons(std::map< int, wxString > aLabels={})
bool IsQuasiModal() const
void EndQuasiModal(int retCode)
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
wxWindow * m_initialFocusTarget
PANEL_NETLIST m_NetlistPanel
const wxString GetPageNetFmtName()
NETLIST_TYPE_ID m_IdNetType
wxCheckBox * m_SaveAllVoltages
wxString m_pageNetFmtName
wxBoxSizer * m_RightBoxSizer
wxCheckBox * m_CurSheetAsRoot
wxBoxSizer * m_LeftBoxSizer
~EXPORT_NETLIST_PAGE()=default
EXPORT_NETLIST_PAGE(wxNotebook *aParent, const wxString &aTitle, NETLIST_TYPE_ID aIdNetType, bool aCustom)
Create a setup page for one netlist format.
wxCheckBox * m_RunExternalSpiceCommand
wxCheckBox * m_SaveAllEvents
wxCheckBox * m_SaveAllCurrents
wxTextCtrl * m_CommandStringCtrl
wxBoxSizer * m_RightOptionsBoxSizer
wxCheckBox * m_SaveAllDissipations
wxTextCtrl * m_TitleStringCtrl
wxBoxSizer * m_LowBoxSizer
static std::map< JOB_EXPORT_SCH_NETLIST::FORMAT, wxString > & GetFormatNameMap()
APP_SETTINGS_BASE * KifaceSettings() const
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
NETLIST_DIALOG_ADD_GENERATOR_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Add Script-based Netlist Exporter"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxTextCtrl * m_textCtrlCommand
wxTextCtrl * m_textCtrlName
const wxString GetGeneratorTCommandLine()
DIALOG_EXPORT_NETLIST * m_Parent
NETLIST_DIALOG_ADD_GENERATOR(DIALOG_EXPORT_NETLIST *parent)
const wxString GetGeneratorTitle()
void OnBrowseGenerators(wxCommandEvent &event) override
Browse plugin files, and set m_CommandStringCtrl field.
bool TransferDataFromWindow() override
@ OPTION_SAVE_ALL_CURRENTS
@ OPTION_SAVE_ALL_VOLTAGES
@ OPTION_SAVE_ALL_DISSIPATIONS
@ OPTION_CUR_SHEET_AS_ROOT
virtual const wxString & GetExecutablePath() const
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & ReportHead(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Places the report at the beginning of the list for objects that support ordering.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
Schematic editor (Eeschema) main window.
void SaveProjectLocalSettings() override
Save changes to the project settings to the project (.pro) file.
@ ID_SAVE_ALL_DISSIPATIONS
#define CUSTOMPANEL_COUNTMAX
int InvokeDialogNetList(SCH_EDIT_FRAME *aCaller)
@ ID_END_EESCHEMA_ID_LIST
static const std::string CadstarNetlistFileExtension
static const std::string NetlistFileExtension
static const std::string OrCadPcb2NetlistFileExtension
static const std::string SpiceFileExtension
static const std::string PADSNetlistFileExtension
static const std::string AllegroNetlistFileExtension
static wxString SpiceNetlistFileWildcard()
static wxString OrCadPcb2NetlistFileWildcard()
static wxString AllFilesWildcard()
static wxString AllegroNetlistFileWildcard()
static wxString CadstarNetlistFileWildcard()
static wxString PADSNetlistFileWildcard()
static wxString NetlistFileWildcard()
#define NET_PLUGIN_CHANGE
Create and shows DIALOG_EXPORT_NETLIST and returns whatever DIALOG_EXPORT_NETLIST::ShowModal() return...
NETLIST_TYPE_ID
netlist types
static PGM_BASE * process
PGM_BASE & Pgm()
The global program "get" accessor.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
std::vector< NETLIST_PLUGIN_SETTINGS > plugins
Definition of file extensions used in Kicad.