2013-03-30 23:41:08 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2014-06-30 15:03:20 +00:00
|
|
|
* Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2013-03-30 23:41:08 +00:00
|
|
|
* Copyright (C) 2010 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2022-03-24 14:10:47 +00:00
|
|
|
* Copyright (C) 2007-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-03-30 23:41:08 +00: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 09:47:43 +00:00
|
|
|
#ifndef LAYER_IDS_H
|
|
|
|
#define LAYER_IDS_H
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2020-10-24 03:33:04 +00:00
|
|
|
#include <set>
|
2014-06-24 16:17:18 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <bitset>
|
2021-10-11 17:06:40 +00:00
|
|
|
#include <stdexcept>
|
2014-06-24 16:17:18 +00:00
|
|
|
#include <wx/string.h>
|
2010-01-29 20:36:12 +00:00
|
|
|
|
2013-03-30 17:24:04 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
/**
|
|
|
|
* A quick note on layer IDs:
|
|
|
|
*
|
|
|
|
* The layers are stored in separate enums so that certain functions can
|
2020-09-22 21:50:59 +00:00
|
|
|
* take in the enums as data types and don't have to know about layers from
|
2017-03-13 03:19:33 +00: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 17:24:04 +00:00
|
|
|
|
2013-09-11 15:30:21 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* This is the definition of all layers used in Pcbnew.
|
2017-03-13 03:19:33 +00:00
|
|
|
*
|
2020-09-22 21:50:59 +00:00
|
|
|
* The PCB layer types are fixed at value 0 through LAYER_ID_COUNT to ensure compatibility
|
|
|
|
* with legacy board files.
|
2013-09-11 15:30:21 +00:00
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
enum PCB_LAYER_ID: int
|
2013-09-11 15:30:21 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
UNDEFINED_LAYER = -1,
|
|
|
|
UNSELECTED_LAYER = -2,
|
|
|
|
|
2018-09-28 08:10:08 +00:00
|
|
|
PCBNEW_LAYER_ID_START = 0,
|
|
|
|
F_Cu = PCBNEW_LAYER_ID_START,
|
2014-06-24 16:17:18 +00:00
|
|
|
In1_Cu,
|
|
|
|
In2_Cu,
|
|
|
|
In3_Cu,
|
|
|
|
In4_Cu,
|
|
|
|
In5_Cu,
|
|
|
|
In6_Cu,
|
|
|
|
In7_Cu,
|
|
|
|
In8_Cu,
|
|
|
|
In9_Cu,
|
|
|
|
In10_Cu,
|
|
|
|
In11_Cu,
|
|
|
|
In12_Cu,
|
|
|
|
In13_Cu,
|
|
|
|
In14_Cu,
|
|
|
|
In15_Cu,
|
|
|
|
In16_Cu,
|
|
|
|
In17_Cu,
|
|
|
|
In18_Cu,
|
|
|
|
In19_Cu,
|
|
|
|
In20_Cu,
|
|
|
|
In21_Cu,
|
|
|
|
In22_Cu,
|
|
|
|
In23_Cu,
|
|
|
|
In24_Cu,
|
|
|
|
In25_Cu,
|
|
|
|
In26_Cu,
|
|
|
|
In27_Cu,
|
|
|
|
In28_Cu,
|
|
|
|
In29_Cu,
|
|
|
|
In30_Cu,
|
|
|
|
B_Cu, // 31
|
|
|
|
|
2014-07-06 16:59:26 +00:00
|
|
|
B_Adhes,
|
2014-06-24 16:17:18 +00:00
|
|
|
F_Adhes,
|
2014-07-05 20:52:24 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
B_Paste,
|
|
|
|
F_Paste,
|
2014-07-05 20:52:24 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
B_SilkS,
|
|
|
|
F_SilkS,
|
2014-07-05 20:52:24 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
B_Mask,
|
2020-09-22 21:50:59 +00:00
|
|
|
F_Mask, // 39
|
2014-07-05 20:52:24 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
Dwgs_User,
|
|
|
|
Cmts_User,
|
|
|
|
Eco1_User,
|
|
|
|
Eco2_User,
|
|
|
|
Edge_Cuts,
|
2020-09-22 21:50:59 +00:00
|
|
|
Margin, // 45
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
B_CrtYd,
|
2014-07-05 20:52:24 +00:00
|
|
|
F_CrtYd,
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
B_Fab,
|
2020-09-22 21:50:59 +00:00
|
|
|
F_Fab, // 49
|
|
|
|
|
|
|
|
// User definable layers.
|
|
|
|
User_1,
|
|
|
|
User_2,
|
|
|
|
User_3,
|
|
|
|
User_4,
|
|
|
|
User_5,
|
|
|
|
User_6,
|
|
|
|
User_7,
|
|
|
|
User_8,
|
|
|
|
User_9,
|
|
|
|
|
|
|
|
Rescue, // 59
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2020-09-22 21:50:59 +00:00
|
|
|
// Four reserved layers (60 - 63) for future expansion within the 64 bit integer limit.
|
2018-12-07 00:24:27 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID_COUNT
|
|
|
|
};
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
#define MAX_CU_LAYERS (B_Cu - F_Cu + 1)
|
|
|
|
|
2022-03-16 23:48:24 +00:00
|
|
|
/**
|
|
|
|
* Enum used during connectivity building to ensure we do not query connectivity while building
|
|
|
|
* the database
|
|
|
|
*/
|
|
|
|
enum class FLASHING
|
|
|
|
{
|
|
|
|
DEFAULT, // Flashing follows connectivity
|
|
|
|
ALWAYS_FLASHED, // Always flashed for connectivity
|
|
|
|
NEVER_FLASHED, // Never flashed for connectivity
|
|
|
|
};
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
/// Dedicated layers for net names used in Pcbnew
|
|
|
|
enum NETNAMES_LAYER_ID: int
|
|
|
|
{
|
|
|
|
|
|
|
|
NETNAMES_LAYER_ID_START = PCB_LAYER_ID_COUNT,
|
|
|
|
|
|
|
|
/// Reserved space for board layer netnames
|
|
|
|
|
|
|
|
NETNAMES_LAYER_ID_RESERVED = NETNAMES_LAYER_ID_START + PCB_LAYER_ID_COUNT,
|
|
|
|
|
|
|
|
/// Additional netnames layers (not associated with a PCB layer)
|
|
|
|
|
|
|
|
LAYER_PAD_FR_NETNAMES,
|
|
|
|
LAYER_PAD_BK_NETNAMES,
|
2021-01-30 14:41:31 +00:00
|
|
|
LAYER_PAD_NETNAMES,
|
|
|
|
LAYER_VIA_NETNAMES,
|
2017-03-13 03:19:33 +00:00
|
|
|
|
|
|
|
NETNAMES_LAYER_ID_END
|
2016-01-08 22:28:21 +00:00
|
|
|
};
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
/// Macro for obtaining netname layer for a given PCB layer
|
|
|
|
#define NETNAMES_LAYER_INDEX( layer ) ( NETNAMES_LAYER_ID_START + layer )
|
|
|
|
|
2021-02-21 18:41:43 +00:00
|
|
|
/**
|
|
|
|
* GAL layers are "virtual" layers, i.e. not tied into design data.
|
|
|
|
* Some layers here are shared between applications.
|
|
|
|
*
|
2022-09-07 10:07:00 +00:00
|
|
|
* NOTE: Be very careful where you add new layers here. Layers up to GAL_LAYER_ID_BITMASK_END
|
2021-02-21 18:41:43 +00: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
|
|
|
|
* 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
|
|
|
|
* existing visibility settings will be disrupted.
|
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
enum GAL_LAYER_ID: int
|
|
|
|
{
|
|
|
|
GAL_LAYER_ID_START = NETNAMES_LAYER_ID_END,
|
|
|
|
|
2021-02-21 18:41:43 +00:00
|
|
|
LAYER_VIAS = GAL_LAYER_ID_START + 0, ///< Meta control for all vias opacity/visibility
|
|
|
|
LAYER_VIA_MICROVIA = GAL_LAYER_ID_START + 1, ///< to draw micro vias
|
|
|
|
LAYER_VIA_BBLIND = GAL_LAYER_ID_START + 2, ///< to draw blind/buried vias
|
|
|
|
LAYER_VIA_THROUGH = GAL_LAYER_ID_START + 3, ///< to draw usual through hole vias
|
|
|
|
LAYER_NON_PLATEDHOLES = GAL_LAYER_ID_START + 4, ///< handle color for not plated holes (holes, not pads)
|
2021-10-22 20:12:57 +00:00
|
|
|
LAYER_MOD_TEXT = GAL_LAYER_ID_START + 5,
|
|
|
|
// LAYER_MOD_TEXT_BK deprecated + 6,
|
2021-02-21 18:41:43 +00:00
|
|
|
LAYER_MOD_TEXT_INVISIBLE = GAL_LAYER_ID_START + 7, ///< text marked as invisible
|
|
|
|
LAYER_ANCHOR = GAL_LAYER_ID_START + 8, ///< anchor of items having an anchor point (texts, footprints)
|
|
|
|
LAYER_PAD_FR = GAL_LAYER_ID_START + 9, ///< smd pads, front layer
|
|
|
|
LAYER_PAD_BK = GAL_LAYER_ID_START + 10, ///< smd pads, back layer
|
|
|
|
LAYER_RATSNEST = GAL_LAYER_ID_START + 11,
|
|
|
|
LAYER_GRID = GAL_LAYER_ID_START + 12,
|
|
|
|
LAYER_GRID_AXES = GAL_LAYER_ID_START + 13,
|
2022-09-07 10:07:00 +00:00
|
|
|
// LAYER_NO_CONNECTS deprecated + 14, ///< show a marker on pads with no nets
|
2021-02-21 18:41:43 +00:00
|
|
|
LAYER_MOD_FR = GAL_LAYER_ID_START + 15, ///< show footprints on front
|
|
|
|
LAYER_MOD_BK = GAL_LAYER_ID_START + 16, ///< show footprints on back
|
2021-06-09 19:32:58 +00:00
|
|
|
LAYER_MOD_VALUES = GAL_LAYER_ID_START + 17, ///< show footprints values (when texts are visible)
|
|
|
|
LAYER_MOD_REFERENCES = GAL_LAYER_ID_START + 18, ///< show footprints references (when texts are visible)
|
2021-02-21 18:41:43 +00:00
|
|
|
LAYER_TRACKS = GAL_LAYER_ID_START + 19,
|
|
|
|
LAYER_PADS_TH = GAL_LAYER_ID_START + 20, ///< multilayer pads, usually with holes
|
|
|
|
LAYER_PAD_PLATEDHOLES = GAL_LAYER_ID_START + 21, ///< to draw pad holes (plated)
|
|
|
|
LAYER_VIA_HOLES = GAL_LAYER_ID_START + 22, ///< to draw via holes (pad holes do not use this layer)
|
|
|
|
LAYER_DRC_ERROR = GAL_LAYER_ID_START + 23, ///< layer for drc markers with SEVERITY_ERROR
|
2021-02-22 16:37:43 +00:00
|
|
|
LAYER_DRAWINGSHEET = GAL_LAYER_ID_START + 24, ///< drawingsheet frame and titleblock
|
2021-02-21 18:41:43 +00:00
|
|
|
LAYER_GP_OVERLAY = GAL_LAYER_ID_START + 25, ///< general purpose overlay
|
|
|
|
LAYER_SELECT_OVERLAY = GAL_LAYER_ID_START + 26, ///< currently 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, ///< to handle and draw images bitmaps
|
2017-03-13 03:19:33 +00:00
|
|
|
|
2022-09-07 10:07:00 +00:00
|
|
|
/// This is the end of the layers used for visibility bit masks in legacy board files
|
2021-02-21 18:41:43 +00: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.
|
|
|
|
|
|
|
|
LAYER_PADS = GAL_LAYER_ID_START + 32, ///< Meta control for all pads opacity/visibility (color ignored)
|
|
|
|
LAYER_ZONES = GAL_LAYER_ID_START + 33, ///< Control for copper zone opacity/visibility (color ignored)
|
|
|
|
|
|
|
|
LAYER_PAD_HOLEWALLS = GAL_LAYER_ID_START + 34,
|
|
|
|
LAYER_VIA_HOLEWALLS = GAL_LAYER_ID_START + 35,
|
|
|
|
LAYER_DRC_WARNING = GAL_LAYER_ID_START + 36, ///< layer for drc markers with SEVERITY_WARNING
|
|
|
|
LAYER_DRC_EXCLUSION = GAL_LAYER_ID_START + 37, ///< layer for drc markers which have been individually excluded
|
|
|
|
LAYER_MARKER_SHADOWS = GAL_LAYER_ID_START + 38, ///< shadows for drc markers
|
|
|
|
|
2022-03-06 19:11:03 +00:00
|
|
|
LAYER_LOCKED_ITEM_SHADOW = GAL_LAYER_ID_START + 39, ///< shadow layer for locked items
|
|
|
|
|
2022-05-20 09:08:33 +00:00
|
|
|
LAYER_CONFLICTS_SHADOW = GAL_LAYER_ID_START + 40, ///< shadow layer for items flagged conficting
|
|
|
|
|
2021-02-21 18:41:43 +00:00
|
|
|
// Add layers below this point that do not have visibility controls, so don't need explicit
|
|
|
|
// enum values
|
2017-03-13 03:19:33 +00:00
|
|
|
|
2021-02-22 16:37:43 +00:00
|
|
|
LAYER_DRAWINGSHEET_PAGE1, ///< for drawingsheetEditor previewing
|
|
|
|
LAYER_DRAWINGSHEET_PAGEn, ///< for drawingsheetEditor previewing
|
2019-05-24 20:09:42 +00:00
|
|
|
|
2022-03-24 14:10:47 +00:00
|
|
|
LAYER_PAGE_LIMITS, ///< color for drawing the page extents (visibility stored in
|
|
|
|
///< PCBNEW_SETTINGS::m_ShowPageLimits)
|
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
/// Virtual layers for stacking zones and tracks on a given copper layer
|
|
|
|
LAYER_ZONE_START,
|
|
|
|
LAYER_ZONE_END = LAYER_ZONE_START + PCB_LAYER_ID_COUNT,
|
|
|
|
|
2022-06-27 18:07:52 +00:00
|
|
|
/// Virtual layers for background images per board layer
|
|
|
|
LAYER_BITMAP_START,
|
|
|
|
LAYER_BITMAP_END = LAYER_BITMAP_START + PCB_LAYER_ID_COUNT,
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
GAL_LAYER_ID_END
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Use this macro to convert a GAL layer to a 0-indexed offset from LAYER_VIAS
|
|
|
|
#define GAL_LAYER_INDEX( x ) ( x - GAL_LAYER_ID_START )
|
|
|
|
|
2022-06-27 18:07:52 +00:00
|
|
|
/// Macros for getting the extra layers for a given board layer
|
|
|
|
#define BITMAP_LAYER_FOR( boardLayer ) ( LAYER_BITMAP_START + boardLayer )
|
|
|
|
#define ZONE_LAYER_FOR( boardLayer ) ( LAYER_ZONE_START + boardLayer )
|
2020-07-11 17:42:00 +00:00
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
constexpr int GAL_LAYER_ID_COUNT = GAL_LAYER_ID_END - GAL_LAYER_ID_START;
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
inline GAL_LAYER_ID operator++( GAL_LAYER_ID& a )
|
|
|
|
{
|
|
|
|
a = GAL_LAYER_ID( int( a ) + 1 );
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2020-07-11 17:42:00 +00: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 );
|
|
|
|
}
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
/// Used for via types
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
typedef std::bitset<GAL_LAYER_ID_COUNT> GAL_BASE_SET;
|
|
|
|
|
2020-07-11 17:40:23 +00:00
|
|
|
/// Helper for storing and iterating over GAL_LAYER_IDs
|
2020-07-11 17:42:00 +00:00
|
|
|
class GAL_SET : public GAL_BASE_SET
|
2020-07-11 17:40:23 +00:00
|
|
|
{
|
2020-07-11 17:42:00 +00:00
|
|
|
private:
|
|
|
|
static constexpr int start = static_cast<int>( GAL_LAYER_ID_START );
|
|
|
|
|
2020-07-11 17:40:23 +00: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 17:42:00 +00:00
|
|
|
GAL_SET( const GAL_LAYER_ID* aArray, unsigned aCount );
|
|
|
|
|
2020-07-11 17:40:23 +00:00
|
|
|
GAL_SET& set()
|
|
|
|
{
|
2020-07-11 17:42:00 +00:00
|
|
|
GAL_BASE_SET::set();
|
2020-07-11 17:40:23 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
GAL_SET& set( int aPos, bool aVal = true )
|
2020-07-11 17:40:23 +00:00
|
|
|
{
|
2020-07-11 17:42:00 +00:00
|
|
|
GAL_BASE_SET::set( aPos, aVal );
|
2020-07-11 17:40:23 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
GAL_SET& set( GAL_LAYER_ID aPos, bool aVal = true )
|
2020-07-11 17:40:23 +00:00
|
|
|
{
|
2020-10-05 10:41:14 +00:00
|
|
|
GAL_BASE_SET::set( static_cast<std::size_t>( aPos ) - start, aVal );
|
2020-07-11 17:42:00 +00:00
|
|
|
return *this;
|
|
|
|
}
|
2020-07-11 17:40:23 +00:00
|
|
|
|
2020-07-11 17:42:00 +00: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 17:40:23 +00:00
|
|
|
}
|
2020-07-11 17:42:00 +00:00
|
|
|
|
|
|
|
std::vector<GAL_LAYER_ID> Seq() const;
|
|
|
|
|
|
|
|
static GAL_SET DefaultVisible();
|
2020-07-11 17:40:23 +00:00
|
|
|
};
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
/// Eeschema drawing layers
|
|
|
|
enum SCH_LAYER_ID: int
|
|
|
|
{
|
|
|
|
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 20:05:37 +00:00
|
|
|
LAYER_INTERSHEET_REFS,
|
|
|
|
LAYER_NETCLASS_REFS,
|
2017-03-13 03:19:33 +00:00
|
|
|
LAYER_DEVICE,
|
|
|
|
LAYER_NOTES,
|
2022-07-07 04:51:23 +00:00
|
|
|
LAYER_PRIVATE_NOTES,
|
2021-07-17 19:56:18 +00:00
|
|
|
LAYER_NOTES_BACKGROUND,
|
2017-03-13 03:19:33 +00:00
|
|
|
LAYER_PIN,
|
|
|
|
LAYER_SHEET,
|
|
|
|
LAYER_SHEETNAME,
|
|
|
|
LAYER_SHEETFILENAME,
|
2020-03-06 12:05:21 +00:00
|
|
|
LAYER_SHEETFIELDS,
|
2017-03-13 03:19:33 +00:00
|
|
|
LAYER_SHEETLABEL,
|
|
|
|
LAYER_NOCONNECT,
|
2021-12-06 18:50:00 +00:00
|
|
|
LAYER_DANGLING,
|
2017-03-13 03:19:33 +00:00
|
|
|
LAYER_ERC_WARN,
|
|
|
|
LAYER_ERC_ERR,
|
2021-11-05 21:16:26 +00:00
|
|
|
LAYER_ERC_EXCLUSION,
|
2017-03-13 03:19:33 +00:00
|
|
|
LAYER_DEVICE_BACKGROUND,
|
2018-10-21 12:50:31 +00:00
|
|
|
LAYER_SHEET_BACKGROUND,
|
2017-03-13 03:19:33 +00:00
|
|
|
LAYER_SCHEMATIC_GRID,
|
2020-03-22 00:03:59 +00:00
|
|
|
LAYER_SCHEMATIC_GRID_AXES,
|
2017-03-13 03:19:33 +00:00
|
|
|
LAYER_SCHEMATIC_BACKGROUND,
|
2018-09-17 23:19:58 +00:00
|
|
|
LAYER_SCHEMATIC_CURSOR,
|
2022-05-14 15:49:53 +00:00
|
|
|
LAYER_HOVERED,
|
2017-03-13 03:19:33 +00:00
|
|
|
LAYER_BRIGHTENED,
|
2018-08-30 19:44:10 +00:00
|
|
|
LAYER_HIDDEN,
|
2019-07-30 01:57:41 +00: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-23 01:33:57 +00:00
|
|
|
LAYER_BUS_JUNCTION,
|
2020-08-09 21:39:45 +00:00
|
|
|
LAYER_SCHEMATIC_AUX_ITEMS,
|
2021-09-29 00:26:47 +00:00
|
|
|
LAYER_SCHEMATIC_ANCHOR,
|
2017-03-13 03:19:33 +00: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// number of draw layers in Gerbview
|
2019-04-10 13:40:01 +00:00
|
|
|
#define GERBER_DRAWLAYERS_COUNT PCB_LAYER_ID_COUNT
|
2017-03-13 03:19:33 +00:00
|
|
|
|
|
|
|
/// GerbView draw layers
|
|
|
|
enum GERBVIEW_LAYER_ID: int
|
|
|
|
{
|
|
|
|
GERBVIEW_LAYER_ID_START = SCH_LAYER_ID_END,
|
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
/// GerbView draw layers and d-code layers
|
|
|
|
GERBVIEW_LAYER_ID_RESERVED = GERBVIEW_LAYER_ID_START + ( 2 * GERBER_DRAWLAYERS_COUNT ),
|
2017-03-13 03:19:33 +00: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-13 03:19:33 +00:00
|
|
|
|
|
|
|
GERBVIEW_LAYER_ID_END
|
|
|
|
};
|
|
|
|
|
2017-09-17 22:43:20 +00: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-13 01:44:19 +00:00
|
|
|
|
|
|
|
/// 3D Viewer virtual layers for color settings
|
|
|
|
enum LAYER_3D_ID : int
|
|
|
|
{
|
2020-05-06 01:45:48 +00:00
|
|
|
LAYER_3D_START = GERBVIEW_LAYER_ID_END,
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
LAYER_3D_BACKGROUND_BOTTOM,
|
|
|
|
LAYER_3D_BACKGROUND_TOP,
|
|
|
|
LAYER_3D_BOARD,
|
|
|
|
LAYER_3D_COPPER,
|
|
|
|
LAYER_3D_SILKSCREEN_BOTTOM,
|
|
|
|
LAYER_3D_SILKSCREEN_TOP,
|
2021-07-27 21:24:18 +00:00
|
|
|
LAYER_3D_SOLDERMASK_BOTTOM,
|
|
|
|
LAYER_3D_SOLDERMASK_TOP,
|
2020-01-13 01:44:19 +00:00
|
|
|
LAYER_3D_SOLDERPASTE,
|
|
|
|
|
|
|
|
LAYER_3D_END = LAYER_3D_SOLDERPASTE
|
|
|
|
};
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
/// Must update this if you add any enums after GerbView!
|
2020-05-06 01:45:48 +00:00
|
|
|
#define LAYER_ID_COUNT LAYER_3D_END
|
2017-03-13 03:19:33 +00:00
|
|
|
|
|
|
|
|
2020-04-24 01:55:20 +00:00
|
|
|
/**
|
|
|
|
* Returns the string equivalent of a given layer
|
|
|
|
* @param aLayer is a valid layer ID
|
|
|
|
*/
|
|
|
|
wxString LayerName( int aLayer );
|
2020-02-03 16:46:58 +00:00
|
|
|
|
|
|
|
|
2017-03-13 03:19:33 +00: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 16:17:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
/// A sequence of layers, a sequence provides a certain order.
|
2017-03-13 03:19:33 +00:00
|
|
|
typedef std::vector<PCB_LAYER_ID> BASE_SEQ;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2013-09-11 15:30:21 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs. A sequence provides
|
2014-06-24 16:17:18 +00:00
|
|
|
* a certain order.
|
|
|
|
* <p>
|
|
|
|
* It can also be used as an iterator:
|
|
|
|
* <code>
|
|
|
|
*
|
|
|
|
* for( LSEQ cu_stack = aSet.CuStack(); cu_stack; ++cu_stack )
|
2014-06-29 18:09:32 +00:00
|
|
|
* {
|
2014-06-24 16:17:18 +00:00
|
|
|
* layer_id = *cu_stack;
|
2014-06-29 18:09:32 +00:00
|
|
|
* :
|
|
|
|
* things to do with layer_id;
|
|
|
|
* }
|
2014-06-24 16:17:18 +00:00
|
|
|
*
|
|
|
|
* </code>
|
2013-09-11 15:30:21 +00:00
|
|
|
*/
|
2014-06-24 16:17:18 +00:00
|
|
|
class LSEQ : public BASE_SEQ
|
2013-09-11 15:30:21 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
unsigned m_index;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
LSEQ() :
|
|
|
|
m_index( 0 )
|
|
|
|
{}
|
|
|
|
|
|
|
|
template <class InputIterator>
|
2017-02-23 12:16:54 +00:00
|
|
|
LSEQ( InputIterator aStart, InputIterator aEnd ) :
|
|
|
|
BASE_SEQ( aStart, aEnd ), m_index( 0 )
|
2014-06-24 16:17:18 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
void Rewind() { m_index = 0; }
|
|
|
|
|
|
|
|
void operator ++ () { ++m_index; } // returns nothing, used in simple statements only.
|
|
|
|
|
|
|
|
void operator ++ (int) { ++m_index; }
|
|
|
|
|
|
|
|
operator bool () { return m_index < size(); }
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID operator * () const
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
|
|
|
return at( m_index ); // throws std::out_of_range
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
typedef std::bitset<PCB_LAYER_ID_COUNT> BASE_SET;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2013-09-11 15:30:21 +00:00
|
|
|
|
2013-04-04 21:35:01 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* LSET is a set of PCB_LAYER_IDs. It can be converted to numerous purpose LSEQs using
|
2014-06-24 16:17:18 +00:00
|
|
|
* 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.
|
2013-04-04 21:35:01 +00:00
|
|
|
*/
|
2014-06-24 16:17:18 +00:00
|
|
|
class LSET : public BASE_SET
|
2013-04-04 21:35:01 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
public:
|
|
|
|
|
2014-06-29 18:09:32 +00:00
|
|
|
// 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.
|
2017-03-13 03:19:33 +00:00
|
|
|
// Remember LSET( PCB_LAYER_ID(0) ) sets bit 0, so "LSET s = 0;" is illegal
|
2020-09-22 21:50:59 +00:00
|
|
|
// to prevent that surprise. Therefore LSET's constructor suite is significantly
|
2014-06-29 18:09:32 +00:00
|
|
|
// 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.
|
|
|
|
|
2014-06-29 13:05:51 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Create an empty (cleared) set.
|
2014-06-29 13:05:51 +00:00
|
|
|
*/
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET() :
|
2014-06-29 18:09:32 +00:00
|
|
|
BASE_SET() // all bits are set to zero in BASE_SET()
|
|
|
|
{
|
|
|
|
}
|
2013-04-04 21:35:01 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET( const BASE_SET& aOther ) :
|
|
|
|
BASE_SET( aOther )
|
2013-04-04 21:35:01 +00:00
|
|
|
{
|
|
|
|
}
|
2010-01-29 20:36:12 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Take a PCB_LAYER_ID and sets that bit. This makes the following code into
|
2014-06-29 18:09:32 +00:00
|
|
|
* a bug:
|
2014-06-29 13:05:51 +00:00
|
|
|
*
|
|
|
|
* <code> LSET s = 0; </code>
|
|
|
|
*
|
2014-06-29 18:09:32 +00:00
|
|
|
* Instead use:
|
2014-06-29 13:05:51 +00:00
|
|
|
*
|
|
|
|
* <code>
|
|
|
|
* LSET s;
|
|
|
|
* </code>
|
|
|
|
*
|
|
|
|
* for an empty set.
|
2014-06-24 16:17:18 +00:00
|
|
|
*/
|
2020-09-22 21:50:59 +00:00
|
|
|
LSET( PCB_LAYER_ID aLayer ) : // PCB_LAYER_ID deliberately excludes int and relatives
|
2014-06-29 20:33:29 +00:00
|
|
|
BASE_SET()
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
|
|
|
set( aLayer );
|
|
|
|
}
|
2010-01-29 20:36:12 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Create an array or LSEQ.
|
2014-06-24 16:17:18 +00:00
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
LSET( const PCB_LAYER_ID* aArray, unsigned aCount );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Take one or more PCB_LAYER_IDs in the argument list to construct the set. Typically
|
|
|
|
* only used in static construction.
|
2014-06-29 18:09:32 +00:00
|
|
|
*
|
2017-03-13 03:19:33 +00:00
|
|
|
* @param aIdCount is the number of PCB_LAYER_IDs which follow.
|
2014-06-29 18:09:32 +00:00
|
|
|
* @param aFirst is the first included in @a aIdCount and must always be present, and can
|
2017-03-13 03:19:33 +00:00
|
|
|
* be followed by any number of additional PCB_LAYER_IDs so long as @a aIdCount accurately
|
2014-06-29 18:09:32 +00:00
|
|
|
* reflects the count.
|
2017-03-18 02:43:54 +00:00
|
|
|
*
|
|
|
|
* Parameter is 'int' to avoid va_start undefined behavior.
|
2014-06-24 16:17:18 +00:00
|
|
|
*/
|
2020-09-22 21:50:59 +00:00
|
|
|
LSET( unsigned aIdCount, int aFirst, ... ); // args chosen to prevent LSET( int ) from compiling
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2020-04-20 21:43:55 +00:00
|
|
|
/**
|
|
|
|
* 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 )
|
|
|
|
{
|
2021-10-11 17:06:40 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
return test( aLayer );
|
|
|
|
}
|
|
|
|
catch( std::out_of_range& )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2020-04-20 21:43:55 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return the fixed name association with aLayerId.
|
2014-06-24 16:17:18 +00:00
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
static const wxChar* Name( PCB_LAYER_ID aLayerId );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a complete set of internal copper layers which is all Cu layers
|
2014-06-24 16:17:18 +00:00
|
|
|
* except F_Cu and B_Cu.
|
|
|
|
*/
|
|
|
|
static LSET InternalCuMask();
|
|
|
|
|
2020-05-22 20:40:53 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a complete set of all top assembly layers which is all F_SilkS and F_Mask
|
2020-05-22 20:40:53 +00:00
|
|
|
*/
|
|
|
|
static LSET FrontAssembly();
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a complete set of all bottom assembly layers which is all B_SilkS and B_Mask
|
2020-05-22 20:40:53 +00:00
|
|
|
*/
|
|
|
|
static LSET BackAssembly();
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a mask holding the requested number of Cu PCB_LAYER_IDs.
|
2014-06-24 16:17:18 +00:00
|
|
|
*/
|
|
|
|
static LSET AllCuMask( int aCuLayerCount = MAX_CU_LAYERS );
|
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a mask holding the Front and Bottom layers.
|
2016-09-19 11:01:36 +00:00
|
|
|
*/
|
|
|
|
static LSET ExternalCuMask();
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a mask holding all layer minus CU layers.
|
2014-06-24 16:17:18 +00:00
|
|
|
*/
|
|
|
|
static LSET AllNonCuMask();
|
|
|
|
|
|
|
|
static LSET AllLayersMask();
|
|
|
|
|
2014-08-02 10:29:10 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a mask holding all technical layers (no CU layer) on front side.
|
2014-08-02 10:29:10 +00:00
|
|
|
*/
|
2014-06-24 16:17:18 +00:00
|
|
|
static LSET FrontTechMask();
|
2014-08-02 10:29:10 +00:00
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a mask holding technical layers used in a board fabrication
|
2016-09-19 11:01:36 +00:00
|
|
|
* (no CU layer) on front side.
|
|
|
|
*/
|
|
|
|
static LSET FrontBoardTechMask();
|
|
|
|
|
2014-08-02 10:29:10 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a mask holding all technical layers (no CU layer) on back side.
|
2014-08-02 10:29:10 +00:00
|
|
|
*/
|
2014-06-24 16:17:18 +00:00
|
|
|
static LSET BackTechMask();
|
2016-09-19 11:01:36 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a mask holding technical layers used in a board fabrication
|
2016-09-19 11:01:36 +00:00
|
|
|
* (no CU layer) on Back side.
|
|
|
|
*/
|
|
|
|
static LSET BackBoardTechMask();
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a mask holding all technical layers (no CU layer) on both side.
|
2016-09-19 11:01:36 +00:00
|
|
|
*/
|
2014-06-24 16:17:18 +00:00
|
|
|
static LSET AllTechMask();
|
|
|
|
|
2016-09-19 11:01:36 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a mask holding board technical layers (no CU layer) on both side.
|
2016-09-19 11:01:36 +00:00
|
|
|
*/
|
|
|
|
static LSET AllBoardTechMask();
|
|
|
|
|
2014-08-02 10:29:10 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a mask holding all technical layers and the external CU layer on front side.
|
2014-08-02 10:29:10 +00:00
|
|
|
*/
|
2014-06-24 16:17:18 +00:00
|
|
|
static LSET FrontMask();
|
|
|
|
|
2014-08-02 10:29:10 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a mask holding all technical layers and the external CU layer on back side.
|
2014-08-02 10:29:10 +00:00
|
|
|
*/
|
2014-06-24 16:17:18 +00:00
|
|
|
static LSET BackMask();
|
|
|
|
|
2022-10-25 11:08:32 +00:00
|
|
|
static LSET SideSpecificMask();
|
2022-10-24 15:22:27 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
static LSET UserMask();
|
|
|
|
|
2021-02-01 16:03:05 +00:00
|
|
|
/**
|
|
|
|
* Return a mask holding all layers which are physically realized. Equivalent to the copper
|
|
|
|
* layers + the board tech mask.
|
|
|
|
*/
|
|
|
|
static LSET PhysicalLayersMask();
|
|
|
|
|
2018-08-26 17:58:27 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a mask with all of the allowable user defined layers.
|
|
|
|
*/
|
|
|
|
static LSET UserDefinedLayers();
|
|
|
|
|
|
|
|
/**
|
2018-08-26 17:58:27 +00:00
|
|
|
* Layers which are not allowed within footprint definitions. Currently internal
|
2020-02-27 17:42:46 +00:00
|
|
|
* copper layers and Margin.
|
2018-08-26 17:58:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
static LSET ForbiddenFootprintLayers();
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a sequence of copper layers in starting from the front/top
|
2014-06-24 16:17:18 +00:00
|
|
|
* and extending to the back/bottom. This specific sequence is depended upon
|
|
|
|
* in numerous places.
|
|
|
|
*/
|
|
|
|
LSEQ CuStack() const;
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* 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.
|
2014-06-24 16:17:18 +00:00
|
|
|
*/
|
|
|
|
LSEQ Technicals( LSET aSubToOmit = LSET() ) const;
|
|
|
|
|
|
|
|
/// *_User layers.
|
|
|
|
LSEQ Users() const;
|
|
|
|
|
2018-01-12 03:32:14 +00:00
|
|
|
/// Returns the technical and user layers in the order shown in layer widget
|
|
|
|
LSEQ TechAndUserUIOrder() const;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LSEQ UIOrder() const;
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return an LSEQ from the union of this LSET and a desired sequence. The LSEQ
|
2014-06-24 16:17:18 +00:00
|
|
|
* 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
|
2017-03-13 03:19:33 +00:00
|
|
|
* contain PCB_LAYER_IDs which are present in this set.
|
2014-06-24 16:17:18 +00:00
|
|
|
* @param aCount is the length of aWishListSequence array.
|
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
LSEQ Seq( const PCB_LAYER_ID* aWishListSequence, unsigned aCount ) const;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2022-03-29 20:08:02 +00:00
|
|
|
LSEQ Seq( const LSEQ& aSequence ) const;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a LSEQ from this LSET in ascending PCB_LAYER_ID order. Each LSEQ
|
2017-03-13 03:19:33 +00:00
|
|
|
* element will be in the same sequence as in PCB_LAYER_ID and only present
|
2014-06-24 16:17:18 +00:00
|
|
|
* 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;
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return the sequence that is typical for a bottom-to-top stack-up.
|
2014-08-10 14:15:02 +00:00
|
|
|
* For instance, to plot multiple layers in a single image, the top layers output last.
|
|
|
|
*/
|
|
|
|
LSEQ SeqStackupBottom2Top() const;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a hex string showing contents of this LSEQ.
|
2014-06-24 16:17:18 +00:00
|
|
|
*/
|
|
|
|
std::string FmtHex() const;
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Convert the output of FmtHex() and replaces this set's values
|
2014-06-24 16:17:18 +00:00
|
|
|
* 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 );
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Return a binary string showing contents of this LSEQ.
|
2014-06-24 16:17:18 +00:00
|
|
|
*/
|
|
|
|
std::string FmtBin() const;
|
|
|
|
|
|
|
|
/**
|
2017-03-13 03:19:33 +00:00
|
|
|
* Find the first set PCB_LAYER_ID. Returns UNDEFINED_LAYER if more
|
2014-06-24 16:17:18 +00:00
|
|
|
* than one is set or UNSELECTED_LAYER if none is set.
|
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID ExtractLayer() const;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
private:
|
2014-06-25 17:01:50 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
/// Take this off the market, it may not be used because of LSET( PCB_LAYER_ID ).
|
2014-06-29 20:33:29 +00:00
|
|
|
LSET( unsigned long __val )
|
|
|
|
{
|
|
|
|
// not usable, it's private.
|
|
|
|
}
|
2010-01-29 20:36:12 +00:00
|
|
|
};
|
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2010-01-29 20:36:12 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Test whether a given integer is a valid layer index, i.e. can
|
2017-03-13 03:19:33 +00:00
|
|
|
* be safely put in a PCB_LAYER_ID
|
2020-09-22 21:50:59 +00: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-21 23:14:56 +00:00
|
|
|
inline bool IsValidLayer( int aLayerId )
|
2013-04-09 16:00:46 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
return unsigned( aLayerId ) < PCB_LAYER_ID_COUNT;
|
2013-04-09 16:00:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Test whether a layer is a valid layer for Pcbnew
|
|
|
|
*
|
2013-04-09 16:00:46 +00:00
|
|
|
* @param aLayer = Layer to test
|
2020-09-22 21:50:59 +00:00
|
|
|
* @return true if aLayer is a layer valid in Pcbnew
|
2013-04-09 16:00:46 +00:00
|
|
|
*/
|
2021-07-21 23:14:56 +00:00
|
|
|
inline bool IsPcbLayer( int aLayer )
|
2010-01-29 20:36:12 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
return aLayer >= F_Cu && aLayer < PCB_LAYER_ID_COUNT;
|
2010-01-29 20:36:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Tests whether a layer is a copper layer.
|
|
|
|
*
|
2014-06-24 16:17:18 +00:00
|
|
|
* @param aLayerId = Layer to test
|
2013-09-11 15:30:21 +00:00
|
|
|
* @return true if aLayer is a valid copper layer
|
2010-01-29 20:36:12 +00:00
|
|
|
*/
|
2021-07-21 23:14:56 +00:00
|
|
|
inline bool IsCopperLayer( int aLayerId )
|
2010-01-29 20:36:12 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
return aLayerId >= F_Cu && aLayerId <= B_Cu;
|
2010-01-29 20:36:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Test whether a layer is a non copper layer.
|
|
|
|
*
|
2014-06-24 16:17:18 +00:00
|
|
|
* @param aLayerId = Layer to test
|
2013-04-09 16:00:46 +00:00
|
|
|
* @return true if aLayer is a non copper layer
|
2010-01-29 20:36:12 +00:00
|
|
|
*/
|
2021-07-21 23:14:56 +00:00
|
|
|
inline bool IsNonCopperLayer( int aLayerId )
|
2010-01-29 20:36:12 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
return aLayerId > B_Cu && aLayerId <= PCB_LAYER_ID_COUNT;
|
2014-03-08 19:04:23 +00:00
|
|
|
}
|
|
|
|
|
2021-01-27 14:52:22 +00:00
|
|
|
/**
|
|
|
|
* Tests whether a layer is a copper layer, optionally including synthetic copper layers such
|
|
|
|
* as LAYER_VIA_THROUGH, LAYER_PAD_FR, etc.
|
|
|
|
*
|
|
|
|
* @param aLayerId
|
|
|
|
* @param aIncludeSyntheticCopperLayers
|
|
|
|
* @return
|
|
|
|
*/
|
2021-07-21 23:14:56 +00: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-21 23:14:56 +00: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-21 23:14:56 +00: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;
|
|
|
|
}
|
|
|
|
|
2014-03-08 19:04:23 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Test whether a layer is a non copper and a non tech layer.
|
|
|
|
*
|
2014-06-24 16:17:18 +00:00
|
|
|
* @param aLayerId = Layer to test
|
2014-03-08 19:04:23 +00:00
|
|
|
* @return true if aLayer is a user layer
|
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
inline bool IsUserLayer( PCB_LAYER_ID aLayerId )
|
2014-03-08 19:04:23 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
return aLayerId >= Dwgs_User && aLayerId <= Eco2_User;
|
2010-01-29 20:36:12 +00:00
|
|
|
}
|
|
|
|
|
2013-04-04 21:35:01 +00:00
|
|
|
|
2021-07-21 23:14:56 +00: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 21:35:01 +00:00
|
|
|
|
2013-09-11 15:30:21 +00:00
|
|
|
/**
|
2013-04-04 21:35:01 +00:00
|
|
|
* Layer classification: check if it's a front layer
|
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
inline bool IsFrontLayer( PCB_LAYER_ID aLayerId )
|
2013-04-04 21:35:01 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00: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 21:35:01 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2013-09-11 15:30:21 +00:00
|
|
|
/**
|
2013-04-04 21:35:01 +00:00
|
|
|
* Layer classification: check if it's a back layer
|
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
inline bool IsBackLayer( PCB_LAYER_ID aLayerId )
|
2013-04-04 21:35:01 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00: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 15:22:27 +00:00
|
|
|
return false;
|
2014-06-24 16:17:18 +00:00
|
|
|
}
|
2013-04-04 21:35:01 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2013-04-05 19:04:58 +00:00
|
|
|
/**
|
|
|
|
* @return the layer number after flipping an item
|
2015-12-27 15:51:13 +00:00
|
|
|
* some (not all) layers: external copper, and paired layers( Mask, Paste, solder ... )
|
2013-04-05 19:04:58 +00:00
|
|
|
* are swapped between front and back sides
|
2015-12-27 15:51:13 +00:00
|
|
|
* internal layers are flipped only if the copper layers count is known
|
2017-06-15 09:28:36 +00:00
|
|
|
* @param aLayerId = the PCB_LAYER_ID to flip
|
2015-12-27 15:51:13 +00:00
|
|
|
* @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 19:04:58 +00:00
|
|
|
*/
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID FlipLayer( PCB_LAYER_ID aLayerId, int aCopperLayersCount = 0 );
|
2013-04-05 19:04:58 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Calculate the mask layer when flipping a footprint.
|
|
|
|
*
|
2013-04-05 19:04:58 +00:00
|
|
|
* BACK and FRONT copper layers, mask, paste, solder layers are swapped
|
2015-12-27 15:51:13 +00:00
|
|
|
* 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
|
2013-04-05 19:04:58 +00:00
|
|
|
*/
|
2015-12-27 15:51:13 +00:00
|
|
|
LSET FlipLayerMask( LSET aMask, int aCopperLayersCount = 0 );
|
2013-04-04 21:35:01 +00:00
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
|
2013-07-08 14:46:04 +00:00
|
|
|
/**
|
|
|
|
* Returns a netname layer corresponding to the given layer.
|
|
|
|
*/
|
2014-06-24 16:17:18 +00:00
|
|
|
inline int GetNetnameLayer( int aLayer )
|
2013-07-08 14:46:04 +00:00
|
|
|
{
|
|
|
|
if( IsCopperLayer( aLayer ) )
|
2017-03-13 03:19:33 +00:00
|
|
|
return NETNAMES_LAYER_INDEX( aLayer );
|
2017-11-29 08:48:41 +00:00
|
|
|
else if( aLayer == LAYER_PADS_TH )
|
2021-01-30 14:41:31 +00:00
|
|
|
return LAYER_PAD_NETNAMES;
|
2017-03-13 03:19:33 +00:00
|
|
|
else if( aLayer == LAYER_PAD_FR )
|
|
|
|
return LAYER_PAD_FR_NETNAMES;
|
|
|
|
else if( aLayer == LAYER_PAD_BK )
|
|
|
|
return LAYER_PAD_BK_NETNAMES;
|
2021-02-01 16:03:05 +00:00
|
|
|
else if( IsViaPadLayer( aLayer ) )
|
2021-01-30 14:41:31 +00:00
|
|
|
return LAYER_VIA_NETNAMES;
|
2013-07-08 14:46:04 +00:00
|
|
|
|
|
|
|
// Fallback
|
2014-06-24 16:17:18 +00:00
|
|
|
return Cmts_User;
|
2013-07-08 14:46:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Test whether a layer is a netname layer.
|
|
|
|
*
|
2013-07-08 14:46:04 +00:00
|
|
|
* @param aLayer = Layer to test
|
|
|
|
* @return true if aLayer is a valid netname layer
|
|
|
|
*/
|
2021-07-21 23:14:56 +00:00
|
|
|
inline bool IsNetnameLayer( int aLayer )
|
2013-07-08 14:46:04 +00:00
|
|
|
{
|
2021-07-21 23:14:56 +00:00
|
|
|
return aLayer >= NETNAMES_LAYER_INDEX( F_Cu ) && aLayer < NETNAMES_LAYER_ID_END;
|
2013-07-08 14:46:04 +00:00
|
|
|
}
|
|
|
|
|
2014-06-29 13:05:51 +00:00
|
|
|
|
2021-07-21 23:14:56 +00:00
|
|
|
inline bool IsZoneLayer( int aLayer )
|
2020-07-11 17:42:00 +00:00
|
|
|
{
|
|
|
|
return aLayer >= LAYER_ZONE_START && aLayer <= LAYER_ZONE_END;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
inline bool IsDCodeLayer( int aLayer )
|
|
|
|
{
|
2021-07-21 23:14:56 +00:00
|
|
|
return aLayer >= ( GERBVIEW_LAYER_ID_START + GERBER_DRAWLAYERS_COUNT )
|
|
|
|
&& aLayer < ( GERBVIEW_LAYER_ID_START + ( 2 * GERBER_DRAWLAYERS_COUNT ) );
|
2017-09-17 22:43:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-15 22:49:56 +00:00
|
|
|
/**
|
2020-09-22 21:50:59 +00:00
|
|
|
* Checks if the given layer is "net copper", meaning it is eligible for net coloring.
|
|
|
|
*
|
2020-08-15 22:49:56 +00:00
|
|
|
* @param aLayer is the layer to test
|
|
|
|
* @return true if the layer is one that participates in net coloring
|
|
|
|
*/
|
2021-07-21 23:14:56 +00:00
|
|
|
inline bool IsNetCopperLayer( int aLayer )
|
2020-08-15 22:49:56 +00:00
|
|
|
{
|
2021-07-21 23:14:56 +00:00
|
|
|
static std::set<int> netCopperLayers =
|
2020-08-15 22:49:56 +00:00
|
|
|
{
|
2021-07-21 23:14:56 +00:00
|
|
|
LAYER_PAD_FR,
|
|
|
|
LAYER_PAD_BK,
|
|
|
|
LAYER_PADS_TH,
|
|
|
|
LAYER_PAD_HOLEWALLS,
|
|
|
|
LAYER_VIA_THROUGH,
|
|
|
|
LAYER_VIA_BBLIND,
|
|
|
|
LAYER_VIA_MICROVIA,
|
|
|
|
LAYER_VIA_HOLEWALLS
|
2020-08-15 22:49:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return IsCopperLayer( aLayer ) || netCopperLayers.count( aLayer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID ToLAYER_ID( int aLayer );
|
2014-06-29 13:05:51 +00:00
|
|
|
|
2021-07-29 09:47:43 +00:00
|
|
|
#endif // LAYER_IDS_H
|