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
35
36#define PLOT_LINEWIDTH_DEFAULT ( DEFAULT_TEXT_WIDTH * IU_PER_MM )
37
38#define HPGL_PEN_DIAMETER_MIN 0
39#define HPGL_PEN_DIAMETER_MAX 100.0 // Unit = mil
40#define HPGL_PEN_SPEED_MIN 1 // this param is always in cm/s
41#define HPGL_PEN_SPEED_MAX 99 // this param is always in cm/s
42#define HPGL_PEN_NUMBER_MIN 1
43#define HPGL_PEN_NUMBER_MAX 16
44
45#define SVG_PRECISION_MIN 3U
46#define SVG_PRECISION_MAX 6U
47#define SVG_PRECISION_DEFAULT 4
48
49
50// default trailing digits in Gerber coordinates, when units are mm
51// This is also the max usable precision (i.e. internal Pcbnew Units)
52static const int gbrDefaultPrecision = 6;
53
54
55using namespace PCBPLOTPARAMS_T;
56
57
58static const char* getTokenName( T aTok )
59{
60 return PCB_PLOT_PARAMS_LEXER::TokenName( aTok );
61}
62
63
64static bool setInt( int* aTarget, int aValue, int aMin, int aMax )
65{
66 int temp = aValue;
67
68 if( aValue < aMin )
69 temp = aMin;
70 else if( aValue > aMax )
71 temp = aMax;
72
73 *aTarget = temp;
74 return ( temp == aValue );
75}
76
77
78static bool setDouble( double* aTarget, double aValue, double aMin, double aMax )
79{
80 double temp = aValue;
81
82 if( aValue < aMin )
83 temp = aMin;
84 else if( aValue > aMax )
85 temp = aMax;
86
87 *aTarget = temp;
88 return ( temp == aValue );
89}
90
91
93{
100 m_dashedLineDashRatio = 12.0; // From ISO 128-2
101 m_dashedLineGapRatio = 3.0; // From ISO 128-2
102
103 // we used 0.1mils for SVG step before, but nm precision is more accurate, so we use nm
105 m_plotDrawingSheet = false;
107 m_DXFPolygonMode = true;
108 m_DXFUnits = DXF_UNITS::INCHES;
109 m_useAuxOrigin = false;
110 m_HPGLPenNum = 1;
111 m_HPGLPenSpeed = 20; // this param is always in cm/s
112 m_HPGLPenDiam = 15; // in mils
113 m_negative = false;
114 m_A4Output = false;
115 m_plotReference = true;
116 m_plotValue = true;
117 m_plotFPText = true;
118 m_plotInvisibleText = false;
123 m_plotPadNumbers = false;
125 m_format = PLOT_FORMAT::GERBER;
126 m_mirror = false;
127 m_drillMarks = DRILL_MARKS::SMALL_DRILL_SHAPE;
128 m_autoScale = false;
129 m_scale = 1.0;
131 m_fineScaleAdjustX = 1.0;
132 m_fineScaleAdjustY = 1.0;
133 m_widthAdjust = 0.;
134 m_textMode = PLOT_TEXT_MODE::DEFAULT;
135 m_outputDirectory.clear();
138 | LSET::AllCuMask();
139
142 m_PDFMetadata = true;
143 m_PDFSingle = false;
144
145 // This parameter controls if the NPTH pads will be plotted or not
146 // it is a "local" parameter
147 m_skipNPTH_Pads = false;
148
149 // line width to plot items in outline mode.
151
152 m_default_colors = std::make_shared<COLOR_SETTINGS>();
154
155 m_blackAndWhite = true;
156}
157
158
160{
161 // Currently Gerber files use mm.
162 // accepted precision is only 6 (max value, this is the resolution of Pcbnew)
163 // or 5, min value for professional boards, when 6 creates problems
164 // to board makers.
165
168}
169
170
171void PCB_PLOT_PARAMS::SetSvgPrecision( unsigned aPrecision )
172{
173 m_svgPrecision = std::clamp( aPrecision, SVG_PRECISION_MIN, SVG_PRECISION_MAX );
174}
175
176
178{
179 aFormatter->Print( "(pcbplotparams" );
180
181 aFormatter->Print( "(layerselection 0x%s)", m_layerSelection.FmtHex().c_str() );
182
183 aFormatter->Print( "(plot_on_all_layers_selection 0x%s)",
185
186 KICAD_FORMAT::FormatBool( aFormatter, "disableapertmacros", m_gerberDisableApertMacros );
187 KICAD_FORMAT::FormatBool( aFormatter, "usegerberextensions", m_useGerberProtelExtensions );
188 KICAD_FORMAT::FormatBool( aFormatter, "usegerberattributes", GetUseGerberX2format() );
189 KICAD_FORMAT::FormatBool( aFormatter, "usegerberadvancedattributes", GetIncludeGerberNetlistInfo() );
190 KICAD_FORMAT::FormatBool( aFormatter, "creategerberjobfile", GetCreateGerberJobFile() );
191
192 // save this option only if it is not the default value,
193 // to avoid incompatibility with older Pcbnew version
195 aFormatter->Print( "(gerberprecision %d)", m_gerberPrecision );
196
197 aFormatter->Print( "(dashed_line_dash_ratio %f)", GetDashedLineDashRatio() );
198 aFormatter->Print( "(dashed_line_gap_ratio %f)", GetDashedLineGapRatio() );
199
200 // SVG options
201 aFormatter->Print( "(svgprecision %d)", m_svgPrecision );
202
203 KICAD_FORMAT::FormatBool( aFormatter, "plotframeref", m_plotDrawingSheet );
204 aFormatter->Print( "(mode %d)", GetPlotMode() == SKETCH ? 2 : 1 );
205 KICAD_FORMAT::FormatBool( aFormatter, "useauxorigin", m_useAuxOrigin );
206
207 // HPGL options
208 aFormatter->Print( "(hpglpennumber %d)", m_HPGLPenNum );
209 aFormatter->Print( "(hpglpenspeed %d)", m_HPGLPenSpeed );
210 aFormatter->Print( "(hpglpendiameter %f)", m_HPGLPenDiam );
211
212 // PDF options
213 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_pdf_front_fp_property_popups ),
215 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_pdf_back_fp_property_popups ),
217 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_pdf_metadata ), m_PDFMetadata );
218 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_pdf_single_document ), m_PDFSingle );
219
220 // DXF options
221 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_dxfpolygonmode ), m_DXFPolygonMode );
222 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_dxfimperialunits ),
223 m_DXFUnits == DXF_UNITS::INCHES );
224 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_dxfusepcbnewfont ),
225 m_textMode != PLOT_TEXT_MODE::NATIVE );
226
227 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_psnegative ), m_negative );
228 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_psa4output ), m_A4Output );
229
230 KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_plot_black_and_white ), m_blackAndWhite );
231
232 KICAD_FORMAT::FormatBool( aFormatter, "plotinvisibletext", m_plotInvisibleText );
233 KICAD_FORMAT::FormatBool( aFormatter, "sketchpadsonfab", m_sketchPadsOnFabLayers );
234 KICAD_FORMAT::FormatBool( aFormatter, "plotpadnumbers", m_plotPadNumbers );
235 KICAD_FORMAT::FormatBool( aFormatter, "hidednponfab", m_hideDNPFPsOnFabLayers );
236 KICAD_FORMAT::FormatBool( aFormatter, "sketchdnponfab", m_sketchDNPFPsOnFabLayers );
237 KICAD_FORMAT::FormatBool( aFormatter, "crossoutdnponfab", m_crossoutDNPFPsOnFabLayers );
238 KICAD_FORMAT::FormatBool( aFormatter, "subtractmaskfromsilk", m_subtractMaskFromSilk );
239 aFormatter->Print( "(outputformat %d)", static_cast<int>( m_format ) );
240 KICAD_FORMAT::FormatBool( aFormatter, "mirror", m_mirror );
241 aFormatter->Print( "(drillshape %d)", (int)m_drillMarks );
242 aFormatter->Print( "(scaleselection %d)", m_scaleSelection );
243 aFormatter->Print( "(outputdirectory %s)", aFormatter->Quotew( m_outputDirectory ).c_str() );
244 aFormatter->Print( ")" );
245}
246
247
249{
250 aParser->Parse( this );
251}
252
253
254bool PCB_PLOT_PARAMS::IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams ) const
255{
256 if( m_layerSelection != aPcbPlotParams.m_layerSelection )
257 return false;
258
260 return false;
261
263 return false;
264
266 return false;
267
268 if( m_useGerberX2format != aPcbPlotParams.m_useGerberX2format )
269 return false;
270
272 return false;
273
274 if( m_createGerberJobFile != aPcbPlotParams.m_createGerberJobFile )
275 return false;
276
277 if( m_gerberPrecision != aPcbPlotParams.m_gerberPrecision )
278 return false;
279
280 if( m_dashedLineDashRatio != aPcbPlotParams.m_dashedLineDashRatio )
281 return false;
282
283 if( m_dashedLineGapRatio != aPcbPlotParams.m_dashedLineGapRatio )
284 return false;
285
286 if( m_plotDrawingSheet != aPcbPlotParams.m_plotDrawingSheet )
287 return false;
288
289 if( m_plotMode != aPcbPlotParams.m_plotMode )
290 return false;
291
292 if( m_DXFPolygonMode != aPcbPlotParams.m_DXFPolygonMode )
293 return false;
294
295 if( m_DXFUnits != aPcbPlotParams.m_DXFUnits )
296 return false;
297
298 if( m_svgPrecision != aPcbPlotParams.m_svgPrecision )
299 return false;
300
301 if( m_useAuxOrigin != aPcbPlotParams.m_useAuxOrigin )
302 return false;
303
304 if( m_HPGLPenNum != aPcbPlotParams.m_HPGLPenNum )
305 return false;
306
307 if( m_HPGLPenSpeed != aPcbPlotParams.m_HPGLPenSpeed )
308 return false;
309
310 if( m_HPGLPenDiam != aPcbPlotParams.m_HPGLPenDiam )
311 return false;
312
313 if( m_negative != aPcbPlotParams.m_negative )
314 return false;
315
317 return false;
318
320 return false;
321
322 if( m_PDFMetadata != aPcbPlotParams.m_PDFMetadata )
323 return false;
324
325 if( m_A4Output != aPcbPlotParams.m_A4Output )
326 return false;
327
328 if( m_plotReference != aPcbPlotParams.m_plotReference )
329 return false;
330
331 if( m_plotValue != aPcbPlotParams.m_plotValue )
332 return false;
333
334 if( m_plotFPText != aPcbPlotParams.m_plotFPText )
335 return false;
336
337 if( m_plotInvisibleText != aPcbPlotParams.m_plotInvisibleText )
338 return false;
339
341 return false;
342
343 if( m_plotPadNumbers != aPcbPlotParams.m_plotPadNumbers )
344 return false;
345
347 return false;
348
350 return false;
351
353 return false;
354
355 if( m_subtractMaskFromSilk != aPcbPlotParams.m_subtractMaskFromSilk )
356 return false;
357
358 if( m_format != aPcbPlotParams.m_format )
359 return false;
360
361 if( m_mirror != aPcbPlotParams.m_mirror )
362 return false;
363
364 if( m_drillMarks != aPcbPlotParams.m_drillMarks )
365 return false;
366
367 if( m_scaleSelection != aPcbPlotParams.m_scaleSelection )
368 return false;
369
370 if( m_autoScale != aPcbPlotParams.m_autoScale )
371 return false;
372
373 if( m_scale != aPcbPlotParams.m_scale )
374 return false;
375
376 if( m_fineScaleAdjustX != aPcbPlotParams.m_fineScaleAdjustX )
377 return false;
378
379 if( m_fineScaleAdjustY != aPcbPlotParams.m_fineScaleAdjustY )
380 return false;
381
382 if( m_widthAdjust != aPcbPlotParams.m_widthAdjust )
383 return false;
384
385 if( m_textMode != aPcbPlotParams.m_textMode )
386 return false;
387
388 if( m_blackAndWhite != aPcbPlotParams.m_blackAndWhite )
389 return false;
390
391 if( !m_outputDirectory.IsSameAs( aPcbPlotParams.m_outputDirectory ) )
392 return false;
393
394 return true;
395}
396
397
399{
401}
402
403
405{
407}
408
409
411 PCB_PLOT_PARAMS_LEXER( aReader ),
412 m_boardFileVersion( aBoardFileVersion )
413{
414}
415
416
417PCB_PLOT_PARAMS_PARSER::PCB_PLOT_PARAMS_PARSER( char* aLine, const wxString& aSource ) :
418 PCB_PLOT_PARAMS_LEXER( aLine, aSource ),
419 m_boardFileVersion( 0 )
420{
421}
422
423
429{
432
465
468
471
474
477
484
487
490
491 // User definable layers.
501
503
504 // Four reserved layers (60 - 63) for future expansion within the 64 bit integer limit.
505
508
509/*
510 * Mapping to translate a legacy layer ID into the new PCB layer IDs.
511 */
512static const std::map<LEGACY_PCB_LAYER_ID, PCB_LAYER_ID> s_legacyLayerIdMap{
513 {LEGACY_F_Cu, F_Cu},
514 {LEGACY_B_Cu, B_Cu},
573};
574
575
576LSET remapLegacyLayerLSET( const BASE_SET& aLegacyLSET )
577{
578 LSET newLayers;
579
580 for( const auto& [legacyLayer, newLayer] : s_legacyLayerIdMap )
581 newLayers[newLayer] = aLegacyLSET[legacyLayer];
582
583 return newLayers;
584}
585
586
588{
589 T token;
590
591 while( ( token = NextTok() ) != T_RIGHT )
592 {
593 if( token == T_EOF)
594 Unexpected( T_EOF );
595
596 if( token == T_LEFT )
597 token = NextTok();
598
599 if( token == T_pcbplotparams )
600 continue;
601
602 bool skip_right = false;
603
604 switch( token )
605 {
606 case T_layerselection:
607 {
608 token = NeedSYMBOLorNUMBER();
609
610 const std::string& cur = CurStr();
611
612 if( token == T_NUMBER ) // pretty 3 format had legacy Cu stack.
613 {
614 // It's not possible to convert a legacy Cu layer number to a new Cu layer
615 // number without knowing the number or total Cu layers in the legacy board.
616 // We do not have that information here, so simply set all layers ON. User
617 // can turn them off in the UI.
618 aPcbPlotParams->m_layerSelection = LSET( { F_SilkS, B_SilkS } ) | LSET::AllCuMask();
619 }
620 else if( cur.find_first_of( "0x" ) == 0 ) // pretty ver. 4.
621 {
622 // The layers were renumbered in 5e0abadb23425765e164f49ee2f893e94ddb97fc, but there wasn't
623 // a board file version change with it, so this value is the one immediately after that happened.
624 if( m_boardFileVersion < 20240819 )
625 {
627
628 // skip the leading 2 0x bytes.
629 legacyLSET.ParseHex( cur.c_str() + 2, cur.size() - 2 );
630 aPcbPlotParams->SetLayerSelection( remapLegacyLayerLSET( legacyLSET ) );
631 }
632 else
633 {
634 // skip the leading 2 0x bytes.
635 aPcbPlotParams->m_layerSelection.ParseHex( cur.c_str() + 2, cur.size() - 2 );
636 }
637 }
638 else
639 {
640 Expecting( "integer or hex layerSelection" );
641 }
642
643 break;
644 }
645
646 case T_plot_on_all_layers_selection:
647 {
648 token = NeedSYMBOLorNUMBER();
649
650 const std::string& cur = CurStr();
651
652 if( cur.find_first_of( "0x" ) == 0 )
653 {
654 // The layers were renumbered in 5e0abadb23425765e164f49ee2f893e94ddb97fc, but there wasn't
655 // a board file version change with it, so this value is the one immediately after that happened.
656 if( m_boardFileVersion < 20240819 )
657 {
659
660 // skip the leading 2 0x bytes.
661 legacyLSET.ParseHex( cur.c_str() + 2, cur.size() - 2 );
662 aPcbPlotParams->SetPlotOnAllLayersSelection( remapLegacyLayerLSET( legacyLSET ) );
663 }
664 else
665 {
666 // skip the leading 2 0x bytes.
667 aPcbPlotParams->m_plotOnAllLayersSelection.ParseHex( cur.c_str() + 2,
668 cur.size() - 2 );
669 }
670 }
671 else
672 {
673 Expecting( "hex plot_on_all_layers_selection" );
674 }
675
676 break;
677 }
678
679 case T_disableapertmacros:
680 aPcbPlotParams->m_gerberDisableApertMacros = parseBool();
681 break;
682
683 case T_usegerberextensions:
684 aPcbPlotParams->m_useGerberProtelExtensions = parseBool();
685 break;
686
687 case T_usegerberattributes:
688 aPcbPlotParams->m_useGerberX2format = parseBool();
689 break;
690
691 case T_usegerberadvancedattributes:
692 aPcbPlotParams->m_includeGerberNetlistInfo = parseBool();
693 break;
694
695 case T_creategerberjobfile:
696 aPcbPlotParams->m_createGerberJobFile = parseBool();
697 break;
698
699 case T_gerberprecision:
700 aPcbPlotParams->m_gerberPrecision = parseInt( gbrDefaultPrecision - 1,
702 break;
703
704 case T_dashed_line_dash_ratio:
705 aPcbPlotParams->m_dashedLineDashRatio = parseDouble();
706 break;
707
708 case T_dashed_line_gap_ratio:
709 aPcbPlotParams->m_dashedLineGapRatio = parseDouble();
710 break;
711
712 case T_svgprecision:
714 break;
715
716 case T_svguseinch:
717 parseBool(); // Unused. For compatibility
718 break;
719
720 case T_psa4output:
721 aPcbPlotParams->m_A4Output = parseBool();
722 break;
723
724 case T_excludeedgelayer:
725 if( !parseBool() )
726 aPcbPlotParams->m_plotOnAllLayersSelection.set( Edge_Cuts );
727
728 break;
729
730 case T_plotframeref:
731 aPcbPlotParams->m_plotDrawingSheet = parseBool();
732 break;
733
734 case T_viasonmask:
735 aPcbPlotParams->m_plotViaOnMaskLayer = parseBool();
736 break;
737
738 case T_mode:
739 aPcbPlotParams->SetPlotMode( parseInt( 0, 2 ) > 1 ? SKETCH : FILLED );
740 break;
741
742 case T_useauxorigin:
743 aPcbPlotParams->m_useAuxOrigin = parseBool();
744 break;
745
746 case T_hpglpennumber:
748 break;
749
750 case T_hpglpenspeed:
752 break;
753
754 case T_hpglpendiameter:
755 aPcbPlotParams->m_HPGLPenDiam = parseDouble();
756 break;
757
758 case T_hpglpenoverlay:
759 // No more used. just here for compatibility with old versions
761 break;
762
763 case T_pdf_front_fp_property_popups:
764 aPcbPlotParams->m_PDFFrontFPPropertyPopups = parseBool();
765 break;
766
767 case T_pdf_back_fp_property_popups:
768 aPcbPlotParams->m_PDFBackFPPropertyPopups = parseBool();
769 break;
770
771 case T_pdf_metadata:
772 aPcbPlotParams->m_PDFMetadata = parseBool();
773 break;
774
775 case T_pdf_single_document:
776 aPcbPlotParams->m_PDFSingle = parseBool();
777 break;
778
779 case T_dxfpolygonmode:
780 aPcbPlotParams->m_DXFPolygonMode = parseBool();
781 break;
782
783 case T_dxfimperialunits:
784 aPcbPlotParams->m_DXFUnits = parseBool() ? DXF_UNITS::INCHES
785 : DXF_UNITS::MILLIMETERS;
786 break;
787
788 case T_dxfusepcbnewfont:
789 aPcbPlotParams->m_textMode = parseBool() ? PLOT_TEXT_MODE::DEFAULT
790 : PLOT_TEXT_MODE::NATIVE;
791 break;
792
793 case T_pscolor:
794 NeedSYMBOL(); // This actually was never used...
795 break;
796
797 case T_psnegative:
798 aPcbPlotParams->m_negative = parseBool();
799 break;
800
801 case T_plot_black_and_white:
802 aPcbPlotParams->m_blackAndWhite = parseBool();
803 break;
804
805 case T_plotinvisibletext:
806 aPcbPlotParams->m_plotInvisibleText = parseBool();
807 break;
808
809 case T_sketchpadsonfab:
810 aPcbPlotParams->m_sketchPadsOnFabLayers= parseBool();
811 break;
812
813 case T_plotpadnumbers:
814 aPcbPlotParams->m_plotPadNumbers = parseBool();
815 break;
816
817 case T_hidednponfab:
818 aPcbPlotParams->m_hideDNPFPsOnFabLayers = parseBool();
819 break;
820
821 case T_sketchdnponfab:
822 aPcbPlotParams->m_sketchDNPFPsOnFabLayers = parseBool();
823 break;
824
825 case T_crossoutdnponfab:
826 aPcbPlotParams->m_crossoutDNPFPsOnFabLayers = parseBool();
827 break;
828
829 case T_subtractmaskfromsilk:
830 aPcbPlotParams->m_subtractMaskFromSilk = parseBool();
831 break;
832
833 case T_outputformat:
834 aPcbPlotParams->m_format = static_cast<PLOT_FORMAT>(
835 parseInt( static_cast<int>( PLOT_FORMAT::FIRST_FORMAT ),
836 static_cast<int>( PLOT_FORMAT::LAST_FORMAT ) ) );
837 break;
838
839 case T_mirror:
840 aPcbPlotParams->m_mirror = parseBool();
841 break;
842
843 case T_drillshape:
844 aPcbPlotParams->m_drillMarks = static_cast<DRILL_MARKS> ( parseInt( 0, 2 ) );
845 break;
846
847 case T_scaleselection:
848 aPcbPlotParams->m_scaleSelection = parseInt( 0, 4 );
849 break;
850
851 case T_outputdirectory:
852 NeedSYMBOLorNUMBER(); // a dir name can be like a number
853 aPcbPlotParams->m_outputDirectory = From_UTF8( CurText() );
854 break;
855
856 default:
857 skipCurrent(); // skip unknown or outdated plot parameter
858 skip_right = true; // the closing right token is already read.
859 break;
860 }
861
862 if( ! skip_right )
863 NeedRIGHT();
864 }
865}
866
867
869{
870 T token = NeedSYMBOL();
871
872 switch( token )
873 {
874 case T_false:
875 case T_no:
876 return false;
877
878 case T_true:
879 case T_yes:
880 return true;
881
882 default:
883 Expecting( "true, false, yes, or no" );
884 return false;
885 }
886}
887
888
889int PCB_PLOT_PARAMS_PARSER::parseInt( int aMin, int aMax )
890{
891 T token = NextTok();
892
893 if( token != T_NUMBER )
894 Expecting( T_NUMBER );
895
896 int val = atoi( CurText() );
897
898 if( val < aMin )
899 val = aMin;
900 else if( val > aMax )
901 val = aMax;
902
903 return val;
904}
905
906
908{
909 T token = NextTok();
910
911 if( token != T_NUMBER )
912 Expecting( T_NUMBER );
913
914 return DSNLEXER::parseDouble();
915}
916
917
919{
920 int curr_level = 0;
921 T token;
922
923 while( ( token = NextTok() ) != T_EOF )
924 {
925 if( token == T_LEFT )
926 curr_level--;
927
928 if( token == T_RIGHT )
929 {
930 curr_level++;
931
932 if( curr_level > 0 )
933 return;
934 }
935 }
936}
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
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:564
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.
bool m_plotValue
Enable plotting of part values.
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.
void SetPlotOnAllLayersSelection(LSET aSelection)
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.
LSET m_plotOnAllLayersSelection
double m_dashedLineDashRatio
void SetGerberPrecision(int aPrecision)
bool m_blackAndWhite
Plot in negative color (supported only by some drivers)
bool SetHPGLPenSpeed(int aValue)
bool m_plotInvisibleText
Force plotting of fields marked invisible.
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
@ 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