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>
54#include <pcb_plotter.h>
55
56#include <wx/dirdlg.h>
57#include <wx/msgdlg.h>
58
59
63
64
68class PCB_LAYER_ID_CLIENT_DATA : public wxClientData
69{
70public:
73 { }
74
76 m_id( aId )
77 { }
78
79 void SetData( PCB_LAYER_ID aId ) { m_id = aId; }
80 PCB_LAYER_ID Layer() const { return m_id; }
81
82private:
84};
85
86
87PCB_LAYER_ID_CLIENT_DATA* getLayerClientData( const wxRearrangeList* aList, int aIdx )
88{
89 return static_cast<PCB_LAYER_ID_CLIENT_DATA*>( aList->GetClientObject( aIdx ) );
90}
91
92
94 : DIALOG_PLOT( aEditFrame, aEditFrame )
95{
96}
97
98
99DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aEditFrame, wxWindow* aParent,
100 JOB_EXPORT_PCB_PLOT* aJob ) :
101 DIALOG_PLOT_BASE( aParent ),
102 m_editFrame( aEditFrame ),
103 m_defaultPenSize( m_editFrame, m_hpglPenLabel, m_hpglPenCtrl, m_hpglPenUnits ),
104 m_trackWidthCorrection( m_editFrame, m_widthAdjustLabel, m_widthAdjustCtrl, m_widthAdjustUnits ),
105 m_job( aJob )
106{
107 BOARD* board = m_editFrame->GetBoard();
108
109 SetName( DLG_WINDOW_NAME );
111
112 if( m_job )
113 {
114 SetTitle( aJob->GetSettingsDialogTitle() );
115
117 m_messagesPanel->Hide();
118
119 m_browseButton->Hide();
120 m_openDirButton->Hide();
121 m_staticTextPlotFmt->Hide();
122 m_plotFormatOpt->Hide();
123 m_buttonDRC->Hide();
125 m_sdbSizer1Apply->Hide();
126 }
127 else
128 {
130 m_messagesPanel->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
131 }
132
133 // DIALOG_SHIM needs a unique hash_key because classname will be the same for both job and
134 // non-job versions (which have different sizes).
135 m_hash_key = TO_UTF8( GetTitle() );
136
137 int order = 0;
138 LSET plotOnAllLayersSelection = m_plotOpts.GetPlotOnAllLayersSelection();
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
154 size_t size = plotOnAllLayersSelection.size();
155
156 if( ( static_cast<size_t>( layer ) <= size ) && plotOnAllLayersSelection.test( layer ) )
157 plotAllLayersOrder.push_back( order );
158 else
159 plotAllLayersOrder.push_back( ~order );
160
161 order += 1;
162 }
163
164 int checkColSize = 22;
165 int layerColSize = textWidth + 15;
166
167#ifdef __WXMAC__
168 // TODO: something in wxWidgets 3.1.x pads checkbox columns with extra space. (It used to
169 // also be that the width of the column would get set too wide (to 30), but that's patched in
170 // our local wxWidgets fork.)
171 checkColSize += 30;
172#endif
173
174 m_layerCheckListBox->SetMinClientSize( wxSize( checkColSize + layerColSize,
175 m_layerCheckListBox->GetMinClientSize().y ) );
176
177 wxStaticBox* allLayersLabel = new wxStaticBox( this, wxID_ANY, _( "Plot on All Layers" ) );
178 wxStaticBoxSizer* sbSizer = new wxStaticBoxSizer( allLayersLabel, wxVERTICAL );
179
180 m_plotAllLayersList = new wxRearrangeList( sbSizer->GetStaticBox(), wxID_ANY,
181 wxDefaultPosition, wxDefaultSize,
182 plotAllLayersOrder, plotAllLayersChoicesStrings, 0 );
183
184 m_plotAllLayersList->SetMinClientSize( wxSize( checkColSize + layerColSize,
185 m_plotAllLayersList->GetMinClientSize().y ) );
186
187 // Attach the LAYER_ID to each item in m_plotAllLayersList
188 // plotAllLayersChoicesStrings and layersIdChoiceList are in the same order,
189 // but m_plotAllLayersList has these strings in a different order
190 for( size_t idx = 0; idx < layersIdChoiceList.size(); idx++ )
191 {
192 wxString& txt = plotAllLayersChoicesStrings[idx];
193 int list_idx = m_plotAllLayersList->FindString( txt, true );
194
195 PCB_LAYER_ID layer_id = layersIdChoiceList[idx];
196 m_plotAllLayersList->SetClientObject( list_idx, new PCB_LAYER_ID_CLIENT_DATA( layer_id ) );
197 }
198
199 sbSizer->Add( m_plotAllLayersList, 1, wxALL | wxEXPAND | wxFIXED_MINSIZE, 3 );
200
201 wxBoxSizer* bButtonSizer;
202 bButtonSizer = new wxBoxSizer( wxHORIZONTAL );
203
204 m_bpMoveUp = new STD_BITMAP_BUTTON( sbSizer->GetStaticBox(), wxID_ANY, wxNullBitmap,
205 wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW | 0 );
206 m_bpMoveUp->SetToolTip( _( "Move current selection up" ) );
207 m_bpMoveUp->SetBitmap( KiBitmapBundle( BITMAPS::small_up ) );
208
209 bButtonSizer->Add( m_bpMoveUp, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 3 );
210
211 m_bpMoveDown = new STD_BITMAP_BUTTON( sbSizer->GetStaticBox(), wxID_ANY, wxNullBitmap,
212 wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW | 0 );
213 m_bpMoveDown->SetToolTip( _( "Move current selection down" ) );
214 m_bpMoveDown->SetBitmap( KiBitmapBundle( BITMAPS::small_down ) );
215
216 bButtonSizer->Add( m_bpMoveDown, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5 );
217
218 sbSizer->Add( bButtonSizer, 0, wxALL | wxEXPAND, 3 );
219
220 bmiddleSizer->Insert( 1, sbSizer, 1, wxALL | wxEXPAND, 5 );
221
222 init_Dialog();
223
224 if( m_job )
225 {
227 }
228 else
229 {
230 SetupStandardButtons( { { wxID_OK, _( "Plot" ) },
231 { wxID_APPLY, _( "Generate Drill Files..." ) },
232 { wxID_CANCEL, _( "Close" ) } } );
233 }
234
235 GetSizer()->Fit( this );
236 GetSizer()->SetSizeHints( this );
237
238 m_bpMoveUp->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveUp, this );
239 m_bpMoveDown->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveDown, this );
240
241 m_layerCheckListBox->Connect( wxEVT_RIGHT_DOWN,
242 wxMouseEventHandler( DIALOG_PLOT::OnRightClickLayers ), nullptr,
243 this );
244
245 m_plotAllLayersList->Connect( wxEVT_RIGHT_DOWN,
246 wxMouseEventHandler( DIALOG_PLOT::OnRightClickAllLayers ), nullptr,
247 this );
248}
249
250
252{
253 s_lastAllLayersOrder.clear();
254
255 for( int ii = 0; ii < (int) m_plotAllLayersList->GetCount(); ++ii )
257
258 m_bpMoveDown->Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveDown, this );
259 m_bpMoveUp->Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveUp, this );
260}
261
262
264{
265 BOARD* board = m_editFrame->GetBoard();
266 wxFileName fileName;
267
268 PROJECT_FILE& projectFile = m_editFrame->Prj().GetProjectFile();
269
270 // Could devote a PlotOrder() function in place of UIOrder().
272
274
275 if( !m_job && !projectFile.m_PcbLastPath[ LAST_PATH_PLOT ].IsEmpty() )
277
280
282
283 m_browseButton->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) );
284 m_openDirButton->SetBitmap( KiBitmapBundle( BITMAPS::small_new_window ) );
285
286 // m_PSWidthAdjust is stored in mm in user config
288
289 // The reasonable width correction value must be in a range of
290 // [-(MinTrackWidth-1), +(MinClearanceValue-1)] decimils.
293
294 switch( m_plotOpts.GetFormat() )
295 {
296 default:
297 case PLOT_FORMAT::GERBER: m_plotFormatOpt->SetSelection( 0 ); break;
298 case PLOT_FORMAT::POST: m_plotFormatOpt->SetSelection( 1 ); break;
299 case PLOT_FORMAT::SVG: m_plotFormatOpt->SetSelection( 2 ); break;
300 case PLOT_FORMAT::DXF: m_plotFormatOpt->SetSelection( 3 ); break;
301 case PLOT_FORMAT::HPGL: m_plotFormatOpt->SetSelection( 4 ); break;
302 case PLOT_FORMAT::PDF: m_plotFormatOpt->SetSelection( 5 ); break;
303 }
304
305 // Set units and value for HPGL pen size (this param is in mils).
307
308 // Test for a reasonable scale value. Set to 1 if problem
311 {
313 }
314
316 unityScale, EDA_UNITS::UNSCALED, m_XScaleAdjust ) );
317
319 unityScale, EDA_UNITS::UNSCALED, m_YScaleAdjust ) );
320
321 // Test for a reasonable PS width correction value. Set to 0 if problem.
322 if( m_PSWidthAdjust < m_widthAdjustMinValue || m_PSWidthAdjust > m_widthAdjustMaxValue )
323 m_PSWidthAdjust = 0.;
324
326
329
330 // Populate the check list box by all enabled layers names.
331 for( PCB_LAYER_ID layer : m_layerList )
332 {
333 int checkIndex = m_layerCheckListBox->Append( board->GetLayerName( layer ) );
334
335 if( m_plotOpts.GetLayerSelection()[layer] )
336 m_layerCheckListBox->Check( checkIndex );
337 }
338
340
341 // Option for disabling Gerber Aperture Macro (for broken Gerber readers)
343
344 // Option for using proper Gerber extensions. Note also Protel extensions are
345 // a broken feature. However, for now, we need to handle it.
347
348 // Option for including Gerber attributes, from Gerber X2 format, in the output
349 // In X1 format, they will be added as comments
351
352 // Option for including Gerber netlist info (from Gerber X2 format) in the output
354
355 // Option to generate a Gerber job file
357
358 // Gerber precision for coordinates
359 m_coordFormatCtrl->SetSelection( m_plotOpts.GetGerberPrecision() == 5 ? 0 : 1 );
360
361 // SVG precision and units for coordinates
363
364 // Option to exclude pads from silkscreen layers
368
372
373 if( m_plotDNP->GetValue() )
374 {
376 m_hideDNP->SetValue( true );
377 else
378 m_crossoutDNP->SetValue( true );
379 }
380
381 m_hideDNP->Enable( m_plotDNP->GetValue() );
382 m_crossoutDNP->Enable( m_plotDNP->GetValue() );
383
384 // Option to tent vias
386
387 // Option to use aux origin
389
390 // Option to plot page references:
392
393 // Option to force ploting of hidden text in footprints
395
396 // Options to plot pads and vias holes
397 m_drillShapeOpt->SetSelection( (int) m_plotOpts.GetDrillMarksType() );
398
399 // Scale option
400 m_scaleOpt->SetSelection( m_plotOpts.GetScaleSelection() );
401
402 // Plot mode
404
405 // DXF outline mode
407
408 // DXF text mode
410 == PLOT_TEXT_MODE::DEFAULT );
411
412 // DXF units selection
413 m_DXF_plotUnits->SetSelection( m_plotOpts.GetDXFPlotUnits() == DXF_UNITS::INCHES ? 0 : 1 );
414
415 // Plot mirror option
416 m_plotMirrorOpt->SetValue( m_plotOpts.GetMirror() );
417
418 // Black and white plotting
419 m_SVGColorChoice->SetSelection( m_plotOpts.GetBlackAndWhite() ? 1 : 0 );
420 m_PDFColorChoice->SetSelection( m_plotOpts.GetBlackAndWhite() ? 1 : 0 );
425
426 // Initialize a few other parameters, which can also be modified
427 // from the drill dialog
428 reInitDialog();
429
430 // Update options values:
431 wxCommandEvent cmd_event;
432 SetPlotFormat( cmd_event );
433 OnSetScaleOpt( cmd_event );
434}
435
436
438{
440 {
441 JOB_EXPORT_PCB_GERBERS* gJob = static_cast<JOB_EXPORT_PCB_GERBERS*>( m_job );
449 gJob->m_useBoardPlotParams = false;
450 }
451
453 {
454 JOB_EXPORT_PCB_SVG* svgJob = static_cast<JOB_EXPORT_PCB_SVG*>( m_job );
457 }
458
460 {
461 JOB_EXPORT_PCB_DXF* dxfJob = static_cast<JOB_EXPORT_PCB_DXF*>( m_job );
462 dxfJob->m_dxfUnits = m_plotOpts.GetDXFPlotUnits() == DXF_UNITS::INCHES
465 dxfJob->m_plotGraphicItemsUsingContours = m_plotOpts.GetPlotMode() == OUTLINE_MODE::SKETCH;
468 }
469
471 {
472 JOB_EXPORT_PCB_PDF* pdfJob = static_cast<JOB_EXPORT_PCB_PDF*>( m_job );
477
478 // we need to embed this for the cli deprecation fix
479 if( pdfJob->m_pdfSingle )
480 {
482 }
483 else
484 {
486 }
487 }
488
494
498
504
507 {
508 switch( m_plotOpts.GetDrillMarksType() )
509 {
510 case DRILL_MARKS::NO_DRILL_SHAPE:
512 break;
513 case DRILL_MARKS::SMALL_DRILL_SHAPE:
515 break;
516 default:
517 case DRILL_MARKS::FULL_DRILL_SHAPE:
519 break;
520 }
521 }
522
524}
525
526
528{
529 // after calling the Drill or DRC dialogs some parameters can be modified....
530
531 // Output directory
533
534 // Origin of coordinates:
536
537 int knownViolations = 0;
538 int exclusions = 0;
539
540 for( PCB_MARKER* marker : m_editFrame->GetBoard()->Markers() )
541 {
542 if( marker->GetSeverity() == RPT_SEVERITY_EXCLUSION )
543 exclusions++;
544 else
545 knownViolations++;
546 }
547
548 if( !m_job && ( knownViolations || exclusions ) )
549 {
550 m_DRCExclusionsWarning->SetLabel( wxString::Format( m_DRCWarningTemplate, knownViolations,
551 exclusions ) );
553 }
554 else
555 {
557 }
558
559 BOARD* board = m_editFrame->GetBoard();
560 const BOARD_DESIGN_SETTINGS& brd_settings = board->GetDesignSettings();
561
562 if( getPlotFormat() == PLOT_FORMAT::GERBER &&
563 ( brd_settings.m_SolderMaskExpansion || brd_settings.m_SolderMaskMinWidth ) )
564 {
566 }
567 else
568 {
570 }
571}
572
573
575{
576 auto findLayer =
577 [&]( wxRearrangeList* aList, PCB_LAYER_ID aLayer ) -> int
578 {
579 for( int ii = 0; ii < (int) aList->GetCount(); ++ii )
580 {
581 if( getLayerClientData( aList, ii )->Layer() == aLayer )
582 return ii;
583 }
584
585 return -1;
586 };
587
588 int idx = 0;
589
590 for( PCB_LAYER_ID layer : aSeq )
591 {
592 int currentPos = findLayer( m_plotAllLayersList, layer );
593
594 while( currentPos > idx )
595 {
596 m_plotAllLayersList->Select( currentPos );
597 m_plotAllLayersList->MoveCurrentUp();
598 currentPos--;
599 }
600
601 idx++;
602 }
603}
604
605
606#define ID_LAYER_FAB 13001
607#define ID_SELECT_COPPER_LAYERS 13002
608#define ID_DESELECT_COPPER_LAYERS 13003
609#define ID_SELECT_ALL_LAYERS 13004
610#define ID_DESELECT_ALL_LAYERS 13005
611#define ID_STACKUP_ORDER 13006
612
613
614// A helper function to show a popup menu, when the dialog is right clicked.
615void DIALOG_PLOT::OnRightClickLayers( wxMouseEvent& event )
616{
617 // Build a list of layers for usual fabrication: copper layers + tech layers without courtyard
618 LSET fab_layer_set = ( LSET::AllCuMask() | LSET::AllTechMask() ) & ~LSET( { B_CrtYd, F_CrtYd } );
619
620 wxMenu menu;
621 menu.Append( new wxMenuItem( &menu, ID_LAYER_FAB, _( "Select Fab Layers" ) ) );
622
623 menu.AppendSeparator();
624 menu.Append( new wxMenuItem( &menu, ID_SELECT_COPPER_LAYERS, _( "Select All Copper Layers" ) ) );
625 menu.Append( new wxMenuItem( &menu, ID_DESELECT_COPPER_LAYERS, _( "Deselect All Copper Layers" ) ) );
626
627 menu.AppendSeparator();
628 menu.Append( new wxMenuItem( &menu, ID_SELECT_ALL_LAYERS, _( "Select All Layers" ) ) );
629 menu.Append( new wxMenuItem( &menu, ID_DESELECT_ALL_LAYERS, _( "Deselect All Layers" ) ) );
630
631 menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
632 [&]( wxCommandEvent& aCmd )
633 {
634 switch( aCmd.GetId() )
635 {
636 case ID_LAYER_FAB: // Select layers usually needed to build a board
637 {
638 for( unsigned i = 0; i < m_layerList.size(); i++ )
639 {
640 LSET layermask( { m_layerList[ i ] } );
641
642 if( ( layermask & fab_layer_set ).any() )
643 m_layerCheckListBox->Check( i, true );
644 else
645 m_layerCheckListBox->Check( i, false );
646 }
647
648 break;
649 }
650
652 for( unsigned i = 0; i < m_layerList.size(); i++ )
653 {
654 if( IsCopperLayer( m_layerList[i] ) )
655 m_layerCheckListBox->Check( i, true );
656 }
657
658 break;
659
661 for( unsigned i = 0; i < m_layerList.size(); i++ )
662 {
663 if( IsCopperLayer( m_layerList[i] ) )
664 m_layerCheckListBox->Check( i, false );
665 }
666
667 break;
668
670 for( unsigned i = 0; i < m_layerList.size(); i++ )
671 m_layerCheckListBox->Check( i, true );
672
673 break;
674
676 for( unsigned i = 0; i < m_layerList.size(); i++ )
677 m_layerCheckListBox->Check( i, false );
678
679 break;
680
681 default:
682 aCmd.Skip();
683 }
684 } );
685
686 PopupMenu( &menu );
687}
688
689
690void DIALOG_PLOT::OnRightClickAllLayers( wxMouseEvent& event )
691{
692 wxMenu menu;
693 menu.Append( new wxMenuItem( &menu, ID_SELECT_ALL_LAYERS, _( "Select All Layers" ) ) );
694 menu.Append( new wxMenuItem( &menu, ID_DESELECT_ALL_LAYERS, _( "Deselect All Layers" ) ) );
695
696 menu.AppendSeparator();
697 menu.Append( new wxMenuItem( &menu, ID_STACKUP_ORDER, _( "Order as Board Stackup" ) ) );
698
699 menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
700 [&]( wxCommandEvent& aCmd )
701 {
702 switch( aCmd.GetId() )
703 {
704 case ID_SELECT_ALL_LAYERS:
705 for( unsigned i = 0; i < m_plotAllLayersList->GetCount(); i++ )
706 m_plotAllLayersList->Check( i, true );
707
708 break;
709
710 case ID_DESELECT_ALL_LAYERS:
711 for( unsigned i = 0; i < m_plotAllLayersList->GetCount(); i++ )
712 m_plotAllLayersList->Check( i, false );
713
714 break;
715
716 case ID_STACKUP_ORDER:
717 {
718 LSEQ stackup = m_editFrame->GetBoard()->GetEnabledLayers().SeqStackupForPlotting();
719 arrangeAllLayersList( stackup );
720 m_plotAllLayersList->Select( -1 );
721 break;
722 }
723
724 default:
725 aCmd.Skip();
726 }
727 } );
728
729 PopupMenu( &menu );
730}
731
732
733void DIALOG_PLOT::CreateDrillFile( wxCommandEvent& event )
734{
735 // Be sure drill file use the same settings (axis option, plot directory) as plot files:
737
738 DIALOG_GENDRILL dlg( m_editFrame, this );
739 dlg.ShowModal();
740
741 // a few plot settings can be modified: take them in account
743 reInitDialog();
744}
745
746
747void DIALOG_PLOT::OnChangeDXFPlotMode( wxCommandEvent& event )
748{
749 // m_DXF_plotTextStrokeFontOpt is disabled if m_DXF_plotModeOpt is checked (plot in DXF
750 // polygon mode)
751 m_DXF_plotTextStrokeFontOpt->Enable( !m_DXF_plotModeOpt->GetValue() );
752
753 // if m_DXF_plotTextStrokeFontOpt option is disabled (plot DXF in polygon mode), force
754 // m_DXF_plotTextStrokeFontOpt to true to use Pcbnew stroke font
755 if( !m_DXF_plotTextStrokeFontOpt->IsEnabled() )
756 m_DXF_plotTextStrokeFontOpt->SetValue( true );
757}
758
759
760void DIALOG_PLOT::OnSetScaleOpt( wxCommandEvent& event )
761{
762 /* Disable sheet reference for scale != 1:1 */
763 bool scale1 = ( m_scaleOpt->GetSelection() == 1 );
764
765 m_plotSheetRef->Enable( scale1 );
766
767 if( !scale1 )
768 m_plotSheetRef->SetValue( false );
769}
770
771
773{
774 // Build the absolute path of current output directory to preselect it in the file browser.
775 std::function<bool( wxString* )> textResolver =
776 [&]( wxString* token ) -> bool
777 {
778 return m_editFrame->GetBoard()->ResolveTextVar( token, 0 );
779 };
780
781 wxString path = m_outputDirectoryName->GetValue();
782 path = ExpandTextVars( path, &textResolver );
784 path = Prj().AbsolutePath( path );
785
786 wxDirDialog dirDialog( this, _( "Select Output Directory" ), path );
787
788 if( dirDialog.ShowModal() == wxID_CANCEL )
789 return;
790
791 wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
792
793 wxFileName fn( Prj().AbsolutePath( m_editFrame->GetBoard()->GetFileName() ) );
794 wxString defaultPath = fn.GetPathWithSep();
795 wxString msg;
796 wxFileName relPathTest; // Used to test if we can make the path relative
797
798 relPathTest.Assign( dirDialog.GetPath() );
799
800 // Test if making the path relative is possible before asking the user if they want to do it
801 if( relPathTest.MakeRelativeTo( defaultPath ) )
802 {
803 msg.Printf( _( "Do you want to use a path relative to\n'%s'?" ), defaultPath );
804
805 wxMessageDialog dialog( this, msg, _( "Plot Output Directory" ),
806 wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
807
808 if( dialog.ShowModal() == wxID_YES )
809 dirName.MakeRelativeTo( defaultPath );
810 }
811
812 m_outputDirectoryName->SetValue( dirName.GetFullPath() );
813}
814
815
817{
818 // plot format id's are ordered like displayed in m_plotFormatOpt
819 static const PLOT_FORMAT plotFmt[] = {
820 PLOT_FORMAT::GERBER,
821 PLOT_FORMAT::POST,
822 PLOT_FORMAT::SVG,
823 PLOT_FORMAT::DXF,
824 PLOT_FORMAT::HPGL,
825 PLOT_FORMAT::PDF };
826
827 return plotFmt[m_plotFormatOpt->GetSelection()];
828}
829
830
831void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
832{
833 // this option exist only in DXF format:
834 m_DXF_plotModeOpt->Enable( getPlotFormat() == PLOT_FORMAT::DXF );
835
836 // The alert message about non 0 solder mask min width and margin is shown
837 // only in gerber format and if min mask width or mask margin is not 0
838 BOARD* board = m_editFrame->GetBoard();
839 const BOARD_DESIGN_SETTINGS& brd_settings = board->GetDesignSettings();
840
841 if( getPlotFormat() == PLOT_FORMAT::GERBER
842 && ( brd_settings.m_SolderMaskExpansion || brd_settings.m_SolderMaskMinWidth ) )
843 {
845 }
846 else
847 {
849 }
850
851 switch( getPlotFormat() )
852 {
853 case PLOT_FORMAT::SVG:
854 case PLOT_FORMAT::PDF:
855 m_drillShapeOpt->Enable( true );
856 m_plotModeOpt->Enable( false );
858 m_plotMirrorOpt->Enable( true );
859 m_useAuxOriginCheckBox->Enable( true );
860 m_defaultPenSize.Enable( false );
861 m_scaleOpt->Enable( false );
862 m_scaleOpt->SetSelection( 1 );
863 m_fineAdjustXCtrl->Enable( false );
864 m_fineAdjustYCtrl->Enable( false );
866 m_plotPSNegativeOpt->Enable( true );
867 m_forcePSA4OutputOpt->Enable( false );
868 m_forcePSA4OutputOpt->SetValue( false );
869
870 if( getPlotFormat() == PLOT_FORMAT::SVG )
871 {
874 }
875 else
876 {
879 }
880
885 break;
886
887 case PLOT_FORMAT::POST:
888 m_drillShapeOpt->Enable( true );
889 m_plotModeOpt->Enable( true );
890 m_plotMirrorOpt->Enable( true );
891 m_useAuxOriginCheckBox->Enable( false );
892 m_useAuxOriginCheckBox->SetValue( false );
893 m_defaultPenSize.Enable( false );
894 m_scaleOpt->Enable( true );
895 m_fineAdjustXCtrl->Enable( true );
896 m_fineAdjustYCtrl->Enable( true );
898 m_plotPSNegativeOpt->Enable( true );
899 m_forcePSA4OutputOpt->Enable( true );
900
907 break;
908
909 case PLOT_FORMAT::GERBER:
910 m_drillShapeOpt->Enable( false );
911 m_drillShapeOpt->SetSelection( 0 );
912 m_plotModeOpt->Enable( false );
914 m_plotMirrorOpt->Enable( false );
915 m_plotMirrorOpt->SetValue( false );
916 m_useAuxOriginCheckBox->Enable( true );
917 m_defaultPenSize.Enable( false );
918 m_scaleOpt->Enable( false );
919 m_scaleOpt->SetSelection( 1 );
920 m_fineAdjustXCtrl->Enable( false );
921 m_fineAdjustYCtrl->Enable( false );
923 m_plotPSNegativeOpt->Enable( false );
924 m_plotPSNegativeOpt->SetValue( false );
925 m_forcePSA4OutputOpt->Enable( false );
926 m_forcePSA4OutputOpt->SetValue( false );
927
934 break;
935
936 case PLOT_FORMAT::HPGL:
937 m_drillShapeOpt->Enable( true );
938 m_plotModeOpt->Enable( true );
939 m_plotMirrorOpt->Enable( true );
940 m_useAuxOriginCheckBox->Enable( false );
941 m_useAuxOriginCheckBox->SetValue( false );
942 m_defaultPenSize.Enable( true );
943 m_scaleOpt->Enable( true );
944 m_fineAdjustXCtrl->Enable( false );
945 m_fineAdjustYCtrl->Enable( false );
947 m_plotPSNegativeOpt->SetValue( false );
948 m_plotPSNegativeOpt->Enable( false );
949 m_forcePSA4OutputOpt->Enable( true );
950
957 break;
958
959 case PLOT_FORMAT::DXF:
960 m_drillShapeOpt->Enable( true );
961 m_plotModeOpt->Enable( false );
963 m_plotMirrorOpt->Enable( false );
964 m_plotMirrorOpt->SetValue( false );
965 m_useAuxOriginCheckBox->Enable( true );
966 m_defaultPenSize.Enable( false );
967 m_scaleOpt->Enable( false );
968 m_scaleOpt->SetSelection( 1 );
969 m_fineAdjustXCtrl->Enable( false );
970 m_fineAdjustYCtrl->Enable( false );
972 m_plotPSNegativeOpt->Enable( false );
973 m_plotPSNegativeOpt->SetValue( false );
974 m_forcePSA4OutputOpt->Enable( false );
975 m_forcePSA4OutputOpt->SetValue( false );
976
983
984 OnChangeDXFPlotMode( event );
985 break;
986
987 case PLOT_FORMAT::UNDEFINED:
988 break;
989 }
990
991 /* Update the interlock between scale and frame reference
992 * (scaling would mess up the frame border...) */
993 OnSetScaleOpt( event );
994
995 Layout();
996 m_MainSizer->SetSizeHints( this );
997}
998
999
1000// A helper function to "clip" aValue between aMin and aMax and write result in * aResult
1001// return false if clipped, true if aValue is just copied into * aResult
1002static bool setDouble( double* aResult, double aValue, double aMin, double aMax )
1003{
1004 if( aValue < aMin )
1005 {
1006 *aResult = aMin;
1007 return false;
1008 }
1009 else if( aValue > aMax )
1010 {
1011 *aResult = aMax;
1012 return false;
1013 }
1014
1015 *aResult = aValue;
1016 return true;
1017}
1018
1019
1020static bool setInt( int* aResult, int aValue, int aMin, int aMax )
1021{
1022 if( aValue < aMin )
1023 {
1024 *aResult = aMin;
1025 return false;
1026 }
1027 else if( aValue > aMax )
1028 {
1029 *aResult = aMax;
1030 return false;
1031 }
1032
1033 *aResult = aValue;
1034 return true;
1035}
1036
1037
1039{
1040 REPORTER& reporter = m_messagesPanel->Reporter();
1041 PCB_PLOT_PARAMS tempOptions;
1042
1043 tempOptions.SetSubtractMaskFromSilk( m_subtractMaskFromSilk->GetValue() );
1044 tempOptions.SetPlotFrameRef( m_plotSheetRef->GetValue() );
1045 tempOptions.SetSketchPadsOnFabLayers( m_sketchPadsOnFabLayers->GetValue() );
1046 tempOptions.SetPlotPadNumbers( m_plotPadNumbers->GetValue() );
1047 tempOptions.SetHideDNPFPsOnFabLayers( m_plotDNP->GetValue()
1048 && m_hideDNP->GetValue() );
1049 tempOptions.SetSketchDNPFPsOnFabLayers( m_plotDNP->GetValue()
1050 && m_crossoutDNP->GetValue() );
1051 tempOptions.SetCrossoutDNPFPsOnFabLayers( m_plotDNP->GetValue()
1052 && m_crossoutDNP->GetValue() );
1053 tempOptions.SetUseAuxOrigin( m_useAuxOriginCheckBox->GetValue() );
1054 tempOptions.SetPlotInvisibleText( m_plotInvisibleText->GetValue() );
1055 tempOptions.SetScaleSelection( m_scaleOpt->GetSelection() );
1056
1057 int sel = m_drillShapeOpt->GetSelection();
1058 tempOptions.SetDrillMarksType( static_cast<DRILL_MARKS>( sel ) );
1059
1060 tempOptions.SetMirror( m_plotMirrorOpt->GetValue() );
1061 tempOptions.SetPlotMode( m_plotModeOpt->GetSelection() == 1 ? SKETCH : FILLED );
1062 tempOptions.SetDXFPlotPolygonMode( m_DXF_plotModeOpt->GetValue() );
1063
1064 sel = m_DXF_plotUnits->GetSelection();
1065 tempOptions.SetDXFPlotUnits( sel == 0 ? DXF_UNITS::INCHES : DXF_UNITS::MILLIMETERS );
1066
1067 if( !m_DXF_plotTextStrokeFontOpt->IsEnabled() ) // Currently, only DXF supports this option
1068 tempOptions.SetTextMode( PLOT_TEXT_MODE::DEFAULT );
1069 else
1070 tempOptions.SetTextMode( m_DXF_plotTextStrokeFontOpt->GetValue() ? PLOT_TEXT_MODE::DEFAULT :
1071 PLOT_TEXT_MODE::NATIVE );
1072
1073 if( getPlotFormat() == PLOT_FORMAT::SVG )
1074 {
1075 tempOptions.SetBlackAndWhite( m_SVGColorChoice->GetSelection() == 1 );
1076 }
1077 else if( getPlotFormat() == PLOT_FORMAT::PDF )
1078 {
1079 tempOptions.SetBlackAndWhite( m_PDFColorChoice->GetSelection() == 1 );
1080 tempOptions.m_PDFFrontFPPropertyPopups = m_frontFPPropertyPopups->GetValue();
1081 tempOptions.m_PDFBackFPPropertyPopups = m_backFPPropertyPopups->GetValue();
1082 tempOptions.m_PDFMetadata = m_pdfMetadata->GetValue();
1083 tempOptions.m_PDFSingle = m_pdfSingle->GetValue();
1084 }
1085 else
1086 {
1087 tempOptions.SetBlackAndWhite( true );
1088 }
1089
1090 // Update settings from text fields. Rewrite values back to the fields,
1091 // since the values may have been constrained by the setters.
1092 wxString msg;
1093
1094 // read HPLG pen size (this param is stored in mils)
1095 // However, due to issues when converting this value from or to mm
1096 // that can slightly change the value, update this param only if it
1097 // is in use
1098 if( getPlotFormat() == PLOT_FORMAT::HPGL )
1099 {
1101 {
1103 msg.Printf( _( "HPGL pen size constrained." ) );
1104 reporter.Report( msg, RPT_SEVERITY_INFO );
1105 }
1106 }
1107 else // keep the last value (initial value if no HPGL plot made)
1108 {
1110 }
1111
1112 // X scale
1113 double tmpDouble;
1114 msg = m_fineAdjustXCtrl->GetValue();
1115 msg.ToDouble( &tmpDouble );
1116
1118 {
1119 msg.Printf( wxT( "%f" ), m_XScaleAdjust );
1120 m_fineAdjustXCtrl->SetValue( msg );
1121 msg.Printf( _( "X scale constrained." ) );
1122 reporter.Report( msg, RPT_SEVERITY_INFO );
1123 }
1124
1125 // Y scale
1126 msg = m_fineAdjustYCtrl->GetValue();
1127 msg.ToDouble( &tmpDouble );
1128
1130 {
1131 msg.Printf( wxT( "%f" ), m_YScaleAdjust );
1132 m_fineAdjustYCtrl->SetValue( msg );
1133 msg.Printf( _( "Y scale constrained." ) );
1134 reporter.Report( msg, RPT_SEVERITY_INFO );
1135 }
1136
1137 auto cfg = m_editFrame->GetPcbNewSettings();
1138
1140 cfg->m_Plot.fine_scale_y = m_YScaleAdjust;
1141
1142 cfg->m_Plot.check_zones_before_plotting = m_zoneFillCheck->GetValue();
1143
1144 // PS Width correction
1147 {
1149 msg.Printf( _( "Width correction constrained. The width correction value must be in the"
1150 " range of [%s; %s] for the current design rules." ),
1153 reporter.Report( msg, RPT_SEVERITY_WARNING );
1154 }
1155
1156 // Store m_PSWidthAdjust in mm in user config
1157 cfg->m_Plot.ps_fine_width_adjust = pcbIUScale.IUTomm( m_PSWidthAdjust );
1158
1159 tempOptions.SetFormat( getPlotFormat() );
1160
1161 tempOptions.SetDisableGerberMacros( m_disableApertMacros->GetValue() );
1162 tempOptions.SetUseGerberProtelExtensions( m_useGerberExtensions->GetValue() );
1163 tempOptions.SetUseGerberX2format( m_useGerberX2Format->GetValue() );
1164 tempOptions.SetIncludeGerberNetlistInfo( m_useGerberNetAttributes->GetValue() );
1165 tempOptions.SetCreateGerberJobFile( m_generateGerberJobFile->GetValue() );
1166
1167 tempOptions.SetGerberPrecision( m_coordFormatCtrl->GetSelection() == 0 ? 5 : 6 );
1168 tempOptions.SetSvgPrecision( m_svgPrecsision->GetValue() );
1169
1170 LSET selectedLayers;
1171
1172 for( unsigned i = 0; i < m_layerList.size(); i++ )
1173 {
1174 if( m_layerCheckListBox->IsChecked( i ) )
1175 selectedLayers.set( m_layerList[i] );
1176 }
1177
1178 // Get a list of copper layers that aren't being used by inverting enabled layers.
1179 LSET disabledCopperLayers = LSET::AllCuMask() & ~m_editFrame->GetBoard()->GetEnabledLayers();
1180
1181 LSET plotOnAllLayers;
1182
1183 // Add selected layers from plot on all layers list in order set by user.
1184 wxArrayInt plotOnAllLayersSelections;
1185
1186 m_plotAllLayersList->GetCheckedItems( plotOnAllLayersSelections );
1187
1188 size_t count = plotOnAllLayersSelections.GetCount();
1189
1190 for( size_t i = 0; i < count; i++ )
1191 {
1192 int index = plotOnAllLayersSelections.Item( i );
1193 wxClientData* tmp = m_plotAllLayersList->GetClientObject( index );
1194 PCB_LAYER_ID_CLIENT_DATA* layerId = dynamic_cast<PCB_LAYER_ID_CLIENT_DATA*>( tmp );
1195
1196 wxCHECK2( layerId, continue );
1197
1198 plotOnAllLayers.set( layerId->Layer() );
1199 }
1200
1201 tempOptions.SetPlotOnAllLayersSelection( plotOnAllLayers );
1202
1203 // Enable all of the disabled copper layers.
1204 // If someone enables more copper layers they will be selected by default.
1205 selectedLayers = selectedLayers | disabledCopperLayers;
1206 tempOptions.SetLayerSelection( selectedLayers );
1207
1208 tempOptions.SetNegative( m_plotPSNegativeOpt->GetValue() );
1209 tempOptions.SetA4Output( m_forcePSA4OutputOpt->GetValue() );
1210
1211 // Set output directory and replace backslashes with forward ones
1212 wxString dirStr;
1213 dirStr = m_outputDirectoryName->GetValue();
1214 dirStr.Replace( wxT( "\\" ), wxT( "/" ) );
1215 tempOptions.SetOutputDirectory( dirStr );
1217
1218 if( !m_job && !m_plotOpts.IsSameAs( tempOptions ) )
1219 {
1220 m_editFrame->SetPlotSettings( tempOptions );
1222 m_plotOpts = tempOptions;
1223 }
1224 else
1225 {
1226 m_plotOpts = tempOptions;
1227 }
1228}
1229
1230
1231void DIALOG_PLOT::OnGerberX2Checked( wxCommandEvent& event )
1232{
1233 // Currently: do nothing
1234}
1235
1236
1237void DIALOG_PLOT::Plot( wxCommandEvent& event )
1238{
1239 if( m_job )
1240 {
1243 EndModal( wxID_OK );
1244 }
1245 else
1246 {
1247 BOARD* board = m_editFrame->GetBoard();
1248
1250
1252 PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" );
1253
1255
1257
1258 // If no layer selected, we have nothing plotted.
1259 // Prompt user if it happens because he could think there is a bug in Pcbnew.
1260 if( !m_plotOpts.GetLayerSelection().any() )
1261 {
1262 DisplayError( this, _( "No layer selected, Nothing to plot" ) );
1263 return;
1264 }
1265
1266 // Create output directory if it does not exist (also transform it in absolute form).
1267 // Bail if it fails.
1268
1269 std::function<bool( wxString* )> textResolver =
1270 [&]( wxString* token ) -> bool
1271 {
1272 // Handles board->GetTitleBlock() *and* board->GetProject()
1273 return m_editFrame->GetBoard()->ResolveTextVar( token, 0 );
1274 };
1275
1276 wxString path = m_plotOpts.GetOutputDirectory();
1277 path = ExpandTextVars( path, &textResolver );
1279
1280 wxFileName outputDir = wxFileName::DirName( path );
1281 wxString boardFilename = m_editFrame->GetBoard()->GetFileName();
1282 REPORTER& reporter = m_messagesPanel->Reporter();
1283
1284 if( !EnsureFileDirectoryExists( &outputDir, boardFilename, &reporter ) )
1285 {
1286 wxString msg;
1287 msg.Printf( _( "Could not write plot files to folder '%s'." ), outputDir.GetPath() );
1288 DisplayError( this, msg );
1289 return;
1290 }
1291
1292 if( m_zoneFillCheck->GetValue() )
1293 m_editFrame->GetToolManager()->GetTool<ZONE_FILLER_TOOL>()->CheckAllZones( this );
1294
1295 m_plotOpts.SetAutoScale( false );
1296
1297 switch( m_plotOpts.GetScaleSelection() )
1298 {
1299 default: m_plotOpts.SetScale( 1 ); break;
1300 case 0: m_plotOpts.SetAutoScale( true ); break;
1301 case 2: m_plotOpts.SetScale( 1.5 ); break;
1302 case 3: m_plotOpts.SetScale( 2 ); break;
1303 case 4: m_plotOpts.SetScale( 3 ); break;
1304 }
1305
1306 /* If the scale factor edit controls are disabled or the scale value
1307 * is 0, don't adjust the base scale factor. This fixes a bug when
1308 * the default scale adjust is initialized to 0 and saved in program
1309 * settings resulting in a divide by zero fault.
1310 */
1311 if( getPlotFormat() == PLOT_FORMAT::POST )
1312 {
1313 if( m_XScaleAdjust != 0.0 )
1315
1316 if( m_YScaleAdjust != 0.0 )
1318
1320 }
1321
1322 // Test for a reasonable scale value
1323 // XXX could this actually happen? isn't it constrained in the apply function?
1325 DisplayInfoMessage( this, _( "Warning: Scale option set to a very small value" ) );
1326
1328 DisplayInfoMessage( this, _( "Warning: Scale option set to a very large value" ) );
1329
1330
1331 // Save the current plot options in the board
1333
1334 LOCALE_IO dummy; // Ensure the "C3 locale is used by the plotter
1335 PCB_PLOTTER pcbPlotter( m_editFrame->GetBoard(), &reporter, m_plotOpts );
1336
1337 LSEQ layersToPlot = m_plotOpts.GetLayerSelection().UIOrder();
1338
1339 wxArrayInt plotOnAllLayers;
1340 LSEQ commonLayers;
1341
1342 if( m_plotAllLayersList->GetCheckedItems( plotOnAllLayers ) )
1343 {
1344 size_t count = plotOnAllLayers.GetCount();
1345
1346 for( size_t i = 0; i < count; i++ )
1347 {
1348 int index = plotOnAllLayers.Item( i );
1349 PCB_LAYER_ID client_layer =
1351
1352 commonLayers.push_back( client_layer );
1353 }
1354 }
1355
1356 pcbPlotter.Plot( outputDir.GetPath(), layersToPlot, commonLayers,
1357 m_useGerberExtensions->GetValue() );
1358 }
1359}
1360
1361
1362
1363void DIALOG_PLOT::onRunDRC( wxCommandEvent& event )
1364{
1365 PCB_EDIT_FRAME* parent = dynamic_cast<PCB_EDIT_FRAME*>( GetParent() );
1366
1367 if( parent )
1368 {
1369 DRC_TOOL* drcTool = parent->GetToolManager()->GetTool<DRC_TOOL>();
1370
1371 // First close an existing dialog if open
1372 // (low probability, but can happen)
1373 drcTool->DestroyDRCDialog();
1374
1375 // Open a new drc dialog, with the right parent frame, and in Modal Mode
1376 drcTool->ShowDRCDialog( this );
1377
1378 // Update DRC warnings on return to this dialog
1379 reInitDialog();
1380 }
1381}
1382
1383
1384void DIALOG_PLOT::onOpenOutputDirectory( wxCommandEvent& event )
1385{
1386 std::function<bool( wxString* )> textResolver = [&]( wxString* token ) -> bool
1387 {
1388 return m_editFrame->GetBoard()->ResolveTextVar( token, 0 );
1389 };
1390
1391 wxString path = m_outputDirectoryName->GetValue();
1392 path = ExpandTextVars( path, &textResolver );
1394 path = Prj().AbsolutePath( path );
1395
1396 if( !wxDirExists( path ) )
1397 {
1398 DisplayError( this, wxString::Format( _( "Directory '%s' does not exist." ), path ) );
1399 return;
1400 }
1401
1402 wxLaunchDefaultApplication( path );
1403}
1404
1405
1406void DIALOG_PLOT::onBoardSetup( wxHyperlinkEvent& aEvent )
1407{
1408 PCB_EDIT_FRAME* parent = dynamic_cast<PCB_EDIT_FRAME*>( GetParent() );
1409
1410 if( parent )
1411 {
1412 parent->ShowBoardSetupDialog( _( "Solder Mask/Paste" ) );
1413
1414 // Update warnings on return to this dialog
1415 reInitDialog();
1416 }
1417}
1418
1419
1420void DIALOG_PLOT::onPlotAllListMoveUp( wxCommandEvent& aEvent )
1421{
1422 if( m_plotAllLayersList->CanMoveCurrentUp() )
1423 m_plotAllLayersList->MoveCurrentUp();
1424}
1425
1426
1427void DIALOG_PLOT::onPlotAllListMoveDown( wxCommandEvent& aEvent )
1428{
1429 if( m_plotAllLayersList->CanMoveCurrentDown() )
1430 m_plotAllLayersList->MoveCurrentDown();
1431}
1432
1433
1434void DIALOG_PLOT::onDNPCheckbox( wxCommandEvent& aEvent )
1435{
1436 m_hideDNP->Enable( aEvent.IsChecked() );
1437 m_crossoutDNP->Enable( aEvent.IsChecked() );
1438}
1439
1440
1441void DIALOG_PLOT::onSketchPads( wxCommandEvent& aEvent )
1442{
1443 m_plotPadNumbers->Enable( aEvent.IsChecked() );
1444}
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
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:199
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:295
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:820
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: board.cpp:436
const MARKERS & Markers() const
Definition: board.h:344
const wxString & GetFileName() const
Definition: board.h:332
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:616
PROJECT * GetProject() const
Definition: board.h:499
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:937
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_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_plotInvisibleText
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:93
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
void OnOutputDirectoryBrowseClicked(wxCommandEvent &event) override
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 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:230
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,...
DRILL_MARKS m_drillShapeOption
Used by SVG/DXF/PDF/Gerbers.
LSEQ m_printMaskLayer
Layers to include on all individual layer prints.
bool m_mirror
Common Options.
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:699
LSEQ SeqStackupForPlotting() const
Return the sequence that is typical for a bottom-to-top stack-up.
Definition: lset.cpp:388
static LSET AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
Definition: lset.cpp:628
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:564
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:69
PCB_LAYER_ID Layer() const
Definition: dialog_plot.cpp:80
void SetData(PCB_LAYER_ID aId)
Definition: dialog_plot.cpp:79
PCB_LAYER_ID_CLIENT_DATA(PCB_LAYER_ID aId)
Definition: dialog_plot.cpp:75
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:49
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
bool GetHideDNPFPsOnFabLayers() const
void SetLayerSelection(LSET aSelection)
void SetOutputDirectory(const wxString &aDir)
void SetSketchPadsOnFabLayers(bool aFlag)
void SetUseGerberX2format(bool aUse)
bool GetMirror() const
DXF_UNITS GetDXFPlotUnits() const
bool GetPlotInvisibleText() const
void SetA4Output(int aForce)
PLOT_TEXT_MODE GetTextMode() const
bool GetCrossoutDNPFPsOnFabLayers() const
bool GetSketchDNPFPsOnFabLayers() const
void SetDXFPlotPolygonMode(bool aFlag)
void SetAutoScale(bool aFlag)
double GetHPGLPenDiameter() const
unsigned GetSvgPrecision() const
void SetPlotFrameRef(bool aFlag)
void SetSketchDNPFPsOnFabLayers(bool aFlag)
bool m_PDFMetadata
Generate PDF metadata for SUBJECT and AUTHOR.
unsigned GetBlackAndWhite() const
double GetScale() const
bool GetCreateGerberJobFile() const
void SetPlotPadNumbers(bool aFlag)
bool GetDXFPlotPolygonMode() const
void SetSketchPadLineWidth(int aWidth)
LSET GetLayerSelection() const
wxString GetOutputDirectory() const
int GetScaleSelection() const
void SetPlotOnAllLayersSelection(LSET aSelection)
LSET GetPlotOnAllLayersSelection() const
bool SetHPGLPenDiameter(double aValue)
bool m_PDFFrontFPPropertyPopups
Generate PDF property popup menus for footprints.
void SetScale(double aVal)
void SetDisableGerberMacros(bool aDisable)
void SetScaleSelection(int aSelection)
void SetFineScaleAdjustX(double aVal)
void SetMirror(bool aFlag)
void SetBlackAndWhite(bool blackAndWhite)
void SetGerberPrecision(int aPrecision)
void SetSubtractMaskFromSilk(bool aSubtract)
bool GetSketchPadsOnFabLayers() const
void SetHideDNPFPsOnFabLayers(bool aFlag)
bool GetSubtractMaskFromSilk() const
int GetGerberPrecision() const
void SetUseGerberProtelExtensions(bool aUse)
bool GetPlotPadNumbers() const
bool GetA4Output() const
DRILL_MARKS GetDrillMarksType() const
bool GetUseGerberX2format() const
void SetDXFPlotUnits(DXF_UNITS aUnit)
void SetColorSettings(COLOR_SETTINGS *aSettings)
bool IsSameAs(const PCB_PLOT_PARAMS &aPcbPlotParams) const
Compare current settings to aPcbPlotParams, including not saved parameters in brd file.
void SetIncludeGerberNetlistInfo(bool aUse)
void SetPlotInvisibleText(bool aFlag)
void SetCreateGerberJobFile(bool aCreate)
bool GetIncludeGerberNetlistInfo() const
bool m_PDFSingle
Generate a single PDF file for all layers.
void SetNegative(bool aFlag)
void SetPlotMode(OUTLINE_MODE aPlotMode)
void SetUseAuxOrigin(bool aAux)
bool m_PDFBackFPPropertyPopups
on front and/or back of board
void SetTextMode(PLOT_TEXT_MODE aVal)
bool GetUseGerberProtelExtensions() const
void SetSvgPrecision(unsigned aPrecision)
bool GetPlotFrameRef() const
void SetCrossoutDNPFPsOnFabLayers(bool aFlag)
void SetFormat(PLOT_FORMAT aFormat)
bool GetDisableGerberMacros() const
void SetFineScaleAdjustY(double aVal)
OUTLINE_MODE GetPlotMode() const
void SetWidthAdjust(int aVal)
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:125
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:72
wxString m_PcbLastPath[LAST_PATH_SIZE]
MRU path storage.
Definition: project_file.h:167
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:200
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:72
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieve a color settings object that applications can read colors from.
T * GetAppSettings(const wxString &aFilename)
Return a handle to the a given settings by type.
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:351
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:372
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:170
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:222
This file is part of the common library.
#define ID_STACKUP_ORDER
static bool setDouble(double *aResult, double aValue, double aMin, double aMax)
static bool setInt(int *aResult, int aValue, int aMin, int aMax)
PCB_LAYER_ID_CLIENT_DATA * getLayerClientData(const wxRearrangeList *aList, int aIdx)
Definition: dialog_plot.cpp:87
#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:617
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:290
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
#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:1073
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:58
@ 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:398
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
Definition of file extensions used in Kicad.