From b2ef81808b68e41aca35a121c8609641fa8f874f Mon Sep 17 00:00:00 2001
From: jean-pierre charras <jp.charras@wanadoo.fr>
Date: Mon, 27 Jan 2025 16:03:17 +0100
Subject: [PATCH] Pcbnew, DIALOG_PLOT: store B&W/Color option for PDF and SVG
 formats

Previously, the dialog started withB&W option.
---
 common/pcb_plot_params.keywords | 1 +
 pcbnew/dialogs/dialog_plot.cpp  | 4 ++--
 pcbnew/pcb_plot_params.cpp      | 6 ++++++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/common/pcb_plot_params.keywords b/common/pcb_plot_params.keywords
index d19fb3b8a3..a536842914 100644
--- a/common/pcb_plot_params.keywords
+++ b/common/pcb_plot_params.keywords
@@ -30,6 +30,7 @@ pdf_metadata
 pdf_single_document
 plotframeref
 plotfptext
+plot_black_and_white
 plotinvisibletext
 plotpadnumbers
 plotreference
diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp
index 87640e78e2..79cc715b67 100644
--- a/pcbnew/dialogs/dialog_plot.cpp
+++ b/pcbnew/dialogs/dialog_plot.cpp
@@ -1072,11 +1072,11 @@ void DIALOG_PLOT::applyPlotSettings()
 
     if( getPlotFormat() == PLOT_FORMAT::SVG )
     {
-        tempOptions.SetBlackAndWhite( !!m_SVGColorChoice->GetSelection() );
+        tempOptions.SetBlackAndWhite( m_SVGColorChoice->GetSelection() == 1 );
     }
     else if( getPlotFormat() == PLOT_FORMAT::PDF )
     {
-        tempOptions.SetBlackAndWhite( !!m_PDFColorChoice->GetSelection() );
+        tempOptions.SetBlackAndWhite( m_PDFColorChoice->GetSelection() == 1 );
         tempOptions.m_PDFFrontFPPropertyPopups = m_frontFPPropertyPopups->GetValue();
         tempOptions.m_PDFBackFPPropertyPopups = m_backFPPropertyPopups->GetValue();
         tempOptions.m_PDFMetadata = m_pdfMetadata->GetValue();
diff --git a/pcbnew/pcb_plot_params.cpp b/pcbnew/pcb_plot_params.cpp
index be5a25627e..abd650fae3 100644
--- a/pcbnew/pcb_plot_params.cpp
+++ b/pcbnew/pcb_plot_params.cpp
@@ -227,6 +227,8 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter ) const
     KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_psnegative ), m_negative );
     KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_psa4output ), m_A4Output );
 
+    KICAD_FORMAT::FormatBool( aFormatter, getTokenName( T_plot_black_and_white ), m_blackAndWhite );
+
     KICAD_FORMAT::FormatBool( aFormatter, "plotinvisibletext", m_plotInvisibleText );
     KICAD_FORMAT::FormatBool( aFormatter, "sketchpadsonfab", m_sketchPadsOnFabLayers );
     KICAD_FORMAT::FormatBool( aFormatter, "plotpadnumbers", m_plotPadNumbers );
@@ -796,6 +798,10 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams )
             aPcbPlotParams->m_negative = parseBool();
             break;
 
+        case T_plot_black_and_white:
+            aPcbPlotParams->m_blackAndWhite = parseBool();
+            break;
+
         case T_plotinvisibletext:
             aPcbPlotParams->m_plotInvisibleText = parseBool();
             break;