[Bf-extensions-cvs] [5dd059cd] master: sun_position: cleanup
Damien Picard
noreply at git.blender.org
Fri Sep 20 11:43:38 CEST 2019
Commit: 5dd059cdde5420aa747d69a920fa66316ee98a10
Author: Damien Picard
Date: Thu Sep 19 12:51:43 2019 +0200
Branches: master
https://developer.blender.org/rBAC5dd059cdde5420aa747d69a920fa66316ee98a10
sun_position: cleanup
===================================================================
M sun_position/__init__.py
M sun_position/hdr.py
M sun_position/north.py
M sun_position/properties.py
M sun_position/sun_calc.py
M sun_position/ui_sun.py
===================================================================
diff --git a/sun_position/__init__.py b/sun_position/__init__.py
index d276463e..6cce76f3 100644
--- a/sun_position/__init__.py
+++ b/sun_position/__init__.py
@@ -52,11 +52,11 @@ if "bpy" in locals():
import importlib
importlib.reload(properties)
importlib.reload(ui_sun)
- importlib.reload(map)
+ # importlib.reload(map)
importlib.reload(hdr)
else:
- from . import properties, ui_sun, map, hdr
+ from . import properties, ui_sun, hdr#, map
import bpy
diff --git a/sun_position/hdr.py b/sun_position/hdr.py
index 774b42df..4c1642ac 100644
--- a/sun_position/hdr.py
+++ b/sun_position/hdr.py
@@ -23,7 +23,6 @@ import gpu
import bgl
from gpu_extras.batch import batch_for_shader
from mathutils import Vector
-from gpu_extras.presets import draw_texture_2d
from math import sqrt, pi, atan2, asin
@@ -68,7 +67,6 @@ def draw_callback_px(self, context):
if image.gl_load():
raise Exception()
- left = 0
bottom = 0
top = context.area.height
right = context.area.width
diff --git a/sun_position/north.py b/sun_position/north.py
index 3ef5f822..44b4ee09 100644
--- a/sun_position/north.py
+++ b/sun_position/north.py
@@ -73,7 +73,6 @@ else:
# less 90 degrees. This forces the unit circle to begin at the
# 12 O'clock instead of 3 O'clock position.
# ------------------------------------------------------------------
- addon_prefs = bpy.context.preferences.addons[__package__].preferences
sun_props = bpy.context.scene.sun_pos_properties
color = (0.2, 0.6, 1.0, 0.7)
diff --git a/sun_position/properties.py b/sun_position/properties.py
index 11d2eaed..20e556e0 100644
--- a/sun_position/properties.py
+++ b/sun_position/properties.py
@@ -46,12 +46,12 @@ class SunPosProperties(PropertyGroup):
default=False,
update=sun_update)
- daylight_savings: BoolProperty(
+ use_daylight_savings: BoolProperty(
description="Daylight savings time adds 1 hour to standard time.",
default=0,
update=sun_update)
- show_refraction: BoolProperty(
+ use_refraction: BoolProperty(
description="Show apparent sun position due to refraction.",
default=1,
update=sun_update)
@@ -61,12 +61,22 @@ class SunPosProperties(PropertyGroup):
default=0,
update=north_update)
+ north_offset: FloatProperty(
+ attr="",
+ name="",
+ description="North offset in degrees or radians "
+ "from scene's units settings",
+ unit="ROTATION",
+ soft_min=-3.14159265, soft_max=3.14159265, step=10.00, default=0.00,
+ update=sun_update)
+
latitude: FloatProperty(
attr="",
name="Latitude",
description="Latitude: (+) Northern (-) Southern",
- soft_min=-90.000, soft_max=90.000, step=3.001,
- default=40.000, precision=3,
+ soft_min=-90.000, soft_max=90.000,
+ step=5, precision=3,
+ default=0.000,
update=sun_update)
longitude: FloatProperty(
@@ -74,7 +84,8 @@ class SunPosProperties(PropertyGroup):
name="Longitude",
description="Longitude: (-) West of Greenwich (+) East of Greenwich",
soft_min=-180.000, soft_max=180.000,
- step=3.001, default=1.000, precision=3,
+ step=5, precision=3,
+ default=0.000,
update=sun_update)
co_parser: StringProperty(
@@ -132,15 +143,6 @@ class SunPosProperties(PropertyGroup):
soft_min=0.00, soft_max=23.9999, step=1.00, default=12.00,
update=sun_update)
- north_offset: FloatProperty(
- attr="",
- name="",
- description="North offset in degrees or radians "
- "from scene's units settings",
- unit="ROTATION",
- soft_min=-3.14159265, soft_max=3.14159265, step=10.00, default=0.00,
- update=sun_update)
-
sun_distance: FloatProperty(
attr="",
name="Distance",
@@ -233,12 +235,6 @@ class SunPosProperties(PropertyGroup):
soft_min=1.00, soft_max=24.00, step=1.00, default=23.00,
update=sun_update)
- location: StringProperty(
- default="view3d",
- name="location",
- description="panel location",
- update=sun_update)
-
############################################################################
# Preference panel properties
@@ -248,22 +244,23 @@ class SunPosProperties(PropertyGroup):
class SunPosAddonPreferences(AddonPreferences):
bl_idname = __package__
- map_location: EnumProperty(
- name="Map location",
- description="Display map in viewport or world panel",
- items=(
- ('VIEWPORT', "Viewport", ""),
- ('PANEL', "Panel", ""),
- ),
- default='VIEWPORT')
+ # map_location: EnumProperty(
+ # name="Map location",
+ # description="Display map in viewport or world panel",
+ # items=(
+ # ('VIEWPORT', "Viewport", ""),
+ # ('PANEL', "Panel", ""),
+ # ),
+ # default='VIEWPORT')
- use_time_place: BoolProperty(
+ show_time_place: BoolProperty(
description="Show time/place presets",
default=False)
- use_object_collection: BoolProperty(
+ show_object_collection: BoolProperty(
description="Use object collection",
- default=True)
+ default=True,
+ update=sun_update)
show_dms: BoolProperty(
description="Show lat/long degrees, minutes, seconds labels",
@@ -283,9 +280,10 @@ class SunPosAddonPreferences(AddonPreferences):
description="Show azimuth and solar elevation info",
default=True)
- show_dst: BoolProperty(
+ show_daylight_savings: BoolProperty(
description="Show daylight savings time choice",
- default=True)
+ default=True,
+ update=sun_update)
show_rise_set: BoolProperty(
description="Show sunrise and sunset",
@@ -310,16 +308,16 @@ class SunPosAddonPreferences(AddonPreferences):
# 'map_presets', text=Sun.map_name)
# col.separator()
- col.prop(self, "map_location")
- col.separator()
+ # col.prop(self, "map_location")
+ # col.separator()
col.label(text="Show or use:")
flow = col.grid_flow(columns=0, even_columns=True, even_rows=False, align=False)
- flow.prop(self, "use_time_place", text="Time/place presets")
- flow.prop(self, "use_object_collection", text="Use collection")
+ flow.prop(self, "show_time_place", text="Time/place presets")
+ flow.prop(self, "show_object_collection", text="Use collection")
flow.prop(self, "show_dms", text="D° M' S\"")
flow.prop(self, "show_north", text="North offset")
flow.prop(self, "show_refraction", text="Refraction")
flow.prop(self, "show_az_el", text="Azimuth, elevation")
- flow.prop(self, "show_dst", text="Daylight savings time")
+ flow.prop(self, "show_daylight_savings", text="Daylight savings time")
flow.prop(self, "show_rise_set", text="Sunrise, sunset")
diff --git a/sun_position/sun_calc.py b/sun_position/sun_calc.py
index ed6107d7..8f217b89 100644
--- a/sun_position/sun_calc.py
+++ b/sun_position/sun_calc.py
@@ -18,7 +18,6 @@
import bpy
from bpy.app.handlers import persistent
-from mathutils import *
import math
from math import degrees, radians, pi
import datetime
@@ -65,7 +64,7 @@ class SunClass:
UTC_zone = 0
sun_distance = 0.0
- daylight_savings = False
+ use_daylight_savings = False
sun = SunClass()
@@ -141,7 +140,9 @@ def move_sun(context):
zone = sun_props.UTC_zone * -1
else:
zone = sun_props.UTC_zone
- if sun_props.daylight_savings:
+ sun.use_daylight_savings = (addon_prefs.show_daylight_savings and
+ sun_props.use_daylight_savings)
+ if sun.use_daylight_savings:
zone -= 1
north_offset = degrees(sun_props.north_offset)
@@ -175,7 +176,7 @@ def move_sun(context):
math.radians(-sun.az_north)))
# Sun collection
- if (addon_prefs.use_object_collection
+ if (addon_prefs.show_object_collection
and sun_props.use_object_collection
and sun_props.object_collection):
sun_objects = sun_props.object_collection.objects
@@ -216,7 +217,6 @@ def move_sun(context):
math.radians(-sun.az_north)))
def update_time(context):
- addon_prefs = context.preferences.addons[__package__].preferences
sun_props = context.scene.sun_pos_properties
if not sun_props.use_day_of_year:
@@ -368,7 +368,7 @@ def get_sun_position(local_time, latitude, longitude, north_offset,
exoatm_elevation = 90.0 - degrees(zenith)
- if addon_prefs.show_refraction and sun_props.show_refraction:
+ if addon_prefs.show_refraction and sun_props.use_refraction:
if exoatm_elevation > 85.0:
refraction_correction = 0.0
else:
@@ -472,7 +472,7 @@ def calc_sunrise_sunset(rise):
get_sun_position(tl, sun.latitude, sun.longitude, 0.0,
zone, sun.month, sun.day, sun.year,
sun.sun_distance)
- if sun.daylight_savings:
+ if sun.use_daylight_savings:
time_local += 60.0
tl = time_local / 60.0
if tl < 0.0:
@@ -483,7 +483,7 @@ def calc_sunrise_sunset(rise):
sun.sunrise.time = tl
sun.sunrise.azimuth = sun.azimuth
sun.sunrise.elevation = sun.elevation
- calc_solar_noon(jd, sun.longitude, -zone, sun.daylight_savings)
+ calc_solar_noon(jd, sun.longitude, -zone, sun.use_daylight_savings)
get_sun_position(sun.solar_noon.time, sun.latitude, sun.longitude,
0.0, zone, sun.month, sun.day, sun.year,
sun.sun_distance)
diff --git a/sun_position/ui_sun.py b/sun_position/ui_sun.py
index a923ce9e..ca6d22d7 100644
--- a/sun_position/ui_sun.py
+++ b/sun_position/ui_sun.py
@@ -20,11 +20,8 @@ import bpy
from bpy.types import Operator, Menu
from bl_operators.presets import AddPresetBase
import os
-import datetime
-from math import radians
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list