Expose black&white setting for PDF plotting also

Also fix an issue plotting tech layers for pads in color

Fixes https://gitlab.com/kicad/code/kicad/-/issues/12740
This commit is contained in:
Jon Evans 2022-10-25 19:06:05 -04:00
parent 9380b9a451
commit 5f0ebfbfbd
5 changed files with 125 additions and 12 deletions

View File

@ -334,6 +334,7 @@ void DIALOG_PLOT::init_Dialog()
// Black and white plotting
m_SVGBlackAndWhite->SetValue( m_plotOpts.GetBlackAndWhite() );
m_PDFBlackAndWhite->SetValue( m_plotOpts.GetBlackAndWhite() );
// Initialize a few other parameters, which can also be modified
// from the drill dialog
@ -575,7 +576,6 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
m_PlotOptionsSizer->Hide( m_SizerSolderMaskAlert );
}
switch( getPlotFormat() )
{
case PLOT_FORMAT::SVG:
@ -597,9 +597,15 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
m_forcePSA4OutputOpt->SetValue( false );
if( getPlotFormat() == PLOT_FORMAT::SVG )
{
m_PlotOptionsSizer->Show( m_svgOptionsSizer );
m_PlotOptionsSizer->Hide( m_PDFOptionsSizer );
}
else
{
m_PlotOptionsSizer->Hide( m_svgOptionsSizer );
m_PlotOptionsSizer->Show( m_PDFOptionsSizer );
}
m_PlotOptionsSizer->Hide( m_GerberOptionsSizer );
m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer );
@ -626,6 +632,7 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
m_PlotOptionsSizer->Show( m_PSOptionsSizer );
m_PlotOptionsSizer->Hide( m_SizerDXF_options );
m_PlotOptionsSizer->Hide( m_svgOptionsSizer );
m_PlotOptionsSizer->Hide( m_PDFOptionsSizer );
break;
case PLOT_FORMAT::GERBER:
@ -652,6 +659,7 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
m_PlotOptionsSizer->Hide( m_PSOptionsSizer );
m_PlotOptionsSizer->Hide( m_SizerDXF_options );
m_PlotOptionsSizer->Hide( m_svgOptionsSizer );
m_PlotOptionsSizer->Hide( m_PDFOptionsSizer );
break;
case PLOT_FORMAT::HPGL:
@ -674,6 +682,7 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
m_PlotOptionsSizer->Hide( m_PSOptionsSizer );
m_PlotOptionsSizer->Hide( m_SizerDXF_options );
m_PlotOptionsSizer->Hide( m_svgOptionsSizer );
m_PlotOptionsSizer->Hide( m_PDFOptionsSizer );
break;
case PLOT_FORMAT::DXF:
@ -699,6 +708,7 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
m_PlotOptionsSizer->Hide( m_PSOptionsSizer );
m_PlotOptionsSizer->Show( m_SizerDXF_options );
m_PlotOptionsSizer->Hide( m_svgOptionsSizer );
m_PlotOptionsSizer->Hide( m_PDFOptionsSizer );
OnChangeDXFPlotMode( event );
break;
@ -787,7 +797,12 @@ void DIALOG_PLOT::applyPlotSettings()
tempOptions.SetTextMode( m_DXF_plotTextStrokeFontOpt->GetValue() ? PLOT_TEXT_MODE::DEFAULT :
PLOT_TEXT_MODE::NATIVE );
tempOptions.SetBlackAndWhite( m_SVGBlackAndWhite->GetValue() );
if( getPlotFormat() == PLOT_FORMAT::SVG )
tempOptions.SetBlackAndWhite( m_SVGBlackAndWhite->GetValue() );
else if( getPlotFormat() == PLOT_FORMAT::PDF )
tempOptions.SetBlackAndWhite( m_PDFBlackAndWhite->GetValue() );
else
tempOptions.SetBlackAndWhite( true );
// Update settings from text fields. Rewrite values back to the fields,
// since the values may have been constrained by the setters.

View File

@ -377,7 +377,7 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr
gbSizer3->Add( m_svgPrecsision, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 );
m_SVGBlackAndWhite = new wxCheckBox( m_svgOptionsSizer->GetStaticBox(), wxID_ANY, _("Plot in black and white"), wxDefaultPosition, wxDefaultSize, 0 );
m_SVGBlackAndWhite->SetToolTip( _("Check to use KiCad stroke font\nUncheck to plot single-line ASCII texts as editable text (using DXF font)") );
m_SVGBlackAndWhite->SetToolTip( _("When disabled, the color from the chosen layer will be used to plot.") );
gbSizer3->Add( m_SVGBlackAndWhite, wxGBPosition( 0, 2 ), wxGBSpan( 1, 1 ), wxALL, 5 );
@ -387,6 +387,16 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr
m_PlotOptionsSizer->Add( m_svgOptionsSizer, 1, wxEXPAND|wxALL, 5 );
m_PDFOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("PDF Options") ), wxVERTICAL );
m_PDFBlackAndWhite = new wxCheckBox( m_PDFOptionsSizer->GetStaticBox(), wxID_ANY, _("Plot in black and white"), wxDefaultPosition, wxDefaultSize, 0 );
m_PDFBlackAndWhite->SetToolTip( _("When disabled, the color from the chosen layer will be used to plot.") );
m_PDFOptionsSizer->Add( m_PDFBlackAndWhite, 0, wxALL, 5 );
m_PlotOptionsSizer->Add( m_PDFOptionsSizer, 1, wxALL|wxEXPAND, 5 );
bmiddleSizer->Add( m_PlotOptionsSizer, 0, 0, 6 );

View File

@ -3727,7 +3727,7 @@
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Check to use KiCad stroke font&#x0A;Uncheck to plot single-line ASCII texts as editable text (using DXF font)</property>
<property name="tooltip">When disabled, the color from the chosen layer will be used to plot.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
@ -3741,6 +3741,84 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">PDF Options</property>
<property name="minimum_size"></property>
<property name="name">m_PDFOptionsSizer</property>
<property name="orient">wxVERTICAL</property>
<property name="parent">1</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Plot in black and white</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_PDFBlackAndWhite</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip">When disabled, the color from the chosen layer will be used to plot.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
</object>
</object>
</object>

View File

@ -122,6 +122,8 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM
wxStaticText* svgPrecisionLabel;
wxSpinCtrl* m_svgPrecsision;
wxCheckBox* m_SVGBlackAndWhite;
wxStaticBoxSizer* m_PDFOptionsSizer;
wxCheckBox* m_PDFBlackAndWhite;
WX_HTML_REPORT_PANEL* m_messagesPanel;
wxBoxSizer* m_sizerButtons;
wxButton* m_buttonDRC;

View File

@ -314,16 +314,24 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
COLOR4D color = COLOR4D::BLACK;
if( ( pad->GetLayerSet() & aLayerMask )[B_Cu] )
color = aPlotOpt.ColorSettings()->GetColor( B_Cu );
// If we're plotting a single layer, the color for that layer can be used directly.
if( aLayerMask.count() == 1 )
{
color = aPlotOpt.ColorSettings()->GetColor( aLayerMask.Seq()[0] );
}
else
{
if( ( pad->GetLayerSet() & aLayerMask )[B_Cu] )
color = aPlotOpt.ColorSettings()->GetColor( B_Cu );
if( ( pad->GetLayerSet() & aLayerMask )[F_Cu] )
color = color.LegacyMix( aPlotOpt.ColorSettings()->GetColor( F_Cu ) );
if( ( pad->GetLayerSet() & aLayerMask )[F_Cu] )
color = color.LegacyMix( aPlotOpt.ColorSettings()->GetColor( F_Cu ) );
if( sketchPads && aLayerMask[F_Fab] )
color = aPlotOpt.ColorSettings()->GetColor( F_Fab );
else if( sketchPads && aLayerMask[B_Fab] )
color = aPlotOpt.ColorSettings()->GetColor( B_Fab );
if( sketchPads && aLayerMask[F_Fab] )
color = aPlotOpt.ColorSettings()->GetColor( F_Fab );
else if( sketchPads && aLayerMask[B_Fab] )
color = aPlotOpt.ColorSettings()->GetColor( B_Fab );
}
VECTOR2I margin;
int width_adj = 0;