2011-01-28 22:54:16 +00:00
|
|
|
/*
|
2011-09-30 18:15:37 +00:00
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
2011-01-28 22:54:16 +00:00
|
|
|
*
|
2022-01-28 17:06:47 +00:00
|
|
|
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-01-28 22:54:16 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <board_design_settings.h>
|
2022-08-14 02:28:41 +00:00
|
|
|
#include <charconv>
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2023-09-09 04:10:57 +00:00
|
|
|
#include <string_utils.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <math/util.h> // for KiROUND
|
|
|
|
#include <pcb_plot_params.h>
|
|
|
|
#include <pcb_plot_params_parser.h>
|
2021-08-18 20:38:14 +00:00
|
|
|
#include <plotters/plotter.h>
|
2023-12-19 17:39:26 +00:00
|
|
|
#include <io/kicad/kicad_io_utils.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/color_settings.h>
|
2011-01-28 22:54:16 +00:00
|
|
|
|
2012-01-09 08:35:06 +00:00
|
|
|
|
2018-10-07 22:22:54 +00:00
|
|
|
#define PLOT_LINEWIDTH_DEFAULT ( DEFAULT_TEXT_WIDTH * IU_PER_MM )
|
2020-04-23 08:02:59 +00:00
|
|
|
|
2011-02-03 22:26:30 +00:00
|
|
|
#define HPGL_PEN_DIAMETER_MIN 0
|
2018-05-26 07:37:21 +00:00
|
|
|
#define HPGL_PEN_DIAMETER_MAX 100.0 // Unit = mil
|
2012-06-09 09:38:58 +00:00
|
|
|
#define HPGL_PEN_SPEED_MIN 1 // this param is always in cm/s
|
|
|
|
#define HPGL_PEN_SPEED_MAX 99 // this param is always in cm/s
|
2011-02-03 22:26:30 +00:00
|
|
|
#define HPGL_PEN_NUMBER_MIN 1
|
|
|
|
#define HPGL_PEN_NUMBER_MAX 16
|
|
|
|
|
2020-04-23 08:02:59 +00:00
|
|
|
#define SVG_PRECISION_MIN 3U
|
|
|
|
#define SVG_PRECISION_MAX 6U
|
2022-01-28 17:06:47 +00:00
|
|
|
#define SVG_PRECISION_DEFAULT 4
|
2020-04-23 08:02:59 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
|
2014-07-04 14:22:38 +00:00
|
|
|
// default trailing digits in Gerber coordinates, when units are mm
|
|
|
|
// This is also the max usable precision (i.e. internal Pcbnew Units)
|
|
|
|
static const int gbrDefaultPrecision = 6;
|
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
|
|
|
|
using namespace PCBPLOTPARAMS_T;
|
|
|
|
|
2011-02-03 22:26:30 +00:00
|
|
|
|
|
|
|
static const char* getTokenName( T aTok )
|
2011-01-28 22:54:16 +00:00
|
|
|
{
|
|
|
|
return PCB_PLOT_PARAMS_LEXER::TokenName( aTok );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-26 07:37:21 +00:00
|
|
|
static bool setInt( int* aTarget, int aValue, int aMin, int aMax )
|
2011-02-03 22:26:30 +00:00
|
|
|
{
|
|
|
|
int temp = aValue;
|
|
|
|
|
|
|
|
if( aValue < aMin )
|
|
|
|
temp = aMin;
|
|
|
|
else if( aValue > aMax )
|
|
|
|
temp = aMax;
|
|
|
|
|
2018-05-26 07:37:21 +00:00
|
|
|
*aTarget = temp;
|
2021-07-19 23:56:05 +00:00
|
|
|
return ( temp == aValue );
|
2018-05-26 07:37:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool setDouble( double* aTarget, double aValue, double aMin, double aMax )
|
|
|
|
{
|
|
|
|
double temp = aValue;
|
|
|
|
|
|
|
|
if( aValue < aMin )
|
|
|
|
temp = aMin;
|
|
|
|
else if( aValue > aMax )
|
|
|
|
temp = aMax;
|
|
|
|
|
|
|
|
*aTarget = temp;
|
2021-07-19 23:56:05 +00:00
|
|
|
return ( temp == aValue );
|
2011-02-03 22:26:30 +00:00
|
|
|
}
|
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
|
2015-12-08 15:15:24 +00:00
|
|
|
PCB_PLOT_PARAMS::PCB_PLOT_PARAMS()
|
2011-01-28 22:54:16 +00:00
|
|
|
{
|
2015-10-21 06:55:30 +00:00
|
|
|
m_useGerberProtelExtensions = false;
|
2020-10-10 12:39:54 +00:00
|
|
|
m_gerberDisableApertMacros = false;
|
2020-03-29 13:35:47 +00:00
|
|
|
m_useGerberX2format = true;
|
|
|
|
m_includeGerberNetlistInfo = true;
|
|
|
|
m_createGerberJobFile = true;
|
2015-10-21 06:55:30 +00:00
|
|
|
m_gerberPrecision = gbrDefaultPrecision;
|
2021-12-25 14:00:57 +00:00
|
|
|
m_dashedLineDashRatio = 12.0; // From ISO 128-2
|
|
|
|
m_dashedLineGapRatio = 3.0; // From ISO 128-2
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-04-20 22:02:03 +00:00
|
|
|
// we used 0.1mils for SVG step before, but nm precision is more accurate, so we use nm
|
2020-04-23 08:02:59 +00:00
|
|
|
m_svgPrecision = SVG_PRECISION_DEFAULT;
|
2023-08-16 05:23:27 +00:00
|
|
|
m_plotDrawingSheet = false;
|
|
|
|
m_plotViaOnMaskLayer = false;
|
2015-10-21 06:55:30 +00:00
|
|
|
m_plotMode = FILLED;
|
2023-04-30 12:43:25 +00:00
|
|
|
m_DXFPolygonMode = true;
|
|
|
|
m_DXFUnits = DXF_UNITS::INCHES;
|
2015-10-21 06:55:30 +00:00
|
|
|
m_useAuxOrigin = false;
|
|
|
|
m_HPGLPenNum = 1;
|
|
|
|
m_HPGLPenSpeed = 20; // this param is always in cm/s
|
|
|
|
m_HPGLPenDiam = 15; // in mils
|
|
|
|
m_negative = false;
|
|
|
|
m_A4Output = false;
|
|
|
|
m_plotReference = true;
|
|
|
|
m_plotValue = true;
|
2023-08-15 15:56:46 +00:00
|
|
|
m_plotFPText = true;
|
2015-10-21 06:55:30 +00:00
|
|
|
m_plotInvisibleText = false;
|
2020-05-01 16:24:01 +00:00
|
|
|
m_sketchPadsOnFabLayers = false;
|
2024-05-27 19:56:16 +00:00
|
|
|
m_plotPadNumbers = false;
|
2015-10-21 06:55:30 +00:00
|
|
|
m_subtractMaskFromSilk = false;
|
2019-12-28 00:55:11 +00:00
|
|
|
m_format = PLOT_FORMAT::GERBER;
|
2015-10-21 06:55:30 +00:00
|
|
|
m_mirror = false;
|
2022-11-12 07:48:25 +00:00
|
|
|
m_drillMarks = DRILL_MARKS::SMALL_DRILL_SHAPE;
|
2015-10-21 06:55:30 +00:00
|
|
|
m_autoScale = false;
|
|
|
|
m_scale = 1.0;
|
|
|
|
m_scaleSelection = 1;
|
|
|
|
m_fineScaleAdjustX = 1.0;
|
|
|
|
m_fineScaleAdjustY = 1.0;
|
|
|
|
m_widthAdjust = 0.;
|
2019-12-28 00:55:11 +00:00
|
|
|
m_textMode = PLOT_TEXT_MODE::DEFAULT;
|
|
|
|
m_outputDirectory.clear();
|
2017-10-24 18:11:08 +00:00
|
|
|
m_layerSelection = LSET( 7, F_SilkS, B_SilkS, F_Mask, B_Mask,
|
|
|
|
F_Paste, B_Paste, Edge_Cuts )
|
|
|
|
| LSET::AllCuMask();
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-30 17:09:40 +00:00
|
|
|
m_PDFFrontFPPropertyPopups = true;
|
|
|
|
m_PDFBackFPPropertyPopups = true;
|
2024-03-13 23:40:18 +00:00
|
|
|
m_PDFMetadata = true;
|
2023-04-30 17:09:40 +00:00
|
|
|
|
2012-09-24 06:39:59 +00:00
|
|
|
// This parameter controls if the NPTH pads will be plotted or not
|
2013-05-07 18:32:06 +00:00
|
|
|
// it is a "local" parameter
|
2015-10-21 06:55:30 +00:00
|
|
|
m_skipNPTH_Pads = false;
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
// line width to plot items in outline mode.
|
2022-09-16 11:33:56 +00:00
|
|
|
m_sketchPadLineWidth = pcbIUScale.mmToIU( 0.1 );
|
2020-06-01 14:08:46 +00:00
|
|
|
|
2020-06-06 17:57:28 +00:00
|
|
|
m_default_colors = std::make_shared<COLOR_SETTINGS>();
|
|
|
|
m_colors = m_default_colors.get();
|
2022-10-25 02:45:24 +00:00
|
|
|
|
|
|
|
m_blackAndWhite = true;
|
2011-01-28 22:54:16 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2014-07-04 14:22:38 +00:00
|
|
|
void PCB_PLOT_PARAMS::SetGerberPrecision( int aPrecision )
|
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
// Currently Gerber files use mm.
|
2014-07-04 14:22:38 +00:00
|
|
|
// accepted precision is only 6 (max value, this is the resolution of Pcbnew)
|
|
|
|
// or 5, min value for professional boards, when 6 creates problems
|
|
|
|
// to board makers.
|
|
|
|
|
|
|
|
m_gerberPrecision = aPrecision == gbrDefaultPrecision-1 ? gbrDefaultPrecision-1 :
|
|
|
|
gbrDefaultPrecision;
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2022-01-28 17:06:47 +00:00
|
|
|
void PCB_PLOT_PARAMS::SetSvgPrecision( unsigned aPrecision )
|
2020-04-20 22:02:03 +00:00
|
|
|
{
|
2020-04-23 08:02:59 +00:00
|
|
|
m_svgPrecision = Clamp( SVG_PRECISION_MIN, aPrecision, SVG_PRECISION_MAX );
|
2020-04-20 22:02:03 +00:00
|
|
|
}
|
2011-01-28 22:54:16 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter,
|
2017-06-08 21:47:21 +00:00
|
|
|
int aNestLevel, int aControl ) const
|
2011-01-28 22:54:16 +00:00
|
|
|
{
|
2021-08-25 23:14:36 +00:00
|
|
|
aFormatter->Print( aNestLevel, "(pcbplotparams\n" );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(layerselection 0x%s)\n",
|
2014-06-24 16:17:18 +00:00
|
|
|
m_layerSelection.FmtHex().c_str() );
|
|
|
|
|
2022-04-02 13:36:20 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(plot_on_all_layers_selection 0x%s)\n",
|
|
|
|
m_plotOnAllLayersSelection.FmtHex().c_str() );
|
|
|
|
|
2023-09-24 16:53:34 +00:00
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "disableapertmacros",
|
|
|
|
m_gerberDisableApertMacros );
|
2020-10-10 12:39:54 +00:00
|
|
|
|
2023-09-24 16:53:34 +00:00
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "usegerberextensions",
|
|
|
|
m_useGerberProtelExtensions );
|
2014-06-19 07:12:48 +00:00
|
|
|
|
2023-09-24 16:53:34 +00:00
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "usegerberattributes",
|
|
|
|
GetUseGerberX2format() );
|
2014-06-19 07:12:48 +00:00
|
|
|
|
2023-09-24 16:53:34 +00:00
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "usegerberadvancedattributes",
|
|
|
|
GetIncludeGerberNetlistInfo() );
|
2017-08-19 16:28:11 +00:00
|
|
|
|
2023-09-24 16:53:34 +00:00
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "creategerberjobfile",
|
|
|
|
GetCreateGerberJobFile() );
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
// save this option only if it is not the default value,
|
|
|
|
// to avoid incompatibility with older Pcbnew version
|
|
|
|
if( m_gerberPrecision != gbrDefaultPrecision )
|
2021-08-25 23:14:36 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(gerberprecision %d)\n", m_gerberPrecision );
|
|
|
|
|
|
|
|
aFormatter->Print( aNestLevel+1, "(dashed_line_dash_ratio %f)\n", GetDashedLineDashRatio() );
|
|
|
|
aFormatter->Print( aNestLevel+1, "(dashed_line_gap_ratio %f)\n", GetDashedLineGapRatio() );
|
2014-07-04 14:22:38 +00:00
|
|
|
|
2021-01-03 13:59:23 +00:00
|
|
|
// SVG options
|
2021-08-25 23:14:36 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(svgprecision %d)\n", m_svgPrecision );
|
|
|
|
|
2023-09-24 16:53:34 +00:00
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "plotframeref", m_plotDrawingSheet );
|
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "viasonmask", m_plotViaOnMaskLayer );
|
2021-08-25 23:14:36 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(mode %d)\n", GetPlotMode() == SKETCH ? 2 : 1 );
|
2023-09-24 16:53:34 +00:00
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "useauxorigin", m_useAuxOrigin );
|
2021-01-03 13:59:23 +00:00
|
|
|
|
|
|
|
// HPGL options
|
2021-08-25 23:14:36 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(hpglpennumber %d)\n", m_HPGLPenNum );
|
|
|
|
aFormatter->Print( aNestLevel+1, "(hpglpenspeed %d)\n", m_HPGLPenSpeed );
|
|
|
|
aFormatter->Print( aNestLevel+1, "(hpglpendiameter %f)\n", m_HPGLPenDiam );
|
2021-01-03 13:59:23 +00:00
|
|
|
|
2023-04-30 17:09:40 +00:00
|
|
|
// PDF options
|
2023-09-24 16:53:34 +00:00
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1,
|
|
|
|
getTokenName( T_pdf_front_fp_property_popups ),
|
|
|
|
m_PDFFrontFPPropertyPopups );
|
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1,
|
|
|
|
getTokenName( T_pdf_back_fp_property_popups ),
|
|
|
|
m_PDFBackFPPropertyPopups );
|
2024-03-13 23:40:18 +00:00
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1,
|
|
|
|
getTokenName( T_pdf_metadata ),
|
|
|
|
m_PDFMetadata );
|
2023-04-30 17:09:40 +00:00
|
|
|
|
2021-01-03 13:59:23 +00:00
|
|
|
// DXF options
|
2023-09-24 16:53:34 +00:00
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, getTokenName( T_dxfpolygonmode ),
|
|
|
|
m_DXFPolygonMode );
|
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, getTokenName( T_dxfimperialunits ),
|
|
|
|
m_DXFUnits == DXF_UNITS::INCHES );
|
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, getTokenName( T_dxfusepcbnewfont ),
|
|
|
|
m_textMode != PLOT_TEXT_MODE::NATIVE );
|
|
|
|
|
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, getTokenName( T_psnegative ),
|
|
|
|
m_negative );
|
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, getTokenName( T_psa4output ),
|
|
|
|
m_A4Output );
|
|
|
|
|
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "plotreference", m_plotReference );
|
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "plotvalue", m_plotValue );
|
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "plotfptext", m_plotFPText );
|
2024-05-27 19:56:16 +00:00
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "plotinvisibletext", m_plotInvisibleText );
|
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "sketchpadsonfab", m_sketchPadsOnFabLayers );
|
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "plotpadnumbers", m_plotPadNumbers );
|
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "subtractmaskfromsilk", m_subtractMaskFromSilk );
|
2021-08-25 23:14:36 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(outputformat %d)\n", static_cast<int>( m_format ) );
|
2023-09-24 16:53:34 +00:00
|
|
|
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "mirror", m_mirror );
|
2022-11-12 07:48:25 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(drillshape %d)\n", (int)m_drillMarks );
|
2021-08-25 23:14:36 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(scaleselection %d)\n", m_scaleSelection );
|
2022-01-28 17:06:47 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(outputdirectory \"%s\")",
|
2018-06-21 10:30:38 +00:00
|
|
|
(const char*) m_outputDirectory.utf8_str() );
|
2019-07-27 19:09:43 +00:00
|
|
|
aFormatter->Print( 0, "\n" );
|
|
|
|
aFormatter->Print( aNestLevel, ")\n" );
|
2011-01-28 22:54:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-05 20:20:34 +00:00
|
|
|
void PCB_PLOT_PARAMS::Parse( PCB_PLOT_PARAMS_PARSER* aParser )
|
2011-01-28 22:54:16 +00:00
|
|
|
{
|
|
|
|
aParser->Parse( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-03 13:59:23 +00:00
|
|
|
bool PCB_PLOT_PARAMS::IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams ) const
|
2011-01-28 22:54:16 +00:00
|
|
|
{
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_layerSelection != aPcbPlotParams.m_layerSelection )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2022-04-02 13:36:20 +00:00
|
|
|
if( m_plotOnAllLayersSelection != aPcbPlotParams.m_plotOnAllLayersSelection )
|
|
|
|
return false;
|
|
|
|
|
2015-10-21 06:55:30 +00:00
|
|
|
if( m_useGerberProtelExtensions != aPcbPlotParams.m_useGerberProtelExtensions )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-10-10 12:39:54 +00:00
|
|
|
if( m_gerberDisableApertMacros != aPcbPlotParams.m_gerberDisableApertMacros )
|
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2018-12-08 16:46:41 +00:00
|
|
|
if( m_useGerberX2format != aPcbPlotParams.m_useGerberX2format )
|
2014-06-19 06:26:53 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2018-12-08 16:46:41 +00:00
|
|
|
if( m_includeGerberNetlistInfo != aPcbPlotParams.m_includeGerberNetlistInfo )
|
2016-09-19 11:01:36 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2017-08-19 16:28:11 +00:00
|
|
|
if( m_createGerberJobFile != aPcbPlotParams.m_createGerberJobFile )
|
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2014-07-04 14:22:38 +00:00
|
|
|
if( m_gerberPrecision != aPcbPlotParams.m_gerberPrecision )
|
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
if( m_dashedLineDashRatio != aPcbPlotParams.m_dashedLineDashRatio )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( m_dashedLineGapRatio != aPcbPlotParams.m_dashedLineGapRatio )
|
|
|
|
return false;
|
|
|
|
|
2023-04-30 12:43:25 +00:00
|
|
|
if( m_plotDrawingSheet != aPcbPlotParams.m_plotDrawingSheet )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_plotViaOnMaskLayer != aPcbPlotParams.m_plotViaOnMaskLayer )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
if( m_plotMode != aPcbPlotParams.m_plotMode )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-30 12:43:25 +00:00
|
|
|
if( m_DXFPolygonMode != aPcbPlotParams.m_DXFPolygonMode )
|
2021-01-03 13:59:23 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-30 12:43:25 +00:00
|
|
|
if( m_DXFUnits != aPcbPlotParams.m_DXFUnits )
|
2021-01-03 13:59:23 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-04-23 08:02:59 +00:00
|
|
|
if( m_svgPrecision != aPcbPlotParams.m_svgPrecision )
|
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_useAuxOrigin != aPcbPlotParams.m_useAuxOrigin )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
if( m_HPGLPenNum != aPcbPlotParams.m_HPGLPenNum )
|
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
if( m_HPGLPenSpeed != aPcbPlotParams.m_HPGLPenSpeed )
|
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
if( m_HPGLPenDiam != aPcbPlotParams.m_HPGLPenDiam )
|
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_negative != aPcbPlotParams.m_negative )
|
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-30 17:09:40 +00:00
|
|
|
if( m_PDFFrontFPPropertyPopups != aPcbPlotParams.m_PDFFrontFPPropertyPopups )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( m_PDFBackFPPropertyPopups != aPcbPlotParams.m_PDFBackFPPropertyPopups )
|
|
|
|
return false;
|
|
|
|
|
2024-03-13 23:40:18 +00:00
|
|
|
if( m_PDFMetadata != aPcbPlotParams.m_PDFMetadata )
|
|
|
|
return false;
|
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_A4Output != aPcbPlotParams.m_A4Output )
|
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_plotReference != aPcbPlotParams.m_plotReference )
|
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_plotValue != aPcbPlotParams.m_plotValue )
|
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-08-15 15:56:46 +00:00
|
|
|
if( m_plotFPText != aPcbPlotParams.m_plotFPText )
|
|
|
|
return false;
|
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_plotInvisibleText != aPcbPlotParams.m_plotInvisibleText )
|
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-05-01 16:24:01 +00:00
|
|
|
if( m_sketchPadsOnFabLayers != aPcbPlotParams.m_sketchPadsOnFabLayers )
|
2012-08-30 18:06:13 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2024-05-27 19:56:16 +00:00
|
|
|
if( m_plotPadNumbers != aPcbPlotParams.m_plotPadNumbers )
|
|
|
|
return false;
|
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_subtractMaskFromSilk != aPcbPlotParams.m_subtractMaskFromSilk )
|
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_format != aPcbPlotParams.m_format )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_mirror != aPcbPlotParams.m_mirror )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_drillMarks != aPcbPlotParams.m_drillMarks )
|
2011-02-17 17:11:20 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_scaleSelection != aPcbPlotParams.m_scaleSelection )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_autoScale != aPcbPlotParams.m_autoScale )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_scale != aPcbPlotParams.m_scale )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_fineScaleAdjustX != aPcbPlotParams.m_fineScaleAdjustX )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_fineScaleAdjustY != aPcbPlotParams.m_fineScaleAdjustY )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_widthAdjust != aPcbPlotParams.m_widthAdjust )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_textMode != aPcbPlotParams.m_textMode )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2022-10-25 02:45:24 +00:00
|
|
|
if( m_blackAndWhite != aPcbPlotParams.m_blackAndWhite )
|
|
|
|
return false;
|
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
if( !m_outputDirectory.IsSameAs( aPcbPlotParams.m_outputDirectory ) )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2017-07-30 18:27:03 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-26 07:37:21 +00:00
|
|
|
bool PCB_PLOT_PARAMS::SetHPGLPenDiameter( double aValue )
|
2011-02-03 22:26:30 +00:00
|
|
|
{
|
2018-05-26 07:37:21 +00:00
|
|
|
return setDouble( &m_HPGLPenDiam, aValue, HPGL_PEN_DIAMETER_MIN, HPGL_PEN_DIAMETER_MAX );
|
2011-02-03 22:26:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
bool PCB_PLOT_PARAMS::SetHPGLPenSpeed( int aValue )
|
2011-02-03 22:26:30 +00:00
|
|
|
{
|
|
|
|
return setInt( &m_HPGLPenSpeed, aValue, HPGL_PEN_SPEED_MIN, HPGL_PEN_SPEED_MAX );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
PCB_PLOT_PARAMS_PARSER::PCB_PLOT_PARAMS_PARSER( LINE_READER* aReader ) :
|
|
|
|
PCB_PLOT_PARAMS_LEXER( aReader )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-05 20:20:34 +00:00
|
|
|
PCB_PLOT_PARAMS_PARSER::PCB_PLOT_PARAMS_PARSER( char* aLine, const wxString& aSource ) :
|
2011-01-28 22:54:16 +00:00
|
|
|
PCB_PLOT_PARAMS_LEXER( aLine, aSource )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-05 20:20:34 +00:00
|
|
|
void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams )
|
2011-01-28 22:54:16 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
T token;
|
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
while( ( token = NextTok() ) != T_RIGHT )
|
|
|
|
{
|
|
|
|
if( token == T_EOF)
|
|
|
|
Unexpected( T_EOF );
|
|
|
|
|
|
|
|
if( token == T_LEFT )
|
|
|
|
token = NextTok();
|
|
|
|
|
|
|
|
if( token == T_pcbplotparams )
|
|
|
|
continue;
|
|
|
|
|
2014-07-04 15:54:14 +00:00
|
|
|
bool skip_right = false;
|
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
switch( token )
|
|
|
|
{
|
|
|
|
case T_layerselection:
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
|
|
|
token = NeedSYMBOLorNUMBER();
|
|
|
|
|
|
|
|
const std::string& cur = CurStr();
|
|
|
|
|
|
|
|
if( token == T_NUMBER ) // pretty 3 format had legacy Cu stack.
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
// It's not possible to convert a legacy Cu layer number to a new Cu layer
|
|
|
|
// number without knowing the number or total Cu layers in the legacy board.
|
|
|
|
// We do not have that information here, so simply set all layers ON. User
|
|
|
|
// can turn them off in the UI.
|
|
|
|
aPcbPlotParams->m_layerSelection = LSET( 2, F_SilkS, B_SilkS ) | LSET::AllCuMask();
|
2014-06-24 16:17:18 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
else if( cur.find_first_of( "0x" ) == 0 ) // pretty ver. 4.
|
|
|
|
{
|
|
|
|
// skip the leading 2 0x bytes.
|
|
|
|
aPcbPlotParams->m_layerSelection.ParseHex( cur.c_str() + 2, cur.size() - 2 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Expecting( "integer or hex layerSelection" );
|
|
|
|
}
|
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2022-04-02 13:36:20 +00:00
|
|
|
case T_plot_on_all_layers_selection:
|
|
|
|
{
|
|
|
|
token = NeedSYMBOLorNUMBER();
|
|
|
|
|
|
|
|
const std::string& cur = CurStr();
|
|
|
|
|
|
|
|
if( cur.find_first_of( "0x" ) == 0 )
|
|
|
|
{
|
|
|
|
// skip the leading 2 0x bytes.
|
|
|
|
aPcbPlotParams->m_plotOnAllLayersSelection.ParseHex( cur.c_str() + 2,
|
|
|
|
cur.size() - 2 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Expecting( "hex plot_on_all_layers_selection" );
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-10-10 12:39:54 +00:00
|
|
|
case T_disableapertmacros:
|
|
|
|
aPcbPlotParams->m_gerberDisableApertMacros = parseBool();
|
|
|
|
break;
|
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_usegerberextensions:
|
2015-10-21 06:55:30 +00:00
|
|
|
aPcbPlotParams->m_useGerberProtelExtensions = parseBool();
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2014-06-19 06:26:53 +00:00
|
|
|
case T_usegerberattributes:
|
2018-12-08 16:46:41 +00:00
|
|
|
aPcbPlotParams->m_useGerberX2format = parseBool();
|
2014-06-19 06:26:53 +00:00
|
|
|
break;
|
2014-06-30 05:46:18 +00:00
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
case T_usegerberadvancedattributes:
|
|
|
|
aPcbPlotParams->m_includeGerberNetlistInfo = parseBool();
|
|
|
|
break;
|
|
|
|
|
2017-08-19 16:28:11 +00:00
|
|
|
case T_creategerberjobfile:
|
|
|
|
aPcbPlotParams->m_createGerberJobFile = parseBool();
|
|
|
|
break;
|
|
|
|
|
2014-07-04 14:22:38 +00:00
|
|
|
case T_gerberprecision:
|
2021-07-19 23:56:05 +00:00
|
|
|
aPcbPlotParams->m_gerberPrecision = parseInt( gbrDefaultPrecision - 1,
|
2021-01-03 13:59:23 +00:00
|
|
|
gbrDefaultPrecision);
|
2014-07-04 14:22:38 +00:00
|
|
|
break;
|
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
case T_dashed_line_dash_ratio:
|
|
|
|
aPcbPlotParams->m_dashedLineDashRatio = parseDouble();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_dashed_line_gap_ratio:
|
|
|
|
aPcbPlotParams->m_dashedLineGapRatio = parseDouble();
|
|
|
|
break;
|
|
|
|
|
2020-04-23 08:02:59 +00:00
|
|
|
case T_svgprecision:
|
|
|
|
aPcbPlotParams->m_svgPrecision = parseInt( SVG_PRECISION_MIN, SVG_PRECISION_MAX );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_svguseinch:
|
2022-01-28 17:06:47 +00:00
|
|
|
parseBool(); // Unused. For compatibility
|
2020-04-23 08:02:59 +00:00
|
|
|
break;
|
|
|
|
|
2011-02-17 17:11:20 +00:00
|
|
|
case T_psa4output:
|
2013-05-09 19:08:12 +00:00
|
|
|
aPcbPlotParams->m_A4Output = parseBool();
|
2011-02-17 17:11:20 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_excludeedgelayer:
|
2022-04-02 13:36:20 +00:00
|
|
|
if( !parseBool() )
|
|
|
|
aPcbPlotParams->m_plotOnAllLayersSelection.set( Edge_Cuts );
|
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_plotframeref:
|
2023-04-30 12:43:25 +00:00
|
|
|
aPcbPlotParams->m_plotDrawingSheet = parseBool();
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_viasonmask:
|
2013-05-09 19:08:12 +00:00
|
|
|
aPcbPlotParams->m_plotViaOnMaskLayer = parseBool();
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_mode:
|
2015-02-02 08:06:39 +00:00
|
|
|
aPcbPlotParams->SetPlotMode( parseInt( 0, 2 ) > 1 ? SKETCH : FILLED );
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_useauxorigin:
|
2013-05-09 19:08:12 +00:00
|
|
|
aPcbPlotParams->m_useAuxOrigin = parseBool();
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_hpglpennumber:
|
2021-07-19 23:56:05 +00:00
|
|
|
aPcbPlotParams->m_HPGLPenNum = parseInt( HPGL_PEN_NUMBER_MIN, HPGL_PEN_NUMBER_MAX );
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2017-07-31 12:28:35 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_hpglpenspeed:
|
2021-07-19 23:56:05 +00:00
|
|
|
aPcbPlotParams->m_HPGLPenSpeed = parseInt( HPGL_PEN_SPEED_MIN, HPGL_PEN_SPEED_MAX );
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2017-07-31 12:28:35 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_hpglpendiameter:
|
2018-05-26 07:37:21 +00:00
|
|
|
aPcbPlotParams->m_HPGLPenDiam = parseDouble();
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2017-07-31 12:28:35 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_hpglpenoverlay:
|
2021-07-19 23:56:05 +00:00
|
|
|
// No more used. just here for compatibility with old versions
|
2016-02-11 12:14:46 +00:00
|
|
|
parseInt( 0, HPGL_PEN_DIAMETER_MAX );
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2017-07-31 12:28:35 +00:00
|
|
|
|
2023-04-30 17:09:40 +00:00
|
|
|
case T_pdf_front_fp_property_popups:
|
|
|
|
aPcbPlotParams->m_PDFFrontFPPropertyPopups = parseBool();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_pdf_back_fp_property_popups:
|
|
|
|
aPcbPlotParams->m_PDFFrontFPPropertyPopups = parseBool();
|
|
|
|
break;
|
|
|
|
|
2024-03-13 23:40:18 +00:00
|
|
|
case T_pdf_metadata:
|
|
|
|
aPcbPlotParams->m_PDFMetadata = parseBool();
|
|
|
|
break;
|
|
|
|
|
2021-01-03 13:59:23 +00:00
|
|
|
case T_dxfpolygonmode:
|
2023-04-30 12:43:25 +00:00
|
|
|
aPcbPlotParams->m_DXFPolygonMode = parseBool();
|
2021-01-03 13:59:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case T_dxfimperialunits:
|
2023-04-30 12:43:25 +00:00
|
|
|
aPcbPlotParams->m_DXFUnits = parseBool() ? DXF_UNITS::INCHES
|
2021-01-03 13:59:23 +00:00
|
|
|
: DXF_UNITS::MILLIMETERS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_dxfusepcbnewfont:
|
|
|
|
aPcbPlotParams->m_textMode = parseBool() ? PLOT_TEXT_MODE::DEFAULT
|
|
|
|
: PLOT_TEXT_MODE::NATIVE;
|
|
|
|
break;
|
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_pscolor:
|
2012-08-30 18:06:13 +00:00
|
|
|
NeedSYMBOL(); // This actually was never used...
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_psnegative:
|
2013-05-09 19:08:12 +00:00
|
|
|
aPcbPlotParams->m_negative = parseBool();
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_plotreference:
|
2013-05-09 19:08:12 +00:00
|
|
|
aPcbPlotParams->m_plotReference = parseBool();
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2023-08-15 15:56:46 +00:00
|
|
|
case T_plotfptext:
|
|
|
|
aPcbPlotParams->m_plotFPText = parseBool();
|
|
|
|
break;
|
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_plotvalue:
|
2013-05-09 19:08:12 +00:00
|
|
|
aPcbPlotParams->m_plotValue = parseBool();
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_plotinvisibletext:
|
2013-05-09 19:08:12 +00:00
|
|
|
aPcbPlotParams->m_plotInvisibleText = parseBool();
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2020-05-01 16:24:01 +00:00
|
|
|
case T_sketchpadsonfab:
|
|
|
|
aPcbPlotParams->m_sketchPadsOnFabLayers= parseBool();
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2024-05-27 19:56:16 +00:00
|
|
|
case T_plotpadnumbers:
|
|
|
|
aPcbPlotParams->m_plotPadNumbers = parseBool();
|
|
|
|
break;
|
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_subtractmaskfromsilk:
|
2013-05-09 19:08:12 +00:00
|
|
|
aPcbPlotParams->m_subtractMaskFromSilk = parseBool();
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_outputformat:
|
2019-12-28 00:55:11 +00:00
|
|
|
aPcbPlotParams->m_format = static_cast<PLOT_FORMAT>(
|
|
|
|
parseInt( static_cast<int>( PLOT_FORMAT::FIRST_FORMAT ),
|
|
|
|
static_cast<int>( PLOT_FORMAT::LAST_FORMAT ) ) );
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_mirror:
|
2013-05-09 19:08:12 +00:00
|
|
|
aPcbPlotParams->m_mirror = parseBool();
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_drillshape:
|
2022-11-12 07:48:25 +00:00
|
|
|
aPcbPlotParams->m_drillMarks = static_cast<DRILL_MARKS> ( parseInt( 0, 2 ) );
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_scaleselection:
|
2013-05-09 19:08:12 +00:00
|
|
|
aPcbPlotParams->m_scaleSelection = parseInt( 0, 4 );
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_outputdirectory:
|
2018-06-21 10:30:38 +00:00
|
|
|
NeedSYMBOLorNUMBER(); // a dir name can be like a number
|
2023-09-09 04:10:57 +00:00
|
|
|
aPcbPlotParams->m_outputDirectory = From_UTF8( CurText() );
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
default:
|
2014-07-04 15:54:14 +00:00
|
|
|
skipCurrent(); // skip unknown or outdated plot parameter
|
|
|
|
skip_right = true; // the closing right token is already read.
|
2011-01-28 22:54:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-07-04 15:54:14 +00:00
|
|
|
|
|
|
|
if( ! skip_right )
|
|
|
|
NeedRIGHT();
|
2011-01-28 22:54:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-09 19:08:12 +00:00
|
|
|
bool PCB_PLOT_PARAMS_PARSER::parseBool()
|
2011-01-28 22:54:16 +00:00
|
|
|
{
|
2012-01-09 08:35:06 +00:00
|
|
|
T token = NeedSYMBOL();
|
|
|
|
|
2023-09-24 16:53:34 +00:00
|
|
|
switch( token )
|
|
|
|
{
|
|
|
|
case T_false:
|
|
|
|
case T_no:
|
|
|
|
return false;
|
2012-01-09 08:35:06 +00:00
|
|
|
|
2023-09-24 16:53:34 +00:00
|
|
|
case T_true:
|
|
|
|
case T_yes:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
Expecting( "true, false, yes, or no" );
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-28 22:54:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-09 19:08:12 +00:00
|
|
|
int PCB_PLOT_PARAMS_PARSER::parseInt( int aMin, int aMax )
|
2011-01-28 22:54:16 +00:00
|
|
|
{
|
2012-01-09 08:35:06 +00:00
|
|
|
T token = NextTok();
|
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
if( token != T_NUMBER )
|
|
|
|
Expecting( T_NUMBER );
|
|
|
|
|
2012-01-09 08:35:06 +00:00
|
|
|
int val = atoi( CurText() );
|
|
|
|
|
|
|
|
if( val < aMin )
|
|
|
|
val = aMin;
|
|
|
|
else if( val > aMax )
|
|
|
|
val = aMax;
|
2011-01-28 22:54:16 +00:00
|
|
|
|
2012-01-09 08:35:06 +00:00
|
|
|
return val;
|
2011-01-28 22:54:16 +00:00
|
|
|
}
|
2013-05-09 19:08:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
double PCB_PLOT_PARAMS_PARSER::parseDouble()
|
|
|
|
{
|
|
|
|
T token = NextTok();
|
|
|
|
|
|
|
|
if( token != T_NUMBER )
|
|
|
|
Expecting( T_NUMBER );
|
|
|
|
|
2022-08-14 22:40:54 +00:00
|
|
|
return DSNLEXER::parseDouble();
|
2013-05-09 19:08:12 +00:00
|
|
|
}
|
2014-07-04 14:22:38 +00:00
|
|
|
|
2017-07-31 12:28:35 +00:00
|
|
|
|
2017-06-08 21:47:21 +00:00
|
|
|
void PCB_PLOT_PARAMS_PARSER::skipCurrent()
|
2014-07-04 14:22:38 +00:00
|
|
|
{
|
|
|
|
int curr_level = 0;
|
|
|
|
T token;
|
|
|
|
|
|
|
|
while( ( token = NextTok() ) != T_EOF )
|
|
|
|
{
|
|
|
|
if( token == T_LEFT )
|
|
|
|
curr_level--;
|
|
|
|
|
|
|
|
if( token == T_RIGHT )
|
|
|
|
{
|
|
|
|
curr_level++;
|
|
|
|
|
|
|
|
if( curr_level > 0 )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|