33using namespace std::placeholders;
76 std::vector<LAYER_PRESET_3D>* aPresetList ) :
81 m_presets( aPresetList )
83 wxASSERT( aPresetList );
89 nlohmann::json ret = nlohmann::json::array();
94 {
"name", preset.name }
97 nlohmann::json layers = nlohmann::json::array();
101 if( preset.layers.test( layer ) )
102 layers.push_back( layer );
105 js[
"layers"] = layers;
107 nlohmann::json colors = nlohmann::json::array();
109 for(
const auto& [ layer,
color ] : preset.colors )
111 nlohmann::json layerColor = {
113 {
"color",
color.ToCSSString() }
116 colors.push_back( layerColor );
119 js[
"colors"] = colors;
130 if( aJson.empty() || !aJson.is_array() )
135 for(
const nlohmann::json& preset : aJson )
137 if( preset.contains(
"name" ) )
141 if( preset.contains(
"layers" ) && preset.at(
"layers" ).is_array() )
145 for(
const nlohmann::json& layer : preset.at(
"layers" ) )
147 if( layer.is_number_integer() )
149 int layerNum = layer.get<
int>();
157 if( preset.contains(
"colors" ) && preset.at(
"colors" ).is_array() )
159 for(
const nlohmann::json& layerColor : preset.at(
"colors" ) )
161 if( layerColor.contains(
"layer" ) && layerColor.contains(
"color" )
162 && layerColor.at(
"layer" ).is_number_integer() )
164 int layerNum = layerColor.at(
"layer" ).get<
int>();
193 RENDER_ENGINE::OPENGL,
194 RENDER_ENGINE::OPENGL,
195 RENDER_ENGINE::RAYTRACING ) );
200 GRID3D_TYPE::GRID_10MM ) );
204 MATERIAL_MODE::NORMAL,
205 MATERIAL_MODE::NORMAL,
206 MATERIAL_MODE::CAD_MODE ) );
210 ANTIALIASING_MODE::AA_8X,
211 ANTIALIASING_MODE::AA_NONE,
212 ANTIALIASING_MODE::AA_8X ) );
216 COLOR4D( 0.0, 1.0, 0.0, 1.0 ) ) );
275 COLOR4D( 0.2, 0.2, 0.2, 1.0 ) ) );
279 COLOR4D( 0.247, 0.247, 0.247, 1.0 ) ) );
283 COLOR4D( 0.247, 0.247, 0.247, 1.0 ) ) );
285 std::vector<COLOR4D> default_colors =
287 COLOR4D( 0.168, 0.168, 0.168, 1.0 ),
288 COLOR4D( 0.168, 0.168, 0.168, 1.0 ),
289 COLOR4D( 0.168, 0.168, 0.168, 1.0 ),
290 COLOR4D( 0.168, 0.168, 0.168, 1.0 ),
291 COLOR4D( 0.168, 0.168, 0.168, 1.0 ),
292 COLOR4D( 0.168, 0.168, 0.168, 1.0 ),
293 COLOR4D( 0.168, 0.168, 0.168, 1.0 ),
294 COLOR4D( 0.168, 0.168, 0.168, 1.0 )
301 const std::vector<int> default_elevation =
303 67, 67, 67, 67, -67, -67, -67, -67,
308 default_elevation ) );
310 const std::vector<int> default_azimuth =
312 45, 135, 225, 315, 45, 135, 225, 315,
394 Set(
"render.opengl_copper_thickness",
false );
401 if( std::optional<bool> optval = Get<bool>(
"render.show_copper" ) )
403 Set(
"render.show_copper_top", *optval );
404 Set(
"render.show_copper_bottom", *optval );
407 if( std::optional<bool> optval = Get<bool>(
"render.show_silkscreen" ) )
409 Set(
"render.show_silkscreen_top", *optval );
410 Set(
"render.show_silkscreen_bottom", *optval );
413 if( std::optional<bool> optval = Get<bool>(
"render.show_soldermask" ) )
415 Set(
"render.show_soldermask_top", *optval );
416 Set(
"render.show_soldermask_bottom", *optval );
419 if( std::optional<bool> optval = Get<bool>(
"render.show_comments" ) )
420 Set(
"render.show_drawings", *optval );
422 if( std::optional<bool> optval = Get<bool>(
"render.show_eco" ) )
424 Set(
"render.show_eco1", *optval );
425 Set(
"render.show_eco2", *optval );
437 if( preset.name == aName )
469 ret &= fromLegacy<int>( aCfg,
"RenderEngine",
"render.engine" );
470 ret &= fromLegacy<int>( aCfg,
"ShowGrid3D",
"render.grid_type" );
471 ret &= fromLegacy<int>( aCfg,
"Render_Material",
"render.material_mode" );
472 ret &= fromLegacy<bool>( aCfg,
"Render_OGL_ShowCopperThickness",
"render.opengl_copper_thickness" );
473 ret &= fromLegacy<bool>( aCfg,
"Render_OGL_ShowModelBoudingBoxes",
"render.opengl_show_model_bbox" );
474 ret &= fromLegacy<bool>( aCfg,
"Render_RAY_AntiAliasing",
"render.raytrace_anti_aliasing" );
475 ret &= fromLegacy<bool>( aCfg,
"Render_RAY_Backfloor",
"render.raytrace_backfloor" );
476 ret &= fromLegacy<bool>( aCfg,
"Render_RAY_PostProcess",
"render.raytrace_post_processing" );
477 ret &= fromLegacy<bool>( aCfg,
"Render_RAY_ProceduralTextures",
"render.raytrace_procedural_textures" );
478 ret &= fromLegacy<bool>( aCfg,
"Render_RAY_Reflections",
"render.raytrace_reflections" );
479 ret &= fromLegacy<bool>( aCfg,
"Render_RAY_Refractions",
"render.raytrace_refractions" );
480 ret &= fromLegacy<bool>( aCfg,
"Render_RAY_Shadows",
"render.raytrace_shadows" );
481 ret &= fromLegacy<bool>( aCfg,
"ShowRealisticMode",
"render.realistic" );
482 ret &= fromLegacy<bool>( aCfg,
"ShowAdhesiveLayers",
"render.show_adhesive" );
483 ret &= fromLegacy<bool>( aCfg,
"ShowAxis",
"render.show_axis" );
484 ret &= fromLegacy<bool>( aCfg,
"ShowBoardBody",
"render.show_board_body" );
485 ret &= fromLegacy<bool>( aCfg,
"ShowCommentsLayers",
"render.show_comments" );
486 ret &= fromLegacy<bool>( aCfg,
"ShowEcoLayers",
"render.show_eco" );
487 ret &= fromLegacy<bool>( aCfg,
"ShowFootprints_Insert",
"render.show_footprints_insert" );
488 ret &= fromLegacy<bool>( aCfg,
"ShowFootprints_Normal",
"render.show_footprints_normal" );
489 ret &= fromLegacy<bool>( aCfg,
"ShowFootprints_Virtual",
"render.show_footprints_virtual" );
490 ret &= fromLegacy<bool>( aCfg,
"ShowSilkScreenLayers",
"render.show_silkscreen" );
491 ret &= fromLegacy<bool>( aCfg,
"ShowSolderMasLayers",
"render.show_soldermask" );
492 ret &= fromLegacy<bool>( aCfg,
"ShowSolderPasteLayers",
"render.show_solderpaste" );
493 ret &= fromLegacy<bool>( aCfg,
"ShowZones",
"render.show_zones" );
494 ret &= fromLegacy<bool>( aCfg,
"SubtractMaskFromSilk",
"render.subtract_mask_from_silk" );
497 [&] (
const std::string& key_r,
const std::string& key_g,
const std::string& key_b,
498 std::string key_dest,
double alpha = 1.0 )
502 if( aCfg->Read( key_r, &
color.r )
503 && aCfg->Read( key_g, &
color.g )
504 && aCfg->Read( key_b, &
color.b ) )
510 do_color(
"BgColor_Red",
"BgColor_Green",
"BgColor_Blue",
"colors.background_bottom" );
511 do_color(
"BgColor_Red_Top",
"BgColor_Green_Top",
"BgColor_Blue_Top",
"colors.background_top" );
512 do_color(
"BoardBodyColor_Red",
"BoardBodyColor_Green",
"BoardBodyColor_Blue",
"colors.board" );
513 do_color(
"CopperColor_Red",
"CopperColor_Green",
"CopperColor_Blue",
"colors.copper" );
514 do_color(
"SilkColor_Red",
"SilkColor_Green",
"SilkColor_Blue",
"colors.silkscreen_bottom" );
515 do_color(
"SilkColor_Red",
"SilkColor_Green",
"SilkColor_Blue",
"colors.silkscreen_top" );
516 do_color(
"SMaskColor_Red",
"SMaskColor_Green",
"SMaskColor_Blue",
"colors.soldermask", 0.83 );
517 do_color(
"SPasteColor_Red",
"SPasteColor_Green",
"SPasteColor_Blue",
"colors.solderpaste" );
declared enumerations and flags
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
static KIGFX::COLOR4D g_DefaultComments
static KIGFX::COLOR4D g_DefaultBoardBody
static KIGFX::COLOR4D g_DefaultSolderMask
static KIGFX::COLOR4D g_DefaultECOs
static KIGFX::COLOR4D g_DefaultBackgroundTop
static KIGFX::COLOR4D g_DefaultSurfaceFinish
static KIGFX::COLOR4D g_DefaultSolderPaste
static KIGFX::COLOR4D g_DefaultSilkscreen
static KIGFX::COLOR4D g_DefaultBackgroundBot
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
LAYER_PRESET_3D * FindPreset(const wxString &aName)
std::vector< LAYER_PRESET_3D > m_LayerPresets
void Set(const std::string &aPath, ValueType aVal)
Stores a value into the JSON document Will throw an exception if ValueType isn't something that the l...
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
void registerMigration(int aOldSchemaVersion, int aNewSchemaVersion, std::function< bool(void)> aMigrator)
Registers a migration from one schema version to another.
std::unique_ptr< JSON_SETTINGS_INTERNALS > m_internals
A color representation with 4 components: red, green, blue, alpha.
Stores an enum as an integer.
Like a normal param, but with custom getter and setter functions.
std::vector< LAYER_PRESET_3D > * m_presets
void jsonToPresets(const nlohmann::json &aJson)
PARAM_LAYER_PRESET_3D(const std::string &aPath, std::vector< LAYER_PRESET_3D > *aPresetList)
nlohmann::json presetsToJson()
const int viewer3dSchemaVersion
! Update the schema version whenever a migration is required
#define LEGACY_PRESET_FLAG
@ LAYER_3D_SOLDERMASK_TOP
@ LAYER_3D_BACKGROUND_TOP
@ LAYER_3D_SOLDERMASK_BOTTOM
@ LAYER_3D_SILKSCREEN_TOP
@ LAYER_3D_BACKGROUND_BOTTOM
@ LAYER_3D_SILKSCREEN_BOTTOM
@ LAYER_FP_REFERENCES
show footprints references (when texts are visible)
Declaration of the cogl_att_list class.
double rotation_increment
int moving_speed_multiplier
bool opengl_thickness_disableOnMove
bool opengl_copper_thickness
bool opengl_render_bbox_only_OnMove
std::vector< int > raytrace_lightElevation
bool show_footprints_normal
bool use_board_editor_copper_colors
MATERIAL_MODE material_mode
KIGFX::COLOR4D raytrace_lightColorCamera
ANTIALIASING_MODE opengl_AA_mode
bool raytrace_post_processing
std::vector< KIGFX::COLOR4D > raytrace_lightColor
KIGFX::COLOR4D raytrace_lightColorBottom
float raytrace_spread_shadows
KIGFX::COLOR4D opengl_selection_color
bool clip_silk_on_via_annuli
bool raytrace_reflections
bool show_footprints_virtual
float raytrace_spread_reflections
int raytrace_nrsamples_shadows
bool differentiate_plated_copper
bool show_silkscreen_bottom
std::vector< int > raytrace_lightAzimuth
int raytrace_nrsamples_reflections
bool subtract_mask_from_silk
bool raytrace_refractions
bool show_footprints_not_in_posfile
int raytrace_recursivelevel_reflections
int raytrace_nrsamples_refractions
bool highlight_on_rollover
bool raytrace_procedural_textures
bool show_footprints_insert
int raytrace_recursivelevel_refractions
bool show_soldermask_bottom
KIGFX::COLOR4D raytrace_lightColorTop
float raytrace_spread_refractions
bool opengl_holes_disableOnMove
bool raytrace_anti_aliasing
bool opengl_AA_disableOnMove
bool opengl_vias_disableOnMove
LAYER_PRESET_3D(const wxString &aName=wxEmptyString)
std::bitset< LAYER_3D_END > layers
std::map< int, KIGFX::COLOR4D > colors