mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-25 21:55:20 +02:00
broke scripted.patch into scripted-new.patch and scripted.patch for easier maintenance
This commit is contained in:
parent
c11feca1e5
commit
9b476d4297
840
kicad-patches/scripted-new.patch
Normal file
840
kicad-patches/scripted-new.patch
Normal file
@ -0,0 +1,840 @@
|
||||
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 2010-12-31 18:03:37.871822958 +0000
|
||||
@@ -0,0 +1,251 @@
|
||||
+/////////////////////////////////////////////////////////////////////////////
|
||||
+// 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("px"), wxT("plotx"), wxT("plots the board [ps|svg|dxf]"),
|
||||
+ wxCMD_LINE_VAL_STRING },
|
||||
+ { wxCMD_LINE_SWITCH, wxT("plotx-bw"), wxT("plotx-bw"), wxT("plot: black & white (default: color)") },
|
||||
+ { wxCMD_LINE_SWITCH, wxT("plotx-sheetref"), wxT("plotx-sheetref"), wxT("plot: print sheet reference (default: off)") },
|
||||
+ { wxCMD_LINE_SWITCH, wxT("p"), wxT("plot"), wxT("plots the schematics (deprecated, use --plotx=ps --plotx-bw)") },
|
||||
+
|
||||
+ { 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("<path to .sch file>"),
|
||||
+ 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();
|
||||
+ if (app.argc < 2 || app.argv[1][0] != '-')
|
||||
+ return false;
|
||||
+ 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 true;
|
||||
+
|
||||
+ i = parser.Found( _("list-sheets") )
|
||||
+ + parser.Found( _("plot") )
|
||||
+ + parser.Found( _("plotx") )
|
||||
+ + parser.Found( _("bom") )
|
||||
+ + parser.Found( _("erc") )
|
||||
+ + parser.Found( _("netlist") );
|
||||
+ if ( !i )
|
||||
+ {
|
||||
+ wxPrintf(wxT("One of --list-sheets --plot --plotx --bom --erc --netlist must be given.\n"));
|
||||
+ return true;
|
||||
+ }
|
||||
+ if ( i > 1 )
|
||||
+ {
|
||||
+ wxPrintf(wxT("Only one of --list-sheets --plot --plotx --bom --erc --netlist may be given at a time.\n"));
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ // parse plotting parameters
|
||||
+ enum PlotCommand {
|
||||
+ PLOT_NONE,
|
||||
+ PLOT_PS,
|
||||
+ PLOT_SVG,
|
||||
+ PLOT_DXF
|
||||
+ } PlotCmd;
|
||||
+ bool PlotBW;
|
||||
+ bool PlotSheetRef;
|
||||
+
|
||||
+ PlotCmd = PLOT_NONE;
|
||||
+ if ( parser.Found( wxT("plot") ) ) // legacy parameter originally introduced by
|
||||
+ // Werner, still used in schhist and other places
|
||||
+ {
|
||||
+ PlotCmd = PLOT_PS;
|
||||
+ PlotBW = true;
|
||||
+ PlotSheetRef = false;
|
||||
+ }
|
||||
+ else if ( parser.Found( _("plotx"), &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
|
||||
+ {
|
||||
+ parser.Usage();
|
||||
+ wxPrintf(wxT("Unexpected plot format '%ls'.\n"), str.c_str());
|
||||
+ return true;
|
||||
+ }
|
||||
+ PlotBW = parser.Found( _("plotx-bw") );
|
||||
+ PlotSheetRef = parser.Found( _("plotx-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())
|
||||
+ {
|
||||
+ wxPrintf( wxT("%ls: file '%ls' does not exist.\n" ), app.argv[0], fn.GetFullPath().c_str() );
|
||||
+ return true;
|
||||
+ }
|
||||
+ wxSetWorkingDirectory( fn.GetPath() );
|
||||
+
|
||||
+ g_DrawBgColor = BLACK;
|
||||
+ SeedLayers();
|
||||
+ frame = new WinEDA_SchematicFrame( NULL, wxT( "EESchema" ),
|
||||
+ wxPoint( 0, 0 ), wxSize( 600, 400 ) );
|
||||
+ ActiveScreen = frame->GetScreen();
|
||||
+#if 0 // enable this to see more of the GUI
|
||||
+ app.SetTopWindow( frame );
|
||||
+ frame->Show( true );
|
||||
+#endif
|
||||
+ if( !frame->LoadOneEEProject( fn.GetFullPath(), false ) )
|
||||
+ {
|
||||
+ fprintf( stderr, "%ls: can't load\n", fn.GetFullPath().c_str() );
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ 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 */ );
|
||||
+ }
|
||||
+
|
||||
+ delete frame;
|
||||
+ 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 2010-12-29 15:09:05.802259004 +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 2010-12-28 13:58:44.257392001 +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 <wx/file.h>
|
||||
+#include <wx/snglinst.h>
|
||||
+#include <wx/cmdline.h>
|
||||
+#include <wx/tokenzr.h>
|
||||
+#include <wx/svg/dcsvg.h>
|
||||
+
|
||||
+#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("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("<path to .brd file>"),
|
||||
+ 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();
|
||||
+ if (app.argc < 2 || app.argv[1][0] != '-')
|
||||
+ return false;
|
||||
+ 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 true;
|
||||
+ if ( parser.Found( wxT("ps-pads-drill-opt"), &str )
|
||||
+ && str.CmpNoCase( wxT("none") )
|
||||
+ && str.CmpNoCase( wxT("small") )
|
||||
+ && str.CmpNoCase( wxT("real") ))
|
||||
+ {
|
||||
+ parser.Usage();
|
||||
+ wxPrintf(wxT("Unexpected pads drill option '%ls'.\n"), str.c_str());
|
||||
+ return true;
|
||||
+ }
|
||||
+ 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 )
|
||||
+ {
|
||||
+ wxPrintf(wxT("One of --drill --list-layers --plot --drc --svg --pos --bom --cmp --vrml must be given.\n"));
|
||||
+ return true;
|
||||
+ }
|
||||
+ if ( i > 1 )
|
||||
+ {
|
||||
+ wxPrintf(wxT("Only one of --drill --list-layers --plot --drc --svg --pos --bom --cmp --vrml may be given at a time.\n"));
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ 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())
|
||||
+ {
|
||||
+ wxPrintf( wxT("%ls: file '%ls' does not exist.\n" ), app.argv[0], fn.GetFullPath().c_str() );
|
||||
+ exit(0);
|
||||
+ }
|
||||
+ 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 ) );
|
||||
+
|
||||
+#if 0 // enable this to see more of the GUI
|
||||
+ app.SetTopWindow( frame );
|
||||
+ 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
|
||||
+ {
|
||||
+ parser.Usage();
|
||||
+ wxPrintf(wxT("Unexpected plot type '%ls'.\n"), str.c_str());
|
||||
+ exit(0);
|
||||
+ }
|
||||
+
|
||||
+ // --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
|
||||
+ {
|
||||
+ parser.Usage();
|
||||
+ wxPrintf(wxT("Unexpected Postscript pads drill option '%ls'.\n"), str.c_str());
|
||||
+ exit(0);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // --mirror
|
||||
+ if ( parser.Found( wxT("mirror") ) )
|
||||
+ g_pcb_plot_options.PlotOrient = PLOT_MIROIR;
|
||||
+
|
||||
+ 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 );
|
||||
+ }
|
||||
+ delete frame;
|
||||
+ 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 2010-12-22 18:47:58.774932729 +0000
|
||||
@@ -0,0 +1,7 @@
|
||||
+/////////////////////////////////////////////////////////////////////////////
|
||||
+// Name: pcbnew_scripted.h
|
||||
+// Copyright: Wolfgang Spraul
|
||||
+// Licence: GPL v3 or higher
|
||||
+/////////////////////////////////////////////////////////////////////////////
|
||||
+
|
||||
+bool Pcbnew_Scripted();
|
@ -130,279 +130,6 @@ diff -ruN kicad.orig/eeschema/eeschema.cpp kicad/eeschema/eeschema.cpp
|
||||
InitEDA_Appl( wxT( "EESchema" ), APP_TYPE_EESCHEMA );
|
||||
|
||||
if( m_Checker && m_Checker->IsAnotherRunning() )
|
||||
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 2010-12-31 18:03:37.871822958 +0000
|
||||
@@ -0,0 +1,251 @@
|
||||
+/////////////////////////////////////////////////////////////////////////////
|
||||
+// 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("px"), wxT("plotx"), wxT("plots the board [ps|svg|dxf]"),
|
||||
+ wxCMD_LINE_VAL_STRING },
|
||||
+ { wxCMD_LINE_SWITCH, wxT("plotx-bw"), wxT("plotx-bw"), wxT("plot: black & white (default: color)") },
|
||||
+ { wxCMD_LINE_SWITCH, wxT("plotx-sheetref"), wxT("plotx-sheetref"), wxT("plot: print sheet reference (default: off)") },
|
||||
+ { wxCMD_LINE_SWITCH, wxT("p"), wxT("plot"), wxT("plots the schematics (deprecated, use --plotx=ps --plotx-bw)") },
|
||||
+
|
||||
+ { 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("<path to .sch file>"),
|
||||
+ 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();
|
||||
+ if (app.argc < 2 || app.argv[1][0] != '-')
|
||||
+ return false;
|
||||
+ 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 true;
|
||||
+
|
||||
+ i = parser.Found( _("list-sheets") )
|
||||
+ + parser.Found( _("plot") )
|
||||
+ + parser.Found( _("plotx") )
|
||||
+ + parser.Found( _("bom") )
|
||||
+ + parser.Found( _("erc") )
|
||||
+ + parser.Found( _("netlist") );
|
||||
+ if ( !i )
|
||||
+ {
|
||||
+ wxPrintf(wxT("One of --list-sheets --plot --plotx --bom --erc --netlist must be given.\n"));
|
||||
+ return true;
|
||||
+ }
|
||||
+ if ( i > 1 )
|
||||
+ {
|
||||
+ wxPrintf(wxT("Only one of --list-sheets --plot --plotx --bom --erc --netlist may be given at a time.\n"));
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ // parse plotting parameters
|
||||
+ enum PlotCommand {
|
||||
+ PLOT_NONE,
|
||||
+ PLOT_PS,
|
||||
+ PLOT_SVG,
|
||||
+ PLOT_DXF
|
||||
+ } PlotCmd;
|
||||
+ bool PlotBW;
|
||||
+ bool PlotSheetRef;
|
||||
+
|
||||
+ PlotCmd = PLOT_NONE;
|
||||
+ if ( parser.Found( wxT("plot") ) ) // legacy parameter originally introduced by
|
||||
+ // Werner, still used in schhist and other places
|
||||
+ {
|
||||
+ PlotCmd = PLOT_PS;
|
||||
+ PlotBW = true;
|
||||
+ PlotSheetRef = false;
|
||||
+ }
|
||||
+ else if ( parser.Found( _("plotx"), &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
|
||||
+ {
|
||||
+ parser.Usage();
|
||||
+ wxPrintf(wxT("Unexpected plot format '%ls'.\n"), str.c_str());
|
||||
+ return true;
|
||||
+ }
|
||||
+ PlotBW = parser.Found( _("plotx-bw") );
|
||||
+ PlotSheetRef = parser.Found( _("plotx-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())
|
||||
+ {
|
||||
+ wxPrintf( wxT("%ls: file '%ls' does not exist.\n" ), app.argv[0], fn.GetFullPath().c_str() );
|
||||
+ return true;
|
||||
+ }
|
||||
+ wxSetWorkingDirectory( fn.GetPath() );
|
||||
+
|
||||
+ g_DrawBgColor = BLACK;
|
||||
+ SeedLayers();
|
||||
+ frame = new WinEDA_SchematicFrame( NULL, wxT( "EESchema" ),
|
||||
+ wxPoint( 0, 0 ), wxSize( 600, 400 ) );
|
||||
+ ActiveScreen = frame->GetScreen();
|
||||
+#if 0 // enable this to see more of the GUI
|
||||
+ app.SetTopWindow( frame );
|
||||
+ frame->Show( true );
|
||||
+#endif
|
||||
+ if( !frame->LoadOneEEProject( fn.GetFullPath(), false ) )
|
||||
+ {
|
||||
+ fprintf( stderr, "%ls: can't load\n", fn.GetFullPath().c_str() );
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ 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 */ );
|
||||
+ }
|
||||
+
|
||||
+ delete frame;
|
||||
+ 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 2010-12-29 15:09:05.802259004 +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/eeschema/erc.cpp kicad/eeschema/erc.cpp
|
||||
--- kicad.orig/eeschema/erc.cpp 2010-12-31 18:11:47.751823001 +0000
|
||||
+++ kicad/eeschema/erc.cpp 2010-12-29 15:43:01.970259008 +0000
|
||||
@ -574,573 +301,6 @@ diff -ruN kicad.orig/pcbnew/pcbnew.cpp kicad/pcbnew/pcbnew.cpp
|
||||
InitEDA_Appl( wxT( "PCBnew" ), APP_TYPE_PCBNEW );
|
||||
|
||||
if( m_Checker && m_Checker->IsAnotherRunning() )
|
||||
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 2010-12-28 13:58:44.257392001 +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 <wx/file.h>
|
||||
+#include <wx/snglinst.h>
|
||||
+#include <wx/cmdline.h>
|
||||
+#include <wx/tokenzr.h>
|
||||
+#include <wx/svg/dcsvg.h>
|
||||
+
|
||||
+#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("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("<path to .brd file>"),
|
||||
+ 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();
|
||||
+ if (app.argc < 2 || app.argv[1][0] != '-')
|
||||
+ return false;
|
||||
+ 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 true;
|
||||
+ if ( parser.Found( wxT("ps-pads-drill-opt"), &str )
|
||||
+ && str.CmpNoCase( wxT("none") )
|
||||
+ && str.CmpNoCase( wxT("small") )
|
||||
+ && str.CmpNoCase( wxT("real") ))
|
||||
+ {
|
||||
+ parser.Usage();
|
||||
+ wxPrintf(wxT("Unexpected pads drill option '%ls'.\n"), str.c_str());
|
||||
+ return true;
|
||||
+ }
|
||||
+ 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 )
|
||||
+ {
|
||||
+ wxPrintf(wxT("One of --drill --list-layers --plot --drc --svg --pos --bom --cmp --vrml must be given.\n"));
|
||||
+ return true;
|
||||
+ }
|
||||
+ if ( i > 1 )
|
||||
+ {
|
||||
+ wxPrintf(wxT("Only one of --drill --list-layers --plot --drc --svg --pos --bom --cmp --vrml may be given at a time.\n"));
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ 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())
|
||||
+ {
|
||||
+ wxPrintf( wxT("%ls: file '%ls' does not exist.\n" ), app.argv[0], fn.GetFullPath().c_str() );
|
||||
+ exit(0);
|
||||
+ }
|
||||
+ 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 ) );
|
||||
+
|
||||
+#if 0 // enable this to see more of the GUI
|
||||
+ app.SetTopWindow( frame );
|
||||
+ 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
|
||||
+ {
|
||||
+ parser.Usage();
|
||||
+ wxPrintf(wxT("Unexpected plot type '%ls'.\n"), str.c_str());
|
||||
+ exit(0);
|
||||
+ }
|
||||
+
|
||||
+ // --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
|
||||
+ {
|
||||
+ parser.Usage();
|
||||
+ wxPrintf(wxT("Unexpected Postscript pads drill option '%ls'.\n"), str.c_str());
|
||||
+ exit(0);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // --mirror
|
||||
+ if ( parser.Found( wxT("mirror") ) )
|
||||
+ g_pcb_plot_options.PlotOrient = PLOT_MIROIR;
|
||||
+
|
||||
+ 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 );
|
||||
+ }
|
||||
+ delete frame;
|
||||
+ 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 2010-12-22 18:47:58.774932729 +0000
|
||||
@@ -0,0 +1,7 @@
|
||||
+/////////////////////////////////////////////////////////////////////////////
|
||||
+// Name: pcbnew_scripted.h
|
||||
+// Copyright: Wolfgang Spraul
|
||||
+// Licence: GPL v3 or higher
|
||||
+/////////////////////////////////////////////////////////////////////////////
|
||||
+
|
||||
+bool Pcbnew_Scripted();
|
||||
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 2010-12-28 13:59:06.985392003 +0000
|
||||
|
@ -12,4 +12,5 @@ streamline-erc.patch
|
||||
erc-exceptions.patch
|
||||
|
||||
# cmdline options for eeschema and pcbnew
|
||||
scripted-new.patch
|
||||
scripted.patch
|
||||
|
Loading…
Reference in New Issue
Block a user