KiCad PCB EDA Suite
Loading...
Searching...
No Matches
layer_settings_utils.cpp
Go to the documentation of this file.
1/*
2* This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <boost/algorithm/string/case_conv.hpp>
21#include <magic_enum.hpp>
22
23#include <core/arraydim.h>
25
26
28{
29 static const GAL_LAYER_ID layers[] = {
50 };
51
52 static const GAL_SET saved( layers, arrayDim( layers ) );
53 return saved;
54}
55
56
58{
59 switch( aLayer )
60 {
81 }
82
83 wxCHECK_MSG( false, GAL_LAYER_ID_END, "Unhandled layer in RenderLayerFromVisibilityLayer" );
84}
85
86
87std::optional<VISIBILITY_LAYER> VisibilityLayerFromRenderLayer( GAL_LAYER_ID aLayerId )
88{
89 switch( aLayerId )
90 {
111 default:
112 break;
113 }
114
115 return std::nullopt;
116}
117
118
119std::optional<GAL_LAYER_ID> RenderLayerFromVisbilityString( const std::string& aLayer )
120{
121 if( std::optional<VISIBILITY_LAYER> val =
122 magic_enum::enum_cast<VISIBILITY_LAYER>( aLayer, magic_enum::case_insensitive ) )
123 {
124 return RenderLayerFromVisibilityLayer( *val );
125 }
126
127 return std::nullopt;
128}
129
130
132{
133 std::string ret( magic_enum::enum_name<VISIBILITY_LAYER>( aLayerId ) );
134 boost::algorithm::to_lower( ret );
135 return ret;
136}
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
Helper for storing and iterating over GAL_LAYER_IDs.
Definition: layer_ids.h:355
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition: layer_ids.h:191
@ LAYER_GRID
Definition: layer_ids.h:216
@ LAYER_LOCKED_ITEM_SHADOW
Shadow layer for locked items.
Definition: layer_ids.h:269
@ LAYER_CONFLICTS_SHADOW
Shadow layer for items flagged conflicting.
Definition: layer_ids.h:272
@ LAYER_FOOTPRINTS_FR
Show footprints on front.
Definition: layer_ids.h:221
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
Definition: layer_ids.h:240
@ LAYER_DRAW_BITMAPS
Draw images.
Definition: layer_ids.h:246
@ LAYER_FP_REFERENCES
Show footprints references (when texts are visible).
Definition: layer_ids.h:228
@ LAYER_DRC_EXCLUSION
Layer for DRC markers which have been individually excluded.
Definition: layer_ids.h:266
@ LAYER_ZONES
Control for copper zone opacity/visibility (color ignored).
Definition: layer_ids.h:257
@ LAYER_SHAPES
Copper graphic shape opacity/visibility (color ignored).
Definition: layer_ids.h:275
@ LAYER_PADS
Meta control for all pads opacity/visibility (color ignored).
Definition: layer_ids.h:254
@ LAYER_DRC_WARNING
Layer for DRC markers with #SEVERITY_WARNING.
Definition: layer_ids.h:263
@ GAL_LAYER_ID_END
Definition: layer_ids.h:313
@ LAYER_TRACKS
Definition: layer_ids.h:229
@ LAYER_RATSNEST
Definition: layer_ids.h:215
@ LAYER_FP_TEXT
Definition: layer_ids.h:202
@ LAYER_FOOTPRINTS_BK
Show footprints on back.
Definition: layer_ids.h:222
@ LAYER_ANCHOR
Anchor of items having an anchor point (texts, footprints).
Definition: layer_ids.h:210
@ LAYER_FP_VALUES
Show footprints values (when texts are visible).
Definition: layer_ids.h:225
@ LAYER_DRC_ERROR
Layer for DRC markers with #SEVERITY_ERROR.
Definition: layer_ids.h:239
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
Definition: layer_ids.h:195
std::optional< VISIBILITY_LAYER > VisibilityLayerFromRenderLayer(GAL_LAYER_ID aLayerId)
GAL_SET UserVisbilityLayers()
The set of GAL_LAYER_IDs that correspond to VISIBILITY_LAYERS.
std::string VisibilityLayerToString(VISIBILITY_LAYER aLayerId)
GAL_LAYER_ID RenderLayerFromVisibilityLayer(VISIBILITY_LAYER aLayer)
std::optional< GAL_LAYER_ID > RenderLayerFromVisbilityString(const std::string &aLayer)
VISIBILITY_LAYER
The set of things that can have visibility settings stored in a project file (for example in a view p...