2013-03-30 19:41:08 -04:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2014-06-30 10:03:20 -05:00
|
|
|
* Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2013-03-30 19:41:08 -04:00
|
|
|
* Copyright (C) 2010 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2013-03-30 19:41:08 -04:00
|
|
|
*
|
|
|
|
* 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 2
|
|
|
|
* 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, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2021-07-29 10:47:43 +01:00
|
|
|
#ifndef LAYER_IDS_H
|
|
|
|
#define LAYER_IDS_H
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2020-10-23 23:33:04 -04:00
|
|
|
#include <set>
|
2014-06-24 11:17:18 -05:00
|
|
|
#include <vector>
|
|
|
|
#include <bitset>
|
2021-10-11 10:06:40 -07:00
|
|
|
#include <stdexcept>
|
2014-06-24 11:17:18 -05:00
|
|
|
#include <wx/string.h>
|
2023-09-14 21:33:03 -04:00
|
|
|
#include <kicommon.h>
|
2010-01-29 20:36:12 +00:00
|
|
|
|
2013-03-30 18:24:04 +01:00
|
|
|
|
2017-03-12 23:19:33 -04:00
|
|
|
/**
|
|
|
|
* A quick note on layer IDs:
|
|
|
|
*
|
|
|
|
* The layers are stored in separate enums so that certain functions can
|
2020-09-22 17:50:59 -04:00
|
|
|
* take in the enums as data types and don't have to know about layers from
|
2017-03-12 23:19:33 -04:00
|
|
|
* other applications.
|
|
|
|
*
|
|
|
|
* Layers that are shared between applications should be in the GAL_LAYER_ID enum.
|
|
|
|
*
|
|
|
|
* The PCB_LAYER_ID struct must start at zero for compatibility with legacy board files.
|
|
|
|
*
|
|
|
|
* Some functions accept any layer ID, so they start at zero (i.e. F_Cu) and go up to
|
|
|
|
* the LAYER_ID_COUNT, which needs to be kept up-to-date if new enums are added.
|
|
|
|
*/
|
|
|
|
|
2013-03-30 18:24:04 +01:00
|
|
|
|
2013-09-11 17:30:21 +02:00
|
|
|
/**
|
2020-09-22 17:50:59 -04:00
|
|
|
* This is the definition of all layers used in Pcbnew.
|
2017-03-12 23:19:33 -04:00
|
|
|
*
|
2025-01-08 13:08:27 -05:00
|
|
|
* The PCB layer types are fixed at value 0 through #LAYER_ID_COUNT to ensure compatibility
|
2020-09-22 17:50:59 -04:00
|
|
|
* with legacy board files.
|
2013-09-11 17:30:21 +02:00
|
|
|
*/
|
2017-03-12 23:19:33 -04:00
|
|
|
enum PCB_LAYER_ID: int
|
2013-09-11 17:30:21 +02:00
|
|
|
{
|
2017-03-12 23:19:33 -04:00
|
|
|
UNDEFINED_LAYER = -1,
|
|
|
|
UNSELECTED_LAYER = -2,
|
|
|
|
|
2023-01-29 13:06:05 -05:00
|
|
|
F_Cu = 0,
|
2024-07-21 10:49:18 -07:00
|
|
|
B_Cu = 2,
|
|
|
|
In1_Cu = 4,
|
|
|
|
In2_Cu = 6,
|
|
|
|
In3_Cu = 8,
|
|
|
|
In4_Cu = 10,
|
|
|
|
In5_Cu = 12,
|
|
|
|
In6_Cu = 14,
|
|
|
|
In7_Cu = 16,
|
|
|
|
In8_Cu = 18,
|
|
|
|
In9_Cu = 20,
|
|
|
|
In10_Cu = 22,
|
|
|
|
In11_Cu = 24,
|
|
|
|
In12_Cu = 26,
|
|
|
|
In13_Cu = 28,
|
|
|
|
In14_Cu = 30,
|
|
|
|
In15_Cu = 32,
|
|
|
|
In16_Cu = 34,
|
|
|
|
In17_Cu = 36,
|
|
|
|
In18_Cu = 38,
|
|
|
|
In19_Cu = 40,
|
|
|
|
In20_Cu = 42,
|
|
|
|
In21_Cu = 44,
|
|
|
|
In22_Cu = 46,
|
|
|
|
In23_Cu = 48,
|
|
|
|
In24_Cu = 50,
|
|
|
|
In25_Cu = 52,
|
|
|
|
In26_Cu = 54,
|
|
|
|
In27_Cu = 56,
|
|
|
|
In28_Cu = 58,
|
|
|
|
In29_Cu = 60,
|
|
|
|
In30_Cu = 62,
|
|
|
|
|
|
|
|
F_Mask = 1,
|
|
|
|
B_Mask = 3,
|
|
|
|
|
|
|
|
F_SilkS = 5,
|
|
|
|
B_SilkS = 7,
|
|
|
|
F_Adhes = 9,
|
|
|
|
B_Adhes = 11,
|
|
|
|
F_Paste = 13,
|
|
|
|
B_Paste = 15,
|
|
|
|
|
|
|
|
Dwgs_User = 17,
|
|
|
|
Cmts_User = 19,
|
|
|
|
Eco1_User = 21,
|
|
|
|
Eco2_User = 23,
|
|
|
|
|
|
|
|
Edge_Cuts = 25,
|
|
|
|
Margin = 27,
|
|
|
|
|
|
|
|
B_CrtYd = 29,
|
|
|
|
F_CrtYd = 31,
|
|
|
|
|
|
|
|
B_Fab = 33,
|
|
|
|
F_Fab = 35,
|
|
|
|
|
|
|
|
Rescue = 37,
|
2020-09-22 17:50:59 -04:00
|
|
|
|
|
|
|
// User definable layers.
|
2024-07-21 10:49:18 -07:00
|
|
|
User_1 = 39,
|
|
|
|
User_2 = 41,
|
|
|
|
User_3 = 43,
|
|
|
|
User_4 = 45,
|
|
|
|
User_5 = 47,
|
|
|
|
User_6 = 49,
|
|
|
|
User_7 = 51,
|
|
|
|
User_8 = 53,
|
|
|
|
User_9 = 55,
|
2024-11-03 10:26:10 -08:00
|
|
|
User_10 = 57,
|
|
|
|
User_11 = 59,
|
|
|
|
User_12 = 61,
|
|
|
|
User_13 = 63,
|
|
|
|
User_14 = 65,
|
|
|
|
User_15 = 67,
|
|
|
|
User_16 = 69,
|
|
|
|
User_17 = 71,
|
|
|
|
User_18 = 73,
|
|
|
|
User_19 = 75,
|
|
|
|
User_20 = 77,
|
|
|
|
User_21 = 79,
|
|
|
|
User_22 = 81,
|
|
|
|
User_23 = 83,
|
|
|
|
User_24 = 85,
|
|
|
|
User_25 = 87,
|
|
|
|
User_26 = 89,
|
|
|
|
User_27 = 91,
|
|
|
|
User_28 = 93,
|
|
|
|
User_29 = 95,
|
|
|
|
User_30 = 97,
|
|
|
|
User_31 = 99,
|
|
|
|
User_32 = 101,
|
|
|
|
User_33 = 103,
|
|
|
|
User_34 = 105,
|
|
|
|
User_35 = 107,
|
|
|
|
User_36 = 109,
|
|
|
|
User_37 = 111,
|
|
|
|
User_38 = 113,
|
|
|
|
User_39 = 115,
|
|
|
|
User_40 = 117,
|
|
|
|
User_41 = 119,
|
|
|
|
User_42 = 121,
|
|
|
|
User_43 = 123,
|
|
|
|
User_44 = 125,
|
|
|
|
User_45 = 127,
|
|
|
|
|
|
|
|
|
|
|
|
PCB_LAYER_ID_COUNT = 128
|
2017-03-12 23:19:33 -04:00
|
|
|
};
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2023-01-29 13:06:05 -05:00
|
|
|
constexpr PCB_LAYER_ID PCBNEW_LAYER_ID_START = F_Cu;
|
|
|
|
|
2025-02-02 00:43:03 +00:00
|
|
|
#define MAX_CU_LAYERS 32
|
|
|
|
#define MAX_USER_DEFINED_LAYERS 45
|
2017-03-12 23:19:33 -04:00
|
|
|
|
2022-03-16 16:48:24 -07:00
|
|
|
/**
|
|
|
|
* Enum used during connectivity building to ensure we do not query connectivity while building
|
2025-01-08 13:08:27 -05:00
|
|
|
* the database.
|
2022-03-16 16:48:24 -07:00
|
|
|
*/
|
|
|
|
enum class FLASHING
|
|
|
|
{
|
2025-01-08 13:08:27 -05:00
|
|
|
DEFAULT, ///< Flashing follows connectivity.
|
|
|
|
ALWAYS_FLASHED, ///< Always flashed for connectivity.
|
|
|
|
NEVER_FLASHED, ///< Never flashed for connectivity.
|
2022-03-16 16:48:24 -07:00
|
|
|
};
|
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Dedicated layers for net names used in Pcbnew.
|
2017-03-12 23:19:33 -04:00
|
|
|
enum NETNAMES_LAYER_ID: int
|
|
|
|
{
|
|
|
|
|
|
|
|
NETNAMES_LAYER_ID_START = PCB_LAYER_ID_COUNT,
|
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Reserved space for board layer netnames.
|
2017-03-12 23:19:33 -04:00
|
|
|
NETNAMES_LAYER_ID_RESERVED = NETNAMES_LAYER_ID_START + PCB_LAYER_ID_COUNT,
|
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Additional netnames layers (not associated with a PCB layer).
|
2017-03-12 23:19:33 -04:00
|
|
|
LAYER_PAD_FR_NETNAMES,
|
|
|
|
LAYER_PAD_BK_NETNAMES,
|
2021-01-30 14:41:31 +00:00
|
|
|
LAYER_PAD_NETNAMES,
|
2024-12-28 10:02:11 -05:00
|
|
|
LAYER_VIA_NETNAMES,
|
2017-03-12 23:19:33 -04:00
|
|
|
|
|
|
|
NETNAMES_LAYER_ID_END
|
2016-01-08 17:28:21 -05:00
|
|
|
};
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2017-03-12 23:19:33 -04:00
|
|
|
/// Macro for obtaining netname layer for a given PCB layer
|
2024-04-12 21:54:51 -04:00
|
|
|
#define NETNAMES_LAYER_INDEX( layer ) ( static_cast<int>( NETNAMES_LAYER_ID_START ) + layer )
|
2017-03-12 23:19:33 -04:00
|
|
|
|
2023-12-17 08:46:57 -05:00
|
|
|
#define GAL_UI_LAYER_COUNT 10
|
|
|
|
|
2021-02-21 13:41:43 -05:00
|
|
|
/**
|
|
|
|
* GAL layers are "virtual" layers, i.e. not tied into design data.
|
2025-01-08 13:08:27 -05:00
|
|
|
*
|
2021-02-21 13:41:43 -05:00
|
|
|
* Some layers here are shared between applications.
|
|
|
|
*
|
2025-01-08 13:08:27 -05:00
|
|
|
* @note Be very careful where you add new layers here. Layers up to #GAL_LAYER_ID_BITMASK_END
|
2021-02-21 13:41:43 -05:00
|
|
|
* must never be re-ordered and new layers must always be added after this value, because the
|
|
|
|
* layers before this value are mapped to bit locations in legacy board files.
|
|
|
|
*
|
|
|
|
* The values in this enum that are used to store visibility state are explicitly encoded with an
|
2025-01-08 13:08:27 -05:00
|
|
|
* offset from #GAL_LAYER_ID_START, which is explicitly encoded itself. The exact value of
|
|
|
|
* #GAL_LAYER_ID_START is not that sensitive, but the offsets should never be changed or else any
|
2021-02-21 13:41:43 -05:00
|
|
|
* existing visibility settings will be disrupted.
|
|
|
|
*/
|
2017-03-12 23:19:33 -04:00
|
|
|
enum GAL_LAYER_ID: int
|
|
|
|
{
|
|
|
|
GAL_LAYER_ID_START = NETNAMES_LAYER_ID_END,
|
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Meta control for all vias opacity/visibility.
|
|
|
|
LAYER_VIAS = GAL_LAYER_ID_START + 0,
|
|
|
|
LAYER_VIA_MICROVIA = GAL_LAYER_ID_START + 1, /// Draw micro vias.
|
|
|
|
LAYER_VIA_BBLIND = GAL_LAYER_ID_START + 2, /// Draw blind/buried vias.
|
|
|
|
LAYER_VIA_THROUGH = GAL_LAYER_ID_START + 3, /// Draw usual through hole vias.
|
|
|
|
|
|
|
|
/// Handle color for not plated holes (holes, not pads).
|
|
|
|
LAYER_NON_PLATEDHOLES = GAL_LAYER_ID_START + 4,
|
2023-08-04 11:13:20 +01:00
|
|
|
LAYER_FP_TEXT = GAL_LAYER_ID_START + 5,
|
2025-01-08 13:08:27 -05:00
|
|
|
|
2021-10-22 21:12:57 +01:00
|
|
|
// LAYER_MOD_TEXT_BK deprecated + 6,
|
2025-01-08 13:08:27 -05:00
|
|
|
|
|
|
|
// DEPRECATED, UNUSED SINCE 9.0. text marked as invisible.
|
|
|
|
// LAYER_HIDDEN_TEXT = GAL_LAYER_ID_START + 7,
|
|
|
|
|
|
|
|
/// Anchor of items having an anchor point (texts, footprints).
|
|
|
|
LAYER_ANCHOR = GAL_LAYER_ID_START + 8,
|
|
|
|
|
|
|
|
// LAYER_PADS_SMD_FR = GAL_LAYER_ID_START + 9, // Deprecated since 9.0
|
|
|
|
// LAYER_PADS_SMD_BK = GAL_LAYER_ID_START + 10, // Deprecated since 9.0
|
|
|
|
|
2021-02-21 13:41:43 -05:00
|
|
|
LAYER_RATSNEST = GAL_LAYER_ID_START + 11,
|
|
|
|
LAYER_GRID = GAL_LAYER_ID_START + 12,
|
|
|
|
LAYER_GRID_AXES = GAL_LAYER_ID_START + 13,
|
2025-01-08 13:08:27 -05:00
|
|
|
|
|
|
|
// LAYER_NO_CONNECTS deprecated + 14, // show a marker on pads with no nets
|
|
|
|
|
|
|
|
LAYER_FOOTPRINTS_FR = GAL_LAYER_ID_START + 15, ///< Show footprints on front.
|
|
|
|
LAYER_FOOTPRINTS_BK = GAL_LAYER_ID_START + 16, ///< Show footprints on back.
|
|
|
|
|
|
|
|
/// Show footprints values (when texts are visible).
|
|
|
|
LAYER_FP_VALUES = GAL_LAYER_ID_START + 17,
|
|
|
|
|
|
|
|
/// Show footprints references (when texts are visible).
|
|
|
|
LAYER_FP_REFERENCES = GAL_LAYER_ID_START + 18,
|
2021-02-21 13:41:43 -05:00
|
|
|
LAYER_TRACKS = GAL_LAYER_ID_START + 19,
|
2025-01-08 13:08:27 -05:00
|
|
|
|
2024-11-12 21:45:52 -05:00
|
|
|
// LAYER_PADS_TH = GAL_LAYER_ID_START + 20, ///< Deprecated since 9.0
|
2025-01-08 13:08:27 -05:00
|
|
|
|
2021-02-21 13:41:43 -05:00
|
|
|
LAYER_PAD_PLATEDHOLES = GAL_LAYER_ID_START + 21, ///< to draw pad holes (plated)
|
2025-01-08 13:08:27 -05:00
|
|
|
|
|
|
|
/// Draw via holes (pad holes do not use this layer).
|
|
|
|
LAYER_VIA_HOLES = GAL_LAYER_ID_START + 22,
|
|
|
|
|
|
|
|
/// Layer for DRC markers with #SEVERITY_ERROR.
|
|
|
|
LAYER_DRC_ERROR = GAL_LAYER_ID_START + 23,
|
|
|
|
LAYER_DRAWINGSHEET = GAL_LAYER_ID_START + 24, ///< Sheet frame and title block.
|
|
|
|
LAYER_GP_OVERLAY = GAL_LAYER_ID_START + 25, ///< General purpose overlay.
|
|
|
|
LAYER_SELECT_OVERLAY = GAL_LAYER_ID_START + 26, ///< Selected items overlay.
|
|
|
|
LAYER_PCB_BACKGROUND = GAL_LAYER_ID_START + 27, ///< PCB background color.
|
|
|
|
LAYER_CURSOR = GAL_LAYER_ID_START + 28, ///< PCB cursor.
|
|
|
|
LAYER_AUX_ITEMS = GAL_LAYER_ID_START + 29, ///< Auxiliary items (guides, rule, etc).
|
|
|
|
LAYER_DRAW_BITMAPS = GAL_LAYER_ID_START + 30, ///< Draw images.
|
2017-03-12 23:19:33 -04:00
|
|
|
|
2022-09-07 11:07:00 +01:00
|
|
|
/// This is the end of the layers used for visibility bit masks in legacy board files
|
2021-02-21 13:41:43 -05:00
|
|
|
GAL_LAYER_ID_BITMASK_END = GAL_LAYER_ID_START + 31,
|
|
|
|
|
|
|
|
// Layers in this section have visibility controls but were not present in legacy board files.
|
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Meta control for all pads opacity/visibility (color ignored).
|
|
|
|
LAYER_PADS = GAL_LAYER_ID_START + 32,
|
|
|
|
|
|
|
|
/// Control for copper zone opacity/visibility (color ignored).
|
|
|
|
LAYER_ZONES = GAL_LAYER_ID_START + 33,
|
2021-02-21 13:41:43 -05:00
|
|
|
|
|
|
|
LAYER_PAD_HOLEWALLS = GAL_LAYER_ID_START + 34,
|
|
|
|
LAYER_VIA_HOLEWALLS = GAL_LAYER_ID_START + 35,
|
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Layer for DRC markers with #SEVERITY_WARNING.
|
|
|
|
LAYER_DRC_WARNING = GAL_LAYER_ID_START + 36,
|
|
|
|
|
|
|
|
/// Layer for DRC markers which have been individually excluded.
|
|
|
|
LAYER_DRC_EXCLUSION = GAL_LAYER_ID_START + 37,
|
|
|
|
LAYER_MARKER_SHADOWS = GAL_LAYER_ID_START + 38, ///< Shadows for DRC markers.
|
|
|
|
|
|
|
|
LAYER_LOCKED_ITEM_SHADOW = GAL_LAYER_ID_START + 39, ///< Shadow layer for locked items.
|
|
|
|
|
|
|
|
/// Shadow layer for items flagged conflicting.
|
|
|
|
LAYER_CONFLICTS_SHADOW = GAL_LAYER_ID_START + 40,
|
|
|
|
|
|
|
|
/// Copper graphic shape opacity/visibility (color ignored).
|
2025-04-13 13:12:11 +01:00
|
|
|
LAYER_FILLED_SHAPES = GAL_LAYER_ID_START + 41,
|
2022-03-06 20:11:03 +01:00
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
LAYER_DRC_SHAPE1 = GAL_LAYER_ID_START + 42, ///< Custom shape for DRC marker.
|
|
|
|
LAYER_DRC_SHAPE2 = GAL_LAYER_ID_START + 43, ///< Custom shape for DRC marker.
|
2022-05-20 11:08:33 +02:00
|
|
|
|
2025-06-19 18:18:28 +02:00
|
|
|
LAYER_BOARD_OUTLINE_AREA = GAL_LAYER_ID_START + 44, ///< PCB board outline
|
2025-03-29 13:07:58 +08:00
|
|
|
|
|
|
|
/// PCB reference/manual snap points visibility
|
|
|
|
LAYER_POINTS = GAL_LAYER_ID_START + 45,
|
|
|
|
|
2021-02-21 13:41:43 -05:00
|
|
|
// Add layers below this point that do not have visibility controls, so don't need explicit
|
|
|
|
// enum values
|
2017-03-12 23:19:33 -04:00
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
LAYER_DRAWINGSHEET_PAGE1, ///< Sheet Editor previewing first page.
|
|
|
|
LAYER_DRAWINGSHEET_PAGEn, ///< Sheet Editor previewing pages after first page.
|
2019-05-24 21:09:42 +01:00
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
LAYER_PAGE_LIMITS, ///< Color for drawing the page extents (visibility stored in
|
|
|
|
///< PCBNEW_SETTINGS::m_ShowPageLimits)
|
2022-03-24 14:10:47 +00:00
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Virtual layers for stacking zones and tracks on a given copper layer.
|
2020-07-11 13:42:00 -04:00
|
|
|
LAYER_ZONE_START,
|
|
|
|
LAYER_ZONE_END = LAYER_ZONE_START + PCB_LAYER_ID_COUNT,
|
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Virtual layers for pad copper on a given copper layer.
|
2024-12-28 10:36:39 -05:00
|
|
|
LAYER_PAD_COPPER_START,
|
|
|
|
LAYER_PAD_COPPER_END = LAYER_PAD_COPPER_START + PCB_LAYER_ID_COUNT,
|
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Virtual layers for via copper on a given copper layer.
|
2024-12-28 10:36:39 -05:00
|
|
|
LAYER_VIA_COPPER_START,
|
|
|
|
LAYER_VIA_COPPER_END = LAYER_VIA_COPPER_START + PCB_LAYER_ID_COUNT,
|
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Virtual layers for pad/via/track clearance outlines for a given copper layer.
|
2024-12-29 23:38:40 +08:00
|
|
|
LAYER_CLEARANCE_START,
|
|
|
|
LAYER_CLEARANCE_END = LAYER_CLEARANCE_START + PCB_LAYER_ID_COUNT,
|
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Virtual layers for background images per board layer.
|
2022-06-27 14:07:52 -04:00
|
|
|
LAYER_BITMAP_START,
|
|
|
|
LAYER_BITMAP_END = LAYER_BITMAP_START + PCB_LAYER_ID_COUNT,
|
|
|
|
|
2025-03-29 13:07:58 +08:00
|
|
|
/// Virtual layers for points per board layer.
|
|
|
|
LAYER_POINT_START,
|
|
|
|
LAYER_POINT_END = LAYER_POINT_START + PCB_LAYER_ID_COUNT,
|
|
|
|
|
2023-12-17 08:46:57 -05:00
|
|
|
// Layers for drawing on-canvas UI
|
|
|
|
LAYER_UI_START,
|
|
|
|
LAYER_UI_END = LAYER_UI_START + GAL_UI_LAYER_COUNT,
|
|
|
|
|
2017-03-12 23:19:33 -04:00
|
|
|
GAL_LAYER_ID_END
|
|
|
|
};
|
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Use this macro to convert a #GAL layer to a 0-indexed offset from #LAYER_VIAS.
|
2017-03-12 23:19:33 -04:00
|
|
|
#define GAL_LAYER_INDEX( x ) ( x - GAL_LAYER_ID_START )
|
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Macros for getting the extra layers for a given board layer.
|
2022-06-27 14:07:52 -04:00
|
|
|
#define BITMAP_LAYER_FOR( boardLayer ) ( LAYER_BITMAP_START + boardLayer )
|
|
|
|
#define ZONE_LAYER_FOR( boardLayer ) ( LAYER_ZONE_START + boardLayer )
|
2024-12-28 10:36:39 -05:00
|
|
|
#define PAD_COPPER_LAYER_FOR( boardLayer ) ( LAYER_PAD_COPPER_START + boardLayer )
|
|
|
|
#define VIA_COPPER_LAYER_FOR( boardLayer ) ( LAYER_VIA_COPPER_START + boardLayer )
|
2024-12-29 23:38:40 +08:00
|
|
|
#define CLEARANCE_LAYER_FOR( boardLayer ) ( LAYER_CLEARANCE_START + boardLayer )
|
2025-03-29 13:07:58 +08:00
|
|
|
#define POINT_LAYER_FOR( boardLayer ) ( LAYER_POINT_START + boardLayer )
|
2020-07-11 13:42:00 -04:00
|
|
|
|
2020-05-31 17:42:04 -04:00
|
|
|
constexpr int GAL_LAYER_ID_COUNT = GAL_LAYER_ID_END - GAL_LAYER_ID_START;
|
|
|
|
|
2017-03-12 23:19:33 -04:00
|
|
|
inline GAL_LAYER_ID operator++( GAL_LAYER_ID& a )
|
|
|
|
{
|
|
|
|
a = GAL_LAYER_ID( int( a ) + 1 );
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2020-07-11 13:42:00 -04:00
|
|
|
inline GAL_LAYER_ID ToGalLayer( int aInteger )
|
|
|
|
{
|
|
|
|
wxASSERT( aInteger >= GAL_LAYER_ID_START && aInteger <= GAL_LAYER_ID_END );
|
|
|
|
return static_cast<GAL_LAYER_ID>( aInteger );
|
|
|
|
}
|
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Used for via types.
|
2017-03-12 23:19:33 -04:00
|
|
|
inline GAL_LAYER_ID operator+( const GAL_LAYER_ID& a, int b )
|
|
|
|
{
|
|
|
|
GAL_LAYER_ID t = GAL_LAYER_ID( int( a ) + b );
|
|
|
|
wxASSERT( t <= GAL_LAYER_ID_END );
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2023-03-24 13:02:13 +00:00
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Wraps a std::bitset.
|
2020-07-11 13:42:00 -04:00
|
|
|
typedef std::bitset<GAL_LAYER_ID_COUNT> GAL_BASE_SET;
|
|
|
|
|
2023-03-24 13:02:13 +00:00
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Helper for storing and iterating over GAL_LAYER_IDs.
|
2023-09-14 21:33:03 -04:00
|
|
|
class KICOMMON_API GAL_SET : public GAL_BASE_SET
|
2020-07-11 13:40:23 -04:00
|
|
|
{
|
2023-03-24 13:02:13 +00:00
|
|
|
|
2020-07-11 13:42:00 -04:00
|
|
|
private:
|
|
|
|
static constexpr int start = static_cast<int>( GAL_LAYER_ID_START );
|
|
|
|
|
2020-07-11 13:40:23 -04:00
|
|
|
public:
|
|
|
|
GAL_SET() : std::bitset<GAL_LAYER_ID_COUNT>()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
GAL_SET( const GAL_SET& aOther ) : std::bitset<GAL_LAYER_ID_COUNT>( aOther )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-07-11 13:42:00 -04:00
|
|
|
GAL_SET( const GAL_LAYER_ID* aArray, unsigned aCount );
|
|
|
|
|
2020-07-11 13:40:23 -04:00
|
|
|
GAL_SET& set()
|
|
|
|
{
|
2020-07-11 13:42:00 -04:00
|
|
|
GAL_BASE_SET::set();
|
2020-07-11 13:40:23 -04:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2020-07-11 13:42:00 -04:00
|
|
|
GAL_SET& set( int aPos, bool aVal = true )
|
2020-07-11 13:40:23 -04:00
|
|
|
{
|
2020-07-11 13:42:00 -04:00
|
|
|
GAL_BASE_SET::set( aPos, aVal );
|
2020-07-11 13:40:23 -04:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2020-07-11 13:42:00 -04:00
|
|
|
GAL_SET& set( GAL_LAYER_ID aPos, bool aVal = true )
|
2020-07-11 13:40:23 -04:00
|
|
|
{
|
2020-10-05 10:41:14 +00:00
|
|
|
GAL_BASE_SET::set( static_cast<std::size_t>( aPos ) - start, aVal );
|
2020-07-11 13:42:00 -04:00
|
|
|
return *this;
|
|
|
|
}
|
2020-07-11 13:40:23 -04:00
|
|
|
|
2020-07-11 13:42:00 -04:00
|
|
|
bool Contains( GAL_LAYER_ID aPos )
|
|
|
|
{
|
2020-10-05 10:41:14 +00:00
|
|
|
return test( static_cast<std::size_t>( aPos ) - start );
|
2020-07-11 13:40:23 -04:00
|
|
|
}
|
2020-07-11 13:42:00 -04:00
|
|
|
|
|
|
|
std::vector<GAL_LAYER_ID> Seq() const;
|
|
|
|
|
|
|
|
static GAL_SET DefaultVisible();
|
2020-07-11 13:40:23 -04:00
|
|
|
};
|
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Eeschema drawing layers.
|
2024-08-12 19:48:11 +01:00
|
|
|
enum SCH_LAYER_ID : int
|
2017-03-12 23:19:33 -04:00
|
|
|
{
|
|
|
|
SCH_LAYER_ID_START = GAL_LAYER_ID_END,
|
|
|
|
|
|
|
|
LAYER_WIRE = SCH_LAYER_ID_START,
|
|
|
|
LAYER_BUS,
|
|
|
|
LAYER_JUNCTION,
|
|
|
|
LAYER_LOCLABEL,
|
|
|
|
LAYER_GLOBLABEL,
|
|
|
|
LAYER_HIERLABEL,
|
|
|
|
LAYER_PINNUM,
|
|
|
|
LAYER_PINNAM,
|
|
|
|
LAYER_REFERENCEPART,
|
|
|
|
LAYER_VALUEPART,
|
|
|
|
LAYER_FIELDS,
|
2021-10-12 21:05:37 +01:00
|
|
|
LAYER_INTERSHEET_REFS,
|
|
|
|
LAYER_NETCLASS_REFS,
|
2024-04-25 14:24:46 +00:00
|
|
|
LAYER_RULE_AREAS,
|
2017-03-12 23:19:33 -04:00
|
|
|
LAYER_DEVICE,
|
|
|
|
LAYER_NOTES,
|
2022-07-06 22:51:23 -06:00
|
|
|
LAYER_PRIVATE_NOTES,
|
2021-07-17 20:56:18 +01:00
|
|
|
LAYER_NOTES_BACKGROUND,
|
2017-03-12 23:19:33 -04:00
|
|
|
LAYER_PIN,
|
|
|
|
LAYER_SHEET,
|
|
|
|
LAYER_SHEETNAME,
|
|
|
|
LAYER_SHEETFILENAME,
|
2020-03-06 12:05:21 +00:00
|
|
|
LAYER_SHEETFIELDS,
|
2017-03-12 23:19:33 -04:00
|
|
|
LAYER_SHEETLABEL,
|
|
|
|
LAYER_NOCONNECT,
|
2021-12-06 18:50:00 +00:00
|
|
|
LAYER_DANGLING,
|
2023-07-16 19:04:21 +02:00
|
|
|
LAYER_DNP_MARKER,
|
2017-03-12 23:19:33 -04:00
|
|
|
LAYER_ERC_WARN,
|
|
|
|
LAYER_ERC_ERR,
|
2021-11-05 21:16:26 +00:00
|
|
|
LAYER_ERC_EXCLUSION,
|
2024-06-03 13:59:40 +01:00
|
|
|
LAYER_EXCLUDED_FROM_SIM,
|
2025-01-01 19:44:46 +00:00
|
|
|
LAYER_SHAPES_BACKGROUND,
|
2017-03-12 23:19:33 -04:00
|
|
|
LAYER_DEVICE_BACKGROUND,
|
2018-10-21 13:50:31 +01:00
|
|
|
LAYER_SHEET_BACKGROUND,
|
2017-03-12 23:19:33 -04:00
|
|
|
LAYER_SCHEMATIC_GRID,
|
2020-03-22 00:03:59 +00:00
|
|
|
LAYER_SCHEMATIC_GRID_AXES,
|
2017-03-12 23:19:33 -04:00
|
|
|
LAYER_SCHEMATIC_BACKGROUND,
|
2018-09-18 00:19:58 +01:00
|
|
|
LAYER_SCHEMATIC_CURSOR,
|
2022-05-14 16:49:53 +01:00
|
|
|
LAYER_HOVERED,
|
2017-03-12 23:19:33 -04:00
|
|
|
LAYER_BRIGHTENED,
|
2018-08-30 20:44:10 +01:00
|
|
|
LAYER_HIDDEN,
|
2024-08-12 19:48:11 +01:00
|
|
|
LAYER_NET_COLOR_HIGHLIGHT,
|
2019-07-29 19:57:41 -06:00
|
|
|
LAYER_SELECTION_SHADOWS,
|
2021-02-22 16:37:43 +00:00
|
|
|
LAYER_SCHEMATIC_DRAWINGSHEET,
|
2022-03-24 14:10:47 +00:00
|
|
|
LAYER_SCHEMATIC_PAGE_LIMITS,
|
2020-04-22 21:33:57 -04:00
|
|
|
LAYER_BUS_JUNCTION,
|
2020-08-09 17:39:45 -04:00
|
|
|
LAYER_SCHEMATIC_AUX_ITEMS,
|
2021-09-28 20:26:47 -04:00
|
|
|
LAYER_SCHEMATIC_ANCHOR,
|
2023-02-09 17:18:56 +00:00
|
|
|
LAYER_OP_VOLTAGES,
|
|
|
|
LAYER_OP_CURRENTS,
|
2017-03-12 23:19:33 -04:00
|
|
|
|
|
|
|
SCH_LAYER_ID_END
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SCH_LAYER_ID_COUNT ( SCH_LAYER_ID_END - SCH_LAYER_ID_START )
|
|
|
|
|
|
|
|
#define SCH_LAYER_INDEX( x ) ( x - SCH_LAYER_ID_START )
|
|
|
|
|
|
|
|
inline SCH_LAYER_ID operator++( SCH_LAYER_ID& a )
|
|
|
|
{
|
|
|
|
a = SCH_LAYER_ID( int( a ) + 1 );
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Number of draw layers in Gerbview.
|
2024-04-12 21:54:51 -04:00
|
|
|
#define GERBER_DRAWLAYERS_COUNT static_cast<int>( PCB_LAYER_ID_COUNT )
|
2017-03-12 23:19:33 -04:00
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Gerbview draw layers.
|
2017-03-12 23:19:33 -04:00
|
|
|
enum GERBVIEW_LAYER_ID: int
|
|
|
|
{
|
|
|
|
GERBVIEW_LAYER_ID_START = SCH_LAYER_ID_END,
|
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Gerbview draw layers and d-code layers
|
2017-09-17 18:43:20 -04:00
|
|
|
GERBVIEW_LAYER_ID_RESERVED = GERBVIEW_LAYER_ID_START + ( 2 * GERBER_DRAWLAYERS_COUNT ),
|
2017-03-12 23:19:33 -04:00
|
|
|
|
|
|
|
LAYER_DCODES,
|
|
|
|
LAYER_NEGATIVE_OBJECTS,
|
|
|
|
LAYER_GERBVIEW_GRID,
|
|
|
|
LAYER_GERBVIEW_AXES,
|
|
|
|
LAYER_GERBVIEW_BACKGROUND,
|
2021-02-22 16:37:43 +00:00
|
|
|
LAYER_GERBVIEW_DRAWINGSHEET,
|
2022-03-24 14:10:47 +00:00
|
|
|
LAYER_GERBVIEW_PAGE_LIMITS,
|
2017-03-12 23:19:33 -04:00
|
|
|
|
|
|
|
GERBVIEW_LAYER_ID_END
|
|
|
|
};
|
|
|
|
|
2017-09-17 18:43:20 -04:00
|
|
|
#define GERBER_DRAW_LAYER( x ) ( GERBVIEW_LAYER_ID_START + x )
|
|
|
|
|
|
|
|
#define GERBER_DCODE_LAYER( x ) ( GERBER_DRAWLAYERS_COUNT + x )
|
|
|
|
|
|
|
|
#define GERBER_DRAW_LAYER_INDEX( x ) ( x - GERBVIEW_LAYER_ID_START )
|
|
|
|
|
2020-01-12 20:44:19 -05:00
|
|
|
|
|
|
|
/// 3D Viewer virtual layers for color settings
|
|
|
|
enum LAYER_3D_ID : int
|
|
|
|
{
|
2020-05-05 21:45:48 -04:00
|
|
|
LAYER_3D_START = GERBVIEW_LAYER_ID_END,
|
2020-01-12 20:44:19 -05:00
|
|
|
|
|
|
|
LAYER_3D_BACKGROUND_BOTTOM,
|
|
|
|
LAYER_3D_BACKGROUND_TOP,
|
|
|
|
LAYER_3D_BOARD,
|
2023-08-11 18:40:13 +01:00
|
|
|
LAYER_3D_COPPER_TOP,
|
|
|
|
LAYER_3D_COPPER_BOTTOM,
|
2020-01-12 20:44:19 -05:00
|
|
|
LAYER_3D_SILKSCREEN_BOTTOM,
|
|
|
|
LAYER_3D_SILKSCREEN_TOP,
|
2021-07-27 22:24:18 +01:00
|
|
|
LAYER_3D_SOLDERMASK_BOTTOM,
|
|
|
|
LAYER_3D_SOLDERMASK_TOP,
|
2020-01-12 20:44:19 -05:00
|
|
|
LAYER_3D_SOLDERPASTE,
|
2023-08-11 18:40:13 +01:00
|
|
|
LAYER_3D_ADHESIVE,
|
|
|
|
LAYER_3D_USER_COMMENTS,
|
|
|
|
LAYER_3D_USER_DRAWINGS,
|
|
|
|
LAYER_3D_USER_ECO1,
|
|
|
|
LAYER_3D_USER_ECO2,
|
2025-03-15 16:13:27 +00:00
|
|
|
LAYER_3D_USER_1,
|
|
|
|
LAYER_3D_USER_2,
|
|
|
|
LAYER_3D_USER_3,
|
|
|
|
LAYER_3D_USER_4,
|
|
|
|
LAYER_3D_USER_5,
|
|
|
|
LAYER_3D_USER_6,
|
|
|
|
LAYER_3D_USER_7,
|
|
|
|
LAYER_3D_USER_8,
|
|
|
|
LAYER_3D_USER_9,
|
|
|
|
LAYER_3D_USER_10,
|
|
|
|
LAYER_3D_USER_11,
|
|
|
|
LAYER_3D_USER_12,
|
|
|
|
LAYER_3D_USER_13,
|
|
|
|
LAYER_3D_USER_14,
|
|
|
|
LAYER_3D_USER_15,
|
|
|
|
LAYER_3D_USER_16,
|
|
|
|
LAYER_3D_USER_17,
|
|
|
|
LAYER_3D_USER_18,
|
|
|
|
LAYER_3D_USER_19,
|
|
|
|
LAYER_3D_USER_20,
|
|
|
|
LAYER_3D_USER_21,
|
|
|
|
LAYER_3D_USER_22,
|
|
|
|
LAYER_3D_USER_23,
|
|
|
|
LAYER_3D_USER_24,
|
|
|
|
LAYER_3D_USER_25,
|
|
|
|
LAYER_3D_USER_26,
|
|
|
|
LAYER_3D_USER_27,
|
|
|
|
LAYER_3D_USER_28,
|
|
|
|
LAYER_3D_USER_29,
|
|
|
|
LAYER_3D_USER_30,
|
|
|
|
LAYER_3D_USER_31,
|
|
|
|
LAYER_3D_USER_32,
|
|
|
|
LAYER_3D_USER_33,
|
|
|
|
LAYER_3D_USER_34,
|
|
|
|
LAYER_3D_USER_35,
|
|
|
|
LAYER_3D_USER_36,
|
|
|
|
LAYER_3D_USER_37,
|
|
|
|
LAYER_3D_USER_38,
|
|
|
|
LAYER_3D_USER_39,
|
|
|
|
LAYER_3D_USER_40,
|
|
|
|
LAYER_3D_USER_41,
|
|
|
|
LAYER_3D_USER_42,
|
|
|
|
LAYER_3D_USER_43,
|
|
|
|
LAYER_3D_USER_44,
|
|
|
|
LAYER_3D_USER_45,
|
2023-08-11 18:40:13 +01:00
|
|
|
LAYER_3D_TH_MODELS,
|
|
|
|
LAYER_3D_SMD_MODELS,
|
|
|
|
LAYER_3D_VIRTUAL_MODELS,
|
|
|
|
LAYER_3D_MODELS_NOT_IN_POS,
|
|
|
|
LAYER_3D_MODELS_MARKED_DNP,
|
2025-06-09 19:29:34 +02:00
|
|
|
LAYER_3D_NAVIGATOR,
|
2023-08-11 18:40:13 +01:00
|
|
|
LAYER_3D_BOUNDING_BOXES,
|
2023-09-20 18:29:38 +01:00
|
|
|
LAYER_3D_OFF_BOARD_SILK,
|
2025-08-05 19:36:50 +08:00
|
|
|
LAYER_3D_PLATED_BARRELS,
|
2023-08-11 18:40:13 +01:00
|
|
|
|
|
|
|
LAYER_3D_END
|
2020-01-12 20:44:19 -05:00
|
|
|
};
|
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Must update this if you add any enums after Gerbview!
|
2020-05-05 21:45:48 -04:00
|
|
|
#define LAYER_ID_COUNT LAYER_3D_END
|
2017-03-12 23:19:33 -04:00
|
|
|
|
|
|
|
|
2020-04-23 21:55:20 -04:00
|
|
|
/**
|
2025-01-08 13:08:27 -05:00
|
|
|
* Return the string equivalent of a given layer.
|
|
|
|
*
|
|
|
|
* @param aLayer is a valid layer ID.
|
2020-04-23 21:55:20 -04:00
|
|
|
*/
|
2023-09-14 21:33:03 -04:00
|
|
|
KICOMMON_API wxString LayerName( int aLayer );
|
2020-02-03 17:46:58 +01:00
|
|
|
|
|
|
|
|
2017-03-12 23:19:33 -04:00
|
|
|
// Some elements do not have yet a visibility control
|
|
|
|
// from a dialog, but have a visibility control flag.
|
|
|
|
// Here is a mask to set them visible, to be sure they are displayed
|
|
|
|
// after loading a board for instance
|
2021-01-30 14:41:31 +00:00
|
|
|
#define MIN_VISIBILITY_MASK int( ( 1 << GAL_LAYER_INDEX( LAYER_PAD_PLATEDHOLES ) ) +\
|
|
|
|
( 1 << GAL_LAYER_INDEX( LAYER_VIA_HOLES ) ) +\
|
|
|
|
( 1 << GAL_LAYER_INDEX( LAYER_SELECT_OVERLAY ) ) +\
|
|
|
|
( 1 << GAL_LAYER_INDEX( LAYER_GP_OVERLAY ) ) +\
|
|
|
|
( 1 << GAL_LAYER_INDEX( LAYER_RATSNEST ) ) )
|
2014-06-24 11:17:18 -05:00
|
|
|
|
|
|
|
|
2010-01-29 20:36:12 +00:00
|
|
|
/**
|
2020-09-22 17:50:59 -04:00
|
|
|
* Test whether a given integer is a valid layer index, i.e. can
|
2025-01-08 13:08:27 -05:00
|
|
|
* be safely put in a #PCB_LAYER_ID.
|
2020-09-22 17:50:59 -04:00
|
|
|
*
|
|
|
|
* @param aLayerId = Layer index to test. It can be an int, so its useful during I/O
|
2010-01-29 20:36:12 +00:00
|
|
|
* @return true if aLayerIndex is a valid layer index
|
|
|
|
*/
|
2021-07-22 00:14:56 +01:00
|
|
|
inline bool IsValidLayer( int aLayerId )
|
2013-04-09 18:00:46 +02:00
|
|
|
{
|
2017-03-12 23:19:33 -04:00
|
|
|
return unsigned( aLayerId ) < PCB_LAYER_ID_COUNT;
|
2013-04-09 18:00:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-09-22 17:50:59 -04:00
|
|
|
* Test whether a layer is a valid layer for Pcbnew
|
|
|
|
*
|
2013-04-09 18:00:46 +02:00
|
|
|
* @param aLayer = Layer to test
|
2020-09-22 17:50:59 -04:00
|
|
|
* @return true if aLayer is a layer valid in Pcbnew
|
2013-04-09 18:00:46 +02:00
|
|
|
*/
|
2021-07-22 00:14:56 +01:00
|
|
|
inline bool IsPcbLayer( int aLayer )
|
2010-01-29 20:36:12 +00:00
|
|
|
{
|
2017-03-12 23:19:33 -04:00
|
|
|
return aLayer >= F_Cu && aLayer < PCB_LAYER_ID_COUNT;
|
2010-01-29 20:36:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2025-01-08 13:08:27 -05:00
|
|
|
* Test whether a layer is a copper layer.
|
2020-09-22 17:50:59 -04:00
|
|
|
*
|
2014-06-24 11:17:18 -05:00
|
|
|
* @param aLayerId = Layer to test
|
2013-09-11 17:30:21 +02:00
|
|
|
* @return true if aLayer is a valid copper layer
|
2010-01-29 20:36:12 +00:00
|
|
|
*/
|
2021-07-22 00:14:56 +01:00
|
|
|
inline bool IsCopperLayer( int aLayerId )
|
2010-01-29 20:36:12 +00:00
|
|
|
{
|
2024-12-02 15:40:30 -05:00
|
|
|
return !( aLayerId & 1 ) && aLayerId < PCB_LAYER_ID_COUNT && aLayerId >= 0;
|
2010-01-29 20:36:12 +00:00
|
|
|
}
|
|
|
|
|
2024-09-16 02:39:12 +02:00
|
|
|
/**
|
2025-01-08 13:08:27 -05:00
|
|
|
* Test whether a layer is an external (#F_Cu or #B_Cu) copper layer.
|
2024-09-16 02:39:12 +02:00
|
|
|
*
|
|
|
|
* @param aLayerId = Layer to test
|
|
|
|
* @return true if aLayer is a valid external copper layer
|
|
|
|
*/
|
|
|
|
inline bool IsExternalCopperLayer( int aLayerId )
|
|
|
|
{
|
|
|
|
return aLayerId == F_Cu || aLayerId == B_Cu;
|
|
|
|
}
|
|
|
|
|
2024-12-10 13:54:47 +00:00
|
|
|
/**
|
2025-01-08 13:08:27 -05:00
|
|
|
* Test whether a layer is an inner (#In1_Cu to #In30_Cu) copper layer.
|
2024-12-10 13:54:47 +00:00
|
|
|
*
|
|
|
|
* @param aLayerId = Layer to test
|
|
|
|
* @return true if aLayer is a valid inner copper layer
|
|
|
|
*/
|
|
|
|
inline bool IsInnerCopperLayer( int aLayerId )
|
|
|
|
{
|
|
|
|
return IsCopperLayer( aLayerId ) && !IsExternalCopperLayer( aLayerId );
|
|
|
|
}
|
|
|
|
|
2010-01-29 20:36:12 +00:00
|
|
|
/**
|
2020-09-22 17:50:59 -04:00
|
|
|
* Test whether a layer is a non copper layer.
|
|
|
|
*
|
2014-06-24 11:17:18 -05:00
|
|
|
* @param aLayerId = Layer to test
|
2013-04-09 18:00:46 +02:00
|
|
|
* @return true if aLayer is a non copper layer
|
2010-01-29 20:36:12 +00:00
|
|
|
*/
|
2021-07-22 00:14:56 +01:00
|
|
|
inline bool IsNonCopperLayer( int aLayerId )
|
2010-01-29 20:36:12 +00:00
|
|
|
{
|
2024-07-21 10:49:18 -07:00
|
|
|
return ( aLayerId & 1 ) && aLayerId <= PCB_LAYER_ID_COUNT;
|
2014-03-08 20:04:23 +01:00
|
|
|
}
|
|
|
|
|
2021-01-27 14:52:22 +00:00
|
|
|
/**
|
2025-01-08 13:08:27 -05:00
|
|
|
* Test whether a layer is a copper layer, optionally including synthetic copper layers such
|
|
|
|
* as #LAYER_VIA_THROUGH, #LAYER_PADS_SMD_FR, etc.
|
2021-01-27 14:52:22 +00:00
|
|
|
*
|
|
|
|
* @param aLayerId
|
|
|
|
* @param aIncludeSyntheticCopperLayers
|
|
|
|
* @return
|
|
|
|
*/
|
2021-07-22 00:14:56 +01:00
|
|
|
inline bool IsCopperLayer( int aLayerId, bool aIncludeSyntheticCopperLayers )
|
2021-01-27 14:52:22 +00:00
|
|
|
{
|
|
|
|
if( aIncludeSyntheticCopperLayers )
|
|
|
|
return !IsNonCopperLayer( aLayerId );
|
|
|
|
else
|
|
|
|
return IsCopperLayer( aLayerId );
|
|
|
|
}
|
|
|
|
|
2021-07-22 00:14:56 +01:00
|
|
|
inline bool IsViaPadLayer( int aLayer )
|
2021-02-01 16:03:05 +00:00
|
|
|
{
|
|
|
|
return aLayer == LAYER_VIA_THROUGH
|
|
|
|
|| aLayer == LAYER_VIA_MICROVIA
|
|
|
|
|| aLayer == LAYER_VIA_BBLIND;
|
|
|
|
}
|
|
|
|
|
2021-07-22 00:14:56 +01:00
|
|
|
inline bool IsHoleLayer( int aLayer )
|
2021-02-01 16:03:05 +00:00
|
|
|
{
|
|
|
|
return aLayer == LAYER_VIA_HOLES
|
|
|
|
|| aLayer == LAYER_VIA_HOLEWALLS
|
|
|
|
|| aLayer == LAYER_PAD_PLATEDHOLES
|
|
|
|
|| aLayer == LAYER_PAD_HOLEWALLS
|
|
|
|
|| aLayer == LAYER_NON_PLATEDHOLES;
|
|
|
|
}
|
|
|
|
|
2024-09-29 13:25:21 +02:00
|
|
|
inline bool IsSolderMaskLayer( int aLayer )
|
|
|
|
{
|
|
|
|
return aLayer == F_Mask || aLayer == B_Mask;
|
|
|
|
}
|
|
|
|
|
2014-03-08 20:04:23 +01:00
|
|
|
/**
|
2020-09-22 17:50:59 -04:00
|
|
|
* Test whether a layer is a non copper and a non tech layer.
|
|
|
|
*
|
2014-06-24 11:17:18 -05:00
|
|
|
* @param aLayerId = Layer to test
|
2014-03-08 20:04:23 +01:00
|
|
|
* @return true if aLayer is a user layer
|
|
|
|
*/
|
2017-03-12 23:19:33 -04:00
|
|
|
inline bool IsUserLayer( PCB_LAYER_ID aLayerId )
|
2014-03-08 20:04:23 +01:00
|
|
|
{
|
2024-11-03 10:26:10 -08:00
|
|
|
return aLayerId == Dwgs_User || aLayerId == Cmts_User || aLayerId == Eco1_User
|
|
|
|
|| aLayerId == Eco2_User || ( aLayerId >= User_1 && !IsCopperLayer( aLayerId ) );
|
2010-01-29 20:36:12 +00:00
|
|
|
}
|
|
|
|
|
2013-04-04 23:35:01 +02:00
|
|
|
|
2021-07-22 00:14:56 +01:00
|
|
|
/*
|
|
|
|
* IMPORTANT: If a layer is not a front layer that doesn't necessarily mean it's a back layer.
|
|
|
|
*
|
|
|
|
* So a layer can be:
|
|
|
|
* - Front
|
|
|
|
* - Back
|
|
|
|
* - Neither (internal or auxiliary)
|
|
|
|
*
|
|
|
|
* The check most frequent is for back layers, since it involves flips.
|
|
|
|
*/
|
2013-04-04 23:35:01 +02:00
|
|
|
|
2013-09-11 17:30:21 +02:00
|
|
|
/**
|
2025-01-08 13:08:27 -05:00
|
|
|
* Layer classification: check if it's a front layer.
|
2013-04-04 23:35:01 +02:00
|
|
|
*/
|
2017-03-12 23:19:33 -04:00
|
|
|
inline bool IsFrontLayer( PCB_LAYER_ID aLayerId )
|
2013-04-04 23:35:01 +02:00
|
|
|
{
|
2014-06-24 11:17:18 -05:00
|
|
|
switch( aLayerId )
|
|
|
|
{
|
|
|
|
case F_Cu:
|
|
|
|
case F_Adhes:
|
|
|
|
case F_Paste:
|
|
|
|
case F_SilkS:
|
|
|
|
case F_Mask:
|
|
|
|
case F_CrtYd:
|
|
|
|
case F_Fab:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2013-04-04 23:35:01 +02:00
|
|
|
}
|
|
|
|
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2013-09-11 17:30:21 +02:00
|
|
|
/**
|
2025-01-08 13:08:27 -05:00
|
|
|
* Layer classification: check if it's a back layer.
|
2013-04-04 23:35:01 +02:00
|
|
|
*/
|
2017-03-12 23:19:33 -04:00
|
|
|
inline bool IsBackLayer( PCB_LAYER_ID aLayerId )
|
2013-04-04 23:35:01 +02:00
|
|
|
{
|
2014-06-24 11:17:18 -05:00
|
|
|
switch( aLayerId )
|
|
|
|
{
|
|
|
|
case B_Cu:
|
|
|
|
case B_Adhes:
|
|
|
|
case B_Paste:
|
|
|
|
case B_SilkS:
|
|
|
|
case B_Mask:
|
|
|
|
case B_CrtYd:
|
|
|
|
case B_Fab:
|
|
|
|
return true;
|
|
|
|
default:
|
2022-10-24 16:22:27 +01:00
|
|
|
return false;
|
2014-06-24 11:17:18 -05:00
|
|
|
}
|
2013-04-04 23:35:01 +02:00
|
|
|
}
|
|
|
|
|
2014-06-24 11:17:18 -05:00
|
|
|
|
2024-09-19 10:07:32 +05:00
|
|
|
/**
|
2025-01-08 13:08:27 -05:00
|
|
|
* Return true if copper aLayerA is placed lower than aLayerB, false otherwise.
|
2024-09-19 10:07:32 +05:00
|
|
|
*/
|
|
|
|
inline bool IsCopperLayerLowerThan( PCB_LAYER_ID aLayerA, PCB_LAYER_ID aLayerB )
|
|
|
|
{
|
|
|
|
if( aLayerA == aLayerB )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( aLayerA == B_Cu )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if( aLayerB == B_Cu )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return aLayerA > aLayerB;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-05 21:04:58 +02:00
|
|
|
/**
|
2025-01-08 13:08:27 -05:00
|
|
|
* @param aLayerId = the PCB_LAYER_ID 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
|
2013-04-05 21:04:58 +02:00
|
|
|
* @return the layer number after flipping an item
|
2015-12-27 16:51:13 +01:00
|
|
|
* some (not all) layers: external copper, and paired layers( Mask, Paste, solder ... )
|
2013-04-05 21:04:58 +02:00
|
|
|
* are swapped between front and back sides
|
2015-12-27 16:51:13 +01:00
|
|
|
* internal layers are flipped only if the copper layers count is known
|
2013-04-05 21:04:58 +02:00
|
|
|
*/
|
2023-09-14 21:33:03 -04:00
|
|
|
KICOMMON_API PCB_LAYER_ID FlipLayer( PCB_LAYER_ID aLayerId, int aCopperLayersCount = 0 );
|
2013-04-05 21:04:58 +02:00
|
|
|
|
2013-04-07 13:55:18 +02:00
|
|
|
|
2013-07-08 16:46:04 +02:00
|
|
|
/**
|
2025-01-08 13:08:27 -05:00
|
|
|
* Return a netname layer corresponding to the given layer.
|
2013-07-08 16:46:04 +02:00
|
|
|
*/
|
2014-06-24 11:17:18 -05:00
|
|
|
inline int GetNetnameLayer( int aLayer )
|
2013-07-08 16:46:04 +02:00
|
|
|
{
|
2024-11-16 11:26:59 -05:00
|
|
|
if( IsCopperLayer( aLayer ) || IsViaPadLayer( aLayer ) )
|
2017-03-12 23:19:33 -04:00
|
|
|
return NETNAMES_LAYER_INDEX( aLayer );
|
2013-07-08 16:46:04 +02:00
|
|
|
|
|
|
|
// Fallback
|
2014-06-24 11:17:18 -05:00
|
|
|
return Cmts_User;
|
2013-07-08 16:46:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-09-22 17:50:59 -04:00
|
|
|
* Test whether a layer is a netname layer.
|
|
|
|
*
|
2013-07-08 16:46:04 +02:00
|
|
|
* @param aLayer = Layer to test
|
|
|
|
* @return true if aLayer is a valid netname layer
|
|
|
|
*/
|
2021-07-22 00:14:56 +01:00
|
|
|
inline bool IsNetnameLayer( int aLayer )
|
2013-07-08 16:46:04 +02:00
|
|
|
{
|
2021-07-22 00:14:56 +01:00
|
|
|
return aLayer >= NETNAMES_LAYER_INDEX( F_Cu ) && aLayer < NETNAMES_LAYER_ID_END;
|
2013-07-08 16:46:04 +02:00
|
|
|
}
|
|
|
|
|
2014-06-29 08:05:51 -05:00
|
|
|
|
2022-11-05 12:00:56 +00:00
|
|
|
inline bool IsZoneFillLayer( int aLayer )
|
2020-07-11 13:42:00 -04:00
|
|
|
{
|
|
|
|
return aLayer >= LAYER_ZONE_START && aLayer <= LAYER_ZONE_END;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-12-28 10:36:39 -05:00
|
|
|
inline bool IsPadCopperLayer( int aLayer )
|
|
|
|
{
|
|
|
|
return aLayer >= LAYER_PAD_COPPER_START && aLayer <= LAYER_PAD_COPPER_END;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline bool IsViaCopperLayer( int aLayer )
|
|
|
|
{
|
|
|
|
return aLayer >= LAYER_VIA_COPPER_START && aLayer <= LAYER_VIA_COPPER_END;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-12-29 23:38:40 +08:00
|
|
|
inline bool IsClearanceLayer( int aLayer )
|
|
|
|
{
|
|
|
|
return aLayer >= LAYER_CLEARANCE_START && aLayer <= LAYER_CLEARANCE_END;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2025-03-29 13:07:58 +08:00
|
|
|
inline bool IsPointsLayer( int aLayer )
|
|
|
|
{
|
|
|
|
return aLayer >= LAYER_POINT_START && aLayer <= LAYER_POINT_END;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-17 18:43:20 -04:00
|
|
|
inline bool IsDCodeLayer( int aLayer )
|
|
|
|
{
|
2021-07-22 00:14:56 +01:00
|
|
|
return aLayer >= ( GERBVIEW_LAYER_ID_START + GERBER_DRAWLAYERS_COUNT )
|
|
|
|
&& aLayer < ( GERBVIEW_LAYER_ID_START + ( 2 * GERBER_DRAWLAYERS_COUNT ) );
|
2017-09-17 18:43:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2025-01-08 13:08:27 -05:00
|
|
|
/// Converts KiCad copper layer enum to an ordinal between the front and back layers.
|
2024-09-15 13:26:01 -04:00
|
|
|
inline size_t CopperLayerToOrdinal( PCB_LAYER_ID aLayer )
|
|
|
|
{
|
|
|
|
wxCHECK( IsCopperLayer( aLayer ), 0 );
|
|
|
|
|
|
|
|
switch( aLayer )
|
|
|
|
{
|
|
|
|
case F_Cu: return 0;
|
|
|
|
case B_Cu: return MAX_CU_LAYERS - 1;
|
|
|
|
default: return ( aLayer - B_Cu ) / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-15 18:49:56 -04:00
|
|
|
|
2024-11-16 09:27:31 -05:00
|
|
|
/**
|
2025-01-08 13:08:27 -05:00
|
|
|
* Retrieve a layer ID from an integer converted from a legacy (pre-V9) enum value.
|
2024-11-16 09:27:31 -05:00
|
|
|
*/
|
|
|
|
KICOMMON_API PCB_LAYER_ID BoardLayerFromLegacyId( int aLegacyId );
|
|
|
|
|
|
|
|
|
2025-03-17 21:23:39 +00:00
|
|
|
KICOMMON_API PCB_LAYER_ID Map3DLayerToPCBLayer( int aLayer );
|
|
|
|
KICOMMON_API int MapPCBLayerTo3DLayer( PCB_LAYER_ID aLayer );
|
2025-03-15 16:13:27 +00:00
|
|
|
|
|
|
|
|
2023-09-14 21:33:03 -04:00
|
|
|
KICOMMON_API PCB_LAYER_ID ToLAYER_ID( int aLayer );
|
2014-06-29 08:05:51 -05:00
|
|
|
|
2021-07-29 10:47:43 +01:00
|
|
|
#endif // LAYER_IDS_H
|