KiCad PCB EDA Suite
board_project_settings.h
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 (C) 2020 Jon Evans <jon@craftyjon.com>
5  * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef KICAD_BOARD_PROJECT_SETTINGS_H
22 #define KICAD_BOARD_PROJECT_SETTINGS_H
23 
25 #include <settings/parameters.h>
26 
27 // Can be removed by refactoring PARAM_LAYER_PRESET
28 #include <nlohmann/json.hpp>
29 
41 {
42  bool lockedItems;
43  bool footprints;
44  bool text;
45  bool tracks;
46  bool vias;
47  bool pads;
48  bool graphics;
49  bool zones;
50  bool keepouts;
51  bool dimensions;
52  bool otherItems;
53 
55  {
56  lockedItems = true;
57  footprints = true;
58  text = true;
59  tracks = true;
60  vias = true;
61  pads = true;
62  graphics = true;
63  zones = true;
64  keepouts = true;
65  dimensions = true;
66  otherItems = true;
67  }
68 
72  bool Any()
73  {
74  return ( footprints || text || tracks || vias || pads || graphics || zones
75  || keepouts || dimensions || otherItems );
76  }
77 
81  bool All()
82  {
83  return ( footprints && text && tracks && vias && pads && graphics && zones
84  && keepouts && dimensions && otherItems );
85  }
86 };
87 
92 {
93  NORMAL = 0,
94  DIMMED,
95  HIDDEN
96 };
97 
100 {
101  SHOW_FILLED,
104 };
105 
107 enum class NET_COLOR_MODE
108 {
109  OFF,
110  RATSNEST,
111  ALL
112 };
113 
115 enum class RATSNEST_MODE
116 {
117  ALL,
118  VISIBLE
119 };
120 
125 {
126  LAYER_PRESET( const wxString& aName = wxEmptyString ) :
127  name( aName ),
129  {
132  readOnly = false;
133  }
134 
135  LAYER_PRESET( const wxString& aName, const LSET& aVisibleLayers ) :
136  name( aName ),
137  layers( aVisibleLayers ),
139  {
141  readOnly = false;
142  }
143 
144  LAYER_PRESET( const wxString& aName, const LSET& aVisibleLayers, const GAL_SET& aVisibleObjects,
145  PCB_LAYER_ID aActiveLayer ) :
146  name( aName ),
147  layers( aVisibleLayers ),
148  renderLayers( aVisibleObjects ),
149  activeLayer( aActiveLayer )
150  {
151  readOnly = false;
152  }
153 
154  bool LayersMatch( const LAYER_PRESET& aOther )
155  {
156  return aOther.layers == layers && aOther.renderLayers == renderLayers;
157  }
158 
159  wxString name;
163  bool readOnly;
164 };
165 
166 
167 class PARAM_LAYER_PRESET : public PARAM_LAMBDA<nlohmann::json>
168 {
169 public:
170  PARAM_LAYER_PRESET( const std::string& aPath, std::vector<LAYER_PRESET>* aPresetList );
171 
172 private:
174 
175  void jsonToPresets( const nlohmann::json& aJson );
176 
177  std::vector<LAYER_PRESET>* m_presets;
178 };
179 
180 #endif // KICAD_BOARD_PROJECT_SETTINGS_H
A saved set of layers that are visible.
Filled polygons are shown.
LAYER_PRESET(const wxString &aName, const LSET &aVisibleLayers)
bool otherItems
Anything not fitting one of the above categories.
Like a normal param, but with custom getter and setter functions.
Definition: parameters.h:296
Ratsnest lines are drawn to items on visible layers only.
Outlines of filled polygons are shown.
Net/netclass colors are shown on all net copper.
Net/netclass colors are shown on ratsnest lines only.
LAYER_PRESET(const wxString &aName=wxEmptyString)
std::vector< LAYER_PRESET > * m_presets
nlohmann::json json
Definition: gerbview.cpp:41
GAL_SET renderLayers
Render layers (e.g. object types) that are visible.
PCB_LAYER_ID activeLayer
Optional layer to set active when this preset is loaded.
Ratsnest lines are drawn to items on all layers (default)
wxString name
A name for this layer set.
bool LayersMatch(const LAYER_PRESET &aOther)
Inactive layers are dimmed (old high-contrast mode)
PCB_LAYER_ID
A quick note on layer IDs:
LSET is a set of PCB_LAYER_IDs.
bool text
Text (free or attached to a footprint)
bool readOnly
True if this is a read-only (built-in) preset.
bool dimensions
Dimension items.
bool graphics
Graphic lines, shapes, polygons.
Inactive layers are shown normally (no high-contrast mode)
HIGH_CONTRAST_MODE
Determine how inactive layers should be displayed.
Helper for storing and iterating over GAL_LAYER_IDs.
static GAL_SET DefaultVisible()
Definition: lset.cpp:933
static LSET AllLayersMask()
Definition: lset.cpp:787
This file contains data structures that are saved in the project file or project local settings file ...
LSET layers
Board layers that are visible.
bool footprints
Allow selecting entire footprints.
void jsonToPresets(const nlohmann::json &aJson)
PARAM_LAYER_PRESET(const std::string &aPath, std::vector< LAYER_PRESET > *aPresetList)
bool lockedItems
Allow selecting locked items.
Board layer functions and definitions.
Only the zone outline is shown.
Net (and netclass) colors are not shown.
nlohmann::json presetsToJson()
LAYER_PRESET(const wxString &aName, const LSET &aVisibleLayers, const GAL_SET &aVisibleObjects, PCB_LAYER_ID aActiveLayer)
Inactive layers are hidden.