Add board layer view stack up sequence from front layer to back layer.

The old bottom to top layer stack up sequence from back to front layer was
only used for plotting so it was renamed appropriately.  This will be used
for future board object select disambiguation improvements.
This commit is contained in:
Wayne Stambaugh 2023-12-11 15:07:58 -05:00
parent 1adf96d879
commit 5fa274ead0
8 changed files with 104 additions and 13 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2014-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2014-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -479,7 +479,88 @@ LSEQ LSET::Seq() const
} }
LSEQ LSET::SeqStackupBottom2Top() const LSEQ LSET::SeqStackupTop2Bottom( PCB_LAYER_ID aSelectedLayer ) const
{
static const PCB_LAYER_ID sequence[] = {
Edge_Cuts,
Margin,
Dwgs_User,
Cmts_User,
Eco1_User,
Eco2_User,
User_1,
User_2,
User_3,
User_4,
User_5,
User_6,
User_7,
User_8,
User_9,
F_Fab,
F_SilkS,
F_Paste,
F_Adhes,
F_Mask,
F_CrtYd,
F_Cu,
In1_Cu,
In2_Cu,
In3_Cu,
In4_Cu,
In5_Cu,
In6_Cu,
In7_Cu,
In8_Cu,
In9_Cu,
In10_Cu,
In11_Cu,
In12_Cu,
In13_Cu,
In14_Cu,
In15_Cu,
In16_Cu,
In17_Cu,
In18_Cu,
In19_Cu,
In20_Cu,
In21_Cu,
In22_Cu,
In23_Cu,
In24_Cu,
In25_Cu,
In26_Cu,
In27_Cu,
In28_Cu,
In29_Cu,
In30_Cu,
B_Cu,
B_CrtYd,
B_Mask,
B_Adhes,
B_Paste,
B_SilkS,
B_Fab,
};
LSEQ seq = Seq( sequence, arrayDim( sequence ) );
if( aSelectedLayer != UNDEFINED_LAYER )
{
auto it = std::find( seq.begin(), seq.end(), aSelectedLayer );
if( it != seq.end() )
{
seq.erase( it );
seq.insert( seq.begin(), aSelectedLayer );
}
}
return seq;
}
LSEQ LSET::SeqStackupForPlotting() const
{ {
// bottom-to-top stack-up layers // bottom-to-top stack-up layers
// Note that the bottom technical layers are flipped so that when plotting a bottom-side view, // Note that the bottom technical layers are flipped so that when plotting a bottom-side view,

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2010 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2010 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2007-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2007-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -780,11 +780,20 @@ public:
*/ */
LSEQ Seq() const; LSEQ Seq() const;
/**
* Generate a sequence of layers that represent a top to bottom stack of this set of layers.
*
* @param aSelectedLayer is the layer to put at the top of stack when defined.
*
* @return the top to bottom layer sequence.
*/
LSEQ SeqStackupTop2Bottom( PCB_LAYER_ID aSelectedLayer = UNDEFINED_LAYER ) const;
/** /**
* Return the sequence that is typical for a bottom-to-top stack-up. * Return the sequence that is typical for a bottom-to-top stack-up.
* For instance, to plot multiple layers in a single image, the top layers output last. * For instance, to plot multiple layers in a single image, the top layers output last.
*/ */
LSEQ SeqStackupBottom2Top() const; LSEQ SeqStackupForPlotting() const;
/** /**
* Return a hex string showing contents of this LSEQ. * Return a hex string showing contents of this LSEQ.

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> * Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
@ -80,7 +80,7 @@ int CLI::FP_EXPORT_SVG_COMMAND::doPerform( KIWAY& aKiway )
if( !m_selectedLayers.empty() ) if( !m_selectedLayers.empty() )
svgJob->m_printMaskLayer = m_selectedLayers; svgJob->m_printMaskLayer = m_selectedLayers;
else else
svgJob->m_printMaskLayer = LSET::AllLayersMask().SeqStackupBottom2Top(); svgJob->m_printMaskLayer = LSET::AllLayersMask().SeqStackupForPlotting();
int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, svgJob.get() ); int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, svgJob.get() );

View File

@ -342,7 +342,7 @@ void DIALOG_EXPORT_SVG::ExportSVGFile( bool aOnlyOneFile )
BuildPlotFileName( &fn, outputDir.GetPath(), suffix, SVGFileExtension ); BuildPlotFileName( &fn, outputDir.GetPath(), suffix, SVGFileExtension );
wxString svgPath = fn.GetFullPath(); wxString svgPath = fn.GetFullPath();
m_printMaskLayer = aOnlyOneFile ? all_selected.SeqStackupBottom2Top() : LSEQ( { layer } ); m_printMaskLayer = aOnlyOneFile ? all_selected.SeqStackupForPlotting() : LSEQ( { layer } );
if( m_checkboxEdgesOnAllPages->GetValue() ) if( m_checkboxEdgesOnAllPages->GetValue() )
m_printMaskLayer.push_back( Edge_Cuts ); m_printMaskLayer.push_back( Edge_Cuts );

View File

@ -104,7 +104,7 @@ DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) :
std::vector<PCB_LAYER_ID> layersIdChoiceList; std::vector<PCB_LAYER_ID> layersIdChoiceList;
int textWidth = 0; int textWidth = 0;
for( LSEQ seq = board->GetEnabledLayers().SeqStackupBottom2Top(); seq; ++seq ) for( LSEQ seq = board->GetEnabledLayers().SeqStackupForPlotting(); seq; ++seq )
{ {
PCB_LAYER_ID id = *seq; PCB_LAYER_ID id = *seq;
wxString layerName = board->GetLayerName( id ); wxString layerName = board->GetLayerName( id );
@ -568,7 +568,7 @@ void DIALOG_PLOT::OnRightClickAllLayers( wxMouseEvent& event )
case ID_STACKUP_ORDER: case ID_STACKUP_ORDER:
{ {
LSEQ stackup = m_parent->GetBoard()->GetEnabledLayers().SeqStackupBottom2Top(); LSEQ stackup = m_parent->GetBoard()->GetEnabledLayers().SeqStackupForPlotting();
arrangeAllLayersList( stackup ); arrangeAllLayersList( stackup );
m_plotAllLayersList->Select( -1 ); m_plotAllLayersList->Select( -1 );
break; break;

View File

@ -366,14 +366,14 @@ int PCBNEW_JOBS_HANDLER::JobExportGerbers( JOB* aJob )
if( aGerberJob->m_useBoardPlotParams ) if( aGerberJob->m_useBoardPlotParams )
{ {
aGerberJob->m_printMaskLayer = boardPlotOptions.GetLayerSelection().SeqStackupBottom2Top(); aGerberJob->m_printMaskLayer = boardPlotOptions.GetLayerSelection().SeqStackupForPlotting();
aGerberJob->m_layersIncludeOnAll = boardPlotOptions.GetPlotOnAllLayersSelection(); aGerberJob->m_layersIncludeOnAll = boardPlotOptions.GetPlotOnAllLayersSelection();
} }
else else
{ {
// default to the board enabled layers // default to the board enabled layers
if( aGerberJob->m_printMaskLayer == 0 ) if( aGerberJob->m_printMaskLayer == 0 )
aGerberJob->m_printMaskLayer = brd->GetEnabledLayers().SeqStackupBottom2Top(); aGerberJob->m_printMaskLayer = brd->GetEnabledLayers().SeqStackupForPlotting();
if( aGerberJob->m_layersIncludeOnAllSet ) if( aGerberJob->m_layersIncludeOnAllSet )
aGerberJob->m_layersIncludeOnAll = plotOnAllLayersSelection; aGerberJob->m_layersIncludeOnAll = plotOnAllLayersSelection;
@ -1079,4 +1079,4 @@ void PCBNEW_JOBS_HANDLER::loadOverrideDrawingSheet( BOARD* aBrd, const wxString&
// failed loading custom path, revert back to default // failed loading custom path, revert back to default
loadSheet( aBrd->GetProject()->GetProjectFile().m_BoardDrawingSheetFile ); loadSheet( aBrd->GetProject()->GetProjectFile().m_BoardDrawingSheetFile );
} }

View File

@ -722,7 +722,7 @@ void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
SHAPE_POLY_SET outlines; SHAPE_POLY_SET outlines;
for( LSEQ seq = aLayerMask.Seq( aLayerMask.SeqStackupBottom2Top() ); seq; ++seq ) for( LSEQ seq = aLayerMask.Seq( aLayerMask.SeqStackupForPlotting() ); seq; ++seq )
{ {
PCB_LAYER_ID layer = *seq; PCB_LAYER_ID layer = *seq;

View File

@ -36,6 +36,7 @@ set( QA_COMMON_SRCS
test_coroutine.cpp test_coroutine.cpp
test_eda_shape.cpp test_eda_shape.cpp
test_eda_text.cpp test_eda_text.cpp
test_layers.cpp
test_lib_table.cpp test_lib_table.cpp
test_markup_parser.cpp test_markup_parser.cpp
test_kicad_string.cpp test_kicad_string.cpp