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
219 wxPanel( aParent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL )
233 aParent->AddPage(
this, aTitle,
false );
235 wxBoxSizer* MainBoxSizer =
new wxBoxSizer( wxVERTICAL );
236 SetSizer( MainBoxSizer );
237 wxBoxSizer* UpperBoxSizer =
new wxBoxSizer( wxHORIZONTAL );
239 MainBoxSizer->Add( UpperBoxSizer, 0, wxGROW | wxALL, 5 );
246 UpperBoxSizer->Add(
m_RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
263 wxStaticText* label =
nullptr;
266 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in legacy KiCad format" ) );
271 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in OrcadPCB2 format" ) );
276 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in Allegro format" ) );
281 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in PADS format" ) );
286 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in CadStar format" ) );
295 { wxID_CANCEL,
_(
"Close" ) } } );
320 wxStaticText* label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in SPICE format" ) );
324 _(
"Use current sheet as root" ) );
325 page->
m_CurSheetAsRoot->SetToolTip(
_(
"Export netlist only for the current sheet" ) );
330 _(
"Save all voltages" ) );
331 page->
m_SaveAllVoltages->SetToolTip(
_(
"Write a directive to save all voltages (.save all)" ) );
336 _(
"Save all currents" ) );
337 page->
m_SaveAllCurrents->SetToolTip(
_(
"Write a directive to save all currents (.probe alli)" ) );
342 _(
"Save all power dissipations" ) );
343 page->
m_SaveAllDissipations->SetToolTip(
_(
"Write directives to save power dissipation of all items (.probe p(<item>))" ) );
348 _(
"Save all digital event data" ) );
349 page->
m_SaveAllEvents->SetToolTip(
_(
"If not set, write a directive to prevent the saving of digital event data (esave none)" ) );
355 _(
"Run external simulator command:" ) );
358 "Usually '<path to SPICE binary> \"%I\"'\n"
359 "%I will be replaced by the netlist filepath" ) );
361 wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
364 wxDefaultPosition, wxDefaultSize );
368 wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
379 wxStaticText* label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist as a SPICE .subckt model" ) );
383 _(
"Use current sheet as root" ) );
384 page->
m_CurSheetAsRoot->SetToolTip(
_(
"Export netlist only for the current sheet" ) );
418 const wxString& aCommandString,
423 currPage->
m_LowBoxSizer->Add(
new wxStaticText( currPage, -1,
_(
"Title:" ) ), 0,
424 wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
427 wxDefaultPosition, wxDefaultSize );
431 wxGROW | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
433 currPage->
m_LowBoxSizer->Add(
new wxStaticText( currPage, -1,
_(
"Netlist command:" ) ), 0,
434 wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
437 wxDefaultPosition, wxDefaultSize );
441 wxGROW | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
455 bool changed =
false;
493 wxString fileWildcard;
495 wxString title =
_(
"Save Netlist File" );
503 bool runExternalSpiceCommand =
false;
504 unsigned netlist_opt = 0;
565 if( runExternalSpiceCommand )
568 fullpath = fn.GetFullPath();
572 fn.SetExt( fileExt );
574 if( fn.GetPath().IsEmpty() )
575 fn.SetPath( wxPathOnly(
Prj().GetProjectFullName() ) );
577 wxString fullname = fn.GetFullName();
578 wxString
path = fn.GetPath();
581 wxFileDialog dlg(
this, title,
path, fullname, fileWildcard, wxFD_SAVE );
583 if( dlg.ShowModal() == wxID_CANCEL )
586 fullpath = dlg.GetPath();
602 if( runExternalSpiceCommand )
606 commandLine.Replace( wxS(
"%I" ), fullpath,
true );
607 commandLine.Trim(
true ).Trim(
false );
609 if( !commandLine.IsEmpty() )
611 wxProcess*
process =
new wxProcess( GetEventHandler(), wxID_ANY );
613 wxExecute( commandLine, wxEXEC_ASYNC,
process );
618 std::this_thread::sleep_for( std::chrono::seconds( 1 ) );
620 if(
process->IsInputAvailable() )
622 wxInputStream* in =
process->GetInputStream();
623 wxTextInputStream textstream( *in );
625 while( in->CanRead() )
627 wxString line = textstream.ReadLine();
629 if( !line.IsEmpty() )
634 if(
process->IsErrorAvailable() )
636 wxInputStream* err =
process->GetErrorStream();
637 wxTextInputStream textstream( *err );
639 while( err->CanRead() )
641 wxString line = textstream.ReadLine();
643 if( !line.IsEmpty() )
645 if( line.EndsWith( wxS(
"failed with error 2!" ) ) )
648 reporter.
Report(
_(
"Note: command line is usually: "
649 "<tt><path to SPICE binary> \"%I\"</tt>" ),
652 else if( line.EndsWith( wxS(
"failed with error 8!" ) ) )
654 reporter.
Report(
_(
"external simulator has the wrong format or "
657 else if( line.EndsWith(
"failed with error 13!" ) )
678 return !runExternalSpiceCommand;
685 wxString fileWildcard;
730 *aWildCard = fileWildcard;
754 if( currPage ==
nullptr )
760 if( title.IsEmpty() || command.IsEmpty() )
792 if( dlg.ShowModal() != wxID_OK )
807 if( currPage ==
nullptr )
812 wxMessageBox(
_(
"This plugin already exists.") );
834 GetSizer()->SetSizeHints(
this );
840 if( !wxDialog::TransferDataFromWindow() )
845 wxMessageBox(
_(
"You must provide a netlist generator command string" ) );
851 wxMessageBox(
_(
"You must provide a netlist generator title" ) );
861 wxString FullFileName, Path;
866 Path = PATHS::GetOSXKicadDataDir() + wxT(
"/plugins" );
869 FullFileName = wxFileSelector(
_(
"Generator File" ), Path, FullFileName,
870 wxEmptyString, wxFileSelectorDefaultWildcardStr,
873 if( FullFileName.IsEmpty() )
879 wxFileName fn( FullFileName );
880 wxString ext = fn.GetExt();
882 if( ext == wxT(
"xsl" ) )
883 cmdLine.Printf( wxT(
"xsltproc -o \"%%O\" \"%s\" \"%%I\"" ), FullFileName );
884 else if( ext == wxT(
"exe" ) || ext.IsEmpty() )
885 cmdLine.Printf( wxT(
"\"%s\" > \"%%O\" < \"%%I\"" ), FullFileName );
886 else if( ext == wxT(
"py" ) || ext.IsEmpty() )
887 cmdLine.Printf( wxT(
"python \"%s\" \"%%I\" \"%%O\"" ), FullFileName );
889 cmdLine.Printf( wxT(
"\"%s\"" ), FullFileName );
904 if( currPage ==
nullptr )
915 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 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.