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 <nlohmann/json.hpp>
30#include <math/box2.h>
31#include <glm/glm.hpp>
32
44{
47 bool text;
48 bool tracks;
49 bool vias;
50 bool pads;
51 bool graphics;
52 bool zones;
53 bool keepouts;
56
58 {
59 lockedItems = true;
60 footprints = true;
61 text = true;
62 tracks = true;
63 vias = true;
64 pads = true;
65 graphics = true;
66 zones = true;
67 keepouts = true;
68 dimensions = true;
69 otherItems = true;
70 }
71
75 bool Any()
76 {
77 return ( footprints || text || tracks || vias || pads || graphics || zones
78 || keepouts || dimensions || otherItems );
79 }
80
84 bool All()
85 {
86 return ( footprints && text && tracks && vias && pads && graphics && zones
87 && keepouts && dimensions && otherItems );
88 }
89};
90
95{
96 NORMAL = 0,
97 DIMMED,
98 HIDDEN
99};
100
103{
106
107 // Debug modes
108
111};
112
115{
116 OFF,
117 RATSNEST,
118 ALL
119};
120
123{
124 ALL,
125 VISIBLE
126};
127
130{
131 wxString mfg;
132 wxString MPN;
133 wxString dist;
134 wxString distPN;
135 wxString id;
136};
137
142{
143 LAYER_PRESET( const wxString& aName = wxS( "" ) ) :
144 name( aName ),
145 layers( LSET::AllLayersMask() ),
146 renderLayers( GAL_SET::DefaultVisible() ),
147 flipBoard( false ),
148 activeLayer( UNSELECTED_LAYER )
149 {
150 readOnly = false;
151 }
152
153 LAYER_PRESET( const wxString& aName, const LSET& aVisibleLayers, bool aFlipBoard ) :
154 name( aName ),
155 layers( aVisibleLayers ),
156 renderLayers( GAL_SET::DefaultVisible() ),
157 flipBoard( aFlipBoard ),
158 activeLayer( UNSELECTED_LAYER )
159 {
160 readOnly = false;
161 }
162
163 LAYER_PRESET( const wxString& aName, const LSET& aVisibleLayers, const GAL_SET& aVisibleObjects,
164 PCB_LAYER_ID aActiveLayer, bool aFlipBoard ) :
165 name( aName ),
166 layers( aVisibleLayers ),
167 renderLayers( aVisibleObjects ),
168 flipBoard( aFlipBoard ),
169 activeLayer( aActiveLayer )
170 {
171 readOnly = false;
172 }
173
174 bool LayersMatch( const LAYER_PRESET& aOther )
175 {
176 return aOther.layers == layers && aOther.renderLayers == renderLayers;
177 }
178
179 wxString name;
184 bool readOnly;
185};
186
187
188class KICOMMON_API PARAM_LAYER_PRESET : public PARAM_LAMBDA<nlohmann::json>
189{
190public:
191 PARAM_LAYER_PRESET( const std::string& aPath, std::vector<LAYER_PRESET>* aPresetList );
192
193 static void MigrateToV9Layers( nlohmann::json& aJson );
194
195 static void MigrateToNamedRenderLayers( nlohmann::json& aJson );
196
197private:
198 nlohmann::json presetsToJson();
199
200 void jsonToPresets( const nlohmann::json& aJson );
201
202 std::vector<LAYER_PRESET>* m_presets;
203};
204
205
207{
208 VIEWPORT( const wxString& aName = wxEmptyString ) :
209 name( aName )
210 { }
211
212 VIEWPORT( const wxString& aName, const BOX2D& aRect ) :
213 name( aName ),
214 rect( aRect )
215 { }
216
217 wxString name;
219};
220
221
222class KICOMMON_API PARAM_VIEWPORT : public PARAM_LAMBDA<nlohmann::json>
223{
224public:
225 PARAM_VIEWPORT( const std::string& aPath, std::vector<VIEWPORT>* aViewportList );
226
227private:
228 nlohmann::json viewportsToJson();
229
230 void jsonToViewports( const nlohmann::json& aJson );
231
232 std::vector<VIEWPORT>* m_viewports;
233};
234
235
237{
238 VIEWPORT3D( const wxString& aName = wxEmptyString ) :
239 name( aName )
240 { }
241
242 VIEWPORT3D( const wxString& aName, glm::mat4 aViewMatrix ) :
243 name( aName ),
244 matrix( std::move( aViewMatrix ) )
245 { }
246
247 wxString name;
248 glm::mat4 matrix;
249};
250
251
252class KICOMMON_API PARAM_VIEWPORT3D : public PARAM_LAMBDA<nlohmann::json>
253{
254public:
255 PARAM_VIEWPORT3D( const std::string& aPath, std::vector<VIEWPORT3D>* aViewportList );
256
257private:
258 nlohmann::json viewportsToJson();
259
260 void jsonToViewports( const nlohmann::json & aJson );
261
262 std::vector<VIEWPORT3D>* m_viewports;
263};
264
265
267{
268public:
270 m_layerA( UNDEFINED_LAYER ), m_layerB( UNDEFINED_LAYER )
271 {
272 }
273
275 m_layerA( a ), m_layerB( b )
276 {
277 }
278
279 PCB_LAYER_ID GetLayerA() const { return m_layerA; }
280 PCB_LAYER_ID GetLayerB() const { return m_layerB; }
281
282 void SetLayerA( PCB_LAYER_ID aLayer ) { m_layerA = aLayer; }
283 void SetLayerB( PCB_LAYER_ID aLayer ) { m_layerB = aLayer; }
284
288 bool HasSameLayers( const LAYER_PAIR& aOther ) const
289 {
290 return ( m_layerA == aOther.m_layerA && m_layerB == aOther.m_layerB )
291 || ( m_layerA == aOther.m_layerB && m_layerB == aOther.m_layerA );
292 }
293
294private:
297};
298
299
304{
305public:
306 LAYER_PAIR_INFO( LAYER_PAIR aPair, bool aEnabled, std::optional<wxString> aName ) :
307 m_pair( std::move( aPair ) ), m_enabled( aEnabled), m_name( std::move( aName ) )
308 {
309 }
310
311 const LAYER_PAIR& GetLayerPair() const { return m_pair; }
312
313 const std::optional<wxString>& GetName() const { return m_name; }
314
315 void SetName( const wxString& aNewName ) { m_name = aNewName; }
316 void UnsetName() { m_name = std::nullopt; }
317
318 bool IsEnabled() const { return m_enabled; }
319 void SetEnabled( bool aNewEnabled ) { m_enabled = aNewEnabled; }
320
321private:
323 bool m_enabled = true;
324 std::optional<wxString> m_name;
325};
326
327
328class KICOMMON_API PARAM_LAYER_PAIRS : public PARAM_LAMBDA<nlohmann::json>
329{
330public:
331 PARAM_LAYER_PAIRS( const std::string& aPath, std::vector<LAYER_PAIR_INFO>& m_layerPairInfos );
332
333private:
334 nlohmann::json layerPairsToJson();
335
336 void jsonToLayerPairs( const nlohmann::json& aJson );
337
338 std::vector<LAYER_PAIR_INFO>& m_layerPairInfos;
339};
340
341
346{
347 wxString filter_text;
352 std::vector<wxString> custom_group_rules;
357 std::vector<int> col_order;
358 std::vector<int> col_widths;
359 std::vector<bool> col_hidden;
360
361 std::vector<wxString> expanded_rows;
362
364 {
365 filter_text = "";
366 filter_by_net_name = true;
367 filter_by_netclass = true;
368 group_by_netclass = false;
369 group_by_constraint = false;
370 show_zero_pad_nets = false;
371 show_unconnected_nets = false;
372 sorting_column = -1;
373 sort_order_asc = true;
374 }
375};
376
377
378#endif // KICAD_BOARD_PROJECT_SETTINGS_H
const char * name
Definition: DXF_plotter.cpp:59
HIGH_CONTRAST_MODE
Determine how inactive layers should be displayed.
@ NORMAL
Inactive layers are shown normally (no high-contrast mode)
@ HIDDEN
Inactive layers are hidden.
@ DIMMED
Inactive layers are dimmed (old high-contrast mode)
@ RATSNEST
Net/netclass colors are shown on ratsnest lines only.
@ ALL
Net/netclass colors are shown on all net copper.
@ OFF
Net (and netclass) colors are not shown.
@ VISIBLE
Ratsnest lines are drawn to items on visible layers only.
Helper for storing and iterating over GAL_LAYER_IDs.
Definition: layer_ids.h:355
All information about a layer pair as stored in the layer pair store.
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
Like a normal param, but with custom getter and setter functions.
Definition: parameters.h:295
std::vector< LAYER_PAIR_INFO > & m_layerPairInfos
std::vector< LAYER_PRESET > * m_presets
std::vector< VIEWPORT3D > * m_viewports
std::vector< VIEWPORT > * m_viewports
#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.
A saved set of layers that are visible.
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)
Persisted state for the net inspector panel.
std::vector< wxString > expanded_rows
std::vector< wxString > custom_group_rules
This file contains data structures that are saved in the project file or project local settings file ...
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)