51#include <wx/checkbox.h>
52#include <wx/filedlg.h>
55#include <wx/txtstrm.h>
60#define CUSTOMPANEL_COUNTMAX 8
81#define DEFINED_NETLISTS_COUNT 6
216 wxPanel( aParent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL )
229 aParent->AddPage(
this, aTitle,
false );
231 wxBoxSizer* MainBoxSizer =
new wxBoxSizer( wxVERTICAL );
232 SetSizer( MainBoxSizer );
233 wxBoxSizer* UpperBoxSizer =
new wxBoxSizer( wxHORIZONTAL );
235 MainBoxSizer->Add( UpperBoxSizer, 0, wxGROW | wxALL, 5 );
242 UpperBoxSizer->Add(
m_RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
275 { wxID_CANCEL,
_(
"Close" ) } } );
301 _(
"Use current sheet as root" ) );
302 page->
m_CurSheetAsRoot->SetToolTip(
_(
"Export netlist only for the current sheet" ) );
307 _(
"Save all voltages" ) );
308 page->
m_SaveAllVoltages->SetToolTip(
_(
"Write a directive to save all voltages (.save all)" ) );
313 _(
"Save all currents" ) );
314 page->
m_SaveAllCurrents->SetToolTip(
_(
"Write a directive to save all currents (.probe alli)" ) );
319 _(
"Save all power dissipations" ) );
320 page->
m_SaveAllDissipations->SetToolTip(
_(
"Write directives to save power dissipation of all items (.probe p(<item>))" ) );
326 _(
"Run external simulator command:" ) );
329 "Usually '<path to SPICE binary> \"%I\"'\n"
330 "%I will be replaced by the netlist filepath" ) );
332 wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
335 wxDefaultPosition, wxDefaultSize );
339 wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
351 _(
"Use current sheet as root" ) );
352 page->
m_CurSheetAsRoot->SetToolTip(
_(
"Export netlist only for the current sheet" ) );
386 const wxString& aCommandString,
391 currPage->
m_LowBoxSizer->Add(
new wxStaticText( currPage, -1,
_(
"Title:" ) ), 0,
392 wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
395 wxDefaultPosition, wxDefaultSize );
399 wxGROW | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
401 currPage->
m_LowBoxSizer->Add(
new wxStaticText( currPage, -1,
_(
"Netlist command:" ) ), 0,
402 wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
405 wxDefaultPosition, wxDefaultSize );
409 wxGROW | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
423 bool changed =
false;
458 wxString fileWildcard;
460 wxString title =
_(
"Save Netlist File" );
468 bool runExternalSpiceCommand =
false;
469 unsigned netlist_opt = 0;
524 if( runExternalSpiceCommand )
527 fullpath = fn.GetFullPath();
531 fn.SetExt( fileExt );
533 if( fn.GetPath().IsEmpty() )
534 fn.SetPath( wxPathOnly(
Prj().GetProjectFullName() ) );
536 wxString fullname = fn.GetFullName();
537 wxString
path = fn.GetPath();
540 wxFileDialog dlg(
this, title,
path, fullname, fileWildcard, wxFD_SAVE );
542 if( dlg.ShowModal() == wxID_CANCEL )
545 fullpath = dlg.GetPath();
561 if( runExternalSpiceCommand )
565 commandLine.Replace( wxS(
"%I" ), fullpath,
true );
566 commandLine.Trim(
true ).Trim(
false );
568 if( !commandLine.IsEmpty() )
570 wxProcess*
process =
new wxProcess( GetEventHandler(), wxID_ANY );
572 wxExecute( commandLine, wxEXEC_ASYNC,
process );
577 std::this_thread::sleep_for( std::chrono::seconds( 1 ) );
579 if(
process->IsInputAvailable() )
581 wxInputStream* in =
process->GetInputStream();
582 wxTextInputStream textstream( *in );
584 while( in->CanRead() )
586 wxString line = textstream.ReadLine();
588 if( !line.IsEmpty() )
593 if(
process->IsErrorAvailable() )
595 wxInputStream* err =
process->GetErrorStream();
596 wxTextInputStream textstream( *err );
598 while( err->CanRead() )
600 wxString line = textstream.ReadLine();
602 if( !line.IsEmpty() )
604 if( line.EndsWith( wxS(
"failed with error 2!" ) ) )
607 reporter.
Report(
_(
"Note: command line is usually: "
608 "<tt><path to SPICE binary> \"%I\"</tt>" ),
611 else if( line.EndsWith( wxS(
"failed with error 8!" ) ) )
613 reporter.
Report(
_(
"external simulator has the wrong format or "
616 else if( line.EndsWith(
"failed with error 13!" ) )
637 return !runExternalSpiceCommand;
644 wxString fileWildcard;
683 *aWildCard = fileWildcard;
707 if( currPage ==
nullptr )
713 if( title.IsEmpty() || command.IsEmpty() )
745 if( dlg.ShowModal() != wxID_OK )
760 if( currPage ==
nullptr )
765 wxMessageBox(
_(
"This plugin already exists.") );
787 GetSizer()->SetSizeHints(
this );
793 if( !wxDialog::TransferDataFromWindow() )
798 wxMessageBox(
_(
"You must provide a netlist generator command string" ) );
804 wxMessageBox(
_(
"You must provide a netlist generator title" ) );
814 wxString FullFileName, Path;
817 Path =
Pgm().GetExecutablePath();
819 Path = PATHS::GetOSXKicadDataDir() + wxT(
"/plugins" );
822 FullFileName = wxFileSelector(
_(
"Generator File" ), Path, FullFileName,
823 wxEmptyString, wxFileSelectorDefaultWildcardStr,
826 if( FullFileName.IsEmpty() )
832 wxFileName fn( FullFileName );
833 wxString ext = fn.GetExt();
835 if( ext == wxT(
"xsl" ) )
836 cmdLine.Printf( wxT(
"xsltproc -o \"%%O\" \"%s\" \"%%I\"" ), FullFileName );
837 else if( ext == wxT(
"exe" ) || ext.IsEmpty() )
838 cmdLine.Printf( wxT(
"\"%s\" > \"%%O\" < \"%%I\"" ), FullFileName );
839 else if( ext == wxT(
"py" ) || ext.IsEmpty() )
840 cmdLine.Printf( wxT(
"python \"%s\" \"%%I\" \"%%O\"" ), FullFileName );
842 cmdLine.Printf( wxT(
"\"%s\"" ), FullFileName );
857 if( currPage ==
nullptr )
868 int ret = dlg.ShowModal();
static PGM_BASE * process
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_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
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 settings were stored in SCH_BASE_FRAME previously.
bool m_SpiceCurSheetAsRoot
bool m_SpiceSaveAllCurrents
bool m_SpiceSaveAllDissipations
bool m_SpiceSaveAllVoltages
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 DEFINED_NETLISTS_COUNT
#define CUSTOMPANEL_COUNTMAX
int InvokeDialogNetList(SCH_EDIT_FRAME *aCaller)
@ ID_END_EESCHEMA_ID_LIST
const std::string SpiceFileExtension
const std::string CadstarNetlistFileExtension
const std::string NetlistFileExtension
const std::string OrCadPcb2NetlistFileExtension
const std::string AllegroNetlistFileExtension
wxString NetlistFileWildcard()
wxString OrCadPcb2NetlistFileWildcard()
wxString CadstarNetlistFileWildcard()
wxString AllFilesWildcard()
wxString SpiceNetlistFileWildcard()
wxString AllegroNetlistFileWildcard()
#define NET_PLUGIN_CHANGE
Create and shows DIALOG_EXPORT_NETLIST and returns whatever DIALOG_EXPORT_NETLIST::ShowModal() return...
NETLIST_TYPE_ID
netlist types
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
std::vector< NETLIST_PLUGIN_SETTINGS > plugins
Definition of file extensions used in Kicad.