← Back to team overview

kicad-developers team mailing list archive

[PATCH] Saving plot dialog settings

 

Hi,

During previous discussions about subtracting masks from silkscreen
layers when plotting gerbers, Dick mentioned that saving plot settings
is not quite up to date. Currently some plot settings to be
saved/loaded are defined in pcbnew_config.cpp. However, that requires
that corresponding variables in the PCB_PLOT_PARAMS class are public.
My proposal is to let the class itself take care of saving/loading the
settings. That's mainly what the attached patch changes. In addition,
all plot dialog settings should now be included. The wxConfig key
names are also edited to start with "Plot", and layer selections are
combined into a single bit mask. Moreover, some global variables in
pcbplot.cpp have been moved into the class, too. g_PcbPlotOptions
itself is still global. However, I think that it could be moved to be
a member of the WinEDA_BasePcbFrame. That way it should be accessible
where needed without being global. And if necessary, plot settings
could still be loaded only once when pcbnew starts (now they are
loaded every time the plot dialog constructor is called). In addition
drill file generation settings could be included into PCB_PLOT_PARAMS.
I can continue working on this if my approach sounds reasonable.

marco
=== modified file 'pcbnew/pcbframe.cpp'
--- pcbnew/pcbframe.cpp	2010-12-21 15:13:09 +0000
+++ pcbnew/pcbframe.cpp	2011-01-01 10:25:26 +0000
@@ -56,7 +56,7 @@
 extern int g_DrawDefaultLineThickness;
 
 // Keys used in read/write config
-#define OPTKEY_DEFAULT_LINEWIDTH_VALUE  wxT( "PlotLineWidth" )
+#define OPTKEY_PLOT_DEFAULT_LINEWIDTH_VALUE  wxT( "PlotDefaultLineWidth" )
 #define PCB_SHOW_FULL_RATSNET_OPT   wxT( "PcbFulRatsnest" )
 #define PCB_MAGNETIC_PADS_OPT   wxT( "PcbMagPadOpt" )
 #define PCB_MAGNETIC_TRACKS_OPT wxT( "PcbMagTrackOpt" )
@@ -513,7 +513,7 @@
     WinEDA_BasePcbFrame::LoadSettings();
 
     long tmp;
-    config->Read( OPTKEY_DEFAULT_LINEWIDTH_VALUE, &g_DrawDefaultLineThickness );
+    config->Read( OPTKEY_PLOT_DEFAULT_LINEWIDTH_VALUE, &g_DrawDefaultLineThickness );
     config->Read( PCB_SHOW_FULL_RATSNET_OPT, &tmp );
     GetBoard()->SetElementVisibility(RATSNEST_VISIBLE, tmp);
     config->Read( PCB_MAGNETIC_PADS_OPT, &g_MagneticPadOption );
@@ -539,7 +539,7 @@
 
     wxRealPoint GridSize = GetScreen()->GetGridSize();
 
-    config->Write( OPTKEY_DEFAULT_LINEWIDTH_VALUE, g_DrawDefaultLineThickness );
+    config->Write( OPTKEY_PLOT_DEFAULT_LINEWIDTH_VALUE, g_DrawDefaultLineThickness );
     long tmp = GetBoard()->IsElementVisible(RATSNEST_VISIBLE);
     config->Write( PCB_SHOW_FULL_RATSNET_OPT, tmp );
     config->Write( PCB_MAGNETIC_PADS_OPT, (long) g_MagneticPadOption );

=== modified file 'pcbnew/pcbnew_config.cpp'
--- pcbnew/pcbnew_config.cpp	2010-12-11 18:40:39 +0000
+++ pcbnew/pcbnew_config.cpp	2010-12-29 19:02:06 +0000
@@ -398,34 +398,5 @@
                                                     &g_Show_Module_Ratsnest, TRUE ) );
     m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "TwoSegT" ),
                                                     &g_TwoSegmentTrackBuild, TRUE ) );
-    // Plot options:
-    m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "HPGLnum" ),
-                                                   &g_PcbPlotOptions.m_HPGLPenNum,
-                                                   1, 1, 16 ) );
-    m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "HPGdiam" ),
-                                                   &g_PcbPlotOptions.m_HPGLPenDiam,
-                                                   15, 0, 100 ) );
-    m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "HPGLSpd" ),
-                                                   &g_PcbPlotOptions.m_HPGLPenSpeed,
-                                                   20, 0, 1000 ) );
-    m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "HPGLrec" ),
-                                                   &g_PcbPlotOptions.m_HPGLPenOvr,
-                                                   2, 0, 0x100 ) );
-    m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "PlotOutputFormat" ),
-                                                    &g_PcbPlotOptions.m_PlotFormat, PLOT_FORMAT_GERBER ) );
-    m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "EdgeLayerGerberOpt" ),
-                                                    &g_PcbPlotOptions.m_ExcludeEdgeLayer, true ) );
-    m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "SubstractMasktoSilk" ),
-                                                    &g_PcbPlotOptions.m_SubtractMaskFromSilk, false ) );
-    m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "PlotPadsOnSilkscreen" ),
-                                                    &g_PcbPlotOptions.m_PlotPadsOnSilkLayer, false ) );
-    m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "PlotFrameRef" ),
-                                                    &g_PcbPlotOptions.m_PlotFrameRef, false ) );
-    m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "PlotViasOnMask" ),
-                                                    &g_PcbPlotOptions.m_PlotViaOnMaskLayer, false ) );
-    m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "PlotHolesOpt" ),
-                                                    (int*)&g_PcbPlotOptions.m_DrillShapeOpt,
-                                                    PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE ) );
-
     return m_configSettings;
 }

=== modified file 'pcbnew/pcbplot.cpp'
--- pcbnew/pcbplot.cpp	2010-12-21 15:13:09 +0000
+++ pcbnew/pcbplot.cpp	2011-01-01 10:24:46 +0000
@@ -21,40 +21,198 @@
 #define PLOT_DEFAULT_MARGE 300      // mils
 
 /* Keywords to r/w options in m_Config */
-#define OPTKEY_GERBER_EXTENSIONS wxT( "GerberOptUseLayersExt" )
-#define OPTKEY_XFINESCALE_ADJ    wxT( "PlotXFineScaleAdj" )
-#define OPTKEY_YFINESCALE_ADJ    wxT( "PlotYFineScaleAdj" )
+#define OPTKEY_PLOT_LAYER_SELECTION      wxT( "PlotLayerSelection" )
+#define OPTKEY_PLOT_GERBER_EXTENSIONS    wxT( "PlotUseGerberExtensions" )
+#define OPTKEY_PLOT_EXCLUDE_EDGE_LAYER   wxT( "PlotExcludeEdgeLayer" )
+#define OPTKEY_PLOT_LINE_WIDTH           wxT( "PlotLineWidth" )
+#define OPTKEY_PLOT_VIAS_ON_MASK         wxT( "PlotViasOnMask" )
+#define OPTKEY_PLOT_MODE                 wxT( "PlotMode" )
+#define OPTKEY_PLOT_AUX_ORIGIN           wxT( "PlotAuxOrigin" )
+#define OPTKEY_PLOT_HPGL_PEN_NUM         wxT( "PlotHPGLPenNumber" )
+#define OPTKEY_PLOT_HPGL_PEN_SPEED       wxT( "PlotHPGLPenSpeed" )
+#define OPTKEY_PLOT_HPGL_PEN_DIAMETER    wxT( "PlotHPGLPenDiameter" )
+#define OPTKEY_PLOT_HPGL_PEN_OVERLAY     wxT( "PlotHPGLPenOverlay" )
+#define OPTKEY_PLOT_PS_COLOR             wxT( "PlotPSColor" )
+#define OPTKEY_PLOT_PS_NEGATIVE          wxT( "PlotPSNegative" )
+#define OPTKEY_PLOT_FRAME_REFERENCE      wxT( "PlotFrameRef" )
+#define OPTKEY_PLOT_VALUE                wxT( "PlotValue" )
+#define OPTKEY_PLOT_REFERENCE            wxT( "PlotReference" )
+#define OPTKEY_PLOT_TEXT_OTHER           wxT( "PlotTextOther" )
+#define OPTKEY_PLOT_INVISIBLE_TEXTS      wxT( "PlotInvisibleTexts" )
+#define OPTKEY_PLOT_PADS_ON_SILK         wxT( "PlotPadsOnSilkscreen" )
+#define OPTKEY_PLOT_SUBTRACT_MASK        wxT( "PlotSubtractMask" )
+#define OPTKEY_PLOT_OUTPUT_FORMAT        wxT( "PlotOutputFormat" )
+#define OPTKEY_PLOT_MIRROR               wxT( "PlotMirror" )
+#define OPTKEY_PLOT_DRILL_SHAPE          wxT( "PlotDrillShape" )
+#define OPTKEY_PLOT_SCALE                wxT( "PlotScaleSelection" )
+#define OPTKEY_PLOT_XFINESCALE_ADJ       wxT( "PlotXFineScaleAdj" )
+#define OPTKEY_PLOT_YFINESCALE_ADJ       wxT( "PlotYFineScaleAdj" )
 
 // Define min and max reasonable values for print scale
 #define MIN_SCALE 0.01
 #define MAX_SCALE 100.0
 
+extern int       g_DrawDefaultLineThickness;
+
+
 // PCB_PLOT_PARAMS constructor: set the default values for plot options:
 PCB_PLOT_PARAMS::PCB_PLOT_PARAMS()
 {
-    m_SubtractMaskFromSilk = false;
-    m_PlotReference = true;
-    m_PlotValue     = true;
-    m_PlotTextOther = true;
-    m_DrillShapeOpt = PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE;
-    m_PlotMode  = FILLED;
-    m_PlotScale = 1.0;
-    m_AutoScale = false;
-    m_FineScaleAdjustX = 1.0;
-    m_FineScaleAdjustY = 1.0;
-    outputDirectory    = wxT( "" );
-}
-
-
-static long s_SelectedLayers = LAYER_BACK | LAYER_FRONT |
-                               SILKSCREEN_LAYER_FRONT | SILKSCREEN_LAYER_BACK;
-
-static bool s_PlotOriginIsAuxAxis = FALSE;
-
+    config                 = NULL;
+    layerSelection         = LAYER_BACK | LAYER_FRONT
+                             | SILKSCREEN_LAYER_FRONT | SILKSCREEN_LAYER_BACK;
+    useGerberExtensions    = true;
+    m_ExcludeEdgeLayer     = true;
+    m_PlotLineWidth        = g_DrawDefaultLineThickness;
+    m_PlotFrameRef         = false;
+    m_PlotViaOnMaskLayer   = false;
+    m_PlotMode             = FILLED;
+    auxOrigin              = false;
+    m_HPGLPenNum           = 1;
+    m_HPGLPenSpeed         = 20;
+    m_HPGLPenDiam          = 15;
+    m_HPGLPenOvr           = 2;
+    m_PlotPSColorOpt       = true;
+    m_PlotPSNegative       = false;
+    m_PlotReference        = true;
+    m_PlotValue            = true;
+    m_PlotTextOther        = true;
+    m_PlotInvisibleTexts   = false;
+    m_PlotPadsOnSilkLayer  = false;
+    subtractMaskFromSilk   = false;
+    m_PlotFormat           = PLOT_FORMAT_GERBER;
+    m_PlotMirror           = false;
+    m_DrillShapeOpt        = SMALL_DRILL_SHAPE;
+    m_AutoScale            = false;
+    m_PlotScale            = 1.0;
+    scaleSelection         = 1;
+    m_FineScaleAdjustX     = 1.0;
+    m_FineScaleAdjustY     = 1.0;
+    outputDirectory        = wxT( "" );
+}
+
+void PCB_PLOT_PARAMS::readConfigLong( wxString aKey, long* aLong )
+{
+    long temp;
+    wxASSERT( config );
+    if( !config->Read( aKey, &temp ) )
+        return;
+    *aLong = temp;
+}
+
+void PCB_PLOT_PARAMS::readConfigInt( wxString aKey, int* aInt,
+                                     int aMin, int aMax )
+{
+    long temp;
+    wxASSERT( config );
+    if( !config->Read( aKey, &temp ) )
+        return;
+    if( temp < aMin )
+        return;
+    if( temp > aMax )
+        return;
+    *aInt = (int)temp;
+}
+
+void PCB_PLOT_PARAMS::readConfigDouble( wxString aKey, double* aDouble,
+                                        double aMin, double aMax )
+{
+    double temp;
+    wxASSERT( config );
+    if( !config->Read( aKey, &temp ) )
+        return;
+    if( temp < aMin )
+        return;
+    if( temp > aMax )
+        return;
+    *aDouble = temp;
+}
+
+void PCB_PLOT_PARAMS::readConfigBool( wxString aKey, bool* aBool )
+{
+    bool temp;
+    wxASSERT( config );
+    if( !config->Read( aKey, &temp ) )
+        return;
+    *aBool = temp;
+}
+
+void PCB_PLOT_PARAMS::SaveSettings( wxConfig* aConfig )
+{
+    config = aConfig;
+    config->Write( OPTKEY_PLOT_LAYER_SELECTION, layerSelection );
+    config->Write( OPTKEY_PLOT_GERBER_EXTENSIONS, useGerberExtensions );
+    config->Write( OPTKEY_PLOT_EXCLUDE_EDGE_LAYER, m_ExcludeEdgeLayer );
+    config->Write( OPTKEY_PLOT_LINE_WIDTH, (long)m_PlotLineWidth );
+    config->Write( OPTKEY_PLOT_FRAME_REFERENCE, m_PlotFrameRef );
+    config->Write( OPTKEY_PLOT_VIAS_ON_MASK, m_PlotViaOnMaskLayer );
+    config->Write( OPTKEY_PLOT_MODE, (long)m_PlotMode );
+    config->Write( OPTKEY_PLOT_AUX_ORIGIN, auxOrigin );
+    config->Write( OPTKEY_PLOT_HPGL_PEN_NUM, (long)m_HPGLPenNum );
+    config->Write( OPTKEY_PLOT_HPGL_PEN_SPEED, (long)m_HPGLPenSpeed );
+    config->Write( OPTKEY_PLOT_HPGL_PEN_DIAMETER, (long)m_HPGLPenDiam );
+    config->Write( OPTKEY_PLOT_HPGL_PEN_OVERLAY, (long)m_HPGLPenOvr );
+    config->Write( OPTKEY_PLOT_PS_COLOR, (long)m_PlotPSColorOpt );
+    config->Write( OPTKEY_PLOT_PS_NEGATIVE, m_PlotPSNegative );
+    config->Write( OPTKEY_PLOT_VALUE, m_PlotValue );
+    config->Write( OPTKEY_PLOT_REFERENCE, m_PlotReference );
+    config->Write( OPTKEY_PLOT_TEXT_OTHER, m_PlotTextOther );
+    config->Write( OPTKEY_PLOT_INVISIBLE_TEXTS, m_PlotInvisibleTexts );
+    config->Write( OPTKEY_PLOT_PADS_ON_SILK, m_PlotPadsOnSilkLayer );
+    config->Write( OPTKEY_PLOT_SUBTRACT_MASK, subtractMaskFromSilk );
+    config->Write( OPTKEY_PLOT_OUTPUT_FORMAT, (long)m_PlotFormat );
+    config->Write( OPTKEY_PLOT_MIRROR, m_PlotMirror );
+    config->Write( OPTKEY_PLOT_DRILL_SHAPE, (long)m_DrillShapeOpt );
+    config->Write( OPTKEY_PLOT_SCALE, (long)scaleSelection );
+    config->Write( OPTKEY_PLOT_XFINESCALE_ADJ, m_FineScaleAdjustX );
+    config->Write( OPTKEY_PLOT_YFINESCALE_ADJ, m_FineScaleAdjustY );
+}
+
+void PCB_PLOT_PARAMS::LoadSettings( wxConfig* aConfig )
+{
+    config = aConfig;
+    readConfigLong( OPTKEY_PLOT_LAYER_SELECTION, &layerSelection );
+    readConfigBool( OPTKEY_PLOT_GERBER_EXTENSIONS, &useGerberExtensions );
+    readConfigBool( OPTKEY_PLOT_EXCLUDE_EDGE_LAYER, &m_ExcludeEdgeLayer );
+    readConfigInt( OPTKEY_PLOT_LINE_WIDTH, &m_PlotLineWidth,
+                   40, 200 );
+    readConfigBool( OPTKEY_PLOT_FRAME_REFERENCE, &m_PlotFrameRef );
+    readConfigBool( OPTKEY_PLOT_VIAS_ON_MASK, &m_PlotViaOnMaskLayer );
+    readConfigInt( OPTKEY_PLOT_MODE, (int*)&m_PlotMode,
+                   0, 2 );
+    readConfigBool( OPTKEY_PLOT_AUX_ORIGIN, &auxOrigin );
+    readConfigInt( OPTKEY_PLOT_HPGL_PEN_NUM, &m_HPGLPenNum,
+                   1, 16 );
+    readConfigInt( OPTKEY_PLOT_HPGL_PEN_SPEED, &m_HPGLPenSpeed,
+                   0, 1000 );
+    readConfigInt( OPTKEY_PLOT_HPGL_PEN_DIAMETER, &m_HPGLPenDiam,
+                   0, 100 );
+    readConfigInt( OPTKEY_PLOT_HPGL_PEN_OVERLAY, &m_HPGLPenOvr,
+                   0, 0x100 );
+    readConfigInt( OPTKEY_PLOT_PS_COLOR, &m_PlotPSColorOpt,
+                   0, 1 );
+    readConfigBool( OPTKEY_PLOT_PS_NEGATIVE, &m_PlotPSNegative );
+    readConfigBool( OPTKEY_PLOT_VALUE, &m_PlotValue );
+    readConfigBool( OPTKEY_PLOT_REFERENCE, &m_PlotReference );
+    readConfigBool( OPTKEY_PLOT_TEXT_OTHER, &m_PlotTextOther );
+    readConfigBool( OPTKEY_PLOT_INVISIBLE_TEXTS, &m_PlotInvisibleTexts );
+    readConfigBool( OPTKEY_PLOT_PADS_ON_SILK, &m_PlotPadsOnSilkLayer );
+    readConfigBool( OPTKEY_PLOT_SUBTRACT_MASK, &subtractMaskFromSilk );
+    readConfigInt( OPTKEY_PLOT_OUTPUT_FORMAT, &m_PlotFormat,
+                   0, 4 );
+    readConfigBool( OPTKEY_PLOT_MIRROR, &m_PlotMirror );
+    readConfigInt( OPTKEY_PLOT_DRILL_SHAPE, (int*)&m_DrillShapeOpt,
+                   0, 2 );
+    readConfigInt( OPTKEY_PLOT_SCALE, &scaleSelection,
+                   0, 4 );
+    readConfigDouble( OPTKEY_PLOT_XFINESCALE_ADJ, &m_FineScaleAdjustX,
+                      MIN_SCALE, MAX_SCALE );
+    readConfigDouble( OPTKEY_PLOT_YFINESCALE_ADJ, &m_FineScaleAdjustY,
+                      MIN_SCALE, MAX_SCALE );
+}
 
 /* The group of plot options - sadly global XXX */
 PCB_PLOT_PARAMS g_PcbPlotOptions;
-extern int       g_DrawDefaultLineThickness;
 
 
 /*******************************/
@@ -69,8 +227,6 @@
     wxCheckBox*      m_BoxSelectLayer[LAYER_COUNT];     // wxCheckBox list to select/deselec layers to plot
     double           m_XScaleAdjust;
     double           m_YScaleAdjust;
-    static           int m_dlgPlotScaleOpt;         // Static to remember last selection
-
 
     bool useA4()
     {
@@ -117,8 +273,6 @@
     void CreateDrillFile( wxCommandEvent& event );
 };
 
-int DIALOG_PLOT::m_dlgPlotScaleOpt = 1;
-
 const int UNITS_MILS = 1000;
 
 
@@ -128,6 +282,8 @@
     m_Parent = parent;
     m_Config = wxGetApp().m_EDA_Config;
 
+    g_PcbPlotOptions.LoadSettings( m_Config );
+
     Init_Dialog();
 
     GetSizer()->Fit( this );
@@ -143,13 +299,12 @@
 
     BOARD*     board = m_Parent->GetBoard();
 
-    m_Config->Read( OPTKEY_XFINESCALE_ADJ, &m_XScaleAdjust );
-    m_Config->Read( OPTKEY_YFINESCALE_ADJ, &m_YScaleAdjust );
+    m_XScaleAdjust = g_PcbPlotOptions.m_FineScaleAdjustX;
+    m_YScaleAdjust = g_PcbPlotOptions.m_FineScaleAdjustY;
 
     m_plotFormatOpt->SetSelection( g_PcbPlotOptions.m_PlotFormat );
     g_PcbPlotOptions.m_PlotLineWidth = g_DrawDefaultLineThickness;
 
-
     // Set units and value for HPGL pen speed.
     AddUnitSymbol( *m_textPenSize, g_UserUnit );
     msg = ReturnStringFromValue( g_UserUnit, g_PcbPlotOptions.m_HPGLPenDiam, UNITS_MILS );
@@ -171,12 +326,9 @@
                                  PCB_INTERNAL_UNIT );
     m_linesWidth->AppendText( msg );
 
-    if( s_PlotOriginIsAuxAxis )
+    if( g_PcbPlotOptions.GetAuxOrigin() )
         m_choicePlotOffset->SetSelection( 1 );
 
-    // Create scale adjust option
-    m_XScaleAdjust = m_YScaleAdjust = 1.0;
-
     // Test for a reasonable scale value. Set to 1 if problem
     if( m_XScaleAdjust < MIN_SCALE || m_YScaleAdjust < MIN_SCALE
         || m_XScaleAdjust > MAX_SCALE || m_YScaleAdjust > MAX_SCALE )
@@ -190,10 +342,8 @@
 
     m_plotPSNegativeOpt->SetValue( g_PcbPlotOptions.m_PlotPSNegative );
 
-
     // Create layer list.
     int      layer;
-    wxString layerKey;
     for( layer = 0; layer < NB_LAYERS; ++layer )
     {
         if( !board->IsLayerEnabled( layer ) )
@@ -223,24 +373,14 @@
             m_TechnicalLayersBoxSizer->Add( m_BoxSelectLayer[layer],
                                             0, wxGROW | wxALL, 1 );
 
-
-        layerKey.Printf( OPTKEY_LAYERBASE, layer );
-        bool option;
-        if( m_Config->Read( layerKey, &option ) )
-            m_BoxSelectLayer[layer]->SetValue( option );
-        else
-        {
-            long mask = 1 << layer;
-            if( mask & s_SelectedLayers )
-                m_BoxSelectLayer[layer]->SetValue( true );
-        }
+        long mask = 1 << layer;
+        if( g_PcbPlotOptions.GetLayerSelection() & mask )
+            m_BoxSelectLayer[layer]->SetValue( true );
     }
 
 
     // Option for using proper Gerber extensions
-    long ltmp;
-    m_Config->Read( OPTKEY_GERBER_EXTENSIONS, &ltmp );
-    m_useGerberExtensions->SetValue( ltmp );
+    m_useGerberExtensions->SetValue( g_PcbPlotOptions.GetUseGerberExtensions() );
 
     // Option for excluding contents of "Edges Pcb" layer
     m_excludeEdgeLayerOpt->SetValue( g_PcbPlotOptions.m_ExcludeEdgeLayer );
@@ -271,7 +411,7 @@
     m_drillShapeOpt->SetSelection( g_PcbPlotOptions.m_DrillShapeOpt );
 
     // Scale option
-    m_scaleOpt->SetSelection( m_dlgPlotScaleOpt );
+    m_scaleOpt->SetSelection( g_PcbPlotOptions.GetScaleSelection() );
 
     // Plot mode
     m_plotModeOpt->SetSelection( g_PcbPlotOptions.m_PlotMode );
@@ -451,15 +591,18 @@
 
     g_PcbPlotOptions.m_PlotPadsOnSilkLayer = m_plotPads_on_Silkscreen->GetValue();
 
-    s_PlotOriginIsAuxAxis =
-        (m_choicePlotOffset->GetSelection() == 0) ? FALSE : TRUE;
+    if( m_choicePlotOffset->GetSelection() == 0 )
+        g_PcbPlotOptions.SetAuxOrigin( false );
+    else
+        g_PcbPlotOptions.SetAuxOrigin( true );
 
     g_PcbPlotOptions.m_PlotValue     = m_plotModuleValueOpt->GetValue();
     g_PcbPlotOptions.m_PlotReference = m_plotModuleRefOpt->GetValue();
     g_PcbPlotOptions.m_PlotTextOther = m_plotTextOther->GetValue();
     g_PcbPlotOptions.m_PlotInvisibleTexts = m_plotInvisibleText->GetValue();
 
-    m_dlgPlotScaleOpt  = m_scaleOpt->GetSelection();
+    g_PcbPlotOptions.SetScaleSelection( m_scaleOpt->GetSelection() );
+
     g_PcbPlotOptions.m_DrillShapeOpt =
         (PCB_PLOT_PARAMS::DrillShapeOptT) m_drillShapeOpt->GetSelection();
     g_PcbPlotOptions.m_PlotMirror = m_plotMirrorOpt->GetValue();
@@ -471,7 +614,7 @@
     g_PcbPlotOptions.m_HPGLPenDiam = tmp;
 
     msg = m_HPGLPenSpeedOpt->GetValue();
-    tmp = ReturnValueFromString( MILLIMETRES, msg, 1 );
+    tmp = ReturnValueFromString( UNSCALED_UNITS, msg, 1 );
     g_PcbPlotOptions.m_HPGLPenSpeed = tmp;
 
     msg = m_HPGLPenOverlayOpt->GetValue();
@@ -488,25 +631,29 @@
     msg = m_fineAdjustYscaleOpt->GetValue();
     msg.ToDouble( &m_YScaleAdjust );
 
-    m_Config->Write( OPTKEY_GERBER_EXTENSIONS,
-                    m_useGerberExtensions->GetValue() );
-    m_Config->Write( OPTKEY_XFINESCALE_ADJ, m_XScaleAdjust );
-    m_Config->Write( OPTKEY_YFINESCALE_ADJ, m_YScaleAdjust );
+    g_PcbPlotOptions.SetUseGerberExtensions( m_useGerberExtensions->GetValue() );
+    g_PcbPlotOptions.m_FineScaleAdjustX = m_XScaleAdjust;
+    g_PcbPlotOptions.m_FineScaleAdjustY = m_YScaleAdjust;
 
     g_PcbPlotOptions.m_PlotFormat = m_plotFormatOpt->GetSelection();
 
-    wxString layerKey;
-    for( int layer = 0; layer<NB_LAYERS; ++layer )
+    long selectedLayers = 0;
+    long mask = 1;
+    int layer;
+    for( layer = 0; layer < NB_LAYERS; layer++, mask <<= 1 )
     {
         if( m_BoxSelectLayer[layer] == NULL )
             continue;
-        layerKey.Printf( OPTKEY_LAYERBASE, layer );
-        m_Config->Write( layerKey, m_BoxSelectLayer[layer]->IsChecked() );
+        if( m_BoxSelectLayer[layer]->GetValue() )
+            selectedLayers |= mask;
     }
+    g_PcbPlotOptions.SetLayerSelection( selectedLayers );
 
     g_PcbPlotOptions.m_PlotPSNegative = m_plotPSNegativeOpt->GetValue();
 
     g_PcbPlotOptions.SetOutputDirectory( m_outputDirectoryName->GetValue() );
+
+    g_PcbPlotOptions.SaveSettings( m_Config );
 }
 
 
@@ -538,7 +685,7 @@
 
     g_PcbPlotOptions.m_AutoScale = false;
     g_PcbPlotOptions.m_PlotScale = 1;
-    switch( m_dlgPlotScaleOpt )
+    switch( g_PcbPlotOptions.GetScaleSelection() )
     {
     default:
         break;
@@ -601,8 +748,7 @@
         DisplayInfoMessage( this,
                            _( "Warning: Scale option set to a very large value" ) );
 
-    int mask = 1;
-    s_SelectedLayers = 0;
+    long mask = 1;
     for( layer = 0; layer < NB_LAYERS; layer++, mask <<= 1 )
     {
         if( m_BoxSelectLayer[layer] == NULL )
@@ -610,8 +756,6 @@
         bool success = false;
         if( m_BoxSelectLayer[layer]->GetValue() )
         {
-            s_SelectedLayers |= mask;
-
             fn = m_Parent->GetScreen()->m_FileName;
             fn.SetPath( m_outputDirectoryName->GetValue() );
 
@@ -711,7 +855,7 @@
 
             case PLOT_FORMAT_GERBER:
                 success = m_Parent->Genere_GERBER( fn.GetFullPath(), layer,
-                                                   s_PlotOriginIsAuxAxis,
+                                                   g_PcbPlotOptions.GetAuxOrigin(),
                                                    g_PcbPlotOptions.m_PlotMode );
                 break;
 
@@ -740,7 +884,7 @@
     // If no layer selected, we have nothing plotted.
     // Prompt user if it happens
     // because he could think there is a bug in pcbnew:
-    if( s_SelectedLayers == 0 )
+    if( !g_PcbPlotOptions.GetLayerSelection() == 0 )
         DisplayError( this, _( "No layer selected" ) );
 }
 

=== modified file 'pcbnew/pcbplot.h'
--- pcbnew/pcbplot.h	2010-12-12 11:41:18 +0000
+++ pcbnew/pcbplot.h	2010-12-30 12:43:17 +0000
@@ -51,8 +51,7 @@
     bool        m_PlotTextOther;
     bool        m_PlotInvisibleTexts;
     bool        m_PlotPadsOnSilkLayer; ///< allows pads outlines on silkscreen layer (when pads are also o, silk screen
-    bool        m_SubtractMaskFromSilk;
-
+public:
     /// id for plot format (see enum PlotFormat in plot_common.h) */
     int         m_PlotFormat;           // Gerber, HPGL ...
     bool        m_PlotMirror;
@@ -74,14 +73,47 @@
     double      m_FineScaleAdjustY;     // dine scale adjust Y axis
 
 private:
-    wxString outputDirectory;
+    bool        useGerberExtensions;
+    bool        subtractMaskFromSilk;
+    bool        auxOrigin;
+    long        layerSelection;
+    int         scaleSelection;
+    wxString    outputDirectory;
+    wxConfig*   config;
+
+    void        readConfigLong( wxString aKey, long* aLong );
+    void        readConfigInt( wxString aKey, int* aInt,
+                               int aMin, int aMax );
+    void        readConfigDouble( wxString aKey, double* aDouble,
+                                  double aMin, double aMax );
+    void        readConfigBool( wxString aKey, bool* aBool );
 
 public:
     PCB_PLOT_PARAMS();
+    /**
+       Function LoadSettings
+       loads plot settings from wxConfig system.
+       @param aConfig is a pointer to a wxConfig.
+     */
+    void        LoadSettings( wxConfig* aConfig );
+    /**
+       Function SaveSettings
+       saves current plot settings to wxConfig system.
+       @param aConfig is a pointer to a wxConfig.
+     */
+    void        SaveSettings( wxConfig* aConfig );
     void        SetOutputDirectory( wxString aDir ) { outputDirectory = aDir; };
     wxString    GetOutputDirectory() { return outputDirectory; };
-    void        SetSubtractMaskFromSilk( bool aSubtract ) { m_SubtractMaskFromSilk = aSubtract; };
-    bool        GetSubtractMaskFromSilk() { return m_SubtractMaskFromSilk; };
+    void        SetUseGerberExtensions( bool aUse ) { useGerberExtensions = aUse; };
+    bool        GetUseGerberExtensions() { return useGerberExtensions; };
+    void        SetSubtractMaskFromSilk( bool aSubtract ) { subtractMaskFromSilk = aSubtract; };
+    bool        GetSubtractMaskFromSilk() { return subtractMaskFromSilk; };
+    void        SetLayerSelection( long aSelection ) { layerSelection = aSelection; };
+    long        GetLayerSelection() { return layerSelection; };
+    void        SetAuxOrigin( bool aAux ) { auxOrigin = aAux; };
+    bool        GetAuxOrigin() { return auxOrigin; };
+    void        SetScaleSelection( int aSelection ) { scaleSelection = aSelection; };
+    int         GetScaleSelection() { return scaleSelection; };
 };
 
 extern PCB_PLOT_PARAMS g_PcbPlotOptions;


Follow ups