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
|
|
|
*
|
2018-01-28 18:12:26 +00:00
|
|
|
* Copyright (C) 1992-2018 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>
|
|
|
|
#include <convert_to_biu.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <layers_id_colors_and_visibility.h>
|
|
|
|
#include <macros.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>
|
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <plotter.h>
|
|
|
|
#include <settings/color_settings.h>
|
|
|
|
#include <settings/settings_manager.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_MIN ( 0.02 * IU_PER_MM ) // min value for default line thickness
|
|
|
|
#define PLOT_LINEWIDTH_MAX ( 2 * IU_PER_MM ) // max value for default line thickness
|
|
|
|
#define PLOT_LINEWIDTH_DEFAULT ( DEFAULT_TEXT_WIDTH * IU_PER_MM )
|
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
|
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
/**
|
2013-05-07 18:32:06 +00:00
|
|
|
* Default line thickness in internal units used to draw or plot items using a
|
|
|
|
* default thickness line value (Frame references)
|
2012-04-05 18:27:56 +00:00
|
|
|
*/
|
2013-05-09 19:08:12 +00:00
|
|
|
int g_DrawDefaultLineThickness = PLOT_LINEWIDTH_DEFAULT;
|
2012-04-05 18:27:56 +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;
|
|
|
|
return (temp == aValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
2011-02-03 22:26:30 +00:00
|
|
|
return (temp == aValue);
|
|
|
|
}
|
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
// PCB_PLOT_PARAMS
|
|
|
|
|
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-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;
|
|
|
|
m_excludeEdgeLayer = true;
|
|
|
|
m_lineWidth = g_DrawDefaultLineThickness;
|
|
|
|
m_plotFrameRef = false;
|
|
|
|
m_plotViaOnMaskLayer = false;
|
|
|
|
m_plotMode = FILLED;
|
2017-07-30 18:27:03 +00:00
|
|
|
m_DXFplotPolygonMode = true;
|
2019-12-20 14:11:39 +00:00
|
|
|
m_DXFplotUnits = DXF_PLOTTER::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;
|
|
|
|
m_plotInvisibleText = false;
|
|
|
|
m_plotPadsOnSilkLayer = false;
|
|
|
|
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;
|
|
|
|
m_drillMarks = SMALL_DRILL_SHAPE;
|
|
|
|
m_autoScale = false;
|
|
|
|
m_scale = 1.0;
|
|
|
|
m_scaleSelection = 1;
|
|
|
|
m_fineScaleAdjustX = 1.0;
|
|
|
|
m_fineScaleAdjustY = 1.0;
|
|
|
|
m_widthAdjust = 0.;
|
|
|
|
m_color = BLACK;
|
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();
|
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
|
|
|
|
2020-03-30 01:43:18 +00:00
|
|
|
if( PgmOrNull() )
|
|
|
|
{
|
|
|
|
m_default_colors = nullptr;
|
|
|
|
m_colors = Pgm().GetSettingsManager().GetColorSettings();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_default_colors = std::make_shared<COLOR_SETTINGS>();
|
|
|
|
m_colors = m_default_colors.get();
|
|
|
|
}
|
2011-01-28 22:54:16 +00:00
|
|
|
}
|
|
|
|
|
2014-07-04 14:22:38 +00:00
|
|
|
void PCB_PLOT_PARAMS::SetGerberPrecision( int aPrecision )
|
|
|
|
{
|
|
|
|
// Currently geber files use mm.
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
// PLEASE NOTE: only plot dialog options are processed
|
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
|
|
|
{
|
2011-02-03 22:26:30 +00:00
|
|
|
const char* falseStr = getTokenName( T_false );
|
|
|
|
const char* trueStr = getTokenName( T_true );
|
2011-01-28 22:54:16 +00:00
|
|
|
|
2012-06-11 00:47:15 +00:00
|
|
|
aFormatter->Print( aNestLevel, "(%s\n", getTokenName( T_pcbplotparams ) );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
aFormatter->Print( aNestLevel+1, "(%s 0x%s)\n", getTokenName( T_layerselection ),
|
|
|
|
m_layerSelection.FmtHex().c_str() );
|
|
|
|
|
2011-02-03 22:26:30 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_usegerberextensions ),
|
2015-10-21 06:55:30 +00:00
|
|
|
m_useGerberProtelExtensions ? trueStr : falseStr );
|
2014-06-19 07:12:48 +00:00
|
|
|
|
2017-11-22 19:27:33 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_usegerberattributes ),
|
2018-12-08 16:46:41 +00:00
|
|
|
GetUseGerberX2format() ? trueStr : falseStr );
|
2014-06-19 07:12:48 +00:00
|
|
|
|
2017-11-22 19:27:33 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_usegerberadvancedattributes ),
|
|
|
|
GetIncludeGerberNetlistInfo() ? trueStr : falseStr );
|
2017-08-19 16:28:11 +00:00
|
|
|
|
2017-11-22 19:27:33 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_creategerberjobfile ),
|
|
|
|
GetCreateGerberJobFile() ? trueStr : falseStr );
|
2016-09-19 11:01:36 +00:00
|
|
|
|
2014-07-04 14:22:38 +00:00
|
|
|
if( m_gerberPrecision != gbrDefaultPrecision ) // save this option only if it is not the default value,
|
|
|
|
// to avoid incompatibility with older Pcbnew version
|
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %d)\n",
|
|
|
|
getTokenName( T_gerberprecision ), m_gerberPrecision );
|
|
|
|
|
2011-02-03 22:26:30 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_excludeedgelayer ),
|
2012-08-30 18:06:13 +00:00
|
|
|
m_excludeEdgeLayer ? trueStr : falseStr );
|
2013-05-09 19:08:12 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %f)\n", getTokenName( T_linewidth ),
|
|
|
|
m_lineWidth / IU_PER_MM );
|
2011-02-03 22:26:30 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_plotframeref ),
|
2012-08-30 18:06:13 +00:00
|
|
|
m_plotFrameRef ? trueStr : falseStr );
|
2011-02-03 22:26:30 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_viasonmask ),
|
2012-08-30 18:06:13 +00:00
|
|
|
m_plotViaOnMaskLayer ? trueStr : falseStr );
|
2011-02-03 22:26:30 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_mode ),
|
2015-02-02 08:06:39 +00:00
|
|
|
GetPlotMode() == SKETCH ? 2 : 1 ); // Value 0 (LINE mode) no more used
|
2011-02-03 22:26:30 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_useauxorigin ),
|
2012-08-30 18:06:13 +00:00
|
|
|
m_useAuxOrigin ? trueStr : falseStr );
|
2011-02-03 22:26:30 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_hpglpennumber ),
|
2011-01-28 22:54:16 +00:00
|
|
|
m_HPGLPenNum );
|
2014-06-30 15:03:20 +00:00
|
|
|
|
|
|
|
// Obsolete parameter, pen speed is no more managed, because hpgl format
|
|
|
|
// is now an export format, and for this, pen speed has no meaning
|
|
|
|
// aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_hpglpenspeed ),
|
|
|
|
// m_HPGLPenSpeed );
|
|
|
|
|
2011-02-03 22:26:30 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_hpglpenspeed ),
|
2011-01-28 22:54:16 +00:00
|
|
|
m_HPGLPenSpeed );
|
2018-05-26 07:37:21 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %f)\n", getTokenName( T_hpglpendiameter ),
|
2011-01-28 22:54:16 +00:00
|
|
|
m_HPGLPenDiam );
|
2011-02-03 22:26:30 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_psnegative ),
|
2012-08-30 18:06:13 +00:00
|
|
|
m_negative ? trueStr : falseStr );
|
2011-02-17 17:11:20 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_psa4output ),
|
2012-08-30 18:06:13 +00:00
|
|
|
m_A4Output ? trueStr : falseStr );
|
2011-02-03 22:26:30 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_plotreference ),
|
2012-08-30 18:06:13 +00:00
|
|
|
m_plotReference ? trueStr : falseStr );
|
2011-02-03 22:26:30 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_plotvalue ),
|
2012-08-30 18:06:13 +00:00
|
|
|
m_plotValue ? trueStr : falseStr );
|
2011-02-03 22:26:30 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_plotinvisibletext ),
|
2012-08-30 18:06:13 +00:00
|
|
|
m_plotInvisibleText ? trueStr : falseStr );
|
2011-02-03 22:26:30 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_padsonsilk ),
|
2012-08-30 18:06:13 +00:00
|
|
|
m_plotPadsOnSilkLayer ? trueStr : falseStr );
|
2011-02-03 22:26:30 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_subtractmaskfromsilk ),
|
2012-08-30 18:06:13 +00:00
|
|
|
m_subtractMaskFromSilk ? trueStr : falseStr );
|
2011-02-03 22:26:30 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_outputformat ),
|
2019-12-28 07:43:29 +00:00
|
|
|
static_cast<int>( m_format ) );
|
2011-02-03 22:26:30 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_mirror ),
|
2012-08-30 18:06:13 +00:00
|
|
|
m_mirror ? trueStr : falseStr );
|
2011-02-03 22:26:30 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_drillshape ),
|
2012-08-30 18:06:13 +00:00
|
|
|
m_drillMarks );
|
2011-02-03 22:26:30 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s %d)\n", getTokenName( T_scaleselection ),
|
2012-08-30 18:06:13 +00:00
|
|
|
m_scaleSelection );
|
2018-06-21 10:30:38 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(%s \"%s\")", getTokenName( T_outputdirectory ),
|
|
|
|
(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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-31 12:28:35 +00:00
|
|
|
bool PCB_PLOT_PARAMS::IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams, bool aCompareOnlySavedPrms ) 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;
|
2015-10-21 06:55:30 +00:00
|
|
|
if( m_useGerberProtelExtensions != aPcbPlotParams.m_useGerberProtelExtensions )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2018-12-08 16:46:41 +00:00
|
|
|
if( m_useGerberX2format != aPcbPlotParams.m_useGerberX2format )
|
2014-06-19 06:26:53 +00:00
|
|
|
return false;
|
2018-12-08 16:46:41 +00:00
|
|
|
if( m_includeGerberNetlistInfo != aPcbPlotParams.m_includeGerberNetlistInfo )
|
2016-09-19 11:01:36 +00:00
|
|
|
return false;
|
2017-08-19 16:28:11 +00:00
|
|
|
if( m_createGerberJobFile != aPcbPlotParams.m_createGerberJobFile )
|
|
|
|
return false;
|
2014-07-04 14:22:38 +00:00
|
|
|
if( m_gerberPrecision != aPcbPlotParams.m_gerberPrecision )
|
|
|
|
return false;
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_excludeEdgeLayer != aPcbPlotParams.m_excludeEdgeLayer )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_lineWidth != aPcbPlotParams.m_lineWidth )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_plotFrameRef != aPcbPlotParams.m_plotFrameRef )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_plotViaOnMaskLayer != aPcbPlotParams.m_plotViaOnMaskLayer )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2015-02-02 08:06:39 +00:00
|
|
|
if( m_plotMode != aPcbPlotParams.m_plotMode )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2017-07-31 12:28:35 +00:00
|
|
|
if( !aCompareOnlySavedPrms )
|
|
|
|
{
|
|
|
|
if( m_DXFplotPolygonMode != aPcbPlotParams.m_DXFplotPolygonMode )
|
2019-06-13 00:28:22 +00:00
|
|
|
return false;
|
|
|
|
if( m_DXFplotUnits != aPcbPlotParams.m_DXFplotUnits )
|
|
|
|
return false;
|
2017-07-31 12:28:35 +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;
|
|
|
|
if( m_HPGLPenNum != aPcbPlotParams.m_HPGLPenNum )
|
|
|
|
return false;
|
|
|
|
if( m_HPGLPenSpeed != aPcbPlotParams.m_HPGLPenSpeed )
|
|
|
|
return false;
|
|
|
|
if( m_HPGLPenDiam != aPcbPlotParams.m_HPGLPenDiam )
|
|
|
|
return false;
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_negative != aPcbPlotParams.m_negative )
|
|
|
|
return false;
|
|
|
|
if( m_A4Output != aPcbPlotParams.m_A4Output )
|
|
|
|
return false;
|
|
|
|
if( m_plotReference != aPcbPlotParams.m_plotReference )
|
|
|
|
return false;
|
|
|
|
if( m_plotValue != aPcbPlotParams.m_plotValue )
|
|
|
|
return false;
|
|
|
|
if( m_plotInvisibleText != aPcbPlotParams.m_plotInvisibleText )
|
|
|
|
return false;
|
|
|
|
if( m_plotPadsOnSilkLayer != aPcbPlotParams.m_plotPadsOnSilkLayer )
|
|
|
|
return false;
|
|
|
|
if( m_subtractMaskFromSilk != aPcbPlotParams.m_subtractMaskFromSilk )
|
|
|
|
return false;
|
|
|
|
if( m_format != aPcbPlotParams.m_format )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_mirror != aPcbPlotParams.m_mirror )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_drillMarks != aPcbPlotParams.m_drillMarks )
|
2011-02-17 17:11:20 +00:00
|
|
|
return false;
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_scaleSelection != aPcbPlotParams.m_scaleSelection )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_autoScale != aPcbPlotParams.m_autoScale )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_scale != aPcbPlotParams.m_scale )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_fineScaleAdjustX != aPcbPlotParams.m_fineScaleAdjustX )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_fineScaleAdjustY != aPcbPlotParams.m_fineScaleAdjustY )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_widthAdjust != aPcbPlotParams.m_widthAdjust )
|
2011-01-28 22:54:16 +00:00
|
|
|
return false;
|
2017-07-31 12:28:35 +00:00
|
|
|
if( !aCompareOnlySavedPrms )
|
|
|
|
{
|
|
|
|
if( m_color != aPcbPlotParams.m_color )
|
|
|
|
return false;
|
|
|
|
}
|
2012-08-30 18:06:13 +00:00
|
|
|
if( m_textMode != aPcbPlotParams.m_textMode )
|
2011-01-28 22:54:16 +00:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
bool PCB_PLOT_PARAMS::SetLineWidth( int aValue )
|
2011-02-03 22:26:30 +00:00
|
|
|
{
|
2012-08-30 18:06:13 +00:00
|
|
|
return setInt( &m_lineWidth, aValue, PLOT_LINEWIDTH_MIN, PLOT_LINEWIDTH_MAX );
|
2011-02-03 22:26:30 +00:00
|
|
|
}
|
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
// PCB_PLOT_PARAMS_PARSER
|
|
|
|
|
|
|
|
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:
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
|
|
|
token = NeedSYMBOLorNUMBER();
|
|
|
|
|
|
|
|
const std::string& cur = CurStr();
|
|
|
|
|
|
|
|
if( token == T_NUMBER ) // pretty 3 format had legacy Cu stack.
|
|
|
|
{
|
|
|
|
// unsigned legacy_mask = atol( cur.c_str() );
|
|
|
|
|
|
|
|
/* 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.
|
|
|
|
This is one of the superiorities of the new Cu sequence.
|
|
|
|
aPcbPlotParams->m_layerSelection = LEGACY_PLUGIN::leg_mask2new( cu_count, legacy_mask );
|
|
|
|
*/
|
|
|
|
|
|
|
|
// sorry, use the UI once to fix:
|
2015-12-08 15:15:24 +00:00
|
|
|
aPcbPlotParams->m_layerSelection = LSET( 2, F_SilkS, B_SilkS) | LSET::AllCuMask();
|
2014-06-24 16:17:18 +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;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
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:
|
|
|
|
aPcbPlotParams->m_gerberPrecision =
|
|
|
|
parseInt( gbrDefaultPrecision-1, gbrDefaultPrecision);
|
|
|
|
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:
|
2013-05-09 19:08:12 +00:00
|
|
|
aPcbPlotParams->m_excludeEdgeLayer = 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_linewidth:
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
|
|
|
// Due to a bug, this (minor) parameter was saved in biu
|
|
|
|
// and now is saved in mm
|
|
|
|
// If the read value is outside bounds, force a default value
|
|
|
|
double tmp = parseDouble();
|
|
|
|
if( !aPcbPlotParams->SetLineWidth( KiROUND( tmp * IU_PER_MM ) ) )
|
|
|
|
aPcbPlotParams->SetLineWidth( PLOT_LINEWIDTH_DEFAULT );
|
|
|
|
}
|
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:
|
2013-05-09 19:08:12 +00:00
|
|
|
aPcbPlotParams->m_plotFrameRef = 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:
|
2013-05-09 19:08:12 +00:00
|
|
|
aPcbPlotParams->m_HPGLPenNum = parseInt( HPGL_PEN_NUMBER_MIN,
|
2011-02-03 22:26:30 +00:00
|
|
|
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:
|
2013-05-09 19:08:12 +00:00
|
|
|
aPcbPlotParams->m_HPGLPenSpeed = parseInt( HPGL_PEN_SPEED_MIN,
|
2011-02-03 22:26:30 +00:00
|
|
|
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:
|
2016-02-11 12:14:46 +00:00
|
|
|
// No more used. juste here for compatibility with old versions
|
|
|
|
parseInt( 0, HPGL_PEN_DIAMETER_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_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
|
|
|
|
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
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
case T_padsonsilk:
|
2013-05-09 19:08:12 +00:00
|
|
|
aPcbPlotParams->m_plotPadsOnSilkLayer= 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_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:
|
2012-09-15 12:13:03 +00:00
|
|
|
aPcbPlotParams->m_drillMarks = static_cast<PCB_PLOT_PARAMS::DrillMarksType>
|
2013-05-09 19:08:12 +00:00
|
|
|
( 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
|
2012-08-30 18:06:13 +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();
|
|
|
|
|
2011-01-28 22:54:16 +00:00
|
|
|
if( token != T_false && token != T_true )
|
|
|
|
Expecting( "true|false" );
|
2012-01-09 08:35:06 +00:00
|
|
|
|
|
|
|
return token == T_true;
|
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 );
|
|
|
|
|
|
|
|
double val = strtod( CurText(), NULL );
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|