Root/
| 1 | --- /dev/null 2012-04-03 10:16:45.622661012 +0200 |
| 2 | +++ kicad/eeschema/eeschema_cmdline.h 2012-04-08 06:48:35.478088781 +0200 |
| 3 | @@ -0,0 +1,14 @@ |
| 4 | +///////////////////////////////////////////////////////////////////////////// |
| 5 | +// Name: eeschema_cmdline.h |
| 6 | +// Copyright: Wolfgang Spraul |
| 7 | +// Licence: GPL v3 or higher |
| 8 | +///////////////////////////////////////////////////////////////////////////// |
| 9 | + |
| 10 | +class EESCHEMA_CMDLINE |
| 11 | +{ |
| 12 | +public: |
| 13 | + EESCHEMA_CMDLINE() { } |
| 14 | + bool Run(); |
| 15 | +}; |
| 16 | + |
| 17 | +extern EESCHEMA_CMDLINE g_EESchemaCmdLine; |
| 18 | --- /dev/null 2012-04-03 10:16:45.622661012 +0200 |
| 19 | +++ kicad/eeschema/eeschema_cmdline.cpp 2012-04-08 07:11:42.232529821 +0200 |
| 20 | @@ -0,0 +1,234 @@ |
| 21 | +///////////////////////////////////////////////////////////////////////////// |
| 22 | +// Name: eeschema_cmdline.cpp |
| 23 | +// Copyright: Werner Almesberger, Wolfgang Spraul |
| 24 | +// License: GPL v2 or higher |
| 25 | +///////////////////////////////////////////////////////////////////////////// |
| 26 | + |
| 27 | +#include <wx/notebook.h> |
| 28 | +#include <fctsys.h> |
| 29 | +#include <appl_wxstruct.h> |
| 30 | +#include <common.h> |
| 31 | +#include <general.h> |
| 32 | +#include <netlist.h> |
| 33 | +#include <netlist_control.h> |
| 34 | +#include <protos.h> |
| 35 | +#include <gr_basic.h> |
| 36 | +#include <wx/cmdline.h> |
| 37 | +#include <dialog_build_BOM.h> |
| 38 | +#include <dialog_SVG_print_base.h> |
| 39 | +#include <dialog_erc.h> |
| 40 | +#include <dialog_color_config.h> |
| 41 | +#include <wxEeschemaStruct.h> |
| 42 | +#include <sch_sheet.h> |
| 43 | +#include <wildcards_and_files_ext.h> |
| 44 | +#include <eeschema_cmdline.h> |
| 45 | + |
| 46 | +EESCHEMA_CMDLINE g_EESchemaCmdLine; |
| 47 | + |
| 48 | +static const wxCmdLineEntryDesc g_cmdLineDesc [] = |
| 49 | +{ |
| 50 | + { wxCMD_LINE_SWITCH, 0, wxT("help"), |
| 51 | + wxT("command line help\n"), |
| 52 | + wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, |
| 53 | + |
| 54 | + { wxCMD_LINE_SWITCH, 0, wxT("list-sheets"), |
| 55 | + wxT("list schematic pages\n") }, |
| 56 | + |
| 57 | + { wxCMD_LINE_OPTION, 0, wxT("plot"), |
| 58 | + wxT("File -> Plot [ps|svg|dxf]"), |
| 59 | + wxCMD_LINE_VAL_STRING }, |
| 60 | + { wxCMD_LINE_SWITCH, 0, wxT("plot-bw"), |
| 61 | + wxT(" Black & white (default: color)") }, |
| 62 | + { wxCMD_LINE_SWITCH, 0, wxT("plot-sheetref"), |
| 63 | + wxT(" Print page references (default: off)\n") }, |
| 64 | + |
| 65 | + { wxCMD_LINE_SWITCH, 0, wxT("erc"), |
| 66 | + wxT("Tools -> ERC (.erc)") }, |
| 67 | + { wxCMD_LINE_SWITCH, 0, wxT("netlist"), |
| 68 | + wxT("Tools -> Generate Netlist (.net)") }, |
| 69 | + { wxCMD_LINE_SWITCH, 0, wxT("bom"), |
| 70 | + wxT("Tools -> Generate Bill of Materials (.bom)") }, |
| 71 | + { wxCMD_LINE_PARAM, 0, 0, wxT("<path to .sch file>"), |
| 72 | + wxCMD_LINE_VAL_STRING }, |
| 73 | + { wxCMD_LINE_NONE } |
| 74 | +}; |
| 75 | + |
| 76 | +bool CmdLineDrawSVGPage( EDA_DRAW_FRAME* frame, |
| 77 | + const wxString& FullFileName, BASE_SCREEN* screen, |
| 78 | + bool aPrintBlackAndWhite = false, |
| 79 | + bool aPrint_Sheet_Ref = false); |
| 80 | + |
| 81 | +// called from EDA_APP::OnInit() |
| 82 | +bool EESCHEMA_CMDLINE::Run() |
| 83 | +{ |
| 84 | + wxFileName fn; |
| 85 | + SCH_EDIT_FRAME* frame; |
| 86 | + wxCommandEvent DummyCmd; |
| 87 | + wxString str; |
| 88 | + int i; |
| 89 | + |
| 90 | + EDA_APP& app = wxGetApp(); |
| 91 | + g_CmdLineMode = true; |
| 92 | + wxLog::EnableLogging(false); // this should suppress some wx dialogs |
| 93 | + app.InitEDA_Appl( wxT( "Eeschema" ), APP_EESCHEMA_T ); |
| 94 | + |
| 95 | + wxCmdLineParser parser; |
| 96 | + parser.SetDesc(g_cmdLineDesc); |
| 97 | + parser.SetCmdLine(app.argc, app.argv); |
| 98 | + if (parser.Parse()) |
| 99 | + return false; |
| 100 | + |
| 101 | + i = parser.Found( _("list-sheets") ) |
| 102 | + + parser.Found( _("plot") ) |
| 103 | + + parser.Found( _("erc") ) |
| 104 | + + parser.Found( _("netlist") ) |
| 105 | + + parser.Found( _("bom") ); |
| 106 | + if ( !i ) |
| 107 | + { |
| 108 | + wxFprintf( stderr, wxT("One of --list-sheets --plot --erc --netlist" |
| 109 | + " --bom must be given.\n")); |
| 110 | + return false; |
| 111 | + } |
| 112 | + if ( i > 1 ) |
| 113 | + { |
| 114 | + wxFprintf( stderr, wxT("Only one of --list-sheets --plot --erc" |
| 115 | + " --netlist --bom may be given at a time.\n")); |
| 116 | + return false; |
| 117 | + } |
| 118 | + |
| 119 | + // parse plotting parameters |
| 120 | + enum PlotCommand { |
| 121 | + PLOT_NONE, |
| 122 | + PLOT_PS, |
| 123 | + PLOT_SVG, |
| 124 | + PLOT_DXF |
| 125 | + } PlotCmd; |
| 126 | + bool PlotBW; |
| 127 | + bool PlotSheetRef; |
| 128 | + |
| 129 | + PlotCmd = PLOT_NONE; |
| 130 | + if ( parser.Found( _("plot"), &str ) ) |
| 131 | + { |
| 132 | + if (!str.CmpNoCase( wxT("ps") ) ) |
| 133 | + PlotCmd = PLOT_PS; |
| 134 | + else if ( !str.CmpNoCase( wxT("svg") ) ) |
| 135 | + PlotCmd = PLOT_SVG; |
| 136 | + else if ( !str.CmpNoCase( wxT("dxf") ) ) |
| 137 | + PlotCmd = PLOT_DXF; |
| 138 | + else |
| 139 | + { |
| 140 | + wxFprintf( stderr, wxT("Unexpected plot format '%ls'.\n"), str.c_str()); |
| 141 | + return false; |
| 142 | + } |
| 143 | + PlotBW = parser.Found( _("plot-bw") ); |
| 144 | + PlotSheetRef = parser.Found( _("plot-sheetref") ); |
| 145 | + } |
| 146 | + |
| 147 | + fn = parser.GetParam(); |
| 148 | + if( fn.GetExt() != SchematicFileExtension ) |
| 149 | + { |
| 150 | + wxLogDebug( wxT( "eeschema file <%s> has the wrong extension." |
| 151 | + " Changing extension to .sch." ), GetChars( fn.GetFullPath() ) ); |
| 152 | + fn.SetExt( PcbFileExtension ); |
| 153 | + } |
| 154 | + if( !fn.FileExists()) |
| 155 | + { |
| 156 | + wxFprintf( stderr, wxT("%ls: file '%ls' does not exist.\n" ), |
| 157 | + app.argv[0], fn.GetFullPath().c_str() ); |
| 158 | + return false; |
| 159 | + } |
| 160 | + wxSetWorkingDirectory( fn.GetPath() ); |
| 161 | + |
| 162 | + SeedLayers(); |
| 163 | + frame = new SCH_EDIT_FRAME( NULL, wxT( "Eeschema" ), wxPoint( 0, 0 ), |
| 164 | + wxSize( 600, 400 ) ); |
| 165 | + app.SetTopWindow( frame ); |
| 166 | +#if 0 // enable this to see more of the GUI |
| 167 | + frame->Show( true ); |
| 168 | +#endif |
| 169 | + if( !frame->LoadOneEEProject( fn.GetFullPath(), false ) ) |
| 170 | + { |
| 171 | + wxFprintf( stderr, fn.GetFullPath() + _(": can't load\n") ); |
| 172 | + return false; |
| 173 | + } |
| 174 | + |
| 175 | + if ( parser.Found( wxT("list-sheets") ) ) |
| 176 | + { |
| 177 | + SCH_SHEET_LIST SheetList( 0 /* aSheet */ ); |
| 178 | + SCH_SHEET_PATH* sheetpath; |
| 179 | + SCH_SHEET_PATH oldsheetpath, list; |
| 180 | + SCH_SCREEN* schscreen; |
| 181 | + |
| 182 | + // dialogs/dialog_SVG_print.cpp:DIALOG_SVG_PRINT:PrintSVGDoc() |
| 183 | + oldsheetpath = frame->GetCurrentSheet(); |
| 184 | + sheetpath = SheetList.GetFirst(); |
| 185 | + while ( sheetpath ) |
| 186 | + { |
| 187 | + list.Clear(); |
| 188 | + if ( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) |
| 189 | + { |
| 190 | + frame->SetCurrentSheet( list ); |
| 191 | + frame->GetCurrentSheet().UpdateAllScreenReferences(); |
| 192 | + frame->SetSheetNumberAndCount(); |
| 193 | + schscreen = frame->GetCurrentSheet().LastScreen(); |
| 194 | + |
| 195 | + wxPrintf( sheetpath->Path() + _(" ") |
| 196 | + + sheetpath->PathHumanReadable() + _(" ") |
| 197 | + + sheetpath->Last()->GetFileName() + _(" ") |
| 198 | + + frame->GetUniqueFilenameForCurrentSheet( ) + wxT( ".sch\n") ); |
| 199 | + } |
| 200 | + sheetpath = SheetList.GetNext(); |
| 201 | + } |
| 202 | + frame->SetCurrentSheet( oldsheetpath ); |
| 203 | + frame->GetCurrentSheet().UpdateAllScreenReferences(); |
| 204 | + frame->SetSheetNumberAndCount(); |
| 205 | + } |
| 206 | + else if ( PlotCmd == PLOT_PS ) |
| 207 | + { |
| 208 | + // dialogs/dialog_plot_schematic_PS_base.cpp |
| 209 | + // dialogs/dialog_plot_schematic_PS.cpp |
| 210 | + frame->CmdLineToPlot_PS( PlotBW, PlotSheetRef ); |
| 211 | + } |
| 212 | + else if ( PlotCmd == PLOT_SVG ) |
| 213 | + { |
| 214 | + // dialogs/dialog_SVG_print.cpp:DIALOG_SVG_PRINT::DrawSVGPage() |
| 215 | + void CmdLinePrintSVGDoc( EDA_DRAW_FRAME* frame, bool aPrintAll, |
| 216 | + bool aPrint_Sheet_Ref, bool aPrintBlackAndWhite ); |
| 217 | + CmdLinePrintSVGDoc( frame, true /* aPrintAll */, PlotSheetRef, PlotBW ); |
| 218 | + } |
| 219 | + else if ( PlotCmd == PLOT_DXF ) |
| 220 | + { |
| 221 | + // dialogs/dialog_plot_schematic_DXF_base.cpp |
| 222 | + // dialogs/dialog_plot_schematic_DXF.cpp |
| 223 | + frame->CmdLineToPlot_DXF( PlotBW, PlotSheetRef ); |
| 224 | + } |
| 225 | + else if ( parser.Found( wxT("erc") ) ) // erc.cpp:DIALOG_ERC::TestErc() |
| 226 | + { |
| 227 | + DIALOG_ERC* dlg = new DIALOG_ERC( frame ); |
| 228 | + dlg->m_WriteResultOpt->SetValue( true ); |
| 229 | + dlg->TestErc( 0 /* messageList */ ); |
| 230 | + delete dlg; |
| 231 | + } |
| 232 | + else if ( parser.Found( wxT("netlist") ) ) |
| 233 | + { |
| 234 | + // netlist_control.cpp:WinEDA_SchematicFrame::CreateNetlist() |
| 235 | + frame->BuildNetListBase(); |
| 236 | + fn.SetExt( wxT( "net" ) ); |
| 237 | + frame->WriteNetListFile( NET_TYPE_PCBNEW /* aFormat */, |
| 238 | + fn.GetFullPath(), 0 /* aNetlistOptions */ ); |
| 239 | + } |
| 240 | + else if ( parser.Found( wxT("bom") ) ) |
| 241 | + { |
| 242 | + // see build_BOM.cpp:DIALOG_BUILD_BOM::GenereListeOfItems() |
| 243 | + DIALOG_BUILD_BOM* dlg = new DIALOG_BUILD_BOM( frame ); |
| 244 | + |
| 245 | + dlg->m_ListCmpbyRefItems->SetValue( true ); |
| 246 | + dlg->m_AddFootprintField->SetValue( true ); |
| 247 | + dlg->m_AddAllFields->SetValue( true ); |
| 248 | + |
| 249 | + fn.SetExt( wxT( "lst" ) ); |
| 250 | + dlg->GenereListeOfItems( fn.GetFullPath(), false /* aIncludeSubComponents */ ); |
| 251 | + delete dlg; |
| 252 | + } |
| 253 | + return true; |
| 254 | +} |
| 255 | --- /dev/null 2012-04-03 10:16:45.622661012 +0200 |
| 256 | +++ kicad/pcbnew/pcbnew_cmdline.h 2012-04-08 06:48:35.482088711 +0200 |
| 257 | @@ -0,0 +1,7 @@ |
| 258 | +///////////////////////////////////////////////////////////////////////////// |
| 259 | +// Name: pcbnew_cmdline.h |
| 260 | +// Copyright: Wolfgang Spraul |
| 261 | +// Licence: GPL v3 or higher |
| 262 | +///////////////////////////////////////////////////////////////////////////// |
| 263 | + |
| 264 | +bool Pcbnew_CmdLine(); |
| 265 | --- /dev/null 2012-04-03 10:16:45.622661012 +0200 |
| 266 | +++ kicad/pcbnew/pcbnew_cmdline.cpp 2012-04-08 08:12:17.841567431 +0200 |
| 267 | @@ -0,0 +1,538 @@ |
| 268 | +///////////////////////////////////////////////////////////////////////////// |
| 269 | +// Name: pcbnew_cmdline.cpp |
| 270 | +// Copyright: Wolfgang Spraul |
| 271 | +// Licence: GPL v3 or higher |
| 272 | +///////////////////////////////////////////////////////////////////////////// |
| 273 | + |
| 274 | +#include <fctsys.h> |
| 275 | +#include <appl_wxstruct.h> |
| 276 | +#include <confirm.h> |
| 277 | + |
| 278 | +#include <wx/file.h> |
| 279 | +#include <wx/snglinst.h> |
| 280 | +#include <wx/cmdline.h> |
| 281 | +#include <wx/tokenzr.h> |
| 282 | +#include <wx/svg/dcsvg.h> |
| 283 | + |
| 284 | +#include <common.h> |
| 285 | +#include <pcbnew.h> |
| 286 | +#include <wxPcbStruct.h> |
| 287 | +#include <plot_common.h> |
| 288 | +#include <gestfich.h> |
| 289 | +#include <pcbplot.h> |
| 290 | +#include <autorout.h> |
| 291 | +#include <cell.h> |
| 292 | +#include <worksheet.h> |
| 293 | +#include <zones.h> |
| 294 | +#include <drag.h> |
| 295 | +#include <eda_dde.h> |
| 296 | +#include <colors_selection.h> |
| 297 | +#include <class_drawpanel.h> |
| 298 | +#include <gr_basic.h> |
| 299 | +#include <id.h> |
| 300 | +#include <build_version.h> |
| 301 | + |
| 302 | +#include <protos.h> |
| 303 | +#include <pcbnew_cmdline.h> |
| 304 | +#include <gendrill.h> |
| 305 | +#include <dialog_gendrill.h> |
| 306 | +#include <dialog_drc.h> |
| 307 | +#include <printout_controler.h> |
| 308 | +#include <dialog_plot_base.h> |
| 309 | +#include <dialog_SVG_print.h> |
| 310 | +#include <wildcards_and_files_ext.h> |
| 311 | + |
| 312 | +extern int g_DrawDefaultLineThickness; |
| 313 | + |
| 314 | +static const wxCmdLineEntryDesc g_cmdLineDesc [] = |
| 315 | +{ |
| 316 | + { wxCMD_LINE_SWITCH, 0, wxT("help"), |
| 317 | + wxT("command line help\n"), |
| 318 | + wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, |
| 319 | + |
| 320 | + { wxCMD_LINE_SWITCH, 0, wxT("list-layers"), |
| 321 | + wxT("list names of enabled layers in .brd file") }, |
| 322 | + { wxCMD_LINE_OPTION, 0, wxT("layers"), |
| 323 | + wxT("comma separated layers for plot and SVG\n"), |
| 324 | + wxCMD_LINE_VAL_STRING }, |
| 325 | + |
| 326 | + { wxCMD_LINE_SWITCH, 0, wxT("drill"), |
| 327 | + wxT("File -> Fabrication -> Drill File (.drl)") }, |
| 328 | + { wxCMD_LINE_SWITCH, 0, wxT("drill-aux-origin"), |
| 329 | + wxT(" Use aux axis as origin (def: abs)\n") }, |
| 330 | + |
| 331 | + { wxCMD_LINE_OPTION, 0, wxT("plot"), |
| 332 | + wxT("File -> Plot [gerber|ps|dxf]"), |
| 333 | + wxCMD_LINE_VAL_STRING }, |
| 334 | + { wxCMD_LINE_SWITCH, 0, wxT("plot-fill-all-zones"), |
| 335 | + wxT(" Fill zones before plotting (not in the dialog)") }, |
| 336 | + { wxCMD_LINE_OPTION, 0, wxT("plot-drill-marks"), |
| 337 | + wxT(" Drill marks [none|small|actual] (def: small)"), |
| 338 | + wxCMD_LINE_VAL_STRING }, |
| 339 | + { wxCMD_LINE_SWITCH, 0, wxT("plot-mirror"), |
| 340 | + wxT(" Postscript: Mirrored plot") }, |
| 341 | + { wxCMD_LINE_SWITCH, 0, wxT("plot-force-a4"), |
| 342 | + wxT(" Postscript: Force A4 output") }, |
| 343 | + { wxCMD_LINE_SWITCH, 0, wxT("plot-aux-origin"), |
| 344 | + wxT(" Gerber & DXF: Aux axis as origin (def: abs)") }, |
| 345 | + { wxCMD_LINE_SWITCH, 0, wxT("plot-exclude-edge"), |
| 346 | + wxT(" Gerber: Exclude PCB edge\n") }, |
| 347 | + |
| 348 | + { wxCMD_LINE_OPTION, 0, wxT("svg"), |
| 349 | + wxT("File -> Print SVG [selected|board]"), |
| 350 | + wxCMD_LINE_VAL_STRING }, |
| 351 | + { wxCMD_LINE_SWITCH, 0, wxT("svg-board-edges"), |
| 352 | + wxT(" add board edges to SVG plots (def: off)\n") }, |
| 353 | + |
| 354 | + { wxCMD_LINE_SWITCH, 0, wxT("drc"), |
| 355 | + wxT("Tools -> DRC (.rpt)") }, |
| 356 | + { wxCMD_LINE_SWITCH, 0, wxT("pos"), |
| 357 | + wxT("File -> Fabrication -> Modules Pos. (.pos)") }, |
| 358 | + { wxCMD_LINE_SWITCH, 0, wxT("bom"), |
| 359 | + wxT("File -> Fabrication -> BOM File (.csv)") }, |
| 360 | + { wxCMD_LINE_SWITCH, 0, wxT("cmp"), |
| 361 | + wxT("File -> Fabrication -> Comp. File (.cmp)") }, |
| 362 | + { wxCMD_LINE_SWITCH, 0, wxT("vrml"), |
| 363 | + wxT("File -> Export -> VRML (.wrl)") }, |
| 364 | + { wxCMD_LINE_PARAM, 0, 0, wxT("<path to .brd file>"), |
| 365 | + wxCMD_LINE_VAL_STRING }, |
| 366 | + { wxCMD_LINE_NONE } |
| 367 | +}; |
| 368 | + |
| 369 | +bool Pcbnew_CmdLine() |
| 370 | +{ |
| 371 | + wxFileName cmdline_fn, fn; |
| 372 | + wxString str; |
| 373 | + PCB_EDIT_FRAME* frame = NULL; |
| 374 | + wxCommandEvent dummy; |
| 375 | + int i; |
| 376 | + |
| 377 | + EDA_APP& app = wxGetApp(); |
| 378 | + g_CmdLineMode = true; |
| 379 | + wxLog::EnableLogging(false); // this should suppress some wx dialogs |
| 380 | + app.InitEDA_Appl( wxT( "Pcbnew" ), APP_PCBNEW_T ); |
| 381 | + |
| 382 | + wxCmdLineParser parser; |
| 383 | + parser.SetDesc(g_cmdLineDesc); |
| 384 | + parser.SetCmdLine(app.argc, app.argv); |
| 385 | + if (parser.Parse()) |
| 386 | + return false; |
| 387 | + i = parser.Found( _("list-layers") ) |
| 388 | + + parser.Found( _("drill") ) |
| 389 | + + parser.Found( _("plot") ) |
| 390 | + + parser.Found( _("svg") ) |
| 391 | + + parser.Found( _("drc") ) |
| 392 | + + parser.Found( _("pos") ) |
| 393 | + + parser.Found( _("bom") ) |
| 394 | + + parser.Found( _("cmp") ) |
| 395 | + + parser.Found( _("vrml") ); |
| 396 | + if ( !i ) |
| 397 | + { |
| 398 | + wxFprintf( stderr, wxT("One of --list-layers --drill --plot --svg --drc --pos --bom --cmp or --vrml must be given.\n")); |
| 399 | + return false; |
| 400 | + } |
| 401 | + if ( i > 1 ) |
| 402 | + { |
| 403 | + wxFprintf( stderr, wxT("Only one of ---list-layers --drill --plot --svg --drc --pos --bom --cmp or --vrml may be given at a time.\n")); |
| 404 | + return false; |
| 405 | + } |
| 406 | + |
| 407 | + cmdline_fn = parser.GetParam(); |
| 408 | + if( cmdline_fn.GetExt() != PcbFileExtension ) |
| 409 | + { |
| 410 | + wxLogDebug( wxT( "PcbNew file <%s> has the wrong extension. Changing extension to .brd." ), GetChars( cmdline_fn.GetFullPath() ) ); |
| 411 | + cmdline_fn.SetExt( PcbFileExtension ); |
| 412 | + } |
| 413 | + if( !cmdline_fn.FileExists()) |
| 414 | + { |
| 415 | + wxFprintf( stderr, wxT("%ls: file '%ls' does not exist.\n" ), app.argv[0], cmdline_fn.GetFullPath().c_str() ); |
| 416 | + return false; |
| 417 | + } |
| 418 | + wxSetWorkingDirectory( cmdline_fn.GetPath() ); |
| 419 | + |
| 420 | + app.GetSettings( false /* reopenLastUsedDirectory */ ); |
| 421 | + |
| 422 | + g_DrawBgColor = BLACK; |
| 423 | + frame = new PCB_EDIT_FRAME( NULL, wxT( "Pcbnew" ), wxPoint( 0, 0 ), |
| 424 | + wxSize( 600, 400 ) ); |
| 425 | + app.SetTopWindow( frame ); |
| 426 | + |
| 427 | +#if 0 // enable this to see more of the GUI |
| 428 | + frame->Show( true ); |
| 429 | + frame->Zoom_Automatique( true ); |
| 430 | +#endif |
| 431 | + |
| 432 | + frame->LoadOnePcbFile( cmdline_fn.GetFullPath() ); |
| 433 | + frame->LoadProjectSettings( cmdline_fn.GetFullPath() ); |
| 434 | + |
| 435 | + if ( parser.Found( wxT("list-layers") ) ) |
| 436 | + { |
| 437 | + for ( i = 0; i < NB_LAYERS; i++ ) |
| 438 | + { |
| 439 | + if( frame->GetBoard()->IsLayerEnabled( i ) ) |
| 440 | + { |
| 441 | + str = frame->GetBoard()->GetLayerName( i ); |
| 442 | + // remove leading and trailing spaces if any |
| 443 | + str.Trim( true ); str.Trim( false ); |
| 444 | + wxPrintf(str + _("\n")); |
| 445 | + } |
| 446 | + } |
| 447 | + } |
| 448 | + |
| 449 | + if ( parser.Found( wxT("drill") ) ) |
| 450 | + { |
| 451 | + DIALOG_GENDRILL drill_frame( frame ); |
| 452 | + drill_frame.m_Choice_Drill_Offset->SetSelection( |
| 453 | + parser.Found( wxT("drill-aux-origin") ) ); |
| 454 | + wxSafeYield(); |
| 455 | + drill_frame.GenDrillAndReportFiles(); |
| 456 | + } |
| 457 | + |
| 458 | + if ( parser.Found( wxT("plot"), &str ) ) // see pcbplot.cpp |
| 459 | + { |
| 460 | + int plot_format; |
| 461 | + PCB_PLOT_PARAMS plot_params; |
| 462 | + wxString ext, layers_str; |
| 463 | + |
| 464 | + plot_params = frame->GetPlotSettings(); |
| 465 | + plot_params.m_PlotLineWidth = g_DrawDefaultLineThickness; |
| 466 | + if (!str.CmpNoCase( wxT("ps") ) ) |
| 467 | + { |
| 468 | + plot_format = PLOT_FORMAT_POST; |
| 469 | + ext = wxT( "ps" ); |
| 470 | + } |
| 471 | + else if ( !str.CmpNoCase( wxT("gerber") ) ) |
| 472 | + { |
| 473 | + plot_format = PLOT_FORMAT_GERBER; |
| 474 | + ext = wxT( "pho" ); |
| 475 | + } |
| 476 | + else if ( !str.CmpNoCase( wxT("dxf") ) ) |
| 477 | + { |
| 478 | + plot_format = PLOT_FORMAT_DXF; |
| 479 | + ext = wxT( "dxf" ); |
| 480 | + } |
| 481 | + else |
| 482 | + { |
| 483 | + wxFprintf( stderr, |
| 484 | + wxT("Unexpected plot type '%ls'.\n"), str.c_str() ); |
| 485 | + return false; |
| 486 | + } |
| 487 | + |
| 488 | + // --plot-fill-all-zones |
| 489 | + if ( parser.Found( wxT("plot-fill-all-zones") ) ) |
| 490 | + frame->Fill_All_Zones( 0 /* aActiveWindow for progress bar */, |
| 491 | + false /* verbose */ ); |
| 492 | + |
| 493 | + // --plot-drill-marks |
| 494 | + if ( plot_format == PLOT_FORMAT_POST |
| 495 | + && parser.Found( wxT("plot-drill-marks"), &str ) ) |
| 496 | + { |
| 497 | + if (!str.CmpNoCase( wxT("none") ) ) |
| 498 | + plot_params.m_DrillShapeOpt = PCB_PLOT_PARAMS::NO_DRILL_SHAPE; |
| 499 | + else if ( !str.CmpNoCase( wxT("small") ) ) |
| 500 | + plot_params.m_DrillShapeOpt = PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE; |
| 501 | + else if ( !str.CmpNoCase( wxT("actual") ) ) |
| 502 | + plot_params.m_DrillShapeOpt = PCB_PLOT_PARAMS::FULL_DRILL_SHAPE; |
| 503 | + else |
| 504 | + { |
| 505 | + wxFprintf( stderr, wxT("Unexpected Postscript plot drill marks option '%ls'.\n"), str.c_str()); |
| 506 | + return false; |
| 507 | + } |
| 508 | + } |
| 509 | + |
| 510 | + // --plot-mirror |
| 511 | + plot_params.m_PlotMirror = parser.Found( wxT("plot-mirror") ); |
| 512 | + |
| 513 | + // --plot-exclude-edge |
| 514 | + plot_params.m_ExcludeEdgeLayer = |
| 515 | + parser.Found( wxT("plot-exclude-edge") ); |
| 516 | + |
| 517 | + frame->SetPlotSettings(plot_params); |
| 518 | + |
| 519 | + parser.Found( wxT("layers"), &layers_str ); |
| 520 | + wxStringTokenizer tokenizer( layers_str, _(",") ); |
| 521 | + int layer_i = 0; |
| 522 | + wxString layername; |
| 523 | + while ( ( layers_str.IsEmpty() && layer_i < NB_LAYERS ) || tokenizer.HasMoreTokens() ) |
| 524 | + { |
| 525 | + if ( layers_str.IsEmpty() ) |
| 526 | + { |
| 527 | + if( !frame->GetBoard()->IsLayerEnabled( layer_i ) ) |
| 528 | + { |
| 529 | + layer_i++; |
| 530 | + continue; |
| 531 | + } |
| 532 | + layername = frame->GetBoard()->GetLayerName( layer_i ); |
| 533 | + // remove leading and trailing spaces if any |
| 534 | + layername.Trim( true ); layername.Trim( false ); |
| 535 | + layer_i++; |
| 536 | + } |
| 537 | + else |
| 538 | + { |
| 539 | + layername = tokenizer.GetNextToken(); |
| 540 | + for( layer_i = 0; layer_i < NB_LAYERS; layer_i++ ) |
| 541 | + { |
| 542 | + str = frame->GetBoard()->GetLayerName( layer_i ); |
| 543 | + // remove leading and trailing spaces if any |
| 544 | + str.Trim( true ); str.Trim( false ); |
| 545 | + if ( !str.Cmp( layername ) ) |
| 546 | + break; |
| 547 | + } |
| 548 | + if (layer_i >= NB_LAYERS) |
| 549 | + { |
| 550 | + wxFprintf( stderr, _( "Unknown layer name '%ls'\n" ), layername.c_str() ); |
| 551 | + continue; |
| 552 | + } |
| 553 | + } |
| 554 | + fn = cmdline_fn; |
| 555 | + fn.SetName( fn.GetName() + wxT( "-" ) + layername ); |
| 556 | + |
| 557 | + // Use Gerber Extensions based on layer number |
| 558 | + // (See http://en.wikipedia.org/wiki/Gerber_File) |
| 559 | + if( (plot_format == PLOT_FORMAT_GERBER) && true /* always use gerber extensions */ ) |
| 560 | + { |
| 561 | + switch( layer_i ) |
| 562 | + { |
| 563 | + case LAYER_N_FRONT: |
| 564 | + fn.SetExt( wxT( "gtl" ) ); |
| 565 | + break; |
| 566 | + |
| 567 | + case LAYER_N_2: |
| 568 | + case LAYER_N_3: |
| 569 | + case LAYER_N_4: |
| 570 | + case LAYER_N_5: |
| 571 | + case LAYER_N_6: |
| 572 | + case LAYER_N_7: |
| 573 | + case LAYER_N_8: |
| 574 | + case LAYER_N_9: |
| 575 | + case LAYER_N_10: |
| 576 | + case LAYER_N_11: |
| 577 | + case LAYER_N_12: |
| 578 | + case LAYER_N_13: |
| 579 | + case LAYER_N_14: |
| 580 | + case LAYER_N_15: |
| 581 | + |
| 582 | + // TODO: see if we use .gbr or a layer identifier (gb1 .. gbnn ?) |
| 583 | + // according to the new internal layers designation |
| 584 | + // (1 is the first internal layer from the front layer) |
| 585 | + fn.SetExt( wxT( "gbr" ) ); |
| 586 | + break; |
| 587 | + |
| 588 | + case LAYER_N_BACK: |
| 589 | + fn.SetExt( wxT( "gbl" ) ); |
| 590 | + break; |
| 591 | + |
| 592 | + case ADHESIVE_N_BACK: |
| 593 | + fn.SetExt( wxT( "gba" ) ); |
| 594 | + break; |
| 595 | + |
| 596 | + case ADHESIVE_N_FRONT: |
| 597 | + fn.SetExt( wxT( "gta" ) ); |
| 598 | + break; |
| 599 | + |
| 600 | + case SOLDERPASTE_N_BACK: |
| 601 | + fn.SetExt( wxT( "gbp" ) ); |
| 602 | + break; |
| 603 | + |
| 604 | + case SOLDERPASTE_N_FRONT: |
| 605 | + fn.SetExt( wxT( "gtp" ) ); |
| 606 | + break; |
| 607 | + |
| 608 | + case SILKSCREEN_N_BACK: |
| 609 | + fn.SetExt( wxT( "gbo" ) ); |
| 610 | + break; |
| 611 | + |
| 612 | + case SILKSCREEN_N_FRONT: |
| 613 | + fn.SetExt( wxT( "gto" ) ); |
| 614 | + break; |
| 615 | + |
| 616 | + case SOLDERMASK_N_BACK: |
| 617 | + fn.SetExt( wxT( "gbs" ) ); |
| 618 | + break; |
| 619 | + |
| 620 | + case SOLDERMASK_N_FRONT: |
| 621 | + fn.SetExt( wxT( "gts" ) ); |
| 622 | + break; |
| 623 | + |
| 624 | + case DRAW_N: |
| 625 | + case COMMENT_N: |
| 626 | + case ECO1_N: |
| 627 | + case ECO2_N: |
| 628 | + case EDGE_N: |
| 629 | + default: |
| 630 | + fn.SetExt( wxT( "gbr" ) ); |
| 631 | + break; |
| 632 | + } |
| 633 | + } |
| 634 | + else |
| 635 | + { |
| 636 | + fn.SetExt( ext ); |
| 637 | + } |
| 638 | + |
| 639 | + bool success = false; |
| 640 | + |
| 641 | + switch( plot_format ) |
| 642 | + { |
| 643 | + case PLOT_FORMAT_POST: |
| 644 | + success = frame->ExportToPostScriptFile( fn.GetFullPath(), |
| 645 | + layer_i, |
| 646 | + parser.Found( wxT("plot-force-a4") ), |
| 647 | + FILLED /* trace_mode */ ); |
| 648 | + break; |
| 649 | + |
| 650 | + case PLOT_FORMAT_GERBER: |
| 651 | + success = frame->ExportToGerberFile( fn.GetFullPath(), layer_i, |
| 652 | + parser.Found( wxT("plot-aux-origin") ), |
| 653 | + FILLED /* trace_mode */ ); |
| 654 | + break; |
| 655 | + |
| 656 | + case PLOT_FORMAT_DXF: |
| 657 | + success = frame->ExportToDxfFile( fn.GetFullPath(), layer_i, |
| 658 | + parser.Found( wxT("plot-aux-origin") ), |
| 659 | + FILLED /* trace_mode */ ); |
| 660 | + break; |
| 661 | + } |
| 662 | + |
| 663 | + // Print diags in messages box: |
| 664 | + wxString msg; |
| 665 | + if( !success ) |
| 666 | + wxFprintf( stderr, _( "Unable to create <%s>\n" ), |
| 667 | + GetChars( fn.GetFullPath() ) ); |
| 668 | + } |
| 669 | + } |
| 670 | + if ( parser.Found( wxT("svg"), &str ) ) |
| 671 | + { |
| 672 | + wxString layers_str; |
| 673 | + DIALOG_SVG_PRINT dlg( frame ); |
| 674 | + |
| 675 | + parser.Found( wxT("layers"), &layers_str ); |
| 676 | + if ( !layers_str.IsEmpty() ) |
| 677 | + { |
| 678 | + int layer; |
| 679 | + for( layer = 0; layer < NB_LAYERS; ++layer ) |
| 680 | + { |
| 681 | + if (dlg.m_BoxSelectLayer[layer]) |
| 682 | + dlg.m_BoxSelectLayer[layer]->SetValue( 0 ); |
| 683 | + } |
| 684 | + |
| 685 | + wxStringTokenizer tokenizer( layers_str, _(",") ); |
| 686 | + while ( tokenizer.HasMoreTokens() ) |
| 687 | + { |
| 688 | + wxString layername = tokenizer.GetNextToken(); |
| 689 | + for( layer = 0; layer < NB_LAYERS; layer++ ) |
| 690 | + { |
| 691 | + wxString cur = frame->GetBoard()->GetLayerName( layer ); |
| 692 | + // remove leading and trailing spaces if any |
| 693 | + cur.Trim( true ); cur.Trim( false ); |
| 694 | + if ( !cur.Cmp( layername ) ) |
| 695 | + break; |
| 696 | + } |
| 697 | + if (layer >= NB_LAYERS) |
| 698 | + { |
| 699 | + wxFprintf( stderr, _( "Unknown layer '%ls'\n" ), |
| 700 | + layername.c_str() ); |
| 701 | + continue; |
| 702 | + } |
| 703 | + if (!dlg.m_BoxSelectLayer[layer]) |
| 704 | + wxFprintf( stderr, _( "No layer '%ls'\n" ), |
| 705 | + layername.c_str() ); |
| 706 | + else |
| 707 | + dlg.m_BoxSelectLayer[layer]->SetValue( 1 ); |
| 708 | + } |
| 709 | + } |
| 710 | + |
| 711 | + dlg.m_Print_Frame_Ref_Ctrl->SetValue( 0 ); |
| 712 | + dlg.m_PrintBoardEdgesCtrl->SetValue( |
| 713 | + parser.Found( wxT("svg-board-edges") ) ); |
| 714 | + |
| 715 | + wxSafeYield(); |
| 716 | + if ( !str.CmpNoCase( wxT("selected") ) ) |
| 717 | + dlg.OnButtonPrintSelectedClick( dummy ); |
| 718 | + else if ( !str.CmpNoCase( wxT("board") ) ) |
| 719 | + dlg.OnButtonPrintBoardClick( dummy ); |
| 720 | + else |
| 721 | + { |
| 722 | + wxFprintf( stderr, wxT("Unexpected SVG type '%ls'.\n"), |
| 723 | + str.c_str()); |
| 724 | + return false; |
| 725 | + } |
| 726 | + } |
| 727 | + |
| 728 | + if ( parser.Found( wxT("drc") ) ) |
| 729 | + { |
| 730 | + wxTextCtrl msgs; |
| 731 | + |
| 732 | + fn = cmdline_fn; |
| 733 | + fn.SetExt( _("rpt") ); |
| 734 | + |
| 735 | + // drc.cpp DRC::ShowDialog() |
| 736 | + // dialogs/dialog_drc.cpp DIALOG_DRC_CONTROL::OnStartdrcClick() |
| 737 | + frame->m_drc->updatePointers(); |
| 738 | + frame->m_drc->SetSettings(true, // Pad to pad DRC test enabled |
| 739 | + true, // unconnected pdas DRC test enabled |
| 740 | + true, // DRC test for zones enabled |
| 741 | + fn.GetFullPath(), // report file name |
| 742 | + true /* aSaveReport */ ); |
| 743 | + frame->m_drc->m_pcb->m_Status_Pcb = 0; // Force full connectivity and ratsnest recalculations |
| 744 | + frame->m_drc->RunTests(&msgs); // not everybody checks for 0 pointer |
| 745 | + FILE* fp = wxFopen( fn.GetFullPath(), wxT( "w" ) ); |
| 746 | + { // strings should match dialogs/dialog_drc.cpp:DIALOG_DRC_CONTROL::writeReport() |
| 747 | + int count; |
| 748 | + |
| 749 | + fprintf( fp, "** Drc report for %s **\n", TO_UTF8( cmdline_fn.GetFullPath() ) ); |
| 750 | + |
| 751 | + wxDateTime now = wxDateTime::Now(); |
| 752 | + fprintf( fp, "** Created on %s **\n", TO_UTF8( now.Format( wxT( "%F %T" ) ) ) ); |
| 753 | + |
| 754 | + class DRC_LIST_MARKERS* markers = new DRC_LIST_MARKERS( frame->m_drc->m_pcb ); |
| 755 | + count = markers->GetCount(); |
| 756 | + fprintf( fp, "\n** Found %d DRC errors **\n", count ); |
| 757 | + for ( i = 0; i < count; i++ ) |
| 758 | + fprintf( fp, "%s", TO_UTF8( markers->GetItem( i )->ShowReport()) ); |
| 759 | + delete markers; |
| 760 | + |
| 761 | + class DRC_LIST_UNCONNECTED* unconnected = new DRC_LIST_UNCONNECTED( &frame->m_drc->m_unconnected ); |
| 762 | + count = unconnected->GetCount(); |
| 763 | + fprintf( fp, "\n** Found %d unconnected pads **\n", count ); |
| 764 | + for ( i = 0; i < count; i++ ) |
| 765 | + fprintf( fp, "%s", TO_UTF8( unconnected->GetItem( i )->ShowReport()) ); |
| 766 | + delete unconnected; |
| 767 | + |
| 768 | + fprintf( fp, "\n** End of Report **\n" ); |
| 769 | + } |
| 770 | + fclose( fp ); |
| 771 | + } |
| 772 | + |
| 773 | + if ( parser.Found( wxT("pos") ) ) |
| 774 | + { |
| 775 | + // see gen_modules_placefile.cpp:PCB_EDIT_FRAME::GenFootprintsPositionFile() |
| 776 | + fn = cmdline_fn; |
| 777 | + fn.SetName( fn.GetName() + wxT( "_all") ); |
| 778 | + fn.SetExt( FootprintPlaceFileExtension ); |
| 779 | + frame->DoGenFootprintsPositionFile( fn.GetFullPath(), |
| 780 | + true /* aUnitsMM */, true /* aForceSmdItems */, |
| 781 | + 2 /* aSide, 2 = both */ ); |
| 782 | + } |
| 783 | + |
| 784 | + if ( parser.Found( wxT("bom") ) ) |
| 785 | + // see build_BOM_from_board.cpp:PCB_EDIT_FRAME::RecreateBOMFileFromBoard() |
| 786 | + frame->RecreateBOMFileFromBoard( dummy ); |
| 787 | + |
| 788 | + if ( parser.Found( wxT("cmp") ) ) |
| 789 | + // see xchgmod.cpp:WinEDA_PcbFrame::RecreateCmpFileFromBoard() |
| 790 | + frame->RecreateCmpFileFromBoard( dummy ); |
| 791 | + |
| 792 | + if ( parser.Found( wxT("vrml") ) ) |
| 793 | + { |
| 794 | + // see export_vrml.cpp:WinEDA_PcbFrame::OnExportVRML() |
| 795 | + wxString subDirFor3Dshapes( _( "shapes3D" ) ); |
| 796 | + |
| 797 | + fn = cmdline_fn; |
| 798 | + fn.SetExt( _("wrl") ); |
| 799 | + if( ! wxDirExists( subDirFor3Dshapes ) ) |
| 800 | + wxMkdir( subDirFor3Dshapes ); |
| 801 | + frame->ExportVRML_File( fn.GetFullPath(), 1.0 /* aScale */, |
| 802 | + true /* aExport3DFile */, subDirFor3Dshapes ); |
| 803 | + } |
| 804 | + return true; |
| 805 | +} |
| 806 |
Branches:
master
