← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Copper layers selected by default in plot dialog

 

Updated patch.

The stupid thing I missed shouldn't happen any more. When you plot it will
only plot the layers you have selected rather than all of the copper layers.

Jon

On Fri, Dec 4, 2015 at 4:06 PM, Jon Neal <reportingsjr@xxxxxxxxx> wrote:

> I think I understand the issue. I will provide an updated patch shortly.
>
> Jon
>
> On Fri, Dec 4, 2015 at 3:39 PM, Jon Neal <reportingsjr@xxxxxxxxx> wrote:
>
>> jp,
>>
>> Can you provide some more details? I tested it on my two computers, but
>> that is as much as I could test.
>>
>> Thanks,
>> Jon
>>
>> On Fri, Dec 4, 2015 at 1:53 PM, jp charras <jp.charras@xxxxxxxxxx> wrote:
>>
>>> Le 04/12/2015 19:48, jp charras a écrit :
>>> > Le 03/12/2015 20:11, Jon Neal a écrit :
>>> >> This fixes a small "issue" that was annoying me.
>>> >>
>>> >> With this patch when you add new layers in pcbnew they will be
>>> selected
>>> >> by default for plotting.
>>> >>
>>> >> It does this in two places:
>>> >> First - it sets the default for a new board to plot select all copper
>>> >> layers. This is needed so the first time the plot dialog is opened all
>>> >> enabled copper layers will be selected.
>>> >> Second - when the plot dialog is closed all disabled copper layers are
>>> >> set to "selected". The reason for this is when the dialog is closed it
>>> >> was setting all disabled copper layers to unselected. If you added new
>>> >> layers to a board it was defaulting to unselected. This is done here
>>> >> because it would have been difficult to access the plot dialog
>>> settings
>>> >> from the layer preferences manager.
>>> >>
>>> >> Jon
>>> >>
>>> >
>>> > Committed. Thanks.
>>> >
>>> >
>>>
>>> Uncommitted: It does not work very well.
>>> Sorry.
>>>
>>>
>>> --
>>> Jean-Pierre CHARRAS
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~kicad-developers
>>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>>> Unsubscribe : https://launchpad.net/~kicad-developers
>>> More help   : https://help.launchpad.net/ListHelp
>>>
>>
>>
>
From a0f1df4a6caa83318a05950979e8c4b5f0104c21 Mon Sep 17 00:00:00 2001
From: Jon Neal <reportingsjr@xxxxxxxxx>
Date: Wed, 11 Nov 2015 21:37:28 -0500
Subject: [PATCH] The plot dialog now selects all copper layers for plotting as
 the default.

---
 pcbnew/dialogs/dialog_plot.cpp | 19 ++++++++++++++++---
 pcbnew/pcb_plot_params.cpp     |  6 +++---
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp
index 5806438..f3d13a4 100644
--- a/pcbnew/dialogs/dialog_plot.cpp
+++ b/pcbnew/dialogs/dialog_plot.cpp
@@ -677,14 +677,18 @@ void DIALOG_PLOT::applyPlotSettings()
     tempOptions.SetGerberPrecision( m_rbGerberFormat->GetSelection() == 0 ? 5 : 6 );
 
     LSET selectedLayers;
-
     for( unsigned i = 0; i < m_layerList.size(); i++ )
     {
         if( m_layerCheckListBox->IsChecked( i ) )
             selectedLayers.set( m_layerList[i] );
     }
-
+    // Get a list of copper layers that aren't being used by inverting enabled layers.
+    LSET disabledCopperLayers = LSET::AllCuMask() & ~m_board->GetEnabledLayers();
+    // Enable all of the disabled copper layers.
+    // If someone enables more copper layers they will be selected by default.
+    selectedLayers = selectedLayers | disabledCopperLayers;
     tempOptions.SetLayerSelection( selectedLayers );
+    
     tempOptions.SetNegative( m_plotPSNegativeOpt->GetValue() );
     tempOptions.SetA4Output( m_forcePSA4OutputOpt->GetValue() );
 
@@ -782,7 +786,16 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
     for( LSEQ seq = m_plotOpts.GetLayerSelection().UIOrder();  seq;  ++seq )
     {
         LAYER_ID layer = *seq;
-
+        
+        // All copper layers that are disabled are actually selected
+        // This is due to wonkyness in automatically selecting copper layers
+        // for plotting when adding more than two layers to a board.
+        // If plot options become accessible to the layers setup dialog
+        // please move this functionality there!
+        // This skips a copper layer if it is actually disabled on the board.
+        if( ( LSET::AllCuMask() & ~m_board->GetEnabledLayers() )[layer] )
+            continue;
+        
         // Pick the basename from the board file
         wxFileName fn( boardFilename );
 
diff --git a/pcbnew/pcb_plot_params.cpp b/pcbnew/pcb_plot_params.cpp
index 9f40fbc..85aeb04 100644
--- a/pcbnew/pcb_plot_params.cpp
+++ b/pcbnew/pcb_plot_params.cpp
@@ -79,8 +79,7 @@ static bool setInt( int* aInt, int aValue, int aMin, int aMax )
 
 // PCB_PLOT_PARAMS
 
-PCB_PLOT_PARAMS::PCB_PLOT_PARAMS() :
-    m_layerSelection( 4, B_Cu, F_Cu, F_SilkS, B_SilkS )
+PCB_PLOT_PARAMS::PCB_PLOT_PARAMS()
 {
     m_useGerberProtelExtensions  = false;
     m_useGerberAttributes        = false;
@@ -116,6 +115,7 @@ PCB_PLOT_PARAMS::PCB_PLOT_PARAMS() :
     m_referenceColor             = BLACK;
     m_valueColor                 = BLACK;
     m_textMode                   = PLOTTEXTMODE_DEFAULT;
+    m_layerSelection = LSET( 2, F_SilkS, B_SilkS) | LSET::AllCuMask();
 
     // This parameter controls if the NPTH pads will be plotted or not
     // it is a "local" parameter
@@ -377,7 +377,7 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams )
                     */
 
                     // sorry, use the UI once to fix:
-                    aPcbPlotParams->m_layerSelection = LSET( 4, B_Cu, F_Cu, F_SilkS, B_SilkS );
+                    aPcbPlotParams->m_layerSelection = LSET( 2, F_SilkS, B_SilkS) | LSET::AllCuMask();
                 }
                 else if( cur.find_first_of( "0x" ) == 0 )   // pretty ver. 4.
                 {
-- 
2.5.0


Follow ups

References