From f571bfdc549914576a720e01e1255e88d425cc27 Mon Sep 17 00:00:00 2001 From: Damien Picard Date: Fri, 14 Apr 2023 02:07:02 +0200 Subject: [PATCH] Sun Position: group some prefs under show_overlays There were three preferences for "Show North", "Show Surface", and "Show Analemmas". These were quite redundant so they can be grouped under a single "Show Overlays" preference. --- sun_position/draw.py | 6 +++--- sun_position/properties.py | 22 ++++------------------ sun_position/ui_sun.py | 10 ++++------ 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/sun_position/draw.py b/sun_position/draw.py index 95ff89f6..ed0a9424 100644 --- a/sun_position/draw.py +++ b/sun_position/draw.py @@ -95,7 +95,7 @@ else: sun_props = context.scene.sun_pos_properties addon_prefs = context.preferences.addons[__package__].preferences - if addon_prefs.show_north and sun_props.show_north: + if addon_prefs.show_overlays and sun_props.show_north: _north_handle = bpy.types.SpaceView3D.draw_handler_add(north_draw, (), 'WINDOW', 'POST_VIEW') elif _north_handle is not None: bpy.types.SpaceView3D.draw_handler_remove(_north_handle, 'WINDOW') @@ -114,7 +114,7 @@ else: sun_props = context.scene.sun_pos_properties addon_prefs = context.preferences.addons[__package__].preferences - if addon_prefs.show_analemmas and sun_props.show_analemmas: + if addon_prefs.show_overlays and sun_props.show_analemmas: coords = [] indices = [] coord_offset = 0 @@ -154,7 +154,7 @@ else: sun_props = context.scene.sun_pos_properties addon_prefs = context.preferences.addons[__package__].preferences - if addon_prefs.show_surface and sun_props.show_surface: + if addon_prefs.show_overlays and sun_props.show_surface: coords = calc_surface(context) shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') batch = batch_for_shader(shader, 'TRIS', {"pos": coords}) diff --git a/sun_position/properties.py b/sun_position/properties.py index 9b709ab2..42a89b8e 100644 --- a/sun_position/properties.py +++ b/sun_position/properties.py @@ -257,21 +257,9 @@ class SunPosAddonPreferences(AddonPreferences): description="Show degrees, minutes, seconds labels for the latitude and longitude", default=True) - show_north: BoolProperty( - name="Show North", - description="Show North offset choice and slider", - default=True, - update=sun_update) - - show_surface: BoolProperty( - name="Show Surface", - description="Show Sun surface choice", - default=True, - update=sun_update) - - show_analemmas: BoolProperty( - name="Show Analemmas", - description="Show Analemmas choice", + show_overlays: BoolProperty( + name="Show Overlays", + description="Display overlays in the viewport: the direction of the north, analemmas and the Sun surface", default=True, update=sun_update) @@ -307,10 +295,8 @@ class SunPosAddonPreferences(AddonPreferences): flow = col.grid_flow(columns=0, even_columns=True, even_rows=False, align=False) flow.prop(self, "show_time_place") flow.prop(self, "show_dms") - flow.prop(self, "show_north") - flow.prop(self, "show_surface") - flow.prop(self, "show_analemmas") flow.prop(self, "show_refraction") + flow.prop(self, "show_overlays") flow.prop(self, "show_az_el") flow.prop(self, "show_daylight_savings") flow.prop(self, "show_rise_set") diff --git a/sun_position/ui_sun.py b/sun_position/ui_sun.py index f0cec345..000532d6 100644 --- a/sun_position/ui_sun.py +++ b/sun_position/ui_sun.py @@ -182,18 +182,16 @@ class SUNPOS_PT_Location(bpy.types.Panel): row.label(text=format_lat_long(sp.longitude, False)) col.separator() - if p.show_north: + if p.show_overlays: col = flow.column(align=True) col.prop(sp, "show_north", toggle=True) col.prop(sp, "north_offset") col.separator() - if p.show_surface or p.show_analemmas: + if p.show_overlays: col = flow.column(align=True) - if p.show_surface: - col.prop(sp, "show_surface", toggle=True) - if p.show_analemmas: - col.prop(sp, "show_analemmas", toggle=True) + col.prop(sp, "show_surface", toggle=True) + col.prop(sp, "show_analemmas", toggle=True) col.separator() if p.show_az_el: -- 2.11.4.GIT