53#include <wx/checkbox.h>
54#include <wx/filedlg.h>
57#include <wx/txtstrm.h>
62#define CUSTOMPANEL_COUNTMAX 8
166 wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL )
180 aParent->AddPage(
this, aTitle,
false );
182 wxBoxSizer* MainBoxSizer =
new wxBoxSizer( wxVERTICAL );
183 SetSizer( MainBoxSizer );
184 wxBoxSizer* UpperBoxSizer =
new wxBoxSizer( wxHORIZONTAL );
186 MainBoxSizer->Add( UpperBoxSizer, 0, wxEXPAND | wxALL, 5 );
193 UpperBoxSizer->Add(
m_RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
218 wxStaticText* label =
nullptr;
221 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in KiCad format" ) );
226 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in OrcadPCB2 format" ) );
231 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in Allegro format" ) );
236 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in PADS format" ) );
241 label =
new wxStaticText( page, wxID_ANY,
_(
"Export netlist in CadStar format" ) );
248 wxString selectedPageFormatName;
257 { wxID_CANCEL,
_(
"Close" ) } } );
285 if( candidate->GetPageNetFmtName() == selectedPageFormatName )
307 wxStaticText* label =
new wxStaticText( pg, wxID_ANY,
_(
"Export netlist in SPICE format" ) );
308 pg->m_LeftBoxSizer->Add( label, 0, wxBOTTOM, 10 );
311 _(
"Use current sheet as root" ) );
312 pg->m_CurSheetAsRoot->SetToolTip(
_(
"Export netlist only for the current sheet" ) );
314 pg->m_LeftBoxSizer->Add( pg->m_CurSheetAsRoot, 0, wxGROW | wxBOTTOM | wxRIGHT, 5 );
317 pg->m_SaveAllVoltages->SetToolTip(
_(
"Write a directive to save all voltages (.save all)" ) );
319 pg->m_LeftBoxSizer->Add( pg->m_SaveAllVoltages, 0, wxBOTTOM | wxRIGHT, 5 );
322 pg->m_SaveAllCurrents->SetToolTip(
_(
"Write a directive to save all currents (.probe alli)" ) );
324 pg->m_LeftBoxSizer->Add( pg->m_SaveAllCurrents, 0, wxBOTTOM | wxRIGHT, 5 );
327 _(
"Save all power dissipations" ) );
328 pg->m_SaveAllDissipations->SetToolTip(
_(
"Write directives to save power dissipation of all "
329 "items (.probe p(<item>))" ) );
331 pg->m_LeftBoxSizer->Add( pg->m_SaveAllDissipations, 0, wxBOTTOM | wxRIGHT, 5 );
334 _(
"Save all digital event data" ) );
335 pg->m_SaveAllEvents->SetToolTip(
_(
"If not set, write a directive to prevent the saving of "
336 "digital event data (esave none)" ) );
338 pg->m_LeftBoxSizer->Add( pg->m_SaveAllEvents, 0, wxBOTTOM | wxRIGHT, 5 );
342 _(
"Run external simulator command:" ) );
344 pg->m_RunExternalSpiceCommand->SetToolTip(
_(
"Enter the command line to run SPICE\n"
345 "Usually '<path to SPICE binary> \"%I\"'\n"
346 "%I will be replaced by the netlist filepath" ) );
347 pg->m_LowBoxSizer->Add( pg->m_RunExternalSpiceCommand, 0,
348 wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
350 pg->m_CommandStringCtrl =
new wxTextCtrl( pg, -1, simulatorCommand,
351 wxDefaultPosition, wxDefaultSize );
353 pg->m_CommandStringCtrl->SetInsertionPoint( 1 );
354 pg->m_LowBoxSizer->Add( pg->m_CommandStringCtrl, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
361 wxT(
"SPICE Model" ),
367 wxStaticText* label =
new wxStaticText( pg, wxID_ANY,
368 _(
"Export netlist as a SPICE .subckt model" ) );
369 pg->m_LeftBoxSizer->Add( label, 0, wxBOTTOM, 10 );
372 _(
"Use current sheet as root" ) );
373 pg->m_CurSheetAsRoot->SetToolTip(
_(
"Export netlist only for the current sheet" ) );
375 pg->m_LeftBoxSizer->Add( pg->m_CurSheetAsRoot, 0, wxEXPAND | wxBOTTOM | wxRIGHT, 5 );
398 const wxString& aCommandString,
403 pg->
m_LowBoxSizer->Add(
new wxStaticText( pg, wxID_ANY,
_(
"Title:" ) ), 0,
404 wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 5 );
415 pg->
m_LowBoxSizer->Add(
new wxStaticText( pg, wxID_ANY,
_(
"Netlist command:" ) ), 0,
416 wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 5 );
437 bool changed =
false;
494 wxString fileWildcard;
496 wxString title =
_(
"Save Netlist File" );
512 bool runExternalSpiceCommand =
false;
513 unsigned netlist_opt = 0;
572 if( runExternalSpiceCommand )
575 fullpath = fn.GetFullPath();
579 fn.SetExt( fileExt );
581 if( fn.GetPath().IsEmpty() )
582 fn.SetPath( wxPathOnly(
Prj().GetProjectFullName() ) );
584 wxString fullname = fn.GetFullName();
585 wxString
path = fn.GetPath();
588 wxFileDialog dlg(
this, title,
path, fullname, fileWildcard, wxFD_SAVE );
590 if( dlg.ShowModal() == wxID_CANCEL )
593 fullpath = dlg.GetPath();
605 _(
"Exporting netlist requires a fully annotated schematic." ) ) )
610 if( runExternalSpiceCommand )
614 commandLine.Replace( wxS(
"%I" ), fullpath,
true );
615 commandLine.Trim(
true ).Trim(
false );
617 if( !commandLine.IsEmpty() )
619 wxProcess*
process =
new wxProcess( GetEventHandler(), wxID_ANY );
621 wxExecute( commandLine, wxEXEC_ASYNC,
process );
626 std::this_thread::sleep_for( std::chrono::seconds( 1 ) );
628 if(
process->IsInputAvailable() )
630 wxInputStream* in =
process->GetInputStream();
631 wxTextInputStream textstream( *in );
633 while( in->CanRead() )
635 wxString line = textstream.ReadLine();
637 if( !line.IsEmpty() )
642 if(
process->IsErrorAvailable() )
644 wxInputStream* err =
process->GetErrorStream();
645 wxTextInputStream textstream( *err );
647 while( err->CanRead() )
649 wxString line = textstream.ReadLine();
651 if( !line.IsEmpty() )
653 if( line.EndsWith( wxS(
"failed with error 2!" ) ) )
656 reporter.
Report(
_(
"Note: command line is usually: "
657 "<tt><path to SPICE binary> \"%I\"</tt>" ),
660 else if( line.EndsWith( wxS(
"failed with error 8!" ) ) )
662 reporter.
Report(
_(
"external simulator has the wrong format or "
665 else if( line.EndsWith(
"failed with error 13!" ) )
686 return !runExternalSpiceCommand;
693 wxString fileWildcard;
738 *aWildCard = fileWildcard;
759 wxString title = currPage->m_TitleStringCtrl->GetValue();
760 wxString command = currPage->m_CommandStringCtrl->GetValue();
762 if( title.IsEmpty() || command.IsEmpty() )
810 wxMessageBox(
_(
"This plugin already exists." ) );
824 wxMessageBox(
_(
"Maximum number of plugins already added to dialog." ) );
857 if( !wxDialog::TransferDataFromWindow() )
862 wxMessageBox(
_(
"You must provide a netlist generator title" ) );
872 wxString FullFileName, Path;
877 Path = PATHS::GetOSXKicadDataDir() + wxT(
"/plugins" );
880 FullFileName = wxFileSelector(
_(
"Generator File" ), Path, FullFileName,
881 wxEmptyString, wxFileSelectorDefaultWildcardStr,
884 if( FullFileName.IsEmpty() )
890 wxFileName fn( FullFileName );
891 wxString ext = fn.GetExt();
893 if( ext == wxT(
"xsl" ) )
894 cmdLine.Printf( wxT(
"xsltproc -o \"%%O\" \"%s\" \"%%I\"" ), FullFileName );
895 else if( ext == wxT(
"exe" ) || ext.IsEmpty() )
896 cmdLine.Printf( wxT(
"\"%s\" > \"%%O\" < \"%%I\"" ), FullFileName );
897 else if( ext == wxT(
"py" ) || ext.IsEmpty() )
898 cmdLine.Printf( wxT(
"python \"%s\" \"%%I\" \"%%O\"" ), FullFileName );
900 cmdLine.Printf( wxT(
"\"%s\"" ), FullFileName );
915 if( currPage ==
nullptr )
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...
wxWindow * m_initialFocusTarget
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
static std::map< JOB_EXPORT_SCH_NETLIST::FORMAT, wxString > & GetFormatNameMap()
wxString GetSettingsDialogTitle() const override
bool m_spiceSaveAllCurrents
bool m_spiceSaveAllEvents
bool m_spiceSaveAllVoltages
bool m_spiceSaveAllDissipations
void SetConfiguredOutputPath(const wxString &aPath)
Sets the configured output path for the job, this path is always saved to file.
wxString GetConfiguredOutputPath() const
Returns the configured output path for the job.
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
Browse plugin files, and set m_CommandStringCtrl field.
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)
REPORTER & Reporter()
Return the reporter object that reports to this panel.
@ 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.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
std::vector< NETLIST_PLUGIN_SETTINGS > plugins
Definition of file extensions used in Kicad.