1 ### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
20 from bpy
.types
import AddonPreferences
, PropertyGroup
21 from bpy
.props
import (StringProperty
, EnumProperty
, IntProperty
,
22 FloatProperty
, BoolProperty
, PointerProperty
)
24 from .sun_calc
import sun_update
, parse_coordinates
25 from .north
import north_update
28 from datetime
import datetime
29 TODAY
= datetime
.today()
31 ############################################################################
32 # Sun panel properties
33 ############################################################################
36 class SunPosProperties(PropertyGroup
):
37 usage_mode
: EnumProperty(
39 description
="Operate in normal mode or environment texture mode",
41 ('NORMAL', "Normal", ""),
42 ('HDR', "Sun + HDR texture", ""),
47 use_daylight_savings
: BoolProperty(
48 name
="Daylight savings",
49 description
="Daylight savings time adds 1 hour to standard time",
53 use_refraction
: BoolProperty(
54 name
="Use refraction",
55 description
="Show apparent sun position due to refraction",
59 show_north
: BoolProperty(
61 description
="Draw line pointing north",
65 north_offset
: FloatProperty(
67 description
="Rotate the scene to choose North direction",
69 soft_min
=-pi
, soft_max
=pi
, step
=10.0, default
=0.0,
72 latitude
: FloatProperty(
74 description
="Latitude: (+) Northern (-) Southern",
75 soft_min
=-90.0, soft_max
=90.0,
80 longitude
: FloatProperty(
82 description
="Longitude: (-) West of Greenwich (+) East of Greenwich",
83 soft_min
=-180.0, soft_max
=180.0,
88 co_parser
: StringProperty(
89 name
="Enter coordinates",
90 description
="Enter coordinates from an online map",
91 update
=parse_coordinates
)
95 min=1, max=12, default
=TODAY
.month
,
100 min=1, max=31, default
=TODAY
.day
,
105 min=1, max=4000, default
=TODAY
.year
,
108 use_day_of_year
: BoolProperty(
109 description
="Use a single value for day of year",
110 name
="Use day of year",
114 day_of_year
: IntProperty(
116 min=1, max=366, default
=1,
119 UTC_zone
: FloatProperty(
121 description
="Time zone: Difference from Greenwich, England in hours",
123 min=-14.0, max=13, step
=50, default
=0.0,
128 description
="Time of the day",
130 soft_min
=0.0, soft_max
=23.9999, step
=1.0, default
=12.0,
133 sun_distance
: FloatProperty(
135 description
="Distance to sun from origin",
137 min=0.0, soft_max
=3000.0, step
=10.0, default
=50.0,
140 sun_object
: PointerProperty(
142 type=bpy
.types
.Object
,
143 description
="Sun object to set in the scene",
144 poll
=lambda self
, obj
: obj
.type == 'LIGHT',
147 object_collection
: PointerProperty(
149 type=bpy
.types
.Collection
,
150 description
="Collection of objects used to visualize sun motion",
153 object_collection_type
: EnumProperty(
155 description
="Show object group as sun motion",
157 ('ANALEMMA', "Analemma", ""),
158 ('DIURNAL', "Diurnal", ""),
163 sky_texture
: StringProperty(
166 description
="Name of sky texture to be used",
169 hdr_texture
: StringProperty(
170 default
="Environment Texture",
171 name
="Environment Texture",
172 description
="Name of texture to use. World nodes must be enabled "
173 "and color set to Environment Texture",
176 hdr_azimuth
: FloatProperty(
178 description
="Rotation angle of sun and environment texture",
181 default
=0.0, precision
=3,
184 hdr_elevation
: FloatProperty(
186 description
="Elevation angle of sun",
189 default
=0.0, precision
=3,
192 bind_to_sun
: BoolProperty(
193 description
="If true, Environment texture moves with sun",
197 time_spread
: FloatProperty(
199 description
="Time period in which to spread object collection",
201 soft_min
=1.0, soft_max
=24.0, step
=1.0, default
=23.0,
205 ############################################################################
206 # Preference panel properties
207 ############################################################################
210 class SunPosAddonPreferences(AddonPreferences
):
211 bl_idname
= __package__
213 show_time_place
: BoolProperty(
214 name
="Time and place presets",
215 description
="Show time/place presets",
218 show_dms
: BoolProperty(
220 description
="Show lat/long degrees, minutes, seconds labels",
223 show_north
: BoolProperty(
225 description
="Show north offset choice and slider",
229 show_refraction
: BoolProperty(
231 description
="Show sun refraction choice",
235 show_az_el
: BoolProperty(
236 name
="Azimuth and elevation info",
237 description
="Show azimuth and solar elevation info",
240 show_daylight_savings
: BoolProperty(
241 name
="Daylight savings",
242 description
="Show daylight savings time choice",
246 show_rise_set
: BoolProperty(
247 name
="Sunrise and sunset info",
248 description
="Show sunrise and sunset labels",
251 def draw(self
, context
):
257 col
.label(text
="Show options or labels:")
258 flow
= col
.grid_flow(columns
=0, even_columns
=True, even_rows
=False, align
=False)
259 flow
.prop(self
, "show_time_place")
260 flow
.prop(self
, "show_dms")
261 flow
.prop(self
, "show_north")
262 flow
.prop(self
, "show_refraction")
263 flow
.prop(self
, "show_az_el")
264 flow
.prop(self
, "show_daylight_savings")
265 flow
.prop(self
, "show_rise_set")