Commit b3f13be3 authored by Dick Hollenbeck's avatar Dick Hollenbeck
parent fa863b08
...@@ -230,7 +230,6 @@ class EXPORT_HELP ...@@ -230,7 +230,6 @@ class EXPORT_HELP
*/ */
XNODE* makeGenericLibraries(); XNODE* makeGenericLibraries();
public: public:
/** /**
...@@ -293,9 +292,56 @@ public: ...@@ -293,9 +292,56 @@ public:
*/ */
bool WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f, bool WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f,
bool use_netnames ); bool use_netnames );
/**
* Function MakeCommandLine
* builds up a string that describes a command line for
* executing a child process. The input and output file names
* along with any options to the executable are all possibly
* in the returned string.
*
* @param aFormatString holds:
* <ul>
* <li>the name of the external program
* <li>any options needed by that program
* <li>formatting sequences, see below.
* </ul>
*
* @param aTempfile is the name of an input file to the
* external program.
* @param aFinalFile is the name of an output file that
* the user expects.
*
* <p> Supported formatting sequences and their meaning:
* <ul>
* <li> %B => base filename of selected output file, minus
* path and extension.
* <li> %I => complete filename and path of the temporary
* input file.
* <li> %O => complete filename and path of the user chosen
* output file.
* </ul>
*/
static wxString MakeCommandLine( const wxString& aFormatString,
const wxString& aTempfile, const wxString& aFinalFile );
}; };
wxString EXPORT_HELP::MakeCommandLine( const wxString& aFormatString,
const wxString& aTempfile, const wxString& aFinalFile )
{
wxString ret = aFormatString;
wxFileName in = aTempfile;
wxFileName out = aFinalFile;
ret.Replace( wxT("%B"), out.GetName().GetData(), true );
ret.Replace( wxT("%I"), in.GetFullName().GetData(), true );
ret.Replace( wxT("%O"), out.GetFullName().GetData(), true );
return ret;
}
/** /**
* Function WriteNetListFile * Function WriteNetListFile
* creates the netlist file. Netlist info must be existing * creates the netlist file. Netlist info must be existing
...@@ -356,22 +402,18 @@ bool WinEDA_SchematicFrame::WriteNetListFile( int aFormat, const wxString& aFull ...@@ -356,22 +402,18 @@ bool WinEDA_SchematicFrame::WriteNetListFile( int aFormat, const wxString& aFull
if( !ret ) if( !ret )
break; break;
// Call the external module (plug in ) // If user provided no plugin command line, return now.
if( g_NetListerCommandLine.IsEmpty() ) if( g_NetListerCommandLine.IsEmpty() )
break; break;
wxString commandLine; // build full command line from user's format string, e.g.:
// "xsltproc -o %O /usr/local/lib/kicad/plugins/netlist_form_pads-pcb.xsl %I"
if( wxIsAbsolutePath( g_NetListerCommandLine ) ) // becomes, after the user selects /tmp/s1.net as the output file from the file dialog:
commandLine = g_NetListerCommandLine; // "xsltproc -o /tmp/s1.net /usr/local/lib/kicad/plugins/netlist_form_pads-pcb.xsl /tmp/s1.tmp"
else wxString commandLine = EXPORT_HELP::MakeCommandLine(
commandLine = FindKicadFile( g_NetListerCommandLine ); g_NetListerCommandLine,
tmpFile.GetFullPath(),
// this is the input file to the plugin aFullFileName );
commandLine += wxT( " " ) + tmpFile.GetFullPath();
// this is the output file to the plugin
commandLine += wxT( " " ) + aFullFileName;
ProcessExecute( commandLine, wxEXEC_SYNC ); ProcessExecute( commandLine, wxEXEC_SYNC );
...@@ -1614,7 +1656,7 @@ bool EXPORT_HELP::writeGENERICListOfNets( FILE* f, NETLIST_OBJECT_LIST& aObjects ...@@ -1614,7 +1656,7 @@ bool EXPORT_HELP::writeGENERICListOfNets( FILE* f, NETLIST_OBJECT_LIST& aObjects
/* Generate CADSTAR net list. */ /* Generate CADSTAR net list. */
wxString StartLine( wxT( "." ) ); static wxString StartLine( wxT( "." ) );
void EXPORT_HELP::WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f ) void EXPORT_HELP::WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f )
......
...@@ -445,6 +445,7 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event ) ...@@ -445,6 +445,7 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event )
wxFileName fn; wxFileName fn;
wxString FileWildcard, FileExt; wxString FileWildcard, FileExt;
wxString msg, Command; wxString msg, Command;
wxString title = _( "Save Netlist File" );
NetlistUpdateOpt(); NetlistUpdateOpt();
...@@ -466,15 +467,20 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event ) ...@@ -466,15 +467,20 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event )
FileWildcard = _( "CadStar netlist file (.frp)|*.frp" ); FileWildcard = _( "CadStar netlist file (.frp)|*.frp" );
break; break;
default: case NET_TYPE_PCBNEW:
FileExt = NetlistFileExtension; FileExt = NetlistFileExtension;
FileWildcard = NetlistFileWildcard; FileWildcard = NetlistFileWildcard;
break; break;
default: // custom
FileExt = wxT( "*" );
FileWildcard = AllFilesWildcard;
title = _( "Generic Export" );
} }
fn.SetExt( FileExt ); fn.SetExt( FileExt );
wxFileDialog dlg( this, _( "Save Netlist Files" ), fn.GetPath(), wxFileDialog dlg( this, title, fn.GetPath(),
fn.GetFullName(), FileWildcard, fn.GetFullName(), FileWildcard,
wxFD_SAVE ); wxFD_SAVE );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment