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