KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_plot.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, see <https://www.gnu.org/licenses/>.
18 */
19
20#include "dialog_plot.h"
21
22#include <wx/bmpbuttn.h>
23#include <wx/clntdata.h>
24#include <wx/dirdlg.h>
25#include <wx/msgdlg.h>
26#include <wx/rearrangectrl.h>
27
28#include <plotters/plotter.h>
29#include <confirm.h>
30#include <pcb_edit_frame.h>
32#include <pcbplot.h>
33#include <pgm_base.h>
35#include <reporter.h>
37#include <layer_ids.h>
38#include <bitmaps.h>
39#include <dialog_gendrill.h>
40#include <string_utils.h>
44#include <tool/tool_manager.h>
46#include <tools/drc_tool.h>
47#include <math/util.h> // for KiROUND
48#include <macros.h>
57#include <pcb_plotter.h>
60
61
63
64
65static double selectionToScale( int selection )
66{
67 switch( selection )
68 {
69 default: return 1.0;
70 case 0: return 0.0;
71 case 2: return 1.5;
72 case 3: return 2.0;
73 case 4: return 3.0;
74 }
75}
76
77
81class PCB_LAYER_ID_CLIENT_DATA : public wxClientData
82{
83public:
87
89 m_id( aId )
90 { }
91
92 void SetData( PCB_LAYER_ID aId ) { m_id = aId; }
93 PCB_LAYER_ID Layer() const { return m_id; }
94
95private:
97};
98
99
100PCB_LAYER_ID_CLIENT_DATA* getLayerClientData( const wxRearrangeList* aList, int aIdx )
101{
102 return static_cast<PCB_LAYER_ID_CLIENT_DATA*>( aList->GetClientObject( aIdx ) );
103}
104
105
107 : DIALOG_PLOT( aEditFrame, aEditFrame )
108{
109}
110
111
112DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aEditFrame, wxWindow* aParent, JOB_EXPORT_PCB_PLOT* aJob ) :
113 DIALOG_PLOT_BASE( aParent ),
114 m_editFrame( aEditFrame ),
116 m_job( aJob )
117{
118 BOARD* board = m_editFrame->GetBoard();
119
121
122 SetName( DLG_WINDOW_NAME );
124
125 if( m_job )
126 {
127 SetTitle( aJob->GetSettingsDialogTitle() );
128
130 m_messagesPanel->Hide();
131
132 m_browseButton->Hide();
133 m_openDirButton->Hide();
134 m_staticTextPlotFmt->Hide();
135 m_plotFormatOpt->Hide();
136 m_buttonDRC->Hide();
138 m_sdbSizer1Apply->Hide();
139 m_zoneFillCheck->SetLabel( _( "Refill zones before plotting" ) );
140
141 // UpdateUI rather than wxEVT_CHECKBOX so dialog undo/redo also refreshes the label
142 m_staticTextDir->Bind( wxEVT_UPDATE_UI,
143 [this]( wxUpdateUIEvent& aEvent )
144 {
146 aEvent.Skip();
147 } );
148 }
149 else
150 {
151 m_plotOpts = m_editFrame->GetPlotSettings();
152 m_messagesPanel->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
153 m_allCopperLayers->Hide();
154
155 // Only plot jobs carry these, the board plot settings do not store them
156 m_plotFootprintValues->Hide();
157 m_plotRefDes->Hide();
158 }
159
160 // DIALOG_SHIM needs a unique hash_key because classname will be the same for both job and
161 // non-job versions.
162 m_hash_key = TO_UTF8( GetTitle() );
163
165
166 m_variantChoiceCtrl->Append( board->GetVariantNamesForUI() );
167 m_variantChoiceCtrl->SetSelection( 0 );
168
169 int order = 0;
170 wxArrayInt plotAllLayersOrder;
171 wxArrayString plotAllLayersChoicesStrings;
172 std::vector<PCB_LAYER_ID> layersIdChoiceList;
173 int textWidth = 0;
174
175 for( PCB_LAYER_ID layer : board->GetEnabledLayers().SeqStackupForPlotting() )
176 {
177 wxString layerName = board->GetLayerName( layer );
178
179 // wxCOL_WIDTH_AUTOSIZE doesn't work on all platforms, so we calculate width here
180 textWidth = std::max( textWidth, KIUI::GetTextSize( layerName, m_layerCheckListBox ).x );
181
182 plotAllLayersChoicesStrings.Add( layerName );
183 layersIdChoiceList.push_back( layer );
184
185 if( alg::contains( m_plotOpts.GetPlotOnAllLayersSequence(), layer ) )
186 plotAllLayersOrder.push_back( order );
187 else
188 plotAllLayersOrder.push_back( ~order );
189
190 order += 1;
191 }
192
193 int checkColSize = 22;
194 int layerColSize = textWidth + 15;
195
196#ifdef __WXMAC__
197 // TODO: something in wxWidgets 3.1.x pads checkbox columns with extra space. (It used to
198 // also be that the width of the column would get set too wide (to 30), but that's patched in
199 // our local wxWidgets fork.)
200 checkColSize += 30;
201#endif
202
203 m_layerCheckListBox->SetMinClientSize( wxSize( checkColSize + layerColSize,
204 m_layerCheckListBox->GetMinClientSize().y ) );
205
206 wxStaticBox* allLayersLabel = new wxStaticBox( this, wxID_ANY, _( "Plot on All Layers" ) );
207 wxStaticBoxSizer* sbSizer = new wxStaticBoxSizer( allLayersLabel, wxVERTICAL );
208
209 m_plotAllLayersList = new wxRearrangeList( sbSizer->GetStaticBox(), wxID_ANY,
210 wxDefaultPosition, wxDefaultSize,
211 plotAllLayersOrder, plotAllLayersChoicesStrings, 0 );
212
213 m_plotAllLayersList->SetMinClientSize( wxSize( checkColSize + layerColSize,
214 m_plotAllLayersList->GetMinClientSize().y ) );
215
216 // Attach the LAYER_ID to each item in m_plotAllLayersList
217 // plotAllLayersChoicesStrings and layersIdChoiceList are in the same order,
218 // but m_plotAllLayersList has these strings in a different order
219 for( size_t idx = 0; idx < layersIdChoiceList.size(); idx++ )
220 {
221 wxString& txt = plotAllLayersChoicesStrings[idx];
222 int list_idx = m_plotAllLayersList->FindString( txt, true );
223
224 PCB_LAYER_ID layer_id = layersIdChoiceList[idx];
225 m_plotAllLayersList->SetClientObject( list_idx, new PCB_LAYER_ID_CLIENT_DATA( layer_id ) );
226 }
227
228 sbSizer->Add( m_plotAllLayersList, 1, wxALL | wxEXPAND | wxFIXED_MINSIZE, 3 );
229
230 wxBoxSizer* bButtonSizer;
231 bButtonSizer = new wxBoxSizer( wxHORIZONTAL );
232
233 m_bpMoveUp = new STD_BITMAP_BUTTON( sbSizer->GetStaticBox(), wxID_ANY, wxNullBitmap,
234 wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW | 0 );
235 m_bpMoveUp->SetToolTip( _( "Move current selection up" ) );
237
238 bButtonSizer->Add( m_bpMoveUp, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 3 );
239
240 m_bpMoveDown = new STD_BITMAP_BUTTON( sbSizer->GetStaticBox(), wxID_ANY, wxNullBitmap,
241 wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW | 0 );
242 m_bpMoveDown->SetToolTip( _( "Move current selection down" ) );
244
245 bButtonSizer->Add( m_bpMoveDown, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5 );
246
247 sbSizer->Add( bButtonSizer, 0, wxALL | wxEXPAND, 3 );
248
249 bmiddleSizer->Insert( 1, sbSizer, 1, wxALL | wxEXPAND, 5 );
250
253
254 if( m_job )
255 {
257 }
258 else
259 {
260 SetupStandardButtons( { { wxID_OK, _( "Plot" ) },
261 { wxID_APPLY, _( "Generate Drill Files..." ) },
262 { wxID_CANCEL, _( "Close" ) } } );
263 }
264
265 GetSizer()->Fit( this );
266 GetSizer()->SetSizeHints( this );
267
268 m_bpMoveUp->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveUp, this );
269 m_bpMoveDown->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveDown, this );
270
271 m_layerCheckListBox->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( DIALOG_PLOT::OnRightClickLayers ),
272 nullptr, this );
273
274 m_plotAllLayersList->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( DIALOG_PLOT::OnRightClickAllLayers ),
275 nullptr, this );
276}
277
278
280{
281 s_lastAllLayersOrder.clear();
282
283 for( int ii = 0; ii < (int) m_plotAllLayersList->GetCount(); ++ii )
285
286 m_bpMoveDown->Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveDown, this );
287 m_bpMoveUp->Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveUp, this );
288}
289
290
292{
293 m_colorTheme->Clear();
294
295 for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() )
296 m_colorTheme->Append( settings->GetName(), static_cast<void*>( settings ) );
297}
298
299
300void DIALOG_PLOT::setColorThemeSelection( const wxString& aTheme )
301{
302 wxString target = aTheme;
303
304 if( target.IsEmpty() )
305 {
307 target = cfg ? cfg->m_ColorTheme : DEFAULT_THEME;
308 }
309
310 for( int ii = 0; ii < (int) m_colorTheme->GetCount(); ++ii )
311 {
312 COLOR_SETTINGS* settings = static_cast<COLOR_SETTINGS*>( m_colorTheme->GetClientData( ii ) );
313
314 if( settings && ( settings->GetFilename() == target || settings->GetName().Lower() == target.Lower() ) )
315 {
316 m_colorTheme->SetSelection( ii );
317 return;
318 }
319 }
320
321 if( m_colorTheme->GetCount() > 0 )
322 m_colorTheme->SetSelection( 0 );
323}
324
325
327{
329 return ::GetColorSettings( cfg ? cfg->m_ColorTheme : DEFAULT_THEME );
330}
331
332
334{
335 int selection = m_colorTheme->GetSelection();
336
337 if( selection >= 0 && selection < (int) m_colorTheme->GetCount() )
338 {
339 if( COLOR_SETTINGS* settings = static_cast<COLOR_SETTINGS*>( m_colorTheme->GetClientData( selection ) ) )
340 {
341 return settings;
342 }
343 }
344
345 return getEditorColorSettings();
346}
347
348
350{
351 switch( getPlotFormat() )
352 {
353 case PLOT_FORMAT::SVG:
354 case PLOT_FORMAT::PDF:
355 case PLOT_FORMAT::PNG: return true;
356
357 default: return false;
358 }
359}
360
361
363{
364 bool enable = formatUsesColorTheme();
365
367 enable = enable && m_SVGColorChoice->GetSelection() == 0;
368 else if( getPlotFormat() == PLOT_FORMAT::PDF )
369 enable = enable && m_PDFColorChoice->GetSelection() == 0;
370
371 m_colorThemeLabel->Enable( enable );
372 m_colorTheme->Enable( enable );
373}
374
375
377{
378 BOARD* board = m_editFrame->GetBoard();
379 wxFileName fileName;
380
381 PROJECT_FILE& projectFile = m_editFrame->Prj().GetProjectFile();
382
383 // Could devote a PlotOrder() function in place of UIOrder().
385
386 // Select the current board variant in the variant choice
387 if( m_job )
388 {
389 m_plotFootprintValues->SetValue( m_plotOpts.GetPlotValue() );
390 m_plotRefDes->SetValue( m_plotOpts.GetPlotReference() );
391
392 if( !m_job->m_variant.IsEmpty() )
393 {
394 int idx = m_variantChoiceCtrl->FindString( m_job->m_variant );
395
396 if( idx != wxNOT_FOUND )
397 m_variantChoiceCtrl->SetSelection( idx );
398 }
399 }
400 else
401 {
402 wxString currentVariant = board->GetCurrentVariant();
403
404 if( !currentVariant.IsEmpty() )
405 {
406 int idx = m_variantChoiceCtrl->FindString( currentVariant );
407
408 if( idx != wxNOT_FOUND )
409 m_variantChoiceCtrl->SetSelection( idx );
410 }
411 }
412
413 setColorThemeSelection( m_job ? m_job->m_colorTheme : wxString() );
414
415 if( !m_job && !projectFile.m_PcbLastPath[ LAST_PATH_PLOT ].IsEmpty() )
416 m_plotOpts.SetOutputDirectory( projectFile.m_PcbLastPath[ LAST_PATH_PLOT ] );
417
418 if( m_job
419 && !( m_job->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::POST
420 && static_cast<JOB_EXPORT_PCB_PS*>( m_job )->m_useGlobalSettings ) )
421 {
422 // When we are using a job we get the PS adjust values from the plot options
423 // The exception is when this is a fresh job and we want to get the global values as defaults
425 m_plotOpts.GetFineScaleAdjustX() ) );
426
428 m_plotOpts.GetFineScaleAdjustY() ) );
429 m_trackWidthCorrection.SetValue( m_plotOpts.GetWidthAdjust() );
430 m_zoneFillCheck->SetValue( m_job->m_checkZonesBeforePlot );
431 }
432
433 // The reasonable width correction value must be in a range of
434 // [-(MinTrackWidth-1), +(MinClearanceValue-1)] decimils.
435 m_widthAdjustMinValue = -( board->GetDesignSettings().m_TrackMinWidth - 1 );
437
438 switch( m_plotOpts.GetFormat() )
439 {
440 default:
441 case PLOT_FORMAT::GERBER: m_plotFormatOpt->SetSelection( 0 ); break;
442 case PLOT_FORMAT::POST: m_plotFormatOpt->SetSelection( 1 ); break;
443 case PLOT_FORMAT::SVG: m_plotFormatOpt->SetSelection( 2 ); break;
444 case PLOT_FORMAT::DXF: m_plotFormatOpt->SetSelection( 3 ); break;
445 case PLOT_FORMAT::HPGL: /* no longer supported */ break;
446 case PLOT_FORMAT::PDF: m_plotFormatOpt->SetSelection( 4 ); break;
447 case PLOT_FORMAT::PNG: m_plotFormatOpt->SetSelection( 5 ); break;
448 }
449
450 m_plotPSNegativeOpt->SetValue( m_plotOpts.GetNegative() );
451 m_forcePSA4OutputOpt->SetValue( m_plotOpts.GetA4Output() );
452
453 // Populate the check list box by all enabled layers names.
454 for( PCB_LAYER_ID layer : m_layerList )
455 {
456 int checkIndex = m_layerCheckListBox->Append( board->GetLayerName( layer ) );
457
458 if( m_plotOpts.GetLayerSelection()[layer] )
459 m_layerCheckListBox->Check( checkIndex );
460 }
461
462 if( m_job )
463 {
464 // A new Gerber job starts with every copper layer, as a fabrication set needs them all
465 bool newGerberJob = m_job->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::GERBER
466 && m_job->m_plotLayerSequence.empty();
467
468 m_allCopperLayers->SetValue( m_job->m_plotAllCopperLayers || newGerberJob );
469
470 if( m_allCopperLayers->GetValue() )
472 }
473
475
476 // Option for disabling Gerber Aperture Macro (for broken Gerber readers)
477 m_disableApertMacros->SetValue( m_plotOpts.GetDisableGerberMacros() );
478
479 // Option for using proper Gerber extensions. Note also Protel extensions are
480 // a broken feature. However, for now, we need to handle it.
481 m_useGerberExtensions->SetValue( m_plotOpts.GetUseGerberProtelExtensions() );
482
483 // Option for including Gerber attributes, from Gerber X2 format, in the output
484 // In X1 format, they will be added as comments
485 m_useGerberX2Format->SetValue( m_plotOpts.GetUseGerberX2format() );
486
487 // Option for including Gerber netlist info (from Gerber X2 format) in the output
488 m_useGerberNetAttributes->SetValue( m_plotOpts.GetIncludeGerberNetlistInfo() );
489
490 // Option to generate a Gerber job file
491 m_generateGerberJobFile->SetValue( m_plotOpts.GetCreateGerberJobFile() );
492
493 // Gerber precision for coordinates
494 m_coordFormatCtrl->SetSelection( m_plotOpts.GetGerberPrecision() == 5 ? 0 : 1 );
495
496 // SVG precision and units for coordinates
497 m_svgPrecsision->SetValue( m_plotOpts.GetSvgPrecision() );
498 m_SVG_fitPageToBoard->SetValue( m_plotOpts.GetSvgFitPagetoBoard() );
499
500 // PNG options
501 m_pngDPI->SetValue( m_plotOpts.GetPngDPI() );
502 m_pngAntialias->SetValue( m_plotOpts.GetPngAntialias() );
503
504 m_sketchPadsOnFabLayers->SetValue( m_plotOpts.GetSketchPadsOnFabLayers() );
505 m_plotPadNumbers->SetValue( m_plotOpts.GetPlotPadNumbers() );
506 m_plotPadNumbers->Enable( m_plotOpts.GetSketchPadsOnFabLayers() );
507
508 m_plotDNP->SetValue( m_plotOpts.GetHideDNPFPsOnFabLayers()
509 || m_plotOpts.GetSketchDNPFPsOnFabLayers()
510 || m_plotOpts.GetCrossoutDNPFPsOnFabLayers() );
511
512 if( m_plotDNP->GetValue() )
513 {
514 if( m_plotOpts.GetHideDNPFPsOnFabLayers() )
515 m_hideDNP->SetValue( true );
516 else
517 m_crossoutDNP->SetValue( true );
518 }
519
520 m_hideDNP->Enable( m_plotDNP->GetValue() );
521 m_crossoutDNP->Enable( m_plotDNP->GetValue() );
522
523 m_subtractMaskFromSilk->SetValue( m_plotOpts.GetSubtractMaskFromSilk() );
524
525 m_useAuxOriginCheckBox->SetValue( m_plotOpts.GetUseAuxOrigin() );
526
527 m_plotSheetRef->SetValue( m_plotOpts.GetPlotFrameRef() );
528
529 // Options to plot pads and vias holes
530 m_drillShapeOpt->SetSelection( (int) m_plotOpts.GetDrillMarksType() );
531
532 // Scale option
533 m_scaleOpt->SetSelection( m_plotOpts.GetScaleSelection() );
534
535 // DXF outline mode
536 m_DXF_plotModeOpt->SetValue( m_plotOpts.GetDXFPlotPolygonMode() );
537
538 // DXF text mode
540
541 // DXF units selection
542 m_DXF_plotUnits->SetSelection( m_plotOpts.GetDXFPlotUnits() == DXF_UNITS::INCH ? 0 : 1 );
543
544 // Job only, PCB_PLOTTER honours this flag for non-DXF formats too
545 if( m_job )
546 m_DXF_exportAsMultiLayeredFile->SetValue( m_plotOpts.GetDXFMultiLayeredExportOption() );
547
548 // Plot mirror option
549 m_plotMirrorOpt->SetValue( m_plotOpts.GetMirror() );
550
551 // Black and white plotting
552 m_SVGColorChoice->SetSelection( m_plotOpts.GetBlackAndWhite() ? 1 : 0 );
553 m_PDFColorChoice->SetSelection( m_plotOpts.GetBlackAndWhite() ? 1 : 0 );
554 m_frontFPPropertyPopups->SetValue( m_plotOpts.m_PDFFrontFPPropertyPopups );
555 m_backFPPropertyPopups->SetValue( m_plotOpts.m_PDFBackFPPropertyPopups );
556 m_pdfMetadata->SetValue( m_plotOpts.m_PDFMetadata );
557 m_pdfSingle->SetValue( m_plotOpts.m_PDFSingle );
558 m_pdfBackgroundColorSwatch->SetSwatchColor( m_plotOpts.m_backgroundColor, false );
560
561 // Initialize a few other parameters, which can also be modified
562 // from the drill dialog
563 reInitDialog();
564
565 // Update options values:
566 wxCommandEvent cmd_event;
567 SetPlotFormat( cmd_event );
568
569 if( m_job )
571
572 return true;
573}
574
575
577{
579 bool singleFile = ( fmt == PLOT_FORMAT::PDF && m_pdfSingle->GetValue() )
580 || ( fmt == PLOT_FORMAT::DXF && m_DXF_exportAsMultiLayeredFile->GetValue() );
581
582 wxString label = singleFile ? _( "Output file:" ) : _( "Output directory:" );
583
584 if( m_staticTextDir->GetLabel() == label )
585 return;
586
587 m_staticTextDir->SetLabel( label );
588
589 if( singleFile )
590 {
591 m_outputDirectoryName->SetToolTip( _( "Target file for the plot. Can be absolute or relative to the board "
592 "file location." ) );
593 }
594 else
595 {
596 m_outputDirectoryName->SetToolTip( _( "Target directory for plot files. Can be absolute or relative to "
597 "the board file location." ) );
598 }
599
600 Layout();
601}
602
603
605{
607 {
608 JOB_EXPORT_PCB_GERBERS* gJob = static_cast<JOB_EXPORT_PCB_GERBERS*>( m_job );
609 gJob->m_disableApertureMacros = m_plotOpts.GetDisableGerberMacros();
610 gJob->m_useProtelFileExtension = m_plotOpts.GetUseGerberProtelExtensions();
611 gJob->m_useX2Format = m_plotOpts.GetUseGerberX2format();
612 gJob->m_includeNetlistAttributes = m_plotOpts.GetIncludeGerberNetlistInfo();
613 gJob->m_createJobsFile = m_plotOpts.GetCreateGerberJobFile();
614 gJob->m_precision = m_plotOpts.GetGerberPrecision();
615 gJob->m_useBoardPlotParams = false;
616 }
617 else
618 {
619 m_job->m_scale = selectionToScale( m_plotOpts.GetScaleSelection() );
620 }
621
622 if( m_job->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::SVG )
623 {
624 JOB_EXPORT_PCB_SVG* svgJob = static_cast<JOB_EXPORT_PCB_SVG*>( m_job );
625 svgJob->m_precision = m_plotOpts.GetSvgPrecision();
627 svgJob->m_fitPageToBoard = m_plotOpts.GetSvgFitPagetoBoard();
628 }
629
630 if( m_job->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::DXF )
631 {
632 JOB_EXPORT_PCB_DXF* dxfJob = static_cast<JOB_EXPORT_PCB_DXF*>( m_job );
636 dxfJob->m_polygonMode = m_plotOpts.GetDXFPlotPolygonMode();
637 dxfJob->m_useKiCadFont = m_plotOpts.GetTextMode() != PLOT_TEXT_MODE::NATIVE;
638 dxfJob->m_genMode = m_plotOpts.GetDXFMultiLayeredExportOption() ? JOB_EXPORT_PCB_DXF::GEN_MODE::SINGLE
640 }
641
642 if( m_job->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::POST )
643 {
644 JOB_EXPORT_PCB_PS* psJob = static_cast<JOB_EXPORT_PCB_PS*>( m_job );
646 psJob->m_XScaleAdjust = m_plotOpts.GetFineScaleAdjustX();
647 psJob->m_YScaleAdjust = m_plotOpts.GetFineScaleAdjustY();
648 psJob->m_trackWidthCorrection = pcbIUScale.IUTomm( m_plotOpts.GetWidthAdjust() );
649 psJob->m_forceA4 = m_plotOpts.GetA4Output();
650 // For a fresh job we got the adjusts from the global pcbnew settings
651 // After the user confirmed and/or changed them we stop using the global adjusts
652 psJob->m_useGlobalSettings = false;
653 }
654
655 if( m_job->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::PDF )
656 {
657 JOB_EXPORT_PCB_PDF* pdfJob = static_cast<JOB_EXPORT_PCB_PDF*>( m_job );
658 pdfJob->m_pdfFrontFPPropertyPopups = m_plotOpts.m_PDFFrontFPPropertyPopups;
659 pdfJob->m_pdfBackFPPropertyPopups = m_plotOpts.m_PDFBackFPPropertyPopups;
660 pdfJob->m_pdfMetadata = m_plotOpts.m_PDFMetadata;
661 pdfJob->m_pdfSingle = m_plotOpts.m_PDFSingle;
662 pdfJob->m_pdfBackgroundColor = m_plotOpts.m_backgroundColor.ToCSSString();
663
664 // we need to embed this for the cli deprecation fix
665 if( pdfJob->m_pdfSingle )
666 {
668 }
669 else
670 {
672 }
673 }
674
675 if( m_job->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::PNG )
676 {
677 JOB_EXPORT_PCB_PNG* pngJob = static_cast<JOB_EXPORT_PCB_PNG*>( m_job );
678 pngJob->m_dpi = m_plotOpts.GetPngDPI();
679 pngJob->m_antialias = m_plotOpts.GetPngAntialias();
680 }
681
682 m_job->m_subtractSolderMaskFromSilk = m_plotOpts.GetSubtractMaskFromSilk();
683 m_job->m_useDrillOrigin = m_plotOpts.GetUseAuxOrigin();
684 m_job->m_crossoutDNPFPsOnFabLayers = m_plotOpts.GetCrossoutDNPFPsOnFabLayers();
685 m_job->m_hideDNPFPsOnFabLayers = m_plotOpts.GetHideDNPFPsOnFabLayers();
686 m_job->m_sketchDNPFPsOnFabLayers = m_plotOpts.GetSketchDNPFPsOnFabLayers();
687 m_job->m_sketchPadsOnFabLayers = m_plotOpts.GetSketchPadsOnFabLayers();
688
689 m_job->m_plotDrawingSheet = m_plotOpts.GetPlotFrameRef();
690 m_job->m_plotPadNumbers = m_plotOpts.GetPlotPadNumbers();
691 m_job->m_plotFootprintValues = m_plotOpts.GetPlotValue();
692 m_job->m_plotRefDes = m_plotOpts.GetPlotReference();
693
694 m_job->m_blackAndWhite = m_plotOpts.GetBlackAndWhite();
695 m_job->m_mirror = m_plotOpts.GetMirror();
696 m_job->m_negative = m_plotOpts.GetNegative();
697 m_job->m_plotLayerSequence = m_plotOpts.GetLayerSelection().SeqStackupForPlotting();
698 m_job->m_plotAllCopperLayers = m_allCopperLayers->GetValue() && allCopperLayersChecked();
699 m_job->m_plotOnAllLayersSequence = m_plotOpts.GetPlotOnAllLayersSequence();
700
701 // An empty theme follows the PCB editor at run time, so leave it that way until the user picks one.
702 if( formatUsesColorTheme() && ( !m_job->m_colorTheme.IsEmpty() || getColorSettings() != getEditorColorSettings() ) )
703 {
704 m_job->m_colorTheme = getColorSettings()->GetFilename();
705 }
706
707 if( m_job->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::SVG ||
709 {
710 switch( m_plotOpts.GetDrillMarksType() )
711 {
712 case DRILL_MARKS::NO_DRILL_SHAPE: m_job->m_drillShapeOption = DRILL_MARKS::NO_DRILL_SHAPE; break;
714 default:
715 case DRILL_MARKS::FULL_DRILL_SHAPE: m_job->m_drillShapeOption = DRILL_MARKS::FULL_DRILL_SHAPE; break;
716 }
717 }
718
719 m_job->SetConfiguredOutputPath( m_plotOpts.GetOutputDirectory() );
720
721 // this exists outside plot opts because its usually globally saved
722 m_job->m_checkZonesBeforePlot = m_zoneFillCheck->GetValue();
723
724 m_job->m_variant = getSelectedVariant();
725}
726
727
729{
730 // after calling the Drill or DRC dialogs some parameters can be modified....
731
732 // Output directory
733 m_outputDirectoryName->SetValue( m_plotOpts.GetOutputDirectory() );
734
735 // Origin of coordinates:
736 m_useAuxOriginCheckBox->SetValue( m_plotOpts.GetUseAuxOrigin() );
737
738 int knownViolations = 0;
739 int exclusions = 0;
740
741 for( PCB_MARKER* marker : m_editFrame->GetBoard()->Markers() )
742 {
743 if( marker->GetSeverity() == RPT_SEVERITY_EXCLUSION )
744 exclusions++;
745 else
746 knownViolations++;
747 }
748
749 if( !m_job && ( knownViolations || exclusions ) )
750 {
751 m_DRCExclusionsWarning->SetLabel( wxString::Format( m_DRCWarningTemplate, knownViolations,
752 exclusions ) );
754 }
755 else
756 {
758 }
759
760 BOARD* board = m_editFrame->GetBoard();
761 const BOARD_DESIGN_SETTINGS& brd_settings = board->GetDesignSettings();
762
764 ( brd_settings.m_SolderMaskExpansion || brd_settings.m_SolderMaskMinWidth ) )
765 {
767 }
768 else
769 {
771 }
772}
773
774
776{
777 wxString variant;
778 int selection = m_variantChoiceCtrl->GetSelection();
779
780 if( ( selection != 0 ) && ( selection != wxNOT_FOUND ) )
781 variant = m_variantChoiceCtrl->GetString( selection );
782
783 return variant;
784}
785
786
788{
789 auto findLayer =
790 [&]( wxRearrangeList* aList, PCB_LAYER_ID aLayer ) -> int
791 {
792 for( int ii = 0; ii < (int) aList->GetCount(); ++ii )
793 {
794 if( getLayerClientData( aList, ii )->Layer() == aLayer )
795 return ii;
796 }
797
798 return -1;
799 };
800
801 int idx = 0;
802
803 for( PCB_LAYER_ID layer : aSeq )
804 {
805 int currentPos = findLayer( m_plotAllLayersList, layer );
806
807 while( currentPos > idx )
808 {
809 m_plotAllLayersList->Select( currentPos );
810 m_plotAllLayersList->MoveCurrentUp();
811 currentPos--;
812 }
813
814 idx++;
815 }
816}
817
818
819#define ID_LAYER_FAB 13001
820#define ID_SELECT_COPPER_LAYERS 13002
821#define ID_DESELECT_COPPER_LAYERS 13003
822#define ID_SELECT_ALL_LAYERS 13004
823#define ID_DESELECT_ALL_LAYERS 13005
824#define ID_STACKUP_ORDER 13006
825
826
827// A helper function to show a popup menu, when the dialog is right clicked.
828void DIALOG_PLOT::OnRightClickLayers( wxMouseEvent& event )
829{
830 // Build a list of layers for usual fabrication: copper layers + tech layers without courtyard
831 LSET fab_layer_set = ( LSET::AllCuMask() | LSET::AllTechMask() ) & ~LSET( { B_CrtYd, F_CrtYd } );
832
833 wxMenu menu;
834 menu.Append( new wxMenuItem( &menu, ID_LAYER_FAB, _( "Select Fab Layers" ) ) );
835
836 menu.AppendSeparator();
837 menu.Append( new wxMenuItem( &menu, ID_SELECT_COPPER_LAYERS, _( "Select All Copper Layers" ) ) );
838 menu.Append( new wxMenuItem( &menu, ID_DESELECT_COPPER_LAYERS, _( "Deselect All Copper Layers" ) ) );
839
840 menu.AppendSeparator();
841 menu.Append( new wxMenuItem( &menu, ID_SELECT_ALL_LAYERS, _( "Select All Layers" ) ) );
842 menu.Append( new wxMenuItem( &menu, ID_DESELECT_ALL_LAYERS, _( "Deselect All Layers" ) ) );
843
844 menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
845 [&]( wxCommandEvent& aCmd )
846 {
847 switch( aCmd.GetId() )
848 {
849 case ID_LAYER_FAB: // Select layers usually needed to build a board
850 {
851 for( unsigned i = 0; i < m_layerList.size(); i++ )
852 {
853 LSET layermask( { m_layerList[ i ] } );
854
855 if( ( layermask & fab_layer_set ).any() )
856 m_layerCheckListBox->Check( i, true );
857 else
858 m_layerCheckListBox->Check( i, false );
859 }
860
861 break;
862 }
863
865 for( unsigned i = 0; i < m_layerList.size(); i++ )
866 {
867 if( IsCopperLayer( m_layerList[i] ) )
868 m_layerCheckListBox->Check( i, true );
869 }
870
871 break;
872
874 for( unsigned i = 0; i < m_layerList.size(); i++ )
875 {
876 if( IsCopperLayer( m_layerList[i] ) )
877 m_layerCheckListBox->Check( i, false );
878 }
879
880 break;
881
883 for( unsigned i = 0; i < m_layerList.size(); i++ )
884 m_layerCheckListBox->Check( i, true );
885
886 break;
887
889 for( unsigned i = 0; i < m_layerList.size(); i++ )
890 m_layerCheckListBox->Check( i, false );
891
892 break;
893
894 default:
895 aCmd.Skip();
896 }
897 } );
898
899 PopupMenu( &menu );
900
903}
904
905
907{
908 for( unsigned i = 0; i < m_layerList.size(); i++ )
909 {
910 if( IsCopperLayer( m_layerList[i] ) )
911 m_layerCheckListBox->Check( i, true );
912 }
913}
914
915
917{
918 for( unsigned i = 0; i < m_layerList.size(); i++ )
919 {
920 if( IsCopperLayer( m_layerList[i] ) && !m_layerCheckListBox->IsChecked( i ) )
921 return false;
922 }
923
924 return true;
925}
926
927
929{
930 if( m_allCopperLayers->GetValue() && !allCopperLayersChecked() )
931 {
932 m_allCopperLayers->SetValue( false );
934 }
935}
936
937
938void DIALOG_PLOT::onLayerToggled( wxCommandEvent& event )
939{
941 event.Skip();
942}
943
944
945void DIALOG_PLOT::onAllCopperLayers( wxCommandEvent& event )
946{
947 if( m_allCopperLayers->GetValue() )
948 {
951 }
952
953 event.Skip();
954}
955
956
957void DIALOG_PLOT::OnRightClickAllLayers( wxMouseEvent& event )
958{
959 wxMenu menu;
960 menu.Append( new wxMenuItem( &menu, ID_SELECT_ALL_LAYERS, _( "Select All Layers" ) ) );
961 menu.Append( new wxMenuItem( &menu, ID_DESELECT_ALL_LAYERS, _( "Deselect All Layers" ) ) );
962
963 menu.AppendSeparator();
964 menu.Append( new wxMenuItem( &menu, ID_STACKUP_ORDER, _( "Order as Board Stackup" ) ) );
965
966 menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
967 [&]( wxCommandEvent& aCmd )
968 {
969 switch( aCmd.GetId() )
970 {
972 for( unsigned i = 0; i < m_plotAllLayersList->GetCount(); i++ )
973 m_plotAllLayersList->Check( i, true );
974
975 break;
976
978 for( unsigned i = 0; i < m_plotAllLayersList->GetCount(); i++ )
979 m_plotAllLayersList->Check( i, false );
980
981 break;
982
983 case ID_STACKUP_ORDER:
984 {
985 LSEQ stackup = m_editFrame->GetBoard()->GetEnabledLayers().SeqStackupForPlotting();
986 arrangeAllLayersList( stackup );
987 m_plotAllLayersList->Select( -1 );
988 break;
989 }
990
991 default:
992 aCmd.Skip();
993 }
994 } );
995
996 PopupMenu( &menu );
997}
998
999
1000void DIALOG_PLOT::CreateDrillFile( wxCommandEvent& event )
1001{
1002 // Be sure drill file use the same settings (axis option, plot directory) as plot files:
1004
1005 DIALOG_GENDRILL dlg( m_editFrame, this );
1006 dlg.ShowModal();
1007
1008 // a few plot settings can be modified: take them in account
1009 m_plotOpts = m_editFrame->GetPlotSettings();
1010 reInitDialog();
1011}
1012
1013
1014void DIALOG_PLOT::OnChangeDXFPlotMode( wxCommandEvent& event )
1015{
1016 // m_DXF_plotTextStrokeFontOpt is disabled if m_DXF_plotModeOpt is checked (plot in DXF
1017 // polygon mode)
1018 m_DXF_plotTextStrokeFontOpt->Enable( !m_DXF_plotModeOpt->GetValue() );
1019
1020 // if m_DXF_plotTextStrokeFontOpt option is disabled (plot DXF in polygon mode), force
1021 // m_DXF_plotTextStrokeFontOpt to true to use Pcbnew stroke font
1022 if( !m_DXF_plotTextStrokeFontOpt->IsEnabled() )
1023 m_DXF_plotTextStrokeFontOpt->SetValue( true );
1024}
1025
1026
1028{
1029 // Build the absolute path of current output directory to preselect it in the file browser.
1030 std::function<bool( wxString* )> textResolver =
1031 [&]( wxString* token ) -> bool
1032 {
1033 return m_editFrame->GetBoard()->ResolveTextVar( token, 0 );
1034 };
1035
1036 wxString path = ResolveProjectPath( m_outputDirectoryName->GetValue(), &Prj(), &textResolver );
1037
1038 wxDirDialog dirDialog( this, _( "Select Output Directory" ), path );
1039
1040 if( dirDialog.ShowModal() == wxID_CANCEL )
1041 return;
1042
1043 wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
1044
1045 wxFileName fn( Prj().AbsolutePath( m_editFrame->GetBoard()->GetFileName() ) );
1046 wxString defaultPath = fn.GetPathWithSep();
1047 wxFileName relPathTest; // Used to test if we can make the path relative
1048
1049 relPathTest.Assign( dirDialog.GetPath() );
1050
1051 // Test if making the path relative is possible before asking the user if they want to do it
1052 if( relPathTest.MakeRelativeTo( defaultPath ) )
1053 {
1054 if( IsOK( this, wxString::Format( _( "Do you want to use a path relative to\n'%s'?" ), defaultPath ) ) )
1055 dirName.MakeRelativeTo( defaultPath );
1056 }
1057
1058 m_outputDirectoryName->SetValue( dirName.GetFullPath() );
1059}
1060
1061
1063{
1064 // plot format id's are ordered like displayed in m_plotFormatOpt
1065 static const PLOT_FORMAT plotFmt[] = {
1072
1073 return plotFmt[m_plotFormatOpt->GetSelection()];
1074}
1075
1076
1077void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
1078{
1079 // this option exist only in DXF format:
1081
1082 // The alert message about non 0 solder mask min width and margin is shown
1083 // only in gerber format and if min mask width or mask margin is not 0
1084 BOARD* board = m_editFrame->GetBoard();
1085 const BOARD_DESIGN_SETTINGS& brd_settings = board->GetDesignSettings();
1086
1088 && ( brd_settings.m_SolderMaskExpansion || brd_settings.m_SolderMaskMinWidth ) )
1089 {
1091 }
1092 else
1093 {
1095 }
1096
1097 wxSizer* shownFormatSizer = nullptr;
1098
1099 switch( getPlotFormat() )
1100 {
1101 case PLOT_FORMAT::SVG:
1102 case PLOT_FORMAT::PDF:
1103 m_drillShapeOpt->Enable( true );
1104 m_plotMirrorOpt->Enable( true );
1105 m_useAuxOriginCheckBox->Enable( true );
1106 m_scaleOpt->Enable( true );
1107 m_fineAdjustXCtrl->Enable( false );
1108 m_fineAdjustYCtrl->Enable( false );
1109 m_trackWidthCorrection.Enable( false );
1110 m_plotPSNegativeOpt->Enable( true );
1111 m_forcePSA4OutputOpt->Enable( false );
1112 m_forcePSA4OutputOpt->SetValue( false );
1113
1114 shownFormatSizer = ( getPlotFormat() == PLOT_FORMAT::SVG ) ? m_svgOptionsSizer : m_PDFOptionsSizer;
1115 break;
1116
1117 case PLOT_FORMAT::POST:
1118 m_drillShapeOpt->Enable( true );
1119 m_plotMirrorOpt->Enable( true );
1120 m_useAuxOriginCheckBox->Enable( false );
1121 m_useAuxOriginCheckBox->SetValue( false );
1122 m_scaleOpt->Enable( true );
1123 m_fineAdjustXCtrl->Enable( true );
1124 m_fineAdjustYCtrl->Enable( true );
1125 m_trackWidthCorrection.Enable( true );
1126 m_plotPSNegativeOpt->Enable( true );
1127 m_forcePSA4OutputOpt->Enable( true );
1128
1129 shownFormatSizer = m_PSOptionsSizer;
1130 break;
1131
1133 m_drillShapeOpt->Enable( false );
1134 m_drillShapeOpt->SetSelection( 0 );
1135 m_plotMirrorOpt->Enable( false );
1136 m_plotMirrorOpt->SetValue( false );
1137 m_useAuxOriginCheckBox->Enable( true );
1138 m_scaleOpt->Enable( false );
1139 m_scaleOpt->SetSelection( 1 );
1140 m_fineAdjustXCtrl->Enable( false );
1141 m_fineAdjustYCtrl->Enable( false );
1142 m_trackWidthCorrection.Enable( false );
1143 m_plotPSNegativeOpt->Enable( false );
1144 m_plotPSNegativeOpt->SetValue( false );
1145 m_forcePSA4OutputOpt->Enable( false );
1146 m_forcePSA4OutputOpt->SetValue( false );
1147
1148 shownFormatSizer = m_GerberOptionsSizer;
1149 break;
1150
1151 case PLOT_FORMAT::DXF:
1152 m_drillShapeOpt->Enable( true );
1153 m_plotMirrorOpt->Enable( false );
1154 m_plotMirrorOpt->SetValue( false );
1155 m_useAuxOriginCheckBox->Enable( true );
1156 m_scaleOpt->Enable( true );
1157 m_fineAdjustXCtrl->Enable( false );
1158 m_fineAdjustYCtrl->Enable( false );
1159 m_trackWidthCorrection.Enable( false );
1160 m_plotPSNegativeOpt->Enable( false );
1161 m_plotPSNegativeOpt->SetValue( false );
1162 m_forcePSA4OutputOpt->Enable( false );
1163 m_forcePSA4OutputOpt->SetValue( false );
1164
1165 shownFormatSizer = m_SizerDXF_options;
1166 OnChangeDXFPlotMode( event );
1167 break;
1168
1169 case PLOT_FORMAT::PNG:
1170 m_drillShapeOpt->Enable( true );
1171 m_plotMirrorOpt->Enable( true );
1172 m_useAuxOriginCheckBox->Enable( true );
1173 m_scaleOpt->Enable( true );
1174 m_fineAdjustXCtrl->Enable( false );
1175 m_fineAdjustYCtrl->Enable( false );
1176 m_trackWidthCorrection.Enable( false );
1177 m_plotPSNegativeOpt->Enable( true );
1178 m_forcePSA4OutputOpt->Enable( false );
1179 m_forcePSA4OutputOpt->SetValue( false );
1180
1181 shownFormatSizer = m_pngOptionsSizer;
1182 break;
1183
1184 default:
1185 case PLOT_FORMAT::HPGL:
1187 break;
1188 }
1189
1190 for( wxSizer* formatSizer : { m_GerberOptionsSizer, m_PSOptionsSizer, m_SizerDXF_options,
1192 {
1193 m_PlotOptionsSizer->Show( formatSizer, formatSizer == shownFormatSizer );
1194 }
1195
1197
1198 Layout();
1199 m_MainSizer->SetSizeHints( this );
1200}
1201
1202
1203// A helper function to "clip" aValue between aMin and aMax and write result in * aResult
1204// return false if clipped, true if aValue is just copied into * aResult
1205static bool setDouble( double* aResult, double aValue, double aMin, double aMax )
1206{
1207 if( aValue < aMin )
1208 {
1209 *aResult = aMin;
1210 return false;
1211 }
1212 else if( aValue > aMax )
1213 {
1214 *aResult = aMax;
1215 return false;
1216 }
1217
1218 *aResult = aValue;
1219 return true;
1220}
1221
1222
1223static bool setInt( int* aResult, int aValue, int aMin, int aMax )
1224{
1225 if( aValue < aMin )
1226 {
1227 *aResult = aMin;
1228 return false;
1229 }
1230 else if( aValue > aMax )
1231 {
1232 *aResult = aMax;
1233 return false;
1234 }
1235
1236 *aResult = aValue;
1237 return true;
1238}
1239
1240
1242{
1243 REPORTER& reporter = m_messagesPanel->Reporter();
1244 PCB_PLOT_PARAMS tempOptions;
1245
1246 tempOptions.SetDashedLineDashRatio( m_plotOpts.GetDashedLineDashRatio() );
1247 tempOptions.SetDashedLineGapRatio( m_plotOpts.GetDashedLineGapRatio() );
1248
1249 tempOptions.SetSubtractMaskFromSilk( m_subtractMaskFromSilk->GetValue() );
1250 tempOptions.SetPlotFrameRef( m_plotSheetRef->GetValue() );
1251 tempOptions.SetSketchPadsOnFabLayers( m_sketchPadsOnFabLayers->GetValue() );
1252 tempOptions.SetPlotPadNumbers( m_plotPadNumbers->GetValue() );
1253 tempOptions.SetPlotValue( !m_job || m_plotFootprintValues->GetValue() );
1254 tempOptions.SetPlotReference( !m_job || m_plotRefDes->GetValue() );
1255 tempOptions.SetHideDNPFPsOnFabLayers( m_plotDNP->GetValue()
1256 && m_hideDNP->GetValue() );
1257 tempOptions.SetSketchDNPFPsOnFabLayers( m_plotDNP->GetValue()
1258 && m_crossoutDNP->GetValue() );
1259 tempOptions.SetCrossoutDNPFPsOnFabLayers( m_plotDNP->GetValue()
1260 && m_crossoutDNP->GetValue() );
1261 tempOptions.SetUseAuxOrigin( m_useAuxOriginCheckBox->GetValue() );
1262 tempOptions.SetScaleSelection( m_scaleOpt->GetSelection() );
1263
1264 int sel = m_drillShapeOpt->GetSelection();
1265 tempOptions.SetDrillMarksType( static_cast<DRILL_MARKS>( sel ) );
1266
1267 tempOptions.SetMirror( m_plotMirrorOpt->GetValue() );
1268 tempOptions.SetDXFPlotPolygonMode( m_DXF_plotModeOpt->GetValue() );
1269
1270 sel = m_DXF_plotUnits->GetSelection();
1271 tempOptions.SetDXFPlotUnits( sel == 0 ? DXF_UNITS::INCH : DXF_UNITS::MM );
1272
1273 if( !m_DXF_plotTextStrokeFontOpt->IsEnabled() ) // Currently, only DXF supports this option
1274 {
1275 tempOptions.SetTextMode( PLOT_TEXT_MODE::DEFAULT );
1276 }
1277 else
1278 {
1281 }
1282
1284
1286 {
1287 tempOptions.SetBlackAndWhite( m_SVGColorChoice->GetSelection() == 1 );
1288 }
1289 else if( getPlotFormat() == PLOT_FORMAT::PDF )
1290 {
1291 tempOptions.SetBlackAndWhite( m_PDFColorChoice->GetSelection() == 1 );
1292 tempOptions.m_PDFFrontFPPropertyPopups = m_frontFPPropertyPopups->GetValue();
1293 tempOptions.m_PDFBackFPPropertyPopups = m_backFPPropertyPopups->GetValue();
1294 tempOptions.m_PDFMetadata = m_pdfMetadata->GetValue();
1295 tempOptions.m_PDFSingle = m_pdfSingle->GetValue();
1296 tempOptions.m_backgroundColor = m_pdfBackgroundColorSwatch->GetSwatchColor();
1297 }
1298 else if( getPlotFormat() == PLOT_FORMAT::PNG )
1299 {
1300 // Match the CLI default; a dedicated UI control will be added with the next .fbp regen.
1301 tempOptions.SetBlackAndWhite( false );
1302 }
1303 else
1304 {
1305 tempOptions.SetBlackAndWhite( true );
1306 }
1307
1308 // Update settings from text fields. Rewrite values back to the fields,
1309 // since the values may have been constrained by the setters.
1310
1311 // X scale
1312 double tmpDouble;
1313 wxString msg = m_fineAdjustXCtrl->GetValue();
1314 msg.ToDouble( &tmpDouble );
1315
1317 {
1318 msg.Printf( wxT( "%f" ), m_XScaleAdjust );
1319 m_fineAdjustXCtrl->SetValue( msg );
1320 msg.Printf( _( "X scale constrained." ) );
1321 reporter.Report( msg, RPT_SEVERITY_INFO );
1322 }
1323
1324 // Y scale
1325 msg = m_fineAdjustYCtrl->GetValue();
1326 msg.ToDouble( &tmpDouble );
1327
1329 {
1330 msg.Printf( wxT( "%f" ), m_YScaleAdjust );
1331 m_fineAdjustYCtrl->SetValue( msg );
1332 msg.Printf( _( "Y scale constrained." ) );
1333 reporter.Report( msg, RPT_SEVERITY_INFO );
1334 }
1335
1336 // PS Width correction
1339 {
1341 msg.Printf( _( "Width correction constrained. The width correction value must be in the"
1342 " range of [%s; %s] for the current design rules." ),
1343 m_editFrame->StringFromValue( m_widthAdjustMinValue, true ),
1344 m_editFrame->StringFromValue( m_widthAdjustMaxValue, true ) );
1345 reporter.Report( msg, RPT_SEVERITY_WARNING );
1346 }
1347
1348 if( m_job )
1349 {
1350 // When using a job we store the adjusts in the plot options
1351 tempOptions.SetFineScaleAdjustX( m_XScaleAdjust );
1352 tempOptions.SetFineScaleAdjustY( m_YScaleAdjust );
1353 tempOptions.SetWidthAdjust( m_PSWidthAdjust );
1354 }
1355
1356 tempOptions.SetFormat( getPlotFormat() );
1357
1359 {
1360 tempOptions.SetDisableGerberMacros( m_disableApertMacros->GetValue() );
1361 tempOptions.SetUseGerberProtelExtensions( m_useGerberExtensions->GetValue() );
1362 tempOptions.SetUseGerberX2format( m_useGerberX2Format->GetValue() );
1363 tempOptions.SetIncludeGerberNetlistInfo( m_useGerberNetAttributes->GetValue() );
1364 tempOptions.SetCreateGerberJobFile( m_generateGerberJobFile->GetValue() );
1365 tempOptions.SetGerberPrecision( m_coordFormatCtrl->GetSelection() == 0 ? 5 : 6 );
1366 }
1367 else if( getPlotFormat() == PLOT_FORMAT::SVG )
1368 {
1369 tempOptions.SetSvgPrecision( m_svgPrecsision->GetValue() );
1370 tempOptions.SetSvgFitPageToBoard( m_SVG_fitPageToBoard->GetValue() );
1371 }
1372 else if( getPlotFormat() == PLOT_FORMAT::PNG )
1373 {
1374 tempOptions.SetPngDPI( m_pngDPI->GetValue() );
1375 tempOptions.SetPngAntialias( m_pngAntialias->GetValue() );
1376 }
1377
1378 LSET selectedLayers;
1379
1380 for( unsigned i = 0; i < m_layerList.size(); i++ )
1381 {
1382 if( m_layerCheckListBox->IsChecked( i ) )
1383 selectedLayers.set( m_layerList[i] );
1384 }
1385
1386 // Add selected layers from plot on all layers list in order set by user.
1387 wxArrayInt plotOnAllLayers;
1388 LSEQ commonLayers;
1389
1390 if( m_plotAllLayersList->GetCheckedItems( plotOnAllLayers ) )
1391 {
1392 size_t count = plotOnAllLayers.GetCount();
1393
1394 for( size_t i = 0; i < count; i++ )
1395 {
1396 int index = plotOnAllLayers.Item( i );
1398
1399 commonLayers.push_back( client_layer );
1400 }
1401 }
1402
1403 tempOptions.SetPlotOnAllLayersSequence( commonLayers );
1404
1405 tempOptions.SetLayerSelection( PCB_PLOTTER::DialogLayerSelection( selectedLayers,
1406 m_editFrame->GetBoard()->GetEnabledLayers(),
1407 m_job != nullptr ) );
1408
1409 tempOptions.SetNegative( m_plotPSNegativeOpt->GetValue() );
1410 tempOptions.SetA4Output( m_forcePSA4OutputOpt->GetValue() );
1411
1412 // Set output directory and replace backslashes with forward ones
1413 wxString dirStr;
1414 dirStr = m_outputDirectoryName->GetValue();
1415 dirStr.Replace( wxT( "\\" ), wxT( "/" ) );
1416 tempOptions.SetOutputDirectory( dirStr );
1417 m_editFrame->Prj().GetProjectFile().m_PcbLastPath[ LAST_PATH_PLOT ] = dirStr;
1418
1419 if( !m_job && !m_plotOpts.IsSameAs( tempOptions ) )
1420 {
1421 m_editFrame->SetPlotSettings( tempOptions );
1422 m_editFrame->OnModify();
1423 m_plotOpts = tempOptions;
1424 }
1425 else
1426 {
1427 m_plotOpts = tempOptions;
1428 }
1429}
1430
1431
1432void DIALOG_PLOT::OnGerberX2Checked( wxCommandEvent& event )
1433{
1434 // Currently: do nothing
1435}
1436
1437
1438void DIALOG_PLOT::Plot( wxCommandEvent& event )
1439{
1440 if( m_job )
1441 {
1444 EndModal( wxID_OK );
1445 }
1446 else
1447 {
1448 BOARD* board = m_editFrame->GetBoard();
1449
1451
1452 // The formats without a selector keep plotting with the editor theme.
1454
1455 m_plotOpts.SetSketchPadLineWidth( board->GetDesignSettings().GetLineThickness( F_Fab ) );
1456
1457 // If no layer selected, we have nothing plotted.
1458 // Prompt user if it happens because he could think there is a bug in Pcbnew.
1459 if( !m_plotOpts.GetLayerSelection().any() )
1460 {
1461 DisplayError( this, _( "No layer selected, Nothing to plot" ) );
1462 return;
1463 }
1464
1465 // Create output directory if it does not exist (also transform it in absolute form).
1466 // Bail if it fails.
1467
1468 std::function<bool( wxString* )> textResolver =
1469 [&]( wxString* token ) -> bool
1470 {
1471 // Handles board->GetTitleBlock() *and* board->GetProject()
1472 return m_editFrame->GetBoard()->ResolveTextVar( token, 0 );
1473 };
1474
1475 wxString path = ExpandPathVariables( m_plotOpts.GetOutputDirectory(), board->GetProject(), &textResolver );
1476
1477 wxFileName outputDir = wxFileName::DirName( path );
1478 wxString boardFilename = m_editFrame->GetBoard()->GetFileName();
1479 REPORTER& reporter = m_messagesPanel->Reporter();
1480
1481 if( !EnsureFileDirectoryExists( &outputDir, boardFilename, &reporter ) )
1482 {
1483 wxString msg;
1484 msg.Printf( _( "Could not write plot files to folder '%s'." ), outputDir.GetPath() );
1485 DisplayError( this, msg );
1486 return;
1487 }
1488
1489 if( m_zoneFillCheck->GetValue() )
1490 m_editFrame->GetToolManager()->GetTool<ZONE_FILLER_TOOL>()->CheckAllZones( this );
1491
1492 m_plotOpts.SetAutoScale( false );
1493
1494 switch( m_plotOpts.GetScaleSelection() )
1495 {
1496 default: m_plotOpts.SetScale( 1 ); break;
1497 case 0: m_plotOpts.SetAutoScale( true ); break;
1498 case 2: m_plotOpts.SetScale( 1.5 ); break;
1499 case 3: m_plotOpts.SetScale( 2 ); break;
1500 case 4: m_plotOpts.SetScale( 3 ); break;
1501 }
1502
1503 /* If the scale factor edit controls are disabled or the scale value
1504 * is 0, don't adjust the base scale factor. This fixes a bug when
1505 * the default scale adjust is initialized to 0 and saved in program
1506 * settings resulting in a divide by zero fault.
1507 */
1509 {
1510 if( m_XScaleAdjust != 0.0 )
1511 m_plotOpts.SetFineScaleAdjustX( m_XScaleAdjust );
1512
1513 if( m_YScaleAdjust != 0.0 )
1514 m_plotOpts.SetFineScaleAdjustY( m_YScaleAdjust );
1515
1516 m_plotOpts.SetWidthAdjust( m_PSWidthAdjust );
1517 }
1518
1519 // Test for a reasonable scale value
1520 // XXX could this actually happen? isn't it constrained in the apply function?
1521 if( m_plotOpts.GetScale() < PLOT_MIN_SCALE )
1522 DisplayInfoMessage( this, _( "Warning: Scale option set to a very small value" ) );
1523
1524 if( m_plotOpts.GetScale() > PLOT_MAX_SCALE )
1525 DisplayInfoMessage( this, _( "Warning: Scale option set to a very large value" ) );
1526
1527
1528 // Save the current plot options in the board
1529 m_editFrame->SetPlotSettings( m_plotOpts );
1530
1531 wxString oldVariant = board->GetCurrentVariant();
1533
1534 PCB_PLOTTER pcbPlotter( m_editFrame->GetBoard(), &reporter, m_plotOpts );
1535
1536 LSEQ layersToPlot = m_plotOpts.GetLayerSelection().UIOrder();
1537
1538 wxArrayInt plotOnAllLayers;
1539 LSEQ commonLayers;
1540
1541 if( m_plotAllLayersList->GetCheckedItems( plotOnAllLayers ) )
1542 {
1543 size_t count = plotOnAllLayers.GetCount();
1544
1545 for( size_t i = 0; i < count; i++ )
1546 {
1547 int index = plotOnAllLayers.Item( i );
1549
1550 commonLayers.push_back( client_layer );
1551 }
1552 }
1553
1554 bool plotAllLayersToOneFile = m_plotOpts.m_PDFSingle || m_plotOpts.GetDXFMultiLayeredExportOption();
1555 bool forceAllLayersToOnePage = false;
1556
1557 pcbPlotter.Plot( outputDir.GetPath(), layersToPlot, commonLayers, m_plotOpts.GetUseGerberProtelExtensions(),
1558 plotAllLayersToOneFile, forceAllLayersToOnePage );
1559
1560 board->SetCurrentVariant( oldVariant );
1561 }
1562}
1563
1564
1565
1566void DIALOG_PLOT::onRunDRC( wxCommandEvent& event )
1567{
1568 PCB_EDIT_FRAME* parent = dynamic_cast<PCB_EDIT_FRAME*>( GetParent() );
1569
1570 if( parent )
1571 {
1572 DRC_TOOL* drcTool = parent->GetToolManager()->GetTool<DRC_TOOL>();
1573
1574 // First close an existing dialog if open
1575 // (low probability, but can happen)
1576 drcTool->DestroyDRCDialog();
1577
1578 // Open a new drc dialog, with the right parent frame, and in Modal Mode
1579 drcTool->ShowDRCDialog( this );
1580
1581 // Update DRC warnings on return to this dialog
1582 reInitDialog();
1583 }
1584}
1585
1586
1587void DIALOG_PLOT::onOpenOutputDirectory( wxCommandEvent& event )
1588{
1589 std::function<bool( wxString* )> textResolver =
1590 [&]( wxString* token ) -> bool
1591 {
1592 return m_editFrame->GetBoard()->ResolveTextVar( token, 0 );
1593 };
1594
1595 wxString path = ResolveProjectPath( m_outputDirectoryName->GetValue(), &Prj(), &textResolver );
1596
1597 if( !wxDirExists( path ) )
1598 {
1599 DisplayError( this, wxString::Format( _( "Directory '%s' does not exist." ), path ) );
1600 return;
1601 }
1602
1603 wxLaunchDefaultApplication( path );
1604}
1605
1606
1607void DIALOG_PLOT::onBoardSetup( wxHyperlinkEvent& aEvent )
1608{
1609 PCB_EDIT_FRAME* parent = dynamic_cast<PCB_EDIT_FRAME*>( GetParent() );
1610
1611 if( parent )
1612 {
1613 parent->ShowBoardSetupDialog( _( "Solder Mask/Paste" ) );
1614
1615 // Update warnings on return to this dialog
1616 reInitDialog();
1617 }
1618}
1619
1620
1621void DIALOG_PLOT::onPlotAllListMoveUp( wxCommandEvent& aEvent )
1622{
1623 if( m_plotAllLayersList->CanMoveCurrentUp() )
1624 m_plotAllLayersList->MoveCurrentUp();
1625}
1626
1627
1628void DIALOG_PLOT::onPlotAllListMoveDown( wxCommandEvent& aEvent )
1629{
1630 if( m_plotAllLayersList->CanMoveCurrentDown() )
1631 m_plotAllLayersList->MoveCurrentDown();
1632}
1633
1634
1635void DIALOG_PLOT::onDNPCheckbox( wxCommandEvent& aEvent )
1636{
1637 m_hideDNP->Enable( aEvent.IsChecked() );
1638 m_crossoutDNP->Enable( aEvent.IsChecked() );
1639}
1640
1641
1642void DIALOG_PLOT::onSketchPads( wxCommandEvent& aEvent )
1643{
1644 m_plotPadNumbers->Enable( aEvent.IsChecked() );
1645}
1646
1647
1649{
1650 if( m_PDFColorChoice->GetSelection() == 1 )
1651 {
1652 m_pdfBackgroundColorSwatch->Disable();
1653 m_pdfBackgroundColorText->Disable();
1654 }
1655 else
1656 {
1658 m_pdfBackgroundColorText->Enable();
1659 }
1660
1662}
1663
1664
1665void DIALOG_PLOT::onSVGColorChoice( wxCommandEvent& aEvent )
1666{
1668}
1669
1670
1671void DIALOG_PLOT::onPDFColorChoice( wxCommandEvent& aEvent )
1672{
1674}
int index
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
constexpr EDA_IU_SCALE unityScale
Definition base_units.h:131
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:106
@ small_new_window
wxString m_ColorTheme
Active color theme name.
BASE_SET & set(size_t pos)
Definition base_set.h:126
Container for design settings for a BOARD object.
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
void SetCurrentVariant(const wxString &aVariant)
Definition board.cpp:3016
wxArrayString GetVariantNamesForUI() const
Return the variant names for UI display.
Definition board.cpp:3208
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition board.cpp:960
wxString GetCurrentVariant() const
Definition board.h:530
PROJECT * GetProject() const
Definition board.h:774
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition board.cpp:1202
BOARD_DESIGN_SETTINGS & GetDesignSettings()
Definition board.cpp:1318
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:400
Color settings are a bit different than most of the settings objects in that there can be more than o...
const wxString & GetName() const
wxCheckBox * m_frontFPPropertyPopups
wxStaticText * m_DRCExclusionsWarning
wxTextCtrl * m_widthAdjustCtrl
wxCheckBox * m_backFPPropertyPopups
wxTextCtrl * m_fineAdjustXCtrl
wxBoxSizer * bmiddleSizer
wxStaticBoxSizer * m_PDFOptionsSizer
wxCheckBox * m_disableApertMacros
wxChoice * m_coordFormatCtrl
wxCheckBox * m_DXF_plotModeOpt
wxCheckBox * m_pdfSingle
wxChoice * m_colorTheme
wxChoice * m_SVGColorChoice
wxStaticText * m_staticTextPlotFmt
wxStaticBoxSizer * m_pngOptionsSizer
wxCheckBox * m_DXF_exportAsMultiLayeredFile
STD_BITMAP_BUTTON * m_browseButton
wxTextCtrl * m_outputDirectoryName
wxSpinCtrl * m_svgPrecsision
wxTextCtrl * m_fineAdjustYCtrl
wxCheckBox * m_plotPadNumbers
wxCheckBox * m_useAuxOriginCheckBox
wxStaticBoxSizer * m_PSOptionsSizer
STD_BITMAP_BUTTON * m_openDirButton
wxCheckBox * m_plotPSNegativeOpt
wxChoice * m_variantChoiceCtrl
wxStaticText * m_widthAdjustLabel
wxCheckBox * m_SVG_fitPageToBoard
wxStaticText * m_pdfBackgroundColorText
wxCheckBox * m_DXF_plotTextStrokeFontOpt
wxCheckBox * m_allCopperLayers
wxCheckBox * m_useGerberExtensions
wxCheckBox * m_plotSheetRef
wxBoxSizer * m_SizerSolderMaskAlert
wxCheckBox * m_generateGerberJobFile
wxRadioButton * m_crossoutDNP
wxButton * m_sdbSizer1Apply
wxCheckBox * m_useGerberX2Format
wxCheckListBox * m_layerCheckListBox
wxCheckBox * m_plotMirrorOpt
wxStaticText * m_staticTextDir
wxStaticText * m_widthAdjustUnits
wxStaticBoxSizer * m_svgOptionsSizer
COLOR_SWATCH * m_pdfBackgroundColorSwatch
wxCheckBox * m_forcePSA4OutputOpt
wxCheckBox * m_useGerberNetAttributes
wxStaticText * m_colorThemeLabel
wxCheckBox * m_sketchPadsOnFabLayers
wxCheckBox * m_pngAntialias
wxCheckBox * m_subtractMaskFromSilk
wxCheckBox * m_plotDNP
wxBoxSizer * m_PlotOptionsSizer
wxSpinCtrl * m_pngDPI
wxCheckBox * m_plotRefDes
wxChoice * m_DXF_plotUnits
DIALOG_PLOT_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Plot"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxStaticBoxSizer * m_SizerDXF_options
wxCheckBox * m_pdfMetadata
wxChoice * m_drillShapeOpt
wxCheckBox * m_plotFootprintValues
wxRadioButton * m_hideDNP
wxCheckBox * m_zoneFillCheck
wxStaticBoxSizer * m_GerberOptionsSizer
WX_HTML_REPORT_PANEL * m_messagesPanel
wxChoice * m_PDFColorChoice
wxChoice * m_plotFormatOpt
wxBoxSizer * m_MainSizer
bool formatUsesColorTheme()
void populateColorThemeSelector()
void onPDFColorChoice(wxCommandEvent &event) override
DIALOG_PLOT(PCB_EDIT_FRAME *aEditFrame)
COLOR_SETTINGS * getEditorColorSettings() const
void reInitDialog()
void OnRightClickLayers(wxMouseEvent &event)
static LSEQ s_lastAllLayersOrder
The plot on all layers ordering the last time the dialog was opened.
void onAllCopperLayers(wxCommandEvent &event) override
JOB_EXPORT_PCB_PLOT * m_job
PCB_PLOT_PARAMS m_plotOpts
STD_BITMAP_BUTTON * m_bpMoveUp
void onPlotAllListMoveUp(wxCommandEvent &aEvent)
void OnChangeDXFPlotMode(wxCommandEvent &event) override
int m_widthAdjustMinValue
UNIT_BINDER m_trackWidthCorrection
void onBoardSetup(wxHyperlinkEvent &aEvent) override
void OnRightClickAllLayers(wxMouseEvent &event)
void onSketchPads(wxCommandEvent &event) override
bool allCopperLayersChecked() const
void Plot(wxCommandEvent &event) override
void applyPlotSettings()
int m_PSWidthAdjust
Definition dialog_plot.h:98
wxString m_DRCWarningTemplate
wxRearrangeList * m_plotAllLayersList
bool TransferDataToWindow() override
void onPlotAllListMoveDown(wxCommandEvent &aEvent)
void onRunDRC(wxCommandEvent &event) override
void arrangeAllLayersList(const LSEQ &aSeq)
double m_YScaleAdjust
Definition dialog_plot.h:96
void checkAllCopperLayers()
void onOpenOutputDirectory(wxCommandEvent &event) override
void updatePdfColorOptions()
PCB_EDIT_FRAME * m_editFrame
Definition dialog_plot.h:92
virtual ~DIALOG_PLOT()
void updateColorThemeControl()
STD_BITMAP_BUTTON * m_bpMoveDown
void syncAllCopperLayers()
void onLayerToggled(wxCommandEvent &event) override
void updateJobOutputLabel()
COLOR_SETTINGS * getColorSettings() const
wxString getSelectedVariant() const
void CreateDrillFile(wxCommandEvent &event) override
void onSVGColorChoice(wxCommandEvent &event) override
void onDNPCheckbox(wxCommandEvent &event) override
double m_XScaleAdjust
Definition dialog_plot.h:94
PLOT_FORMAT getPlotFormat()
void transferPlotParamsToJob()
int m_widthAdjustMaxValue
void onOutputDirectoryBrowseClicked(wxCommandEvent &event) override
void OnGerberX2Checked(wxCommandEvent &event) override
void setColorThemeSelection(const wxString &aTheme)
void SetPlotFormat(wxCommandEvent &event) override
LSEQ m_layerList
Definition dialog_plot.h:93
void recordControlChange(wxWindow *aCtrl)
Tell the undo mechanism to snapshot the current value of a control and record it as an undo step when...
void SetupStandardButtons(std::map< int, wxString > aLabels={})
std::string m_hash_key
int ShowModal() override
void ShowDRCDialog(wxWindow *aParent)
Opens the DRC dialog.
Definition drc_tool.cpp:72
void DestroyDRCDialog()
Close and free the DRC dialog.
Definition drc_tool.cpp:123
@ ALL_LAYERS_SEPARATE_FILE
The most traditional output mode KiCad has had.
@ ONE_PAGE_PER_LAYER_ONE_FILE
"Single Document" mode
wxString m_pdfBackgroundColor
The background color specified in a hex string.
GEN_MODE m_pdfGenMode
uused by the cli, will be removed when the other behavior is deprecated
virtual wxString GetSettingsDialogTitle() const
Definition job.cpp:80
wxString GetFilename() const
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition lseq.h:47
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
Definition lset.cpp:604
LSEQ UIOrder() const
Return the copper, technical and user layers in the order shown in layer widget.
Definition lset.cpp:739
LSEQ SeqStackupForPlotting() const
Return the sequence that is typical for a bottom-to-top stack-up.
Definition lset.cpp:400
static const LSET & AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
Definition lset.cpp:672
The main frame for Pcbnew.
void ShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString, wxWindow *aParent=nullptr)
A helper wxWidgets control client data object to store layer IDs.
PCB_LAYER_ID Layer() const
void SetData(PCB_LAYER_ID aId)
PCB_LAYER_ID_CLIENT_DATA(PCB_LAYER_ID aId)
bool Plot(const wxString &aOutputPath, const LSEQ &aLayersToPlot, const LSEQ &aCommonLayers, bool aUseGerberFileExtensions, bool aPlotAllLayersToSingleFile, bool aForceAllLayersToSinglePage, std::optional< wxString > aLayerName=std::nullopt, std::optional< wxString > aSheetName=std::nullopt, std::optional< wxString > aSheetPath=std::nullopt, std::vector< wxString > *aOutputFiles=nullptr)
static void PlotJobToPlotOpts(PCB_PLOT_PARAMS &aOpts, JOB_EXPORT_PCB_PLOT *aJob, REPORTER &aReporter)
Translate a JOB to PCB_PLOT_PARAMS.
static LSET DialogLayerSelection(const LSET &aChecked, const LSET &aEnabledLayers, bool aForJob)
Return the layers a plot dialog stores when aChecked are ticked.
Parameters and options when plotting/printing a board.
void SetDrillMarksType(DRILL_MARKS aVal)
void SetLayerSelection(const LSET &aSelection)
void SetOutputDirectory(const wxString &aDir)
void SetPlotReference(bool aFlag)
void SetSketchPadsOnFabLayers(bool aFlag)
void SetUseGerberX2format(bool aUse)
void SetA4Output(int aForce)
void SetPlotOnAllLayersSequence(LSEQ aSeq)
void SetDXFPlotPolygonMode(bool aFlag)
void SetPlotFrameRef(bool aFlag)
void SetSketchDNPFPsOnFabLayers(bool aFlag)
bool m_PDFMetadata
Generate PDF metadata for SUBJECT and AUTHOR.
void SetDashedLineGapRatio(double aVal)
void SetPlotPadNumbers(bool aFlag)
COLOR4D m_backgroundColor
Background color to use for PNG and PDF plotting.
bool m_PDFFrontFPPropertyPopups
Generate PDF property popup menus for footprints.
void SetDisableGerberMacros(bool aDisable)
void SetDXFMultiLayeredExportOption(bool aFlag)
void SetScaleSelection(int aSelection)
void SetFineScaleAdjustX(double aVal)
void SetMirror(bool aFlag)
void SetBlackAndWhite(bool blackAndWhite)
void SetGerberPrecision(int aPrecision)
void SetSubtractMaskFromSilk(bool aSubtract)
void SetHideDNPFPsOnFabLayers(bool aFlag)
void SetPlotValue(bool aFlag)
void SetPngDPI(int aDPI)
void SetUseGerberProtelExtensions(bool aUse)
void SetDashedLineDashRatio(double aVal)
void SetDXFPlotUnits(DXF_UNITS aUnit)
void SetPngAntialias(bool aFlag)
void SetIncludeGerberNetlistInfo(bool aUse)
void SetCreateGerberJobFile(bool aCreate)
bool m_PDFSingle
Generate a single PDF file for all layers.
void SetNegative(bool aFlag)
void SetUseAuxOrigin(bool aAux)
bool m_PDFBackFPPropertyPopups
on front and/or back of board
void SetTextMode(PLOT_TEXT_MODE aVal)
void SetSvgFitPageToBoard(int aSvgFitPageToBoard)
void SetSvgPrecision(unsigned aPrecision)
void SetCrossoutDNPFPsOnFabLayers(bool aFlag)
void SetFormat(PLOT_FORMAT aFormat)
void SetFineScaleAdjustY(double aVal)
void SetWidthAdjust(int aVal)
The backing store for a PROJECT, in JSON format.
wxString m_PcbLastPath[LAST_PATH_SIZE]
MRU path storage.
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
A bitmap button widget that behaves like a standard dialog button except with an icon.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
T * GetTool()
Return the tool of given type or nullptr if there is no such tool registered.
Handle actions specific to filling copper zones.
A type-safe container of any type.
Definition ki_any.h:92
wxString ExpandPathVariables(const wxString &aPath, const PROJECT *aProject, const std::function< bool(wxString *)> *aTextResolver)
Expand text variables, environment variables and a leading '~' in a user-entered file path.
Definition common.cpp:798
wxString ResolveProjectPath(const wxString &aPath, const PROJECT *aProject, const std::function< bool(wxString *)> *aTextResolver)
Expand a user-entered file path as ExpandPathVariables() does, then anchor a relative result at the p...
Definition common.cpp:817
bool EnsureFileDirectoryExists(wxFileName *aTargetFullFileName, const wxString &aBaseFilename, REPORTER *aReporter)
Make aTargetFullFileName absolute and create the path of this file if it doesn't yet exist.
Definition common.cpp:829
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition confirm.cpp:274
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition confirm.cpp:245
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition confirm.cpp:192
This file is part of the common library.
#define ID_STACKUP_ORDER
static bool setDouble(double *aResult, double aValue, double aMin, double aMax)
static bool setInt(int *aResult, int aValue, int aMin, int aMax)
PCB_LAYER_ID_CLIENT_DATA * getLayerClientData(const wxRearrangeList *aList, int aIdx)
#define ID_SELECT_ALL_LAYERS
static double selectionToScale(int selection)
#define ID_DESELECT_COPPER_LAYERS
#define ID_DESELECT_ALL_LAYERS
#define ID_LAYER_FAB
#define ID_SELECT_COPPER_LAYERS
#define DLG_WINDOW_NAME
Definition dialog_plot.h:26
#define _(s)
Classes used to generate a Gerber job file in JSON.
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition layer_ids.h:744
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ F_CrtYd
Definition layer_ids.h:112
@ F_Fab
Definition layer_ids.h:115
@ B_CrtYd
Definition layer_ids.h:111
@ UNDEFINED_LAYER
Definition layer_ids.h:57
This file contains miscellaneous commonly used macros and functions.
KICOMMON_API wxString StringFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Return the string from aValue according to aUnits (inch, mm ...) for display.
KICOMMON_API wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
Definition ui_common.cpp:80
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition kicad_algo.h:96
#define PLOT_MIN_SCALE
Definition pcbplot.h:55
#define PLOT_MAX_SCALE
Definition pcbplot.h:56
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
DRILL_MARKS
Plots and prints can show holes in pads and vias 3 options are available:
@ SKETCH
Definition plotter.h:83
PLOT_FORMAT
The set of supported output plot formats.
Definition plotter.h:65
Plotting engines similar to ps (PostScript, Gerber, svg)
@ LAST_PATH_PLOT
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_EXCLUSION
@ RPT_SEVERITY_INFO
#define DEFAULT_THEME
T * GetAppSettings(const char *aFilename)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
std::string path
IbisParser parser & reporter
Definition of file extensions used in Kicad.