54#include <wx/checkbox.h>
55#include <wx/filedlg.h>
58#include <wx/txtstrm.h>
63#define CUSTOMPANEL_COUNTMAX 8
176 wxPanel( aParent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL )
190 aParent->AddPage(
this, aTitle,
false );
192 wxBoxSizer* MainBoxSizer =
new wxBoxSizer( wxVERTICAL );
193 SetSizer( MainBoxSizer );
194 wxBoxSizer* UpperBoxSizer =
new wxBoxSizer( wxHORIZONTAL );
196 MainBoxSizer->Add( UpperBoxSizer, 0, wxGROW | wxALL, 5 );
203 UpperBoxSizer->Add(
m_RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
229 wxStaticText* label =
nullptr;
232 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in legacy KiCad format" ) );
237 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in OrcadPCB2 format" ) );
242 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in Allegro format" ) );
247 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in PADS format" ) );
252 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in CadStar format" ) );
259 wxString selectedPageFormatName;
267 { wxID_CANCEL,
_(
"Close" ) } } );
277 { wxID_CANCEL,
_(
"Close" ) } } );
283 selectedPageFormatName = it->second;
293 if( candidate->GetPageNetFmtName() == selectedPageFormatName )
315 wxStaticText* label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in SPICE format" ) );
319 _(
"Use current sheet as root" ) );
320 page->
m_CurSheetAsRoot->SetToolTip(
_(
"Export netlist only for the current sheet" ) );
325 _(
"Save all voltages" ) );
326 page->
m_SaveAllVoltages->SetToolTip(
_(
"Write a directive to save all voltages (.save all)" ) );
331 _(
"Save all currents" ) );
332 page->
m_SaveAllCurrents->SetToolTip(
_(
"Write a directive to save all currents (.probe alli)" ) );
337 _(
"Save all power dissipations" ) );
338 page->
m_SaveAllDissipations->SetToolTip(
_(
"Write directives to save power dissipation of all items (.probe p(<item>))" ) );
343 _(
"Save all digital event data" ) );
344 page->
m_SaveAllEvents->SetToolTip(
_(
"If not set, write a directive to prevent the saving of digital event data (esave none)" ) );
350 _(
"Run external simulator command:" ) );
353 "Usually '<path to SPICE binary> \"%I\"'\n"
354 "%I will be replaced by the netlist filepath" ) );
356 wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
359 wxDefaultPosition, wxDefaultSize );
363 wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
374 wxStaticText* label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist as a SPICE .subckt model" ) );
378 _(
"Use current sheet as root" ) );
379 page->
m_CurSheetAsRoot->SetToolTip(
_(
"Export netlist only for the current sheet" ) );
404 const wxString& aCommandString,
409 currPage->
m_LowBoxSizer->Add(
new wxStaticText( currPage, -1,
_(
"Title:" ) ), 0,
410 wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
413 wxDefaultPosition, wxDefaultSize );
417 wxGROW | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
419 currPage->
m_LowBoxSizer->Add(
new wxStaticText( currPage, -1,
_(
"Netlist command:" ) ), 0,
420 wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
423 wxDefaultPosition, wxDefaultSize );
427 wxGROW | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
441 bool changed =
false;
498 wxString fileWildcard;
500 wxString title =
_(
"Save Netlist File" );
518 bool runExternalSpiceCommand =
false;
519 unsigned netlist_opt = 0;
580 if( runExternalSpiceCommand )
583 fullpath = fn.GetFullPath();
587 fn.SetExt( fileExt );
589 if( fn.GetPath().IsEmpty() )
590 fn.SetPath( wxPathOnly(
Prj().GetProjectFullName() ) );
592 wxString fullname = fn.GetFullName();
593 wxString
path = fn.GetPath();
596 wxFileDialog dlg(
this, title,
path, fullname, fileWildcard, wxFD_SAVE );
598 if( dlg.ShowModal() == wxID_CANCEL )
601 fullpath = dlg.GetPath();
613 _(
"Exporting netlist requires a fully annotated schematic." ) ) )
618 if( runExternalSpiceCommand )
622 commandLine.Replace( wxS(
"%I" ), fullpath,
true );
623 commandLine.Trim(
true ).Trim(
false );
625 if( !commandLine.IsEmpty() )
627 wxProcess*
process =
new wxProcess( GetEventHandler(), wxID_ANY );
629 wxExecute( commandLine, wxEXEC_ASYNC,
process );
634 std::this_thread::sleep_for( std::chrono::seconds( 1 ) );
636 if(
process->IsInputAvailable() )
638 wxInputStream* in =
process->GetInputStream();
639 wxTextInputStream textstream( *in );
641 while( in->CanRead() )
643 wxString line = textstream.ReadLine();
645 if( !line.IsEmpty() )
650 if(
process->IsErrorAvailable() )
652 wxInputStream* err =
process->GetErrorStream();
653 wxTextInputStream textstream( *err );
655 while( err->CanRead() )
657 wxString line = textstream.ReadLine();
659 if( !line.IsEmpty() )
661 if( line.EndsWith( wxS(
"failed with error 2!" ) ) )
664 reporter.
Report(
_(
"Note: command line is usually: "
665 "<tt><path to SPICE binary> \"%I\"</tt>" ),
668 else if( line.EndsWith( wxS(
"failed with error 8!" ) ) )
670 reporter.
Report(
_(
"external simulator has the wrong format or "
673 else if( line.EndsWith(
"failed with error 13!" ) )
694 return !runExternalSpiceCommand;
701 wxString fileWildcard;
746 *aWildCard = fileWildcard;
767 wxString title = currPage->m_TitleStringCtrl->GetValue();
768 wxString command = currPage->m_CommandStringCtrl->GetValue();
770 if( title.IsEmpty() || command.IsEmpty() )
803 if( dlg.ShowModal() != wxID_OK )
814 wxMessageBox(
_(
"This plugin already exists." ) );
828 wxMessageBox(
_(
"Maximum number of plugins already added to dialog." ) );
848 GetSizer()->SetSizeHints(
this );
854 if( !wxDialog::TransferDataFromWindow() )
859 wxMessageBox(
_(
"You must provide a netlist generator command string" ) );
865 wxMessageBox(
_(
"You must provide a netlist generator title" ) );
875 wxString FullFileName, Path;
880 Path = PATHS::GetOSXKicadDataDir() + wxT(
"/plugins" );
883 FullFileName = wxFileSelector(
_(
"Generator File" ), Path, FullFileName,
884 wxEmptyString, wxFileSelectorDefaultWildcardStr,
887 if( FullFileName.IsEmpty() )
893 wxFileName fn( FullFileName );
894 wxString ext = fn.GetExt();
896 if( ext == wxT(
"xsl" ) )
897 cmdLine.Printf( wxT(
"xsltproc -o \"%%O\" \"%s\" \"%%I\"" ), FullFileName );
898 else if( ext == wxT(
"exe" ) || ext.IsEmpty() )
899 cmdLine.Printf( wxT(
"\"%s\" > \"%%O\" < \"%%I\"" ), FullFileName );
900 else if( ext == wxT(
"py" ) || ext.IsEmpty() )
901 cmdLine.Printf( wxT(
"python \"%s\" \"%%I\" \"%%O\"" ), FullFileName );
903 cmdLine.Printf( wxT(
"\"%s\"" ), FullFileName );
918 if( currPage ==
nullptr )
929 int ret = dlg.ShowModal();
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Class DIALOG_EXPORT_NETLIST_BASE.
wxStaticText * m_staticTextOutputPath
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...
virtual void ClearMsgPanel()
Clear all messages from the message panel.
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(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
bool m_spiceSaveAllCurrents
bool m_spiceSaveAllEvents
bool m_spiceSaveAllVoltages
bool m_spiceSaveAllDissipations
void SetOutputPath(const wxString &aPath)
wxString GetOutputPath() const
APP_SETTINGS_BASE * KifaceSettings() const
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Class NETLIST_DIALOG_ADD_GENERATOR_BASE.
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
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)=0
Report a string with a given severity.
These are loaded from Eeschema settings but then overwritten by the project settings.
bool m_SpiceCurSheetAsRoot
bool m_SpiceSaveAllCurrents
bool m_SpiceSaveAllDissipations
bool m_SpiceSaveAllVoltages
bool m_SpiceSaveAllEvents
bool m_SpiceModelCurSheetAsRoot
wxString m_SpiceCommandString
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
SCHEMATIC_SETTINGS & Settings() const
Schematic editor (Eeschema) main window.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
void SaveProjectLocalSettings() override
Save changes to the project settings to the project (.pro) file.
bool ReadyToNetlist(const wxString &aAnnotateMessage)
Check if we are ready to write a netlist file for the current schematic.
bool WriteNetListFile(int aFormat, const wxString &aFullFileName, unsigned aNetlistOptions, REPORTER *aReporter=nullptr)
Create a netlist file.
SCHEMATIC & Schematic() const
void SetNetListerCommand(const wxString &aCommand)
std::map< JOB_EXPORT_SCH_NETLIST::FORMAT, wxString > jobNetlistNameLookup
@ 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.
std::vector< NETLIST_PLUGIN_SETTINGS > plugins
Definition of file extensions used in Kicad.