Browse Source

Split out LSEQ/LSET from LAYER_ID

Separate the layer grouping classes for easier modification
jobs
Seth Hillbrand 1 year ago
parent
commit
cc850d0da0
  1. 1
      3d-viewer/3d_canvas/board_adapter.cpp
  2. 1
      3d-viewer/3d_canvas/create_layer_items.cpp
  3. 1
      3d-viewer/3d_rendering/opengl/create_scene.cpp
  4. 1
      3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp
  5. 1
      3d-viewer/dialogs/panel_preview_3d_model.cpp
  6. 1
      common/CMakeLists.txt
  7. 1
      common/board_printout.cpp
  8. 1
      common/jobs/job_export_pcb_dxf.h
  9. 1
      common/jobs/job_export_pcb_gerber.h
  10. 1
      common/jobs/job_export_pcb_gerbers.h
  11. 1
      common/jobs/job_export_pcb_pdf.h
  12. 1
      common/jobs/job_export_pcb_svg.h
  13. 1
      common/jobs/job_fp_export_svg.h
  14. 166
      common/layer_id.cpp
  15. 23
      common/lseq.cpp
  16. 141
      common/lset.cpp
  17. 2
      common/project/board_project_settings.cpp
  18. 1
      common/project/project_local_settings.cpp
  19. 1
      gerbview/files.cpp
  20. 1
      gerbview/gerbview_frame.cpp
  21. 1
      gerbview/gerbview_frame.h
  22. 3
      gerbview/gerbview_printout.cpp
  23. 1
      gerbview/gerbview_printout.h
  24. 1
      gerbview/widgets/gerbview_layer_widget.cpp
  25. 1
      include/board_design_settings.h
  26. 2
      include/board_item.h
  27. 1
      include/board_printout.h
  28. 370
      include/layer_ids.h
  29. 86
      include/lseq.h
  30. 332
      include/lset.h
  31. 1
      include/pcb_base_frame.h
  32. 1
      include/project/board_project_settings.h
  33. 1
      include/render_settings.h
  34. 2
      kicad/cli/command_pcb_export_base.cpp
  35. 2
      kicad/cli/command_pcb_export_base.h
  36. 1
      pcbnew/api/api_pcb_utils.cpp
  37. 1
      pcbnew/api/api_pcb_utils.h
  38. 1
      pcbnew/autorouter/ar_autoplacer.cpp
  39. 1
      pcbnew/autorouter/ar_autoplacer.h
  40. 1
      pcbnew/autorouter/ar_matrix.cpp
  41. 1
      pcbnew/autorouter/ar_matrix.h
  42. 1
      pcbnew/board.cpp
  43. 1
      pcbnew/board.h
  44. 1
      pcbnew/board_commit.cpp
  45. 1
      pcbnew/board_connected_item.cpp
  46. 1
      pcbnew/board_design_settings.cpp
  47. 1
      pcbnew/board_item.cpp
  48. 1
      pcbnew/board_stackup_manager/board_stackup.h
  49. 1
      pcbnew/collectors.h
  50. 1
      pcbnew/dialogs/dialog_map_layers.cpp
  51. 2
      pcbnew/drc/drc_engine.h
  52. 1
      pcbnew/drc/drc_rule.h
  53. 1
      pcbnew/exporters/step/exporter_step.h
  54. 1
      pcbnew/footprint.cpp
  55. 1
      pcbnew/footprint.h
  56. 1
      pcbnew/footprint_chooser_frame.cpp
  57. 1
      pcbnew/footprint_editor_settings.cpp
  58. 1
      pcbnew/grid_layer_box_helpers.cpp
  59. 1
      pcbnew/grid_layer_box_helpers.h
  60. 1
      pcbnew/initpcb.cpp
  61. 4
      pcbnew/pad.cpp
  62. 1
      pcbnew/pad.h
  63. 1
      pcbnew/padstack.h
  64. 1
      pcbnew/pcb_base_frame.cpp
  65. 1
      pcbnew/pcb_edit_frame.cpp
  66. 1
      pcbnew/pcb_generator.h
  67. 1
      pcbnew/pcb_group.h
  68. 2
      pcbnew/pcb_io/altium/altium_pcb.cpp
  69. 1
      pcbnew/pcb_io/common/plugin_common_layer_mapping.h
  70. 1
      pcbnew/pcb_io/eagle/pcb_io_eagle.h
  71. 2
      pcbnew/pcb_io/easyeda/pcb_io_easyeda_parser.cpp
  72. 2
      pcbnew/pcb_io/easyedapro/pcb_io_easyedapro_parser.cpp
  73. 2
      pcbnew/pcb_io/fabmaster/import_fabmaster.cpp
  74. 1
      pcbnew/pcb_io/kicad_legacy/pcb_io_kicad_legacy.h
  75. 1
      pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h
  76. 1
      pcbnew/pcb_layer_box_selector.h
  77. 1
      pcbnew/pcb_painter.cpp
  78. 1
      pcbnew/pcb_plot_params.cpp
  79. 1
      pcbnew/pcb_shape.cpp
  80. 1
      pcbnew/pcb_track.cpp
  81. 1
      pcbnew/pcb_track.h
  82. 1
      pcbnew/pcbexpr_evaluator.cpp
  83. 1
      pcbnew/pcbexpr_functions.cpp
  84. 1
      pcbnew/pcbnew_jobs_handler.cpp
  85. 1
      pcbnew/pcbnew_printout.cpp
  86. 1
      pcbnew/pcbnew_printout.h
  87. 3
      pcbnew/pcbnew_settings.cpp
  88. 1
      pcbnew/pcbplot.cpp
  89. 1
      pcbnew/pcbplot.h
  90. 1
      pcbnew/plot_board_layers.cpp
  91. 1
      pcbnew/plot_brditems_plotter.cpp
  92. 1
      pcbnew/plotcontroller.h
  93. 1
      pcbnew/sel_layer.cpp
  94. 1
      pcbnew/toolbars_footprint_editor.cpp
  95. 2
      pcbnew/tools/pcb_grid_helper.h
  96. 1
      pcbnew/tracks_cleaner.cpp
  97. 1
      pcbnew/undo_redo.cpp
  98. 3
      pcbnew/zone.cpp
  99. 1
      pcbnew/zone.h
  100. 1
      pcbnew/zone_settings.cpp

1
3d-viewer/3d_canvas/board_adapter.cpp

@ -34,6 +34,7 @@
#include <3d_math.h>
#include "3d_fastmath.h"
#include <geometry/geometry_utils.h>
#include <lset.h>
#include <pgm_base.h>
#include <settings/settings_manager.h>
#include <wx/log.h>

1
3d-viewer/3d_canvas/create_layer_items.cpp

@ -38,6 +38,7 @@
#include <board_design_settings.h>
#include <board.h>
#include <footprint.h>
#include <lset.h>
#include <pad.h>
#include <pcb_text.h>
#include <pcb_textbox.h>

1
3d-viewer/3d_rendering/opengl/create_scene.cpp

@ -28,6 +28,7 @@
#include <footprint.h>
#include "../../3d_math.h"
#include "convert_basic_shapes_to_polygon.h"
#include <lset.h>
#include <trigo.h>
#include <project.h>
#include <core/profile.h> // To use GetRunningMicroSecs or another profiling utility

1
3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp

@ -34,6 +34,7 @@
#include <footprint.h>
#include <3d_math.h>
#include <glm/geometric.hpp>
#include <lset.h>
#include <math/util.h> // for KiROUND
#include <utility>
#include <vector>

1
3d-viewer/dialogs/panel_preview_3d_model.cpp

@ -36,6 +36,7 @@
#include <board.h>
#include <common_ogl/ogl_attr_list.h>
#include <dpi_scaling_common.h>
#include <lset.h>
#include <pgm_base.h>
#include <project_pcb.h>
#include <settings/common_settings.h>

1
common/CMakeLists.txt

@ -143,6 +143,7 @@ set( KICOMMON_SRCS
layer_id.cpp
lib_id.cpp
locale_io.cpp
lseq.cpp
lset.cpp
markup_parser.cpp
netclass.cpp

1
common/board_printout.cpp

@ -26,6 +26,7 @@
#include <board_printout.h>
#include <lset.h>
#include <view/view.h>
#include <gal/gal_print.h>
#include <gal/graphics_abstraction_layer.h>

1
common/jobs/job_export_pcb_dxf.h

@ -23,6 +23,7 @@
#include <kicommon.h>
#include <layer_ids.h>
#include <lseq.h>
#include <wx/string.h>
#include "job.h"

1
common/jobs/job_export_pcb_gerber.h

@ -23,6 +23,7 @@
#include <kicommon.h>
#include <layer_ids.h>
#include <lseq.h>
#include <wx/string.h>
#include "job.h"

1
common/jobs/job_export_pcb_gerbers.h

@ -24,6 +24,7 @@
#include <kicommon.h>
#include "job_export_pcb_gerber.h"
#include <layer_ids.h>
#include <lset.h>
#include <wx/string.h>
#include "job.h"

1
common/jobs/job_export_pcb_pdf.h

@ -24,6 +24,7 @@
#include <kicommon.h>
#include <kicommon.h>
#include <layer_ids.h>
#include <lseq.h>
#include <wx/string.h>
#include "job.h"

1
common/jobs/job_export_pcb_svg.h

@ -23,6 +23,7 @@
#include <kicommon.h>
#include <layer_ids.h>
#include <lseq.h>
#include <wx/string.h>
#include "job.h"

1
common/jobs/job_fp_export_svg.h

@ -23,6 +23,7 @@
#include <kicommon.h>
#include <layer_ids.h>
#include <lseq.h>
#include <wx/string.h>
#include "job.h"

166
common/layer_id.cpp

@ -35,76 +35,76 @@ wxString LayerName( int aLayer )
case UNDEFINED_LAYER: return _( "undefined" );
// Copper
case F_Cu: return wxT( "F.Cu" );
case In1_Cu: return wxT( "In1.Cu" );
case In2_Cu: return wxT( "In2.Cu" );
case In3_Cu: return wxT( "In3.Cu" );
case In4_Cu: return wxT( "In4.Cu" );
case In5_Cu: return wxT( "In5.Cu" );
case In6_Cu: return wxT( "In6.Cu" );
case In7_Cu: return wxT( "In7.Cu" );
case In8_Cu: return wxT( "In8.Cu" );
case In9_Cu: return wxT( "In9.Cu" );
case In10_Cu: return wxT( "In10.Cu" );
case In11_Cu: return wxT( "In11.Cu" );
case In12_Cu: return wxT( "In12.Cu" );
case In13_Cu: return wxT( "In13.Cu" );
case In14_Cu: return wxT( "In14.Cu" );
case In15_Cu: return wxT( "In15.Cu" );
case In16_Cu: return wxT( "In16.Cu" );
case In17_Cu: return wxT( "In17.Cu" );
case In18_Cu: return wxT( "In18.Cu" );
case In19_Cu: return wxT( "In19.Cu" );
case In20_Cu: return wxT( "In20.Cu" );
case In21_Cu: return wxT( "In21.Cu" );
case In22_Cu: return wxT( "In22.Cu" );
case In23_Cu: return wxT( "In23.Cu" );
case In24_Cu: return wxT( "In24.Cu" );
case In25_Cu: return wxT( "In25.Cu" );
case In26_Cu: return wxT( "In26.Cu" );
case In27_Cu: return wxT( "In27.Cu" );
case In28_Cu: return wxT( "In28.Cu" );
case In29_Cu: return wxT( "In29.Cu" );
case In30_Cu: return wxT( "In30.Cu" );
case B_Cu: return wxT( "B.Cu" );
case PCB_LAYER_ID::F_Cu: return wxT( "F.Cu" );
case PCB_LAYER_ID::In1_Cu: return wxT( "In1.Cu" );
case PCB_LAYER_ID::In2_Cu: return wxT( "In2.Cu" );
case PCB_LAYER_ID::In3_Cu: return wxT( "In3.Cu" );
case PCB_LAYER_ID::In4_Cu: return wxT( "In4.Cu" );
case PCB_LAYER_ID::In5_Cu: return wxT( "In5.Cu" );
case PCB_LAYER_ID::In6_Cu: return wxT( "In6.Cu" );
case PCB_LAYER_ID::In7_Cu: return wxT( "In7.Cu" );
case PCB_LAYER_ID::In8_Cu: return wxT( "In8.Cu" );
case PCB_LAYER_ID::In9_Cu: return wxT( "In9.Cu" );
case PCB_LAYER_ID::In10_Cu: return wxT( "In10.Cu" );
case PCB_LAYER_ID::In11_Cu: return wxT( "In11.Cu" );
case PCB_LAYER_ID::In12_Cu: return wxT( "In12.Cu" );
case PCB_LAYER_ID::In13_Cu: return wxT( "In13.Cu" );
case PCB_LAYER_ID::In14_Cu: return wxT( "In14.Cu" );
case PCB_LAYER_ID::In15_Cu: return wxT( "In15.Cu" );
case PCB_LAYER_ID::In16_Cu: return wxT( "In16.Cu" );
case PCB_LAYER_ID::In17_Cu: return wxT( "In17.Cu" );
case PCB_LAYER_ID::In18_Cu: return wxT( "In18.Cu" );
case PCB_LAYER_ID::In19_Cu: return wxT( "In19.Cu" );
case PCB_LAYER_ID::In20_Cu: return wxT( "In20.Cu" );
case PCB_LAYER_ID::In21_Cu: return wxT( "In21.Cu" );
case PCB_LAYER_ID::In22_Cu: return wxT( "In22.Cu" );
case PCB_LAYER_ID::In23_Cu: return wxT( "In23.Cu" );
case PCB_LAYER_ID::In24_Cu: return wxT( "In24.Cu" );
case PCB_LAYER_ID::In25_Cu: return wxT( "In25.Cu" );
case PCB_LAYER_ID::In26_Cu: return wxT( "In26.Cu" );
case PCB_LAYER_ID::In27_Cu: return wxT( "In27.Cu" );
case PCB_LAYER_ID::In28_Cu: return wxT( "In28.Cu" );
case PCB_LAYER_ID::In29_Cu: return wxT( "In29.Cu" );
case PCB_LAYER_ID::In30_Cu: return wxT( "In30.Cu" );
case PCB_LAYER_ID::B_Cu: return wxT( "B.Cu" );
// Technicals
case B_Adhes: return wxT( "B.Adhesive" );
case F_Adhes: return wxT( "F.Adhesive" );
case B_Paste: return wxT( "B.Paste" );
case F_Paste: return wxT( "F.Paste" );
case B_SilkS: return wxT( "B.Silkscreen" );
case F_SilkS: return wxT( "F.Silkscreen" );
case B_Mask: return wxT( "B.Mask" );
case F_Mask: return wxT( "F.Mask" );
case PCB_LAYER_ID::B_Adhes: return wxT( "B.Adhesive" );
case PCB_LAYER_ID::F_Adhes: return wxT( "F.Adhesive" );
case PCB_LAYER_ID::B_Paste: return wxT( "B.Paste" );
case PCB_LAYER_ID::F_Paste: return wxT( "F.Paste" );
case PCB_LAYER_ID::B_SilkS: return wxT( "B.Silkscreen" );
case PCB_LAYER_ID::F_SilkS: return wxT( "F.Silkscreen" );
case PCB_LAYER_ID::B_Mask: return wxT( "B.Mask" );
case PCB_LAYER_ID::F_Mask: return wxT( "F.Mask" );
// Users
case Dwgs_User: return wxT( "User.Drawings" );
case Cmts_User: return wxT( "User.Comments" );
case Eco1_User: return wxT( "User.Eco1" );
case Eco2_User: return wxT( "User.Eco2" );
case Edge_Cuts: return wxT( "Edge.Cuts" );
case Margin: return wxT( "Margin" );
case PCB_LAYER_ID::Dwgs_User: return wxT( "User.Drawings" );
case PCB_LAYER_ID::Cmts_User: return wxT( "User.Comments" );
case PCB_LAYER_ID::Eco1_User: return wxT( "User.Eco1" );
case PCB_LAYER_ID::Eco2_User: return wxT( "User.Eco2" );
case PCB_LAYER_ID::Edge_Cuts: return wxT( "Edge.Cuts" );
case PCB_LAYER_ID::Margin: return wxT( "PCB_LAYER_ID::Margin" );
// Footprint
case F_CrtYd: return wxT( "F.Courtyard" );
case B_CrtYd: return wxT( "B.Courtyard" );
case F_Fab: return wxT( "F.Fab" );
case B_Fab: return wxT( "B.Fab" );
case PCB_LAYER_ID::F_CrtYd: return wxT( "F.Courtyard" );
case PCB_LAYER_ID::B_CrtYd: return wxT( "B.Courtyard" );
case PCB_LAYER_ID::F_Fab: return wxT( "F.Fab" );
case PCB_LAYER_ID::B_Fab: return wxT( "B.Fab" );
// User definable layers.
case User_1: return wxT( "User.1" );
case User_2: return wxT( "User.2" );
case User_3: return wxT( "User.3" );
case User_4: return wxT( "User.4" );
case User_5: return wxT( "User.5" );
case User_6: return wxT( "User.6" );
case User_7: return wxT( "User.7" );
case User_8: return wxT( "User.8" );
case User_9: return wxT( "User.9" );
case PCB_LAYER_ID::User_1: return wxT( "User.1" );
case PCB_LAYER_ID::User_2: return wxT( "User.2" );
case PCB_LAYER_ID::User_3: return wxT( "User.3" );
case PCB_LAYER_ID::User_4: return wxT( "User.4" );
case PCB_LAYER_ID::User_5: return wxT( "User.5" );
case PCB_LAYER_ID::User_6: return wxT( "User.6" );
case PCB_LAYER_ID::User_7: return wxT( "User.7" );
case PCB_LAYER_ID::User_8: return wxT( "User.8" );
case PCB_LAYER_ID::User_9: return wxT( "User.9" );
// Rescue
case Rescue: return _( "Rescue" );
case PCB_LAYER_ID::Rescue: return _( "Rescue" );
// SCH_LAYER_ID
@ -197,3 +197,49 @@ wxString LayerName( int aLayer )
wxCHECK_MSG( false, wxEmptyString, wxString::Format( "Unknown layer ID %d", aLayer ) );
}
}
PCB_LAYER_ID FlipLayer( PCB_LAYER_ID aLayerId, int aCopperLayersCount )
{
switch( aLayerId )
{
case B_Cu: return F_Cu;
case F_Cu: return B_Cu;
case B_SilkS: return F_SilkS;
case F_SilkS: return B_SilkS;
case B_Adhes: return F_Adhes;
case F_Adhes: return B_Adhes;
case B_Mask: return F_Mask;
case F_Mask: return B_Mask;
case B_Paste: return F_Paste;
case F_Paste: return B_Paste;
case B_CrtYd: return F_CrtYd;
case F_CrtYd: return B_CrtYd;
case B_Fab: return F_Fab;
case F_Fab: return B_Fab;
default: // change internal layer if aCopperLayersCount is >= 4
if( IsCopperLayer( aLayerId ) && aCopperLayersCount >= 4 )
{
// internal copper layers count is aCopperLayersCount-2
PCB_LAYER_ID fliplayer = PCB_LAYER_ID(aCopperLayersCount - 2 - ( aLayerId - In1_Cu ) );
// Ensure fliplayer has a value which does not crash Pcbnew:
if( fliplayer < F_Cu )
fliplayer = F_Cu;
if( fliplayer > B_Cu )
fliplayer = B_Cu;
return fliplayer;
}
// No change for the other layers
return aLayerId;
}
}

23
common/lseq.cpp

@ -0,0 +1,23 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <layer_ids.h>
#include <lseq.h>
#include <vector>

141
common/lset.cpp

@ -30,11 +30,14 @@
#include <core/arraydim.h>
#include <math/util.h> // for Clamp
#include <layer_ids.h> // for LSET, PCB_LAYER_ID, LSEQ
#include <layer_ids.h> // for PCB_LAYER_ID
#include <lseq.h>
#include <macros.h> // for arrayDim
#include <wx/debug.h> // for wxASSERT, wxASSERT_MSG
#include <wx/string.h>
#include <lset.h>
LSET::LSET( const PCB_LAYER_ID* aArray, unsigned aCount ) :
BASE_SET()
@ -631,121 +634,65 @@ LSEQ LSET::SeqStackupForPlotting() const
}
PCB_LAYER_ID FlipLayer( PCB_LAYER_ID aLayerId, int aCopperLayersCount )
{
switch( aLayerId )
{
case B_Cu: return F_Cu;
case F_Cu: return B_Cu;
case B_SilkS: return F_SilkS;
case F_SilkS: return B_SilkS;
case B_Adhes: return F_Adhes;
case F_Adhes: return B_Adhes;
case B_Mask: return F_Mask;
case F_Mask: return B_Mask;
case B_Paste: return F_Paste;
case F_Paste: return B_Paste;
case B_CrtYd: return F_CrtYd;
case F_CrtYd: return B_CrtYd;
case B_Fab: return F_Fab;
case F_Fab: return B_Fab;
default: // change internal layer if aCopperLayersCount is >= 4
if( IsCopperLayer( aLayerId ) && aCopperLayersCount >= 4 )
{
// internal copper layers count is aCopperLayersCount-2
PCB_LAYER_ID fliplayer = PCB_LAYER_ID(aCopperLayersCount - 2 - ( aLayerId - In1_Cu ) );
// Ensure fliplayer has a value which does not crash Pcbnew:
if( fliplayer < F_Cu )
fliplayer = F_Cu;
if( fliplayer > B_Cu )
fliplayer = B_Cu;
return fliplayer;
}
// No change for the other layers
return aLayerId;
}
}
LSET FlipLayerMask( LSET aMask, int aCopperLayersCount )
LSET& LSET::Flip( int aCopperLayersCount )
{
// layers on physical outside of a board:
const static LSET and_mask( 16, // !! update count
B_Cu, F_Cu,
B_SilkS, F_SilkS,
B_Adhes, F_Adhes,
B_Mask, F_Mask,
B_Paste, F_Paste,
B_Adhes, F_Adhes,
B_CrtYd, F_CrtYd,
B_Fab, F_Fab
);
LSET oldMask = *this;
LSET newMask = aMask & ~and_mask;
reset();
if( aMask[B_Cu] )
newMask.set( F_Cu );
if( oldMask.test( B_Cu ) )
set( F_Cu );
if( aMask[F_Cu] )
newMask.set( B_Cu );
if( oldMask.test( F_Cu ) )
set( B_Cu );
if( aMask[B_SilkS] )
newMask.set( F_SilkS );
if( oldMask.test( B_SilkS ) )
set( F_SilkS );
if( aMask[F_SilkS] )
newMask.set( B_SilkS );
if( oldMask.test( F_SilkS ) )
set( B_SilkS );
if( aMask[B_Adhes] )
newMask.set( F_Adhes );
if( oldMask.test( B_Adhes ) )
set( F_Adhes );
if( aMask[F_Adhes] )
newMask.set( B_Adhes );
if( oldMask.test( F_Adhes ) )
set( B_Adhes );
if( aMask[B_Mask] )
newMask.set( F_Mask );
if( oldMask.test( B_Mask ) )
set( F_Mask );
if( aMask[F_Mask] )
newMask.set( B_Mask );
if( oldMask.test( F_Mask ) )
set( B_Mask );
if( aMask[B_Paste] )
newMask.set( F_Paste );
if( oldMask.test( B_Paste ) )
set( F_Paste );
if( aMask[F_Paste] )
newMask.set( B_Paste );
if( oldMask.test( F_Paste ) )
set( B_Paste );
if( aMask[B_Adhes] )
newMask.set( F_Adhes );
if( oldMask.test( B_Adhes ) )
set( F_Adhes );
if( aMask[F_Adhes] )
newMask.set( B_Adhes );
if( oldMask.test( F_Adhes ) )
set( B_Adhes );
if( aMask[B_CrtYd] )
newMask.set( F_CrtYd );
if( oldMask.test( B_CrtYd ) )
set( F_CrtYd );
if( aMask[F_CrtYd] )
newMask.set( B_CrtYd );
if( oldMask.test( F_CrtYd ) )
set( B_CrtYd );
if( aMask[B_Fab] )
newMask.set( F_Fab );
if( oldMask.test( B_Fab ) )
set( F_Fab );
if( aMask[F_Fab] )
newMask.set( B_Fab );
if( oldMask.test( F_Fab ) )
set( B_Fab );
if( aCopperLayersCount >= 4 ) // Internal layers exist
{
LSET internalMask = aMask & LSET::InternalCuMask();
LSET internalMask = *this & InternalCuMask();
if( internalMask != LSET::InternalCuMask() )
if( internalMask != InternalCuMask() )
{
// the mask does not include all internal layers. Therefore
// the flipped mask for internal copper layers must be built
@ -757,17 +704,17 @@ LSET FlipLayerMask( LSET aMask, int aCopperLayersCount )
{
if( internalMask[innerLayerCnt - ii] )
{
newMask.set( ii + In1_Cu );
set( ii + In1_Cu );
}
else
{
newMask.reset( ii + In1_Cu );
reset( ii + In1_Cu );
}
}
}
}
return newMask;
return *this;
}

2
common/project/board_project_settings.cpp

@ -19,6 +19,8 @@
*/
#include <functional>
#include <lset.h>
#include <lseq.h>
#include <project/board_project_settings.h>
using namespace std::placeholders;

1
common/project/project_local_settings.cpp

@ -19,6 +19,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <lset.h>
#include <project.h>
#include <project/project_local_settings.h>
#include <settings/json_settings_internals.h>

1
gerbview/files.cpp

@ -33,6 +33,7 @@
#include <gerber_file_image.h>
#include <gerber_file_image_list.h>
#include <excellon_image.h>
#include <lset.h>
#include <wildcards_and_files_ext.h>
#include <view/view.h>
#include <widgets/wx_progress_reporters.h>

1
gerbview/gerbview_frame.cpp

@ -32,6 +32,7 @@
#include <gerbview_draw_panel_gal.h>
#include <gerbview_settings.h>
#include <drawing_sheet/ds_proxy_view_item.h>
#include <lset.h>
#include <settings/settings_manager.h>
#include <tool/tool_manager.h>
#include <tool/action_toolbar.h>

1
gerbview/gerbview_frame.h

@ -24,6 +24,7 @@
#include <file_history.h>
#include <eda_draw_frame.h>
#include <lset.h>
#include <layer_ids.h>
#include <gerbview.h>
#include <gbr_layout.h>

3
gerbview/gerbview_printout.cpp

@ -29,6 +29,9 @@
#include <gerber_file_image.h>
#include <gerber_file_image_list.h>
#include "gerbview_printout.h"
#include <lseq.h>
#include <lset.h>
#include <view/view.h>
#include <gerbview_painter.h>
#include <math/util.h> // for KiROUND

1
gerbview/gerbview_printout.h

@ -20,6 +20,7 @@
#ifndef GERBVIEW_PRINTOUT_H
#define GERBVIEW_PRINTOUT_H
#include <lset.h>
#include <board_printout.h>
class GBR_LAYOUT;

1
gerbview/widgets/gerbview_layer_widget.cpp

@ -31,6 +31,7 @@
#include <gerbview_frame.h>
#include <gerber_file_image_list.h>
#include <core/arraydim.h>
#include <lset.h>
#include <view/view.h>
#include <gerbview_painter.h>
#include <gal/graphics_abstraction_layer.h>

1
include/board_design_settings.h

@ -31,6 +31,7 @@
#include <project/net_settings.h>
#include <board_stackup_manager/board_stackup.h>
#include <drc/drc_engine.h>
#include <lset.h>
#include <settings/nested_settings.h>
#include <widgets/ui_common.h>
#include <zone_settings.h>

2
include/board_item.h

@ -28,6 +28,8 @@
#include <eda_item.h>
#include <layer_ids.h>
#include <lseq.h>
#include <lset.h>
#include <geometry/geometry_utils.h>
#include <stroke_params.h>
#include <geometry/eda_angle.h>

1
include/board_printout.h

@ -30,6 +30,7 @@
#include <wx/print.h>
#include <layer_ids.h>
#include <lset.h>
#include <printout.h>
#include <math/box2.h>

370
include/layer_ids.h

@ -499,365 +499,6 @@ KICOMMON_API wxString LayerName( int aLayer );
( 1 << GAL_LAYER_INDEX( LAYER_RATSNEST ) ) )
/// A sequence of layers, a sequence provides a certain order.
typedef std::vector<PCB_LAYER_ID> BASE_SEQ;
/**
* LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs. A sequence provides
* a certain order.
* <p>
* It can also be used as an iterator:
* <code>
*
* for( LSEQ cu_stack = aSet.CuStack(); cu_stack; ++cu_stack )
* {
* layer_id = *cu_stack;
* :
* things to do with layer_id;
* }
*
* </code>
*/
class KICOMMON_API LSEQ : public BASE_SEQ
{
unsigned m_index;
public:
LSEQ() :
m_index( 0 )
{}
template <class InputIterator>
LSEQ( InputIterator aStart, InputIterator aEnd ) :
BASE_SEQ( aStart, aEnd ), m_index( 0 )
{}
LSEQ( std::initializer_list<PCB_LAYER_ID> aLayers ) :
BASE_SEQ( aLayers ), m_index( 0 )
{}
operator bool () { return m_index < size(); }
PCB_LAYER_ID operator * () const
{
return at( m_index ); // throws std::out_of_range
}
int TestLayers( PCB_LAYER_ID aRhs, PCB_LAYER_ID aLhs ) const
{
if( aRhs == aLhs )
return 0;
auto itRhs = std::find( begin(), end(), aRhs );
auto itLhs = std::find( begin(), end(), aLhs );
return std::distance( itRhs, itLhs );
}
};
typedef std::bitset<PCB_LAYER_ID_COUNT> BASE_SET;
/**
* LSET is a set of PCB_LAYER_IDs. It can be converted to numerous purpose LSEQs using
* the various member functions, most of which are based on Seq(). The advantage
* of converting to LSEQ using purposeful code, is it removes any dependency
* on order/sequence inherent in this set.
*/
class KICOMMON_API LSET : public BASE_SET
{
public:
// The constructor flavors are carefully chosen to prevent LSET( int ) from compiling.
// That excludes "LSET s = 0;" and excludes "LSET s = -1;", etc.
// LSET s = 0; needs to be removed from the code, this accomplishes that.
// Remember LSET( PCB_LAYER_ID(0) ) sets bit 0, so "LSET s = 0;" is illegal
// to prevent that surprise. Therefore LSET's constructor suite is significantly
// different than the base class from which it is derived.
// Other member functions (non-constructor functions) are identical to the base
// class's and therefore are re-used from the base class.
/**
* Create an empty (cleared) set.
*/
LSET() :
BASE_SET() // all bits are set to zero in BASE_SET()
{
}
LSET( const BASE_SET& aOther ) :
BASE_SET( aOther )
{
}
/**
* Take a PCB_LAYER_ID and sets that bit. This makes the following code into
* a bug:
*
* <code> LSET s = 0; </code>
*
* Instead use:
*
* <code>
* LSET s;
* </code>
*
* for an empty set.
*/
LSET( PCB_LAYER_ID aLayer ) : // PCB_LAYER_ID deliberately excludes int and relatives
BASE_SET()
{
set( aLayer );
}
/**
* Create an array or LSEQ.
*/
LSET( const PCB_LAYER_ID* aArray, unsigned aCount );
/**
* Take one or more PCB_LAYER_IDs in the argument list to construct the set. Typically
* only used in static construction.
*
* @param aIdCount is the number of PCB_LAYER_IDs which follow.
* @param aFirst is the first included in @a aIdCount and must always be present, and can
* be followed by any number of additional PCB_LAYER_IDs so long as @a aIdCount accurately
* reflects the count.
*
* Parameter is 'int' to avoid va_start undefined behavior.
*/
LSET( unsigned aIdCount, int aFirst, ... ); // args chosen to prevent LSET( int ) from compiling
LSET( const LSEQ& aSeq );
/**
* See if the layer set contains a PCB layer.
*
* @param aLayer is the layer to check
* @return true if the layer is included
*/
bool Contains( PCB_LAYER_ID aLayer )
{
try
{
return test( aLayer );
}
catch( std::out_of_range& )
{
return false;
}
}
/**
* Return the fixed name association with aLayerId.
*/
static const wxChar* Name( PCB_LAYER_ID aLayerId );
/**
* Return a complete set of internal copper layers which is all Cu layers
* except F_Cu and B_Cu.
*/
static LSET InternalCuMask();
/**
* Return a complete set of all top assembly layers which is all F_SilkS and F_Mask
*/
static LSET FrontAssembly();
/**
* Return a complete set of all bottom assembly layers which is all B_SilkS and B_Mask
*/
static LSET BackAssembly();
/**
* Return a mask holding the requested number of Cu PCB_LAYER_IDs.
*/
static LSET AllCuMask( int aCuLayerCount = MAX_CU_LAYERS );
/**
* Return a mask holding the Front and Bottom layers.
*/
static LSET ExternalCuMask();
/**
* Return a mask holding all layer minus CU layers.
*/
static LSET AllNonCuMask();
static LSET AllLayersMask();
/**
* Return a mask holding all technical layers (no CU layer) on front side.
*/
static LSET FrontTechMask();
/**
* Return a mask holding technical layers used in a board fabrication
* (no CU layer) on front side.
*/
static LSET FrontBoardTechMask();
/**
* Return a mask holding all technical layers (no CU layer) on back side.
*/
static LSET BackTechMask();
/**
* Return a mask holding technical layers used in a board fabrication
* (no CU layer) on Back side.
*/
static LSET BackBoardTechMask();
/**
* Return a mask holding all technical layers (no CU layer) on both side.
*/
static LSET AllTechMask();
/**
* Return a mask holding board technical layers (no CU layer) on both side.
*/
static LSET AllBoardTechMask();
/**
* Return a mask holding all technical layers and the external CU layer on front side.
*/
static LSET FrontMask();
/**
* Return a mask holding all technical layers and the external CU layer on back side.
*/
static LSET BackMask();
static LSET SideSpecificMask();
static LSET UserMask();
/**
* Return a mask holding all layers which are physically realized. Equivalent to the copper
* layers + the board tech mask.
*/
static LSET PhysicalLayersMask();
/**
* Return a mask with all of the allowable user defined layers.
*/
static LSET UserDefinedLayers();
/**
* Layers which are not allowed within footprint definitions. Currently internal
* copper layers and Margin.
*/
static LSET ForbiddenFootprintLayers();
/**
* Return a sequence of copper layers in starting from the front/top
* and extending to the back/bottom. This specific sequence is depended upon
* in numerous places.
*/
LSEQ CuStack() const;
/**
* Return a sequence of technical layers. A sequence provides a certain order.
*
* @param aSubToOmit is the subset of the technical layers to omit, defaults to none.
*/
LSEQ Technicals( LSET aSubToOmit = LSET() ) const;
/// *_User layers.
LSEQ Users() const;
/// Returns the technical and user layers in the order shown in layer widget
LSEQ TechAndUserUIOrder() const;
LSEQ UIOrder() const;
/**
* Return an LSEQ from the union of this LSET and a desired sequence. The LSEQ
* element will be in the same sequence as aWishListSequence if they are present.
* @param aWishListSequence establishes the order of the returned LSEQ, and the LSEQ will only
* contain PCB_LAYER_IDs which are present in this set.
* @param aCount is the length of aWishListSequence array.
*/
LSEQ Seq( const PCB_LAYER_ID* aWishListSequence, unsigned aCount ) const;
LSEQ Seq( const LSEQ& aSequence ) const;
/**
* Return a LSEQ from this LSET in ascending PCB_LAYER_ID order. Each LSEQ
* element will be in the same sequence as in PCB_LAYER_ID and only present
* in the resultant LSEQ if present in this set. Therefore the sequence is
* subject to change, use it only when enumeration and not order is important.
*/
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.
* For instance, to plot multiple layers in a single image, the top layers output last.
*/
LSEQ SeqStackupForPlotting() const;
/**
* Execute a function on each layer of the LSET.
*/
void RunOnLayers( const std::function<void( PCB_LAYER_ID )>& aFunction ) const
{
for( size_t ii = 0; ii < size(); ++ii )
{
if( test( ii ) )
aFunction( PCB_LAYER_ID( ii ) );
}
}
/**
* Return a hex string showing contents of this LSEQ.
*/
std::string FmtHex() const;
/**
* Convert the output of FmtHex() and replaces this set's values
* with those given in the input string. Parsing stops at the first
* non hex ASCII byte, except that marker bytes output from FmtHex are
* not terminators.
* @return int - number of bytes consumed
*/
int ParseHex( const char* aStart, int aCount );
/**
* Return a binary string showing contents of this LSEQ.
*/
std::string FmtBin() const;
/**
* Find the first set PCB_LAYER_ID. Returns UNDEFINED_LAYER if more
* than one is set or UNSELECTED_LAYER if none is set.
*/
PCB_LAYER_ID ExtractLayer() const;
private:
/// Take this off the market, it may not be used because of LSET( PCB_LAYER_ID ).
LSET( unsigned long __val )
{
// not usable, it's private.
}
};
/**
* Test whether a given integer is a valid layer index, i.e. can
* be safely put in a PCB_LAYER_ID
@ -1013,17 +654,6 @@ inline bool IsBackLayer( PCB_LAYER_ID aLayerId )
*/
KICOMMON_API PCB_LAYER_ID FlipLayer( PCB_LAYER_ID aLayerId, int aCopperLayersCount = 0 );
/**
* Calculate the mask layer when flipping a footprint.
*
* BACK and FRONT copper layers, mask, paste, solder layers are swapped
* internal layers are flipped only if the copper layers count is known
* @param aMask = the LSET to flip
* @param aCopperLayersCount = the number of copper layers. if 0 (in fact if < 4 )
* internal layers will be not flipped because the layer count is not known
*/
KICOMMON_API LSET FlipLayerMask( LSET aMask, int aCopperLayersCount = 0 );
/**
* Returns a netname layer corresponding to the given layer.

86
include/lseq.h

@ -0,0 +1,86 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LSEQ_H
#define LSEQ_H
#include <vector>
#include <layer_ids.h>
/// A sequence of layers, a sequence provides a certain order.
typedef std::vector<PCB_LAYER_ID> BASE_SEQ;
/**
* LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs. A sequence provides
* a certain order.
* <p>
* It can also be used as an iterator:
* <code>
*
* for( LSEQ cu_stack = aSet.CuStack(); cu_stack; ++cu_stack )
* {
* layer_id = *cu_stack;
* :
* things to do with layer_id;
* }
*
* </code>
*/
class KICOMMON_API LSEQ : public BASE_SEQ
{
unsigned m_index;
public:
LSEQ() :
m_index( 0 )
{}
template <class InputIterator>
LSEQ( InputIterator aStart, InputIterator aEnd ) :
BASE_SEQ( aStart, aEnd ), m_index( 0 )
{}
LSEQ( std::initializer_list<PCB_LAYER_ID> aLayers ) :
BASE_SEQ( aLayers ), m_index( 0 )
{}
operator bool () { return m_index < size(); }
PCB_LAYER_ID operator * () const
{
return at( m_index ); // throws std::out_of_range
}
int TestLayers( PCB_LAYER_ID aRhs, PCB_LAYER_ID aLhs ) const
{
if( aRhs == aLhs )
return 0;
auto itRhs = std::find( begin(), end(), aRhs );
auto itLhs = std::find( begin(), end(), aLhs );
return std::distance( itRhs, itLhs );
}
};
#endif // LSEQ_H

332
include/lset.h

@ -0,0 +1,332 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LSET_H
#define LSET_H
#include <bitset>
#include <layer_ids.h>
class LSEQ;
typedef std::bitset<PCB_LAYER_ID_COUNT> BASE_SET;
/**
* LSET is a set of PCB_LAYER_IDs. It can be converted to numerous purpose LSEQs using
* the various member functions, most of which are based on Seq(). The advantage
* of converting to LSEQ using purposeful code, is it removes any dependency
* on order/sequence inherent in this set.
*/
class KICOMMON_API LSET : public BASE_SET
{
public:
// The constructor flavors are carefully chosen to prevent LSET( int ) from compiling.
// That excludes "LSET s = 0;" and excludes "LSET s = -1;", etc.
// LSET s = 0; needs to be removed from the code, this accomplishes that.
// Remember LSET( PCB_LAYER_ID(0) ) sets bit 0, so "LSET s = 0;" is illegal
// to prevent that surprise. Therefore LSET's constructor suite is significantly
// different than the base class from which it is derived.
// Other member functions (non-constructor functions) are identical to the base
// class's and therefore are re-used from the base class.
/**
* Create an empty (cleared) set.
*/
LSET() :
BASE_SET() // all bits are set to zero in BASE_SET()
{
}
LSET( const BASE_SET& aOther ) :
BASE_SET( aOther )
{
}
/**
* Take a PCB_LAYER_ID and sets that bit. This makes the following code into
* a bug:
*
* <code> LSET s = 0; </code>
*
* Instead use:
*
* <code>
* LSET s;
* </code>
*
* for an empty set.
*/
LSET( PCB_LAYER_ID aLayer ) : // PCB_LAYER_ID deliberately excludes int and relatives
BASE_SET()
{
set( aLayer );
}
/**
* Create an array or LSEQ.
*/
LSET( const PCB_LAYER_ID* aArray, unsigned aCount );
/**
* Take one or more PCB_LAYER_IDs in the argument list to construct the set. Typically
* only used in static construction.
*
* @param aIdCount is the number of PCB_LAYER_IDs which follow.
* @param aFirst is the first included in @a aIdCount and must always be present, and can
* be followed by any number of additional PCB_LAYER_IDs so long as @a aIdCount accurately
* reflects the count.
*
* Parameter is 'int' to avoid va_start undefined behavior.
*/
LSET( unsigned aIdCount, int aFirst, ... ); // args chosen to prevent LSET( int ) from compiling
LSET( const LSEQ& aSeq );
LSET( unsigned long __val ) = delete;
/**
* See if the layer set contains a PCB layer.
*
* @param aLayer is the layer to check
* @return true if the layer is included
*/
bool Contains( PCB_LAYER_ID aLayer )
{
try
{
return test( aLayer );
}
catch( std::out_of_range& )
{
return false;
}
}
/**
* Return the fixed name association with aLayerId.
*/
static const wxChar* Name( PCB_LAYER_ID aLayerId );
/**
* Return a complete set of internal copper layers which is all Cu layers
* except F_Cu and B_Cu.
*/
static LSET InternalCuMask();
/**
* Return a complete set of all top assembly layers which is all F_SilkS and F_Mask
*/
static LSET FrontAssembly();
/**
* Return a complete set of all bottom assembly layers which is all B_SilkS and B_Mask
*/
static LSET BackAssembly();
/**
* Return a mask holding the requested number of Cu PCB_LAYER_IDs.
*/
static LSET AllCuMask( int aCuLayerCount = MAX_CU_LAYERS );
/**
* Return a mask holding the Front and Bottom layers.
*/
static LSET ExternalCuMask();
/**
* Return a mask holding all layer minus CU layers.
*/
static LSET AllNonCuMask();
static LSET AllLayersMask();
/**
* Return a mask holding all technical layers (no CU layer) on front side.
*/
static LSET FrontTechMask();
/**
* Return a mask holding technical layers used in a board fabrication
* (no CU layer) on front side.
*/
static LSET FrontBoardTechMask();
/**
* Return a mask holding all technical layers (no CU layer) on back side.
*/
static LSET BackTechMask();
/**
* Return a mask holding technical layers used in a board fabrication
* (no CU layer) on Back side.
*/
static LSET BackBoardTechMask();
/**
* Return a mask holding all technical layers (no CU layer) on both side.
*/
static LSET AllTechMask();
/**
* Return a mask holding board technical layers (no CU layer) on both side.
*/
static LSET AllBoardTechMask();
/**
* Return a mask holding all technical layers and the external CU layer on front side.
*/
static LSET FrontMask();
/**
* Return a mask holding all technical layers and the external CU layer on back side.
*/
static LSET BackMask();
static LSET SideSpecificMask();
static LSET UserMask();
/**
* Return a mask holding all layers which are physically realized. Equivalent to the copper
* layers + the board tech mask.
*/
static LSET PhysicalLayersMask();
/**
* Return a mask with all of the allowable user defined layers.
*/
static LSET UserDefinedLayers();
/**
* Layers which are not allowed within footprint definitions. Currently internal
* copper layers and Margin.
*/
static LSET ForbiddenFootprintLayers();
/**
* Return a sequence of copper layers in starting from the front/top
* and extending to the back/bottom. This specific sequence is depended upon
* in numerous places.
*/
LSEQ CuStack() const;
/**
* Return a sequence of technical layers. A sequence provides a certain order.
*
* @param aSubToOmit is the subset of the technical layers to omit, defaults to none.
*/
LSEQ Technicals( LSET aSubToOmit = LSET() ) const;
/// *_User layers.
LSEQ Users() const;
/// Returns the technical and user layers in the order shown in layer widget
LSEQ TechAndUserUIOrder() const;
LSEQ UIOrder() const;
/**
* Return an LSEQ from the union of this LSET and a desired sequence. The LSEQ
* element will be in the same sequence as aWishListSequence if they are present.
* @param aWishListSequence establishes the order of the returned LSEQ, and the LSEQ will only
* contain PCB_LAYER_IDs which are present in this set.
* @param aCount is the length of aWishListSequence array.
*/
LSEQ Seq( const PCB_LAYER_ID* aWishListSequence, unsigned aCount ) const;
LSEQ Seq( const LSEQ& aSequence ) const;
/**
* Return a LSEQ from this LSET in ascending PCB_LAYER_ID order. Each LSEQ
* element will be in the same sequence as in PCB_LAYER_ID and only present
* in the resultant LSEQ if present in this set. Therefore the sequence is
* subject to change, use it only when enumeration and not order is important.
*/
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.
* For instance, to plot multiple layers in a single image, the top layers output last.
*/
LSEQ SeqStackupForPlotting() const;
/**
* Execute a function on each layer of the LSET.
*/
void RunOnLayers( const std::function<void( PCB_LAYER_ID )>& aFunction ) const
{
for( size_t ii = 0; ii < size(); ++ii )
{
if( test( ii ) )
aFunction( PCB_LAYER_ID( ii ) );
}
}
/**
* Return a hex string showing contents of this LSEQ.
*/
std::string FmtHex() const;
/**
* Convert the output of FmtHex() and replaces this set's values
* with those given in the input string. Parsing stops at the first
* non hex ASCII byte, except that marker bytes output from FmtHex are
* not terminators.
* @return int - number of bytes consumed
*/
int ParseHex( const char* aStart, int aCount );
/**
* Return a binary string showing contents of this LSEQ.
*/
std::string FmtBin() const;
/**
* Find the first set PCB_LAYER_ID. Returns UNDEFINED_LAYER if more
* than one is set or UNSELECTED_LAYER if none is set.
*/
PCB_LAYER_ID ExtractLayer() const;
/**
* Flip the layers in this set.
*
* BACK and FRONT copper layers, mask, paste, solder layers are swapped
* internal layers are flipped only if the copper layers count is known
* @param aMask = the LSET to flip
* @param aCopperLayersCount = the number of copper layers. if 0 (in fact if < 4 )
* internal layers will be not flipped because the layer count is not known
*/
LSET& Flip( int aCopperLayersCount = 0 );
};
#endif // LSET_H

1
include/pcb_base_frame.h

@ -31,6 +31,7 @@
#include <eda_draw_frame.h>
#include <outline_mode.h>
#include <lib_id.h>
#include <lset.h>
#include <pcb_display_options.h>
#include <pcb_draw_panel_gal.h>
#include <pcb_origin_transforms.h>

1
include/project/board_project_settings.h

@ -22,6 +22,7 @@
#define KICAD_BOARD_PROJECT_SETTINGS_H
#include <layer_ids.h>
#include <lset.h>
#include <settings/parameters.h>
// Can be removed by refactoring PARAM_LAYER_PRESET

1
include/render_settings.h

@ -29,6 +29,7 @@
#include <gal/color4d.h>
#include <layer_ids.h>
#include <lset.h>
#include <memory>
#include <wx/dc.h>

2
kicad/cli/command_pcb_export_base.cpp

@ -23,6 +23,8 @@
#include <kiface_base.h>
#include <bitset>
#include <layer_ids.h>
#include <lset.h>
#include <lseq.h>
#include <string_utils.h>
#include <macros.h>

2
kicad/cli/command_pcb_export_base.h

@ -23,6 +23,8 @@
#include "command.h"
#include <layer_ids.h>
#include <lset.h>
#include <lseq.h>
namespace CLI
{

1
pcbnew/api/api_pcb_utils.cpp

@ -23,6 +23,7 @@
#include <board.h>
#include <board_item_container.h>
#include <footprint.h>
#include <lset.h>
#include <pad.h>
#include <pcb_group.h>
#include <pcb_reference_image.h>

1
pcbnew/api/api_pcb_utils.h

@ -25,6 +25,7 @@
#include <core/typeinfo.h>
#include <import_export.h>
#include <layer_ids.h>
#include <lset.h>
#include <api/common/types/base_types.pb.h>
#include <api/board/board_types.pb.h>

1
pcbnew/autorouter/ar_autoplacer.cpp

@ -30,6 +30,7 @@
#include <widgets/msgpanel.h>
#include <board.h>
#include <footprint.h>
#include <lset.h>
#include <pcb_shape.h>
#include <pad.h>
#include <board_commit.h>

1
pcbnew/autorouter/ar_autoplacer.h

@ -33,6 +33,7 @@
#include <board.h>
#include <footprint.h>
#include <lset.h>
#include <connectivity/connectivity_data.h>

1
pcbnew/autorouter/ar_matrix.cpp

@ -26,6 +26,7 @@
*/
#include "ar_matrix.h"
#include <lset.h>
#include <math/util.h> // for KiROUND
#include <math_for_graphics.h>
#include <trigo.h>

1
pcbnew/autorouter/ar_matrix.h

@ -30,6 +30,7 @@
#define __AR_MATRIX_H
#include <layer_ids.h>
#include <lset.h>
#include <math/box2.h>
class PCB_SHAPE;

1
pcbnew/board.cpp

@ -38,6 +38,7 @@
#include <connectivity/connectivity_data.h>
#include <convert_shape_list_to_polygon.h>
#include <footprint.h>
#include <lset.h>
#include <pcb_base_frame.h>
#include <pcb_track.h>
#include <pcb_marker.h>

1
pcbnew/board.h

@ -31,6 +31,7 @@
#include <convert_shape_list_to_polygon.h> // for OUTLINE_ERROR_HANDLER
#include <hash.h>
#include <layer_ids.h>
#include <lset.h>
#include <netinfo.h>
#include <pcb_item_containers.h>
#include <pcb_plot_params.h>

1
pcbnew/board_commit.cpp

@ -26,6 +26,7 @@
#include <macros.h>
#include <board.h>
#include <footprint.h>
#include <lset.h>
#include <pcb_group.h>
#include <pcb_track.h>
#include <tool/tool_manager.h>

1
pcbnew/board_connected_item.cpp

@ -27,6 +27,7 @@
#include <board_connected_item.h>
#include <board_design_settings.h>
#include <connectivity/connectivity_data.h>
#include <lset.h>
#include <properties/property_validators.h>
#include <string_utils.h>
#include <i18n_utility.h>

1
pcbnew/board_design_settings.cpp

@ -24,6 +24,7 @@
#include <pcb_dimension.h>
#include <pcb_track.h>
#include <layer_ids.h>
#include <lset.h>
#include <kiface_base.h>
#include <pad.h>
#include <board_design_settings.h>

1
pcbnew/board_item.cpp

@ -31,6 +31,7 @@
#include <macros.h>
#include <board.h>
#include <board_design_settings.h>
#include <lset.h>
#include <pcb_group.h>
#include <pcb_generator.h>
#include <footprint.h>

1
pcbnew/board_stackup_manager/board_stackup.h

@ -29,6 +29,7 @@
#include <vector>
#include <wx/string.h>
#include <layer_ids.h>
#include <lset.h>
#include <api/serializable.h>
class BOARD;

1
pcbnew/collectors.h

@ -32,6 +32,7 @@
#include <collector.h>
#include <layer_ids.h> // LAYER_COUNT, layer defs
#include <lset.h>
#include <view/view.h>
#include <board_item.h>

1
pcbnew/dialogs/dialog_map_layers.cpp

@ -20,6 +20,7 @@
#include <layer_ids.h>
#include <lseq.h>
#include <dialog_map_layers.h>
#include <wx/msgdlg.h>

2
pcbnew/drc/drc_engine.h

@ -30,7 +30,7 @@
#include <units_provider.h>
#include <geometry/shape.h>
#include <lset.h>
#include <drc/drc_rule.h>

1
pcbnew/drc/drc_rule.h

@ -29,6 +29,7 @@
#include <optional>
#include <core/minoptmax.h>
#include <layer_ids.h>
#include <lset.h>
#include <netclass.h>
#include <zones.h>
#include <libeval_compiler/libeval_compiler.h>

1
pcbnew/exporters/step/exporter_step.h

@ -29,6 +29,7 @@
#include <geometry/shape_poly_set.h>
#include <gal/color4d.h>
#include <layer_ids.h>
#include <lset.h>
// Default value to chain 2 shapes when creating the board outlines
// from shapes on Edges.Cut layer

1
pcbnew/footprint.cpp

@ -34,6 +34,7 @@
#include <pcb_edit_frame.h>
#include <board.h>
#include <board_design_settings.h>
#include <lset.h>
#include <macros.h>
#include <pad.h>
#include <pcb_marker.h>

1
pcbnew/footprint.h

@ -33,6 +33,7 @@
#include <board_item.h>
#include <collectors.h>
#include <layer_ids.h> // ALL_LAYERS definition.
#include <lset.h>
#include <lib_id.h>
#include <list>

1
pcbnew/footprint_chooser_frame.cpp

@ -30,6 +30,7 @@
#include <wx/button.h>
#include <wx/checkbox.h>
#include <kiplatform/ui.h>
#include <lset.h>
#include <widgets/panel_footprint_chooser.h>
#include <settings/settings_manager.h>
#include <footprint_editor_settings.h>

1
pcbnew/footprint_editor_settings.cpp

@ -21,6 +21,7 @@
#include <common.h>
#include <footprint_editor_settings.h>
#include <layer_ids.h>
#include <lset.h>
#include <pgm_base.h>
#include <eda_text.h>
#include <settings/common_settings.h>

1
pcbnew/grid_layer_box_helpers.cpp

@ -27,6 +27,7 @@
#include <settings/color_settings.h>
#include <footprint_editor_settings.h>
#include <board.h>
#include <lset.h>
#include <pcb_edit_frame.h>
#include <pcb_layer_box_selector.h>
#include <settings/color_settings.h>

1
pcbnew/grid_layer_box_helpers.h

@ -27,6 +27,7 @@
#include <wx/generic/gridctrl.h>
#include <wx/generic/grideditors.h>
#include "pcb_layer_box_selector.h"
#include <lset.h>
class wxGrid;
class PCB_LAYER_BOX_SELECTOR;

1
pcbnew/initpcb.cpp

@ -23,6 +23,7 @@
*/
#include <confirm.h>
#include <lset.h>
#include <pcb_edit_frame.h>
#include <project.h>
#include <tool/tool_manager.h>

4
pcbnew/pad.cpp

@ -41,6 +41,7 @@
#include <board_connected_item.h>
#include <board_design_settings.h>
#include <footprint.h>
#include <lset.h>
#include <pad.h>
#include <pcb_shape.h>
#include <connectivity/connectivity_data.h>
@ -873,7 +874,8 @@ void PAD::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
// PADS items are currently on all copper layers, or
// currently, only on Front or Back layers.
// So the copper layers count is not taken in account
SetLayerSet( FlipLayerMask( m_padStack.LayerSet() ) );
LSET layerSet = m_padStack.LayerSet();
SetLayerSet( layerSet.Flip() );
// Flip the basic shapes, in custom pads
FlipPrimitives( aFlipLeftRight );

1
pcbnew/pad.h

@ -31,6 +31,7 @@
#include <board_connected_item.h>
#include <geometry/shape_poly_set.h>
#include <geometry/shape_compound.h>
#include <lset.h>
#include <padstack.h>
#include <geometry/eda_angle.h>
#include <geometry/geometry_utils.h>

1
pcbnew/padstack.h

@ -28,6 +28,7 @@
#include <api/serializable.h>
#include <geometry/eda_angle.h>
#include <layer_ids.h>
#include <lset.h>
#include <math/vector2d.h>
#include <properties/property.h>
#include <zones.h>

1
pcbnew/pcb_base_frame.cpp

@ -43,6 +43,7 @@
#include <footprint.h>
#include <footprint_editor_settings.h>
#include <fp_lib_table.h>
#include <lset.h>
#include <kiface_base.h>
#include <pcb_painter.h>
#include <pcbnew_id.h>

1
pcbnew/pcb_edit_frame.cpp

@ -30,6 +30,7 @@
#include <fp_lib_table.h>
#include <bitmaps.h>
#include <confirm.h>
#include <lset.h>
#include <trace_helpers.h>
#include <pcbnew_id.h>
#include <pcbnew_settings.h>

1
pcbnew/pcb_generator.h

@ -29,6 +29,7 @@
#include <unordered_set>
#include <string_any_map.h>
#include <lset.h>
#include <pcb_group.h>
class EDIT_POINTS;

1
pcbnew/pcb_group.h

@ -32,6 +32,7 @@
#include <board_commit.h>
#include <board_item.h>
#include <lset.h>
#include <unordered_set>
namespace KIGFX

2
pcbnew/pcb_io/altium/altium_pcb.cpp

@ -3423,7 +3423,7 @@ void ALTIUM_PCB::ConvertPads6ToFootprintItemOnCopper( FOOTPRINT* aFootprint, con
case ALTIUM_LAYER::BOTTOM_LAYER:
pad->SetLayer( B_Cu );
pad->SetLayerSet( FlipLayerMask( PAD::SMDMask() ) );
pad->SetLayerSet( PAD::SMDMask().Flip() );
break;
case ALTIUM_LAYER::MULTI_LAYER:

1
pcbnew/pcb_io/common/plugin_common_layer_mapping.h

@ -27,6 +27,7 @@
#include <pcb_io/pcb_io_mgr.h>
#include <layer_ids.h> // PCB_LAYER_ID
#include <lset.h>
/**
* @brief Describes an imported layer and how it could be mapped to KiCad Layers

1
pcbnew/pcb_io/eagle/pcb_io_eagle.h

@ -32,6 +32,7 @@
#include <eda_units.h>
#include <layer_ids.h>
#include <lset.h>
#include <netclass.h>
#include <map>

2
pcbnew/pcb_io/easyeda/pcb_io_easyeda_parser.cpp

@ -973,7 +973,7 @@ void PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer(
else if( klayer == B_Cu )
{
pad->SetLayer( B_Cu );
pad->SetLayerSet( FlipLayerMask( PAD::SMDMask() ) );
pad->SetLayerSet( PAD::SMDMask().Flip() );
pad->SetAttribute( PAD_ATTRIB::SMD );
}
else if( elayer == wxS( "11" ) )

2
pcbnew/pcb_io/easyedapro/pcb_io_easyedapro_parser.cpp

@ -654,7 +654,7 @@ std::unique_ptr<PAD> PCB_IO_EASYEDAPRO_PARSER::createPAD( FOOTPRINT*
}
else if( klayer == B_Cu )
{
pad->SetLayerSet( FlipLayerMask( PAD::SMDMask() ) );
pad->SetLayerSet( PAD::SMDMask().Flip() );
}
pad->SetAttribute( PAD_ATTRIB::SMD );

2
pcbnew/pcb_io/fabmaster/import_fabmaster.cpp

@ -2432,7 +2432,7 @@ bool FABMASTER::loadFootprints( BOARD* aBoard )
if( pad.top )
newpad->SetLayerSet( PAD::SMDMask() );
else if( pad.bottom )
newpad->SetLayerSet( FlipLayerMask( PAD::SMDMask() ) );
newpad->SetLayerSet( PAD::SMDMask().Flip() );
}
}

1
pcbnew/pcb_io/kicad_legacy/pcb_io_kicad_legacy.h

@ -31,6 +31,7 @@
#include <richio.h>
#include <string>
#include <layer_ids.h>
#include <lset.h>
#include <memory>
#include <geometry/eda_angle.h>

1
pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h

@ -31,6 +31,7 @@
#include <richio.h>
#include <string>
#include <layer_ids.h>
#include <lset.h>
#include <boost/ptr_container/ptr_map.hpp>
#include <wx_filename.h>
#include "widgets/report_severity.h"

1
pcbnew/pcb_layer_box_selector.h

@ -25,6 +25,7 @@
#ifndef PCB_LAYER_BOX_SELECTOR_H
#define PCB_LAYER_BOX_SELECTOR_H
#include <lset.h>
#include <widgets/layer_box_selector.h>
class PCB_BASE_FRAME;

1
pcbnew/pcb_painter.cpp

@ -44,6 +44,7 @@
#include <pcb_target.h>
#include <layer_ids.h>
#include <lset.h>
#include <pcb_painter.h>
#include <pcb_display_options.h>
#include <project/net_settings.h>

1
pcbnew/pcb_plot_params.cpp

@ -24,6 +24,7 @@
#include <board_design_settings.h>
#include <charconv>
#include <layer_ids.h>
#include <lset.h>
#include <string_utils.h>
#include <math/util.h> // for KiROUND
#include <pcb_plot_params.h>

1
pcbnew/pcb_shape.cpp

@ -34,6 +34,7 @@
#include <board_design_settings.h>
#include <board.h>
#include <footprint.h>
#include <lset.h>
#include <pad.h>
#include <base_units.h>
#include <geometry/shape_compound.h>

1
pcbnew/pcb_track.cpp

@ -31,6 +31,7 @@
#include <convert_basic_shapes_to_polygon.h>
#include <pcb_track.h>
#include <base_units.h>
#include <lset.h>
#include <string_utils.h>
#include <view/view.h>
#include <settings/color_settings.h>

1
pcbnew/pcb_track.h

@ -43,6 +43,7 @@
#include <geometry/shape_segment.h>
#include <core/minoptmax.h>
#include <core/arraydim.h>
#include <lset.h>
#include <padstack.h>
class PCB_TRACK;

1
pcbnew/pcbexpr_evaluator.cpp

@ -26,6 +26,7 @@
#include <memory>
#include <mutex>
#include <board.h>
#include <lset.h>
#include <board_connected_item.h>
#include <pcbexpr_evaluator.h>
#include <drc/drc_engine.h>

1
pcbnew/pcbexpr_functions.cpp

@ -30,6 +30,7 @@
#include <board_design_settings.h>
#include <drc/drc_rtree.h>
#include <drc/drc_engine.h>
#include <lset.h>
#include <pcb_track.h>
#include <pcb_group.h>
#include <geometry/shape_segment.h>

1
pcbnew/pcbnew_jobs_handler.cpp

@ -39,6 +39,7 @@
#include <jobs/job_export_pcb_3d.h>
#include <jobs/job_pcb_render.h>
#include <jobs/job_pcb_drc.h>
#include <lset.h>
#include <cli/exit_codes.h>
#include <exporters/place_file_exporter.h>
#include <exporters/step/exporter_step.h>

1
pcbnew/pcbnew_printout.cpp

@ -29,6 +29,7 @@
#include <board.h>
#include <math/util.h> // for KiROUND
#include <gal/graphics_abstraction_layer.h>
#include <lset.h>
#include <pcb_painter.h>
#include <pcbnew_settings.h>
#include <view/view.h>

1
pcbnew/pcbnew_printout.h

@ -22,6 +22,7 @@
#define PCBNEW_PRINTOUT_H
#include <board_printout.h>
#include <lset.h>
#include <pcb_painter.h>
#include <plotprint_opts.h>

3
pcbnew/pcbnew_settings.cpp

@ -26,6 +26,7 @@
#include <common.h>
#include <footprint_editor_settings.h>
#include <layer_ids.h>
#include <lset.h>
#include <pcbnew_settings.h>
#include <pgm_base.h>
#include <router/pns_routing_settings.h>
@ -129,7 +130,7 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
&m_AuiPanels.show_search, false ) );
m_params.emplace_back( new PARAM<bool>( "aui.show_net_inspector",
&m_AuiPanels.show_net_inspector, false ) );
&m_AuiPanels.show_net_inspector, false ) );
m_params.emplace_back( new PARAM<int>( "footprint_chooser.width",
&m_FootprintChooser.width, -1 ) );

1
pcbnew/pcbplot.cpp

@ -26,6 +26,7 @@
#include <plotters/plotter.h>
#include <pcbplot.h>
#include <base_units.h>
#include <lset.h>
#include <locale_io.h>
#include <reporter.h>
#include <board.h>

1
pcbnew/pcbplot.h

@ -24,6 +24,7 @@
#ifndef PCBPLOT_H_
#define PCBPLOT_H_
#include <lset.h>
#include <padstack.h> // for PAD_DRILL_SHAPE
#include <pcb_plot_params.h>
#include <settings/color_settings.h>

1
pcbnew/plot_board_layers.cpp

@ -24,6 +24,7 @@
#include <wx/log.h>
#include <eda_item.h>
#include <layer_ids.h>
#include <lset.h>
#include <geometry/geometry_utils.h>
#include <geometry/shape_segment.h>
#include <pcb_base_frame.h>

1
pcbnew/plot_brditems_plotter.cpp

@ -41,6 +41,7 @@
#include <gbr_metadata.h>
#include <gbr_netlist_metadata.h> // for GBR_NETLIST_METADATA
#include <layer_ids.h> // for LSET, IsCopperLayer
#include <lset.h>
#include <pcbplot.h>
#include <pcb_plot_params.h> // for PCB_PLOT_PARAMS, PCB_PL...
#include <advanced_config.h>

1
pcbnew/plotcontroller.h

@ -32,6 +32,7 @@
#include <pcb_plot_params.h>
#include <layer_ids.h>
#include <lset.h>
class PLOTTER;
class BOARD;

1
pcbnew/sel_layer.cpp

@ -25,6 +25,7 @@
#include <kiplatform/ui.h>
#include <confirm.h>
#include <lset.h>
#include <pcb_base_frame.h>
#include <widgets/layer_box_selector.h>
#include <board.h>

1
pcbnew/toolbars_footprint_editor.cpp

@ -24,6 +24,7 @@
#include <footprint_edit_frame.h>
#include <pcbnew_id.h>
#include <bitmaps.h>
#include <lset.h>
#include <tool/action_toolbar.h>
#include <tool/tool_manager.h>
#include <tools/pcb_actions.h>

2
pcbnew/tools/pcb_grid_helper.h

@ -27,6 +27,8 @@
#define PCB_GRID_HELPER_H
#include <vector>
#include <lset.h>
#include <pcb_item_containers.h>
#include <tool/grid_helper.h>

1
pcbnew/tracks_cleaner.cpp

@ -28,6 +28,7 @@
#include <cleanup_item.h>
#include <connectivity/connectivity_algo.h>
#include <connectivity/connectivity_data.h>
#include <lset.h>
#include <tool/tool_manager.h>
#include <tools/pcb_actions.h>
#include <tools/global_edit_tool.h>

1
pcbnew/undo_redo.cpp

@ -34,6 +34,7 @@ using namespace std::placeholders;
#include <pcb_generator.h>
#include <pcb_target.h>
#include <footprint.h>
#include <lset.h>
#include <pad.h>
#include <origin_viewitem.h>
#include <connectivity/connectivity_data.h>

3
pcbnew/zone.cpp

@ -30,6 +30,7 @@
#include <pcb_screen.h>
#include <board.h>
#include <board_design_settings.h>
#include <lset.h>
#include <pad.h>
#include <zone.h>
#include <footprint.h>
@ -733,7 +734,7 @@ void ZONE::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
fillsCopy[oldLayer] = *shapePtr;
}
SetLayerSet( FlipLayerMask( GetLayerSet(), GetBoard()->GetCopperLayerCount() ) );
SetLayerSet( GetLayerSet().Flip( GetBoard()->GetCopperLayerCount() ) );
for( auto& [oldLayer, shape] : fillsCopy )
{

1
pcbnew/zone.h

@ -32,6 +32,7 @@
#include <board_item.h>
#include <board_connected_item.h>
#include <layer_ids.h>
#include <lset.h>
#include <geometry/shape_poly_set.h>
#include <zone_settings.h>
#include <teardrop/teardrop_types.h>

1
pcbnew/zone_settings.cpp

@ -27,6 +27,7 @@
#include <pcb_base_frame.h>
#include <board.h>
#include <lset.h>
#include <settings/color_settings.h>
#include <zones.h>

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save