1 # SPDX-License-Identifier: GPL-2.0-or-later
4 from bpy
.types
import AddonPreferences
, PropertyGroup
5 from bpy
.props
import (StringProperty
, EnumProperty
, IntProperty
,
6 FloatProperty
, BoolProperty
, PointerProperty
)
8 from .sun_calc
import sun_update
, parse_coordinates
9 from .north
import north_update
12 from datetime
import datetime
13 TODAY
= datetime
.today()
15 ############################################################################
16 # Sun panel properties
17 ############################################################################
20 class SunPosProperties(PropertyGroup
):
21 usage_mode
: EnumProperty(
23 description
="Operate in normal mode or environment texture mode",
25 ('NORMAL', "Normal", ""),
26 ('HDR', "Sun + HDR texture", ""),
31 use_daylight_savings
: BoolProperty(
32 name
="Daylight savings",
33 description
="Daylight savings time adds 1 hour to standard time",
37 use_refraction
: BoolProperty(
38 name
="Use refraction",
39 description
="Show apparent sun position due to refraction",
43 show_north
: BoolProperty(
45 description
="Draw line pointing north",
49 north_offset
: FloatProperty(
51 description
="Rotate the scene to choose North direction",
53 soft_min
=-pi
, soft_max
=pi
, step
=10.0, default
=0.0,
56 latitude
: FloatProperty(
58 description
="Latitude: (+) Northern (-) Southern",
59 soft_min
=-90.0, soft_max
=90.0,
64 longitude
: FloatProperty(
66 description
="Longitude: (-) West of Greenwich (+) East of Greenwich",
67 soft_min
=-180.0, soft_max
=180.0,
72 co_parser
: StringProperty(
73 name
="Enter coordinates",
74 description
="Enter coordinates from an online map",
75 update
=parse_coordinates
)
79 min=1, max=12, default
=TODAY
.month
,
84 min=1, max=31, default
=TODAY
.day
,
89 min=1, max=4000, default
=TODAY
.year
,
92 use_day_of_year
: BoolProperty(
93 description
="Use a single value for day of year",
94 name
="Use day of year",
98 day_of_year
: IntProperty(
100 min=1, max=366, default
=1,
103 UTC_zone
: FloatProperty(
105 description
="Time zone: Difference from Greenwich, England in hours",
107 min=-14.0, max=13, step
=50, default
=0.0,
112 description
="Time of the day",
114 soft_min
=0.0, soft_max
=23.9999, step
=1.0, default
=12.0,
117 sun_distance
: FloatProperty(
119 description
="Distance to sun from origin",
121 min=0.0, soft_max
=3000.0, step
=10.0, default
=50.0,
124 sun_object
: PointerProperty(
126 type=bpy
.types
.Object
,
127 description
="Sun object to set in the scene",
128 poll
=lambda self
, obj
: obj
.type == 'LIGHT',
131 object_collection
: PointerProperty(
133 type=bpy
.types
.Collection
,
134 description
="Collection of objects used to visualize sun motion",
137 object_collection_type
: EnumProperty(
139 description
="Show object collection as sun motion",
141 ('ANALEMMA', "Analemma", ""),
142 ('DIURNAL', "Diurnal", ""),
147 sky_texture
: StringProperty(
150 description
="Name of sky texture to be used",
153 hdr_texture
: StringProperty(
154 default
="Environment Texture",
155 name
="Environment Texture",
156 description
="Name of texture to use. World nodes must be enabled "
157 "and color set to Environment Texture",
160 hdr_azimuth
: FloatProperty(
162 description
="Rotation angle of sun and environment texture",
165 default
=0.0, precision
=3,
168 hdr_elevation
: FloatProperty(
170 description
="Elevation angle of sun",
173 default
=0.0, precision
=3,
176 bind_to_sun
: BoolProperty(
177 description
="If true, Environment texture moves with sun",
181 time_spread
: FloatProperty(
183 description
="Time period in which to spread object collection",
185 soft_min
=1.0, soft_max
=24.0, step
=1.0, default
=23.0,
189 ############################################################################
190 # Preference panel properties
191 ############################################################################
194 class SunPosAddonPreferences(AddonPreferences
):
195 bl_idname
= __package__
197 show_time_place
: BoolProperty(
198 name
="Time and place presets",
199 description
="Show time/place presets",
202 show_dms
: BoolProperty(
204 description
="Show lat/long degrees, minutes, seconds labels",
207 show_north
: BoolProperty(
209 description
="Show north offset choice and slider",
213 show_refraction
: BoolProperty(
215 description
="Show sun refraction choice",
219 show_az_el
: BoolProperty(
220 name
="Azimuth and elevation info",
221 description
="Show azimuth and solar elevation info",
224 show_daylight_savings
: BoolProperty(
225 name
="Daylight savings",
226 description
="Show daylight savings time choice",
230 show_rise_set
: BoolProperty(
231 name
="Sunrise and sunset info",
232 description
="Show sunrise and sunset labels",
235 def draw(self
, context
):
241 col
.label(text
="Show options or labels:")
242 flow
= col
.grid_flow(columns
=0, even_columns
=True, even_rows
=False, align
=False)
243 flow
.prop(self
, "show_time_place")
244 flow
.prop(self
, "show_dms")
245 flow
.prop(self
, "show_north")
246 flow
.prop(self
, "show_refraction")
247 flow
.prop(self
, "show_az_el")
248 flow
.prop(self
, "show_daylight_savings")
249 flow
.prop(self
, "show_rise_set")