KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_3D_raytracing_options.cpp
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) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2014-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <pgm_base.h>
28#include <base_units.h>
30
31
34{
35}
36
37
39{
47
51
53 pcbIUScale, EDA_UNITS::PERCENT, aCfg->m_Render.raytrace_spread_shadows * 100.0f ) );
55 pcbIUScale, EDA_UNITS::PERCENT, aCfg->m_Render.raytrace_spread_reflections * 100.0f ) );
57 pcbIUScale, EDA_UNITS::PERCENT, aCfg->m_Render.raytrace_spread_refractions * 100.0f ) );
58
61
62 auto transfer_color =
63 []( COLOR4D aColor, COLOR_SWATCH *aTarget )
64 {
65 aTarget->SetSupportsOpacity( false );
66 aTarget->SetDefaultColor( KIGFX::COLOR4D( 0.5, 0.5, 0.5, 1.0 ) );
67 aTarget->SetSwatchColor( aColor, false );
68 };
69
70 auto transfer_value =
71 []( wxTextCtrl* aCtrl, int aValue )
72 {
73 aCtrl->SetValue(
74 EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, EDA_UNITS::UNSCALED, aValue ) );
75 };
76
80
81 transfer_color( aCfg->m_Render.raytrace_lightColor[0], m_colourPickerLight1 );
82 transfer_color( aCfg->m_Render.raytrace_lightColor[1], m_colourPickerLight2 );
83 transfer_color( aCfg->m_Render.raytrace_lightColor[2], m_colourPickerLight3 );
84 transfer_color( aCfg->m_Render.raytrace_lightColor[3], m_colourPickerLight4 );
85
86 transfer_color( aCfg->m_Render.raytrace_lightColor[4], m_colourPickerLight5 );
87 transfer_color( aCfg->m_Render.raytrace_lightColor[5], m_colourPickerLight6 );
88 transfer_color( aCfg->m_Render.raytrace_lightColor[6], m_colourPickerLight7 );
89 transfer_color( aCfg->m_Render.raytrace_lightColor[7], m_colourPickerLight8 );
90
91 transfer_value( m_lightElevation1, aCfg->m_Render.raytrace_lightElevation[0] );
92 transfer_value( m_lightElevation2, aCfg->m_Render.raytrace_lightElevation[1] );
93 transfer_value( m_lightElevation3, aCfg->m_Render.raytrace_lightElevation[2] );
94 transfer_value( m_lightElevation4, aCfg->m_Render.raytrace_lightElevation[3] );
95 transfer_value( m_lightElevation5, aCfg->m_Render.raytrace_lightElevation[4] );
96 transfer_value( m_lightElevation6, aCfg->m_Render.raytrace_lightElevation[5] );
97 transfer_value( m_lightElevation7, aCfg->m_Render.raytrace_lightElevation[6] );
98 transfer_value( m_lightElevation8, aCfg->m_Render.raytrace_lightElevation[7] );
99
100 transfer_value( m_lightAzimuth1, aCfg->m_Render.raytrace_lightAzimuth[0] );
101 transfer_value( m_lightAzimuth2, aCfg->m_Render.raytrace_lightAzimuth[1] );
102 transfer_value( m_lightAzimuth3, aCfg->m_Render.raytrace_lightAzimuth[2] );
103 transfer_value( m_lightAzimuth4, aCfg->m_Render.raytrace_lightAzimuth[3] );
104 transfer_value( m_lightAzimuth5, aCfg->m_Render.raytrace_lightAzimuth[4] );
105 transfer_value( m_lightAzimuth6, aCfg->m_Render.raytrace_lightAzimuth[5] );
106 transfer_value( m_lightAzimuth7, aCfg->m_Render.raytrace_lightAzimuth[6] );
107 transfer_value( m_lightAzimuth8, aCfg->m_Render.raytrace_lightAzimuth[7] );
108}
109
110
112{
115
116 loadSettings( cfg );
117
118 return true;
119}
120
121
123{
126
134
138
141 m_spreadFactor_Shadows->GetValue() )
142 / 100.0f;
145 m_spreadFactor_Reflections->GetValue() )
146 / 100.0f;
149 m_spreadFactor_Refractions->GetValue() )
150 / 100.0f;
151
154
158
167
168 auto get_value =
169 []( wxTextCtrl* aCtrl )
170 {
171 return EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::UNSCALED,
172 aCtrl->GetValue() );
173 };
174
183
184 cfg->m_Render.raytrace_lightAzimuth[0] = get_value( m_lightAzimuth1 );
185 cfg->m_Render.raytrace_lightAzimuth[1] = get_value( m_lightAzimuth2 );
186 cfg->m_Render.raytrace_lightAzimuth[2] = get_value( m_lightAzimuth3 );
187 cfg->m_Render.raytrace_lightAzimuth[3] = get_value( m_lightAzimuth4 );
188 cfg->m_Render.raytrace_lightAzimuth[4] = get_value( m_lightAzimuth5 );
189 cfg->m_Render.raytrace_lightAzimuth[5] = get_value( m_lightAzimuth6 );
190 cfg->m_Render.raytrace_lightAzimuth[6] = get_value( m_lightAzimuth7 );
191 cfg->m_Render.raytrace_lightAzimuth[7] = get_value( m_lightAzimuth8 );
192
193 return true;
194}
195
196
198{
200 cfg.Load(); // Loading without a file will init to defaults
201
202 loadSettings( &cfg );
203}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
A simple color swatch of the kind used to set layer colors.
Definition: color_swatch.h:57
KIGFX::COLOR4D GetSwatchColor() const
virtual void Load()
Updates the parameters of this object based on the current JSON document contents.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Class PANEL_3D_RAYTRACING_OPTIONS_BASE.
void ResetPanel() override
Reset the contents of this panel.
void loadSettings(EDA_3D_VIEWER_SETTINGS *aCfg)
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
T * GetAppSettings()
Returns a handle to the a given settings by type If the settings have already been loaded,...
KICOMMON_API wxString StringFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Returns the string from aValue according to aUnits (inch, mm ...) for display.
Definition: eda_units.cpp:300
KICOMMON_API double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Function DoubleValueFromString converts aTextValue to a double.
Definition: eda_units.cpp:576
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE
std::vector< KIGFX::COLOR4D > raytrace_lightColor