KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_plot_params.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
25#include <charconv>
26#include <layer_ids.h>
27#include <lset.h>
28#include <string_utils.h>
29#include <pcb_plot_params.h>
31#include <plotters/plotter.h>
34#include <lseq.h>
35
36
37#define PLOT_LINEWIDTH_DEFAULT ( DEFAULT_TEXT_WIDTH * IU_PER_MM )
38
39#define HPGL_PEN_DIAMETER_MIN 0
40#define HPGL_PEN_DIAMETER_MAX 100.0 // Unit = mil
41#define HPGL_PEN_SPEED_MIN 1 // this param is always in cm/s
42#define HPGL_PEN_SPEED_MAX 99 // this param is always in cm/s
43#define HPGL_PEN_NUMBER_MIN 1
44#define HPGL_PEN_NUMBER_MAX 16
45
46#define SVG_PRECISION_MIN 3U
47#define SVG_PRECISION_MAX 6U
48#define SVG_PRECISION_DEFAULT 4
49
50
51// default trailing digits in Gerber coordinates, when units are mm
52// This is also the max usable precision (i.e. internal Pcbnew Units)
53static const int gbrDefaultPrecision = 6;
54
55
56using namespace PCBPLOTPARAMS_T;
57
58
59static const char* getTokenName( T aTok )
60{
61 return PCB_PLOT_PARAMS_LEXER::TokenName( aTok );
62}
63
64
65static bool setInt( int* aTarget, int aValue, int aMin, int aMax )
66{
67 int temp = aValue;
68
69 if( aValue < aMin )
70 temp = aMin;
71 else if( aValue > aMax )
72 temp = aMax;
73
74 *aTarget = temp;
75 return ( temp == aValue );
76}
77
78
79static bool setDouble( double* aTarget, double aValue, double aMin, double aMax )
80{
81 double temp = aValue;
82
83 if( aValue < aMin )
84 temp = aMin;
85 else if( aValue > aMax )
86 temp = aMax;
87
88 *aTarget = temp;
89 return ( temp == aValue );
90}
91
92
94{
101 m_dashedLineDashRatio = 12.0; // From ISO 128-2
102 m_dashedLineGapRatio = 3.0; // From ISO 128-2
103
104 // we used 0.1mils for SVG step before, but nm precision is more accurate, so we use nm
106 m_svgFitPageToBoard = false;
107 m_plotDrawingSheet = false;
109 m_DXFPolygonMode = true;
110 m_DXFUnits = DXF_UNITS::INCH;
111 m_useAuxOrigin = false;
112 m_HPGLPenNum = 1;
113 m_HPGLPenSpeed = 20; // this param is always in cm/s
114 m_HPGLPenDiam = 15; // in mils
115 m_negative = false;
116 m_A4Output = false;
117 m_plotReference = true;
118 m_plotValue = true;
119 m_plotFPText = true;
124 m_plotPadNumbers = false;
126 m_format = PLOT_FORMAT::GERBER;
127 m_mirror = false;
128 m_drillMarks = DRILL_MARKS::SMALL_DRILL_SHAPE;
129 m_autoScale = false;
130 m_scale = 1.0;
132 m_fineScaleAdjustX = 1.0;
133 m_fineScaleAdjustY = 1.0;
134 m_widthAdjust = 0.;
135 m_textMode = PLOT_TEXT_MODE::DEFAULT;
136 m_outputDirectory.clear();
139 | LSET::AllCuMask();
140
143 m_PDFMetadata = true;
144 m_PDFSingle = false;
145
146 // This parameter controls if the NPTH pads will be plotted or not
147 // it is a "local" parameter
148 m_skipNPTH_Pads = false;
149
150 // line width to plot items in outline mode.
152
153 m_default_colors = std::make_shared<COLOR_SETTINGS>();
155
156 m_blackAndWhite = true;
157}
158
159
161{
162 // Currently Gerber files use mm.
163 // accepted precision is only 6 (max value, this is the resolution of Pcbnew)
164 // or 5, min value for professional boards, when 6 creates problems
165 // to board makers.
166
169}
170
171
172void PCB_PLOT_PARAMS::SetSvgPrecision( unsigned aPrecision )
173{
174 m_svgPrecision = std::clamp( aPrecision, SVG_PRECISION_MIN, SVG_PRECISION_MAX );
175}
176
177
179{
180 aFormatter->Print( "(pcbplotparams" );
181
182 aFormatter->Print( "(layerselection 0x%s)", m_layerSelection.FmtHex().c_str() );
183
184 LSET commonLayers;
185
186 for( PCB_LAYER_ID commonLayer : m_plotOnAllLayersSequence )
187 commonLayers.set( commonLayer );
188
189 aFormatter->Print( "(plot_on_all_layers_selection 0x%s)", commonLayers.FmtHex().c_str() );
190
191 KICAD_FORMAT::FormatBool( aFormatter, "disableapertmacros", m_gerberDisableApertMacros );
192 KICAD_FORMAT::FormatBool( aFormatter, "usegerberextensions", m_useGerberProtelExtensions );
193 KICAD_FORMAT::FormatBool( aFormatter, "usegerberattributes", GetUseGerberX2format() );
194 KICAD_FORMAT::FormatBool( aFormatter, "usegerberadvancedattributes", GetIncludeGerberNetlistInfo() );
195 KICAD_FORMAT::FormatBool( aFormatter, "creategerberjobfile", GetCreateGerberJobFile() );
196
197 // save this option only if it is not the default value,
198 // to avoid incompatibility with older Pcbnew version
200 aFormatter->Print( "(gerberprecision %d)", m_gerberPrecision );
201
202 aFormatter->Print( "(dashed_line_dash_ratio %f)", GetDashedLineDashRatio() );
203 aFormatter->Print( "(dashed_line_gap_ratio %f)", GetDashedLineGapRatio() );
204
205 // SVG options
206 aFormatter->Print( "(svgprecision %d)", m_svgPrecision );
207
208 KICAD_FORMAT::FormatBool( aFormatter, "plotframeref", m_plotDrawingSheet );
209 aFormatter->Print( "(mode %d)", GetPlotMode() == SKETCH ? 2 : 1 );
210 KICAD_FORMAT::FormatBool( aFormatter, "useauxorigin", m_useAuxOrigin );
211
212 // HPGL options
213 aFormatter->Print( "(hpglpennumber %d)", m_HPGLPenNum );
214 aFormatter->Print( "(hpglpenspeed %d)", m_HPGLPenSpeed );
215 aFormatter->Print( "(hpglpendiameter %f)", m_HPGLPenDiam );
216
217 // PDF options
218 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_pdf_front_fp_property_popups ),
220 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_pdf_back_fp_property_popups ),
222 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_pdf_metadata ), m_PDFMetadata );
223 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_pdf_single_document ), m_PDFSingle );
224
225 // DXF options
226 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_dxfpolygonmode ), m_DXFPolygonMode );
227 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_dxfimperialunits ),
228 m_DXFUnits == DXF_UNITS::INCH );
229 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_dxfusepcbnewfont ),
230 m_textMode != PLOT_TEXT_MODE::NATIVE );
231
232 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_psnegative ), m_negative );
233 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_psa4output ), m_A4Output );
234
235 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_plot_black_and_white ), m_blackAndWhite );
236
237 KICAD_FORMAT::FormatBool( aFormatter, "sketchpadsonfab", m_sketchPadsOnFabLayers );
238 KICAD_FORMAT::FormatBool( aFormatter, "plotpadnumbers", m_plotPadNumbers );
239 KICAD_FORMAT::FormatBool( aFormatter, "hidednponfab", m_hideDNPFPsOnFabLayers );
240 KICAD_FORMAT::FormatBool( aFormatter, "sketchdnponfab", m_sketchDNPFPsOnFabLayers );
241 KICAD_FORMAT::FormatBool( aFormatter, "crossoutdnponfab", m_crossoutDNPFPsOnFabLayers );
242 KICAD_FORMAT::FormatBool( aFormatter, "subtractmaskfromsilk", m_subtractMaskFromSilk );
243 aFormatter->Print( "(outputformat %d)", static_cast<int>( m_format ) );
244 KICAD_FORMAT::FormatBool( aFormatter, "mirror", m_mirror );
245 aFormatter->Print( "(drillshape %d)", (int)m_drillMarks );
246 aFormatter->Print( "(scaleselection %d)", m_scaleSelection );
247 aFormatter->Print( "(outputdirectory %s)", aFormatter->Quotew( m_outputDirectory ).c_str() );
248 aFormatter->Print( ")" );
249}
250
251
253{
254 aParser->Parse( this );
255}
256
257
258bool PCB_PLOT_PARAMS::IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams ) const
259{
260 if( m_layerSelection != aPcbPlotParams.m_layerSelection )
261 return false;
262
264 return false;
265
267 return false;
268
270 return false;
271
272 if( m_useGerberX2format != aPcbPlotParams.m_useGerberX2format )
273 return false;
274
276 return false;
277
278 if( m_createGerberJobFile != aPcbPlotParams.m_createGerberJobFile )
279 return false;
280
281 if( m_gerberPrecision != aPcbPlotParams.m_gerberPrecision )
282 return false;
283
284 if( m_dashedLineDashRatio != aPcbPlotParams.m_dashedLineDashRatio )
285 return false;
286
287 if( m_dashedLineGapRatio != aPcbPlotParams.m_dashedLineGapRatio )
288 return false;
289
290 if( m_plotDrawingSheet != aPcbPlotParams.m_plotDrawingSheet )
291 return false;
292
293 if( m_plotMode != aPcbPlotParams.m_plotMode )
294 return false;
295
296 if( m_DXFPolygonMode != aPcbPlotParams.m_DXFPolygonMode )
297 return false;
298
299 if( m_DXFUnits != aPcbPlotParams.m_DXFUnits )
300 return false;
301
302 if( m_svgPrecision != aPcbPlotParams.m_svgPrecision )
303 return false;
304
305 if( m_useAuxOrigin != aPcbPlotParams.m_useAuxOrigin )
306 return false;
307
308 if( m_HPGLPenNum != aPcbPlotParams.m_HPGLPenNum )
309 return false;
310
311 if( m_HPGLPenSpeed != aPcbPlotParams.m_HPGLPenSpeed )
312 return false;
313
314 if( m_HPGLPenDiam != aPcbPlotParams.m_HPGLPenDiam )
315 return false;
316
317 if( m_negative != aPcbPlotParams.m_negative )
318 return false;
319
321 return false;
322
324 return false;
325
326 if( m_PDFMetadata != aPcbPlotParams.m_PDFMetadata )
327 return false;
328
329 if( m_A4Output != aPcbPlotParams.m_A4Output )
330 return false;
331
332 if( m_plotReference != aPcbPlotParams.m_plotReference )
333 return false;
334
335 if( m_plotValue != aPcbPlotParams.m_plotValue )
336 return false;
337
338 if( m_plotFPText != aPcbPlotParams.m_plotFPText )
339 return false;
340
342 return false;
343
344 if( m_plotPadNumbers != aPcbPlotParams.m_plotPadNumbers )
345 return false;
346
348 return false;
349
351 return false;
352
354 return false;
355
356 if( m_subtractMaskFromSilk != aPcbPlotParams.m_subtractMaskFromSilk )
357 return false;
358
359 if( m_format != aPcbPlotParams.m_format )
360 return false;
361
362 if( m_mirror != aPcbPlotParams.m_mirror )
363 return false;
364
365 if( m_drillMarks != aPcbPlotParams.m_drillMarks )
366 return false;
367
368 if( m_scaleSelection != aPcbPlotParams.m_scaleSelection )
369 return false;
370
371 if( m_autoScale != aPcbPlotParams.m_autoScale )
372 return false;
373
374 if( m_scale != aPcbPlotParams.m_scale )
375 return false;
376
377 if( m_fineScaleAdjustX != aPcbPlotParams.m_fineScaleAdjustX )
378 return false;
379
380 if( m_fineScaleAdjustY != aPcbPlotParams.m_fineScaleAdjustY )
381 return false;
382
383 if( m_widthAdjust != aPcbPlotParams.m_widthAdjust )
384 return false;
385
386 if( m_textMode != aPcbPlotParams.m_textMode )
387 return false;
388
389 if( m_blackAndWhite != aPcbPlotParams.m_blackAndWhite )
390 return false;
391
392 if( !m_outputDirectory.IsSameAs( aPcbPlotParams.m_outputDirectory ) )
393 return false;
394
395 return true;
396}
397
398
400{
402}
403
404
406{
408}
409
410
412 PCB_PLOT_PARAMS_LEXER( aReader ),
413 m_boardFileVersion( aBoardFileVersion )
414{
415}
416
417
418PCB_PLOT_PARAMS_PARSER::PCB_PLOT_PARAMS_PARSER( char* aLine, const wxString& aSource ) :
419 PCB_PLOT_PARAMS_LEXER( aLine, aSource ),
420 m_boardFileVersion( 0 )
421{
422}
423
424
430{
433
466
469
472
475
478
485
488
491
492 // User definable layers.
502
504
505 // Four reserved layers (60 - 63) for future expansion within the 64 bit integer limit.
506
509
510/*
511 * Mapping to translate a legacy layer ID into the new PCB layer IDs.
512 */
513static const std::map<LEGACY_PCB_LAYER_ID, PCB_LAYER_ID> s_legacyLayerIdMap{
514 {LEGACY_F_Cu, F_Cu},
515 {LEGACY_B_Cu, B_Cu},
574};
575
576
577LSET remapLegacyLayerLSET( const BASE_SET& aLegacyLSET )
578{
579 LSET newLayers;
580
581 for( const auto& [legacyLayer, newLayer] : s_legacyLayerIdMap )
582 newLayers[newLayer] = aLegacyLSET[legacyLayer];
583
584 return newLayers;
585}
586
587
589{
590 T token;
591
592 while( ( token = NextTok() ) != T_RIGHT )
593 {
594 if( token == T_EOF)
595 Unexpected( T_EOF );
596
597 if( token == T_LEFT )
598 token = NextTok();
599
600 if( token == T_pcbplotparams )
601 continue;
602
603 bool skip_right = false;
604
605 switch( token )
606 {
607 case T_layerselection:
608 {
609 token = NeedSYMBOLorNUMBER();
610
611 const std::string& cur = CurStr();
612
613 if( token == T_NUMBER ) // pretty 3 format had legacy Cu stack.
614 {
615 // It's not possible to convert a legacy Cu layer number to a new Cu layer
616 // number without knowing the number or total Cu layers in the legacy board.
617 // We do not have that information here, so simply set all layers ON. User
618 // can turn them off in the UI.
619 aPcbPlotParams->m_layerSelection = LSET( { F_SilkS, B_SilkS } ) | LSET::AllCuMask();
620 }
621 else if( cur.find_first_of( "0x" ) == 0 ) // pretty ver. 4.
622 {
623 // The layers were renumbered in 5e0abadb23425765e164f49ee2f893e94ddb97fc, but there wasn't
624 // a board file version change with it, so this value is the one immediately after that happened.
625 if( m_boardFileVersion < 20240819 )
626 {
628
629 // skip the leading 2 0x bytes.
630 legacyLSET.ParseHex( cur.c_str() + 2, cur.size() - 2 );
631 aPcbPlotParams->SetLayerSelection( remapLegacyLayerLSET( legacyLSET ) );
632 }
633 else
634 {
635 // skip the leading 2 0x bytes.
636 aPcbPlotParams->m_layerSelection.ParseHex( cur.c_str() + 2, cur.size() - 2 );
637 }
638 }
639 else
640 {
641 Expecting( "integer or hex layerSelection" );
642 }
643
644 break;
645 }
646
647 case T_plot_on_all_layers_selection:
648 {
649 token = NeedSYMBOLorNUMBER();
650
651 const std::string& cur = CurStr();
652
653 if( cur.find_first_of( "0x" ) == 0 )
654 {
655 LSET layers;
656
657 // The layers were renumbered in 5e0abadb23425765e164f49ee2f893e94ddb97fc, but
658 // there wasn't a board file version change with it, so this value is the one
659 // immediately after that happened.
660 if( m_boardFileVersion < 20240819 )
661 {
663
664 // skip the leading 2 0x bytes.
665 legacyLSET.ParseHex( cur.c_str() + 2, cur.size() - 2 );
666
667 layers = remapLegacyLayerLSET( legacyLSET );
668 }
669 else
670 {
671 // skip the leading 2 0x bytes.
672 layers.ParseHex( cur.c_str() + 2, cur.size() - 2 );
673 }
674
675 aPcbPlotParams->SetPlotOnAllLayersSequence( layers.SeqStackupForPlotting() );
676 }
677 else
678 {
679 Expecting( "hex plot_on_all_layers_selection" );
680 }
681
682 break;
683 }
684
685 case T_disableapertmacros:
686 aPcbPlotParams->m_gerberDisableApertMacros = parseBool();
687 break;
688
689 case T_usegerberextensions:
690 aPcbPlotParams->m_useGerberProtelExtensions = parseBool();
691 break;
692
693 case T_usegerberattributes:
694 aPcbPlotParams->m_useGerberX2format = parseBool();
695 break;
696
697 case T_usegerberadvancedattributes:
698 aPcbPlotParams->m_includeGerberNetlistInfo = parseBool();
699 break;
700
701 case T_creategerberjobfile:
702 aPcbPlotParams->m_createGerberJobFile = parseBool();
703 break;
704
705 case T_gerberprecision:
706 aPcbPlotParams->m_gerberPrecision = parseInt( gbrDefaultPrecision - 1,
708 break;
709
710 case T_dashed_line_dash_ratio:
711 aPcbPlotParams->m_dashedLineDashRatio = parseDouble();
712 break;
713
714 case T_dashed_line_gap_ratio:
715 aPcbPlotParams->m_dashedLineGapRatio = parseDouble();
716 break;
717
718 case T_svgprecision:
720 break;
721
722 case T_svguseinch:
723 parseBool(); // Unused. For compatibility
724 break;
725
726 case T_psa4output:
727 aPcbPlotParams->m_A4Output = parseBool();
728 break;
729
730 case T_excludeedgelayer:
731 if( !parseBool() )
732 aPcbPlotParams->m_plotOnAllLayersSequence.push_back( Edge_Cuts );
733
734 break;
735
736 case T_plotframeref:
737 aPcbPlotParams->m_plotDrawingSheet = parseBool();
738 break;
739
740 case T_viasonmask:
741 aPcbPlotParams->m_plotViaOnMaskLayer = parseBool();
742 break;
743
744 case T_mode:
745 aPcbPlotParams->SetPlotMode( parseInt( 0, 2 ) > 1 ? SKETCH : FILLED );
746 break;
747
748 case T_useauxorigin:
749 aPcbPlotParams->m_useAuxOrigin = parseBool();
750 break;
751
752 case T_hpglpennumber:
754 break;
755
756 case T_hpglpenspeed:
758 break;
759
760 case T_hpglpendiameter:
761 aPcbPlotParams->m_HPGLPenDiam = parseDouble();
762 break;
763
764 case T_hpglpenoverlay:
765 // No more used. just here for compatibility with old versions
767 break;
768
769 case T_pdf_front_fp_property_popups:
770 aPcbPlotParams->m_PDFFrontFPPropertyPopups = parseBool();
771 break;
772
773 case T_pdf_back_fp_property_popups:
774 aPcbPlotParams->m_PDFBackFPPropertyPopups = parseBool();
775 break;
776
777 case T_pdf_metadata:
778 aPcbPlotParams->m_PDFMetadata = parseBool();
779 break;
780
781 case T_pdf_single_document:
782 aPcbPlotParams->m_PDFSingle = parseBool();
783 break;
784
785 case T_dxfpolygonmode:
786 aPcbPlotParams->m_DXFPolygonMode = parseBool();
787 break;
788
789 case T_dxfimperialunits:
790 aPcbPlotParams->m_DXFUnits = parseBool() ? DXF_UNITS::INCH : DXF_UNITS::MM;
791 break;
792
793 case T_dxfusepcbnewfont:
794 aPcbPlotParams->m_textMode = parseBool() ? PLOT_TEXT_MODE::DEFAULT
795 : PLOT_TEXT_MODE::NATIVE;
796 break;
797
798 case T_pscolor:
799 NeedSYMBOL(); // This actually was never used...
800 break;
801
802 case T_psnegative:
803 aPcbPlotParams->m_negative = parseBool();
804 break;
805
806 case T_plot_black_and_white:
807 aPcbPlotParams->m_blackAndWhite = parseBool();
808 break;
809
810 case T_plotinvisibletext: // legacy token; no longer supported
811 parseBool();
812 break;
813
814 case T_sketchpadsonfab:
815 aPcbPlotParams->m_sketchPadsOnFabLayers= parseBool();
816 break;
817
818 case T_plotpadnumbers:
819 aPcbPlotParams->m_plotPadNumbers = parseBool();
820 break;
821
822 case T_hidednponfab:
823 aPcbPlotParams->m_hideDNPFPsOnFabLayers = parseBool();
824 break;
825
826 case T_sketchdnponfab:
827 aPcbPlotParams->m_sketchDNPFPsOnFabLayers = parseBool();
828 break;
829
830 case T_crossoutdnponfab:
831 aPcbPlotParams->m_crossoutDNPFPsOnFabLayers = parseBool();
832 break;
833
834 case T_subtractmaskfromsilk:
835 aPcbPlotParams->m_subtractMaskFromSilk = parseBool();
836 break;
837
838 case T_outputformat:
839 aPcbPlotParams->m_format = static_cast<PLOT_FORMAT>(
840 parseInt( static_cast<int>( PLOT_FORMAT::FIRST_FORMAT ),
841 static_cast<int>( PLOT_FORMAT::LAST_FORMAT ) ) );
842 break;
843
844 case T_mirror:
845 aPcbPlotParams->m_mirror = parseBool();
846 break;
847
848 case T_drillshape:
849 aPcbPlotParams->m_drillMarks = static_cast<DRILL_MARKS> ( parseInt( 0, 2 ) );
850 break;
851
852 case T_scaleselection:
853 aPcbPlotParams->m_scaleSelection = parseInt( 0, 4 );
854 break;
855
856 case T_outputdirectory:
857 NeedSYMBOLorNUMBER(); // a dir name can be like a number
858 aPcbPlotParams->m_outputDirectory = From_UTF8( CurText() );
859 break;
860
861 default:
862 skipCurrent(); // skip unknown or outdated plot parameter
863 skip_right = true; // the closing right token is already read.
864 break;
865 }
866
867 if( ! skip_right )
868 NeedRIGHT();
869 }
870}
871
872
874{
875 T token = NeedSYMBOL();
876
877 switch( token )
878 {
879 case T_false:
880 case T_no:
881 return false;
882
883 case T_true:
884 case T_yes:
885 return true;
886
887 default:
888 Expecting( "true, false, yes, or no" );
889 return false;
890 }
891}
892
893
894int PCB_PLOT_PARAMS_PARSER::parseInt( int aMin, int aMax )
895{
896 T token = NextTok();
897
898 if( token != T_NUMBER )
899 Expecting( T_NUMBER );
900
901 int val = atoi( CurText() );
902
903 if( val < aMin )
904 val = aMin;
905 else if( val > aMax )
906 val = aMax;
907
908 return val;
909}
910
911
913{
914 T token = NextTok();
915
916 if( token != T_NUMBER )
917 Expecting( T_NUMBER );
918
919 return DSNLEXER::parseDouble();
920}
921
922
924{
925 int curr_level = 0;
926 T token;
927
928 while( ( token = NextTok() ) != T_EOF )
929 {
930 if( token == T_LEFT )
931 curr_level--;
932
933 if( token == T_RIGHT )
934 {
935 curr_level++;
936
937 if( curr_level > 0 )
938 return;
939 }
940 }
941}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
int ParseHex(const std::string &str)
Convert the output of FmtHex() and replaces this set's values with those given in the input string.
Definition: base_set.h:348
BASE_SET & set(size_t pos)
Definition: base_set.h:116
std::string FmtHex() const
Return a hex string showing contents of this set.
Definition: base_set.h:302
double parseDouble()
Parse the current token as an ASCII numeric string with possible leading whitespace into a double pre...
Definition: dsnlexer.cpp:844
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:93
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:37
LSEQ SeqStackupForPlotting() const
Return the sequence that is typical for a bottom-to-top stack-up.
Definition: lset.cpp:388
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:572
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:322
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:545
int PRINTF_FUNC_N Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:460
The parser for PCB_PLOT_PARAMS.
void skipCurrent()
Skip the current token level.
PCB_PLOT_PARAMS_PARSER(LINE_READER *aReader, int aBoardFileVersion)
int parseInt(int aMin, int aMax)
Parse an integer and constrains it between two values.
double parseDouble()
Parse a double precision floating point number.
void Parse(PCB_PLOT_PARAMS *aPcbPlotParams)
Parameters and options when plotting/printing a board.
bool m_sketchPadsOnFabLayers
Plots pads outlines on fab layers.
int m_HPGLPenNum
HPGL only: pen number selection(1 to 9)
bool m_crossoutDNPFPsOnFabLayers
double m_dashedLineGapRatio
std::optional< bool > m_plotViaOnMaskLayer
int m_gerberPrecision
Precision of coordinates in Gerber: accepted 5 or 6 when units are in mm, 6 or 7 in inches (but Pcbne...
void SetLayerSelection(LSET aSelection)
std::shared_ptr< COLOR_SETTINGS > m_default_colors
Pointer to color settings to be used for plotting.
OUTLINE_MODE m_plotMode
Used to disable NPTH pads plotting on copper layers.
bool m_A4Output
In polygon mode, each item to plot is converted to a polygon and all polygons are merged.
int m_scaleSelection
Scale ratio index (UI only)
DXF_UNITS m_DXFUnits
PLOT_TEXT_MODE m_textMode
Holes can be not plotted, have a small mark, or be plotted in actual size.
void SetPlotOnAllLayersSequence(LSEQ aSeq)
bool m_plotValue
Enable plotting of part values.
LSEQ m_plotOnAllLayersSequence
wxString m_outputDirectory
Output directory for plot files (usually relative to the board file)
bool m_PDFMetadata
Generate PDF metadata for SUBJECT and AUTHOR.
bool m_autoScale
Autoscale the plot to fit an A4 (landscape?) sheet.
bool m_useGerberProtelExtensions
On gerbers 'scrape' away the solder mask from silkscreen (trim silks)
int m_HPGLPenSpeed
HPGL only: pen speed, always in cm/s (1 to 99 cm/s)
bool GetCreateGerberJobFile() const
bool m_useAuxOrigin
Plot gerbers using auxiliary (drill) origin instead of absolute coordinates.
double m_scale
When true set the scale to fit the board in the page.
int m_widthAdjust
Compensation for PS printers/plotters that do not strictly obey line width settings.
bool SetHPGLPenDiameter(double aValue)
bool m_PDFFrontFPPropertyPopups
Generate PDF property popup menus for footprints.
double m_fineScaleAdjustX
Compensation for printer scale errors (and therefore.
double m_dashedLineDashRatio
void SetGerberPrecision(int aPrecision)
bool m_blackAndWhite
Plot in negative color (supported only by some drivers)
bool SetHPGLPenSpeed(int aValue)
PLOT_FORMAT m_format
bool m_createGerberJobFile
generate the auxiliary "job file" in gerber format
bool m_plotReference
Enable plotting of part references.
double m_fineScaleAdjustY
expected to be very near 1.0).
double m_HPGLPenDiam
HPGL only: pen diameter in MILS, useful to fill areas However, it is in mm in hpgl files.
bool m_gerberDisableApertMacros
Disable aperture macros in Gerber format (only for broken Gerber readers).
void Parse(PCB_PLOT_PARAMS_PARSER *aParser)
bool m_subtractMaskFromSilk
Deprecated; only used for reading legacy files.
COLOR_SETTINGS * m_colors
bool GetUseGerberX2format() const
bool m_mirror
Global scale factor, 1.0 plots a board at actual size.
bool IsSameAs(const PCB_PLOT_PARAMS &aPcbPlotParams) const
Compare current settings to aPcbPlotParams, including not saved parameters in brd file.
bool m_includeGerberNetlistInfo
Include netlist info (only in Gerber X2 format) (chapter ? in revision ?)
unsigned m_svgPrecision
Precision of coordinates in SVG: accepted 3 - 6; 6 is the internal resolution of Pcbnew.
bool GetIncludeGerberNetlistInfo() const
bool m_PDFSingle
Generate a single PDF file for all layers.
void SetPlotMode(OUTLINE_MODE aPlotMode)
double GetDashedLineGapRatio() const
bool m_PDFBackFPPropertyPopups
on front and/or back of board
bool m_sketchDNPFPsOnFabLayers
double GetDashedLineDashRatio() const
void SetSvgPrecision(unsigned aPrecision)
DRILL_MARKS m_drillMarks
Plot pad numbers when sketching pads on fab layers.
bool m_useGerberX2format
Include attributes from the Gerber X2 format (chapter 5 in revision J2)
bool m_negative
Mirror the plot around the X axis.
bool m_plotDrawingSheet
Plot in black and white only.
void Format(OUTPUTFORMATTER *aFormatter) const
OUTLINE_MODE GetPlotMode() const
LSET m_layerSelection
Plot format type (chooses the driver to be used)
bool m_plotPadNumbers
FILLED or SKETCH for filled objects.
static bool setDouble(double *aResult, double aValue, double aMin, double aMax)
static bool setInt(int *aResult, int aValue, int aMin, int aMax)
static const char * getTokenName(T aTok)
static const bool FILLED
Definition: gr_basic.cpp:30
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ In22_Cu
Definition: layer_ids.h:87
@ In11_Cu
Definition: layer_ids.h:76
@ In29_Cu
Definition: layer_ids.h:94
@ In30_Cu
Definition: layer_ids.h:95
@ User_8
Definition: layer_ids.h:131
@ F_CrtYd
Definition: layer_ids.h:116
@ In17_Cu
Definition: layer_ids.h:82
@ B_Adhes
Definition: layer_ids.h:103
@ Edge_Cuts
Definition: layer_ids.h:112
@ Dwgs_User
Definition: layer_ids.h:107
@ F_Paste
Definition: layer_ids.h:104
@ In9_Cu
Definition: layer_ids.h:74
@ Cmts_User
Definition: layer_ids.h:108
@ User_6
Definition: layer_ids.h:129
@ User_7
Definition: layer_ids.h:130
@ In19_Cu
Definition: layer_ids.h:84
@ In7_Cu
Definition: layer_ids.h:72
@ In28_Cu
Definition: layer_ids.h:93
@ In26_Cu
Definition: layer_ids.h:91
@ F_Adhes
Definition: layer_ids.h:102
@ B_Mask
Definition: layer_ids.h:98
@ B_Cu
Definition: layer_ids.h:65
@ User_5
Definition: layer_ids.h:128
@ Eco1_User
Definition: layer_ids.h:109
@ F_Mask
Definition: layer_ids.h:97
@ In21_Cu
Definition: layer_ids.h:86
@ In23_Cu
Definition: layer_ids.h:88
@ B_Paste
Definition: layer_ids.h:105
@ In15_Cu
Definition: layer_ids.h:80
@ In2_Cu
Definition: layer_ids.h:67
@ User_9
Definition: layer_ids.h:132
@ F_Fab
Definition: layer_ids.h:119
@ In10_Cu
Definition: layer_ids.h:75
@ Margin
Definition: layer_ids.h:113
@ F_SilkS
Definition: layer_ids.h:100
@ In4_Cu
Definition: layer_ids.h:69
@ B_CrtYd
Definition: layer_ids.h:115
@ Eco2_User
Definition: layer_ids.h:110
@ In16_Cu
Definition: layer_ids.h:81
@ In24_Cu
Definition: layer_ids.h:89
@ In1_Cu
Definition: layer_ids.h:66
@ Rescue
Definition: layer_ids.h:121
@ User_3
Definition: layer_ids.h:126
@ User_1
Definition: layer_ids.h:124
@ B_SilkS
Definition: layer_ids.h:101
@ In13_Cu
Definition: layer_ids.h:78
@ User_4
Definition: layer_ids.h:127
@ In8_Cu
Definition: layer_ids.h:73
@ In14_Cu
Definition: layer_ids.h:79
@ User_2
Definition: layer_ids.h:125
@ In12_Cu
Definition: layer_ids.h:77
@ In27_Cu
Definition: layer_ids.h:92
@ In6_Cu
Definition: layer_ids.h:71
@ In5_Cu
Definition: layer_ids.h:70
@ In3_Cu
Definition: layer_ids.h:68
@ In20_Cu
Definition: layer_ids.h:85
@ F_Cu
Definition: layer_ids.h:64
@ In18_Cu
Definition: layer_ids.h:83
@ In25_Cu
Definition: layer_ids.h:90
@ B_Fab
Definition: layer_ids.h:118
void FormatBool(OUTPUTFORMATTER *aOut, const wxString &aKey, bool aValue)
Writes a boolean to the formatter, in the style (aKey [yes|no])
@ SKETCH
Definition: outline_mode.h:26
#define HPGL_PEN_NUMBER_MAX
static bool setDouble(double *aTarget, double aValue, double aMin, double aMax)
#define SVG_PRECISION_MIN
#define HPGL_PEN_SPEED_MAX
static bool setInt(int *aTarget, int aValue, int aMin, int aMax)
#define HPGL_PEN_DIAMETER_MIN
static const char * getTokenName(T aTok)
static const std::map< LEGACY_PCB_LAYER_ID, PCB_LAYER_ID > s_legacyLayerIdMap
#define HPGL_PEN_DIAMETER_MAX
LEGACY_PCB_LAYER_ID
These are the layer IDs from before 5e0abadb23425765e164f49ee2f893e94ddb97fc, and are needed for mapp...
@ LEGACY_In2_Cu
@ LEGACY_User_8
@ LEGACY_UNSELECTED_LAYER
@ LEGACY_PCB_LAYER_ID_COUNT
@ LEGACY_Eco2_User
@ LEGACY_In21_Cu
@ LEGACY_Dwgs_User
@ LEGACY_F_Cu
@ LEGACY_In23_Cu
@ LEGACY_In7_Cu
@ LEGACY_In18_Cu
@ LEGACY_Cmts_User
@ LEGACY_UNDEFINED_LAYER
@ LEGACY_In27_Cu
@ LEGACY_User_9
@ LEGACY_F_SilkS
@ LEGACY_In14_Cu
@ LEGACY_B_CrtYd
@ LEGACY_User_6
@ LEGACY_User_4
@ LEGACY_In11_Cu
@ LEGACY_In6_Cu
@ LEGACY_B_Paste
@ LEGACY_Margin
@ LEGACY_B_Cu
@ LEGACY_In4_Cu
@ LEGACY_In16_Cu
@ LEGACY_In28_Cu
@ LEGACY_In22_Cu
@ LEGACY_User_2
@ LEGACY_F_Mask
@ LEGACY_B_Adhes
@ LEGACY_In15_Cu
@ LEGACY_In29_Cu
@ LEGACY_B_Fab
@ LEGACY_In13_Cu
@ LEGACY_In17_Cu
@ LEGACY_In1_Cu
@ LEGACY_In24_Cu
@ LEGACY_B_Mask
@ LEGACY_User_1
@ LEGACY_User_3
@ LEGACY_Eco1_User
@ LEGACY_F_CrtYd
@ LEGACY_Rescue
@ LEGACY_In26_Cu
@ LEGACY_In19_Cu
@ LEGACY_In12_Cu
@ LEGACY_Edge_Cuts
@ LEGACY_In10_Cu
@ LEGACY_F_Adhes
@ LEGACY_In5_Cu
@ LEGACY_User_5
@ LEGACY_F_Paste
@ LEGACY_In9_Cu
@ LEGACY_B_SilkS
@ LEGACY_In25_Cu
@ LEGACY_User_7
@ LEGACY_In20_Cu
@ LEGACY_F_Fab
@ LEGACY_In30_Cu
@ LEGACY_In8_Cu
@ LEGACY_In3_Cu
static const int gbrDefaultPrecision
#define HPGL_PEN_SPEED_MIN
#define HPGL_PEN_NUMBER_MIN
#define SVG_PRECISION_MAX
#define SVG_PRECISION_DEFAULT
LSET remapLegacyLayerLSET(const BASE_SET &aLegacyLSET)
DRILL_MARKS
Plots and prints can show holes in pads and vias 3 options are available:
PLOT_FORMAT
The set of supported output plot formats.
Definition: plotter.h:65
wxString From_UTF8(const char *cstring)
constexpr int mmToIU(double mm) const
Definition: base_units.h:88