From 1f4b288664b1ea0a9e17f987b310281122f09a05 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 22 Jun 2022 11:13:06 +0200 Subject: [PATCH] gen drill maps: remove unusable format (HPGL and GERBER) for map files. Especially, on a regular basis, map files in gerber format create problems for board house. From Master branch. --- pcbnew/dialogs/dialog_gendrill.cpp | 14 +++++++------ pcbnew/dialogs/dialog_gendrill_base.cpp | 6 +++--- pcbnew/dialogs/dialog_gendrill_base.fbp | 11 +++++++--- pcbnew/dialogs/dialog_gendrill_base.h | 5 +++-- pcbnew/exporters/gen_drill_report_files.cpp | 23 +++++++-------------- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/pcbnew/dialogs/dialog_gendrill.cpp b/pcbnew/dialogs/dialog_gendrill.cpp index 974bb29cac..e0fcf22cb1 100644 --- a/pcbnew/dialogs/dialog_gendrill.cpp +++ b/pcbnew/dialogs/dialog_gendrill.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 1992-2019 Jean_Pierre Charras - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -92,7 +92,7 @@ int DIALOG_GENDRILL::m_ZerosFormat = EXCELLON_WRITER::DECIMAL_FORMAT; bool DIALOG_GENDRILL::m_MinimalHeader = false; // Only for Excellon format bool DIALOG_GENDRILL::m_Mirror = false; // Only for Excellon format bool DIALOG_GENDRILL::m_Merge_PTH_NPTH = false; // Only for Excellon format -int DIALOG_GENDRILL::m_mapFileType = 1; +int DIALOG_GENDRILL::m_mapFileType = 3; int DIALOG_GENDRILL::m_drillFileType = 0; bool DIALOG_GENDRILL::m_UseRouteModeForOvalHoles = true; // Use G00 route mode to "drill" oval holes @@ -116,6 +116,10 @@ void DIALOG_GENDRILL::initDialog() m_drillOriginIsAuxAxis = m_plotOpts.GetUseAuxOrigin(); + // Ensure validity of m_mapFileType + if( m_mapFileType < 0 || m_mapFileType > 3 ) + m_mapFileType = 3; // default = PDF + InitDisplayParams(); } @@ -368,11 +372,9 @@ void DIALOG_GENDRILL::GenDrillAndMapFiles( bool aGenDrill, bool aGenMap ) m_pcbEditFrame->ClearMsgPanel(); WX_TEXT_CTRL_REPORTER reporter( m_messagesBox ); - const PLOT_FORMAT filefmt[6] = { + const PLOT_FORMAT filefmt[] = { // Keep these format ids in the same order than m_Choice_Drill_Map choices - PLOT_FORMAT::HPGL, PLOT_FORMAT::POST, - PLOT_FORMAT::GERBER, PLOT_FORMAT::DXF, PLOT_FORMAT::SVG, PLOT_FORMAT::PDF @@ -381,7 +383,7 @@ void DIALOG_GENDRILL::GenDrillAndMapFiles( bool aGenDrill, bool aGenMap ) unsigned choice = (unsigned) m_Choice_Drill_Map->GetSelection(); if( choice >= arrayDim( filefmt ) ) - choice = 1; + choice = arrayDim( filefmt )-1; // Last choice = PDF // Create output directory if it does not exist (also transform it in absolute form). // Bail if it fails. diff --git a/pcbnew/dialogs/dialog_gendrill_base.cpp b/pcbnew/dialogs/dialog_gendrill_base.cpp index 0cbe5dacbf..0e03044239 100644 --- a/pcbnew/dialogs/dialog_gendrill_base.cpp +++ b/pcbnew/dialogs/dialog_gendrill_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -79,10 +79,10 @@ DIALOG_GENDRILL_BASE::DIALOG_GENDRILL_BASE( wxWindow* parent, wxWindowID id, con bMiddleSizer->Add( sbSizer6, 1, wxEXPAND|wxALL, 5 ); - wxString m_Choice_Drill_MapChoices[] = { _("HPGL"), _("PostScript"), _("Gerber"), _("DXF"), _("SVG"), _("PDF") }; + wxString m_Choice_Drill_MapChoices[] = { _("PostScript"), _("DXF"), _("SVG"), _("PDF") }; int m_Choice_Drill_MapNChoices = sizeof( m_Choice_Drill_MapChoices ) / sizeof( wxString ); m_Choice_Drill_Map = new wxRadioBox( this, wxID_ANY, _("Map File Format"), wxDefaultPosition, wxDefaultSize, m_Choice_Drill_MapNChoices, m_Choice_Drill_MapChoices, 1, wxRA_SPECIFY_COLS ); - m_Choice_Drill_Map->SetSelection( 1 ); + m_Choice_Drill_Map->SetSelection( 5 ); m_Choice_Drill_Map->SetToolTip( _("Creates a drill map in PS, HPGL or other formats") ); bMiddleSizer->Add( m_Choice_Drill_Map, 0, wxALL|wxEXPAND, 5 ); diff --git a/pcbnew/dialogs/dialog_gendrill_base.fbp b/pcbnew/dialogs/dialog_gendrill_base.fbp index 30c9c497a8..867d3c1ae8 100644 --- a/pcbnew/dialogs/dialog_gendrill_base.fbp +++ b/pcbnew/dialogs/dialog_gendrill_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -14,6 +14,7 @@ dialog_gendrill_base 1000 none + 1 dialog_gendrill_base @@ -25,6 +26,7 @@ 1 1 UI + 0 0 0 @@ -50,6 +52,7 @@ DIALOG_SHIM; dialog_shim.h Generate Drill Files + 0 @@ -206,6 +209,7 @@ + 0 @@ -717,7 +721,7 @@ 1 0 - "HPGL" "PostScript" "Gerber" "DXF" "SVG" "PDF" + "PostScript" "DXF" "SVG" "PDF" 1 1 @@ -749,7 +753,7 @@ 1 Resizable - 1 + 5 1 wxRA_SPECIFY_COLS @@ -1873,6 +1877,7 @@ + 0 diff --git a/pcbnew/dialogs/dialog_gendrill_base.h b/pcbnew/dialogs/dialog_gendrill_base.h index 7dc718f948..fdb735d56f 100644 --- a/pcbnew/dialogs/dialog_gendrill_base.h +++ b/pcbnew/dialogs/dialog_gendrill_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -74,7 +74,7 @@ class DIALOG_GENDRILL_BASE : public DIALOG_SHIM wxButton* m_sdbSizerApply; wxButton* m_sdbSizerCancel; - // Virtual event handlers, overide them in your derived class + // Virtual event handlers, override them in your derived class virtual void onCloseDlg( wxCloseEvent& event ) { event.Skip(); } virtual void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) { event.Skip(); } virtual void onFileFormatSelection( wxCommandEvent& event ) { event.Skip(); } @@ -89,6 +89,7 @@ class DIALOG_GENDRILL_BASE : public DIALOG_SHIM public: DIALOG_GENDRILL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Generate Drill Files"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_GENDRILL_BASE(); }; diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp index fa9d0369c6..bf769914a5 100644 --- a/pcbnew/exporters/gen_drill_report_files.cpp +++ b/pcbnew/exporters/gen_drill_report_files.cpp @@ -91,27 +91,20 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_ EDA_RECT bbbox = m_pcb->GetBoardEdgesBoundingBox(); m_pcb->SetVisibleLayers( visibleLayers ); + // Some formats cannot be used to generate a document like the map files + // - HPGL (old format not very used) + // - GERBER because a map file is not a fabrication file usable by board house + // (in fact such a file usually create problems when sent to a board house) + + if( aFormat == PLOT_FORMAT::HPGL || aFormat == PLOT_FORMAT::GERBER ) + aFormat = PLOT_FORMAT::PDF; + // Calculate the scale for the format type, scale 1 in HPGL, drawing on // an A4 sheet in PS, + text description of symbols switch( aFormat ) { case PLOT_FORMAT::GERBER: - plotter = new GERBER_PLOTTER(); - plotter->SetViewport( offset, IU_PER_MILS / 10, scale, false ); - plotter->SetGerberCoordinatesFormat( 5 ); // format x.5 unit = mm - break; - case PLOT_FORMAT::HPGL: // Scale for HPGL format. - { - HPGL_PLOTTER* hpgl_plotter = new HPGL_PLOTTER; - plotter = hpgl_plotter; - hpgl_plotter->SetPenNumber( plot_opts.GetHPGLPenNum() ); - hpgl_plotter->SetPenSpeed( plot_opts.GetHPGLPenSpeed() ); - plotter->SetPageSettings( page_info ); - plotter->SetViewport( offset, IU_PER_MILS / 10, scale, false ); - } - break; - default: wxASSERT( false ); KI_FALLTHROUGH;