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 <[email protected]>
5 * Copyright (C) 2020-2022 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#include <math/box2.h>
30#include <glm/glm.hpp>
31
43{
46 bool text;
47 bool tracks;
48 bool vias;
49 bool pads;
50 bool graphics;
51 bool zones;
52 bool keepouts;
55
57 {
58 lockedItems = true;
59 footprints = true;
60 text = true;
61 tracks = true;
62 vias = true;
63 pads = true;
64 graphics = true;
65 zones = true;
66 keepouts = true;
67 dimensions = true;
68 otherItems = true;
69 }
70
74 bool Any()
75 {
76 return ( footprints || text || tracks || vias || pads || graphics || zones
78 }
79
83 bool All()
84 {
85 return ( footprints && text && tracks && vias && pads && graphics && zones
87 }
88};
89
94{
95 NORMAL = 0,
96 DIMMED,
97 HIDDEN
98};
99
102{
105
106 // Debug modes
107
110};
111
114{
115 OFF,
116 RATSNEST,
117 ALL
118};
119
122{
123 ALL,
124 VISIBLE
125};
126
131{
132 LAYER_PRESET( const wxString& aName = wxEmptyString ) :
133 name( aName ),
135 {
138 readOnly = false;
139 }
140
141 LAYER_PRESET( const wxString& aName, const LSET& aVisibleLayers ) :
142 name( aName ),
143 layers( aVisibleLayers ),
145 {
147 readOnly = false;
148 }
149
150 LAYER_PRESET( const wxString& aName, const LSET& aVisibleLayers, const GAL_SET& aVisibleObjects,
151 PCB_LAYER_ID aActiveLayer ) :
152 name( aName ),
153 layers( aVisibleLayers ),
154 renderLayers( aVisibleObjects ),
155 activeLayer( aActiveLayer )
156 {
157 readOnly = false;
158 }
159
160 bool LayersMatch( const LAYER_PRESET& aOther )
161 {
162 return aOther.layers == layers && aOther.renderLayers == renderLayers;
163 }
164
165 wxString name;
169 bool readOnly;
170};
171
172
173class PARAM_LAYER_PRESET : public PARAM_LAMBDA<nlohmann::json>
174{
175public:
176 PARAM_LAYER_PRESET( const std::string& aPath, std::vector<LAYER_PRESET>* aPresetList );
177
178private:
180
181 void jsonToPresets( const nlohmann::json& aJson );
182
183 std::vector<LAYER_PRESET>* m_presets;
184};
185
186
188{
189 VIEWPORT( const wxString& aName = wxEmptyString ) :
190 name( aName )
191 { }
192
193 VIEWPORT( const wxString& aName, const BOX2D& aRect ) :
194 name( aName ),
195 rect( aRect )
196 { }
197
198 wxString name;
200};
201
202
203class PARAM_VIEWPORT : public PARAM_LAMBDA<nlohmann::json>
204{
205public:
206 PARAM_VIEWPORT( const std::string& aPath, std::vector<VIEWPORT>* aViewportList );
207
208private:
210
211 void jsonToViewports( const nlohmann::json& aJson );
212
213 std::vector<VIEWPORT>* m_viewports;
214};
215
216
218{
219 VIEWPORT3D( const wxString& aName = wxEmptyString ) :
220 name( aName )
221 { }
222
223 VIEWPORT3D( const wxString& aName, glm::mat4 aViewMatrix ) :
224 name( aName ),
225 matrix( aViewMatrix )
226 { }
227
228 wxString name;
229 glm::mat4 matrix;
230};
231
232
233class PARAM_VIEWPORT3D : public PARAM_LAMBDA<nlohmann::json>
234{
235public:
236 PARAM_VIEWPORT3D( const std::string& aPath, std::vector<VIEWPORT3D>* aViewportList );
237
238private:
240
241 void jsonToViewports( const nlohmann::json & aJson );
242
243 std::vector<VIEWPORT3D>* m_viewports;
244};
245
246
247#endif // KICAD_BOARD_PROJECT_SETTINGS_H
@ NORMAL
Use all material properties from model file.
HIGH_CONTRAST_MODE
Determine how inactive layers should be displayed.
@ DIMMED
Inactive layers are dimmed (old high-contrast mode)
@ RATSNEST
Net/netclass colors are shown on ratsnest lines only.
#define OFF
Helper for storing and iterating over GAL_LAYER_IDs.
Definition: layer_ids.h:296
static GAL_SET DefaultVisible()
Definition: lset.cpp:960
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:532
static LSET AllLayersMask()
Definition: lset.cpp:808
Like a normal param, but with custom getter and setter functions.
Definition: parameters.h:282
nlohmann::json presetsToJson()
PARAM_LAYER_PRESET(const std::string &aPath, std::vector< LAYER_PRESET > *aPresetList)
std::vector< LAYER_PRESET > * m_presets
void jsonToPresets(const nlohmann::json &aJson)
void jsonToViewports(const nlohmann::json &aJson)
PARAM_VIEWPORT3D(const std::string &aPath, std::vector< VIEWPORT3D > *aViewportList)
nlohmann::json viewportsToJson()
std::vector< VIEWPORT3D > * m_viewports
std::vector< VIEWPORT > * m_viewports
PARAM_VIEWPORT(const std::string &aPath, std::vector< VIEWPORT > *aViewportList)
nlohmann::json viewportsToJson()
void jsonToViewports(const nlohmann::json &aJson)
nlohmann::json json
Definition: gerbview.cpp:44
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ UNSELECTED_LAYER
Definition: layer_ids.h:61
A saved set of layers that are visible.
LAYER_PRESET(const wxString &aName=wxEmptyString)
LAYER_PRESET(const wxString &aName, const LSET &aVisibleLayers, const GAL_SET &aVisibleObjects, PCB_LAYER_ID aActiveLayer)
LAYER_PRESET(const wxString &aName, const LSET &aVisibleLayers)
GAL_SET renderLayers
Render layers (e.g. object types) that are visible.
wxString name
A name for this layer set.
LSET layers
Board layers that are visible.
bool readOnly
True if this is a read-only (built-in) preset.
bool LayersMatch(const LAYER_PRESET &aOther)
PCB_LAYER_ID activeLayer
Optional layer to set active when this preset is loaded.
This file contains data structures that are saved in the project file or project local settings file ...
bool graphics
Graphic lines, shapes, polygons.
bool text
Text (free or attached to a footprint)
bool lockedItems
Allow selecting locked items.
bool footprints
Allow selecting entire footprints.
bool dimensions
Dimension items.
bool otherItems
Anything not fitting one of the above categories.
VIEWPORT3D(const wxString &aName=wxEmptyString)
VIEWPORT3D(const wxString &aName, glm::mat4 aViewMatrix)
VIEWPORT(const wxString &aName, const BOX2D &aRect)
VIEWPORT(const wxString &aName=wxEmptyString)