1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-05 07:01:53 +02:00
eda-tools/kicad-patches/scripted.patch

323 lines
11 KiB
Diff

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 2010-12-28 13:58:14.765392001 +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 2010-12-28 13:58:28.045392001 +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/eeschema/CMakeLists.txt kicad/eeschema/CMakeLists.txt
--- kicad.orig/eeschema/CMakeLists.txt 2010-10-19 08:48:07.000000000 +0000
+++ kicad/eeschema/CMakeLists.txt 2010-12-28 13:43:28.365392001 +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 2010-12-29 14:53:53.210259002 +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 2010-12-29 15:45:04.002259005 +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 2010-12-31 14:59:18.871823000 +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-12-28 15:30:43.309392002 +0000
+++ kicad/eeschema/eeschema.cpp 2010-12-28 15:38:23.073392001 +0000
@@ -15,6 +15,7 @@
#include "program.h"
#include "general.h"
#include "protos.h"
+#include "eeschema_scripted.h"
#include <wx/snglinst.h>
@@ -128,6 +129,9 @@
g_DebugLevel = 0; // Debug level */
+ if ( g_EESchemaScripted.Run() )
+ return false;
+
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 2010-12-31 18:11:47.751823001 +0000
+++ kicad/eeschema/erc.cpp 2010-12-29 15:43:01.970259008 +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 +570,8 @@
ExecuteFile( this, wxGetApp().GetEditorName(),
QuoteFullPath( fn ) );
}
+} else
+ WriteDiagnosticERC( fn.GetFullPath() );
}
}
diff -ruN kicad.orig/include/common.h kicad/include/common.h
--- kicad.orig/include/common.h 2010-10-19 08:48:07.000000000 +0000
+++ kicad/include/common.h 2010-12-28 13:58:57.861392001 +0000
@@ -6,6 +6,8 @@
#ifndef __INCLUDE__COMMON_H__
#define __INCLUDE__COMMON_H__ 1
+extern bool g_IsScripted;
+
#include "wx/confbase.h"
#include "wx/fileconf.h"
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 2010-12-24 11:03:20.674781923 +0000
@@ -50,6 +50,7 @@
class WinEDA_PcbFrame : public WinEDA_BasePcbFrame
{
friend class PCB_LAYER_WIDGET;
+ friend bool Pcbnew_Scripted();
protected:
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 2010-12-28 13:59:39.089392001 +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 2010-12-22 02:19:48.597291239 +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 2010-12-22 18:23:00.054932711 +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 2010-12-24 10:01:41.438781921 +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 2010-12-28 13:59:29.321392003 +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 2010-12-28 09:18:32.577470003 +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( Pcbnew_Scripted() )
+ return false;
+
InitEDA_Appl( wxT( "PCBnew" ), APP_TYPE_PCBNEW );
if( m_Checker && m_Checker->IsAnotherRunning() )
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
@@ -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 )