54#include <wx/checkbox.h>
55#include <wx/filedlg.h>
58#include <wx/txtstrm.h>
63#define CUSTOMPANEL_COUNTMAX 8
220 wxPanel( aParent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL )
234 aParent->AddPage(
this, aTitle,
false );
236 wxBoxSizer* MainBoxSizer =
new wxBoxSizer( wxVERTICAL );
237 SetSizer( MainBoxSizer );
238 wxBoxSizer* UpperBoxSizer =
new wxBoxSizer( wxHORIZONTAL );
240 MainBoxSizer->Add( UpperBoxSizer, 0, wxGROW | wxALL, 5 );
247 UpperBoxSizer->Add(
m_RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
264 wxStaticText* label =
nullptr;
267 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in legacy KiCad format" ) );
272 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in OrcadPCB2 format" ) );
277 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in Allegro format" ) );
282 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in PADS format" ) );
287 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in CadStar format" ) );
296 { wxID_CANCEL,
_(
"Close" ) } } );
324 wxStaticText* label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in SPICE format" ) );
328 _(
"Use current sheet as root" ) );
329 page->
m_CurSheetAsRoot->SetToolTip(
_(
"Export netlist only for the current sheet" ) );
334 _(
"Save all voltages" ) );
335 page->
m_SaveAllVoltages->SetToolTip(
_(
"Write a directive to save all voltages (.save all)" ) );
340 _(
"Save all currents" ) );
341 page->
m_SaveAllCurrents->SetToolTip(
_(
"Write a directive to save all currents (.probe alli)" ) );
346 _(
"Save all power dissipations" ) );
347 page->
m_SaveAllDissipations->SetToolTip(
_(
"Write directives to save power dissipation of all items (.probe p(<item>))" ) );
352 _(
"Save all digital event data" ) );
353 page->
m_SaveAllEvents->SetToolTip(
_(
"If not set, write a directive to prevent the saving of digital event data (esave none)" ) );
359 _(
"Run external simulator command:" ) );
362 "Usually '<path to SPICE binary> \"%I\"'\n"
363 "%I will be replaced by the netlist filepath" ) );
365 wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
368 wxDefaultPosition, wxDefaultSize );
372 wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
383 wxStaticText* label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist as a SPICE .subckt model" ) );
387 _(
"Use current sheet as root" ) );
388 page->
m_CurSheetAsRoot->SetToolTip(
_(
"Export netlist only for the current sheet" ) );
413 const wxString& aCommandString,
418 currPage->
m_LowBoxSizer->Add(
new wxStaticText( currPage, -1,
_(
"Title:" ) ), 0,
419 wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
422 wxDefaultPosition, wxDefaultSize );
426 wxGROW | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
428 currPage->
m_LowBoxSizer->Add(
new wxStaticText( currPage, -1,
_(
"Netlist command:" ) ), 0,
429 wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
432 wxDefaultPosition, wxDefaultSize );
436 wxGROW | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
450 bool changed =
false;
488 wxString fileWildcard;
490 wxString title =
_(
"Save Netlist File" );
498 bool runExternalSpiceCommand =
false;
499 unsigned netlist_opt = 0;
560 if( runExternalSpiceCommand )
563 fullpath = fn.GetFullPath();
567 fn.SetExt( fileExt );
569 if( fn.GetPath().IsEmpty() )
570 fn.SetPath( wxPathOnly(
Prj().GetProjectFullName() ) );
572 wxString fullname = fn.GetFullName();
573 wxString
path = fn.GetPath();
576 wxFileDialog dlg(
this, title,
path, fullname, fileWildcard, wxFD_SAVE );
578 if( dlg.ShowModal() == wxID_CANCEL )
581 fullpath = dlg.GetPath();
597 if( runExternalSpiceCommand )
601 commandLine.Replace( wxS(
"%I" ), fullpath,
true );
602 commandLine.Trim(
true ).Trim(
false );
604 if( !commandLine.IsEmpty() )
606 wxProcess*
process =
new wxProcess( GetEventHandler(), wxID_ANY );
608 wxExecute( commandLine, wxEXEC_ASYNC,
process );
613 std::this_thread::sleep_for( std::chrono::seconds( 1 ) );
615 if(
process->IsInputAvailable() )
617 wxInputStream* in =
process->GetInputStream();
618 wxTextInputStream textstream( *in );
620 while( in->CanRead() )
622 wxString line = textstream.ReadLine();
624 if( !line.IsEmpty() )
629 if(
process->IsErrorAvailable() )
631 wxInputStream* err =
process->GetErrorStream();
632 wxTextInputStream textstream( *err );
634 while( err->CanRead() )
636 wxString line = textstream.ReadLine();
638 if( !line.IsEmpty() )
640 if( line.EndsWith( wxS(
"failed with error 2!" ) ) )
643 reporter.
Report(
_(
"Note: command line is usually: "
644 "<tt><path to SPICE binary> \"%I\"</tt>" ),
647 else if( line.EndsWith( wxS(
"failed with error 8!" ) ) )
649 reporter.
Report(
_(
"external simulator has the wrong format or "
652 else if( line.EndsWith(
"failed with error 13!" ) )
673 return !runExternalSpiceCommand;
680 wxString fileWildcard;
725 *aWildCard = fileWildcard;
746 wxString title = currPage->m_TitleStringCtrl->GetValue();
747 wxString command = currPage->m_CommandStringCtrl->GetValue();
749 if( title.IsEmpty() || command.IsEmpty() )
782 if( dlg.ShowModal() != wxID_OK )
793 wxMessageBox(
_(
"This plugin already exists." ) );
807 wxMessageBox(
_(
"Maximum number of plugins already added to dialog." ) );
827 GetSizer()->SetSizeHints(
this );
833 if( !wxDialog::TransferDataFromWindow() )
838 wxMessageBox(
_(
"You must provide a netlist generator command string" ) );
844 wxMessageBox(
_(
"You must provide a netlist generator title" ) );
854 wxString FullFileName, Path;
859 Path = PATHS::GetOSXKicadDataDir() + wxT(
"/plugins" );
862 FullFileName = wxFileSelector(
_(
"Generator File" ), Path, FullFileName,
863 wxEmptyString, wxFileSelectorDefaultWildcardStr,
866 if( FullFileName.IsEmpty() )
872 wxFileName fn( FullFileName );
873 wxString ext = fn.GetExt();
875 if( ext == wxT(
"xsl" ) )
876 cmdLine.Printf( wxT(
"xsltproc -o \"%%O\" \"%s\" \"%%I\"" ), FullFileName );
877 else if( ext == wxT(
"exe" ) || ext.IsEmpty() )
878 cmdLine.Printf( wxT(
"\"%s\" > \"%%O\" < \"%%I\"" ), FullFileName );
879 else if( ext == wxT(
"py" ) || ext.IsEmpty() )
880 cmdLine.Printf( wxT(
"python \"%s\" \"%%I\" \"%%O\"" ), FullFileName );
882 cmdLine.Printf( wxT(
"\"%s\"" ), FullFileName );
897 if( currPage ==
nullptr )
908 int ret = dlg.ShowModal();
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Class DIALOG_EXPORT_NETLIST_BASE.
wxButton * m_buttonDelGenerator
WX_HTML_REPORT_PANEL * m_MessagesBox
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
SCH_EDIT_FRAME * m_Parent
void InstallCustomPages()
void OnAddGenerator(wxCommandEvent &event) override
Add a new panel for a new netlist plugin.
void OnNetlistTypeSelection(wxNotebookEvent &event) override
EXPORT_NETLIST_PAGE * m_PanelNetType[DEFINED_NETLISTS_COUNT+CUSTOMPANEL_COUNTMAX]
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...
void updateGeneratorButtons()
DIALOG_EXPORT_NETLIST(SCH_EDIT_FRAME *parent)
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
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)
@ 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.