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 
24 #include <layer_ids.h>
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,
103 
104  // Debug modes
105 
108 };
109 
111 enum class NET_COLOR_MODE
112 {
113  OFF,
114  RATSNEST,
115  ALL
116 };
117 
119 enum class RATSNEST_MODE
120 {
121  ALL,
122  VISIBLE
123 };
124 
129 {
130  LAYER_PRESET( const wxString& aName = wxEmptyString ) :
131  name( aName ),
133  {
136  readOnly = false;
137  }
138 
139  LAYER_PRESET( const wxString& aName, const LSET& aVisibleLayers ) :
140  name( aName ),
141  layers( aVisibleLayers ),
143  {
145  readOnly = false;
146  }
147 
148  LAYER_PRESET( const wxString& aName, const LSET& aVisibleLayers, const GAL_SET& aVisibleObjects,
149  PCB_LAYER_ID aActiveLayer ) :
150  name( aName ),
151  layers( aVisibleLayers ),
152  renderLayers( aVisibleObjects ),
153  activeLayer( aActiveLayer )
154  {
155  readOnly = false;
156  }
157 
158  bool LayersMatch( const LAYER_PRESET& aOther )
159  {
160  return aOther.layers == layers && aOther.renderLayers == renderLayers;
161  }
162 
163  wxString name;
167  bool readOnly;
168 };
169 
170 
171 class PARAM_LAYER_PRESET : public PARAM_LAMBDA<nlohmann::json>
172 {
173 public:
174  PARAM_LAYER_PRESET( const std::string& aPath, std::vector<LAYER_PRESET>* aPresetList );
175 
176 private:
178 
179  void jsonToPresets( const nlohmann::json& aJson );
180 
181  std::vector<LAYER_PRESET>* m_presets;
182 };
183 
184 #endif // KICAD_BOARD_PROJECT_SETTINGS_H
A saved set of layers that are visible.
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:280
Ratsnest lines are drawn to items on visible layers only.
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)
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:502
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.
Definition: layer_ids.h:278
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.
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:64
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.