KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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 <lset.h>
26#include <settings/parameters.h>
27
28// Can be removed by refactoring PARAM_LAYER_PRESET
29#include <json_common.h>
30#include <math/box2.h>
31#include <glm/glm.hpp>
32
37
38
44{
47 bool text;
48 bool tracks;
49 bool vias;
50 bool pads;
51 bool graphics;
52 bool zones;
53 bool keepouts;
55 bool points;
57
59 {
60 lockedItems = true;
61 footprints = true;
62 text = true;
63 tracks = true;
64 vias = true;
65 pads = true;
66 graphics = true;
67 zones = true;
68 keepouts = true;
69 dimensions = true;
70 points = true;
71 otherItems = true;
72 }
73
77 bool Any()
78 {
79 return ( footprints || text || tracks || vias || pads || graphics || zones
81 }
82
86 bool All()
87 {
88 return ( footprints && text && tracks && vias && pads && graphics && zones
90 }
91
92 void SetAll( bool aState )
93 {
94 footprints = aState;
95 text = aState;
96 tracks = aState;
97 vias = aState;
98 pads = aState;
99 graphics = aState;
100 zones = aState;
101 keepouts = aState;
102 dimensions = aState;
103 points = aState;
104 otherItems = aState;
105 lockedItems = aState;
106 }
107};
108
118
130
138
141{
144};
145
148{
149 wxString mfg;
150 wxString MPN;
151 wxString dist;
152 wxString distPN;
153 wxString id;
154};
155
160{
161 LAYER_PRESET( const wxString& aName = wxS( "" ) ) :
162 name( aName ),
163 layers( LSET::AllLayersMask() ),
164 renderLayers( GAL_SET::DefaultVisible() ),
165 flipBoard( false ),
167 {
168 readOnly = false;
169 }
170
171 LAYER_PRESET( const wxString& aName, const LSET& aVisibleLayers, bool aFlipBoard ) :
172 name( aName ),
173 layers( aVisibleLayers ),
174 renderLayers( GAL_SET::DefaultVisible() ),
175 flipBoard( aFlipBoard ),
177 {
178 readOnly = false;
179 }
180
181 LAYER_PRESET( const wxString& aName, const LSET& aVisibleLayers, const GAL_SET& aVisibleObjects,
182 PCB_LAYER_ID aActiveLayer, bool aFlipBoard ) :
183 name( aName ),
184 layers( aVisibleLayers ),
185 renderLayers( aVisibleObjects ),
186 flipBoard( aFlipBoard ),
187 activeLayer( aActiveLayer )
188 {
189 readOnly = false;
190 }
191
192 bool LayersMatch( const LAYER_PRESET& aOther )
193 {
194 return aOther.layers == layers && aOther.renderLayers == renderLayers;
195 }
196
197 wxString name;
202 bool readOnly;
203};
204
205
206class KICOMMON_API PARAM_LAYER_PRESET : public PARAM_LAMBDA<nlohmann::json>
207{
208public:
209 PARAM_LAYER_PRESET( const std::string& aPath, std::vector<LAYER_PRESET>* aPresetList );
210
211 static void MigrateToV9Layers( nlohmann::json& aJson );
212
213 static void MigrateToNamedRenderLayers( nlohmann::json& aJson );
214
215private:
216 nlohmann::json presetsToJson();
217
218 void jsonToPresets( const nlohmann::json& aJson );
219
220 std::vector<LAYER_PRESET>* m_presets;
221};
222
223
225{
226 VIEWPORT( const wxString& aName = wxEmptyString ) :
227 name( aName )
228 { }
229
230 VIEWPORT( const wxString& aName, const BOX2D& aRect ) :
231 name( aName ),
232 rect( aRect )
233 { }
234
235 wxString name;
237};
238
239
240class KICOMMON_API PARAM_VIEWPORT : public PARAM_LAMBDA<nlohmann::json>
241{
242public:
243 PARAM_VIEWPORT( const std::string& aPath, std::vector<VIEWPORT>* aViewportList );
244
245private:
246 nlohmann::json viewportsToJson();
247
248 void jsonToViewports( const nlohmann::json& aJson );
249
250 std::vector<VIEWPORT>* m_viewports;
251};
252
253
255{
256 VIEWPORT3D( const wxString& aName = wxEmptyString ) :
257 name( aName )
258 { }
259
260 VIEWPORT3D( const wxString& aName, glm::mat4 aViewMatrix ) :
261 name( aName ),
262 matrix( std::move( aViewMatrix ) )
263 { }
264
265 wxString name;
266 glm::mat4 matrix;
267};
268
269
270class KICOMMON_API PARAM_VIEWPORT3D : public PARAM_LAMBDA<nlohmann::json>
271{
272public:
273 PARAM_VIEWPORT3D( const std::string& aPath, std::vector<VIEWPORT3D>* aViewportList );
274
275private:
276 nlohmann::json viewportsToJson();
277
278 void jsonToViewports( const nlohmann::json & aJson );
279
280 std::vector<VIEWPORT3D>* m_viewports;
281};
282
283
285{
286public:
291
293 m_layerA( a ), m_layerB( b )
294 {
295 }
296
297 PCB_LAYER_ID GetLayerA() const { return m_layerA; }
298 PCB_LAYER_ID GetLayerB() const { return m_layerB; }
299
300 void SetLayerA( PCB_LAYER_ID aLayer ) { m_layerA = aLayer; }
301 void SetLayerB( PCB_LAYER_ID aLayer ) { m_layerB = aLayer; }
302
306 bool HasSameLayers( const LAYER_PAIR& aOther ) const
307 {
308 return ( m_layerA == aOther.m_layerA && m_layerB == aOther.m_layerB )
309 || ( m_layerA == aOther.m_layerB && m_layerB == aOther.m_layerA );
310 }
311
312private:
315};
316
317
322{
323public:
324 LAYER_PAIR_INFO( LAYER_PAIR aPair, bool aEnabled, std::optional<wxString> aName ) :
325 m_pair( std::move( aPair ) ), m_enabled( aEnabled), m_name( std::move( aName ) )
326 {
327 }
328
329 const LAYER_PAIR& GetLayerPair() const { return m_pair; }
330
331 const std::optional<wxString>& GetName() const { return m_name; }
332
333 void SetName( const wxString& aNewName ) { m_name = aNewName; }
334 void UnsetName() { m_name = std::nullopt; }
335
336 bool IsEnabled() const { return m_enabled; }
337 void SetEnabled( bool aNewEnabled ) { m_enabled = aNewEnabled; }
338
339private:
341 bool m_enabled = true;
342 std::optional<wxString> m_name;
343};
344
345
346class KICOMMON_API PARAM_LAYER_PAIRS : public PARAM_LAMBDA<nlohmann::json>
347{
348public:
349 PARAM_LAYER_PAIRS( const std::string& aPath, std::vector<LAYER_PAIR_INFO>& m_layerPairInfos );
350
351private:
352 nlohmann::json layerPairsToJson();
353
354 void jsonToLayerPairs( const nlohmann::json& aJson );
355
356 std::vector<LAYER_PAIR_INFO>& m_layerPairInfos;
357};
358
359
396
397
398#endif // KICAD_BOARD_PROJECT_SETTINGS_H
@ NORMAL
Use all material properties from model file.
Definition 3d_enums.h:72
HIGH_CONTRAST_MODE
Determine how inactive layers should be displayed.
@ HIDDEN
Inactive layers are hidden.
@ DIMMED
Inactive layers are dimmed (old high-contrast mode)
@ RATSNEST
Net/netclass colors are shown on ratsnest lines only.
@ VISIBLE
Ratsnest lines are drawn to items on visible layers only.
BOX2< VECTOR2D > BOX2D
Definition box2.h:923
#define OFF
Helper for storing and iterating over GAL_LAYER_IDs.
Definition layer_ids.h:402
const LAYER_PAIR & GetLayerPair() const
void SetName(const wxString &aNewName)
const std::optional< wxString > & GetName() const
std::optional< wxString > m_name
void SetEnabled(bool aNewEnabled)
LAYER_PAIR_INFO(LAYER_PAIR aPair, bool aEnabled, std::optional< wxString > aName)
PCB_LAYER_ID GetLayerA() const
PCB_LAYER_ID m_layerA
void SetLayerB(PCB_LAYER_ID aLayer)
PCB_LAYER_ID GetLayerB() const
LAYER_PAIR(PCB_LAYER_ID a, PCB_LAYER_ID b)
PCB_LAYER_ID m_layerB
void SetLayerA(PCB_LAYER_ID aLayer)
bool HasSameLayers(const LAYER_PAIR &aOther) const
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
PARAM_LAMBDA(const std::string &aJsonPath, std::function< nlohmann::json()> aGetter, std::function< void(nlohmann::json)> aSetter, nlohmann::json aDefault, bool aReadOnly=false)
Definition parameters.h:298
nlohmann::json layerPairsToJson()
void jsonToLayerPairs(const nlohmann::json &aJson)
std::vector< LAYER_PAIR_INFO > & m_layerPairInfos
PARAM_LAYER_PAIRS(const std::string &aPath, std::vector< LAYER_PAIR_INFO > &m_layerPairInfos)
static void MigrateToV9Layers(nlohmann::json &aJson)
static void MigrateToNamedRenderLayers(nlohmann::json &aJson)
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)
#define KICOMMON_API
Definition kicommon.h:28
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
@ UNSELECTED_LAYER
Definition layer_ids.h:62
@ UNDEFINED_LAYER
Definition layer_ids.h:61
STL namespace.
wxString mfg
Manufacturer name column.
wxString MPN
Manufacturer part number column.
wxString id
Internal ID column.
wxString dist
Distributor name column.
wxString distPN
Distributor part number column.
GAL_SET renderLayers
Render layers (e.g. object types) that are visible.
wxString name
A name for this layer set.
LAYER_PRESET(const wxString &aName=wxS(""))
bool flipBoard
True if the flip board is enabled.
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.
LAYER_PRESET(const wxString &aName, const LSET &aVisibleLayers, bool aFlipBoard)
LAYER_PRESET(const wxString &aName, const LSET &aVisibleLayers, const GAL_SET &aVisibleObjects, PCB_LAYER_ID aActiveLayer, bool aFlipBoard)
std::vector< wxString > expanded_rows
std::vector< wxString > custom_group_rules
bool otherItems
Anything not fitting one of the above categories.
bool graphics
Graphic lines, shapes, polygons.
bool footprints
Allow selecting entire footprints.
bool text
Text (free or attached to a footprint)
bool lockedItems
Allow selecting locked items.
VIEWPORT3D(const wxString &aName=wxEmptyString)
VIEWPORT3D(const wxString &aName, glm::mat4 aViewMatrix)
VIEWPORT(const wxString &aName, const BOX2D &aRect)
VIEWPORT(const wxString &aName=wxEmptyString)