From a27777996ad3170a386da3003620a2521c5f76fa Mon Sep 17 00:00:00 2001 From: Wolfgang Spraul Date: Wed, 11 Jan 2012 00:28:19 +0100 Subject: [PATCH] uplevel cmdline patches (entire set won't build right now) --- kicad-cmdline-testing/kicmd_test.sh | 64 +- kicad-patches/TODO | 13 +- kicad-patches/cmdline-common.patch | 102 ++++ kicad-patches/cmdline-eeschema.patch | 158 +++++ kicad-patches/cmdline-new.patch | 791 ++++++++++++++++++++++++ kicad-patches/cmdline-pcbnew.patch | 183 ++++++ kicad-patches/scripted-common.patch | 79 --- kicad-patches/scripted-eeschema.patch | 105 ---- kicad-patches/scripted-new.patch | 825 -------------------------- kicad-patches/scripted-pcbnew.patch | 158 ----- kicad-patches/series | 12 +- 11 files changed, 1280 insertions(+), 1210 deletions(-) create mode 100644 kicad-patches/cmdline-common.patch create mode 100644 kicad-patches/cmdline-eeschema.patch create mode 100644 kicad-patches/cmdline-new.patch create mode 100644 kicad-patches/cmdline-pcbnew.patch delete mode 100644 kicad-patches/scripted-common.patch delete mode 100644 kicad-patches/scripted-eeschema.patch delete mode 100644 kicad-patches/scripted-new.patch delete mode 100644 kicad-patches/scripted-pcbnew.patch diff --git a/kicad-cmdline-testing/kicmd_test.sh b/kicad-cmdline-testing/kicmd_test.sh index a558bbd..aaa9fae 100755 --- a/kicad-cmdline-testing/kicmd_test.sh +++ b/kicad-cmdline-testing/kicmd_test.sh @@ -67,15 +67,34 @@ if [ "$1" == "test" ]; then $EESCHEMA --netlist atusb.sch ls -la *.net echo ----- + echo Displaying pcbnew help text: $PCBNEW --help echo ----- + echo Listing enabled layers: + $PCBNEW --list-layers atusb.brd + echo ----- echo Generating .drl drill files: $PCBNEW --drill atusb.brd ls -la *.drl echo ----- - echo Listing enabled layers: - $PCBNEW --list-layers atusb.brd + # We are currently not testing options affecting plotting operation + # such as --layers --plot-mirror and others. + echo Plotting GERBER: + $PCBNEW --plot=gerber atusb.brd + ls -la *.{gbr,gba,gbs,gbo,gts} + echo ----- + echo Plotting Postscript: + $PCBNEW --plot=ps atusb.brd + ls -la *.ps + echo ----- + echo Plotting DXF: + $PCBNEW --plot=dxf atusb.brd + ls -la *.dxf + echo ----- + echo Plotting SVG: + $PCBNEW --svg=selected atusb.brd + ls -la *.svg echo ----- echo Generating .rpt design rule file: $PCBNEW --drc atusb.brd @@ -97,33 +116,6 @@ if [ "$1" == "test" ]; then $PCBNEW --vrml atusb.brd ls -la *.wrl echo ----- - - # We are currently not testing options affecting plotting operation - # such as --layers --mirror --exlude-pcb-edge --fill-all-zones - echo Plotting GERBER: - $PCBNEW --plot=gerber atusb.brd - ls -la *.{gbr,gba,gbs,gbo,gts} - echo ----- - echo Plotting HPGL: - $PCBNEW --plot=hpgl atusb.brd - ls -la *.plt - echo ----- - echo Plotting Postscript \(A4\): - $PCBNEW --plot=ps_a4 atusb.brd - ls -la *.ps - echo ----- - echo Plotting Postscript: - $PCBNEW --plot=ps atusb.brd - ls -la *.ps - echo ----- - echo Plotting DXF: - $PCBNEW --plot=dxf atusb.brd - ls -la *.dxf - echo ----- - echo Plotting SVG: - $PCBNEW --svg atusb.brd - ls -la *.svg - echo ----- cd ../.. exit fi @@ -145,12 +137,16 @@ if [ "$1" == "clean" ]; then atusb.cmp \ atusb.csv \ atusb.wrl \ - atusb-Back.gbr atusb-Comments.gbr atusb-Drawings.gbr atusb-Front.gba \ - atusb-Mask_Back.gts atusb-Mask_Front.gbr atusb-PCB_Edges.gbr \ - atusb-SilkS_Front.gbs atusb-SoldP_Front.gbo + atusb-Front.{gba,ps,dxf,svg} \ + atusb-Back.{gbr,ps,dxf,svg} \ + atusb-Comments.{gbr,ps,dxf} \ + atusb-Drawings.{gbr,ps,dxf} \ + atusb-Mask_Front.{gbr,ps,dxf} \ + atusb-Mask_Back.{gts,ps,dxf} \ + atusb-PCB_Edges.{gbr,ps,dxf} \ + atusb-SilkS_Front.{gbs,ps,dxf,svg} \ + atusb-SoldP_Front.{gbo,ps,dxf} rmdir shapes3D cd ../.. exit fi - -usage diff --git a/kicad-patches/TODO b/kicad-patches/TODO index 3ef06fe..52f1846 100644 --- a/kicad-patches/TODO +++ b/kicad-patches/TODO @@ -1,3 +1,10 @@ -* running eeschema --bom will permanently change the background color - to black (until it's restored manually in the preferences) -* start offering scripted patches upstream +* start upstreaming cmdline patches + +* pcbnew --plot doesn't pick up global clearance settings, so we end up + with the hard-coded defaults. See Preferences -> Dimensions -> Pads + Mask Clearance. It is not quite clear whether settings are stored in + the .pro or .brd files, there seems to be a difference depending on + whether the .brd file is opened directly via pcbnew, or via the kicad + binary and .pro file. Some values are in the .brd file but it's not clear + how they can be changed from the GUI. These values need to come from the + .brd file, cannot be passed in via the command line. diff --git a/kicad-patches/cmdline-common.patch b/kicad-patches/cmdline-common.patch new file mode 100644 index 0000000..af0f2ee --- /dev/null +++ b/kicad-patches/cmdline-common.patch @@ -0,0 +1,102 @@ +diff -ru kicad.orig/common/confirm.cpp kicad/common/confirm.cpp +--- kicad.orig/common/confirm.cpp 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/common/confirm.cpp 2012-01-04 00:59:04.412020890 +0100 +@@ -9,11 +9,18 @@ + #include "wx/html/htmlwin.h" + #include "html_messagebox.h" + ++bool g_CmdLineMode = false; + + void DisplayError( wxWindow* parent, const wxString& text, int displaytime ) + { + wxMessageDialog* dialog; + ++ if (g_CmdLineMode) ++ { ++ wxFprintf( stderr, text + _( "\n" ) ); ++ return; ++ } ++ + if( displaytime > 0 ) + dialog = new wxMessageDialog( parent, text, _( "Warning" ), + wxOK | wxCENTRE | wxICON_INFORMATION ); +@@ -30,6 +37,12 @@ + { + wxMessageDialog* dialog; + ++ if (g_CmdLineMode) ++ { ++ wxPrintf( text + _( "\n" ) ); ++ return; ++ } ++ + dialog = new wxMessageDialog( parent, text, _( "Info:" ), + wxOK | wxCENTRE | wxICON_INFORMATION ); + +@@ -41,6 +54,12 @@ + void DisplayHtmlInfoMessage( wxWindow* parent, const wxString& title, + const wxString& text, const wxSize& size ) + { ++ if (g_CmdLineMode) ++ { ++ wxPrintf( title + _( "\n" ) + text + _( "\n" ) ); ++ return; ++ } ++ + HTML_MESSAGE_BOX *dlg = new HTML_MESSAGE_BOX(parent,title, wxDefaultPosition, size ); + dlg->AddHTML_Text( text ); + dlg->ShowModal(); +diff -ru kicad.orig/common/edaappl.cpp kicad/common/edaappl.cpp +--- kicad.orig/common/edaappl.cpp 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/common/edaappl.cpp 2012-01-04 00:58:45.466217466 +0100 +@@ -306,6 +306,7 @@ + wxString EnvLang; + + m_Id = aId; ++if (!g_CmdLineMode) + m_Checker = new wxSingleInstanceChecker( aName.Lower() + wxT( "-" ) + wxGetUserId() ); + + /* Init KiCad environment +diff -ru kicad.orig/include/appl_wxstruct.h kicad/include/appl_wxstruct.h +--- kicad.orig/include/appl_wxstruct.h 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/include/appl_wxstruct.h 2012-01-04 00:58:00.447684901 +0100 +@@ -52,6 +52,7 @@ + class wxSingleInstanceChecker; + class wxHtmlHelpController; + ++extern bool g_CmdLineMode; + + /** + * Class EDA_APP +@@ -185,6 +186,8 @@ + */ + void InitEDA_Appl( const wxString& aName, EDA_APP_T aId = APP_UNKNOWN_T ); + ++ virtual int OnRun() { return g_CmdLineMode ? 0 : wxApp::OnRun(); } ++ + /** + * Function SetLanguage + * sets the dictionary file name for internationalization. +diff -ru kicad.orig/include/wxEeschemaStruct.h kicad/include/wxEeschemaStruct.h +--- kicad.orig/include/wxEeschemaStruct.h 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/include/wxEeschemaStruct.h 2012-01-04 02:04:17.560214904 +0100 +@@ -585,6 +585,8 @@ + void SVG_Print( wxCommandEvent& event ); + + // Plot functions: ++ void CmdLineToPlot_PS( bool PlotBW, bool PlotSheetRef ); ++ void CmdLineToPlot_DXF( bool PlotBW, bool PlotSheetRef ); + void ToPlot_PS( wxCommandEvent& event ); + void ToPlot_HPGL( wxCommandEvent& event ); + void ToPlot_DXF( wxCommandEvent& event ); +diff -ru kicad.orig/include/wxPcbStruct.h kicad/include/wxPcbStruct.h +--- kicad.orig/include/wxPcbStruct.h 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/include/wxPcbStruct.h 2012-01-10 17:49:51.848114042 +0100 +@@ -75,6 +75,7 @@ + class PCB_EDIT_FRAME : public PCB_BASE_FRAME + { + friend class PCB_LAYER_WIDGET; ++ friend bool Pcbnew_CmdLine(); + + void updateTraceWidthSelectBox(); + void updateViaSizeSelectBox(); diff --git a/kicad-patches/cmdline-eeschema.patch b/kicad-patches/cmdline-eeschema.patch new file mode 100644 index 0000000..c60f5e8 --- /dev/null +++ b/kicad-patches/cmdline-eeschema.patch @@ -0,0 +1,158 @@ +diff -ru kicad.orig/eeschema/CMakeLists.txt kicad/eeschema/CMakeLists.txt +--- kicad.orig/eeschema/CMakeLists.txt 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/eeschema/CMakeLists.txt 2012-01-04 00:55:02.169540766 +0100 +@@ -78,6 +78,7 @@ + eeredraw.cpp + eeschema.cpp + eeschema_config.cpp ++ eeschema_cmdline.cpp + erc.cpp + events_called_functions_for_edit.cpp + files-io.cpp +diff -ru kicad.orig/eeschema/dialogs/dialog_build_BOM.h kicad/eeschema/dialogs/dialog_build_BOM.h +--- kicad.orig/eeschema/dialogs/dialog_build_BOM.h 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/eeschema/dialogs/dialog_build_BOM.h 2012-01-04 01:04:19.481832883 +0100 +@@ -17,6 +17,7 @@ + + class DIALOG_BUILD_BOM : public DIALOG_BUILD_BOM_BASE + { ++friend class EESCHEMA_CMDLINE; + private: + EDA_DRAW_FRAME* m_Parent; + wxConfig* m_Config; +diff -ru kicad.orig/eeschema/dialogs/dialog_erc.cpp kicad/eeschema/dialogs/dialog_erc.cpp +--- kicad.orig/eeschema/dialogs/dialog_erc.cpp 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/eeschema/dialogs/dialog_erc.cpp 2012-01-10 23:17:59.518338725 +0100 +@@ -574,10 +574,10 @@ + _( "Electronic rule check file (.erc)|*.erc" ), + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + +- if( dlg.ShowModal() == wxID_CANCEL ) ++ if( !g_CmdLineMode && dlg.ShowModal() == wxID_CANCEL ) + return; + +- if( WriteDiagnosticERC( dlg.GetPath() ) ) ++ if( WriteDiagnosticERC( g_CmdLineMode ? fn.GetFullPath() : dlg.GetPath() ) ) + { + Close( true ); + ExecuteFile( this, wxGetApp().GetEditorName(), QuoteFullPath( fn ) ); +diff -ru kicad.orig/eeschema/dialogs/dialog_erc.h kicad/eeschema/dialogs/dialog_erc.h +--- kicad.orig/eeschema/dialogs/dialog_erc.h 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/eeschema/dialogs/dialog_erc.h 2012-01-04 01:03:05.419550431 +0100 +@@ -29,6 +29,7 @@ + + class DIALOG_ERC : public DIALOG_ERC_BASE + { ++friend class EESCHEMA_CMDLINE; + DECLARE_EVENT_TABLE() + + private: +diff -ru kicad.orig/eeschema/dialogs/dialog_plot_schematic_DXF.cpp kicad/eeschema/dialogs/dialog_plot_schematic_DXF.cpp +--- kicad.orig/eeschema/dialogs/dialog_plot_schematic_DXF.cpp 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/eeschema/dialogs/dialog_plot_schematic_DXF.cpp 2012-01-04 02:05:43.305394193 +0100 +@@ -42,6 +42,7 @@ + + class DIALOG_PLOT_SCHEMATIC_DXF : public DIALOG_PLOT_SCHEMATIC_DXF_BASE + { ++friend class SCH_EDIT_FRAME; + private: + SCH_EDIT_FRAME* m_Parent; + +@@ -73,6 +74,15 @@ + + + ++void SCH_EDIT_FRAME::CmdLineToPlot_DXF( bool PlotBW, bool PlotSheetRef ) ++{ ++ DIALOG_PLOT_SCHEMATIC_DXF::m_plotColorOpt = !PlotBW; ++ DIALOG_PLOT_SCHEMATIC_DXF::m_plot_Sheet_Ref = PlotSheetRef; ++ DIALOG_PLOT_SCHEMATIC_DXF dlg( this ); ++ wxCommandEvent dummy; ++ dlg.OnPlotAll( dummy ); ++} ++ + void SCH_EDIT_FRAME::ToPlot_DXF( wxCommandEvent& event ) + { + DIALOG_PLOT_SCHEMATIC_DXF DXF_frame( this ); +diff -ru kicad.orig/eeschema/dialogs/dialog_plot_schematic_PS.cpp kicad/eeschema/dialogs/dialog_plot_schematic_PS.cpp +--- kicad.orig/eeschema/dialogs/dialog_plot_schematic_PS.cpp 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/eeschema/dialogs/dialog_plot_schematic_PS.cpp 2012-01-04 01:20:57.415188192 +0100 +@@ -48,6 +48,7 @@ + + class DIALOG_PLOT_SCHEMATIC_PS : public DIALOG_PLOT_SCHEMATIC_PS_BASE + { ++friend class SCH_EDIT_FRAME; + private: + SCH_EDIT_FRAME* m_Parent; + +@@ -79,6 +80,15 @@ + bool DIALOG_PLOT_SCHEMATIC_PS::m_plot_Sheet_Ref = true; + + ++void SCH_EDIT_FRAME::CmdLineToPlot_PS( bool PlotBW, bool PlotSheetRef ) ++{ ++ DIALOG_PLOT_SCHEMATIC_PS::m_plotColorOpt = !PlotBW; ++ DIALOG_PLOT_SCHEMATIC_PS::m_plot_Sheet_Ref = PlotSheetRef; ++ DIALOG_PLOT_SCHEMATIC_PS dlg( this ); ++ wxCommandEvent dummy; ++ dlg.OnPlotAll( dummy ); ++} ++ + void SCH_EDIT_FRAME::ToPlot_PS( wxCommandEvent& event ) + { + DIALOG_PLOT_SCHEMATIC_PS dlg( this ); +diff -ru kicad.orig/eeschema/dialogs/dialog_SVG_print.cpp kicad/eeschema/dialogs/dialog_SVG_print.cpp +--- kicad.orig/eeschema/dialogs/dialog_SVG_print.cpp 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/eeschema/dialogs/dialog_SVG_print.cpp 2012-01-10 23:20:13.888411068 +0100 +@@ -53,6 +53,13 @@ + static bool s_Print_Frame_Ref = true; + static int s_PlotBlackAndWhite = 0; + ++void CmdLinePrintSVGDoc( EDA_DRAW_FRAME* frame, bool aPrintAll, bool aPrint_Sheet_Ref, bool aPrintBlackAndWhite ) ++{ ++ class DIALOG_SVG_PRINT* dlg = new DIALOG_SVG_PRINT( frame ); ++ dlg->m_ModeColorOption->SetSelection( aPrintBlackAndWhite ); ++ dlg->PrintSVGDoc( aPrintAll, aPrint_Sheet_Ref ); ++ delete dlg; ++} + + /*! + * DIALOG_SVG_PRINT functions +diff -ru kicad.orig/eeschema/dialogs/dialog_SVG_print.h kicad/eeschema/dialogs/dialog_SVG_print.h +--- kicad.orig/eeschema/dialogs/dialog_SVG_print.h 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/eeschema/dialogs/dialog_SVG_print.h 2012-01-04 01:03:17.627432139 +0100 +@@ -12,6 +12,7 @@ + + class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base + { ++friend void CmdLinePrintSVGDoc( EDA_DRAW_FRAME* frame, bool aPrintAll, bool aPrint_Sheet_Ref, bool aPrintBlackAndWhite ); + private: + EDA_DRAW_FRAME* m_Parent; + wxConfig* m_Config; +@@ -37,5 +38,4 @@ + bool aPrint_Sheet_Ref = false ); + }; + +- + #endif // _DIALOG_SVG_PRINT_H_ +diff -ru kicad.orig/eeschema/eeschema.cpp kicad/eeschema/eeschema.cpp +--- kicad.orig/eeschema/eeschema.cpp 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/eeschema/eeschema.cpp 2012-01-04 01:05:55.083907033 +0100 +@@ -41,6 +41,7 @@ + #include "hotkeys.h" + #include "dialogs/dialog_color_config.h" + #include "transform.h" ++#include "eeschema_cmdline.h" + + #include + +@@ -122,6 +123,9 @@ + wxFileName filename; + SCH_EDIT_FRAME* frame = NULL; + ++ if ( argc >= 2 && argv[1][0] == '-' ) ++ return g_EESchemaCmdLine.Run(); ++ + InitEDA_Appl( wxT( "Eeschema" ), APP_EESCHEMA_T ); + + if( m_Checker && m_Checker->IsAnotherRunning() ) diff --git a/kicad-patches/cmdline-new.patch b/kicad-patches/cmdline-new.patch new file mode 100644 index 0000000..b0298c4 --- /dev/null +++ b/kicad-patches/cmdline-new.patch @@ -0,0 +1,791 @@ +--- /dev/null 2012-01-06 01:10:09.493787641 +0100 ++++ kicad/eeschema/eeschema_cmdline.h 2012-01-04 00:55:43.066114352 +0100 +@@ -0,0 +1,14 @@ ++///////////////////////////////////////////////////////////////////////////// ++// Name: eeschema_cmdline.h ++// Copyright: Wolfgang Spraul ++// Licence: GPL v3 or higher ++///////////////////////////////////////////////////////////////////////////// ++ ++class EESCHEMA_CMDLINE ++{ ++public: ++ EESCHEMA_CMDLINE() { } ++ bool Run(); ++}; ++ ++extern EESCHEMA_CMDLINE g_EESchemaCmdLine; +--- /dev/null 2012-01-06 01:10:09.493787641 +0100 ++++ kicad/eeschema/eeschema_cmdline.cpp 2012-01-10 16:33:11.565978324 +0100 +@@ -0,0 +1,233 @@ ++///////////////////////////////////////////////////////////////////////////// ++// Name: eeschema_cmdline.cpp ++// Copyright: Werner Almesberger, Wolfgang Spraul ++// License: GPL v2 or higher ++///////////////////////////////////////////////////////////////////////////// ++ ++#include "fctsys.h" ++#include "appl_wxstruct.h" ++#include "common.h" ++#include "general.h" ++#include "netlist.h" ++#include "netlist_control.h" ++#include "protos.h" ++#include "gr_basic.h" ++#include "wx/cmdline.h" ++#include "dialog_build_BOM.h" ++#include "dialog_SVG_print_base.h" ++#include "dialog_erc.h" ++#include "dialog_color_config.h" ++#include "wxEeschemaStruct.h" ++#include "sch_sheet.h" ++#include "eeschema_cmdline.h" ++ ++EESCHEMA_CMDLINE g_EESchemaCmdLine; ++ ++static const wxCmdLineEntryDesc g_cmdLineDesc [] = ++{ ++ { wxCMD_LINE_SWITCH, 0, wxT("help"), ++ wxT("command line help\n"), ++ wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, ++ ++ { wxCMD_LINE_SWITCH, 0, wxT("list-sheets"), ++ wxT("list schematic pages\n") }, ++ ++ { wxCMD_LINE_OPTION, 0, wxT("plot"), ++ wxT("File -> Plot [ps|svg|dxf]"), ++ wxCMD_LINE_VAL_STRING }, ++ { wxCMD_LINE_SWITCH, 0, wxT("plot-bw"), ++ wxT(" Black & white (default: color)") }, ++ { wxCMD_LINE_SWITCH, 0, wxT("plot-sheetref"), ++ wxT(" Print page references (default: off)\n") }, ++ ++ { wxCMD_LINE_SWITCH, 0, wxT("erc"), ++ wxT("Tools -> ERC (.erc)") }, ++ { wxCMD_LINE_SWITCH, 0, wxT("netlist"), ++ wxT("Tools -> Generate Netlist (.net)") }, ++ { wxCMD_LINE_SWITCH, 0, wxT("bom"), ++ wxT("Tools -> Generate Bill of Materials (.bom)") }, ++ { wxCMD_LINE_PARAM, 0, 0, wxT(""), ++ wxCMD_LINE_VAL_STRING }, ++ { wxCMD_LINE_NONE } ++}; ++ ++bool CmdLineDrawSVGPage( EDA_DRAW_FRAME* frame, ++ const wxString& FullFileName, BASE_SCREEN* screen, ++ bool aPrintBlackAndWhite = false, ++ bool aPrint_Sheet_Ref = false); ++ ++// called from EDA_APP::OnInit() ++bool EESCHEMA_CMDLINE::Run() ++{ ++ wxFileName fn; ++ SCH_EDIT_FRAME* frame; ++ wxCommandEvent DummyCmd; ++ wxString str; ++ int i; ++ ++ EDA_APP& app = wxGetApp(); ++ g_CmdLineMode = true; ++ wxLog::EnableLogging(false); // this should suppress some wx dialogs ++ app.InitEDA_Appl( wxT( "Eeschema" ), APP_EESCHEMA_T ); ++ ++ wxCmdLineParser parser; ++ parser.SetDesc(g_cmdLineDesc); ++ parser.SetCmdLine(app.argc, app.argv); ++ if (parser.Parse()) ++ return false; ++ ++ i = parser.Found( _("list-sheets") ) ++ + parser.Found( _("plot") ) ++ + parser.Found( _("erc") ) ++ + parser.Found( _("netlist") ) ++ + parser.Found( _("bom") ); ++ if ( !i ) ++ { ++ wxFprintf( stderr, wxT("One of --list-sheets --plot --erc --netlist" ++ " --bom must be given.\n")); ++ return false; ++ } ++ if ( i > 1 ) ++ { ++ wxFprintf( stderr, wxT("Only one of --list-sheets --plot --erc" ++ " --netlist --bom may be given at a time.\n")); ++ return false; ++ } ++ ++ // parse plotting parameters ++ enum PlotCommand { ++ PLOT_NONE, ++ PLOT_PS, ++ PLOT_SVG, ++ PLOT_DXF ++ } PlotCmd; ++ bool PlotBW; ++ bool PlotSheetRef; ++ ++ PlotCmd = PLOT_NONE; ++ if ( parser.Found( _("plot"), &str ) ) ++ { ++ if (!str.CmpNoCase( wxT("ps") ) ) ++ PlotCmd = PLOT_PS; ++ else if ( !str.CmpNoCase( wxT("svg") ) ) ++ PlotCmd = PLOT_SVG; ++ else if ( !str.CmpNoCase( wxT("dxf") ) ) ++ PlotCmd = PLOT_DXF; ++ else ++ { ++ wxFprintf( stderr, wxT("Unexpected plot format '%ls'.\n"), str.c_str()); ++ return false; ++ } ++ PlotBW = parser.Found( _("plot-bw") ); ++ PlotSheetRef = parser.Found( _("plot-sheetref") ); ++ } ++ ++ fn = parser.GetParam(); ++ if( fn.GetExt() != SchematicFileExtension ) ++ { ++ wxLogDebug( wxT( "eeschema file <%s> has the wrong extension." ++ " Changing extension to .sch." ), GetChars( fn.GetFullPath() ) ); ++ fn.SetExt( PcbFileExtension ); ++ } ++ if( !fn.FileExists()) ++ { ++ wxFprintf( stderr, wxT("%ls: file '%ls' does not exist.\n" ), ++ app.argv[0], fn.GetFullPath().c_str() ); ++ return false; ++ } ++ wxSetWorkingDirectory( fn.GetPath() ); ++ ++ SeedLayers(); ++ frame = new SCH_EDIT_FRAME( NULL, wxT( "Eeschema" ), wxPoint( 0, 0 ), ++ wxSize( 600, 400 ) ); ++ app.SetTopWindow( frame ); ++#if 0 // enable this to see more of the GUI ++ frame->Show( true ); ++#endif ++ if( !frame->LoadOneEEProject( fn.GetFullPath(), false ) ) ++ { ++ wxFprintf( stderr, fn.GetFullPath() + _(": can't load\n") ); ++ return false; ++ } ++ ++ if ( parser.Found( wxT("list-sheets") ) ) ++ { ++ SCH_SHEET_LIST SheetList( 0 /* aSheet */ ); ++ SCH_SHEET_PATH* sheetpath; ++ SCH_SHEET_PATH oldsheetpath, list; ++ SCH_SCREEN* schscreen; ++ ++ // dialogs/dialog_SVG_print.cpp:DIALOG_SVG_PRINT:PrintSVGDoc() ++ oldsheetpath = frame->GetCurrentSheet(); ++ sheetpath = SheetList.GetFirst(); ++ while ( sheetpath ) ++ { ++ list.Clear(); ++ if ( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) ++ { ++ frame->SetCurrentSheet( list ); ++ frame->GetCurrentSheet().UpdateAllScreenReferences(); ++ frame->SetSheetNumberAndCount(); ++ schscreen = frame->GetCurrentSheet().LastScreen(); ++ ++ wxPrintf( sheetpath->Path() + _(" ") ++ + sheetpath->PathHumanReadable() + _(" ") ++ + sheetpath->Last()->GetFileName() + _(" ") ++ + frame->GetUniqueFilenameForCurrentSheet( ) + wxT( ".sch\n") ); ++ } ++ sheetpath = SheetList.GetNext(); ++ } ++ frame->SetCurrentSheet( oldsheetpath ); ++ frame->GetCurrentSheet().UpdateAllScreenReferences(); ++ frame->SetSheetNumberAndCount(); ++ } ++ else if ( PlotCmd == PLOT_PS ) ++ { ++ // dialogs/dialog_plot_schematic_PS_base.cpp ++ // dialogs/dialog_plot_schematic_PS.cpp ++ frame->CmdLineToPlot_PS( PlotBW, PlotSheetRef ); ++ } ++ else if ( PlotCmd == PLOT_SVG ) ++ { ++ // dialogs/dialog_SVG_print.cpp:DIALOG_SVG_PRINT::DrawSVGPage() ++ void CmdLinePrintSVGDoc( EDA_DRAW_FRAME* frame, bool aPrintAll, ++ bool aPrint_Sheet_Ref, bool aPrintBlackAndWhite ); ++ CmdLinePrintSVGDoc( frame, true /* aPrintAll */, PlotSheetRef, PlotBW ); ++ } ++ else if ( PlotCmd == PLOT_DXF ) ++ { ++ // dialogs/dialog_plot_schematic_DXF_base.cpp ++ // dialogs/dialog_plot_schematic_DXF.cpp ++ frame->CmdLineToPlot_DXF( PlotBW, PlotSheetRef ); ++ } ++ else if ( parser.Found( wxT("erc") ) ) // erc.cpp:DIALOG_ERC::TestErc() ++ { ++ DIALOG_ERC* dlg = new DIALOG_ERC( frame ); ++ dlg->m_WriteResultOpt->SetValue( true ); ++ dlg->TestErc( 0 /* messageList */ ); ++ delete dlg; ++ } ++ else if ( parser.Found( wxT("netlist") ) ) ++ { ++ // netlist_control.cpp:WinEDA_SchematicFrame::CreateNetlist() ++ frame->BuildNetListBase(); ++ fn.SetExt( wxT( "net" ) ); ++ frame->WriteNetListFile( NET_TYPE_PCBNEW /* aFormat */, ++ fn.GetFullPath(), false /* aUse_netnames - only used for Spice */, ++ false /* aUsePrefix */ ); ++ } ++ else if ( parser.Found( wxT("bom") ) ) ++ { ++ // see build_BOM.cpp:DIALOG_BUILD_BOM::GenereListeOfItems() ++ DIALOG_BUILD_BOM* dlg = new DIALOG_BUILD_BOM( frame ); ++ ++ dlg->m_ListCmpbyRefItems->SetValue( true ); ++ dlg->m_AddFootprintField->SetValue( true ); ++ dlg->m_AddAllFields->SetValue( true ); ++ ++ fn.SetExt( wxT( "lst" ) ); ++ dlg->GenereListeOfItems( fn.GetFullPath(), false /* aIncludeSubComponents */ ); ++ delete dlg; ++ } ++ return true; ++} +--- /dev/null 2012-01-06 01:10:09.493787641 +0100 ++++ kicad/pcbnew/pcbnew_cmdline.h 2012-01-04 00:59:32.003734758 +0100 +@@ -0,0 +1,7 @@ ++///////////////////////////////////////////////////////////////////////////// ++// Name: pcbnew_cmdline.h ++// Copyright: Wolfgang Spraul ++// Licence: GPL v3 or higher ++///////////////////////////////////////////////////////////////////////////// ++ ++bool Pcbnew_CmdLine(); +--- /dev/null 2012-01-06 01:10:09.493787641 +0100 ++++ kicad/pcbnew/pcbnew_cmdline.cpp 2012-01-10 22:52:01.869091302 +0100 +@@ -0,0 +1,525 @@ ++///////////////////////////////////////////////////////////////////////////// ++// Name: pcbnew_cmdline.cpp ++// Copyright: Wolfgang Spraul ++// Licence: GPL v3 or higher ++///////////////////////////////////////////////////////////////////////////// ++ ++#include "fctsys.h" ++#include "appl_wxstruct.h" ++#include "confirm.h" ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include "common.h" ++#include "pcbnew.h" ++#include "wxPcbStruct.h" ++#include "plot_common.h" ++#include "gestfich.h" ++#include "pcbplot.h" ++#include "autorout.h" ++#include "cell.h" ++#include "worksheet.h" ++#include "zones.h" ++#include "drag.h" ++#include "eda_dde.h" ++#include "colors_selection.h" ++#include "class_drawpanel.h" ++#include "gr_basic.h" ++#include "id.h" ++#include "build_version.h" ++ ++#include "protos.h" ++#include "pcbnew_cmdline.h" ++#include "gendrill.h" ++#include "dialog_gendrill.h" ++#include "dialog_drc.h" ++#include "printout_controler.h" ++#include "dialog_plot_base.h" ++#include "dialog_SVG_print.h" ++ ++extern int g_DrawDefaultLineThickness; ++ ++static const wxCmdLineEntryDesc g_cmdLineDesc [] = ++{ ++ { wxCMD_LINE_SWITCH, 0, wxT("help"), ++ wxT("command line help\n"), ++ wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, ++ ++ { wxCMD_LINE_SWITCH, 0, wxT("list-layers"), ++ wxT("list names of enabled layers in .brd file") }, ++ { wxCMD_LINE_OPTION, 0, wxT("layers"), ++ wxT("comma separated layers for plot and SVG\n"), ++ wxCMD_LINE_VAL_STRING }, ++ ++ { wxCMD_LINE_SWITCH, 0, wxT("drill"), ++ wxT("File -> Fabrication -> Drill File (.drl)") }, ++ { wxCMD_LINE_SWITCH, 0, wxT("drill-origin-aux"), ++ wxT(" Use aux axis as origin (def: abs)\n") }, ++ ++ { wxCMD_LINE_OPTION, 0, wxT("plot"), ++ wxT("File -> Plot [gerber|ps|dxf]"), ++ wxCMD_LINE_VAL_STRING }, ++ { wxCMD_LINE_SWITCH, 0, wxT("plot-fill-all-zones"), ++ wxT(" fill zones before plotting (not in the dialog)") }, ++ { wxCMD_LINE_OPTION, 0, wxT("plot-drill-marks"), ++ wxT(" Drill marks [none|small|actual] (def: small)"), ++ wxCMD_LINE_VAL_STRING }, ++ { wxCMD_LINE_SWITCH, 0, wxT("plot-mirror"), ++ wxT(" Mirrored plot (Postscript only)") }, ++ { wxCMD_LINE_SWITCH, 0, wxT("plot-ps-force-a4"), ++ wxT(" Postscript: Force A4 output") }, ++ { wxCMD_LINE_SWITCH, 0, wxT("plot-gb-ex-pcb-edge"), ++ wxT(" Gerber: exclude PCB edge") }, ++ { wxCMD_LINE_SWITCH, 0, wxT("plot-gb-aux-origin"), ++ wxT(" Gerber: Use aux axis as origin (def: abs)\n") }, ++ ++ { wxCMD_LINE_OPTION, 0, wxT("svg"), ++ wxT("File -> Print SVG [selected|board]"), ++ wxCMD_LINE_VAL_STRING }, ++ { wxCMD_LINE_SWITCH, 0, wxT("svg-board-edges"), ++ wxT(" add board edges to SVG plots (def: off)\n") }, ++ ++ { wxCMD_LINE_SWITCH, 0, wxT("drc"), ++ wxT("Tools -> DRC (.rpt)") }, ++ { wxCMD_LINE_SWITCH, 0, wxT("pos"), ++ wxT("File -> Fabrication -> Modules Pos. (.pos)") }, ++ { wxCMD_LINE_SWITCH, 0, wxT("bom"), ++ wxT("File -> Fabrication -> BOM File (.csv)") }, ++ { wxCMD_LINE_SWITCH, 0, wxT("cmp"), ++ wxT("File -> Fabrication -> Comp. File (.cmp)") }, ++ { wxCMD_LINE_SWITCH, 0, wxT("vrml"), ++ wxT("File -> Export -> VRML (.wrl)") }, ++ { wxCMD_LINE_PARAM, 0, 0, wxT(""), ++ wxCMD_LINE_VAL_STRING }, ++ { wxCMD_LINE_NONE } ++}; ++ ++bool Pcbnew_CmdLine() ++{ ++ wxFileName cmdline_fn, fn; ++ wxString str; ++ PCB_EDIT_FRAME* frame = NULL; ++ wxCommandEvent dummy; ++ int i; ++ ++ EDA_APP& app = wxGetApp(); ++ g_CmdLineMode = true; ++ wxLog::EnableLogging(false); // this should suppress some wx dialogs ++ app.InitEDA_Appl( wxT( "Pcbnew" ), APP_PCBNEW_T ); ++ ++ wxCmdLineParser parser; ++ parser.SetDesc(g_cmdLineDesc); ++ parser.SetCmdLine(app.argc, app.argv); ++ if (parser.Parse()) ++ return false; ++ i = parser.Found( _("list-layers") ) ++ + parser.Found( _("drill") ) ++ + parser.Found( _("plot") ) ++ + parser.Found( _("svg") ) ++ + parser.Found( _("drc") ) ++ + parser.Found( _("pos") ) ++ + parser.Found( _("bom") ) ++ + parser.Found( _("cmp") ) ++ + parser.Found( _("vrml") ); ++ if ( !i ) ++ { ++ wxFprintf( stderr, wxT("One of --list-layers --drill --plot --svg --drc --pos --bom --cmp or --vrml must be given.\n")); ++ return false; ++ } ++ if ( i > 1 ) ++ { ++ wxFprintf( stderr, wxT("Only one of ---list-layers --drill --plot --svg --drc --pos --bom --cmp or --vrml may be given at a time.\n")); ++ return false; ++ } ++ ++ cmdline_fn = parser.GetParam(); ++ if( cmdline_fn.GetExt() != PcbFileExtension ) ++ { ++ wxLogDebug( wxT( "PcbNew file <%s> has the wrong extension. Changing extension to .brd." ), GetChars( cmdline_fn.GetFullPath() ) ); ++ cmdline_fn.SetExt( PcbFileExtension ); ++ } ++ if( !cmdline_fn.FileExists()) ++ { ++ wxFprintf( stderr, wxT("%ls: file '%ls' does not exist.\n" ), app.argv[0], cmdline_fn.GetFullPath().c_str() ); ++ return false; ++ } ++ wxSetWorkingDirectory( cmdline_fn.GetPath() ); ++ ++ app.GetSettings( false /* reopenLastUsedDirectory */ ); ++ ++ g_DrawBgColor = BLACK; ++ frame = new PCB_EDIT_FRAME( NULL, wxT( "Pcbnew" ), wxPoint( 0, 0 ), ++ wxSize( 600, 400 ) ); ++ app.SetTopWindow( frame ); ++ ++#if 0 // enable this to see more of the GUI ++ frame->Show( true ); ++ frame->Zoom_Automatique( true ); ++#endif ++ ++ frame->LoadOnePcbFile( cmdline_fn.GetFullPath() ); ++ frame->LoadProjectSettings( cmdline_fn.GetFullPath() ); ++ ++ if ( parser.Found( wxT("list-layers") ) ) ++ { ++ for ( i = 0; i < NB_LAYERS; i++ ) ++ { ++ if( frame->GetBoard()->IsLayerEnabled( i ) ) ++ { ++ str = frame->GetBoard()->GetLayerName( i ); ++ // remove leading and trailing spaces if any ++ str.Trim( true ); str.Trim( false ); ++ wxPrintf(str + _("\n")); ++ } ++ } ++ } ++ ++ if ( parser.Found( wxT("drill") ) ) ++ { ++ DIALOG_GENDRILL drill_frame( frame ); ++ drill_frame.m_Choice_Drill_Offset->SetSelection( ++ parser.Found( wxT("drill-origin-aux") ) ); ++ wxSafeYield(); ++ drill_frame.GenDrillAndReportFiles(); ++ } ++ ++ if ( parser.Found( wxT("plot"), &str ) ) // see pcbplot.cpp ++ { ++ int plot_format; ++ wxString ext, layers_str; ++ ++ g_PcbPlotOptions.m_PlotLineWidth = g_DrawDefaultLineThickness; ++ if (!str.CmpNoCase( wxT("ps") ) ) ++ { ++ plot_format = PLOT_FORMAT_POST; ++ ext = wxT( "ps" ); ++ } ++ else if ( !str.CmpNoCase( wxT("gerber") ) ) ++ { ++ plot_format = PLOT_FORMAT_GERBER; ++ ext = wxT( "pho" ); ++ } ++ else if ( !str.CmpNoCase( wxT("dxf") ) ) ++ { ++ plot_format = PLOT_FORMAT_DXF; ++ ext = wxT( "dxf" ); ++ } ++ else ++ { ++ wxFprintf( stderr, ++ wxT("Unexpected plot type '%ls'.\n"), str.c_str() ); ++ return false; ++ } ++ ++ // --plot-fill-all-zones ++ if ( parser.Found( wxT("plot-fill-all-zones") ) ) ++ frame->Fill_All_Zones( 0 /* aActiveWindow for progress bar */, ++ false /* verbose */ ); ++ ++ // --plot-drill-marks ++ if ( plot_format == PLOT_FORMAT_POST ++ && parser.Found( wxT("plot-drill-marks"), &str ) ) ++ { ++ if (!str.CmpNoCase( wxT("none") ) ) ++ g_PcbPlotOptions.m_DrillShapeOpt = PCB_PLOT_PARAMS::NO_DRILL_SHAPE; ++ else if ( !str.CmpNoCase( wxT("small") ) ) ++ g_PcbPlotOptions.m_DrillShapeOpt = PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE; ++ else if ( !str.CmpNoCase( wxT("actual") ) ) ++ g_PcbPlotOptions.m_DrillShapeOpt = PCB_PLOT_PARAMS::FULL_DRILL_SHAPE; ++ else ++ { ++ wxFprintf( stderr, wxT("Unexpected Postscript plot drill marks option '%ls'.\n"), str.c_str()); ++ return false; ++ } ++ } ++ ++ // --plot-mirror ++ g_PcbPlotOptions.m_PlotMirror = parser.Found( wxT("plot-mirror") ); ++ ++ // --plot-gb-ex-pcb-edge ++ g_PcbPlotOptions.m_ExcludeEdgeLayer = ++ parser.Found( wxT("plot-gb-ex-pcb-edge") ); ++ ++ parser.Found( wxT("layers"), &layers_str ); ++ wxStringTokenizer tokenizer( layers_str, _(",") ); ++ int layer_i = 0; ++ wxString layername; ++ while ( ( layers_str.IsEmpty() && layer_i < NB_LAYERS ) || tokenizer.HasMoreTokens() ) ++ { ++ if ( layers_str.IsEmpty() ) ++ { ++ if( !frame->GetBoard()->IsLayerEnabled( layer_i ) ) ++ { ++ layer_i++; ++ continue; ++ } ++ layername = frame->GetBoard()->GetLayerName( layer_i ); ++ // remove leading and trailing spaces if any ++ layername.Trim( true ); layername.Trim( false ); ++ layer_i++; ++ } ++ else ++ { ++ layername = tokenizer.GetNextToken(); ++ for( layer_i = 0; layer_i < NB_LAYERS; layer_i++ ) ++ { ++ str = frame->GetBoard()->GetLayerName( layer_i ); ++ // remove leading and trailing spaces if any ++ str.Trim( true ); str.Trim( false ); ++ if ( !str.Cmp( layername ) ) ++ break; ++ } ++ if (layer_i >= NB_LAYERS) ++ { ++ wxFprintf( stderr, _( "Unknown layer name '%ls'\n" ), layername.c_str() ); ++ continue; ++ } ++ } ++ fn = cmdline_fn; ++ fn.SetName( fn.GetName() + wxT( "-" ) + layername ); ++ ++ // Use Gerber Extensions based on layer number ++ // (See http://en.wikipedia.org/wiki/Gerber_File) ++ if( (plot_format == PLOT_FORMAT_GERBER) && true /* always use gerber extensions */ ) ++ { ++ switch( layer_i ) ++ { ++ case LAYER_N_FRONT: ++ fn.SetExt( wxT( "gtl" ) ); ++ break; ++ ++ case LAYER_N_2: ++ case LAYER_N_3: ++ case LAYER_N_4: ++ case LAYER_N_5: ++ case LAYER_N_6: ++ case LAYER_N_7: ++ case LAYER_N_8: ++ case LAYER_N_9: ++ case LAYER_N_10: ++ case LAYER_N_11: ++ case LAYER_N_12: ++ case LAYER_N_13: ++ case LAYER_N_14: ++ case LAYER_N_15: ++ ++ // TODO: see if we use .gbr or a layer identifier (gb1 .. gbnn ?) ++ // according to the new internal layers designation ++ // (1 is the first internal layer from the front layer) ++ fn.SetExt( wxT( "gbr" ) ); ++ break; ++ ++ case LAYER_N_BACK: ++ fn.SetExt( wxT( "gbl" ) ); ++ break; ++ ++ case ADHESIVE_N_BACK: ++ fn.SetExt( wxT( "gba" ) ); ++ break; ++ ++ case ADHESIVE_N_FRONT: ++ fn.SetExt( wxT( "gta" ) ); ++ break; ++ ++ case SOLDERPASTE_N_BACK: ++ fn.SetExt( wxT( "gbp" ) ); ++ break; ++ ++ case SOLDERPASTE_N_FRONT: ++ fn.SetExt( wxT( "gtp" ) ); ++ break; ++ ++ case SILKSCREEN_N_BACK: ++ fn.SetExt( wxT( "gbo" ) ); ++ break; ++ ++ case SILKSCREEN_N_FRONT: ++ fn.SetExt( wxT( "gto" ) ); ++ break; ++ ++ case SOLDERMASK_N_BACK: ++ fn.SetExt( wxT( "gbs" ) ); ++ break; ++ ++ case SOLDERMASK_N_FRONT: ++ fn.SetExt( wxT( "gts" ) ); ++ break; ++ ++ case DRAW_N: ++ case COMMENT_N: ++ case ECO1_N: ++ case ECO2_N: ++ case EDGE_N: ++ default: ++ fn.SetExt( wxT( "gbr" ) ); ++ break; ++ } ++ } ++ else ++ { ++ fn.SetExt( ext ); ++ } ++ ++ bool success = false; ++ ++ switch( plot_format ) ++ { ++ case PLOT_FORMAT_POST: ++ success = frame->ExportToPostScriptFile( fn.GetFullPath(), ++ layer_i, ++ parser.Found( wxT("plot-ps-force-a4") ), ++ FILLED /* trace_mode */ ); ++ break; ++ ++ case PLOT_FORMAT_GERBER: ++ success = frame->ExportToGerberFile( fn.GetFullPath(), layer_i, ++ parser.Found( wxT("plot-gb-aux-origin") ), ++ FILLED /* trace_mode */ ); ++ break; ++ ++ case PLOT_FORMAT_DXF: ++ success = frame->ExportToDxfFile( fn.GetFullPath(), layer_i, ++ FILLED /* trace_mode */ ); ++ break; ++ } ++ ++ // Print diags in messages box: ++ wxString msg; ++ if( !success ) ++ wxFprintf( stderr, _( "Unable to create <%s>\n" ), ++ GetChars( fn.GetFullPath() ) ); ++ } ++ } ++ if ( parser.Found( wxT("svg"), &str ) ) ++ { ++ wxString layers_str; ++ DIALOG_SVG_PRINT dlg( frame ); ++ ++ parser.Found( wxT("layers"), &layers_str ); ++ if ( !layers_str.IsEmpty() ) ++ { ++ int layer; ++ for( layer = 0; layer < NB_LAYERS; ++layer ) ++ { ++ if (dlg.m_BoxSelectLayer[layer]) ++ dlg.m_BoxSelectLayer[layer]->SetValue( 0 ); ++ } ++ ++ wxStringTokenizer tokenizer( layers_str, _(",") ); ++ while ( tokenizer.HasMoreTokens() ) ++ { ++ wxString layername = tokenizer.GetNextToken(); ++ for( layer = 0; layer < NB_LAYERS; layer++ ) ++ { ++ wxString cur = frame->GetBoard()->GetLayerName( layer ); ++ // remove leading and trailing spaces if any ++ cur.Trim( true ); cur.Trim( false ); ++ if ( !cur.Cmp( layername ) ) ++ break; ++ } ++ if (layer >= NB_LAYERS) ++ { ++ wxFprintf( stderr, _( "Unknown layer '%ls'\n" ), ++ layername.c_str() ); ++ continue; ++ } ++ if (!dlg.m_BoxSelectLayer[layer]) ++ wxFprintf( stderr, _( "No layer '%ls'\n" ), ++ layername.c_str() ); ++ else ++ dlg.m_BoxSelectLayer[layer]->SetValue( 1 ); ++ } ++ } ++ ++ dlg.m_Print_Frame_Ref_Ctrl->SetValue( 0 ); ++ dlg.m_PrintBoardEdgesCtrl->SetValue( ++ parser.Found( wxT("svg-board-edges") ) ); ++ ++ wxSafeYield(); ++ if ( !str.CmpNoCase( wxT("selected") ) ) ++ dlg.OnButtonPrintSelectedClick( dummy ); ++ else if ( !str.CmpNoCase( wxT("board") ) ) ++ dlg.OnButtonPrintBoardClick( dummy ); ++ else ++ { ++ wxFprintf( stderr, wxT("Unexpected SVG type '%ls'.\n"), ++ str.c_str()); ++ return false; ++ } ++ } ++ ++ if ( parser.Found( wxT("drc") ) ) ++ { ++ wxTextCtrl msgs; ++ ++ fn = cmdline_fn; ++ fn.SetExt( _("rpt") ); ++ ++ // drc.cpp DRC::ShowDialog() ++ // dialogs/dialog_drc.cpp DIALOG_DRC_CONTROL::OnStartdrcClick() ++ frame->m_drc->updatePointers(); ++ frame->m_drc->SetSettings(true, // Pad to pad DRC test enabled ++ true, // unconnected pdas DRC test enabled ++ true, // DRC test for zones enabled ++ fn.GetFullPath(), // report file name ++ true /* aSaveReport */ ); ++ frame->m_drc->m_pcb->m_Status_Pcb = 0; // Force full connectivity and ratsnest recalculations ++ frame->m_drc->RunTests(&msgs); // not everybody checks for 0 pointer ++ FILE* fp = wxFopen( fn.GetFullPath(), wxT( "w" ) ); ++ { // strings should match dialogs/dialog_drc.cpp:DIALOG_DRC_CONTROL::writeReport() ++ int count; ++ ++ fprintf( fp, "** Drc report for %s **\n", TO_UTF8( cmdline_fn.GetFullPath() ) ); ++ ++ wxDateTime now = wxDateTime::Now(); ++ fprintf( fp, "** Created on %s **\n", TO_UTF8( now.Format( wxT( "%F %T" ) ) ) ); ++ ++ class DRC_LIST_MARKERS* markers = new DRC_LIST_MARKERS( frame->m_drc->m_pcb ); ++ count = markers->GetCount(); ++ fprintf( fp, "\n** Found %d DRC errors **\n", count ); ++ for ( i = 0; i < count; i++ ) ++ fprintf( fp, "%s", TO_UTF8( markers->GetItem( i )->ShowReport()) ); ++ delete markers; ++ ++ class DRC_LIST_UNCONNECTED* unconnected = new DRC_LIST_UNCONNECTED( &frame->m_drc->m_unconnected ); ++ count = unconnected->GetCount(); ++ fprintf( fp, "\n** Found %d unconnected pads **\n", count ); ++ for ( i = 0; i < count; i++ ) ++ fprintf( fp, "%s", TO_UTF8( unconnected->GetItem( i )->ShowReport()) ); ++ delete unconnected; ++ ++ fprintf( fp, "\n** End of Report **\n" ); ++ } ++ fclose( fp ); ++ } ++ ++ if ( parser.Found( wxT("pos") ) ) ++ // see gen_modules_placefile.cpp:PCB_EDIT_FRAME::GenModulesPosition() ++ frame->GenModulesPosition( dummy ); ++ ++ if ( parser.Found( wxT("bom") ) ) ++ // see build_BOM_from_board.cpp:PCB_EDIT_FRAME::RecreateBOMFileFromBoard() ++ frame->RecreateBOMFileFromBoard( dummy ); ++ ++ if ( parser.Found( wxT("cmp") ) ) ++ // see xchgmod.cpp:WinEDA_PcbFrame::RecreateCmpFileFromBoard() ++ frame->RecreateCmpFileFromBoard( dummy ); ++ ++ if ( parser.Found( wxT("vrml") ) ) ++ { ++ // see export_vrml.cpp:WinEDA_PcbFrame::OnExportVRML() ++ wxString subDirFor3Dshapes( _( "shapes3D" ) ); ++ ++ fn = cmdline_fn; ++ fn.SetExt( _("wrl") ); ++ if( ! wxDirExists( subDirFor3Dshapes ) ) ++ wxMkdir( subDirFor3Dshapes ); ++ frame->ExportVRML_File( fn.GetFullPath(), 1.0 /* aScale */, ++ true /* aExport3DFile */, subDirFor3Dshapes ); ++ } ++ return true; ++} diff --git a/kicad-patches/cmdline-pcbnew.patch b/kicad-patches/cmdline-pcbnew.patch new file mode 100644 index 0000000..5052ba3 --- /dev/null +++ b/kicad-patches/cmdline-pcbnew.patch @@ -0,0 +1,183 @@ +diff -ru kicad.orig/pcbnew/build_BOM_from_board.cpp kicad/pcbnew/build_BOM_from_board.cpp +--- kicad.orig/pcbnew/build_BOM_from_board.cpp 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/pcbnew/build_BOM_from_board.cpp 2012-01-10 23:23:32.338040998 +0100 +@@ -67,6 +67,7 @@ + fn = GetScreen()->GetFileName(); + fn.SetExt( CsvFileExtension ); + ++ if (!g_CmdLineMode) { + wxFileDialog dlg( this, _( "Save Bill of Materials" ), wxGetCwd(), + fn.GetFullName(), CsvFileWildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); +@@ -75,6 +76,7 @@ + return; + + fn = dlg.GetPath(); ++ } + + FichBom = wxFopen( fn.GetFullPath(), wxT( "wt" ) ); + +diff -ru kicad.orig/pcbnew/CMakeLists.txt kicad/pcbnew/CMakeLists.txt +--- kicad.orig/pcbnew/CMakeLists.txt 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/pcbnew/CMakeLists.txt 2012-01-05 01:53:42.424887775 +0100 +@@ -150,6 +150,7 @@ + onrightclick.cpp + pcb_plot_params.cpp + pcbnew.cpp ++ pcbnew_cmdline.cpp + pcbnew_config.cpp + pcbplot.cpp + plotgerb.cpp +diff -ru kicad.orig/pcbnew/dialogs/dialog_gendrill.h kicad/pcbnew/dialogs/dialog_gendrill.h +--- kicad.orig/pcbnew/dialogs/dialog_gendrill.h 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/pcbnew/dialogs/dialog_gendrill.h 2012-01-05 18:07:15.289119747 +0100 +@@ -33,6 +33,7 @@ + + class DIALOG_GENDRILL : public DIALOG_GENDRILL_BASE + { ++friend bool Pcbnew_CmdLine(); + public: + static int m_UnitDrillIsInch; + static int m_ZerosFormat; +diff -ru kicad.orig/pcbnew/dialogs/dialog_SVG_print.h kicad/pcbnew/dialogs/dialog_SVG_print.h +--- kicad.orig/pcbnew/dialogs/dialog_SVG_print.h 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/pcbnew/dialogs/dialog_SVG_print.h 2012-01-10 19:40:48.754648647 +0100 +@@ -13,6 +13,7 @@ + + class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base + { ++friend bool Pcbnew_CmdLine(); + private: + PCB_BASE_FRAME* m_Parent; + wxConfig* m_Config; +diff -ru kicad.orig/pcbnew/drc_stuff.h kicad/pcbnew/drc_stuff.h +--- kicad.orig/pcbnew/drc_stuff.h 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/pcbnew/drc_stuff.h 2012-01-05 18:08:06.047781508 +0100 +@@ -146,6 +146,7 @@ + */ + class DRC + { ++ friend bool Pcbnew_CmdLine(); + friend class DIALOG_DRC_CONTROL; + + private: +diff -ru kicad.orig/pcbnew/gendrill.cpp kicad/pcbnew/gendrill.cpp +--- kicad.orig/pcbnew/gendrill.cpp 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/pcbnew/gendrill.cpp 2012-01-08 17:26:28.429837548 +0100 +@@ -159,8 +159,13 @@ + fn.GetFullName(), wxGetTranslation( DrillFileWildcard ), + wxFD_SAVE | wxFD_CHANGE_DIR ); + ++ if ( g_CmdLineMode ) { ++ dlg.SetPath( fn.GetFullPath() ); ++ wxTheApp->Yield(); ++ } else { + if( dlg.ShowModal() == wxID_CANCEL ) + break; ++ } + + FILE* aFile = wxFopen( dlg.GetPath(), wxT( "w" ) ); + +@@ -619,8 +624,13 @@ + fn.GetFullName(), wildcard, + wxFD_SAVE ); + ++ if ( g_CmdLineMode ) { ++ dlg.SetPath( fn.GetFullPath() ); ++ wxTheApp->Yield(); ++ } else { + if( dlg.ShowModal() == wxID_CANCEL ) + return; ++ } + + FILE* plotfile = wxFopen( dlg.GetPath(), wxT( "wt" ) ); + +@@ -659,8 +669,13 @@ + fn.GetFullName(), wxGetTranslation( RptFileWildcard ), + wxFD_SAVE ); + ++ if ( g_CmdLineMode ) { ++ dlg.SetPath( fn.GetFullPath() ); ++ wxTheApp->Yield(); ++ } else { + if( dlg.ShowModal() == wxID_CANCEL ) + return; ++ } + + FILE* report_dest = wxFopen( dlg.GetPath(), wxT( "w" ) ); + +diff -ru kicad.orig/pcbnew/gen_modules_placefile.cpp kicad/pcbnew/gen_modules_placefile.cpp +--- kicad.orig/pcbnew/gen_modules_placefile.cpp 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/pcbnew/gen_modules_placefile.cpp 2012-01-08 18:32:33.547634589 +0100 +@@ -138,10 +138,10 @@ + return; + } + +- wxString boardFilePath = ( (wxFileName) GetScreen()->GetFileName()).GetPath(); ++ wxString boardFilePath = ( (wxFileName) GetScreen()->GetFileName()).GetFullPath(); + wxDirDialog dirDialog( this, _( "Select Output Directory" ), boardFilePath ); + +- if( dirDialog.ShowModal() == wxID_CANCEL ) ++ if( !g_CmdLineMode && dirDialog.ShowModal() == wxID_CANCEL ) + return; + + fnFront = GetScreen()->GetFileName(); +@@ -298,6 +298,7 @@ + msg.Append( fnBack.GetFullPath() ); + } + ++ if ( !g_CmdLineMode ) + wxMessageBox( msg, _( "Module Position File" ), wxICON_INFORMATION ); + + exit: // the only safe way out of here, no returns please. +diff -ru kicad.orig/pcbnew/pcbnew.cpp kicad/pcbnew/pcbnew.cpp +--- kicad.orig/pcbnew/pcbnew.cpp 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/pcbnew/pcbnew.cpp 2012-01-05 21:49:03.036099308 +0100 +@@ -44,6 +44,7 @@ + #include "pcbnew.h" + #include "protos.h" + #include "hotkeys.h" ++#include "pcbnew_cmdline.h" + + + // Colors for layers and items +@@ -111,6 +112,9 @@ + wxFileName fn; + PCB_EDIT_FRAME* frame = NULL; + ++ if ( argc >= 2 && argv[1][0] == '-' ) ++ return Pcbnew_CmdLine(); ++ + InitEDA_Appl( wxT( "Pcbnew" ), APP_PCBNEW_T ); + + if( m_Checker && m_Checker->IsAnotherRunning() ) +diff -ru kicad.orig/pcbnew/pcbnew.h kicad/pcbnew/pcbnew.h +--- kicad.orig/pcbnew/pcbnew.h 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/pcbnew/pcbnew.h 2012-01-05 21:47:10.422652798 +0100 +@@ -41,6 +41,7 @@ + #define FORCE_SKETCH ( IS_DRAGGED | IN_EDIT ) + + /* variables */ ++extern bool g_CmdLineMode; + extern bool Drc_On; + extern bool g_AutoDeleteOldTrack; + extern bool g_Drag_Pistes_On; +diff -ru kicad.orig/pcbnew/xchgmod.cpp kicad/pcbnew/xchgmod.cpp +--- kicad.orig/pcbnew/xchgmod.cpp 2012-01-02 15:12:29.461843000 +0100 ++++ kicad/pcbnew/xchgmod.cpp 2012-01-05 21:47:50.531456715 +0100 +@@ -599,6 +599,7 @@ + fn.SetExt( NetCmpExtBuffer ); + wildcard = _( "Component files (." ) + NetCmpExtBuffer + wxT( ")|*." ) + NetCmpExtBuffer; + ++ if ( !g_CmdLineMode) { + wxFileDialog dlg( this, _( "Save Component Files" ), wxGetCwd(), + fn.GetFullName(), wildcard, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); +@@ -607,6 +608,7 @@ + return; + + fn = dlg.GetPath(); ++ } + + FichCmp = wxFopen( fn.GetFullPath(), wxT( "wt" ) ); + diff --git a/kicad-patches/scripted-common.patch b/kicad-patches/scripted-common.patch deleted file mode 100644 index 82de1d2..0000000 --- a/kicad-patches/scripted-common.patch +++ /dev/null @@ -1,79 +0,0 @@ -diff -ruN kicad.orig/common/confirm.cpp kicad/common/confirm.cpp ---- kicad.orig/common/confirm.cpp 2010-10-19 08:48:07.000000000 +0000 -+++ kicad/common/confirm.cpp 2011-01-02 13:04:39.339823004 +0000 -@@ -66,6 +66,7 @@ - * See not above as to why this doesn't work. */ - } - -+bool g_IsScripted = false; - - /* Display an error or warning message. - * If display time > 0 the dialog disappears after displayTime 0.1 seconds -@@ -75,6 +76,12 @@ - { - wxMessageDialog* dialog; - -+ if (g_IsScripted) -+ { -+ wxFprintf( stderr, text + _("\n") ); -+ return; -+ } -+ - if( displaytime > 0 ) - dialog = new WinEDA_MessageDialog( parent, text, _( "Warning" ), - wxOK | wxICON_INFORMATION, -@@ -95,6 +102,11 @@ - { - wxMessageDialog* dialog; - -+ if (g_IsScripted) -+ { -+ wxPrintf( text + _("\n") ); -+ return; -+ } - dialog = new WinEDA_MessageDialog( parent, text, _( "Info:" ), - wxOK | wxICON_INFORMATION, displaytime ); - -diff -ruN kicad.orig/common/edaappl.cpp kicad/common/edaappl.cpp ---- kicad.orig/common/edaappl.cpp 2010-10-19 08:48:07.000000000 +0000 -+++ kicad/common/edaappl.cpp 2011-01-02 13:04:39.343823004 +0000 -@@ -272,6 +272,7 @@ - wxString EnvLang; - - m_Id = aId; -+if (!g_IsScripted) - m_Checker = new wxSingleInstanceChecker( aName.Lower() + wxT( "-" ) + - wxGetUserId() ); - -diff -ruN kicad.orig/include/appl_wxstruct.h kicad/include/appl_wxstruct.h ---- kicad.orig/include/appl_wxstruct.h 2010-10-19 08:48:07.000000000 +0000 -+++ kicad/include/appl_wxstruct.h 2011-01-02 15:13:47.532837657 +0000 -@@ -32,6 +32,8 @@ - /* Class representing the entire Application */ - /**********************************************/ - -+extern bool g_IsScripted; -+ - class WinEDA_App : public wxApp - { - public: -@@ -95,6 +97,8 @@ - void InitEDA_Appl( const wxString& aName, - id_app_type aId = APP_TYPE_UNKOWN ); - -+ virtual int OnRun() { return g_IsScripted ? 0 : wxApp::OnRun(); } -+ - bool SetLanguage( bool first_time = FALSE ); - - /** Function AddMenuLanguageList -diff -ruN kicad.orig/include/wxPcbStruct.h kicad/include/wxPcbStruct.h ---- kicad.orig/include/wxPcbStruct.h 2010-10-19 08:48:07.000000000 +0000 -+++ kicad/include/wxPcbStruct.h 2011-01-02 13:04:39.399823002 +0000 -@@ -50,6 +50,7 @@ - class WinEDA_PcbFrame : public WinEDA_BasePcbFrame - { - friend class PCB_LAYER_WIDGET; -+ friend bool Pcbnew_Scripted(); - - protected: - diff --git a/kicad-patches/scripted-eeschema.patch b/kicad-patches/scripted-eeschema.patch deleted file mode 100644 index 2f05220..0000000 --- a/kicad-patches/scripted-eeschema.patch +++ /dev/null @@ -1,105 +0,0 @@ -diff -ruN kicad.orig/eeschema/CMakeLists.txt kicad/eeschema/CMakeLists.txt ---- kicad.orig/eeschema/CMakeLists.txt 2010-10-19 08:48:07.000000000 +0000 -+++ kicad/eeschema/CMakeLists.txt 2011-01-02 13:06:41.627823067 +0000 -@@ -83,6 +83,7 @@ - eeredraw.cpp - eeschema.cpp - eeschema_config.cpp -+ eeschema_scripted.cpp - erc.cpp - events_called_functions_for_edit.cpp - files-io.cpp -diff -ruN kicad.orig/eeschema/dialog_build_BOM.h kicad/eeschema/dialog_build_BOM.h ---- kicad.orig/eeschema/dialog_build_BOM.h 2010-10-19 08:48:07.000000000 +0000 -+++ kicad/eeschema/dialog_build_BOM.h 2011-01-02 13:06:41.627823067 +0000 -@@ -12,6 +12,7 @@ - - class DIALOG_BUILD_BOM : public DIALOG_BUILD_BOM_BASE - { -+friend class EESCHEMA_SCRIPTED; - private: - WinEDA_DrawFrame * m_Parent; - wxConfig* m_Config; -diff -ruN kicad.orig/eeschema/dialog_erc.h kicad/eeschema/dialog_erc.h ---- kicad.orig/eeschema/dialog_erc.h 2010-10-19 08:48:07.000000000 +0000 -+++ kicad/eeschema/dialog_erc.h 2011-01-02 13:06:41.631823036 +0000 -@@ -30,6 +30,7 @@ - - class DIALOG_ERC : public DIALOG_ERC_BASE - { -+friend class EESCHEMA_SCRIPTED; - DECLARE_EVENT_TABLE() - - private: -diff -ruN kicad.orig/eeschema/dialog_SVG_print.cpp kicad/eeschema/dialog_SVG_print.cpp ---- kicad.orig/eeschema/dialog_SVG_print.cpp 2010-10-19 08:48:07.000000000 +0000 -+++ kicad/eeschema/dialog_SVG_print.cpp 2011-01-02 13:06:41.631823036 +0000 -@@ -33,6 +33,7 @@ - - class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base - { -+friend void ScriptedPrintSVGDoc( WinEDA_DrawFrame* frame, bool aPrintAll, bool aPrint_Sheet_Ref, bool aPrintBlackAndWhite ); - private: - WinEDA_DrawFrame * m_Parent; - wxConfig* m_Config; -@@ -57,6 +58,19 @@ - bool aPrint_Sheet_Ref = false); - }; - -+void ScriptedPrintSVGDoc( WinEDA_DrawFrame* frame, bool aPrintAll, bool aPrint_Sheet_Ref, bool aPrintBlackAndWhite ) -+{ -+ // TBD: It would be better to iterate over the pages ourselves and use -+ // DrawSVGPage() directly, bypassing the GUI dialog... -+ class DIALOG_SVG_PRINT* dlg = new DIALOG_SVG_PRINT( frame ); -+ dlg->m_DialogPenWidth->SetValue( -+ ReturnStringFromValue(g_UserUnit, g_DrawDefaultLineThickness, -+ dlg->m_Parent->m_InternalUnits ) ); -+ dlg->m_ModeColorOption->SetSelection( aPrintBlackAndWhite ); -+ dlg->PrintSVGDoc( aPrintAll, aPrint_Sheet_Ref ); -+ delete dlg; -+} -+ - - /* Prepare the data structures of print management and display the dialog - * window for printing sheets. -diff -ruN kicad.orig/eeschema/eeschema.cpp kicad/eeschema/eeschema.cpp ---- kicad.orig/eeschema/eeschema.cpp 2010-10-19 08:48:07.000000000 +0000 -+++ kicad/eeschema/eeschema.cpp 2011-01-02 16:55:25.188837657 +0000 -@@ -15,6 +15,7 @@ - #include "program.h" - #include "general.h" - #include "protos.h" -+#include "eeschema_scripted.h" - - #include - -@@ -128,6 +129,9 @@ - - g_DebugLevel = 0; // Debug level */ - -+ if ( argc >= 2 && argv[1][0] == '-' ) -+ return g_EESchemaScripted.Run(); -+ - InitEDA_Appl( wxT( "EESchema" ), APP_TYPE_EESCHEMA ); - - if( m_Checker && m_Checker->IsAnotherRunning() ) -diff -ruN kicad.orig/eeschema/erc.cpp kicad/eeschema/erc.cpp ---- kicad.orig/eeschema/erc.cpp 2011-01-02 17:35:54.236837659 +0000 -+++ kicad/eeschema/erc.cpp 2011-01-02 13:06:41.631823036 +0000 -@@ -557,6 +557,7 @@ - fn = g_RootSheet->m_AssociatedScreen->m_FileName; - fn.SetExt( wxT( "erc" ) ); - -+if (!g_IsScripted) { - wxFileDialog dlg( this, _( "ERC File" ), fn.GetPath(), fn.GetFullName(), - _( "Electronic rule check file (.erc)|*.erc" ), - wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); -@@ -570,6 +571,8 @@ - ExecuteFile( this, wxGetApp().GetEditorName(), - QuoteFullPath( fn ) ); - } -+} else -+ WriteDiagnosticERC( fn.GetFullPath() ); - } - } - diff --git a/kicad-patches/scripted-new.patch b/kicad-patches/scripted-new.patch deleted file mode 100644 index c3789e4..0000000 --- a/kicad-patches/scripted-new.patch +++ /dev/null @@ -1,825 +0,0 @@ -diff -ruN kicad.orig/eeschema/eeschema_scripted.cpp kicad/eeschema/eeschema_scripted.cpp ---- kicad.orig/eeschema/eeschema_scripted.cpp 1970-01-01 00:00:00.000000000 +0000 -+++ kicad/eeschema/eeschema_scripted.cpp 2011-03-13 02:25:17.039706999 +0000 -@@ -0,0 +1,236 @@ -+///////////////////////////////////////////////////////////////////////////// -+// Name: eeschema_scripted.cpp -+// Copyright: Werner Almesberger, Wolfgang Spraul -+// Licence: GPL v2 or higher -+///////////////////////////////////////////////////////////////////////////// -+ -+#include "fctsys.h" -+#include "appl_wxstruct.h" -+#include "common.h" -+#include "program.h" -+#include "general.h" -+#include "netlist.h" -+#include "protos.h" -+#include "gr_basic.h" -+#include "plotps.h" -+#include "wx/cmdline.h" -+#include "dialog_build_BOM.h" -+#include "dialog_SVG_print_base.h" -+#include "dialog_erc.h" -+#include "plotdxf.h" -+#include "class_drawsheetpath.h" -+#include "eeschema_scripted.h" -+ -+EESCHEMA_SCRIPTED g_EESchemaScripted; -+ -+static const wxCmdLineEntryDesc g_cmdLineDesc [] = -+{ -+ { wxCMD_LINE_SWITCH, wxT("h"), wxT("help"), wxT("displays help on the command line parameters"), -+ wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, -+ -+ { wxCMD_LINE_SWITCH, wxT("l"), wxT("list-sheets"), wxT("list schematics pages") }, -+ -+ { wxCMD_LINE_OPTION, wxT("p"), wxT("plot"), wxT("plots the board [ps|svg|dxf]"), -+ wxCMD_LINE_VAL_STRING }, -+ { wxCMD_LINE_SWITCH, wxT("plot-bw"), wxT("plot-bw"), wxT("plot: black & white (default: color)") }, -+ { wxCMD_LINE_SWITCH, wxT("plot-sheetref"), wxT("plot-sheetref"), wxT("plot: print sheet reference (default: off)") }, -+ -+ { wxCMD_LINE_SWITCH, wxT("b"), wxT("bom"), wxT("generate bill of materials (.bom)") }, -+ { wxCMD_LINE_SWITCH, wxT("e"), wxT("erc"), wxT("generate electric rules check (.erc) file") }, -+ { wxCMD_LINE_SWITCH, wxT("n"), wxT("netlist"), wxT("generate netlist (.net)") }, -+ { wxCMD_LINE_PARAM, 0, 0, wxT(""), -+ wxCMD_LINE_VAL_STRING }, -+ { wxCMD_LINE_NONE } -+}; -+ -+bool ScriptedDrawSVGPage( WinEDA_DrawFrame * frame, -+ const wxString& FullFileName, BASE_SCREEN* screen, -+ bool aPrintBlackAndWhite = false, -+ bool aPrint_Sheet_Ref = false); -+ -+bool EESCHEMA_SCRIPTED::Run() -+{ -+ wxFileName fn; -+ WinEDA_SchematicFrame* frame; -+ wxCommandEvent DummyCmd; -+ wxString str; -+ int i; -+ -+ WinEDA_App& app = wxGetApp(); -+ g_IsScripted = true; -+ wxLog::EnableLogging(false); // this should suppress some wx dialogs -+ app.InitEDA_Appl( wxT( "EESchema" ), APP_TYPE_EESCHEMA ); -+ -+ wxCmdLineParser parser; -+ parser.SetDesc(g_cmdLineDesc); -+ parser.SetCmdLine(app.argc, app.argv); -+ if (parser.Parse()) -+ return false; -+ -+ i = parser.Found( _("list-sheets") ) -+ + parser.Found( _("plot") ) -+ + parser.Found( _("bom") ) -+ + parser.Found( _("erc") ) -+ + parser.Found( _("netlist") ); -+ if ( !i ) -+ { -+ wxFprintf( stderr, wxT("One of --list-sheets --plot --bom --erc --netlist must be given.\n")); -+ return false; -+ } -+ if ( i > 1 ) -+ { -+ wxFprintf( stderr, wxT("Only one of --list-sheets --plot --bom --erc --netlist may be given at a time.\n")); -+ return false; -+ } -+ -+ // parse plotting parameters -+ enum PlotCommand { -+ PLOT_NONE, -+ PLOT_PS, -+ PLOT_SVG, -+ PLOT_DXF -+ } PlotCmd; -+ bool PlotBW; -+ bool PlotSheetRef; -+ -+ PlotCmd = PLOT_NONE; -+ if ( parser.Found( _("plot"), &str ) ) -+ { -+ if (!str.CmpNoCase( wxT("ps") ) ) -+ PlotCmd = PLOT_PS; -+ else if ( !str.CmpNoCase( wxT("svg") ) ) -+ PlotCmd = PLOT_SVG; -+ else if ( !str.CmpNoCase( wxT("dxf") ) ) -+ PlotCmd = PLOT_DXF; -+ else -+ { -+ wxFprintf( stderr, wxT("Unexpected plot format '%ls'.\n"), str.c_str()); -+ return false; -+ } -+ PlotBW = parser.Found( _("plot-bw") ); -+ PlotSheetRef = parser.Found( _("plot-sheetref") ); -+ } -+ -+ fn = parser.GetParam(); -+ if( fn.GetExt() != SchematicFileExtension ) -+ { -+ wxLogDebug( wxT( "eeschema file <%s> has the wrong extension. Changing extension to .sch." ), GetChars( fn.GetFullPath() ) ); -+ fn.SetExt( PcbFileExtension ); -+ } -+ if( !fn.FileExists()) -+ { -+ wxFprintf( stderr, wxT("%ls: file '%ls' does not exist.\n" ), app.argv[0], fn.GetFullPath().c_str() ); -+ return false; -+ } -+ wxSetWorkingDirectory( fn.GetPath() ); -+ -+ SeedLayers(); -+ frame = new WinEDA_SchematicFrame( NULL, wxT( "EESchema" ), -+ wxPoint( 0, 0 ), wxSize( 600, 400 ) ); -+ ActiveScreen = frame->GetScreen(); -+ app.SetTopWindow( frame ); -+#if 0 // enable this to see more of the GUI -+ frame->Show( true ); -+#endif -+ if( !frame->LoadOneEEProject( fn.GetFullPath(), false ) ) -+ { -+ wxFprintf( stderr, fn.GetFullPath() + _(": can't load\n") ); -+ return false; -+ } -+ -+ if ( parser.Found( wxT("list-sheets") ) ) // class_drawsheetpath.h -+ // dialog_SVG_print.cpp:DIALOG_SVG_PRINT:PrintSVGDoc() -+ { -+ SCH_SHEET_LIST SheetList( 0 /* aSheet */ ); -+ SCH_SHEET_PATH* sheetpath, *oldsheetpath; -+ SCH_SHEET_PATH list; -+ SCH_SCREEN* schscreen; -+ -+ oldsheetpath = frame->GetSheet(); -+ sheetpath = SheetList.GetFirst(); -+ while ( sheetpath ) -+ { -+ list.Clear(); -+ if ( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) -+ { -+ frame->m_CurrentSheet = &list; -+ frame->m_CurrentSheet->UpdateAllScreenReferences(); -+ frame->SetSheetNumberAndCount(); -+ schscreen = frame->m_CurrentSheet->LastScreen(); -+ ActiveScreen = schscreen; -+ -+ wxPrintf( sheetpath->Path() + _(" ") -+ + sheetpath->PathHumanReadable() + _(" ") -+ + sheetpath->Last()->GetFileName() + _(" ") -+ + frame->GetUniqueFilenameForCurrentSheet( ) + wxT( ".sch\n") ); -+ } -+ sheetpath = SheetList.GetNext(); -+ } -+ frame->m_CurrentSheet = oldsheetpath; -+ frame->m_CurrentSheet->UpdateAllScreenReferences(); -+ frame->SetSheetNumberAndCount(); -+ } -+ else if ( PlotCmd == PLOT_PS ) // plotps.cpp -+ { -+ // values must be idential to plotps.cpp:PageFormatReq -+ enum PageFormatReq { -+ PAGE_SIZE_AUTO, -+ PAGE_SIZE_A4, -+ PAGE_SIZE_A -+ }; -+ -+ WinEDA_PlotPSFrame* PlotPSFrame = new WinEDA_PlotPSFrame( frame ); -+ PlotPSFrame->m_Plot_Sheet_Ref->SetValue( PlotSheetRef ); -+ -+ // Strangely it seems that the plots come out right when 'A4' is -+ // selected, even if it's actually not A4 format. But when PAGE_SIZE_AUTO -+ // is selected, pages are cut off. Until we understand this better we -+ // always use A4. -+ PlotPSFrame->m_SizeOption->SetSelection( PAGE_SIZE_A4 ); -+ -+ PlotPSFrame->m_PlotPSColorOption->SetSelection( !PlotBW ); -+ PlotPSFrame->OnPlotPsAllExecuteClick( DummyCmd ); -+ delete PlotPSFrame; -+ } -+ else if ( PlotCmd == PLOT_SVG ) // dialog_SVG_print.cpp:DIALOG_SVG_PRINT::DrawSVGPage() -+ { -+ void ScriptedPrintSVGDoc( WinEDA_DrawFrame* frame, bool aPrintAll, bool aPrint_Sheet_Ref, bool aPrintBlackAndWhite ); -+ ScriptedPrintSVGDoc( frame, true /* aPrintAll */, PlotSheetRef, PlotBW ); -+ } -+ else if ( PlotCmd == PLOT_DXF ) // plotdxf.cpp:WinEDA_PlotDXFFrame::CreateDXFFile() -+ { -+ WinEDA_PlotDXFFrame* PlotDXFFrame = new WinEDA_PlotDXFFrame( frame ); -+ PlotDXFFrame->m_Plot_Sheet_Ref->SetValue( PlotSheetRef ); -+ PlotDXFFrame->m_PlotDXFColorOption->SetSelection( !PlotBW ); -+ PlotDXFFrame->OnPlotDXFAllExecuteClick( DummyCmd ); -+ delete PlotDXFFrame; -+ } -+ else if ( parser.Found( wxT("bom") ) ) // see build_BOM.cpp:DIALOG_BUILD_BOM::GenereListeOfItems() -+ { -+ DIALOG_BUILD_BOM* dlg = new DIALOG_BUILD_BOM( frame ); -+ -+ dlg->m_ListCmpbyRefItems->SetValue( true ); -+ dlg->m_AddFootprintField->SetValue( true ); -+ dlg->m_AddAllFields->SetValue( true ); -+ -+ fn = ActiveScreen->m_FileName; -+ fn.SetExt( wxT( "lst" ) ); -+ dlg->GenereListeOfItems( fn.GetFullPath(), false /* aIncludeSubComponents */ ); -+ delete dlg; -+ } -+ else if ( parser.Found( wxT("erc") ) ) // erc.cpp:DIALOG_ERC::TestErc() -+ { -+ DIALOG_ERC* dlg = new DIALOG_ERC( frame ); -+ dlg->m_WriteResultOpt->SetValue( true ); -+ dlg->TestErc( 0 /* messageList */ ); -+ delete dlg; -+ } -+ else if ( parser.Found( wxT("netlist") ) ) // netlist_control.cpp:WinEDA_SchematicFrame::CreateNetlist() -+ { -+ frame->BuildNetListBase(); -+ fn = ActiveScreen->m_FileName; -+ fn.SetExt( wxT( "net" ) ); -+ frame->WriteNetListFile( NET_TYPE_PCBNEW /* aFormat */, fn.GetFullPath(), false /* aUse_netnames - only used for Spice */ ); -+ } -+ return true; -+} -diff -ruN kicad.orig/eeschema/eeschema_scripted.h kicad/eeschema/eeschema_scripted.h ---- kicad.orig/eeschema/eeschema_scripted.h 1970-01-01 00:00:00.000000000 +0000 -+++ kicad/eeschema/eeschema_scripted.h 2011-01-02 13:10:04.267823004 +0000 -@@ -0,0 +1,14 @@ -+///////////////////////////////////////////////////////////////////////////// -+// Name: eeschema_scripted.h -+// Copyright: Wolfgang Spraul -+// Licence: GPL v3 or higher -+///////////////////////////////////////////////////////////////////////////// -+ -+class EESCHEMA_SCRIPTED -+{ -+public: -+ EESCHEMA_SCRIPTED() { } -+ bool Run(); -+}; -+ -+extern EESCHEMA_SCRIPTED g_EESchemaScripted; -diff -ruN kicad.orig/pcbnew/pcbnew_scripted.cpp kicad/pcbnew/pcbnew_scripted.cpp ---- kicad.orig/pcbnew/pcbnew_scripted.cpp 1970-01-01 00:00:00.000000000 +0000 -+++ kicad/pcbnew/pcbnew_scripted.cpp 2011-03-13 06:55:03.227707000 +0000 -@@ -0,0 +1,552 @@ -+///////////////////////////////////////////////////////////////////////////// -+// Name: pcbnew_scripted.cpp -+// Copyright: Wolfgang Spraul -+// Licence: GPL v3 or higher -+///////////////////////////////////////////////////////////////////////////// -+ -+#include "fctsys.h" -+#include "appl_wxstruct.h" -+#include "confirm.h" -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include "common.h" -+#include "pcbnew.h" -+#include "wxPcbStruct.h" -+#include "plot_common.h" -+#include "gestfich.h" -+#include "pcbplot.h" -+#include "autorout.h" -+#include "cell.h" -+#include "worksheet.h" -+#include "zones.h" -+#include "drag.h" -+#include "eda_dde.h" -+#include "colors_selection.h" -+#include "class_drawpanel.h" -+ -+#include "id.h" -+ -+#include "build_version.h" -+ -+#include "protos.h" -+#include "pcbnew_scripted.h" -+#include "gendrill.h" -+#include "dialog_gendrill.h" -+#include "dialog_drc.h" -+#include "printout_controler.h" -+ -+extern int g_DrawDefaultLineThickness; -+ -+static const wxCmdLineEntryDesc g_cmdLineDesc [] = -+{ -+ { wxCMD_LINE_SWITCH, wxT("h"), wxT("help"), wxT("displays help on the command line parameters"), -+ wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, -+ { wxCMD_LINE_SWITCH, wxT("d"), wxT("drill"), wxT("generates a .drl drill file") }, -+ { wxCMD_LINE_SWITCH, wxT("list-layers"), wxT("list-layers"), wxT("lists the names of all enabled layers in the .brd file") }, -+ { wxCMD_LINE_OPTION, wxT("p"), wxT("plot"), wxT("plots the board [hpgl|gerber|ps|ps_a4|dxf]"), -+ wxCMD_LINE_VAL_STRING }, -+ { wxCMD_LINE_OPTION, wxT("l"), wxT("layers"), wxT("comma separated list of layer names (default: all enabled layers)"), -+ wxCMD_LINE_VAL_STRING }, -+ { wxCMD_LINE_OPTION, wxT("ps-pads-drill-opt"), wxT("ps-pads-drill-opt"), wxT("Postscript pads drill option [none|small|real] (default:small)"), -+ wxCMD_LINE_VAL_STRING }, -+ { wxCMD_LINE_SWITCH, wxT("mirror"), wxT("mirror"), wxT("mirror plot (HPGL and Postscript only)") }, -+ { wxCMD_LINE_SWITCH, wxT("e"), wxT("exclude-pcb-edge"), wxT("exclude PCB edge (Gerber only)") }, -+ { wxCMD_LINE_SWITCH, wxT("fill-all-zones"), wxT("fill-all-zones"), wxT("fill zones before plotting") }, -+ { wxCMD_LINE_SWITCH, wxT("drc"), wxT("drc"), wxT("generates a design rule check report (.rpt)") }, -+ { wxCMD_LINE_SWITCH, wxT("svg"), wxT("svg"), wxT("plots the board in SVG format") }, -+ { wxCMD_LINE_SWITCH, wxT("svg-merge"), wxT("svg-merge-layers"), wxT("merge layers into one SVG file") }, -+ { wxCMD_LINE_SWITCH, wxT("svg-edge"), wxT("svg-board-edges"), wxT("add board edges to SVG plots") }, -+ { wxCMD_LINE_SWITCH, wxT("pos"), wxT("pos"), wxT("create front and back .pos component position files") }, -+ { wxCMD_LINE_SWITCH, wxT("bom"), wxT("bom"), wxT("create a .csv bom") }, -+ { wxCMD_LINE_SWITCH, wxT("cmp"), wxT("cmp"), wxT("recreate .cmp components file for CvPcb") }, -+ { wxCMD_LINE_SWITCH, wxT("vrml"), wxT("vrml"), wxT("generates a .wrl vrml board representation") }, -+ { wxCMD_LINE_PARAM, 0, 0, wxT(""), -+ wxCMD_LINE_VAL_STRING }, -+ { wxCMD_LINE_NONE } -+}; -+ -+bool Pcbnew_Scripted() -+{ -+ wxFileName fn; -+ wxString str; -+ WinEDA_PcbFrame* frame = NULL; -+ wxCommandEvent dummy; -+ int i; -+ -+ WinEDA_App& app = wxGetApp(); -+ g_IsScripted = true; -+ wxLog::EnableLogging(false); // this should suppress some wx dialogs -+ app.InitEDA_Appl( wxT( "PCBnew" ), APP_TYPE_PCBNEW ); -+ -+ wxCmdLineParser parser; -+ parser.SetDesc(g_cmdLineDesc); -+ parser.SetCmdLine(app.argc, app.argv); -+ if (parser.Parse()) -+ return false; -+ if ( parser.Found( wxT("ps-pads-drill-opt"), &str ) -+ && str.CmpNoCase( wxT("none") ) -+ && str.CmpNoCase( wxT("small") ) -+ && str.CmpNoCase( wxT("real") )) -+ { -+ wxFprintf( stderr, wxT("Unexpected pads drill option '%ls'.\n"), str.c_str()); -+ return false; -+ } -+ i = parser.Found( _("drill") ) -+ + parser.Found( _("list-layers") ) -+ + parser.Found( _("plot") ) -+ + parser.Found( _("drc") ) -+ + parser.Found( _("svg") ) -+ + parser.Found( _("pos") ) -+ + parser.Found( _("bom") ) -+ + parser.Found( _("cmp") ) -+ + parser.Found( _("vrml") ); -+ if ( !i ) -+ { -+ wxFprintf( stderr, wxT("One of --drill --list-layers --plot --drc --svg --pos --bom --cmp --vrml must be given.\n")); -+ return false; -+ } -+ if ( i > 1 ) -+ { -+ wxFprintf( stderr, wxT("Only one of --drill --list-layers --plot --drc --svg --pos --bom --cmp --vrml may be given at a time.\n")); -+ return false; -+ } -+ -+ fn = parser.GetParam(); -+ if( fn.GetExt() != PcbFileExtension ) -+ { -+ wxLogDebug( wxT( "PcbNew file <%s> has the wrong extension. Changing extension to .brd." ), GetChars( fn.GetFullPath() ) ); -+ fn.SetExt( PcbFileExtension ); -+ } -+ if( !fn.FileExists()) -+ { -+ wxFprintf( stderr, wxT("%ls: file '%ls' does not exist.\n" ), app.argv[0], fn.GetFullPath().c_str() ); -+ return false; -+ } -+ wxSetWorkingDirectory( fn.GetPath() ); -+ -+ app.InitEDA_Appl( wxT( "PCBnew" ), APP_TYPE_PCBNEW ); -+ ScreenPcb = new PCB_SCREEN(); -+ ActiveScreen = ScreenPcb; -+ app.GetSettings( false /* reopenLastUsedDirectory */ ); -+ -+ g_DrawBgColor = BLACK; -+ frame = new WinEDA_PcbFrame( NULL, wxT( "PcbNew" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) ); -+ app.SetTopWindow( frame ); -+ -+#if 0 // enable this to see more of the GUI -+ frame->Show( true ); -+ frame->Zoom_Automatique( true ); -+#endif -+ -+ frame->LoadOnePcbFile( fn.GetFullPath() ); -+ frame->LoadProjectSettings( fn.GetFullPath() ); -+ -+ if ( parser.Found( wxT("drill") ) ) -+ { -+ DIALOG_GENDRILL* drill_frame = new DIALOG_GENDRILL( frame ); -+ drill_frame->GenDrillFiles( dummy ); -+ delete drill_frame; -+ } -+ if ( parser.Found( wxT("list-layers") ) ) -+ { -+ for ( i = 0; i < NB_LAYERS; i++ ) -+ { -+ if( frame->GetBoard()->IsLayerEnabled( i ) ) -+ { -+ str = frame->GetBoard()->GetLayerName( i ); -+ str.Trim( true ); str.Trim( false ); // remove leading and trailing spaces if any -+ wxPrintf(str + _("\n")); -+ } -+ } -+ } -+ if ( parser.Found( wxT("plot"), &str ) ) // see pcbplot.cpp -+ { -+ bool ps_use_a4; -+ int plot_format; -+ wxString ext, layers_str; -+ -+ g_pcb_plot_options.PlotLine_Width = g_DrawDefaultLineThickness; -+ if (!str.CmpNoCase( wxT("ps") ) ) -+ { -+ plot_format = PLOT_FORMAT_POST; -+ ext = wxT( "ps" ); -+ ps_use_a4 = false; -+ } -+ else if ( !str.CmpNoCase( wxT("ps_a4") ) ) -+ { -+ plot_format = PLOT_FORMAT_POST; -+ ext = wxT( "ps" ); -+ ps_use_a4 = true; -+ } -+ else if ( !str.CmpNoCase( wxT("hpgl") ) ) -+ { -+ plot_format = PLOT_FORMAT_HPGL; -+ ext = wxT( "plt" ); -+ } -+ else if ( !str.CmpNoCase( wxT("gerber") ) ) -+ { -+ plot_format = PLOT_FORMAT_GERBER; -+ ext = wxT( "pho" ); -+ } -+ else if ( !str.CmpNoCase( wxT("dxf") ) ) -+ { -+ plot_format = PLOT_FORMAT_DXF; -+ ext = wxT( "dxf" ); -+ } -+ else -+ { -+ wxFprintf( stderr, wxT("Unexpected plot type '%ls'.\n"), str.c_str()); -+ return false; -+ } -+ -+ // --ps-pads-drill-opt -+ if ( plot_format == PLOT_FORMAT_POST && parser.Found( wxT("ps-pads-drill-opt"), &str ) ) -+ { -+ if (!str.CmpNoCase( wxT("none") ) ) -+ g_pcb_plot_options.DrillShapeOpt = PCB_Plot_Options::NO_DRILL_SHAPE; -+ else if ( !str.CmpNoCase( wxT("small") ) ) -+ g_pcb_plot_options.DrillShapeOpt = PCB_Plot_Options::SMALL_DRILL_SHAPE; -+ else if ( !str.CmpNoCase( wxT("real") ) ) -+ g_pcb_plot_options.DrillShapeOpt = PCB_Plot_Options::FULL_DRILL_SHAPE; -+ else -+ { -+ wxFprintf( stderr, wxT("Unexpected Postscript pads drill option '%ls'.\n"), str.c_str()); -+ return false; -+ } -+ } -+ -+ // --mirror -+ if ( parser.Found( wxT("mirror") ) ) -+ g_pcb_plot_options.PlotOrient = PLOT_MIROIR; -+ -+ // --exclude-pcb-edge -+ if ( parser.Found( wxT("exclude-pcb-edge") ) ) -+ g_pcb_plot_options.Exclude_Edges_Pcb = true; -+ -+ // --fill-all-zones -+ if ( parser.Found( wxT("fill-all-zones") ) ) -+ frame->Fill_All_Zones( false /* verbose */ ); -+ -+ parser.Found( wxT("layers"), &layers_str ); -+ wxStringTokenizer tokenizer( layers_str, _(",") ); -+ int layer_i = 0; -+ wxString layername; -+ while ( ( layers_str.IsEmpty() && layer_i < NB_LAYERS ) || tokenizer.HasMoreTokens() ) -+ { -+ if ( layers_str.IsEmpty() ) -+ { -+ if( !frame->GetBoard()->IsLayerEnabled( layer_i ) ) -+ { -+ layer_i++; -+ continue; -+ } -+ layername = frame->GetBoard()->GetLayerName( layer_i ); -+ layername.Trim( true ); layername.Trim( false ); // remove leading and trailing spaces if any -+ layer_i++; -+ } -+ else -+ { -+ layername = tokenizer.GetNextToken(); -+ for( layer_i = 0; layer_i < NB_LAYERS; layer_i++ ) -+ { -+ str = frame->GetBoard()->GetLayerName( layer_i ); -+ str.Trim( true ); str.Trim( false ); // remove leading and trailing spaces if any -+ if ( !str.Cmp( layername ) ) -+ break; -+ } -+ if (layer_i >= NB_LAYERS) -+ { -+ wxFprintf( stderr, _( "Unknown layer name '%ls'\n" ), layername.c_str() ); -+ continue; -+ } -+ } -+ fn = ScreenPcb->m_FileName; -+ fn.SetName( fn.GetName() + wxT( "-" ) + layername ); -+ -+ // Use Gerber Extensions based on layer number -+ // (See http://en.wikipedia.org/wiki/Gerber_File) -+ if( (plot_format == PLOT_FORMAT_GERBER) && true /* always use gerber extensions */ ) -+ { -+ switch( layer_i ) -+ { -+ case LAYER_N_FRONT: -+ fn.SetExt( wxT( "gtl" ) ); -+ break; -+ -+ case LAYER_N_2: -+ case LAYER_N_3: -+ case LAYER_N_4: -+ case LAYER_N_5: -+ case LAYER_N_6: -+ case LAYER_N_7: -+ case LAYER_N_8: -+ case LAYER_N_9: -+ case LAYER_N_10: -+ case LAYER_N_11: -+ case LAYER_N_12: -+ case LAYER_N_13: -+ case LAYER_N_14: -+ case LAYER_N_15: -+ -+ // TODO: see if we use .gbr or a layer identifier (gb1 .. gbnn ?) -+ // according to the new internal layers designation -+ // (1 is the first internal layer from the front layer) -+ fn.SetExt( wxT( "gbr" ) ); -+ break; -+ -+ case LAYER_N_BACK: -+ fn.SetExt( wxT( "gbl" ) ); -+ break; -+ -+ case ADHESIVE_N_BACK: -+ fn.SetExt( wxT( "gba" ) ); -+ break; -+ -+ case ADHESIVE_N_FRONT: -+ fn.SetExt( wxT( "gta" ) ); -+ break; -+ -+ case SOLDERPASTE_N_BACK: -+ fn.SetExt( wxT( "gbp" ) ); -+ break; -+ -+ case SOLDERPASTE_N_FRONT: -+ fn.SetExt( wxT( "gtp" ) ); -+ break; -+ -+ case SILKSCREEN_N_BACK: -+ fn.SetExt( wxT( "gbo" ) ); -+ break; -+ -+ case SILKSCREEN_N_FRONT: -+ fn.SetExt( wxT( "gto" ) ); -+ break; -+ -+ case SOLDERMASK_N_BACK: -+ fn.SetExt( wxT( "gbs" ) ); -+ break; -+ -+ case SOLDERMASK_N_FRONT: -+ fn.SetExt( wxT( "gts" ) ); -+ break; -+ -+ case DRAW_N: -+ case COMMENT_N: -+ case ECO1_N: -+ case ECO2_N: -+ case EDGE_N: -+ default: -+ fn.SetExt( wxT( "gbr" ) ); -+ break; -+ } -+ } -+ else -+ { -+ fn.SetExt( ext ); -+ } -+ -+ bool success = false; -+ -+ switch( plot_format ) -+ { -+ case PLOT_FORMAT_POST: -+ success = frame->Genere_PS( fn.GetFullPath(), layer_i, ps_use_a4, -+ FILLED /* trace_mode */ ); -+ break; -+ -+ case PLOT_FORMAT_GERBER: -+ success = frame->Genere_GERBER( fn.GetFullPath(), layer_i, -+ false /* PlotOriginIsAuxAxis */, -+ FILLED /* trace_mode */ ); -+ break; -+ -+ case PLOT_FORMAT_HPGL: -+ success = frame->Genere_HPGL( fn.GetFullPath(), layer_i, -+ FILLED /* trace_mode */ ); -+ break; -+ -+ case PLOT_FORMAT_DXF: -+ success = frame->Genere_DXF( fn.GetFullPath(), layer_i, -+ FILLED /* trace_mode */ ); -+ break; -+ } -+ -+ // Print diags in messages box: -+ wxString msg; -+ if( !success ) -+ wxFprintf( stderr, _( "Unable to create <%s>\n" ), GetChars( fn.GetFullPath() ) ); -+ } -+ } -+ if ( parser.Found( wxT("drc") ) ) // drc_stuff.h drc.cpp dialog_drc.{h,cpp} -+ { -+ fn = ScreenPcb->m_FileName; -+ fn.SetExt( _("rpt") ); -+ -+ // if you get a segfault, try adding frame->m_drc->ShowDialog() to run through the GUI codepath -+ frame->m_drc->updatePointers(); -+ frame->m_drc->SetSettings(true, // Pad to pad DRC test enabled -+ true, // unconnected pdas DRC test enabled -+ true, // DRC test for zones enabled -+ fn.GetFullPath(), // report file name -+ true /* aSaveReport */ ); -+ frame->m_drc->m_pcb->m_Status_Pcb = 0; // Force full connectivity and ratsnest recalculations -+ frame->m_drc->RunTests(); -+ FILE* fp = wxFopen( fn.GetFullPath(), wxT( "w" ) ); -+ { // strings should match dialog_drc.cpp:DIALOG_DRC_CONTROL::writeReport() -+ int count; -+ -+ fprintf( fp, "** Drc report for %s **\n", -+ CONV_TO_UTF8( ScreenPcb->m_FileName ) ); -+ -+ wxDateTime now = wxDateTime::Now(); -+ fprintf( fp, "** Created on %s **\n", CONV_TO_UTF8( now.Format( wxT( "%F %T" ) ) ) ); -+ -+ class DRC_LIST_MARKERS* markers = new DRC_LIST_MARKERS( frame->m_drc->m_pcb ); -+ count = markers->GetCount(); -+ fprintf( fp, "\n** Found %d DRC errors **\n", count ); -+ for ( i = 0; i < count; i++ ) -+ fprintf( fp, "%s", CONV_TO_UTF8( markers->GetItem( i )->ShowReport()) ); -+ delete markers; -+ -+ class DRC_LIST_UNCONNECTED* unconnected = new DRC_LIST_UNCONNECTED( &frame->m_drc->m_unconnected ); -+ count = unconnected->GetCount(); -+ fprintf( fp, "\n** Found %d unconnected pads **\n", count ); -+ for ( i = 0; i < count; i++ ) -+ fprintf( fp, "%s", CONV_TO_UTF8( unconnected->GetItem( i )->ShowReport()) ); -+ delete unconnected; -+ -+ fprintf( fp, "\n** End of Report **\n" ); -+ } -+ fclose( fp ); -+ } -+ if ( parser.Found( wxT("svg") ) ) // see dialog_SVG_print.cpp:DIALOG_SVG_PRINT::DrawPage() -+ { -+ BASE_SCREEN* screen = frame->GetBaseScreen(); -+ wxSize SheetSize; // Sheet size in internal units -+ wxString layers_str; -+ PRINT_PARAMETERS print_params; -+ long PrintMaskLayer; -+ int layer_i; -+ wxSVGFileDC* dc; -+ -+ screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0; -+ screen->m_StartVisu.x = screen->m_StartVisu.y = 0; -+ SheetSize = screen->m_CurrentSheetDesc->m_Size; // size in 1/1000 inch -+ SheetSize.x *= frame->m_InternalUnits / 1000; -+ SheetSize.y *= frame->m_InternalUnits / 1000; // size in pixels -+ screen->SetScalingFactor( 1.0 ); -+ screen->m_IsPrinting = true; -+ float dpi = (float)frame->m_InternalUnits; -+ -+ frame->DrawPanel->m_ClipBox.SetX( 0 ); -+ frame->DrawPanel->m_ClipBox.SetY( 0 ); -+ frame->DrawPanel->m_ClipBox.SetWidth( 0x7FFFFF0 ); -+ frame->DrawPanel->m_ClipBox.SetHeight( 0x7FFFFF0 ); -+ -+ print_params.m_DrillShapeOpt = PRINT_PARAMETERS::FULL_DRILL_SHAPE; -+ print_params.m_Print_Sheet_Ref = false; // reference in bottom-right corner -+ -+ SetLocaleTo_C_standard(); // Switch the locale to standard C (needed -+ // to print floating point numbers like 1.3) -+ int bg_color = g_DrawBgColor; -+ g_DrawBgColor = WHITE; -+ -+ PrintMaskLayer = 0; -+ if ( parser.Found( wxT("layers"), &layers_str ) ) -+ { -+ wxStringTokenizer tokenizer( layers_str, _(",") ); -+ layer_i = 0; -+ wxString layername; -+ while ( tokenizer.HasMoreTokens() ) -+ { -+ layername = tokenizer.GetNextToken(); -+ for( layer_i = 0; layer_i < NB_LAYERS; layer_i++ ) -+ { -+ str = frame->GetBoard()->GetLayerName( layer_i ); -+ str.Trim( true ); str.Trim( false ); // remove leading and trailing spaces if any -+ if ( !str.Cmp( layername ) ) -+ break; -+ } -+ if (layer_i >= NB_LAYERS) -+ { -+ wxFprintf( stderr, _( "Unknown layer name '%ls'\n" ), layername.c_str() ); -+ continue; -+ } -+ PrintMaskLayer |= 1 << layer_i; -+ } -+ } -+ else -+ { -+ for ( layer_i = 0; layer_i < NB_LAYERS; layer_i++ ) -+ { -+ if ( frame->GetBoard()->IsLayerEnabled( layer_i ) ) -+ PrintMaskLayer |= 1 << layer_i; -+ } -+ } -+ -+ bool SvgMergeLayers = parser.Found( wxT("svg-merge-layers") ); -+ bool SvgEdgeLayer = parser.Found( wxT("svg-board-edges") ); -+ -+ for ( layer_i = 0; layer_i < NB_LAYERS; layer_i++ ) -+ { -+ long LayerMask; -+ -+ fn = ScreenPcb->m_FileName; -+ fn.SetExt( _("svg") ); -+ if ( SvgMergeLayers ) -+ { -+ fn.SetName( fn.GetName() + wxT( "-brd" ) ); -+ LayerMask = PrintMaskLayer; -+ } -+ else -+ { -+ if ( !(PrintMaskLayer & (1 << layer_i) )) -+ continue; -+ str = frame->GetBoard()->GetLayerName( layer_i ); -+ str.Trim( true ); str.Trim( false ); // remove leading and trailing spaces if any -+ fn.SetName( fn.GetName() + wxT( "-" ) + str ); -+ LayerMask = 1 << layer_i; -+ } -+ if ( SvgEdgeLayer ) -+ LayerMask |= EDGE_LAYER; -+ -+ dc = new wxSVGFileDC( fn.GetFullPath(), SheetSize.x, SheetSize.y, dpi ); -+ GRResetPenAndBrush( dc ); -+ frame->PrintPage( dc, false /* aPrint_Frame_Ref */, LayerMask, false /* aPrintMirrorMode */, &print_params); -+ delete dc; -+ dc = 0; -+ -+ if ( SvgMergeLayers ) -+ break; -+ } -+ g_DrawBgColor = bg_color; -+ SetLocaleTo_Default(); // revert to the current locale -+ screen->m_IsPrinting = false; -+ } -+ -+ if ( parser.Found( wxT("pos") ) ) // see gen_modules_placefile.cpp:WinEDA_PcbFrame::GenModulesPosition() -+ frame->GenModulesPosition( dummy ); -+ -+ if ( parser.Found( wxT("bom") ) ) // see build_BOM_from_board.cpp:WinEDA_PcbFrame::RecreateBOMFileFromBoard() -+ frame->RecreateBOMFileFromBoard( dummy ); -+ -+ if ( parser.Found( wxT("cmp") ) ) // see xchgmod.cpp:WinEDA_PcbFrame::RecreateCmpFileFromBoard() -+ frame->RecreateCmpFileFromBoard( dummy ); -+ -+ if ( parser.Found( wxT("vrml") ) ) // see export_vrml.cpp:WinEDA_PcbFrame::OnExportVRML() -+ { -+ wxString subDirFor3Dshapes( _( "shapes3D" ) ); -+ -+ fn = ScreenPcb->m_FileName; -+ fn.SetExt( _("wrl") ); -+ if( ! wxDirExists( subDirFor3Dshapes ) ) -+ wxMkdir( subDirFor3Dshapes ); -+ frame->ExportVRML_File( fn.GetFullPath(), 1.0 /* aScale */, true /* aExport3DFile */, subDirFor3Dshapes ); -+ } -+ return true; -+} -diff -ruN kicad.orig/pcbnew/pcbnew_scripted.h kicad/pcbnew/pcbnew_scripted.h ---- kicad.orig/pcbnew/pcbnew_scripted.h 1970-01-01 00:00:00.000000000 +0000 -+++ kicad/pcbnew/pcbnew_scripted.h 2011-01-02 13:10:04.267823004 +0000 -@@ -0,0 +1,7 @@ -+///////////////////////////////////////////////////////////////////////////// -+// Name: pcbnew_scripted.h -+// Copyright: Wolfgang Spraul -+// Licence: GPL v3 or higher -+///////////////////////////////////////////////////////////////////////////// -+ -+bool Pcbnew_Scripted(); diff --git a/kicad-patches/scripted-pcbnew.patch b/kicad-patches/scripted-pcbnew.patch deleted file mode 100644 index 982cc37..0000000 --- a/kicad-patches/scripted-pcbnew.patch +++ /dev/null @@ -1,158 +0,0 @@ -diff -ruN kicad.orig/pcbnew/build_BOM_from_board.cpp kicad/pcbnew/build_BOM_from_board.cpp ---- kicad.orig/pcbnew/build_BOM_from_board.cpp 2010-10-19 08:48:07.000000000 +0000 -+++ kicad/pcbnew/build_BOM_from_board.cpp 2011-01-02 16:02:51.792837658 +0000 -@@ -64,6 +64,7 @@ - fn = GetScreen()->m_FileName; - fn.SetExt( CsvFileExtension ); - -+ if (!g_IsScripted) { - wxFileDialog dlg( this, _( "Save Bill of Materials" ), wxGetCwd(), - fn.GetFullName(), CsvFileWildcard, - wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); -@@ -72,6 +73,7 @@ - return; - - fn = dlg.GetPath(); -+ } - - FichBom = wxFopen( fn.GetFullPath(), wxT( "wt" ) ); - -diff -ruN kicad.orig/pcbnew/CMakeLists.txt kicad/pcbnew/CMakeLists.txt ---- kicad.orig/pcbnew/CMakeLists.txt 2010-10-19 08:48:07.000000000 +0000 -+++ kicad/pcbnew/CMakeLists.txt 2011-01-02 13:04:39.451823002 +0000 -@@ -142,6 +142,7 @@ - onrightclick.cpp - pcbnew.cpp - pcbnew_config.cpp -+ pcbnew_scripted.cpp - pcbplot.cpp - plotgerb.cpp - plothpgl.cpp -diff -ruN kicad.orig/pcbnew/dialog_gendrill.h kicad/pcbnew/dialog_gendrill.h ---- kicad.orig/pcbnew/dialog_gendrill.h 2010-10-19 08:48:07.000000000 +0000 -+++ kicad/pcbnew/dialog_gendrill.h 2011-01-02 13:04:39.459823002 +0000 -@@ -12,6 +12,7 @@ - - class DIALOG_GENDRILL: public DIALOG_GENDRILL_BASE - { -+friend bool Pcbnew_Scripted(); - - private: - WinEDA_PcbFrame* m_Parent; -diff -ruN kicad.orig/pcbnew/drc_stuff.h kicad/pcbnew/drc_stuff.h ---- kicad.orig/pcbnew/drc_stuff.h 2010-10-19 08:48:07.000000000 +0000 -+++ kicad/pcbnew/drc_stuff.h 2011-01-02 13:04:39.507823003 +0000 -@@ -136,6 +136,7 @@ - class DRC - { - friend class DIALOG_DRC_CONTROL; -+ friend bool Pcbnew_Scripted(); - - private: - -diff -ruN kicad.orig/pcbnew/gendrill.cpp kicad/pcbnew/gendrill.cpp ---- kicad.orig/pcbnew/gendrill.cpp 2010-10-19 08:48:07.000000000 +0000 -+++ kicad/pcbnew/gendrill.cpp 2011-01-02 13:04:39.515823004 +0000 -@@ -307,6 +307,43 @@ - fn.SetName( fn.GetName() + layer_extend ); - fn.SetExt( DrillFileExtension ); - -+ if (g_IsScripted) -+ { -+ FILE* excellon_dest = wxFopen( fn.GetFullPath(), wxT( "w" ) ); -+ if( excellon_dest == 0 ) -+ { -+ printf("Unable to create %ls.\n", fn.GetFullPath().c_str()); -+ exit(0); -+ } -+ Create_Drill_File_EXCELLON( excellon_dest, s_HoleListBuffer, -+ s_ToolListBuffer ); -+ -+ switch( m_Choice_Drill_Map->GetSelection() ) -+ { -+ case 0: -+ break; -+ -+ case 1: -+ GenDrillMap( fn.GetPath(), s_HoleListBuffer, s_ToolListBuffer, -+ PLOT_FORMAT_HPGL ); -+ break; -+ -+ case 2: -+ GenDrillMap( fn.GetPath(), s_HoleListBuffer, s_ToolListBuffer, -+ PLOT_FORMAT_POST ); -+ break; -+ -+ case 3: -+ GenDrillMap( fn.GetPath(), s_HoleListBuffer, s_ToolListBuffer, -+ PLOT_FORMAT_GERBER ); -+ break; -+ -+ case 4: -+ GenDrillMap( fn.GetPath(), s_HoleListBuffer, s_ToolListBuffer, -+ PLOT_FORMAT_DXF ); -+ break; -+ } -+ } else { - wxFileDialog dlg( this, _( "Save Drill File" ), fn.GetPath(), - fn.GetFullName(), DrillFileWildcard, - wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); -@@ -352,6 +389,7 @@ - PLOT_FORMAT_DXF ); - break; - } -+ } // !g_IsScripted - - if( !ExistsBuriedVias ) - break; -diff -ruN kicad.orig/pcbnew/pcbnew.cpp kicad/pcbnew/pcbnew.cpp ---- kicad.orig/pcbnew/pcbnew.cpp 2010-10-19 08:48:07.000000000 +0000 -+++ kicad/pcbnew/pcbnew.cpp 2011-01-02 17:27:41.612837657 +0000 -@@ -29,6 +29,7 @@ - #include "build_version.h" - - #include "protos.h" -+#include "pcbnew_scripted.h" - - // Colors for layers and items - COLORS_DESIGN_SETTINGS g_ColorsSettings; -@@ -103,6 +104,9 @@ - wxFileName fn; - WinEDA_PcbFrame* frame = NULL; - -+ if ( argc >= 2 && argv[1][0] == '-' ) -+ return Pcbnew_Scripted(); -+ - InitEDA_Appl( wxT( "PCBnew" ), APP_TYPE_PCBNEW ); - - if( m_Checker && m_Checker->IsAnotherRunning() ) -diff -ruN kicad.orig/pcbnew/pcbnew.h kicad/pcbnew/pcbnew.h ---- kicad.orig/pcbnew/pcbnew.h 2010-10-19 08:48:07.000000000 +0000 -+++ kicad/pcbnew/pcbnew.h 2011-01-02 16:02:38.324837657 +0000 -@@ -59,6 +59,7 @@ - - extern const wxString g_FootprintLibFileWildcard; // Wildcard for footprint libraries filesnames - -+extern bool g_IsScripted; - - extern bool g_Track_45_Only_Allowed; - extern bool g_Alternate_Track_Posture; -diff -ruN kicad.orig/pcbnew/xchgmod.cpp kicad/pcbnew/xchgmod.cpp ---- kicad.orig/pcbnew/xchgmod.cpp 2010-10-19 08:48:07.000000000 +0000 -+++ kicad/pcbnew/xchgmod.cpp 2011-01-02 13:04:39.551823004 +0000 -@@ -577,6 +577,7 @@ - wildcard = _( "Component files (." ) + NetCmpExtBuffer + wxT( ")|*." ) + - NetCmpExtBuffer; - -+ if (!g_IsScripted) { - wxFileDialog dlg( this, _( "Save Component Files" ), wxGetCwd(), - fn.GetFullName(), wildcard, - wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); -@@ -585,6 +586,7 @@ - return; - - fn = dlg.GetPath(); -+ } - - FichCmp = wxFopen( fn.GetFullPath(), wxT( "wt" ) ); - if( FichCmp == NULL ) diff --git a/kicad-patches/series b/kicad-patches/series index 469e8e5..0f60fc5 100644 --- a/kicad-patches/series +++ b/kicad-patches/series @@ -12,9 +12,9 @@ streamline-erc.patch erc-exceptions.patch # cmdline options for eeschema and pcbnew -scripted-new.patch -scripted-common.patch -scripted-eeschema.patch -scripted-pcbnew.patch -dxf-aux-origin.patch -origin-opt.patch +cmdline-new.patch +cmdline-common.patch +cmdline-eeschema.patch +cmdline-pcbnew.patch +#dxf-aux-origin.patch +#origin-opt.patch