51#include <wx/checkbox.h>
52#include <wx/filedlg.h>
55#include <wx/txtstrm.h>
60#define CUSTOMPANEL_COUNTMAX 8
82#define DEFINED_NETLISTS_COUNT 6
217 wxPanel( aParent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL )
230 aParent->AddPage(
this, aTitle,
false );
232 wxBoxSizer* MainBoxSizer =
new wxBoxSizer( wxVERTICAL );
233 SetSizer( MainBoxSizer );
234 wxBoxSizer* UpperBoxSizer =
new wxBoxSizer( wxHORIZONTAL );
236 MainBoxSizer->Add( UpperBoxSizer, 0, wxGROW | wxALL, 5 );
243 UpperBoxSizer->Add(
m_RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
260 wxStaticText* label =
nullptr;
263 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in legacy KiCad format" ) );
268 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in OrcadPCB2 format" ) );
273 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in Allegro format" ) );
278 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in PADS format" ) );
283 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in CadStar format" ) );
292 { wxID_CANCEL,
_(
"Close" ) } } );
317 wxStaticText* label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in SPICE format" ) );
321 _(
"Use current sheet as root" ) );
322 page->
m_CurSheetAsRoot->SetToolTip(
_(
"Export netlist only for the current sheet" ) );
327 _(
"Save all voltages" ) );
328 page->
m_SaveAllVoltages->SetToolTip(
_(
"Write a directive to save all voltages (.save all)" ) );
333 _(
"Save all currents" ) );
334 page->
m_SaveAllCurrents->SetToolTip(
_(
"Write a directive to save all currents (.probe alli)" ) );
339 _(
"Save all power dissipations" ) );
340 page->
m_SaveAllDissipations->SetToolTip(
_(
"Write directives to save power dissipation of all items (.probe p(<item>))" ) );
346 _(
"Run external simulator command:" ) );
349 "Usually '<path to SPICE binary> \"%I\"'\n"
350 "%I will be replaced by the netlist filepath" ) );
352 wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
355 wxDefaultPosition, wxDefaultSize );
359 wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
370 wxStaticText* label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist as a SPICE .subckt model" ) );
374 _(
"Use current sheet as root" ) );
375 page->
m_CurSheetAsRoot->SetToolTip(
_(
"Export netlist only for the current sheet" ) );
409 const wxString& aCommandString,
414 currPage->
m_LowBoxSizer->Add(
new wxStaticText( currPage, -1,
_(
"Title:" ) ), 0,
415 wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
418 wxDefaultPosition, wxDefaultSize );
422 wxGROW | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
424 currPage->
m_LowBoxSizer->Add(
new wxStaticText( currPage, -1,
_(
"Netlist command:" ) ), 0,
425 wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
428 wxDefaultPosition, wxDefaultSize );
432 wxGROW | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
446 bool changed =
false;
481 wxString fileWildcard;
483 wxString title =
_(
"Save Netlist File" );
491 bool runExternalSpiceCommand =
false;
492 unsigned netlist_opt = 0;
550 if( runExternalSpiceCommand )
553 fullpath = fn.GetFullPath();
557 fn.SetExt( fileExt );
559 if( fn.GetPath().IsEmpty() )
560 fn.SetPath( wxPathOnly(
Prj().GetProjectFullName() ) );
562 wxString fullname = fn.GetFullName();
563 wxString
path = fn.GetPath();
566 wxFileDialog dlg(
this, title,
path, fullname, fileWildcard, wxFD_SAVE );
568 if( dlg.ShowModal() == wxID_CANCEL )
571 fullpath = dlg.GetPath();
587 if( runExternalSpiceCommand )
591 commandLine.Replace( wxS(
"%I" ), fullpath,
true );
592 commandLine.Trim(
true ).Trim(
false );
594 if( !commandLine.IsEmpty() )
596 wxProcess*
process =
new wxProcess( GetEventHandler(), wxID_ANY );
598 wxExecute( commandLine, wxEXEC_ASYNC,
process );
603 std::this_thread::sleep_for( std::chrono::seconds( 1 ) );
605 if(
process->IsInputAvailable() )
607 wxInputStream* in =
process->GetInputStream();
608 wxTextInputStream textstream( *in );
610 while( in->CanRead() )
612 wxString line = textstream.ReadLine();
614 if( !line.IsEmpty() )
619 if(
process->IsErrorAvailable() )
621 wxInputStream* err =
process->GetErrorStream();
622 wxTextInputStream textstream( *err );
624 while( err->CanRead() )
626 wxString line = textstream.ReadLine();
628 if( !line.IsEmpty() )
630 if( line.EndsWith( wxS(
"failed with error 2!" ) ) )
633 reporter.
Report(
_(
"Note: command line is usually: "
634 "<tt><path to SPICE binary> \"%I\"</tt>" ),
637 else if( line.EndsWith( wxS(
"failed with error 8!" ) ) )
639 reporter.
Report(
_(
"external simulator has the wrong format or "
642 else if( line.EndsWith(
"failed with error 13!" ) )
663 return !runExternalSpiceCommand;
670 wxString fileWildcard;
715 *aWildCard = fileWildcard;
739 if( currPage ==
nullptr )
745 if( title.IsEmpty() || command.IsEmpty() )
777 if( dlg.ShowModal() != wxID_OK )
792 if( currPage ==
nullptr )
797 wxMessageBox(
_(
"This plugin already exists.") );
819 GetSizer()->SetSizeHints(
this );
825 if( !wxDialog::TransferDataFromWindow() )
830 wxMessageBox(
_(
"You must provide a netlist generator command string" ) );
836 wxMessageBox(
_(
"You must provide a netlist generator title" ) );
846 wxString FullFileName, Path;
851 Path = PATHS::GetOSXKicadDataDir() + wxT(
"/plugins" );
854 FullFileName = wxFileSelector(
_(
"Generator File" ), Path, FullFileName,
855 wxEmptyString, wxFileSelectorDefaultWildcardStr,
858 if( FullFileName.IsEmpty() )
864 wxFileName fn( FullFileName );
865 wxString ext = fn.GetExt();
867 if( ext == wxT(
"xsl" ) )
868 cmdLine.Printf( wxT(
"xsltproc -o \"%%O\" \"%s\" \"%%I\"" ), FullFileName );
869 else if( ext == wxT(
"exe" ) || ext.IsEmpty() )
870 cmdLine.Printf( wxT(
"\"%s\" > \"%%O\" < \"%%I\"" ), FullFileName );
871 else if( ext == wxT(
"py" ) || ext.IsEmpty() )
872 cmdLine.Printf( wxT(
"python \"%s\" \"%%I\" \"%%O\"" ), FullFileName );
874 cmdLine.Printf( wxT(
"\"%s\"" ), FullFileName );
889 if( currPage ==
nullptr )
900 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_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 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
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.