KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_plot.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, 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>
55#include <pcb_plotter.h>
56
57#include <wx/dirdlg.h>
58#include <wx/msgdlg.h>
59
60
64
65
69class PCB_LAYER_ID_CLIENT_DATA : public wxClientData
70{
71public:
74 { }
75
77 m_id( aId )
78 { }
79
80 void SetData( PCB_LAYER_ID aId ) { m_id = aId; }
81 PCB_LAYER_ID Layer() const { return m_id; }
82
83private:
85};
86
87
88PCB_LAYER_ID_CLIENT_DATA* getLayerClientData( const wxRearrangeList* aList, int aIdx )
89{
90 return static_cast<PCB_LAYER_ID_CLIENT_DATA*>( aList->GetClientObject( aIdx ) );
91}
92
93
95 : DIALOG_PLOT( aEditFrame, aEditFrame )
96{
97}
98
99
100DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aEditFrame, wxWindow* aParent,
101 JOB_EXPORT_PCB_PLOT* aJob ) :
102 DIALOG_PLOT_BASE( aParent ),
103 m_editFrame( aEditFrame ),
104 m_defaultPenSize( m_editFrame, m_hpglPenLabel, m_hpglPenCtrl, m_hpglPenUnits ),
105 m_trackWidthCorrection( m_editFrame, m_widthAdjustLabel, m_widthAdjustCtrl, m_widthAdjustUnits ),
106 m_job( aJob )
107{
108 BOARD* board = m_editFrame->GetBoard();
109
110 SetName( DLG_WINDOW_NAME );
112
113 if( m_job )
114 {
115 SetTitle( aJob->GetSettingsDialogTitle() );
116
118 m_messagesPanel->Hide();
119
120 m_browseButton->Hide();
121 m_openDirButton->Hide();
122 m_staticTextPlotFmt->Hide();
123 m_plotFormatOpt->Hide();
124 m_buttonDRC->Hide();
126 m_sdbSizer1Apply->Hide();
127 }
128 else
129 {
131 m_messagesPanel->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
132 }
133
134 // DIALOG_SHIM needs a unique hash_key because classname will be the same for both job and
135 // non-job versions (which have different sizes).
136 m_hash_key = TO_UTF8( GetTitle() );
137
138 int order = 0;
139 wxArrayInt plotAllLayersOrder;
140 wxArrayString plotAllLayersChoicesStrings;
141 std::vector<PCB_LAYER_ID> layersIdChoiceList;
142 int textWidth = 0;
143
144 for( PCB_LAYER_ID layer : board->GetEnabledLayers().SeqStackupForPlotting() )
145 {
146 wxString layerName = board->GetLayerName( layer );
147
148 // wxCOL_WIDTH_AUTOSIZE doesn't work on all platforms, so we calculate width here
149 textWidth = std::max( textWidth, KIUI::GetTextSize( layerName, m_layerCheckListBox ).x );
150
151 plotAllLayersChoicesStrings.Add( layerName );
152 layersIdChoiceList.push_back( layer );
153
155 plotAllLayersOrder.push_back( order );
156 else
157 plotAllLayersOrder.push_back( ~order );
158
159 order += 1;
160 }
161
162 int checkColSize = 22;
163 int layerColSize = textWidth + 15;
164
165#ifdef __WXMAC__
166 // TODO: something in wxWidgets 3.1.x pads checkbox columns with extra space. (It used to
167 // also be that the width of the column would get set too wide (to 30), but that's patched in
168 // our local wxWidgets fork.)
169 checkColSize += 30;
170#endif
171
172 m_layerCheckListBox->SetMinClientSize( wxSize( checkColSize + layerColSize,
173 m_layerCheckListBox->GetMinClientSize().y ) );
174
175 wxStaticBox* allLayersLabel = new wxStaticBox( this, wxID_ANY, _( "Plot on All Layers" ) );
176 wxStaticBoxSizer* sbSizer = new wxStaticBoxSizer( allLayersLabel, wxVERTICAL );
177
178 m_plotAllLayersList = new wxRearrangeList( sbSizer->GetStaticBox(), wxID_ANY,
179 wxDefaultPosition, wxDefaultSize,
180 plotAllLayersOrder, plotAllLayersChoicesStrings, 0 );
181
182 m_plotAllLayersList->SetMinClientSize( wxSize( checkColSize + layerColSize,
183 m_plotAllLayersList->GetMinClientSize().y ) );
184
185 // Attach the LAYER_ID to each item in m_plotAllLayersList
186 // plotAllLayersChoicesStrings and layersIdChoiceList are in the same order,
187 // but m_plotAllLayersList has these strings in a different order
188 for( size_t idx = 0; idx < layersIdChoiceList.size(); idx++ )
189 {
190 wxString& txt = plotAllLayersChoicesStrings[idx];
191 int list_idx = m_plotAllLayersList->FindString( txt, true );
192
193 PCB_LAYER_ID layer_id = layersIdChoiceList[idx];
194 m_plotAllLayersList->SetClientObject( list_idx, new PCB_LAYER_ID_CLIENT_DATA( layer_id ) );
195 }
196
197 sbSizer->Add( m_plotAllLayersList, 1, wxALL | wxEXPAND | wxFIXED_MINSIZE, 3 );
198
199 wxBoxSizer* bButtonSizer;
200 bButtonSizer = new wxBoxSizer( wxHORIZONTAL );
201
202 m_bpMoveUp = new STD_BITMAP_BUTTON( sbSizer->GetStaticBox(), wxID_ANY, wxNullBitmap,
203 wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW | 0 );
204 m_bpMoveUp->SetToolTip( _( "Move current selection up" ) );
205 m_bpMoveUp->SetBitmap( KiBitmapBundle( BITMAPS::small_up ) );
206
207 bButtonSizer->Add( m_bpMoveUp, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 3 );
208
209 m_bpMoveDown = new STD_BITMAP_BUTTON( sbSizer->GetStaticBox(), wxID_ANY, wxNullBitmap,
210 wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW | 0 );
211 m_bpMoveDown->SetToolTip( _( "Move current selection down" ) );
212 m_bpMoveDown->SetBitmap( KiBitmapBundle( BITMAPS::small_down ) );
213
214 bButtonSizer->Add( m_bpMoveDown, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5 );
215
216 sbSizer->Add( bButtonSizer, 0, wxALL | wxEXPAND, 3 );
217
218 bmiddleSizer->Insert( 1, sbSizer, 1, wxALL | wxEXPAND, 5 );
219
220 init_Dialog();
221
222 if( m_job )
223 {
225 }
226 else
227 {
228 SetupStandardButtons( { { wxID_OK, _( "Plot" ) },
229 { wxID_APPLY, _( "Generate Drill Files..." ) },
230 { wxID_CANCEL, _( "Close" ) } } );
231 }
232
233 GetSizer()->Fit( this );
234 GetSizer()->SetSizeHints( this );
235
236 m_bpMoveUp->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveUp, this );
237 m_bpMoveDown->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveDown, this );
238
239 m_layerCheckListBox->Connect( wxEVT_RIGHT_DOWN,
240 wxMouseEventHandler( DIALOG_PLOT::OnRightClickLayers ), nullptr,
241 this );
242
243 m_plotAllLayersList->Connect( wxEVT_RIGHT_DOWN,
244 wxMouseEventHandler( DIALOG_PLOT::OnRightClickAllLayers ), nullptr,
245 this );
246}
247
248
250{
251 s_lastAllLayersOrder.clear();
252
253 for( int ii = 0; ii < (int) m_plotAllLayersList->GetCount(); ++ii )
255
256 m_bpMoveDown->Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveDown, this );
257 m_bpMoveUp->Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveUp, this );
258}
259
260
262{
263 BOARD* board = m_editFrame->GetBoard();
264 wxFileName fileName;
265
266 PROJECT_FILE& projectFile = m_editFrame->Prj().GetProjectFile();
267
268 // Could devote a PlotOrder() function in place of UIOrder().
270
272
273 if( !m_job && !projectFile.m_PcbLastPath[ LAST_PATH_PLOT ].IsEmpty() )
275
276 if( m_job
278 && dynamic_cast<JOB_EXPORT_PCB_PS*>( m_job )->m_useGlobalSettings ) )
279 {
280 // When we are using a job we get the PS adjust values from the plot options
281 // The exception is when this is a fresh job and we want to get the global values as defaults
285 }
286 else
287 {
288 // The default is to use the global adjusts from the pcbnew settings
291 // m_PSWidthAdjust is stored in mm in user config
293 }
294
296
297 m_browseButton->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) );
298 m_openDirButton->SetBitmap( KiBitmapBundle( BITMAPS::small_new_window ) );
299
300
301 // The reasonable width correction value must be in a range of
302 // [-(MinTrackWidth-1), +(MinClearanceValue-1)] decimils.
305
306 switch( m_plotOpts.GetFormat() )
307 {
308 default:
309 case PLOT_FORMAT::GERBER: m_plotFormatOpt->SetSelection( 0 ); break;
310 case PLOT_FORMAT::POST: m_plotFormatOpt->SetSelection( 1 ); break;
311 case PLOT_FORMAT::SVG: m_plotFormatOpt->SetSelection( 2 ); break;
312 case PLOT_FORMAT::DXF: m_plotFormatOpt->SetSelection( 3 ); break;
313 case PLOT_FORMAT::HPGL: m_plotFormatOpt->SetSelection( 4 ); break;
314 case PLOT_FORMAT::PDF: m_plotFormatOpt->SetSelection( 5 ); break;
315 }
316
317 // Set units and value for HPGL pen size (this param is in mils).
319
320 // Test for a reasonable scale value. Set to 1 if problem
323 {
325 }
326
328 unityScale, EDA_UNITS::UNSCALED, m_XScaleAdjust ) );
329
331 unityScale, EDA_UNITS::UNSCALED, m_YScaleAdjust ) );
332
333 // Test for a reasonable PS width correction value. Set to 0 if problem.
334 if( m_PSWidthAdjust < m_widthAdjustMinValue || m_PSWidthAdjust > m_widthAdjustMaxValue )
335 m_PSWidthAdjust = 0.;
336
338
341
342 // Populate the check list box by all enabled layers names.
343 for( PCB_LAYER_ID layer : m_layerList )
344 {
345 int checkIndex = m_layerCheckListBox->Append( board->GetLayerName( layer ) );
346
347 if( m_plotOpts.GetLayerSelection()[layer] )
348 m_layerCheckListBox->Check( checkIndex );
349 }
350
352
353 // Option for disabling Gerber Aperture Macro (for broken Gerber readers)
355
356 // Option for using proper Gerber extensions. Note also Protel extensions are
357 // a broken feature. However, for now, we need to handle it.
359
360 // Option for including Gerber attributes, from Gerber X2 format, in the output
361 // In X1 format, they will be added as comments
363
364 // Option for including Gerber netlist info (from Gerber X2 format) in the output
366
367 // Option to generate a Gerber job file
369
370 // Gerber precision for coordinates
371 m_coordFormatCtrl->SetSelection( m_plotOpts.GetGerberPrecision() == 5 ? 0 : 1 );
372
373 // SVG precision and units for coordinates
376
380
384
385 if( m_plotDNP->GetValue() )
386 {
388 m_hideDNP->SetValue( true );
389 else
390 m_crossoutDNP->SetValue( true );
391 }
392
393 m_hideDNP->Enable( m_plotDNP->GetValue() );
394 m_crossoutDNP->Enable( m_plotDNP->GetValue() );
395
397
399
401
402 // Options to plot pads and vias holes
403 m_drillShapeOpt->SetSelection( (int) m_plotOpts.GetDrillMarksType() );
404
405 // Scale option
406 m_scaleOpt->SetSelection( m_plotOpts.GetScaleSelection() );
407
408 // Plot mode
410
411 // DXF outline mode
413
414 // DXF text mode
416 == PLOT_TEXT_MODE::DEFAULT );
417
418 // DXF units selection
419 m_DXF_plotUnits->SetSelection( m_plotOpts.GetDXFPlotUnits() == DXF_UNITS::INCH ? 0 : 1 );
420
421 // Plot mirror option
422 m_plotMirrorOpt->SetValue( m_plotOpts.GetMirror() );
423
424 // Black and white plotting
425 m_SVGColorChoice->SetSelection( m_plotOpts.GetBlackAndWhite() ? 1 : 0 );
426 m_PDFColorChoice->SetSelection( m_plotOpts.GetBlackAndWhite() ? 1 : 0 );
431
432 // Initialize a few other parameters, which can also be modified
433 // from the drill dialog
434 reInitDialog();
435
436 // Update options values:
437 wxCommandEvent cmd_event;
438 SetPlotFormat( cmd_event );
439 OnSetScaleOpt( cmd_event );
440}
441
442
444{
446 {
447 JOB_EXPORT_PCB_GERBERS* gJob = static_cast<JOB_EXPORT_PCB_GERBERS*>( m_job );
454 gJob->m_useBoardPlotParams = false;
455 }
456
458 {
459 JOB_EXPORT_PCB_SVG* svgJob = static_cast<JOB_EXPORT_PCB_SVG*>( m_job );
463 }
464
466 {
467 JOB_EXPORT_PCB_DXF* dxfJob = static_cast<JOB_EXPORT_PCB_DXF*>( m_job );
468 dxfJob->m_dxfUnits = m_plotOpts.GetDXFPlotUnits() == DXF_UNITS::INCH
471 dxfJob->m_plotGraphicItemsUsingContours = m_plotOpts.GetPlotMode() == OUTLINE_MODE::SKETCH;
474 }
475
477 {
478 JOB_EXPORT_PCB_PS* psJob = static_cast<JOB_EXPORT_PCB_PS*>( m_job );
484 // For a fresh job we got the adjusts from the global pcbnew settings
485 // After the user confirmed and/or changed them we stop using the global adjusts
486 psJob->m_useGlobalSettings = false;
487 }
488
490 {
491 JOB_EXPORT_PCB_PDF* pdfJob = static_cast<JOB_EXPORT_PCB_PDF*>( m_job );
496
497 // we need to embed this for the cli deprecation fix
498 if( pdfJob->m_pdfSingle )
499 {
501 }
502 else
503 {
505 }
506 }
507
514
517
523
526 {
527 switch( m_plotOpts.GetDrillMarksType() )
528 {
529 case DRILL_MARKS::NO_DRILL_SHAPE: m_job->m_drillShapeOption = DRILL_MARKS::NO_DRILL_SHAPE; break;
530 case DRILL_MARKS::SMALL_DRILL_SHAPE: m_job->m_drillShapeOption = DRILL_MARKS::SMALL_DRILL_SHAPE; break;
531 default:
532 case DRILL_MARKS::FULL_DRILL_SHAPE: m_job->m_drillShapeOption = DRILL_MARKS::FULL_DRILL_SHAPE; break;
533 }
534 }
535
537}
538
539
541{
542 // after calling the Drill or DRC dialogs some parameters can be modified....
543
544 // Output directory
546
547 // Origin of coordinates:
549
550 int knownViolations = 0;
551 int exclusions = 0;
552
553 for( PCB_MARKER* marker : m_editFrame->GetBoard()->Markers() )
554 {
555 if( marker->GetSeverity() == RPT_SEVERITY_EXCLUSION )
556 exclusions++;
557 else
558 knownViolations++;
559 }
560
561 if( !m_job && ( knownViolations || exclusions ) )
562 {
563 m_DRCExclusionsWarning->SetLabel( wxString::Format( m_DRCWarningTemplate, knownViolations,
564 exclusions ) );
566 }
567 else
568 {
570 }
571
572 BOARD* board = m_editFrame->GetBoard();
573 const BOARD_DESIGN_SETTINGS& brd_settings = board->GetDesignSettings();
574
575 if( getPlotFormat() == PLOT_FORMAT::GERBER &&
576 ( brd_settings.m_SolderMaskExpansion || brd_settings.m_SolderMaskMinWidth ) )
577 {
579 }
580 else
581 {
583 }
584}
585
586
588{
589 auto findLayer =
590 [&]( wxRearrangeList* aList, PCB_LAYER_ID aLayer ) -> int
591 {
592 for( int ii = 0; ii < (int) aList->GetCount(); ++ii )
593 {
594 if( getLayerClientData( aList, ii )->Layer() == aLayer )
595 return ii;
596 }
597
598 return -1;
599 };
600
601 int idx = 0;
602
603 for( PCB_LAYER_ID layer : aSeq )
604 {
605 int currentPos = findLayer( m_plotAllLayersList, layer );
606
607 while( currentPos > idx )
608 {
609 m_plotAllLayersList->Select( currentPos );
610 m_plotAllLayersList->MoveCurrentUp();
611 currentPos--;
612 }
613
614 idx++;
615 }
616}
617
618
619#define ID_LAYER_FAB 13001
620#define ID_SELECT_COPPER_LAYERS 13002
621#define ID_DESELECT_COPPER_LAYERS 13003
622#define ID_SELECT_ALL_LAYERS 13004
623#define ID_DESELECT_ALL_LAYERS 13005
624#define ID_STACKUP_ORDER 13006
625
626
627// A helper function to show a popup menu, when the dialog is right clicked.
628void DIALOG_PLOT::OnRightClickLayers( wxMouseEvent& event )
629{
630 // Build a list of layers for usual fabrication: copper layers + tech layers without courtyard
631 LSET fab_layer_set = ( LSET::AllCuMask() | LSET::AllTechMask() ) & ~LSET( { B_CrtYd, F_CrtYd } );
632
633 wxMenu menu;
634 menu.Append( new wxMenuItem( &menu, ID_LAYER_FAB, _( "Select Fab Layers" ) ) );
635
636 menu.AppendSeparator();
637 menu.Append( new wxMenuItem( &menu, ID_SELECT_COPPER_LAYERS, _( "Select All Copper Layers" ) ) );
638 menu.Append( new wxMenuItem( &menu, ID_DESELECT_COPPER_LAYERS, _( "Deselect All Copper Layers" ) ) );
639
640 menu.AppendSeparator();
641 menu.Append( new wxMenuItem( &menu, ID_SELECT_ALL_LAYERS, _( "Select All Layers" ) ) );
642 menu.Append( new wxMenuItem( &menu, ID_DESELECT_ALL_LAYERS, _( "Deselect All Layers" ) ) );
643
644 menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
645 [&]( wxCommandEvent& aCmd )
646 {
647 switch( aCmd.GetId() )
648 {
649 case ID_LAYER_FAB: // Select layers usually needed to build a board
650 {
651 for( unsigned i = 0; i < m_layerList.size(); i++ )
652 {
653 LSET layermask( { m_layerList[ i ] } );
654
655 if( ( layermask & fab_layer_set ).any() )
656 m_layerCheckListBox->Check( i, true );
657 else
658 m_layerCheckListBox->Check( i, false );
659 }
660
661 break;
662 }
663
665 for( unsigned i = 0; i < m_layerList.size(); i++ )
666 {
667 if( IsCopperLayer( m_layerList[i] ) )
668 m_layerCheckListBox->Check( i, true );
669 }
670
671 break;
672
674 for( unsigned i = 0; i < m_layerList.size(); i++ )
675 {
676 if( IsCopperLayer( m_layerList[i] ) )
677 m_layerCheckListBox->Check( i, false );
678 }
679
680 break;
681
683 for( unsigned i = 0; i < m_layerList.size(); i++ )
684 m_layerCheckListBox->Check( i, true );
685
686 break;
687
689 for( unsigned i = 0; i < m_layerList.size(); i++ )
690 m_layerCheckListBox->Check( i, false );
691
692 break;
693
694 default:
695 aCmd.Skip();
696 }
697 } );
698
699 PopupMenu( &menu );
700}
701
702
703void DIALOG_PLOT::OnRightClickAllLayers( wxMouseEvent& event )
704{
705 wxMenu menu;
706 menu.Append( new wxMenuItem( &menu, ID_SELECT_ALL_LAYERS, _( "Select All Layers" ) ) );
707 menu.Append( new wxMenuItem( &menu, ID_DESELECT_ALL_LAYERS, _( "Deselect All Layers" ) ) );
708
709 menu.AppendSeparator();
710 menu.Append( new wxMenuItem( &menu, ID_STACKUP_ORDER, _( "Order as Board Stackup" ) ) );
711
712 menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
713 [&]( wxCommandEvent& aCmd )
714 {
715 switch( aCmd.GetId() )
716 {
717 case ID_SELECT_ALL_LAYERS:
718 for( unsigned i = 0; i < m_plotAllLayersList->GetCount(); i++ )
719 m_plotAllLayersList->Check( i, true );
720
721 break;
722
723 case ID_DESELECT_ALL_LAYERS:
724 for( unsigned i = 0; i < m_plotAllLayersList->GetCount(); i++ )
725 m_plotAllLayersList->Check( i, false );
726
727 break;
728
729 case ID_STACKUP_ORDER:
730 {
731 LSEQ stackup = m_editFrame->GetBoard()->GetEnabledLayers().SeqStackupForPlotting();
732 arrangeAllLayersList( stackup );
733 m_plotAllLayersList->Select( -1 );
734 break;
735 }
736
737 default:
738 aCmd.Skip();
739 }
740 } );
741
742 PopupMenu( &menu );
743}
744
745
746void DIALOG_PLOT::CreateDrillFile( wxCommandEvent& event )
747{
748 // Be sure drill file use the same settings (axis option, plot directory) as plot files:
750
751 DIALOG_GENDRILL dlg( m_editFrame, this );
752 dlg.ShowModal();
753
754 // a few plot settings can be modified: take them in account
756 reInitDialog();
757}
758
759
760void DIALOG_PLOT::OnChangeDXFPlotMode( wxCommandEvent& event )
761{
762 // m_DXF_plotTextStrokeFontOpt is disabled if m_DXF_plotModeOpt is checked (plot in DXF
763 // polygon mode)
764 m_DXF_plotTextStrokeFontOpt->Enable( !m_DXF_plotModeOpt->GetValue() );
765
766 // if m_DXF_plotTextStrokeFontOpt option is disabled (plot DXF in polygon mode), force
767 // m_DXF_plotTextStrokeFontOpt to true to use Pcbnew stroke font
768 if( !m_DXF_plotTextStrokeFontOpt->IsEnabled() )
769 m_DXF_plotTextStrokeFontOpt->SetValue( true );
770}
771
772
773void DIALOG_PLOT::OnSetScaleOpt( wxCommandEvent& event )
774{
775 /* Disable sheet reference for scale != 1:1 */
776 bool scale1 = ( m_scaleOpt->GetSelection() == 1 );
777
778 m_plotSheetRef->Enable( scale1 );
779
780 if( !scale1 )
781 m_plotSheetRef->SetValue( false );
782}
783
784
786{
787 // Build the absolute path of current output directory to preselect it in the file browser.
788 std::function<bool( wxString* )> textResolver =
789 [&]( wxString* token ) -> bool
790 {
791 return m_editFrame->GetBoard()->ResolveTextVar( token, 0 );
792 };
793
794 wxString path = m_outputDirectoryName->GetValue();
795 path = ExpandTextVars( path, &textResolver );
797 path = Prj().AbsolutePath( path );
798
799 wxDirDialog dirDialog( this, _( "Select Output Directory" ), path );
800
801 if( dirDialog.ShowModal() == wxID_CANCEL )
802 return;
803
804 wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
805
806 wxFileName fn( Prj().AbsolutePath( m_editFrame->GetBoard()->GetFileName() ) );
807 wxString defaultPath = fn.GetPathWithSep();
808 wxString msg;
809 wxFileName relPathTest; // Used to test if we can make the path relative
810
811 relPathTest.Assign( dirDialog.GetPath() );
812
813 // Test if making the path relative is possible before asking the user if they want to do it
814 if( relPathTest.MakeRelativeTo( defaultPath ) )
815 {
816 msg.Printf( _( "Do you want to use a path relative to\n'%s'?" ), defaultPath );
817
818 wxMessageDialog dialog( this, msg, _( "Plot Output Directory" ),
819 wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
820
821 if( dialog.ShowModal() == wxID_YES )
822 dirName.MakeRelativeTo( defaultPath );
823 }
824
825 m_outputDirectoryName->SetValue( dirName.GetFullPath() );
826}
827
828
830{
831 // plot format id's are ordered like displayed in m_plotFormatOpt
832 static const PLOT_FORMAT plotFmt[] = {
833 PLOT_FORMAT::GERBER,
834 PLOT_FORMAT::POST,
835 PLOT_FORMAT::SVG,
836 PLOT_FORMAT::DXF,
837 PLOT_FORMAT::HPGL,
838 PLOT_FORMAT::PDF };
839
840 return plotFmt[m_plotFormatOpt->GetSelection()];
841}
842
843
844void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
845{
846 // this option exist only in DXF format:
847 m_DXF_plotModeOpt->Enable( getPlotFormat() == PLOT_FORMAT::DXF );
848
849 // The alert message about non 0 solder mask min width and margin is shown
850 // only in gerber format and if min mask width or mask margin is not 0
851 BOARD* board = m_editFrame->GetBoard();
852 const BOARD_DESIGN_SETTINGS& brd_settings = board->GetDesignSettings();
853
854 if( getPlotFormat() == PLOT_FORMAT::GERBER
855 && ( brd_settings.m_SolderMaskExpansion || brd_settings.m_SolderMaskMinWidth ) )
856 {
858 }
859 else
860 {
862 }
863
864 switch( getPlotFormat() )
865 {
866 case PLOT_FORMAT::SVG:
867 case PLOT_FORMAT::PDF:
868 m_drillShapeOpt->Enable( true );
869 m_plotModeOpt->Enable( false );
871 m_plotMirrorOpt->Enable( true );
872 m_useAuxOriginCheckBox->Enable( true );
873 m_defaultPenSize.Enable( false );
874 m_scaleOpt->Enable( false );
875 m_scaleOpt->SetSelection( 1 );
876 m_fineAdjustXCtrl->Enable( false );
877 m_fineAdjustYCtrl->Enable( false );
879 m_plotPSNegativeOpt->Enable( true );
880 m_forcePSA4OutputOpt->Enable( false );
881 m_forcePSA4OutputOpt->SetValue( false );
882
883 if( getPlotFormat() == PLOT_FORMAT::SVG )
884 {
887 }
888 else
889 {
892 }
893
898 break;
899
900 case PLOT_FORMAT::POST:
901 m_drillShapeOpt->Enable( true );
902 m_plotModeOpt->Enable( true );
903 m_plotMirrorOpt->Enable( true );
904 m_useAuxOriginCheckBox->Enable( false );
905 m_useAuxOriginCheckBox->SetValue( false );
906 m_defaultPenSize.Enable( false );
907 m_scaleOpt->Enable( true );
908 m_fineAdjustXCtrl->Enable( true );
909 m_fineAdjustYCtrl->Enable( true );
911 m_plotPSNegativeOpt->Enable( true );
912 m_forcePSA4OutputOpt->Enable( true );
913
920 break;
921
922 case PLOT_FORMAT::GERBER:
923 m_drillShapeOpt->Enable( false );
924 m_drillShapeOpt->SetSelection( 0 );
925 m_plotModeOpt->Enable( false );
927 m_plotMirrorOpt->Enable( false );
928 m_plotMirrorOpt->SetValue( false );
929 m_useAuxOriginCheckBox->Enable( true );
930 m_defaultPenSize.Enable( false );
931 m_scaleOpt->Enable( false );
932 m_scaleOpt->SetSelection( 1 );
933 m_fineAdjustXCtrl->Enable( false );
934 m_fineAdjustYCtrl->Enable( false );
936 m_plotPSNegativeOpt->Enable( false );
937 m_plotPSNegativeOpt->SetValue( false );
938 m_forcePSA4OutputOpt->Enable( false );
939 m_forcePSA4OutputOpt->SetValue( false );
940
947 break;
948
949 case PLOT_FORMAT::HPGL:
950 m_drillShapeOpt->Enable( true );
951 m_plotModeOpt->Enable( true );
952 m_plotMirrorOpt->Enable( true );
953 m_useAuxOriginCheckBox->Enable( false );
954 m_useAuxOriginCheckBox->SetValue( false );
955 m_defaultPenSize.Enable( true );
956 m_scaleOpt->Enable( true );
957 m_fineAdjustXCtrl->Enable( false );
958 m_fineAdjustYCtrl->Enable( false );
960 m_plotPSNegativeOpt->SetValue( false );
961 m_plotPSNegativeOpt->Enable( false );
962 m_forcePSA4OutputOpt->Enable( true );
963
970 break;
971
972 case PLOT_FORMAT::DXF:
973 m_drillShapeOpt->Enable( true );
974 m_plotModeOpt->Enable( false );
976 m_plotMirrorOpt->Enable( false );
977 m_plotMirrorOpt->SetValue( false );
978 m_useAuxOriginCheckBox->Enable( true );
979 m_defaultPenSize.Enable( false );
980 m_scaleOpt->Enable( false );
981 m_scaleOpt->SetSelection( 1 );
982 m_fineAdjustXCtrl->Enable( false );
983 m_fineAdjustYCtrl->Enable( false );
985 m_plotPSNegativeOpt->Enable( false );
986 m_plotPSNegativeOpt->SetValue( false );
987 m_forcePSA4OutputOpt->Enable( false );
988 m_forcePSA4OutputOpt->SetValue( false );
989
996
997 OnChangeDXFPlotMode( event );
998 break;
999
1000 case PLOT_FORMAT::UNDEFINED:
1001 break;
1002 }
1003
1004 /* Update the interlock between scale and frame reference
1005 * (scaling would mess up the frame border...) */
1006 OnSetScaleOpt( event );
1007
1008 Layout();
1009 m_MainSizer->SetSizeHints( this );
1010}
1011
1012
1013// A helper function to "clip" aValue between aMin and aMax and write result in * aResult
1014// return false if clipped, true if aValue is just copied into * aResult
1015static bool setDouble( double* aResult, double aValue, double aMin, double aMax )
1016{
1017 if( aValue < aMin )
1018 {
1019 *aResult = aMin;
1020 return false;
1021 }
1022 else if( aValue > aMax )
1023 {
1024 *aResult = aMax;
1025 return false;
1026 }
1027
1028 *aResult = aValue;
1029 return true;
1030}
1031
1032
1033static bool setInt( int* aResult, int aValue, int aMin, int aMax )
1034{
1035 if( aValue < aMin )
1036 {
1037 *aResult = aMin;
1038 return false;
1039 }
1040 else if( aValue > aMax )
1041 {
1042 *aResult = aMax;
1043 return false;
1044 }
1045
1046 *aResult = aValue;
1047 return true;
1048}
1049
1050
1052{
1053 REPORTER& reporter = m_messagesPanel->Reporter();
1054 PCB_PLOT_PARAMS tempOptions;
1055
1056 tempOptions.SetSubtractMaskFromSilk( m_subtractMaskFromSilk->GetValue() );
1057 tempOptions.SetPlotFrameRef( m_plotSheetRef->GetValue() );
1058 tempOptions.SetSketchPadsOnFabLayers( m_sketchPadsOnFabLayers->GetValue() );
1059 tempOptions.SetPlotPadNumbers( m_plotPadNumbers->GetValue() );
1060 tempOptions.SetHideDNPFPsOnFabLayers( m_plotDNP->GetValue()
1061 && m_hideDNP->GetValue() );
1062 tempOptions.SetSketchDNPFPsOnFabLayers( m_plotDNP->GetValue()
1063 && m_crossoutDNP->GetValue() );
1064 tempOptions.SetCrossoutDNPFPsOnFabLayers( m_plotDNP->GetValue()
1065 && m_crossoutDNP->GetValue() );
1066 tempOptions.SetUseAuxOrigin( m_useAuxOriginCheckBox->GetValue() );
1067 tempOptions.SetScaleSelection( m_scaleOpt->GetSelection() );
1068
1069 int sel = m_drillShapeOpt->GetSelection();
1070 tempOptions.SetDrillMarksType( static_cast<DRILL_MARKS>( sel ) );
1071
1072 tempOptions.SetMirror( m_plotMirrorOpt->GetValue() );
1073 tempOptions.SetPlotMode( m_plotModeOpt->GetSelection() == 1 ? SKETCH : FILLED );
1074 tempOptions.SetDXFPlotPolygonMode( m_DXF_plotModeOpt->GetValue() );
1075
1076 sel = m_DXF_plotUnits->GetSelection();
1077 tempOptions.SetDXFPlotUnits( sel == 0 ? DXF_UNITS::INCH : DXF_UNITS::MM );
1078
1079 if( !m_DXF_plotTextStrokeFontOpt->IsEnabled() ) // Currently, only DXF supports this option
1080 tempOptions.SetTextMode( PLOT_TEXT_MODE::DEFAULT );
1081 else
1082 tempOptions.SetTextMode( m_DXF_plotTextStrokeFontOpt->GetValue() ? PLOT_TEXT_MODE::DEFAULT :
1083 PLOT_TEXT_MODE::NATIVE );
1084
1085 if( getPlotFormat() == PLOT_FORMAT::SVG )
1086 {
1087 tempOptions.SetBlackAndWhite( m_SVGColorChoice->GetSelection() == 1 );
1088 }
1089 else if( getPlotFormat() == PLOT_FORMAT::PDF )
1090 {
1091 tempOptions.SetBlackAndWhite( m_PDFColorChoice->GetSelection() == 1 );
1092 tempOptions.m_PDFFrontFPPropertyPopups = m_frontFPPropertyPopups->GetValue();
1093 tempOptions.m_PDFBackFPPropertyPopups = m_backFPPropertyPopups->GetValue();
1094 tempOptions.m_PDFMetadata = m_pdfMetadata->GetValue();
1095 tempOptions.m_PDFSingle = m_pdfSingle->GetValue();
1096 }
1097 else
1098 {
1099 tempOptions.SetBlackAndWhite( true );
1100 }
1101
1102 // Update settings from text fields. Rewrite values back to the fields,
1103 // since the values may have been constrained by the setters.
1104 wxString msg;
1105
1106 // read HPLG pen size (this param is stored in mils)
1107 // However, due to issues when converting this value from or to mm
1108 // that can slightly change the value, update this param only if it
1109 // is in use
1110 if( getPlotFormat() == PLOT_FORMAT::HPGL )
1111 {
1113 {
1115 msg.Printf( _( "HPGL pen size constrained." ) );
1116 reporter.Report( msg, RPT_SEVERITY_INFO );
1117 }
1118 }
1119 else // keep the last value (initial value if no HPGL plot made)
1120 {
1122 }
1123
1124 // X scale
1125 double tmpDouble;
1126 msg = m_fineAdjustXCtrl->GetValue();
1127 msg.ToDouble( &tmpDouble );
1128
1130 {
1131 msg.Printf( wxT( "%f" ), m_XScaleAdjust );
1132 m_fineAdjustXCtrl->SetValue( msg );
1133 msg.Printf( _( "X scale constrained." ) );
1134 reporter.Report( msg, RPT_SEVERITY_INFO );
1135 }
1136
1137 // Y scale
1138 msg = m_fineAdjustYCtrl->GetValue();
1139 msg.ToDouble( &tmpDouble );
1140
1142 {
1143 msg.Printf( wxT( "%f" ), m_YScaleAdjust );
1144 m_fineAdjustYCtrl->SetValue( msg );
1145 msg.Printf( _( "Y scale constrained." ) );
1146 reporter.Report( msg, RPT_SEVERITY_INFO );
1147 }
1148
1149 auto cfg = m_editFrame->GetPcbNewSettings();
1150
1151 if( m_job )
1152 {
1153 // When using a job we store the adjusts in the plot options
1154 tempOptions.SetFineScaleAdjustX( m_XScaleAdjust );
1155 tempOptions.SetFineScaleAdjustY( m_YScaleAdjust );
1156 }
1157 else
1158 {
1159 // The default is to use the pcbnew settings, so here we modify them
1160 cfg->m_Plot.fine_scale_x = m_XScaleAdjust;
1161 cfg->m_Plot.fine_scale_y = m_YScaleAdjust;
1162 }
1163
1164 cfg->m_Plot.check_zones_before_plotting = m_zoneFillCheck->GetValue();
1165
1166 // PS Width correction
1169 {
1171 msg.Printf( _( "Width correction constrained. The width correction value must be in the"
1172 " range of [%s; %s] for the current design rules." ),
1175 reporter.Report( msg, RPT_SEVERITY_WARNING );
1176 }
1177
1178 if( m_job )
1179 {
1180 // When using a job we store the adjusts in the plot options
1181 tempOptions.SetWidthAdjust( m_PSWidthAdjust );
1182 }
1183 else
1184 {
1185 // The default is to use the pcbnew settings, so here we modify them
1186 // Store m_PSWidthAdjust in mm in user config
1187 cfg->m_Plot.ps_fine_width_adjust = pcbIUScale.IUTomm( m_PSWidthAdjust );
1188 }
1189
1190 tempOptions.SetFormat( getPlotFormat() );
1191
1192 tempOptions.SetDisableGerberMacros( m_disableApertMacros->GetValue() );
1193 tempOptions.SetUseGerberProtelExtensions( m_useGerberExtensions->GetValue() );
1194 tempOptions.SetUseGerberX2format( m_useGerberX2Format->GetValue() );
1195 tempOptions.SetIncludeGerberNetlistInfo( m_useGerberNetAttributes->GetValue() );
1196 tempOptions.SetCreateGerberJobFile( m_generateGerberJobFile->GetValue() );
1197
1198 tempOptions.SetGerberPrecision( m_coordFormatCtrl->GetSelection() == 0 ? 5 : 6 );
1199 tempOptions.SetSvgPrecision( m_svgPrecsision->GetValue() );
1200 tempOptions.SetSvgFitPageToBoard( m_SVG_fitPageToBoard->GetValue() );
1201
1202 LSET selectedLayers;
1203
1204 for( unsigned i = 0; i < m_layerList.size(); i++ )
1205 {
1206 if( m_layerCheckListBox->IsChecked( i ) )
1207 selectedLayers.set( m_layerList[i] );
1208 }
1209
1210 // Get a list of copper layers that aren't being used by inverting enabled layers.
1211 LSET disabledCopperLayers = LSET::AllCuMask() & ~m_editFrame->GetBoard()->GetEnabledLayers();
1212
1213 // Add selected layers from plot on all layers list in order set by user.
1214 wxArrayInt plotOnAllLayers;
1215 LSEQ commonLayers;
1216
1217 if( m_plotAllLayersList->GetCheckedItems( plotOnAllLayers ) )
1218 {
1219 size_t count = plotOnAllLayers.GetCount();
1220
1221 for( size_t i = 0; i < count; i++ )
1222 {
1223 int index = plotOnAllLayers.Item( i );
1224 PCB_LAYER_ID client_layer = getLayerClientData( m_plotAllLayersList, index )->Layer();
1225
1226 commonLayers.push_back( client_layer );
1227 }
1228 }
1229
1230 tempOptions.SetPlotOnAllLayersSequence( commonLayers );
1231
1232 // Enable all of the disabled copper layers.
1233 // If someone enables more copper layers they will be selected by default.
1234 selectedLayers = selectedLayers | disabledCopperLayers;
1235 tempOptions.SetLayerSelection( selectedLayers );
1236
1237 tempOptions.SetNegative( m_plotPSNegativeOpt->GetValue() );
1238 tempOptions.SetA4Output( m_forcePSA4OutputOpt->GetValue() );
1239
1240 // Set output directory and replace backslashes with forward ones
1241 wxString dirStr;
1242 dirStr = m_outputDirectoryName->GetValue();
1243 dirStr.Replace( wxT( "\\" ), wxT( "/" ) );
1244 tempOptions.SetOutputDirectory( dirStr );
1246
1247 if( !m_job && !m_plotOpts.IsSameAs( tempOptions ) )
1248 {
1249 m_editFrame->SetPlotSettings( tempOptions );
1251 m_plotOpts = tempOptions;
1252 }
1253 else
1254 {
1255 m_plotOpts = tempOptions;
1256 }
1257}
1258
1259
1260void DIALOG_PLOT::OnGerberX2Checked( wxCommandEvent& event )
1261{
1262 // Currently: do nothing
1263}
1264
1265
1266void DIALOG_PLOT::Plot( wxCommandEvent& event )
1267{
1268 if( m_job )
1269 {
1272 EndModal( wxID_OK );
1273 }
1274 else
1275 {
1276 BOARD* board = m_editFrame->GetBoard();
1277
1279
1281 PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" );
1282
1284
1286
1287 // If no layer selected, we have nothing plotted.
1288 // Prompt user if it happens because he could think there is a bug in Pcbnew.
1289 if( !m_plotOpts.GetLayerSelection().any() )
1290 {
1291 DisplayError( this, _( "No layer selected, Nothing to plot" ) );
1292 return;
1293 }
1294
1295 // Create output directory if it does not exist (also transform it in absolute form).
1296 // Bail if it fails.
1297
1298 std::function<bool( wxString* )> textResolver =
1299 [&]( wxString* token ) -> bool
1300 {
1301 // Handles board->GetTitleBlock() *and* board->GetProject()
1302 return m_editFrame->GetBoard()->ResolveTextVar( token, 0 );
1303 };
1304
1305 wxString path = m_plotOpts.GetOutputDirectory();
1306 path = ExpandTextVars( path, &textResolver );
1308
1309 wxFileName outputDir = wxFileName::DirName( path );
1310 wxString boardFilename = m_editFrame->GetBoard()->GetFileName();
1311 REPORTER& reporter = m_messagesPanel->Reporter();
1312
1313 if( !EnsureFileDirectoryExists( &outputDir, boardFilename, &reporter ) )
1314 {
1315 wxString msg;
1316 msg.Printf( _( "Could not write plot files to folder '%s'." ), outputDir.GetPath() );
1317 DisplayError( this, msg );
1318 return;
1319 }
1320
1321 if( m_zoneFillCheck->GetValue() )
1322 m_editFrame->GetToolManager()->GetTool<ZONE_FILLER_TOOL>()->CheckAllZones( this );
1323
1324 m_plotOpts.SetAutoScale( false );
1325
1326 switch( m_plotOpts.GetScaleSelection() )
1327 {
1328 default: m_plotOpts.SetScale( 1 ); break;
1329 case 0: m_plotOpts.SetAutoScale( true ); break;
1330 case 2: m_plotOpts.SetScale( 1.5 ); break;
1331 case 3: m_plotOpts.SetScale( 2 ); break;
1332 case 4: m_plotOpts.SetScale( 3 ); break;
1333 }
1334
1335 /* If the scale factor edit controls are disabled or the scale value
1336 * is 0, don't adjust the base scale factor. This fixes a bug when
1337 * the default scale adjust is initialized to 0 and saved in program
1338 * settings resulting in a divide by zero fault.
1339 */
1340 if( getPlotFormat() == PLOT_FORMAT::POST )
1341 {
1342 if( m_XScaleAdjust != 0.0 )
1344
1345 if( m_YScaleAdjust != 0.0 )
1347
1349 }
1350
1351 // Test for a reasonable scale value
1352 // XXX could this actually happen? isn't it constrained in the apply function?
1354 DisplayInfoMessage( this, _( "Warning: Scale option set to a very small value" ) );
1355
1357 DisplayInfoMessage( this, _( "Warning: Scale option set to a very large value" ) );
1358
1359
1360 // Save the current plot options in the board
1362
1363 LOCALE_IO dummy; // Ensure the "C3 locale is used by the plotter
1364 PCB_PLOTTER pcbPlotter( m_editFrame->GetBoard(), &reporter, m_plotOpts );
1365
1366 LSEQ layersToPlot = m_plotOpts.GetLayerSelection().UIOrder();
1367
1368 wxArrayInt plotOnAllLayers;
1369 LSEQ commonLayers;
1370
1371 if( m_plotAllLayersList->GetCheckedItems( plotOnAllLayers ) )
1372 {
1373 size_t count = plotOnAllLayers.GetCount();
1374
1375 for( size_t i = 0; i < count; i++ )
1376 {
1377 int index = plotOnAllLayers.Item( i );
1378 PCB_LAYER_ID client_layer = getLayerClientData( m_plotAllLayersList, index )->Layer();
1379
1380 commonLayers.push_back( client_layer );
1381 }
1382 }
1383
1384 pcbPlotter.Plot( outputDir.GetPath(), layersToPlot, commonLayers,
1385 m_useGerberExtensions->GetValue() );
1386 }
1387}
1388
1389
1390
1391void DIALOG_PLOT::onRunDRC( wxCommandEvent& event )
1392{
1393 PCB_EDIT_FRAME* parent = dynamic_cast<PCB_EDIT_FRAME*>( GetParent() );
1394
1395 if( parent )
1396 {
1397 DRC_TOOL* drcTool = parent->GetToolManager()->GetTool<DRC_TOOL>();
1398
1399 // First close an existing dialog if open
1400 // (low probability, but can happen)
1401 drcTool->DestroyDRCDialog();
1402
1403 // Open a new drc dialog, with the right parent frame, and in Modal Mode
1404 drcTool->ShowDRCDialog( this );
1405
1406 // Update DRC warnings on return to this dialog
1407 reInitDialog();
1408 }
1409}
1410
1411
1412void DIALOG_PLOT::onOpenOutputDirectory( wxCommandEvent& event )
1413{
1414 std::function<bool( wxString* )> textResolver = [&]( wxString* token ) -> bool
1415 {
1416 return m_editFrame->GetBoard()->ResolveTextVar( token, 0 );
1417 };
1418
1419 wxString path = m_outputDirectoryName->GetValue();
1420 path = ExpandTextVars( path, &textResolver );
1422 path = Prj().AbsolutePath( path );
1423
1424 if( !wxDirExists( path ) )
1425 {
1426 DisplayError( this, wxString::Format( _( "Directory '%s' does not exist." ), path ) );
1427 return;
1428 }
1429
1430 wxLaunchDefaultApplication( path );
1431}
1432
1433
1434void DIALOG_PLOT::onBoardSetup( wxHyperlinkEvent& aEvent )
1435{
1436 PCB_EDIT_FRAME* parent = dynamic_cast<PCB_EDIT_FRAME*>( GetParent() );
1437
1438 if( parent )
1439 {
1440 parent->ShowBoardSetupDialog( _( "Solder Mask/Paste" ) );
1441
1442 // Update warnings on return to this dialog
1443 reInitDialog();
1444 }
1445}
1446
1447
1448void DIALOG_PLOT::onPlotAllListMoveUp( wxCommandEvent& aEvent )
1449{
1450 if( m_plotAllLayersList->CanMoveCurrentUp() )
1451 m_plotAllLayersList->MoveCurrentUp();
1452}
1453
1454
1455void DIALOG_PLOT::onPlotAllListMoveDown( wxCommandEvent& aEvent )
1456{
1457 if( m_plotAllLayersList->CanMoveCurrentDown() )
1458 m_plotAllLayersList->MoveCurrentDown();
1459}
1460
1461
1462void DIALOG_PLOT::onDNPCheckbox( wxCommandEvent& aEvent )
1463{
1464 m_hideDNP->Enable( aEvent.IsChecked() );
1465 m_crossoutDNP->Enable( aEvent.IsChecked() );
1466}
1467
1468
1469void DIALOG_PLOT::onSketchPads( wxCommandEvent& aEvent )
1470{
1471 m_plotPadNumbers->Enable( aEvent.IsChecked() );
1472}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:110
constexpr EDA_IU_SCALE unityScale
Definition: base_units.h:113
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition: bitmap.cpp:110
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:218
BASE_SET & set(size_t pos)
Definition: base_set.h:116
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:297
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: board.cpp:434
const MARKERS & Markers() const
Definition: board.h:346
const wxString & GetFileName() const
Definition: board.h:334
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:614
PROJECT * GetProject() const
Definition: board.h:511
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:946
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:829
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
wxCheckBox * m_pdfSingle
wxChoice * m_SVGColorChoice
wxStaticText * m_staticTextPlotFmt
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
STD_BITMAP_BUTTON * m_openDirButton
wxCheckBox * m_plotPSNegativeOpt
wxCheckBox * m_SVG_fitPageToBoard
wxCheckBox * m_DXF_plotTextStrokeFontOpt
wxChoice * m_plotModeOpt
wxCheckBox * m_useGerberExtensions
wxCheckBox * m_plotSheetRef
wxBoxSizer * m_SizerSolderMaskAlert
wxCheckBox * m_generateGerberJobFile
wxRadioButton * m_crossoutDNP
wxButton * m_sdbSizer1Apply
wxCheckBox * m_useGerberX2Format
wxCheckListBox * m_layerCheckListBox
wxCheckBox * m_plotMirrorOpt
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_pdfMetadata
wxChoice * m_drillShapeOpt
wxButton * m_buttonDRC
wxRadioButton * m_hideDNP
wxCheckBox * m_zoneFillCheck
wxStaticBoxSizer * m_GerberOptionsSizer
WX_HTML_REPORT_PANEL * m_messagesPanel
wxChoice * m_PDFColorChoice
wxChoice * m_plotFormatOpt
wxBoxSizer * m_MainSizer
A dialog to set the plot options and create plot files in various formats.
Definition: dialog_plot.h:41
static LSET s_lastAllLayersSet
Definition: dialog_plot.h:116
DIALOG_PLOT(PCB_EDIT_FRAME *aEditFrame)
Definition: dialog_plot.cpp:94
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:119
JOB_EXPORT_PCB_PLOT * m_job
Definition: dialog_plot.h:112
PCB_PLOT_PARAMS m_plotOpts
Definition: dialog_plot.h:105
STD_BITMAP_BUTTON * m_bpMoveUp
Definition: dialog_plot.h:109
void onPlotAllListMoveUp(wxCommandEvent &aEvent)
void OnChangeDXFPlotMode(wxCommandEvent &event) override
int m_widthAdjustMinValue
Definition: dialog_plot.h:97
UNIT_BINDER m_trackWidthCorrection
Definition: dialog_plot.h:101
void onBoardSetup(wxHyperlinkEvent &aEvent) override
void OnRightClickAllLayers(wxMouseEvent &event)
void onSketchPads(wxCommandEvent &event) override
void Plot(wxCommandEvent &event) override
void applyPlotSettings()
int m_PSWidthAdjust
Definition: dialog_plot.h:93
wxString m_DRCWarningTemplate
Definition: dialog_plot.h:103
void setPlotModeChoiceSelection(OUTLINE_MODE aPlotMode)
Definition: dialog_plot.h:77
wxRearrangeList * m_plotAllLayersList
Definition: dialog_plot.h:107
void onPlotAllListMoveDown(wxCommandEvent &aEvent)
void onRunDRC(wxCommandEvent &event) override
void arrangeAllLayersList(const LSEQ &aSeq)
double m_YScaleAdjust
Definition: dialog_plot.h:91
void onOpenOutputDirectory(wxCommandEvent &event) override
void OnSetScaleOpt(wxCommandEvent &event) override
PCB_EDIT_FRAME * m_editFrame
Definition: dialog_plot.h:87
virtual ~DIALOG_PLOT()
STD_BITMAP_BUTTON * m_bpMoveDown
Definition: dialog_plot.h:110
void CreateDrillFile(wxCommandEvent &event) override
void onDNPCheckbox(wxCommandEvent &event) override
UNIT_BINDER m_defaultPenSize
Definition: dialog_plot.h:100
double m_XScaleAdjust
Definition: dialog_plot.h:89
PLOT_FORMAT getPlotFormat()
static LSET s_lastLayerSet
The plot layer set that last time the dialog was opened.
Definition: dialog_plot.h:115
void transferPlotParamsToJob()
int m_widthAdjustMaxValue
Definition: dialog_plot.h:98
void onOutputDirectoryBrowseClicked(wxCommandEvent &event) override
void OnGerberX2Checked(wxCommandEvent &event) override
void init_Dialog()
void SetPlotFormat(wxCommandEvent &event) override
LSEQ m_layerList
Definition: dialog_plot.h:88
void SetupStandardButtons(std::map< int, wxString > aLabels={})
std::string m_hash_key
Definition: dialog_shim.h:194
int ShowModal() override
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
@ ONE_PAGE_PER_LAYER_ONE_FILE
The most traditional output mode KiCad has had.
bool m_pdfSingle
This is a hack to deal with cli having the wrong behavior We will deprecate out the wrong behavior,...
LSEQ m_plotOnAllLayersSequence
Used by SVG & PDF.
DRILL_MARKS m_drillShapeOption
Used by SVG/DXF/PDF/Gerbers.
bool m_mirror
Common Options.
LSEQ m_plotLayerSequence
Layers to include on all individual layer prints.
unsigned int m_precision
void SetConfiguredOutputPath(const wxString &aPath)
Sets the configured output path for the job, this path is always saved to file.
Definition: job.cpp:153
virtual wxString GetSettingsDialogTitle() const
Definition: job.cpp:80
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:37
LSEQ UIOrder() const
Return the copper, technical and user layers in the order shown in layer widget.
Definition: lset.cpp:736
LSEQ SeqStackupForPlotting() const
Return the sequence that is typical for a bottom-to-top stack-up.
Definition: lset.cpp:388
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:583
static const LSET & AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
Definition: lset.cpp:662
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:70
PCB_LAYER_ID Layer() const
Definition: dialog_plot.cpp:81
void SetData(PCB_LAYER_ID aId)
Definition: dialog_plot.cpp:80
PCB_LAYER_ID_CLIENT_DATA(PCB_LAYER_ID aId)
Definition: dialog_plot.cpp:76
bool Plot(const wxString &aOutputPath, const LSEQ &aLayersToPlot, const LSEQ &aCommonLayers, bool aUseGerberFileExtensions, bool aOutputPathIsSingle=false, std::optional< wxString > aLayerName=std::nullopt, std::optional< wxString > aSheetName=std::nullopt, std::optional< wxString > aSheetPath=std::nullopt)
Definition: pcb_plotter.cpp:51
static void PlotJobToPlotOpts(PCB_PLOT_PARAMS &aOpts, JOB_EXPORT_PCB_PLOT *aJob, REPORTER &aReporter)
Translate a JOB to PCB_PLOT_PARAMS.
Parameters and options when plotting/printing a board.
bool GetNegative() const
PLOT_FORMAT GetFormat() const
void SetDrillMarksType(DRILL_MARKS aVal)
bool GetUseAuxOrigin() const
LSEQ GetPlotOnAllLayersSequence() const
bool GetHideDNPFPsOnFabLayers() const
void SetLayerSelection(const LSET &aSelection)
void SetOutputDirectory(const wxString &aDir)
int GetWidthAdjust() const
void SetSketchPadsOnFabLayers(bool aFlag)
void SetUseGerberX2format(bool aUse)
bool GetMirror() const
DXF_UNITS GetDXFPlotUnits() const
void SetA4Output(int aForce)
PLOT_TEXT_MODE GetTextMode() const
bool GetCrossoutDNPFPsOnFabLayers() const
bool GetSketchDNPFPsOnFabLayers() const
void SetPlotOnAllLayersSequence(LSEQ aSeq)
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)
bool GetSvgFitPagetoBoard() const
LSET GetLayerSelection() const
wxString GetOutputDirectory() const
int GetScaleSelection() 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
double GetFineScaleAdjustY() 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 SetCreateGerberJobFile(bool aCreate)
bool GetIncludeGerberNetlistInfo() const
bool m_PDFSingle
Generate a single PDF file for all layers.
void SetNegative(bool aFlag)
double GetFineScaleAdjustX() const
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)
void SetSvgFitPageToBoard(int aSvgFitPageToBoard)
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:125
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:74
wxString m_PcbLastPath[LAST_PATH_SIZE]
MRU path storage.
Definition: project_file.h:179
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:203
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:370
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:73
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
Definition: reporter.h:102
T * GetAppSettings(const char *aFilename)
Return a handle to the a given settings by type.
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieve a color settings object that applications can read colors from.
A bitmap button widget that behaves like a standard dialog button except with an icon.
void SetBitmap(const wxBitmapBundle &aBmp)
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
wxString StringFromValue(double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) 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)
Set the report full file name to the string.
REPORTER & Reporter()
Return the reporter object that reports to this panel.
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:353
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, int aFlags)
Definition: common.cpp:59
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:374
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:221
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:170
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:88
#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
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition: layer_ids.h:663
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ F_CrtYd
Definition: layer_ids.h:116
@ F_Fab
Definition: layer_ids.h:119
@ B_CrtYd
Definition: layer_ids.h:115
@ 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)
Return the string from aValue according to aUnits (inch, mm ...) for display.
Definition: eda_units.cpp:310
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:78
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:100
@ SKETCH
Definition: outline_mode.h:26
#define PLOT_MIN_SCALE
Definition: pcbplot.h:57
#define PLOT_MAX_SCALE
Definition: pcbplot.h:58
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:1071
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
Plotting engines similar to ps (PostScript, Gerber, svg)
@ LAST_PATH_PLOT
Definition: project_file.h:60
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_EXCLUSION
@ RPT_SEVERITY_INFO
std::vector< FAB_LAYER_COLOR > dummy
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: string_utils.h:408
constexpr double IUTomm(int iu) const
Definition: base_units.h:88
const double IU_PER_MM
Definition: base_units.h:76
const double IU_PER_MILS
Definition: base_units.h:77
Definition of file extensions used in Kicad.