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 (C) 1992-2023 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
24#include <wx/bmpbuttn.h>
25#include <wx/clntdata.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 <locale_io.h>
39#include <bitmaps.h>
40#include <dialog_plot.h>
41#include <dialog_gendrill.h>
44#include <tool/tool_manager.h>
46#include <tools/drc_tool.h>
47#include <math/util.h> // for KiROUND
48#include <macros.h>
49
50#include <wx/dirdlg.h>
51
52
55
56
60class PCB_LAYER_ID_CLIENT_DATA : public wxClientData
61{
62public:
65
66 void SetData( PCB_LAYER_ID aId ) { m_id = aId; }
67
68 PCB_LAYER_ID GetData() const { return m_id; }
69
70private:
72};
73
74
76 DIALOG_PLOT_BASE( aParent ),
77 m_parent( aParent ),
78 m_defaultPenSize( aParent, m_hpglPenLabel, m_hpglPenCtrl, m_hpglPenUnits ),
79 m_trackWidthCorrection( aParent, m_widthAdjustLabel, m_widthAdjustCtrl, m_widthAdjustUnits )
80{
81 BOARD* board = m_parent->GetBoard();
82
83 SetName( DLG_WINDOW_NAME );
84 m_plotOpts = aParent->GetPlotSettings();
86
87 m_messagesPanel->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
88
89 int order = 0;
90 LSET plotOnAllLayersSelection = m_plotOpts.GetPlotOnAllLayersSelection();
91 wxArrayInt plotAllLayersOrder;
92 wxArrayString plotAllLayersChoicesStrings;
93 std::vector<PCB_LAYER_ID> layersIdChoiceList;
94 int textWidth = 0;
95
96 for( LSEQ seq = board->GetEnabledLayers().UIOrder(); seq; ++seq )
97 {
98 PCB_LAYER_ID id = *seq;
99 wxString layerName = board->GetLayerName( id );
100
101 // wxCOL_WIDTH_AUTOSIZE doesn't work on all platforms, so we calculate width here
102 textWidth = std::max( textWidth, KIUI::GetTextSize( layerName, m_layerCheckListBox ).x );
103
104 plotAllLayersChoicesStrings.Add( layerName );
105 layersIdChoiceList.push_back( id );
106
107 size_t size = plotOnAllLayersSelection.size();
108
109 if( ( static_cast<size_t>( id ) <= size ) && plotOnAllLayersSelection.test( id ) )
110 plotAllLayersOrder.push_back( order );
111 else
112 plotAllLayersOrder.push_back( ~order );
113
114 order += 1;
115 }
116
117 int checkColSize = 22;
118 int layerColSize = textWidth + 15;
119
120#ifdef __WXMAC__
121 // TODO: something in wxWidgets 3.1.x pads checkbox columns with extra space. (It used to
122 // also be that the width of the column would get set too wide (to 30), but that's patched in
123 // our local wxWidgets fork.)
124 checkColSize += 30;
125#endif
126
127 m_layerCheckListBox->SetMinClientSize( wxSize( checkColSize + layerColSize,
128 m_layerCheckListBox->GetMinClientSize().y ) );
129
130 wxStaticBox* allLayersLabel = new wxStaticBox( this, wxID_ANY, _( "Plot on All Layers" ) );
131 wxStaticBoxSizer* sbSizer = new wxStaticBoxSizer( allLayersLabel, wxVERTICAL );
132
133 m_plotAllLayersList = new wxRearrangeList( sbSizer->GetStaticBox(), wxID_ANY,
134 wxDefaultPosition, wxDefaultSize,
135 plotAllLayersOrder, plotAllLayersChoicesStrings, 0 );
136
137 m_plotAllLayersList->SetMinClientSize( wxSize( checkColSize + layerColSize,
138 m_plotAllLayersList->GetMinClientSize().y ) );
139
140 // Attach the LAYER_ID to each item in m_plotAllLayersList
141 // plotAllLayersChoicesStrings and layersIdChoiceList are in the same order,
142 // but m_plotAllLayersList has these strings in a different order
143 for( size_t idx = 0; idx < layersIdChoiceList.size(); idx++ )
144 {
145 wxString& txt = plotAllLayersChoicesStrings[idx];
146 int list_idx = m_plotAllLayersList->FindString( txt, true );
147
148 PCB_LAYER_ID layer_id = layersIdChoiceList[idx];
149 m_plotAllLayersList->SetClientObject( list_idx, new PCB_LAYER_ID_CLIENT_DATA( layer_id ) );
150 }
151
152 sbSizer->Add( m_plotAllLayersList, 1, wxALL | wxEXPAND, 5 );
153
154#if 0 // re-enable once layer ordering is implemented
155 wxBoxSizer* bButtonSizer;
156 bButtonSizer = new wxBoxSizer( wxHORIZONTAL );
157
158 m_bpMoveUp = new STD_BITMAP_BUTTON( sbSizer->GetStaticBox(), wxID_ANY, wxNullBitmap,
159 wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW | 0 );
160 m_bpMoveUp->SetToolTip( _( "Move current selection up" ) );
161 m_bpMoveUp->SetBitmap( KiBitmap( BITMAPS::small_up ) );
162
163 bButtonSizer->Add( m_bpMoveUp, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5 );
164
165 m_bpMoveDown = new STD_BITMAP_BUTTON( sbSizer->GetStaticBox(), wxID_ANY, wxNullBitmap,
166 wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW | 0 );
167 m_bpMoveDown->SetToolTip( _( "Move current selection down" ) );
168 m_bpMoveDown->SetBitmap( KiBitmap( BITMAPS::small_down ) );
169
170 bButtonSizer->Add( m_bpMoveDown, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5 );
171
172 sbSizer->Add( bButtonSizer, 0, wxALL | wxEXPAND, 5 );
173#endif
174
175 bmiddleSizer->Insert( 1, sbSizer, 1, wxALL | wxEXPAND, 3 );
176
177 init_Dialog();
178
179 SetupStandardButtons( { { wxID_OK, _( "Plot" ) },
180 { wxID_APPLY, _( "Generate Drill Files..." ) },
181 { wxID_CANCEL, _( "Close" ) } } );
182
183 GetSizer()->Fit( this );
184 GetSizer()->SetSizeHints( this );
185
186#if 0 // re-enable once layer ordering is implemented
187 m_bpMoveUp->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveUp, this );
188 m_bpMoveDown->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveDown, this );
189#endif
190}
191
192
194{
195#if 0 // re-enable once layer ordering is implemented
196 m_bpMoveDown->Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveDown, this );
197 m_bpMoveUp->Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveUp, this );
198#endif
199}
200
201
203{
204 BOARD* board = m_parent->GetBoard();
205 wxFileName fileName;
206
207 PROJECT_FILE& projectFile = m_parent->Prj().GetProjectFile();
209
210 if( !projectFile.m_PcbLastPath[ LAST_PATH_PLOT ].IsEmpty() )
212
215
217
218 m_browseButton->SetBitmap( KiBitmap( BITMAPS::small_folder ) );
219
220 // m_PSWidthAdjust is stored in mm in user config
222
223 // The reasonable width correction value must be in a range of
224 // [-(MinTrackWidth-1), +(MinClearanceValue-1)] decimils.
227
228 switch( m_plotOpts.GetFormat() )
229 {
230 default:
231 case PLOT_FORMAT::GERBER: m_plotFormatOpt->SetSelection( 0 ); break;
232 case PLOT_FORMAT::POST: m_plotFormatOpt->SetSelection( 1 ); break;
233 case PLOT_FORMAT::SVG: m_plotFormatOpt->SetSelection( 2 ); break;
234 case PLOT_FORMAT::DXF: m_plotFormatOpt->SetSelection( 3 ); break;
235 case PLOT_FORMAT::HPGL: m_plotFormatOpt->SetSelection( 4 ); break;
236 case PLOT_FORMAT::PDF: m_plotFormatOpt->SetSelection( 5 ); break;
237 }
238
239 // Set units and value for HPGL pen size (this param is in mils).
241
242 // Test for a reasonable scale value. Set to 1 if problem
245 {
247 }
248
250 EDA_UNITS::UNSCALED,
251 m_XScaleAdjust ) );
252
254 EDA_UNITS::UNSCALED,
255 m_YScaleAdjust ) );
256
257 // Test for a reasonable PS width correction value. Set to 0 if problem.
258 if( m_PSWidthAdjust < m_widthAdjustMinValue || m_PSWidthAdjust > m_widthAdjustMaxValue )
259 m_PSWidthAdjust = 0.;
260
262
265
266 // Could devote a PlotOrder() function in place of UIOrder().
268
269 // Populate the check list box by all enabled layers names.
270 for( LSEQ seq = m_layerList; seq; ++seq )
271 {
272 PCB_LAYER_ID layer = *seq;
273
274 int checkIndex = m_layerCheckListBox->Append( board->GetLayerName( layer ) );
275
276 if( m_plotOpts.GetLayerSelection()[layer] )
277 m_layerCheckListBox->Check( checkIndex );
278 }
279
280 // Option for disabling Gerber Aperture Macro (for broken Gerber readers)
282
283 // Option for using proper Gerber extensions. Note also Protel extensions are
284 // a broken feature. However, for now, we need to handle it.
286
287 // Option for including Gerber attributes, from Gerber X2 format, in the output
288 // In X1 format, they will be added as comments
290
291 // Option for including Gerber netlist info (from Gerber X2 format) in the output
293
294 // Option to generate a Gerber job file
296
297 // Gerber precision for coordinates
298 m_coordFormatCtrl->SetSelection( m_plotOpts.GetGerberPrecision() == 5 ? 0 : 1 );
299
300 // SVG precision and units for coordinates
302
303 // Option to exclude pads from silkscreen layers
305
306 // Option to tent vias
308
309 // Option to use aux origin
311
312 // Option to plot page references:
314
315 // Options to plot texts on footprints
320
321 // Options to plot pads and vias holes
322 m_drillShapeOpt->SetSelection( (int)m_plotOpts.GetDrillMarksType() );
323
324 // Scale option
325 m_scaleOpt->SetSelection( m_plotOpts.GetScaleSelection() );
326
327 // Plot mode
329
330 // DXF outline mode
332
333 // DXF text mode
334 m_DXF_plotTextStrokeFontOpt->SetValue( m_plotOpts.GetTextMode() == PLOT_TEXT_MODE::DEFAULT );
335
336 // DXF units selection
337 m_DXF_plotUnits->SetSelection( m_plotOpts.GetDXFPlotUnits() == DXF_UNITS::INCHES ? 0 : 1);
338
339 // Plot mirror option
340 m_plotMirrorOpt->SetValue( m_plotOpts.GetMirror() );
341
342 // Plot vias on mask layer (not tented) or not (tented)
344
345 // Black and white plotting
346 m_SVGColorChoice->SetSelection( m_plotOpts.GetBlackAndWhite() ? 1 : 0 );
347 m_PDFColorChoice->SetSelection( m_plotOpts.GetBlackAndWhite() ? 1 : 0 );
350
351 // Initialize a few other parameters, which can also be modified
352 // from the drill dialog
353 reInitDialog();
354
355 // Update options values:
356 wxCommandEvent cmd_event;
357 SetPlotFormat( cmd_event );
358 OnSetScaleOpt( cmd_event );
359}
360
361
363{
364 // after calling the Drill or DRC dialogs some parameters can be modified....
365
366 // Output directory
368
369 // Origin of coordinates:
371
372 int knownViolations = 0;
373 int exclusions = 0;
374
375 for( PCB_MARKER* marker : m_parent->GetBoard()->Markers() )
376 {
377 if( marker->GetSeverity() == RPT_SEVERITY_EXCLUSION )
378 exclusions++;
379 else
380 knownViolations++;
381 }
382
383 if( knownViolations || exclusions )
384 {
385 m_DRCExclusionsWarning->SetLabel( wxString::Format( m_DRCWarningTemplate, knownViolations,
386 exclusions ) );
388 }
389 else
390 {
392 }
393
394 BOARD* board = m_parent->GetBoard();
395 const BOARD_DESIGN_SETTINGS& brd_settings = board->GetDesignSettings();
396
397 if( getPlotFormat() == PLOT_FORMAT::GERBER &&
398 ( brd_settings.m_SolderMaskExpansion || brd_settings.m_SolderMaskMinWidth ) )
399 {
401 }
402 else
403 {
405 }
406}
407
408
409// A helper function to show a popup menu, when the dialog is right clicked.
410void DIALOG_PLOT::OnRightClick( wxMouseEvent& event )
411{
412 PopupMenu( m_popMenu );
413}
414
415
416// Select or deselect groups of layers in the layers list:
417void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event )
418{
419 // Build a list of layers for usual fabrication: copper layers + tech layers without courtyard
420 LSET fab_layer_set = ( LSET::AllCuMask() | LSET::AllTechMask() ) & ~LSET( 2, B_CrtYd, F_CrtYd );
421
422 switch( event.GetId() )
423 {
424 case ID_LAYER_FAB: // Select layers usually needed to build a board
425 for( unsigned i = 0; i < m_layerList.size(); i++ )
426 {
427 LSET layermask( m_layerList[ i ] );
428
429 if( ( layermask & fab_layer_set ).any() )
430 m_layerCheckListBox->Check( i, true );
431 else
432 m_layerCheckListBox->Check( i, false );
433 }
434
435 break;
436
438 for( unsigned i = 0; i < m_layerList.size(); i++ )
439 {
440 if( IsCopperLayer( m_layerList[i] ) )
441 m_layerCheckListBox->Check( i, true );
442 }
443
444 break;
445
447 for( unsigned i = 0; i < m_layerList.size(); i++ )
448 {
449 if( IsCopperLayer( m_layerList[i] ) )
450 m_layerCheckListBox->Check( i, false );
451 }
452
453 break;
454
456 for( unsigned i = 0; i < m_layerList.size(); i++ )
457 m_layerCheckListBox->Check( i, true );
458
459 break;
460
462 for( unsigned i = 0; i < m_layerList.size(); i++ )
463 m_layerCheckListBox->Check( i, false );
464
465 break;
466
467 default:
468 break;
469 }
470}
471
472
473void DIALOG_PLOT::CreateDrillFile( wxCommandEvent& event )
474{
475 // Be sure drill file use the same settings (axis option, plot directory) as plot files:
477
478 DIALOG_GENDRILL dlg( m_parent, this );
479 dlg.ShowModal();
480
481 // a few plot settings can be modified: take them in account
483 reInitDialog();
484}
485
486
487void DIALOG_PLOT::OnChangeDXFPlotMode( wxCommandEvent& event )
488{
489 // m_DXF_plotTextStrokeFontOpt is disabled if m_DXF_plotModeOpt is checked (plot in DXF
490 // polygon mode)
491 m_DXF_plotTextStrokeFontOpt->Enable( !m_DXF_plotModeOpt->GetValue() );
492
493 // if m_DXF_plotTextStrokeFontOpt option is disabled (plot DXF in polygon mode), force
494 // m_DXF_plotTextStrokeFontOpt to true to use Pcbnew stroke font
495 if( !m_DXF_plotTextStrokeFontOpt->IsEnabled() )
496 m_DXF_plotTextStrokeFontOpt->SetValue( true );
497}
498
499
500void DIALOG_PLOT::OnSetScaleOpt( wxCommandEvent& event )
501{
502 /* Disable sheet reference for scale != 1:1 */
503 bool scale1 = ( m_scaleOpt->GetSelection() == 1 );
504
505 m_plotSheetRef->Enable( scale1 );
506
507 if( !scale1 )
508 m_plotSheetRef->SetValue( false );
509}
510
511
513{
514 // Build the absolute path of current output directory to preselect it in the file browser.
515 std::function<bool( wxString* )> textResolver =
516 [&]( wxString* token ) -> bool
517 {
518 return m_parent->GetBoard()->ResolveTextVar( token, 0 );
519 };
520
521 wxString path = m_outputDirectoryName->GetValue();
522 path = ExpandTextVars( path, &textResolver );
524 path = Prj().AbsolutePath( path );
525
526 wxDirDialog dirDialog( this, _( "Select Output Directory" ), path );
527
528 if( dirDialog.ShowModal() == wxID_CANCEL )
529 return;
530
531 wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
532
533 wxFileName fn( Prj().AbsolutePath( m_parent->GetBoard()->GetFileName() ) );
534 wxString defaultPath = fn.GetPathWithSep();
535 wxString msg;
536 wxFileName relPathTest; // Used to test if we can make the path relative
537
538 relPathTest.Assign( dirDialog.GetPath() );
539
540 // Test if making the path relative is possible before asking the user if they want to do it
541 if( relPathTest.MakeRelativeTo( defaultPath ) )
542 {
543 msg.Printf( _( "Do you want to use a path relative to\n'%s'?" ), defaultPath );
544
545 wxMessageDialog dialog( this, msg, _( "Plot Output Directory" ),
546 wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
547
548 if( dialog.ShowModal() == wxID_YES )
549 dirName.MakeRelativeTo( defaultPath );
550 }
551
552 m_outputDirectoryName->SetValue( dirName.GetFullPath() );
553}
554
555
557{
558 // plot format id's are ordered like displayed in m_plotFormatOpt
559 static const PLOT_FORMAT plotFmt[] = {
560 PLOT_FORMAT::GERBER,
561 PLOT_FORMAT::POST,
562 PLOT_FORMAT::SVG,
563 PLOT_FORMAT::DXF,
564 PLOT_FORMAT::HPGL,
565 PLOT_FORMAT::PDF };
566
567 return plotFmt[m_plotFormatOpt->GetSelection()];
568}
569
570
571void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
572{
573 // this option exist only in DXF format:
574 m_DXF_plotModeOpt->Enable( getPlotFormat() == PLOT_FORMAT::DXF );
575
576 // The alert message about non 0 solder mask min width and margin is shown
577 // only in gerber format and if min mask width or mask margin is not 0
578 BOARD* board = m_parent->GetBoard();
579 const BOARD_DESIGN_SETTINGS& brd_settings = board->GetDesignSettings();
580
581 if( getPlotFormat() == PLOT_FORMAT::GERBER
582 && ( brd_settings.m_SolderMaskExpansion || brd_settings.m_SolderMaskMinWidth ) )
583 {
585 }
586 else
587 {
589 }
590
591 switch( getPlotFormat() )
592 {
593 case PLOT_FORMAT::SVG:
594 case PLOT_FORMAT::PDF:
595 m_drillShapeOpt->Enable( true );
596 m_plotModeOpt->Enable( false );
598 m_plotMirrorOpt->Enable( true );
599 m_useAuxOriginCheckBox->Enable( false );
600 m_useAuxOriginCheckBox->SetValue( false );
601 m_defaultPenSize.Enable( false );
602 m_scaleOpt->Enable( false );
603 m_scaleOpt->SetSelection( 1 );
604 m_fineAdjustXCtrl->Enable( false );
605 m_fineAdjustYCtrl->Enable( false );
607 m_plotPSNegativeOpt->Enable( true );
608 m_forcePSA4OutputOpt->Enable( false );
609 m_forcePSA4OutputOpt->SetValue( false );
610
611 if( getPlotFormat() == PLOT_FORMAT::SVG )
612 {
615 }
616 else
617 {
620 }
621
626 break;
627
628 case PLOT_FORMAT::POST:
629 m_drillShapeOpt->Enable( true );
630 m_plotModeOpt->Enable( true );
631 m_plotMirrorOpt->Enable( true );
632 m_useAuxOriginCheckBox->Enable( false );
633 m_useAuxOriginCheckBox->SetValue( false );
634 m_defaultPenSize.Enable( false );
635 m_scaleOpt->Enable( true );
636 m_fineAdjustXCtrl->Enable( true );
637 m_fineAdjustYCtrl->Enable( true );
639 m_plotPSNegativeOpt->Enable( true );
640 m_forcePSA4OutputOpt->Enable( true );
641
648 break;
649
650 case PLOT_FORMAT::GERBER:
651 m_drillShapeOpt->Enable( false );
652 m_drillShapeOpt->SetSelection( 0 );
653 m_plotModeOpt->Enable( false );
655 m_plotMirrorOpt->Enable( false );
656 m_plotMirrorOpt->SetValue( false );
657 m_useAuxOriginCheckBox->Enable( true );
658 m_defaultPenSize.Enable( false );
659 m_scaleOpt->Enable( false );
660 m_scaleOpt->SetSelection( 1 );
661 m_fineAdjustXCtrl->Enable( false );
662 m_fineAdjustYCtrl->Enable( false );
664 m_plotPSNegativeOpt->Enable( false );
665 m_plotPSNegativeOpt->SetValue( false );
666 m_forcePSA4OutputOpt->Enable( false );
667 m_forcePSA4OutputOpt->SetValue( false );
668
675 break;
676
677 case PLOT_FORMAT::HPGL:
678 m_drillShapeOpt->Enable( true );
679 m_plotModeOpt->Enable( true );
680 m_plotMirrorOpt->Enable( true );
681 m_useAuxOriginCheckBox->Enable( false );
682 m_useAuxOriginCheckBox->SetValue( false );
683 m_defaultPenSize.Enable( true );
684 m_scaleOpt->Enable( true );
685 m_fineAdjustXCtrl->Enable( false );
686 m_fineAdjustYCtrl->Enable( false );
688 m_plotPSNegativeOpt->SetValue( false );
689 m_plotPSNegativeOpt->Enable( false );
690 m_forcePSA4OutputOpt->Enable( true );
691
698 break;
699
700 case PLOT_FORMAT::DXF:
701 m_drillShapeOpt->Enable( true );
702 m_plotModeOpt->Enable( false );
704 m_plotMirrorOpt->Enable( false );
705 m_plotMirrorOpt->SetValue( false );
706 m_useAuxOriginCheckBox->Enable( true );
707 m_defaultPenSize.Enable( false );
708 m_scaleOpt->Enable( false );
709 m_scaleOpt->SetSelection( 1 );
710 m_fineAdjustXCtrl->Enable( false );
711 m_fineAdjustYCtrl->Enable( false );
713 m_plotPSNegativeOpt->Enable( false );
714 m_plotPSNegativeOpt->SetValue( false );
715 m_forcePSA4OutputOpt->Enable( false );
716 m_forcePSA4OutputOpt->SetValue( false );
717
724
725 OnChangeDXFPlotMode( event );
726 break;
727
728 case PLOT_FORMAT::UNDEFINED:
729 break;
730 }
731
732 /* Update the interlock between scale and frame reference
733 * (scaling would mess up the frame border...) */
734 OnSetScaleOpt( event );
735
736 Layout();
737 m_MainSizer->SetSizeHints( this );
738}
739
740
741// A helper function to "clip" aValue between aMin and aMax and write result in * aResult
742// return false if clipped, true if aValue is just copied into * aResult
743static bool setDouble( double* aResult, double aValue, double aMin, double aMax )
744{
745 if( aValue < aMin )
746 {
747 *aResult = aMin;
748 return false;
749 }
750 else if( aValue > aMax )
751 {
752 *aResult = aMax;
753 return false;
754 }
755
756 *aResult = aValue;
757 return true;
758}
759
760
761static bool setInt( int* aResult, int aValue, int aMin, int aMax )
762{
763 if( aValue < aMin )
764 {
765 *aResult = aMin;
766 return false;
767 }
768 else if( aValue > aMax )
769 {
770 *aResult = aMax;
771 return false;
772 }
773
774 *aResult = aValue;
775 return true;
776}
777
778
780{
781 REPORTER& reporter = m_messagesPanel->Reporter();
782 PCB_PLOT_PARAMS tempOptions;
783
784 tempOptions.SetSubtractMaskFromSilk( m_subtractMaskFromSilk->GetValue() );
785 tempOptions.SetPlotFrameRef( m_plotSheetRef->GetValue() );
786 tempOptions.SetSketchPadsOnFabLayers( m_sketchPadsOnFabLayers->GetValue() );
787 tempOptions.SetUseAuxOrigin( m_useAuxOriginCheckBox->GetValue() );
788 tempOptions.SetPlotValue( m_plotFootprintValues->GetValue() );
789 tempOptions.SetPlotReference( m_plotFootprintRefs->GetValue() );
790 tempOptions.SetPlotFPText( m_plotFootprintText->GetValue() );
791 tempOptions.SetPlotInvisibleText( m_plotInvisibleText->GetValue() );
792 tempOptions.SetScaleSelection( m_scaleOpt->GetSelection() );
793
794 int sel = m_drillShapeOpt->GetSelection();
795 tempOptions.SetDrillMarksType( static_cast<DRILL_MARKS>( sel ) );
796
797 tempOptions.SetMirror( m_plotMirrorOpt->GetValue() );
798 tempOptions.SetPlotMode( m_plotModeOpt->GetSelection() == 1 ? SKETCH : FILLED );
799 tempOptions.SetDXFPlotPolygonMode( m_DXF_plotModeOpt->GetValue() );
800
801 sel = m_DXF_plotUnits->GetSelection();
802 tempOptions.SetDXFPlotUnits( sel == 0 ? DXF_UNITS::INCHES : DXF_UNITS::MILLIMETERS );
803
804 tempOptions.SetPlotViaOnMaskLayer( !m_tentVias->GetValue() );
805
806 if( !m_DXF_plotTextStrokeFontOpt->IsEnabled() ) // Currently, only DXF supports this option
807 tempOptions.SetTextMode( PLOT_TEXT_MODE::DEFAULT );
808 else
809 tempOptions.SetTextMode( m_DXF_plotTextStrokeFontOpt->GetValue() ? PLOT_TEXT_MODE::DEFAULT :
810 PLOT_TEXT_MODE::NATIVE );
811
812 if( getPlotFormat() == PLOT_FORMAT::SVG )
813 {
814 tempOptions.SetBlackAndWhite( !!m_SVGColorChoice->GetSelection() );
815 }
816 else if( getPlotFormat() == PLOT_FORMAT::PDF )
817 {
818 tempOptions.SetBlackAndWhite( !!m_PDFColorChoice->GetSelection() );
819 tempOptions.m_PDFFrontFPPropertyPopups = m_frontFPPropertyPopups->GetValue();
820 tempOptions.m_PDFBackFPPropertyPopups = m_backFPPropertyPopups->GetValue();
821 }
822 else
823 {
824 tempOptions.SetBlackAndWhite( true );
825 }
826
827 // Update settings from text fields. Rewrite values back to the fields,
828 // since the values may have been constrained by the setters.
829 wxString msg;
830
831 // read HPLG pen size (this param is stored in mils)
832 // However, due to issues when converting this value from or to mm
833 // that can slightly change the value, update this param only if it
834 // is in use
835 if( getPlotFormat() == PLOT_FORMAT::HPGL )
836 {
838 {
840 msg.Printf( _( "HPGL pen size constrained." ) );
841 reporter.Report( msg, RPT_SEVERITY_INFO );
842 }
843 }
844 else // keep the last value (initial value if no HPGL plot made)
845 {
847 }
848
849 // X scale
850 double tmpDouble;
851 msg = m_fineAdjustXCtrl->GetValue();
852 msg.ToDouble( &tmpDouble );
853
855 {
856 msg.Printf( wxT( "%f" ), m_XScaleAdjust );
857 m_fineAdjustXCtrl->SetValue( msg );
858 msg.Printf( _( "X scale constrained." ) );
859 reporter.Report( msg, RPT_SEVERITY_INFO );
860 }
861
862 // Y scale
863 msg = m_fineAdjustYCtrl->GetValue();
864 msg.ToDouble( &tmpDouble );
865
867 {
868 msg.Printf( wxT( "%f" ), m_YScaleAdjust );
869 m_fineAdjustYCtrl->SetValue( msg );
870 msg.Printf( _( "Y scale constrained." ) );
871 reporter.Report( msg, RPT_SEVERITY_INFO );
872 }
873
874 auto cfg = m_parent->GetPcbNewSettings();
875
877 cfg->m_Plot.fine_scale_y = m_YScaleAdjust;
878
879 cfg->m_Plot.check_zones_before_plotting = m_zoneFillCheck->GetValue();
880
881 // PS Width correction
884 {
886 msg.Printf( _( "Width correction constrained. The width correction value must be in the"
887 " range of [%s; %s] for the current design rules." ),
890 reporter.Report( msg, RPT_SEVERITY_WARNING );
891 }
892
893 // Store m_PSWidthAdjust in mm in user config
894 cfg->m_Plot.ps_fine_width_adjust = pcbIUScale.IUTomm( m_PSWidthAdjust );
895
896 tempOptions.SetFormat( getPlotFormat() );
897
898 tempOptions.SetDisableGerberMacros( m_disableApertMacros->GetValue() );
899 tempOptions.SetUseGerberProtelExtensions( m_useGerberExtensions->GetValue() );
900 tempOptions.SetUseGerberX2format( m_useGerberX2Format->GetValue() );
901 tempOptions.SetIncludeGerberNetlistInfo( m_useGerberNetAttributes->GetValue() );
902 tempOptions.SetCreateGerberJobFile( m_generateGerberJobFile->GetValue() );
903
904 tempOptions.SetGerberPrecision( m_coordFormatCtrl->GetSelection() == 0 ? 5 : 6 );
905 tempOptions.SetSvgPrecision( m_svgPrecsision->GetValue() );
906
907 LSET selectedLayers;
908
909 for( unsigned i = 0; i < m_layerList.size(); i++ )
910 {
911 if( m_layerCheckListBox->IsChecked( i ) )
912 selectedLayers.set( m_layerList[i] );
913 }
914
915 // Get a list of copper layers that aren't being used by inverting enabled layers.
916 LSET disabledCopperLayers = LSET::AllCuMask() & ~m_parent->GetBoard()->GetEnabledLayers();
917
918 LSET plotOnAllLayers;
919
920 // Add selected layers from plot on all layers list in order set by user.
921 wxArrayInt plotOnAllLayersSelections;
922
923 m_plotAllLayersList->GetCheckedItems( plotOnAllLayersSelections );
924
925 size_t count = plotOnAllLayersSelections.GetCount();
926
927 for( size_t i = 0; i < count; i++ )
928 {
929 int index = plotOnAllLayersSelections.Item( i );
930 wxClientData* tmp = m_plotAllLayersList->GetClientObject( index );
931 PCB_LAYER_ID_CLIENT_DATA* layerId = dynamic_cast<PCB_LAYER_ID_CLIENT_DATA*>( tmp );
932
933 wxCHECK2( layerId, continue );
934
935 plotOnAllLayers.set( layerId->GetData() );
936 }
937
938 tempOptions.SetPlotOnAllLayersSelection( plotOnAllLayers );
939
940 // Enable all of the disabled copper layers.
941 // If someone enables more copper layers they will be selected by default.
942 selectedLayers = selectedLayers | disabledCopperLayers;
943 tempOptions.SetLayerSelection( selectedLayers );
944
945 tempOptions.SetNegative( m_plotPSNegativeOpt->GetValue() );
946 tempOptions.SetA4Output( m_forcePSA4OutputOpt->GetValue() );
947
948 // Set output directory and replace backslashes with forward ones
949 wxString dirStr;
950 dirStr = m_outputDirectoryName->GetValue();
951 dirStr.Replace( wxT( "\\" ), wxT( "/" ) );
952 tempOptions.SetOutputDirectory( dirStr );
954
955 if( !m_plotOpts.IsSameAs( tempOptions ) )
956 {
957 m_parent->SetPlotSettings( tempOptions );
959 m_plotOpts = tempOptions;
960 }
961}
962
963
964void DIALOG_PLOT::OnGerberX2Checked( wxCommandEvent& event )
965{
966 // Currently: do nothing
967}
968
969
970void DIALOG_PLOT::Plot( wxCommandEvent& event )
971{
972 BOARD* board = m_parent->GetBoard();
973
975
976 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
978
980
982
983 // If no layer selected, we have nothing plotted.
984 // Prompt user if it happens because he could think there is a bug in Pcbnew.
985 if( !m_plotOpts.GetLayerSelection().any() )
986 {
987 DisplayError( this, _( "No layer selected, Nothing to plot" ) );
988 return;
989 }
990
991 // Create output directory if it does not exist (also transform it in absolute form).
992 // Bail if it fails.
993
994 std::function<bool( wxString* )> textResolver =
995 [&]( wxString* token ) -> bool
996 {
997 // Handles board->GetTitleBlock() *and* board->GetProject()
998 return m_parent->GetBoard()->ResolveTextVar( token, 0 );
999 };
1000
1001 wxString path = m_plotOpts.GetOutputDirectory();
1002 path = ExpandTextVars( path, &textResolver );
1004
1005 wxFileName outputDir = wxFileName::DirName( path );
1006 wxString boardFilename = m_parent->GetBoard()->GetFileName();
1007 REPORTER& reporter = m_messagesPanel->Reporter();
1008
1009 if( !EnsureFileDirectoryExists( &outputDir, boardFilename, &reporter ) )
1010 {
1011 wxString msg;
1012 msg.Printf( _( "Could not write plot files to folder '%s'." ), outputDir.GetPath() );
1013 DisplayError( this, msg );
1014 return;
1015 }
1016
1017 if( m_zoneFillCheck->GetValue() )
1018 m_parent->GetToolManager()->GetTool<ZONE_FILLER_TOOL>()->CheckAllZones( this );
1019
1020 m_plotOpts.SetAutoScale( false );
1021
1022 switch( m_plotOpts.GetScaleSelection() )
1023 {
1024 default: m_plotOpts.SetScale( 1 ); break;
1025 case 0: m_plotOpts.SetAutoScale( true ); break;
1026 case 2: m_plotOpts.SetScale( 1.5 ); break;
1027 case 3: m_plotOpts.SetScale( 2 ); break;
1028 case 4: m_plotOpts.SetScale( 3 ); break;
1029 }
1030
1031 /* If the scale factor edit controls are disabled or the scale value
1032 * is 0, don't adjust the base scale factor. This fixes a bug when
1033 * the default scale adjust is initialized to 0 and saved in program
1034 * settings resulting in a divide by zero fault.
1035 */
1036 if( getPlotFormat() == PLOT_FORMAT::POST )
1037 {
1038 if( m_XScaleAdjust != 0.0 )
1040
1041 if( m_YScaleAdjust != 0.0 )
1043
1045 }
1046
1047 wxString file_ext( GetDefaultPlotExtension( m_plotOpts.GetFormat() ) );
1048
1049 // Test for a reasonable scale value
1050 // XXX could this actually happen? isn't it constrained in the apply function?
1052 DisplayInfoMessage( this, _( "Warning: Scale option set to a very small value" ) );
1053
1055 DisplayInfoMessage( this, _( "Warning: Scale option set to a very large value" ) );
1056
1057 GERBER_JOBFILE_WRITER jobfile_writer( board, &reporter );
1058
1059 // Save the current plot options in the board
1061
1062 wxBusyCursor dummy;
1063
1064 for( LSEQ seq = m_plotOpts.GetLayerSelection().UIOrder(); seq; ++seq )
1065 {
1066 LSEQ plotSequence;
1067
1068 // Base layer always gets plotted first.
1069 plotSequence.push_back( *seq );
1070
1071 // Add selected layers from plot on all layers list in order set by user.
1072 wxArrayInt plotOnAllLayers;
1073
1074 if( m_plotAllLayersList->GetCheckedItems( plotOnAllLayers ) )
1075 {
1076 size_t count = plotOnAllLayers.GetCount();
1077
1078 for( size_t i = 0; i < count; i++ )
1079 {
1080 int index = plotOnAllLayers.Item( i );
1081 wxClientData* tmp = m_plotAllLayersList->GetClientObject( index );
1082 PCB_LAYER_ID_CLIENT_DATA* layerId = dynamic_cast<PCB_LAYER_ID_CLIENT_DATA*>( tmp );
1083
1084 wxCHECK2( layerId, continue );
1085
1086 // Don't plot the same layer more than once;
1087 if( find( plotSequence.begin(), plotSequence.end(), layerId->GetData() ) !=
1088 plotSequence.end() )
1089 continue;
1090
1091 plotSequence.push_back( layerId->GetData() );
1092 }
1093 }
1094
1095 PCB_LAYER_ID layer = *seq;
1096
1097 // All copper layers that are disabled are actually selected
1098 // This is due to wonkyness in automatically selecting copper layers
1099 // for plotting when adding more than two layers to a board.
1100 // If plot options become accessible to the layers setup dialog
1101 // please move this functionality there!
1102 // This skips a copper layer if it is actually disabled on the board.
1103 if( ( LSET::AllCuMask() & ~board->GetEnabledLayers() )[layer] )
1104 continue;
1105
1106 // Pick the basename from the board file
1107 wxFileName fn( boardFilename );
1108
1109 // Use Gerber Extensions based on layer number
1110 // (See http://en.wikipedia.org/wiki/Gerber_File)
1111 if( m_plotOpts.GetFormat() == PLOT_FORMAT::GERBER && m_useGerberExtensions->GetValue() )
1112 file_ext = GetGerberProtelExtension( layer );
1113
1114 BuildPlotFileName( &fn, outputDir.GetPath(), board->GetLayerName( layer ), file_ext );
1115 wxString fullname = fn.GetFullName();
1116 jobfile_writer.AddGbrFile( layer, fullname );
1117
1118 LOCALE_IO toggle;
1119
1120 //@todo allow controlling the sheet name and path that will be displayed in the title block
1121 // Leave blank for now
1122 PLOTTER* plotter = StartPlotBoard( board, &m_plotOpts, layer, fn.GetFullPath(),
1123 wxEmptyString, wxEmptyString );
1124
1125 // Print diags in messages box:
1126 wxString msg;
1127
1128 if( plotter )
1129 {
1130 PlotBoardLayers( board, plotter, plotSequence, m_plotOpts );
1131 PlotInteractiveLayer( board, plotter, m_plotOpts );
1132 plotter->EndPlot();
1133 delete plotter->RenderSettings();
1134 delete plotter;
1135
1136 msg.Printf( _( "Plotted to '%s'." ), fn.GetFullPath() );
1137 reporter.Report( msg, RPT_SEVERITY_ACTION );
1138 }
1139 else
1140 {
1141 msg.Printf( _( "Failed to create file '%s'." ), fn.GetFullPath() );
1142 reporter.Report( msg, RPT_SEVERITY_ERROR );
1143 }
1144
1145 wxSafeYield(); // displays report message.
1146 }
1147
1148 if( m_plotOpts.GetFormat() == PLOT_FORMAT::GERBER && m_plotOpts.GetCreateGerberJobFile() )
1149 {
1150 // Pick the basename from the board file
1151 wxFileName fn( boardFilename );
1152
1153 // Build gerber job file from basename
1154 BuildPlotFileName( &fn, outputDir.GetPath(), wxT( "job" ), GerberJobFileExtension );
1155 jobfile_writer.CreateJobFile( fn.GetFullPath() );
1156 }
1157
1158 reporter.ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
1159}
1160
1161
1162void DIALOG_PLOT::onRunDRC( wxCommandEvent& event )
1163{
1164 PCB_EDIT_FRAME* parent = dynamic_cast<PCB_EDIT_FRAME*>( GetParent() );
1165
1166 if( parent )
1167 {
1168 DRC_TOOL* drcTool = parent->GetToolManager()->GetTool<DRC_TOOL>();
1169
1170 // First close an existing dialog if open
1171 // (low probability, but can happen)
1172 drcTool->DestroyDRCDialog();
1173
1174 // Open a new drc dialog, with the right parent frame, and in Modal Mode
1175 drcTool->ShowDRCDialog( this );
1176
1177 // Update DRC warnings on return to this dialog
1178 reInitDialog();
1179 }
1180}
1181
1182
1183void DIALOG_PLOT::onBoardSetup( wxHyperlinkEvent& aEvent )
1184{
1185 PCB_EDIT_FRAME* parent = dynamic_cast<PCB_EDIT_FRAME*>( GetParent() );
1186
1187 if( parent )
1188 {
1189 parent->ShowBoardSetupDialog( _( "Solder Mask/Paste" ) );
1190
1191 // Update warnings on return to this dialog
1192 reInitDialog();
1193 }
1194}
1195
1196
1197void DIALOG_PLOT::onPlotAllListMoveUp( wxCommandEvent& aEvent )
1198{
1199 if( m_plotAllLayersList->CanMoveCurrentUp() )
1200 m_plotAllLayersList->MoveCurrentUp();
1201}
1202
1203
1204void DIALOG_PLOT::onPlotAllListMoveDown( wxCommandEvent& aEvent )
1205{
1206 if( m_plotAllLayersList->CanMoveCurrentDown() )
1207 m_plotAllLayersList->MoveCurrentDown();
1208}
1209
1210
1211void DIALOG_PLOT::onPlotFPRefs( wxCommandEvent& aEvent )
1212{
1213 if( aEvent.IsChecked() )
1214 m_plotFootprintText->SetValue( true );
1215}
1216
1217
1218void DIALOG_PLOT::onPlotFPValues( wxCommandEvent& aEvent )
1219{
1220 if( aEvent.IsChecked() )
1221 m_plotFootprintText->SetValue( true );
1222}
1223
1224
1225void DIALOG_PLOT::onPlotFPText( wxCommandEvent& aEvent )
1226{
1227 if( !aEvent.IsChecked() )
1228 {
1229 m_plotFootprintRefs->SetValue( false );
1230 m_plotFootprintValues->SetValue( false );
1231 }
1232}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
constexpr EDA_IU_SCALE unityScale
Definition: base_units.h:112
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:106
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:172
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:271
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:614
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: board.cpp:376
MARKERS & Markers()
Definition: board.h:322
const wxString & GetFileName() const
Definition: board.h:308
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:501
PROJECT * GetProject() const
Definition: board.h:449
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:731
Class DIALOG_PLOT_BASE.
wxCheckBox * m_frontFPPropertyPopups
wxStaticText * m_DRCExclusionsWarning
wxCheckBox * m_backFPPropertyPopups
wxTextCtrl * m_fineAdjustXCtrl
wxBoxSizer * bmiddleSizer
wxStaticBoxSizer * m_PDFOptionsSizer
wxCheckBox * m_disableApertMacros
wxChoice * m_scaleOpt
wxChoice * m_coordFormatCtrl
wxCheckBox * m_DXF_plotModeOpt
wxChoice * m_SVGColorChoice
STD_BITMAP_BUTTON * m_browseButton
wxTextCtrl * m_outputDirectoryName
wxSpinCtrl * m_svgPrecsision
wxTextCtrl * m_fineAdjustYCtrl
wxStaticBoxSizer * m_HPGLOptionsSizer
wxCheckBox * m_tentVias
wxCheckBox * m_plotFootprintRefs
wxCheckBox * m_useAuxOriginCheckBox
wxStaticBoxSizer * m_PSOptionsSizer
wxCheckBox * m_plotFootprintText
wxCheckBox * m_plotPSNegativeOpt
wxCheckBox * m_DXF_plotTextStrokeFontOpt
wxChoice * m_plotModeOpt
wxCheckBox * m_useGerberExtensions
wxCheckBox * m_plotSheetRef
wxBoxSizer * m_SizerSolderMaskAlert
wxCheckBox * m_generateGerberJobFile
wxCheckBox * m_useGerberX2Format
wxCheckListBox * m_layerCheckListBox
wxCheckBox * m_plotMirrorOpt
wxStaticBoxSizer * m_svgOptionsSizer
wxCheckBox * m_forcePSA4OutputOpt
wxCheckBox * m_useGerberNetAttributes
wxCheckBox * m_sketchPadsOnFabLayers
wxCheckBox * m_subtractMaskFromSilk
wxBoxSizer * m_PlotOptionsSizer
wxChoice * m_DXF_plotUnits
wxStaticBoxSizer * m_SizerDXF_options
wxCheckBox * m_plotInvisibleText
wxChoice * m_drillShapeOpt
wxCheckBox * m_plotFootprintValues
wxCheckBox * m_zoneFillCheck
wxStaticBoxSizer * m_GerberOptionsSizer
WX_HTML_REPORT_PANEL * m_messagesPanel
wxChoice * m_PDFColorChoice
wxChoice * m_plotFormatOpt
wxBoxSizer * m_MainSizer
void OnRightClick(wxMouseEvent &event) override
void reInitDialog()
PCB_PLOT_PARAMS m_plotOpts
Definition: dialog_plot.h:96
void onPlotAllListMoveUp(wxCommandEvent &aEvent)
void OnChangeDXFPlotMode(wxCommandEvent &event) override
int m_widthAdjustMinValue
Definition: dialog_plot.h:88
UNIT_BINDER m_trackWidthCorrection
Definition: dialog_plot.h:92
void onBoardSetup(wxHyperlinkEvent &aEvent) override
PCB_EDIT_FRAME * m_parent
Definition: dialog_plot.h:78
void Plot(wxCommandEvent &event) override
void applyPlotSettings()
int m_PSWidthAdjust
Definition: dialog_plot.h:84
wxString m_DRCWarningTemplate
Definition: dialog_plot.h:94
void setPlotModeChoiceSelection(OUTLINE_MODE aPlotMode)
Definition: dialog_plot.h:73
void OnOutputDirectoryBrowseClicked(wxCommandEvent &event) override
wxRearrangeList * m_plotAllLayersList
Definition: dialog_plot.h:98
void onPlotAllListMoveDown(wxCommandEvent &aEvent)
void onRunDRC(wxCommandEvent &event) override
double m_YScaleAdjust
Definition: dialog_plot.h:82
void OnSetScaleOpt(wxCommandEvent &event) override
virtual ~DIALOG_PLOT()
static LSEQ m_lastPlotOnAllLayersOrder
The plot on all layers ordering the last time the dialog was opened.
Definition: dialog_plot.h:109
void OnPopUpLayers(wxCommandEvent &event) override
void onPlotFPText(wxCommandEvent &aEvent) override
static LSET m_lastLayerSet
The plot layer set that last time the dialog was opened.
Definition: dialog_plot.h:106
DIALOG_PLOT(PCB_EDIT_FRAME *parent)
Definition: dialog_plot.cpp:75
void CreateDrillFile(wxCommandEvent &event) override
void onPlotFPValues(wxCommandEvent &aEvent) override
void onPlotFPRefs(wxCommandEvent &aEvent) override
UNIT_BINDER m_defaultPenSize
Definition: dialog_plot.h:91
double m_XScaleAdjust
Definition: dialog_plot.h:80
PLOT_FORMAT getPlotFormat()
int m_widthAdjustMaxValue
Definition: dialog_plot.h:89
void OnGerberX2Checked(wxCommandEvent &event) override
void init_Dialog()
void SetPlotFormat(wxCommandEvent &event) override
LSEQ m_layerList
Definition: dialog_plot.h:79
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void ShowDRCDialog(wxWindow *aParent)
Opens the DRC dialog.
Definition: drc_tool.cpp:71
void DestroyDRCDialog()
Close and free the DRC dialog.
Definition: drc_tool.cpp:122
GERBER_JOBFILE_WRITER is a class used to create Gerber job file a Gerber job file stores info to make...
bool CreateJobFile(const wxString &aFullFilename)
Creates a Gerber job file.
void AddGbrFile(PCB_LAYER_ID aLayer, wxString &aFilename)
add a gerber file name and type in job file list
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:49
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:513
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:552
LSEQ UIOrder() const
Definition: lset.cpp:922
static LSET AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
Definition: lset.cpp:841
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
DIALOG_PLOT m_Plot
virtual const PCB_PLOT_PARAMS & GetPlotSettings() const
Return the PCB_PLOT_PARAMS for the BOARD owned by this frame.
PCBNEW_SETTINGS * GetPcbNewSettings() const
BOARD * GetBoard() const
virtual void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings)
The main frame for Pcbnew.
void ShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString)
void OnModify() override
Must be called after a board change to set the modified flag.
A helper wxWidgets control client data object to store layer IDs.
Definition: dialog_plot.cpp:61
PCB_LAYER_ID GetData() const
Definition: dialog_plot.cpp:68
void SetData(PCB_LAYER_ID aId)
Definition: dialog_plot.cpp:66
PCB_LAYER_ID_CLIENT_DATA(PCB_LAYER_ID aId)
Definition: dialog_plot.cpp:64
Parameters and options when plotting/printing a board.
bool GetNegative() const
PLOT_FORMAT GetFormat() const
void SetDrillMarksType(DRILL_MARKS aVal)
bool GetUseAuxOrigin() const
void SetLayerSelection(LSET aSelection)
void SetOutputDirectory(const wxString &aDir)
void SetPlotReference(bool aFlag)
void SetSketchPadsOnFabLayers(bool aFlag)
void SetUseGerberX2format(bool aUse)
bool GetMirror() const
DXF_UNITS GetDXFPlotUnits() const
bool GetPlotInvisibleText() const
void SetA4Output(int aForce)
PLOT_TEXT_MODE GetTextMode() const
void SetDXFPlotPolygonMode(bool aFlag)
void SetAutoScale(bool aFlag)
double GetHPGLPenDiameter() const
unsigned GetSvgPrecision() const
void SetPlotFrameRef(bool aFlag)
unsigned GetBlackAndWhite() const
double GetScale() const
bool GetCreateGerberJobFile() const
bool GetDXFPlotPolygonMode() const
void SetSketchPadLineWidth(int aWidth)
LSET GetLayerSelection() const
bool GetPlotReference() const
wxString GetOutputDirectory() const
int GetScaleSelection() const
void SetPlotOnAllLayersSelection(LSET aSelection)
LSET GetPlotOnAllLayersSelection() const
bool SetHPGLPenDiameter(double aValue)
bool m_PDFFrontFPPropertyPopups
Generate PDF property popup menus for footprints.
void SetScale(double aVal)
void SetDisableGerberMacros(bool aDisable)
void SetScaleSelection(int aSelection)
void SetFineScaleAdjustX(double aVal)
void SetMirror(bool aFlag)
void SetBlackAndWhite(bool blackAndWhite)
void SetPlotViaOnMaskLayer(bool aFlag)
void SetPlotFPText(bool aFlag)
void SetGerberPrecision(int aPrecision)
void SetSubtractMaskFromSilk(bool aSubtract)
bool GetSketchPadsOnFabLayers() const
bool GetSubtractMaskFromSilk() const
void SetPlotValue(bool aFlag)
int GetGerberPrecision() const
void SetUseGerberProtelExtensions(bool aUse)
bool GetA4Output() const
DRILL_MARKS GetDrillMarksType() const
bool GetUseGerberX2format() const
void SetDXFPlotUnits(DXF_UNITS aUnit)
void SetColorSettings(COLOR_SETTINGS *aSettings)
bool IsSameAs(const PCB_PLOT_PARAMS &aPcbPlotParams) const
Compare current settings to aPcbPlotParams, including not saved parameters in brd file.
void SetIncludeGerberNetlistInfo(bool aUse)
bool GetPlotValue() const
void SetPlotInvisibleText(bool aFlag)
void SetCreateGerberJobFile(bool aCreate)
bool GetIncludeGerberNetlistInfo() const
void SetNegative(bool aFlag)
void SetPlotMode(OUTLINE_MODE aPlotMode)
void SetUseAuxOrigin(bool aAux)
bool m_PDFBackFPPropertyPopups
on front and/or back of board
bool GetPlotFPText() const
void SetTextMode(PLOT_TEXT_MODE aVal)
bool GetUseGerberProtelExtensions() const
void SetSvgPrecision(unsigned aPrecision)
bool GetPlotFrameRef() const
void SetFormat(PLOT_FORMAT aFormat)
bool GetPlotViaOnMaskLayer() const
bool GetDisableGerberMacros() const
void SetFineScaleAdjustY(double aVal)
OUTLINE_MODE GetPlotMode() const
void SetWidthAdjust(int aVal)
Base plotter engine class.
Definition: plotter.h:104
virtual bool EndPlot()=0
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:135
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:69
wxString m_PcbLastPath[LAST_PATH_SIZE]
MRU path storage.
Definition: project_file.h:156
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:158
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
Definition: project.cpp:322
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
virtual REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Places the report at the end of the list, for objects that support report ordering.
Definition: reporter.h:99
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
T * GetAppSettings()
Returns a handle to the a given settings by type If the settings have already been loaded,...
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
A bitmap button widget that behaves like a standard dialog button except with an icon.
void SetBitmap(const wxBitmapBundle &aBmp)
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
wxString StringFromValue(double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Converts aValue in internal units into a united string.
virtual long long int GetValue()
Return the current value in Internal Units.
void Enable(bool aEnable)
Enable/disable the label, widget and units label.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
void SetFileName(const wxString &aReportFileName)
Handle actions specific to filling copper zones.
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
Definition: common.cpp:317
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:345
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:58
wxString GetDefaultPlotExtension(PLOT_FORMAT aFormat)
Returns the default plot extension for a format.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:282
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:334
This file is part of the common library.
static bool setDouble(double *aResult, double aValue, double aMin, double aMax)
static bool setInt(int *aResult, int aValue, int aMin, int aMax)
#define DLG_WINDOW_NAME
Definition: dialog_plot.h:30
#define _(s)
Classes used to generate a Gerber job file in JSON.
static const bool FILLED
Definition: gr_basic.cpp:30
const std::string GerberJobFileExtension
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:847
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ F_CrtYd
Definition: layer_ids.h:118
@ F_Fab
Definition: layer_ids.h:121
@ B_CrtYd
Definition: layer_ids.h:117
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
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)
Returns the string from aValue according to aUnits (inch, mm ...) for display.
Definition: eda_units.cpp:225
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:74
@ SKETCH
Definition: outline_mode.h:26
const wxString GetGerberProtelExtension(int aLayer)
Definition: pcbplot.cpp:42
void BuildPlotFileName(wxFileName *aFilename, const wxString &aOutputDir, const wxString &aSuffix, const wxString &aExtension)
Complete a plot filename.
Definition: pcbplot.cpp:361
PLOTTER * StartPlotBoard(BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer, const wxString &aFullFileName, const wxString &aSheetName, const wxString &aSheetPath)
Open a new plotfile using the options (and especially the format) specified in the options and prepar...
void PlotBoardLayers(BOARD *aBoard, PLOTTER *aPlotter, const LSEQ &aLayerSequence, const PCB_PLOT_PARAMS &aPlotOptions)
Plot a sequence of board layer IDs.
void PlotInteractiveLayer(BOARD *aBoard, PLOTTER *aPlotter, const PCB_PLOT_PARAMS &aPlotOpt)
Plot interactive items (hypertext links, properties, etc.).
#define PLOT_MIN_SCALE
Definition: pcbplot.h:55
#define PLOT_MAX_SCALE
Definition: pcbplot.h:56
see class PGM_BASE
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:64
@ LAST_PATH_PLOT
Definition: project_file.h:57
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_EXCLUSION
@ RPT_SEVERITY_INFO
@ RPT_SEVERITY_ACTION
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:115
std::vector< FAB_LAYER_COLOR > dummy
constexpr double IUTomm(int iu) const
Definition: base_units.h:87
const double IU_PER_MM
Definition: base_units.h:77
const double IU_PER_MILS
Definition: base_units.h:78
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85
Definition of file extensions used in Kicad.