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#include <wx/msgdlg.h>
52
53
57
58
62class PCB_LAYER_ID_CLIENT_DATA : public wxClientData
63{
64public:
67 { }
68
70 m_id( aId )
71 { }
72
73 void SetData( PCB_LAYER_ID aId ) { m_id = aId; }
74 PCB_LAYER_ID Layer() const { return m_id; }
75
76private:
78};
79
80
81PCB_LAYER_ID_CLIENT_DATA* getLayerClientData( const wxRearrangeList* aList, int aIdx )
82{
83 return static_cast<PCB_LAYER_ID_CLIENT_DATA*>( aList->GetClientObject( aIdx ) );
84}
85
86
88 DIALOG_PLOT_BASE( aParent ),
89 m_parent( aParent ),
90 m_defaultPenSize( aParent, m_hpglPenLabel, m_hpglPenCtrl, m_hpglPenUnits ),
91 m_trackWidthCorrection( aParent, m_widthAdjustLabel, m_widthAdjustCtrl, m_widthAdjustUnits )
92{
93 BOARD* board = m_parent->GetBoard();
94
95 SetName( DLG_WINDOW_NAME );
96 m_plotOpts = aParent->GetPlotSettings();
98
99 m_messagesPanel->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
100
101 int order = 0;
102 LSET plotOnAllLayersSelection = m_plotOpts.GetPlotOnAllLayersSelection();
103 wxArrayInt plotAllLayersOrder;
104 wxArrayString plotAllLayersChoicesStrings;
105 std::vector<PCB_LAYER_ID> layersIdChoiceList;
106 int textWidth = 0;
107
108 for( PCB_LAYER_ID layer : board->GetEnabledLayers().SeqStackupForPlotting() )
109 {
110 wxString layerName = board->GetLayerName( layer );
111
112 // wxCOL_WIDTH_AUTOSIZE doesn't work on all platforms, so we calculate width here
113 textWidth = std::max( textWidth, KIUI::GetTextSize( layerName, m_layerCheckListBox ).x );
114
115 plotAllLayersChoicesStrings.Add( layerName );
116 layersIdChoiceList.push_back( layer );
117
118 size_t size = plotOnAllLayersSelection.size();
119
120 if( ( static_cast<size_t>( layer ) <= size ) && plotOnAllLayersSelection.test( layer ) )
121 plotAllLayersOrder.push_back( order );
122 else
123 plotAllLayersOrder.push_back( ~order );
124
125 order += 1;
126 }
127
128 int checkColSize = 22;
129 int layerColSize = textWidth + 15;
130
131#ifdef __WXMAC__
132 // TODO: something in wxWidgets 3.1.x pads checkbox columns with extra space. (It used to
133 // also be that the width of the column would get set too wide (to 30), but that's patched in
134 // our local wxWidgets fork.)
135 checkColSize += 30;
136#endif
137
138 m_layerCheckListBox->SetMinClientSize( wxSize( checkColSize + layerColSize,
139 m_layerCheckListBox->GetMinClientSize().y ) );
140
141 wxStaticBox* allLayersLabel = new wxStaticBox( this, wxID_ANY, _( "Plot on All Layers" ) );
142 wxStaticBoxSizer* sbSizer = new wxStaticBoxSizer( allLayersLabel, wxVERTICAL );
143
144 m_plotAllLayersList = new wxRearrangeList( sbSizer->GetStaticBox(), wxID_ANY,
145 wxDefaultPosition, wxDefaultSize,
146 plotAllLayersOrder, plotAllLayersChoicesStrings, 0 );
147
148 m_plotAllLayersList->SetMinClientSize( wxSize( checkColSize + layerColSize,
149 m_plotAllLayersList->GetMinClientSize().y ) );
150
151 // Attach the LAYER_ID to each item in m_plotAllLayersList
152 // plotAllLayersChoicesStrings and layersIdChoiceList are in the same order,
153 // but m_plotAllLayersList has these strings in a different order
154 for( size_t idx = 0; idx < layersIdChoiceList.size(); idx++ )
155 {
156 wxString& txt = plotAllLayersChoicesStrings[idx];
157 int list_idx = m_plotAllLayersList->FindString( txt, true );
158
159 PCB_LAYER_ID layer_id = layersIdChoiceList[idx];
160 m_plotAllLayersList->SetClientObject( list_idx, new PCB_LAYER_ID_CLIENT_DATA( layer_id ) );
161 }
162
163 sbSizer->Add( m_plotAllLayersList, 1, wxALL | wxEXPAND | wxFIXED_MINSIZE, 3 );
164
165 wxBoxSizer* bButtonSizer;
166 bButtonSizer = new wxBoxSizer( wxHORIZONTAL );
167
168 m_bpMoveUp = new STD_BITMAP_BUTTON( sbSizer->GetStaticBox(), wxID_ANY, wxNullBitmap,
169 wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW | 0 );
170 m_bpMoveUp->SetToolTip( _( "Move current selection up" ) );
171 m_bpMoveUp->SetBitmap( KiBitmapBundle( BITMAPS::small_up ) );
172
173 bButtonSizer->Add( m_bpMoveUp, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 3 );
174
175 m_bpMoveDown = new STD_BITMAP_BUTTON( sbSizer->GetStaticBox(), wxID_ANY, wxNullBitmap,
176 wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW | 0 );
177 m_bpMoveDown->SetToolTip( _( "Move current selection down" ) );
178 m_bpMoveDown->SetBitmap( KiBitmapBundle( BITMAPS::small_down ) );
179
180 bButtonSizer->Add( m_bpMoveDown, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5 );
181
182 sbSizer->Add( bButtonSizer, 0, wxALL | wxEXPAND, 3 );
183
184 bmiddleSizer->Insert( 1, sbSizer, 1, wxALL | wxEXPAND, 5 );
185
186 init_Dialog();
187
188 SetupStandardButtons( { { wxID_OK, _( "Plot" ) },
189 { wxID_APPLY, _( "Generate Drill Files..." ) },
190 { wxID_CANCEL, _( "Close" ) } } );
191
192 GetSizer()->Fit( this );
193 GetSizer()->SetSizeHints( this );
194
195 m_bpMoveUp->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveUp, this );
196 m_bpMoveDown->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveDown, this );
197
198 m_layerCheckListBox->Connect( wxEVT_RIGHT_DOWN,
199 wxMouseEventHandler( DIALOG_PLOT::OnRightClickLayers ), nullptr,
200 this );
201
202 m_plotAllLayersList->Connect( wxEVT_RIGHT_DOWN,
203 wxMouseEventHandler( DIALOG_PLOT::OnRightClickAllLayers ), nullptr,
204 this );
205}
206
207
209{
210 s_lastAllLayersOrder.clear();
211
212 for( int ii = 0; ii < (int) m_plotAllLayersList->GetCount(); ++ii )
214
215 m_bpMoveDown->Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveDown, this );
216 m_bpMoveUp->Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveUp, this );
217}
218
219
221{
222 BOARD* board = m_parent->GetBoard();
223 wxFileName fileName;
224
225 PROJECT_FILE& projectFile = m_parent->Prj().GetProjectFile();
227
228 if( !projectFile.m_PcbLastPath[ LAST_PATH_PLOT ].IsEmpty() )
230
233
235
236 m_browseButton->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) );
237
238 // m_PSWidthAdjust is stored in mm in user config
240
241 // The reasonable width correction value must be in a range of
242 // [-(MinTrackWidth-1), +(MinClearanceValue-1)] decimils.
245
246 switch( m_plotOpts.GetFormat() )
247 {
248 default:
249 case PLOT_FORMAT::GERBER: m_plotFormatOpt->SetSelection( 0 ); break;
250 case PLOT_FORMAT::POST: m_plotFormatOpt->SetSelection( 1 ); break;
251 case PLOT_FORMAT::SVG: m_plotFormatOpt->SetSelection( 2 ); break;
252 case PLOT_FORMAT::DXF: m_plotFormatOpt->SetSelection( 3 ); break;
253 case PLOT_FORMAT::HPGL: m_plotFormatOpt->SetSelection( 4 ); break;
254 case PLOT_FORMAT::PDF: m_plotFormatOpt->SetSelection( 5 ); break;
255 }
256
257 // Set units and value for HPGL pen size (this param is in mils).
259
260 // Test for a reasonable scale value. Set to 1 if problem
263 {
265 }
266
268 EDA_UNITS::UNSCALED,
269 m_XScaleAdjust ) );
270
272 EDA_UNITS::UNSCALED,
273 m_YScaleAdjust ) );
274
275 // Test for a reasonable PS width correction value. Set to 0 if problem.
276 if( m_PSWidthAdjust < m_widthAdjustMinValue || m_PSWidthAdjust > m_widthAdjustMaxValue )
277 m_PSWidthAdjust = 0.;
278
280
283
284 // Could devote a PlotOrder() function in place of UIOrder().
286
287 // Populate the check list box by all enabled layers names.
288 for( PCB_LAYER_ID layer : m_layerList )
289 {
290 int checkIndex = m_layerCheckListBox->Append( board->GetLayerName( layer ) );
291
292 if( m_plotOpts.GetLayerSelection()[layer] )
293 m_layerCheckListBox->Check( checkIndex );
294 }
295
297
298 // Option for disabling Gerber Aperture Macro (for broken Gerber readers)
300
301 // Option for using proper Gerber extensions. Note also Protel extensions are
302 // a broken feature. However, for now, we need to handle it.
304
305 // Option for including Gerber attributes, from Gerber X2 format, in the output
306 // In X1 format, they will be added as comments
308
309 // Option for including Gerber netlist info (from Gerber X2 format) in the output
311
312 // Option to generate a Gerber job file
314
315 // Gerber precision for coordinates
316 m_coordFormatCtrl->SetSelection( m_plotOpts.GetGerberPrecision() == 5 ? 0 : 1 );
317
318 // SVG precision and units for coordinates
320
321 // Option to exclude pads from silkscreen layers
325
329
330 if( m_plotDNP->GetValue() )
331 {
333 m_hideDNP->SetValue( true );
334 else
335 m_crossoutDNP->SetValue( true );
336 }
337
338 m_hideDNP->Enable( m_plotDNP->GetValue() );
339 m_crossoutDNP->Enable( m_plotDNP->GetValue() );
340
341 // Option to tent vias
343
344 // Option to use aux origin
346
347 // Option to plot page references:
349
350 // Option to force ploting of hidden text in footprints
352
353 // Options to plot pads and vias holes
354 m_drillShapeOpt->SetSelection( (int)m_plotOpts.GetDrillMarksType() );
355
356 // Scale option
357 m_scaleOpt->SetSelection( m_plotOpts.GetScaleSelection() );
358
359 // Plot mode
361
362 // DXF outline mode
364
365 // DXF text mode
366 m_DXF_plotTextStrokeFontOpt->SetValue( m_plotOpts.GetTextMode() == PLOT_TEXT_MODE::DEFAULT );
367
368 // DXF units selection
369 m_DXF_plotUnits->SetSelection( m_plotOpts.GetDXFPlotUnits() == DXF_UNITS::INCHES ? 0 : 1);
370
371 // Plot mirror option
372 m_plotMirrorOpt->SetValue( m_plotOpts.GetMirror() );
373
374 // Black and white plotting
375 m_SVGColorChoice->SetSelection( m_plotOpts.GetBlackAndWhite() ? 1 : 0 );
376 m_PDFColorChoice->SetSelection( m_plotOpts.GetBlackAndWhite() ? 1 : 0 );
380
381 // Initialize a few other parameters, which can also be modified
382 // from the drill dialog
383 reInitDialog();
384
385 // Update options values:
386 wxCommandEvent cmd_event;
387 SetPlotFormat( cmd_event );
388 OnSetScaleOpt( cmd_event );
389}
390
391
393{
394 // after calling the Drill or DRC dialogs some parameters can be modified....
395
396 // Output directory
398
399 // Origin of coordinates:
401
402 int knownViolations = 0;
403 int exclusions = 0;
404
405 for( PCB_MARKER* marker : m_parent->GetBoard()->Markers() )
406 {
407 if( marker->GetSeverity() == RPT_SEVERITY_EXCLUSION )
408 exclusions++;
409 else
410 knownViolations++;
411 }
412
413 if( knownViolations || exclusions )
414 {
415 m_DRCExclusionsWarning->SetLabel( wxString::Format( m_DRCWarningTemplate, knownViolations,
416 exclusions ) );
418 }
419 else
420 {
422 }
423
424 BOARD* board = m_parent->GetBoard();
425 const BOARD_DESIGN_SETTINGS& brd_settings = board->GetDesignSettings();
426
427 if( getPlotFormat() == PLOT_FORMAT::GERBER &&
428 ( brd_settings.m_SolderMaskExpansion || brd_settings.m_SolderMaskMinWidth ) )
429 {
431 }
432 else
433 {
435 }
436}
437
438
440{
441 auto findLayer =
442 [&]( wxRearrangeList* aList, PCB_LAYER_ID aLayer ) -> int
443 {
444 for( int ii = 0; ii < (int) aList->GetCount(); ++ii )
445 {
446 if( getLayerClientData( aList, ii )->Layer() == aLayer )
447 return ii;
448 }
449
450 return -1;
451 };
452
453 int idx = 0;
454
455 for( PCB_LAYER_ID layer : aSeq )
456 {
457 int currentPos = findLayer( m_plotAllLayersList, layer );
458
459 while( currentPos > idx )
460 {
461 m_plotAllLayersList->Select( currentPos );
462 m_plotAllLayersList->MoveCurrentUp();
463 currentPos--;
464 }
465 }
466}
467
468
469#define ID_LAYER_FAB 13001
470#define ID_SELECT_COPPER_LAYERS 13002
471#define ID_DESELECT_COPPER_LAYERS 13003
472#define ID_SELECT_ALL_LAYERS 13004
473#define ID_DESELECT_ALL_LAYERS 13005
474#define ID_STACKUP_ORDER 13006
475
476
477// A helper function to show a popup menu, when the dialog is right clicked.
478void DIALOG_PLOT::OnRightClickLayers( wxMouseEvent& event )
479{
480 // Build a list of layers for usual fabrication: copper layers + tech layers without courtyard
481 LSET fab_layer_set = ( LSET::AllCuMask() | LSET::AllTechMask() ) & ~LSET( { B_CrtYd, F_CrtYd } );
482
483 wxMenu menu;
484 menu.Append( new wxMenuItem( &menu, ID_LAYER_FAB, _( "Select Fab Layers" ) ) );
485
486 menu.AppendSeparator();
487 menu.Append( new wxMenuItem( &menu, ID_SELECT_COPPER_LAYERS, _( "Select All Copper Layers" ) ) );
488 menu.Append( new wxMenuItem( &menu, ID_DESELECT_COPPER_LAYERS, _( "Deselect All Copper Layers" ) ) );
489
490 menu.AppendSeparator();
491 menu.Append( new wxMenuItem( &menu, ID_SELECT_ALL_LAYERS, _( "Select All Layers" ) ) );
492 menu.Append( new wxMenuItem( &menu, ID_DESELECT_ALL_LAYERS, _( "Deselect All Layers" ) ) );
493
494 menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
495 [&]( wxCommandEvent& aCmd )
496 {
497 switch( aCmd.GetId() )
498 {
499 case ID_LAYER_FAB: // Select layers usually needed to build a board
500 {
501 for( unsigned i = 0; i < m_layerList.size(); i++ )
502 {
503 LSET layermask( m_layerList[ i ] );
504
505 if( ( layermask & fab_layer_set ).any() )
506 m_layerCheckListBox->Check( i, true );
507 else
508 m_layerCheckListBox->Check( i, false );
509 }
510
511 break;
512 }
513
515 for( unsigned i = 0; i < m_layerList.size(); i++ )
516 {
517 if( IsCopperLayer( m_layerList[i] ) )
518 m_layerCheckListBox->Check( i, true );
519 }
520
521 break;
522
524 for( unsigned i = 0; i < m_layerList.size(); i++ )
525 {
526 if( IsCopperLayer( m_layerList[i] ) )
527 m_layerCheckListBox->Check( i, false );
528 }
529
530 break;
531
533 for( unsigned i = 0; i < m_layerList.size(); i++ )
534 m_layerCheckListBox->Check( i, true );
535
536 break;
537
539 for( unsigned i = 0; i < m_layerList.size(); i++ )
540 m_layerCheckListBox->Check( i, false );
541
542 break;
543
544 default:
545 aCmd.Skip();
546 }
547 } );
548
549 PopupMenu( &menu );
550}
551
552
553void DIALOG_PLOT::OnRightClickAllLayers( wxMouseEvent& event )
554{
555 wxMenu menu;
556 menu.Append( new wxMenuItem( &menu, ID_SELECT_ALL_LAYERS, _( "Select All Layers" ) ) );
557 menu.Append( new wxMenuItem( &menu, ID_DESELECT_ALL_LAYERS, _( "Deselect All Layers" ) ) );
558
559 menu.AppendSeparator();
560 menu.Append( new wxMenuItem( &menu, ID_STACKUP_ORDER, _( "Order as Board Stackup" ) ) );
561
562 menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
563 [&]( wxCommandEvent& aCmd )
564 {
565 switch( aCmd.GetId() )
566 {
567 case ID_SELECT_ALL_LAYERS:
568 for( unsigned i = 0; i < m_plotAllLayersList->GetCount(); i++ )
569 m_plotAllLayersList->Check( i, true );
570
571 break;
572
573 case ID_DESELECT_ALL_LAYERS:
574 for( unsigned i = 0; i < m_plotAllLayersList->GetCount(); i++ )
575 m_plotAllLayersList->Check( i, false );
576
577 break;
578
579 case ID_STACKUP_ORDER:
580 {
581 LSEQ stackup = m_parent->GetBoard()->GetEnabledLayers().SeqStackupForPlotting();
582 arrangeAllLayersList( stackup );
583 m_plotAllLayersList->Select( -1 );
584 break;
585 }
586
587 default:
588 aCmd.Skip();
589 }
590 } );
591
592 PopupMenu( &menu );
593}
594
595
596void DIALOG_PLOT::CreateDrillFile( wxCommandEvent& event )
597{
598 // Be sure drill file use the same settings (axis option, plot directory) as plot files:
600
601 DIALOG_GENDRILL dlg( m_parent, this );
602 dlg.ShowModal();
603
604 // a few plot settings can be modified: take them in account
606 reInitDialog();
607}
608
609
610void DIALOG_PLOT::OnChangeDXFPlotMode( wxCommandEvent& event )
611{
612 // m_DXF_plotTextStrokeFontOpt is disabled if m_DXF_plotModeOpt is checked (plot in DXF
613 // polygon mode)
614 m_DXF_plotTextStrokeFontOpt->Enable( !m_DXF_plotModeOpt->GetValue() );
615
616 // if m_DXF_plotTextStrokeFontOpt option is disabled (plot DXF in polygon mode), force
617 // m_DXF_plotTextStrokeFontOpt to true to use Pcbnew stroke font
618 if( !m_DXF_plotTextStrokeFontOpt->IsEnabled() )
619 m_DXF_plotTextStrokeFontOpt->SetValue( true );
620}
621
622
623void DIALOG_PLOT::OnSetScaleOpt( wxCommandEvent& event )
624{
625 /* Disable sheet reference for scale != 1:1 */
626 bool scale1 = ( m_scaleOpt->GetSelection() == 1 );
627
628 m_plotSheetRef->Enable( scale1 );
629
630 if( !scale1 )
631 m_plotSheetRef->SetValue( false );
632}
633
634
636{
637 // Build the absolute path of current output directory to preselect it in the file browser.
638 std::function<bool( wxString* )> textResolver =
639 [&]( wxString* token ) -> bool
640 {
641 return m_parent->GetBoard()->ResolveTextVar( token, 0 );
642 };
643
644 wxString path = m_outputDirectoryName->GetValue();
645 path = ExpandTextVars( path, &textResolver );
647 path = Prj().AbsolutePath( path );
648
649 wxDirDialog dirDialog( this, _( "Select Output Directory" ), path );
650
651 if( dirDialog.ShowModal() == wxID_CANCEL )
652 return;
653
654 wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
655
656 wxFileName fn( Prj().AbsolutePath( m_parent->GetBoard()->GetFileName() ) );
657 wxString defaultPath = fn.GetPathWithSep();
658 wxString msg;
659 wxFileName relPathTest; // Used to test if we can make the path relative
660
661 relPathTest.Assign( dirDialog.GetPath() );
662
663 // Test if making the path relative is possible before asking the user if they want to do it
664 if( relPathTest.MakeRelativeTo( defaultPath ) )
665 {
666 msg.Printf( _( "Do you want to use a path relative to\n'%s'?" ), defaultPath );
667
668 wxMessageDialog dialog( this, msg, _( "Plot Output Directory" ),
669 wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
670
671 if( dialog.ShowModal() == wxID_YES )
672 dirName.MakeRelativeTo( defaultPath );
673 }
674
675 m_outputDirectoryName->SetValue( dirName.GetFullPath() );
676}
677
678
680{
681 // plot format id's are ordered like displayed in m_plotFormatOpt
682 static const PLOT_FORMAT plotFmt[] = {
683 PLOT_FORMAT::GERBER,
684 PLOT_FORMAT::POST,
685 PLOT_FORMAT::SVG,
686 PLOT_FORMAT::DXF,
687 PLOT_FORMAT::HPGL,
688 PLOT_FORMAT::PDF };
689
690 return plotFmt[m_plotFormatOpt->GetSelection()];
691}
692
693
694void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
695{
696 // this option exist only in DXF format:
697 m_DXF_plotModeOpt->Enable( getPlotFormat() == PLOT_FORMAT::DXF );
698
699 // The alert message about non 0 solder mask min width and margin is shown
700 // only in gerber format and if min mask width or mask margin is not 0
701 BOARD* board = m_parent->GetBoard();
702 const BOARD_DESIGN_SETTINGS& brd_settings = board->GetDesignSettings();
703
704 if( getPlotFormat() == PLOT_FORMAT::GERBER
705 && ( brd_settings.m_SolderMaskExpansion || brd_settings.m_SolderMaskMinWidth ) )
706 {
708 }
709 else
710 {
712 }
713
714 switch( getPlotFormat() )
715 {
716 case PLOT_FORMAT::SVG:
717 case PLOT_FORMAT::PDF:
718 m_drillShapeOpt->Enable( true );
719 m_plotModeOpt->Enable( false );
721 m_plotMirrorOpt->Enable( true );
722 m_useAuxOriginCheckBox->Enable( true );
723 m_defaultPenSize.Enable( false );
724 m_scaleOpt->Enable( false );
725 m_scaleOpt->SetSelection( 1 );
726 m_fineAdjustXCtrl->Enable( false );
727 m_fineAdjustYCtrl->Enable( false );
729 m_plotPSNegativeOpt->Enable( true );
730 m_forcePSA4OutputOpt->Enable( false );
731 m_forcePSA4OutputOpt->SetValue( false );
732
733 if( getPlotFormat() == PLOT_FORMAT::SVG )
734 {
737 }
738 else
739 {
742 }
743
748 break;
749
750 case PLOT_FORMAT::POST:
751 m_drillShapeOpt->Enable( true );
752 m_plotModeOpt->Enable( true );
753 m_plotMirrorOpt->Enable( true );
754 m_useAuxOriginCheckBox->Enable( false );
755 m_useAuxOriginCheckBox->SetValue( false );
756 m_defaultPenSize.Enable( false );
757 m_scaleOpt->Enable( true );
758 m_fineAdjustXCtrl->Enable( true );
759 m_fineAdjustYCtrl->Enable( true );
761 m_plotPSNegativeOpt->Enable( true );
762 m_forcePSA4OutputOpt->Enable( true );
763
770 break;
771
772 case PLOT_FORMAT::GERBER:
773 m_drillShapeOpt->Enable( false );
774 m_drillShapeOpt->SetSelection( 0 );
775 m_plotModeOpt->Enable( false );
777 m_plotMirrorOpt->Enable( false );
778 m_plotMirrorOpt->SetValue( false );
779 m_useAuxOriginCheckBox->Enable( true );
780 m_defaultPenSize.Enable( false );
781 m_scaleOpt->Enable( false );
782 m_scaleOpt->SetSelection( 1 );
783 m_fineAdjustXCtrl->Enable( false );
784 m_fineAdjustYCtrl->Enable( false );
786 m_plotPSNegativeOpt->Enable( false );
787 m_plotPSNegativeOpt->SetValue( false );
788 m_forcePSA4OutputOpt->Enable( false );
789 m_forcePSA4OutputOpt->SetValue( false );
790
797 break;
798
799 case PLOT_FORMAT::HPGL:
800 m_drillShapeOpt->Enable( true );
801 m_plotModeOpt->Enable( true );
802 m_plotMirrorOpt->Enable( true );
803 m_useAuxOriginCheckBox->Enable( false );
804 m_useAuxOriginCheckBox->SetValue( false );
805 m_defaultPenSize.Enable( true );
806 m_scaleOpt->Enable( true );
807 m_fineAdjustXCtrl->Enable( false );
808 m_fineAdjustYCtrl->Enable( false );
810 m_plotPSNegativeOpt->SetValue( false );
811 m_plotPSNegativeOpt->Enable( false );
812 m_forcePSA4OutputOpt->Enable( true );
813
820 break;
821
822 case PLOT_FORMAT::DXF:
823 m_drillShapeOpt->Enable( true );
824 m_plotModeOpt->Enable( false );
826 m_plotMirrorOpt->Enable( false );
827 m_plotMirrorOpt->SetValue( false );
828 m_useAuxOriginCheckBox->Enable( true );
829 m_defaultPenSize.Enable( false );
830 m_scaleOpt->Enable( false );
831 m_scaleOpt->SetSelection( 1 );
832 m_fineAdjustXCtrl->Enable( false );
833 m_fineAdjustYCtrl->Enable( false );
835 m_plotPSNegativeOpt->Enable( false );
836 m_plotPSNegativeOpt->SetValue( false );
837 m_forcePSA4OutputOpt->Enable( false );
838 m_forcePSA4OutputOpt->SetValue( false );
839
846
847 OnChangeDXFPlotMode( event );
848 break;
849
850 case PLOT_FORMAT::UNDEFINED:
851 break;
852 }
853
854 /* Update the interlock between scale and frame reference
855 * (scaling would mess up the frame border...) */
856 OnSetScaleOpt( event );
857
858 Layout();
859 m_MainSizer->SetSizeHints( this );
860}
861
862
863// A helper function to "clip" aValue between aMin and aMax and write result in * aResult
864// return false if clipped, true if aValue is just copied into * aResult
865static bool setDouble( double* aResult, double aValue, double aMin, double aMax )
866{
867 if( aValue < aMin )
868 {
869 *aResult = aMin;
870 return false;
871 }
872 else if( aValue > aMax )
873 {
874 *aResult = aMax;
875 return false;
876 }
877
878 *aResult = aValue;
879 return true;
880}
881
882
883static bool setInt( int* aResult, int aValue, int aMin, int aMax )
884{
885 if( aValue < aMin )
886 {
887 *aResult = aMin;
888 return false;
889 }
890 else if( aValue > aMax )
891 {
892 *aResult = aMax;
893 return false;
894 }
895
896 *aResult = aValue;
897 return true;
898}
899
900
902{
903 REPORTER& reporter = m_messagesPanel->Reporter();
904 PCB_PLOT_PARAMS tempOptions;
905
906 tempOptions.SetSubtractMaskFromSilk( m_subtractMaskFromSilk->GetValue() );
907 tempOptions.SetPlotFrameRef( m_plotSheetRef->GetValue() );
908 tempOptions.SetSketchPadsOnFabLayers( m_sketchPadsOnFabLayers->GetValue() );
909 tempOptions.SetPlotPadNumbers( m_plotPadNumbers->GetValue() );
910 tempOptions.SetHideDNPFPsOnFabLayers( m_plotDNP->GetValue()
911 && m_hideDNP->GetValue() );
912 tempOptions.SetSketchDNPFPsOnFabLayers( m_plotDNP->GetValue()
913 && m_crossoutDNP->GetValue() );
914 tempOptions.SetCrossoutDNPFPsOnFabLayers( m_plotDNP->GetValue()
915 && m_crossoutDNP->GetValue() );
916 tempOptions.SetUseAuxOrigin( m_useAuxOriginCheckBox->GetValue() );
917 tempOptions.SetPlotInvisibleText( m_plotInvisibleText->GetValue() );
918 tempOptions.SetScaleSelection( m_scaleOpt->GetSelection() );
919
920 int sel = m_drillShapeOpt->GetSelection();
921 tempOptions.SetDrillMarksType( static_cast<DRILL_MARKS>( sel ) );
922
923 tempOptions.SetMirror( m_plotMirrorOpt->GetValue() );
924 tempOptions.SetPlotMode( m_plotModeOpt->GetSelection() == 1 ? SKETCH : FILLED );
925 tempOptions.SetDXFPlotPolygonMode( m_DXF_plotModeOpt->GetValue() );
926
927 sel = m_DXF_plotUnits->GetSelection();
928 tempOptions.SetDXFPlotUnits( sel == 0 ? DXF_UNITS::INCHES : DXF_UNITS::MILLIMETERS );
929
930 if( !m_DXF_plotTextStrokeFontOpt->IsEnabled() ) // Currently, only DXF supports this option
931 tempOptions.SetTextMode( PLOT_TEXT_MODE::DEFAULT );
932 else
933 tempOptions.SetTextMode( m_DXF_plotTextStrokeFontOpt->GetValue() ? PLOT_TEXT_MODE::DEFAULT :
934 PLOT_TEXT_MODE::NATIVE );
935
936 if( getPlotFormat() == PLOT_FORMAT::SVG )
937 {
938 tempOptions.SetBlackAndWhite( !!m_SVGColorChoice->GetSelection() );
939 }
940 else if( getPlotFormat() == PLOT_FORMAT::PDF )
941 {
942 tempOptions.SetBlackAndWhite( !!m_PDFColorChoice->GetSelection() );
943 tempOptions.m_PDFFrontFPPropertyPopups = m_frontFPPropertyPopups->GetValue();
944 tempOptions.m_PDFBackFPPropertyPopups = m_backFPPropertyPopups->GetValue();
945 tempOptions.m_PDFMetadata = m_pdfMetadata->GetValue();
946 }
947 else
948 {
949 tempOptions.SetBlackAndWhite( true );
950 }
951
952 // Update settings from text fields. Rewrite values back to the fields,
953 // since the values may have been constrained by the setters.
954 wxString msg;
955
956 // read HPLG pen size (this param is stored in mils)
957 // However, due to issues when converting this value from or to mm
958 // that can slightly change the value, update this param only if it
959 // is in use
960 if( getPlotFormat() == PLOT_FORMAT::HPGL )
961 {
963 {
965 msg.Printf( _( "HPGL pen size constrained." ) );
966 reporter.Report( msg, RPT_SEVERITY_INFO );
967 }
968 }
969 else // keep the last value (initial value if no HPGL plot made)
970 {
972 }
973
974 // X scale
975 double tmpDouble;
976 msg = m_fineAdjustXCtrl->GetValue();
977 msg.ToDouble( &tmpDouble );
978
980 {
981 msg.Printf( wxT( "%f" ), m_XScaleAdjust );
982 m_fineAdjustXCtrl->SetValue( msg );
983 msg.Printf( _( "X scale constrained." ) );
984 reporter.Report( msg, RPT_SEVERITY_INFO );
985 }
986
987 // Y scale
988 msg = m_fineAdjustYCtrl->GetValue();
989 msg.ToDouble( &tmpDouble );
990
992 {
993 msg.Printf( wxT( "%f" ), m_YScaleAdjust );
994 m_fineAdjustYCtrl->SetValue( msg );
995 msg.Printf( _( "Y scale constrained." ) );
996 reporter.Report( msg, RPT_SEVERITY_INFO );
997 }
998
999 auto cfg = m_parent->GetPcbNewSettings();
1000
1002 cfg->m_Plot.fine_scale_y = m_YScaleAdjust;
1003
1004 cfg->m_Plot.check_zones_before_plotting = m_zoneFillCheck->GetValue();
1005
1006 // PS Width correction
1009 {
1011 msg.Printf( _( "Width correction constrained. The width correction value must be in the"
1012 " range of [%s; %s] for the current design rules." ),
1015 reporter.Report( msg, RPT_SEVERITY_WARNING );
1016 }
1017
1018 // Store m_PSWidthAdjust in mm in user config
1019 cfg->m_Plot.ps_fine_width_adjust = pcbIUScale.IUTomm( m_PSWidthAdjust );
1020
1021 tempOptions.SetFormat( getPlotFormat() );
1022
1023 tempOptions.SetDisableGerberMacros( m_disableApertMacros->GetValue() );
1024 tempOptions.SetUseGerberProtelExtensions( m_useGerberExtensions->GetValue() );
1025 tempOptions.SetUseGerberX2format( m_useGerberX2Format->GetValue() );
1026 tempOptions.SetIncludeGerberNetlistInfo( m_useGerberNetAttributes->GetValue() );
1027 tempOptions.SetCreateGerberJobFile( m_generateGerberJobFile->GetValue() );
1028
1029 tempOptions.SetGerberPrecision( m_coordFormatCtrl->GetSelection() == 0 ? 5 : 6 );
1030 tempOptions.SetSvgPrecision( m_svgPrecsision->GetValue() );
1031
1032 LSET selectedLayers;
1033
1034 for( unsigned i = 0; i < m_layerList.size(); i++ )
1035 {
1036 if( m_layerCheckListBox->IsChecked( i ) )
1037 selectedLayers.set( m_layerList[i] );
1038 }
1039
1040 // Get a list of copper layers that aren't being used by inverting enabled layers.
1041 LSET disabledCopperLayers = LSET::AllCuMask() & ~m_parent->GetBoard()->GetEnabledLayers();
1042
1043 LSET plotOnAllLayers;
1044
1045 // Add selected layers from plot on all layers list in order set by user.
1046 wxArrayInt plotOnAllLayersSelections;
1047
1048 m_plotAllLayersList->GetCheckedItems( plotOnAllLayersSelections );
1049
1050 size_t count = plotOnAllLayersSelections.GetCount();
1051
1052 for( size_t i = 0; i < count; i++ )
1053 {
1054 int index = plotOnAllLayersSelections.Item( i );
1055 wxClientData* tmp = m_plotAllLayersList->GetClientObject( index );
1056 PCB_LAYER_ID_CLIENT_DATA* layerId = dynamic_cast<PCB_LAYER_ID_CLIENT_DATA*>( tmp );
1057
1058 wxCHECK2( layerId, continue );
1059
1060 plotOnAllLayers.set( layerId->Layer() );
1061 }
1062
1063 tempOptions.SetPlotOnAllLayersSelection( plotOnAllLayers );
1064
1065 // Enable all of the disabled copper layers.
1066 // If someone enables more copper layers they will be selected by default.
1067 selectedLayers = selectedLayers | disabledCopperLayers;
1068 tempOptions.SetLayerSelection( selectedLayers );
1069
1070 tempOptions.SetNegative( m_plotPSNegativeOpt->GetValue() );
1071 tempOptions.SetA4Output( m_forcePSA4OutputOpt->GetValue() );
1072
1073 // Set output directory and replace backslashes with forward ones
1074 wxString dirStr;
1075 dirStr = m_outputDirectoryName->GetValue();
1076 dirStr.Replace( wxT( "\\" ), wxT( "/" ) );
1077 tempOptions.SetOutputDirectory( dirStr );
1079
1080 if( !m_plotOpts.IsSameAs( tempOptions ) )
1081 {
1082 m_parent->SetPlotSettings( tempOptions );
1083 m_parent->OnModify();
1084 m_plotOpts = tempOptions;
1085 }
1086}
1087
1088
1089void DIALOG_PLOT::OnGerberX2Checked( wxCommandEvent& event )
1090{
1091 // Currently: do nothing
1092}
1093
1094
1095void DIALOG_PLOT::Plot( wxCommandEvent& event )
1096{
1097 BOARD* board = m_parent->GetBoard();
1098
1100
1103
1105
1107
1108 // If no layer selected, we have nothing plotted.
1109 // Prompt user if it happens because he could think there is a bug in Pcbnew.
1111 {
1112 DisplayError( this, _( "No layer selected, Nothing to plot" ) );
1113 return;
1114 }
1115
1116 // Create output directory if it does not exist (also transform it in absolute form).
1117 // Bail if it fails.
1118
1119 std::function<bool( wxString* )> textResolver =
1120 [&]( wxString* token ) -> bool
1121 {
1122 // Handles board->GetTitleBlock() *and* board->GetProject()
1123 return m_parent->GetBoard()->ResolveTextVar( token, 0 );
1124 };
1125
1126 wxString path = m_plotOpts.GetOutputDirectory();
1127 path = ExpandTextVars( path, &textResolver );
1129
1130 wxFileName outputDir = wxFileName::DirName( path );
1131 wxString boardFilename = m_parent->GetBoard()->GetFileName();
1132 REPORTER& reporter = m_messagesPanel->Reporter();
1133
1134 if( !EnsureFileDirectoryExists( &outputDir, boardFilename, &reporter ) )
1135 {
1136 wxString msg;
1137 msg.Printf( _( "Could not write plot files to folder '%s'." ), outputDir.GetPath() );
1138 DisplayError( this, msg );
1139 return;
1140 }
1141
1142 if( m_zoneFillCheck->GetValue() )
1143 m_parent->GetToolManager()->GetTool<ZONE_FILLER_TOOL>()->CheckAllZones( this );
1144
1145 m_plotOpts.SetAutoScale( false );
1146
1147 switch( m_plotOpts.GetScaleSelection() )
1148 {
1149 default: m_plotOpts.SetScale( 1 ); break;
1150 case 0: m_plotOpts.SetAutoScale( true ); break;
1151 case 2: m_plotOpts.SetScale( 1.5 ); break;
1152 case 3: m_plotOpts.SetScale( 2 ); break;
1153 case 4: m_plotOpts.SetScale( 3 ); break;
1154 }
1155
1156 /* If the scale factor edit controls are disabled or the scale value
1157 * is 0, don't adjust the base scale factor. This fixes a bug when
1158 * the default scale adjust is initialized to 0 and saved in program
1159 * settings resulting in a divide by zero fault.
1160 */
1161 if( getPlotFormat() == PLOT_FORMAT::POST )
1162 {
1163 if( m_XScaleAdjust != 0.0 )
1165
1166 if( m_YScaleAdjust != 0.0 )
1168
1170 }
1171
1172 wxString file_ext( GetDefaultPlotExtension( m_plotOpts.GetFormat() ) );
1173
1174 // Test for a reasonable scale value
1175 // XXX could this actually happen? isn't it constrained in the apply function?
1177 DisplayInfoMessage( this, _( "Warning: Scale option set to a very small value" ) );
1178
1180 DisplayInfoMessage( this, _( "Warning: Scale option set to a very large value" ) );
1181
1182 GERBER_JOBFILE_WRITER jobfile_writer( board, &reporter );
1183
1184 // Save the current plot options in the board
1186
1187 wxBusyCursor dummy;
1188
1190 {
1191 LSEQ plotSequence;
1192
1193 // Base layer always gets plotted first.
1194 plotSequence.push_back( layer );
1195
1196 // Add selected layers from plot on all layers list in order set by user.
1197 wxArrayInt plotOnAllLayers;
1198
1199 if( m_plotAllLayersList->GetCheckedItems( plotOnAllLayers ) )
1200 {
1201 size_t count = plotOnAllLayers.GetCount();
1202
1203 for( size_t i = 0; i < count; i++ )
1204 {
1205 int index = plotOnAllLayers.Item( i );
1206 PCB_LAYER_ID client_layer = getLayerClientData( m_plotAllLayersList, index )->Layer();
1207
1208 // Don't plot the same layer more than once;
1209 if( find( plotSequence.begin(), plotSequence.end(), client_layer ) != plotSequence.end() )
1210 continue;
1211
1212 plotSequence.push_back( client_layer );
1213 }
1214 }
1215
1216 wxString layerName = board->GetLayerName( layer );
1217 //@todo allow controlling the sheet name and path that will be displayed in the title block
1218 // Leave blank for now
1219 wxString sheetName;
1220 wxString sheetPath;
1221
1222 // All copper layers that are disabled are actually selected
1223 // This is due to wonkyness in automatically selecting copper layers
1224 // for plotting when adding more than two layers to a board.
1225 // If plot options become accessible to the layers setup dialog
1226 // please move this functionality there!
1227 // This skips a copper layer if it is actually disabled on the board.
1228 if( ( LSET::AllCuMask() & ~board->GetEnabledLayers() )[layer] )
1229 continue;
1230
1231 // Pick the basename from the board file
1232 wxFileName fn( boardFilename );
1233
1234 // Use Gerber Extensions based on layer number
1235 // (See http://en.wikipedia.org/wiki/Gerber_File)
1236 if( m_plotOpts.GetFormat() == PLOT_FORMAT::GERBER && m_useGerberExtensions->GetValue() )
1237 file_ext = GetGerberProtelExtension( layer );
1238
1239 BuildPlotFileName( &fn, outputDir.GetPath(), layerName, file_ext );
1240 wxString fullname = fn.GetFullName();
1241 jobfile_writer.AddGbrFile( layer, fullname );
1242
1243 LOCALE_IO toggle;
1244
1245 PLOTTER* plotter = StartPlotBoard( board, &m_plotOpts, layer, layerName, fn.GetFullPath(),
1246 sheetName, sheetPath );
1247
1248 // Print diags in messages box:
1249 wxString msg;
1250
1251 if( plotter )
1252 {
1253 plotter->SetTitle( ExpandTextVars( board->GetTitleBlock().GetTitle(), &textResolver ) );
1254
1256 {
1257 msg = wxS( "AUTHOR" );
1258
1259 if( board->ResolveTextVar( &msg, 0 ) )
1260 plotter->SetAuthor( msg );
1261
1262 msg = wxS( "SUBJECT" );
1263
1264 if( board->ResolveTextVar( &msg, 0 ) )
1265 plotter->SetSubject( msg );
1266 }
1267
1268 PlotBoardLayers( board, plotter, plotSequence, m_plotOpts );
1269 PlotInteractiveLayer( board, plotter, m_plotOpts );
1270 plotter->EndPlot();
1271 delete plotter->RenderSettings();
1272 delete plotter;
1273
1274 msg.Printf( _( "Plotted to '%s'." ), fn.GetFullPath() );
1275 reporter.Report( msg, RPT_SEVERITY_ACTION );
1276 }
1277 else
1278 {
1279 msg.Printf( _( "Failed to create file '%s'." ), fn.GetFullPath() );
1280 reporter.Report( msg, RPT_SEVERITY_ERROR );
1281 }
1282
1283 wxSafeYield(); // displays report message.
1284 }
1285
1286 if( m_plotOpts.GetFormat() == PLOT_FORMAT::GERBER && m_plotOpts.GetCreateGerberJobFile() )
1287 {
1288 // Pick the basename from the board file
1289 wxFileName fn( boardFilename );
1290
1291 // Build gerber job file from basename
1292 BuildPlotFileName( &fn, outputDir.GetPath(), wxT( "job" ),
1294 jobfile_writer.CreateJobFile( fn.GetFullPath() );
1295 }
1296
1297 reporter.ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
1298}
1299
1300
1301void DIALOG_PLOT::onRunDRC( wxCommandEvent& event )
1302{
1303 PCB_EDIT_FRAME* parent = dynamic_cast<PCB_EDIT_FRAME*>( GetParent() );
1304
1305 if( parent )
1306 {
1307 DRC_TOOL* drcTool = parent->GetToolManager()->GetTool<DRC_TOOL>();
1308
1309 // First close an existing dialog if open
1310 // (low probability, but can happen)
1311 drcTool->DestroyDRCDialog();
1312
1313 // Open a new drc dialog, with the right parent frame, and in Modal Mode
1314 drcTool->ShowDRCDialog( this );
1315
1316 // Update DRC warnings on return to this dialog
1317 reInitDialog();
1318 }
1319}
1320
1321
1322void DIALOG_PLOT::onBoardSetup( wxHyperlinkEvent& aEvent )
1323{
1324 PCB_EDIT_FRAME* parent = dynamic_cast<PCB_EDIT_FRAME*>( GetParent() );
1325
1326 if( parent )
1327 {
1328 parent->ShowBoardSetupDialog( _( "Solder Mask/Paste" ) );
1329
1330 // Update warnings on return to this dialog
1331 reInitDialog();
1332 }
1333}
1334
1335
1336void DIALOG_PLOT::onPlotAllListMoveUp( wxCommandEvent& aEvent )
1337{
1338 if( m_plotAllLayersList->CanMoveCurrentUp() )
1339 m_plotAllLayersList->MoveCurrentUp();
1340}
1341
1342
1343void DIALOG_PLOT::onPlotAllListMoveDown( wxCommandEvent& aEvent )
1344{
1345 if( m_plotAllLayersList->CanMoveCurrentDown() )
1346 m_plotAllLayersList->MoveCurrentDown();
1347}
1348
1349
1350void DIALOG_PLOT::onDNPCheckbox( wxCommandEvent& aEvent )
1351{
1352 m_hideDNP->Enable( aEvent.IsChecked() );
1353 m_crossoutDNP->Enable( aEvent.IsChecked() );
1354}
1355
1356
1357void DIALOG_PLOT::onSketchPads( wxCommandEvent& aEvent )
1358{
1359 m_plotPadNumbers->Enable( aEvent.IsChecked() );
1360}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
constexpr EDA_IU_SCALE unityScale
Definition: base_units.h:111
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Definition: bitmap.cpp:110
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:175
BASE_SET & set(size_t pos=std::numeric_limits< size_t >::max(), bool value=true)
Definition: base_set.h:62
bool test(size_t pos) const
Definition: base_set.h:48
bool any() const
Definition: base_set.h:56
size_t size() const
Definition: base_set.h:109
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:289
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:760
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: board.cpp:431
const MARKERS & Markers() const
Definition: board.h:338
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:688
const wxString & GetFileName() const
Definition: board.h:326
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:577
PROJECT * GetProject() const
Definition: board.h:490
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:877
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
wxCheckBox * m_plotPadNumbers
wxStaticBoxSizer * m_HPGLOptionsSizer
wxCheckBox * m_useAuxOriginCheckBox
wxStaticBoxSizer * m_PSOptionsSizer
wxCheckBox * m_plotPSNegativeOpt
wxCheckBox * m_DXF_plotTextStrokeFontOpt
wxChoice * m_plotModeOpt
wxCheckBox * m_useGerberExtensions
wxCheckBox * m_plotSheetRef
wxBoxSizer * m_SizerSolderMaskAlert
wxCheckBox * m_generateGerberJobFile
wxRadioButton * m_crossoutDNP
wxCheckBox * m_useGerberX2Format
wxCheckListBox * m_layerCheckListBox
wxCheckBox * m_plotMirrorOpt
wxStaticBoxSizer * m_svgOptionsSizer
wxCheckBox * m_forcePSA4OutputOpt
wxCheckBox * m_useGerberNetAttributes
wxCheckBox * m_sketchPadsOnFabLayers
wxCheckBox * m_subtractMaskFromSilk
wxCheckBox * m_plotDNP
wxBoxSizer * m_PlotOptionsSizer
wxChoice * m_DXF_plotUnits
wxStaticBoxSizer * m_SizerDXF_options
wxCheckBox * m_plotInvisibleText
wxCheckBox * m_pdfMetadata
wxChoice * m_drillShapeOpt
wxRadioButton * m_hideDNP
wxCheckBox * m_zoneFillCheck
wxStaticBoxSizer * m_GerberOptionsSizer
WX_HTML_REPORT_PANEL * m_messagesPanel
wxChoice * m_PDFColorChoice
wxChoice * m_plotFormatOpt
wxBoxSizer * m_MainSizer
static LSET s_lastAllLayersSet
Definition: dialog_plot.h:107
void reInitDialog()
void OnRightClickLayers(wxMouseEvent &event)
static LSEQ s_lastAllLayersOrder
The plot on all layers ordering the last time the dialog was opened.
Definition: dialog_plot.h:110
PCB_PLOT_PARAMS m_plotOpts
Definition: dialog_plot.h:98
STD_BITMAP_BUTTON * m_bpMoveUp
Definition: dialog_plot.h:102
void onPlotAllListMoveUp(wxCommandEvent &aEvent)
void OnChangeDXFPlotMode(wxCommandEvent &event) override
int m_widthAdjustMinValue
Definition: dialog_plot.h:90
UNIT_BINDER m_trackWidthCorrection
Definition: dialog_plot.h:94
void onBoardSetup(wxHyperlinkEvent &aEvent) override
void OnRightClickAllLayers(wxMouseEvent &event)
void onSketchPads(wxCommandEvent &event) override
PCB_EDIT_FRAME * m_parent
Definition: dialog_plot.h:80
void Plot(wxCommandEvent &event) override
void applyPlotSettings()
int m_PSWidthAdjust
Definition: dialog_plot.h:86
wxString m_DRCWarningTemplate
Definition: dialog_plot.h:96
void setPlotModeChoiceSelection(OUTLINE_MODE aPlotMode)
Definition: dialog_plot.h:72
void OnOutputDirectoryBrowseClicked(wxCommandEvent &event) override
wxRearrangeList * m_plotAllLayersList
Definition: dialog_plot.h:100
void onPlotAllListMoveDown(wxCommandEvent &aEvent)
void onRunDRC(wxCommandEvent &event) override
void arrangeAllLayersList(const LSEQ &aSeq)
double m_YScaleAdjust
Definition: dialog_plot.h:84
void OnSetScaleOpt(wxCommandEvent &event) override
virtual ~DIALOG_PLOT()
STD_BITMAP_BUTTON * m_bpMoveDown
Definition: dialog_plot.h:103
DIALOG_PLOT(PCB_EDIT_FRAME *parent)
Definition: dialog_plot.cpp:87
void CreateDrillFile(wxCommandEvent &event) override
void onDNPCheckbox(wxCommandEvent &event) override
UNIT_BINDER m_defaultPenSize
Definition: dialog_plot.h:93
double m_XScaleAdjust
Definition: dialog_plot.h:82
PLOT_FORMAT getPlotFormat()
static LSET s_lastLayerSet
The plot layer set that last time the dialog was opened.
Definition: dialog_plot.h:106
int m_widthAdjustMaxValue
Definition: dialog_plot.h:91
void OnGerberX2Checked(wxCommandEvent &event) override
void init_Dialog()
void SetPlotFormat(wxCommandEvent &event) override
LSEQ m_layerList
Definition: dialog_plot.h:81
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: lseq.h:47
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:35
LSEQ UIOrder() const
Definition: lset.cpp:865
LSEQ SeqStackupForPlotting() const
Return the sequence that is typical for a bottom-to-top stack-up.
Definition: lset.cpp:537
static LSET AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
Definition: lset.cpp:800
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:732
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:63
PCB_LAYER_ID Layer() const
Definition: dialog_plot.cpp:74
void SetData(PCB_LAYER_ID aId)
Definition: dialog_plot.cpp:73
PCB_LAYER_ID_CLIENT_DATA(PCB_LAYER_ID aId)
Definition: dialog_plot.cpp:69
Parameters and options when plotting/printing a board.
bool GetNegative() const
PLOT_FORMAT GetFormat() const
void SetDrillMarksType(DRILL_MARKS aVal)
bool GetUseAuxOrigin() const
bool GetHideDNPFPsOnFabLayers() const
void SetLayerSelection(LSET aSelection)
void SetOutputDirectory(const wxString &aDir)
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
bool GetCrossoutDNPFPsOnFabLayers() const
bool GetSketchDNPFPsOnFabLayers() const
void SetDXFPlotPolygonMode(bool aFlag)
void SetAutoScale(bool aFlag)
double GetHPGLPenDiameter() const
unsigned GetSvgPrecision() const
void SetPlotFrameRef(bool aFlag)
void SetSketchDNPFPsOnFabLayers(bool aFlag)
bool m_PDFMetadata
Generate PDF metadata for SUBJECT and AUTHOR.
unsigned GetBlackAndWhite() const
double GetScale() const
bool GetCreateGerberJobFile() const
void SetPlotPadNumbers(bool aFlag)
bool GetDXFPlotPolygonMode() const
void SetSketchPadLineWidth(int aWidth)
LSET GetLayerSelection() 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 SetGerberPrecision(int aPrecision)
void SetSubtractMaskFromSilk(bool aSubtract)
bool GetSketchPadsOnFabLayers() const
void SetHideDNPFPsOnFabLayers(bool aFlag)
bool GetSubtractMaskFromSilk() const
int GetGerberPrecision() const
void SetUseGerberProtelExtensions(bool aUse)
bool GetPlotPadNumbers() const
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)
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
void SetTextMode(PLOT_TEXT_MODE aVal)
bool GetUseGerberProtelExtensions() const
void SetSvgPrecision(unsigned aPrecision)
bool GetPlotFrameRef() const
void SetCrossoutDNPFPsOnFabLayers(bool aFlag)
void SetFormat(PLOT_FORMAT aFormat)
bool GetDisableGerberMacros() const
void SetFineScaleAdjustY(double aVal)
OUTLINE_MODE GetPlotMode() const
void SetWidthAdjust(int aVal)
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
Base plotter engine class.
Definition: plotter.h:105
virtual void SetAuthor(const wxString &aAuthor)
Definition: plotter.h:156
virtual void SetTitle(const wxString &aTitle)
Definition: plotter.h:155
virtual bool EndPlot()=0
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:136
virtual void SetSubject(const wxString &aSubject)
Definition: plotter.h:157
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:71
wxString m_PcbLastPath[LAST_PATH_SIZE]
MRU path storage.
Definition: project_file.h:158
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:183
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:320
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:72
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:100
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)
const wxString & GetTitle() const
Definition: title_block.h:63
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) const
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:343
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:371
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:59
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:170
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:222
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)
Definition: dialog_plot.cpp:81
#define ID_SELECT_ALL_LAYERS
#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:30
#define _(s)
Classes used to generate a Gerber job file in JSON.
static const bool FILLED
Definition: gr_basic.cpp:30
static const std::string GerberJobFileExtension
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:532
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ F_CrtYd
Definition: layer_ids.h:117
@ F_Fab
Definition: layer_ids.h:120
@ B_CrtYd
Definition: layer_ids.h:116
@ 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:300
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:77
@ SKETCH
Definition: outline_mode.h:26
const wxString GetGerberProtelExtension(int aLayer)
Definition: pcbplot.cpp:43
void BuildPlotFileName(wxFileName *aFilename, const wxString &aOutputDir, const wxString &aSuffix, const wxString &aExtension)
Complete a plot filename.
Definition: pcbplot.cpp:373
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:57
PLOTTER * StartPlotBoard(BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer, const wxString &aLayerName, 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...
#define PLOT_MAX_SCALE
Definition: pcbplot.h:58
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
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:65
@ LAST_PATH_PLOT
Definition: project_file.h:58
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_EXCLUSION
@ RPT_SEVERITY_INFO
@ RPT_SEVERITY_ACTION
std::vector< FAB_LAYER_COLOR > dummy
constexpr double IUTomm(int iu) const
Definition: base_units.h:86
const double IU_PER_MM
Definition: base_units.h:76
const double IU_PER_MILS
Definition: base_units.h:77
constexpr ret_type KiROUND(fp_type v, bool aQuiet=false)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:100
Definition of file extensions used in Kicad.