[Bf-extensions-cvs] [a833e05d] master: NP Station: performance improvements and cleanup
NBurn
noreply at git.blender.org
Sat Sep 30 07:13:36 CEST 2017
Commit: a833e05dcf4a59ef8c0d908565d50ef239d8b124
Author: NBurn
Date: Sat Sep 30 01:13:14 2017 -0400
Branches: master
https://developer.blender.org/rBACa833e05dcf4a59ef8c0d908565d50ef239d8b124
NP Station: performance improvements and cleanup
===================================================================
M np_station/__init__.py
M np_station/np_shader_brush.py
M np_station/utils_graphics.py
===================================================================
diff --git a/np_station/__init__.py b/np_station/__init__.py
index ee24e7e8..73193b31 100644
--- a/np_station/__init__.py
+++ b/np_station/__init__.py
@@ -166,14 +166,12 @@ class NP020Preferences(bpy.types.AddonPreferences):
default = 'csc_default_grey',
description = 'Choose the overall addon color scheme, according to your current Blender theme')
- np_size_num = bpy.props.FloatProperty(
+ np_size_num = bpy.props.IntProperty(
name='',
description='Size of the numerics that display on-screen dimensions, the default is 18',
default=18,
min=10,
- max=30,
- step=100,
- precision=0)
+ max=30)
np_scale_dist = bpy.props.FloatProperty(
name='',
@@ -185,10 +183,10 @@ class NP020Preferences(bpy.types.AddonPreferences):
np_suffix_dist = bpy.props.EnumProperty(
name='',
- items=(("'", "'", ''), ('"', '"', ''), ('thou', 'thou', ''),
- ('km', 'km', ''), ('m', 'm', ''), ('cm', 'cm', ''),
- ('mm', 'mm', ''), ('nm', 'nm', ''), ('None', 'None', '')),
- default='cm',
+ items=(("'", "'", ''), ('"', '"', ''), (' thou', 'thou', ''),
+ (' km', 'km', ''), (' m', 'm', ''), (' cm', 'cm', ''),
+ (' mm', 'mm', ''), (' nm', 'nm', ''), ('None', 'None', '')),
+ default=' cm',
description='Add a unit extension after the numerical distance ')
np_display_badge = bpy.props.BoolProperty(
@@ -196,14 +194,12 @@ class NP020Preferences(bpy.types.AddonPreferences):
description='Use the graphical badge near the mouse cursor',
default=True)
- np_size_badge = bpy.props.FloatProperty(
+ np_size_badge = bpy.props.IntProperty(
name='badge_size',
- description='Size of the mouse badge, the default is 2.0',
+ description='Size of the mouse badge, the default is 2',
default=2,
- min=0.5,
- step=10,
- precision=1)
-
+ min=0,
+ step=10)
op_prefs = bpy.props.EnumProperty(
name ='Individual operator settings',
diff --git a/np_station/np_shader_brush.py b/np_station/np_shader_brush.py
index 4fd7d971..ec68bec6 100644
--- a/np_station/np_shader_brush.py
+++ b/np_station/np_shader_brush.py
@@ -192,8 +192,8 @@ def draw_callback1_px(self, context):
display_instructions(region, rv3d, instruct, keys_aff, keys_nav, keys_neg)
- col_bg_fill_main_run = addon_settings_graph()['col_bg_fill_main_run']
- col_bg_fill_main_nav = addon_settings_graph()['col_bg_fill_main_nav']
+ col_bg_fill_main_run = addon_settings_graph('col_bg_fill_main_run')
+ col_bg_fill_main_nav = addon_settings_graph('col_bg_fill_main_nav')
# Drawing the small icon near the cursor and the shader name:
# First color is for lighter themes, second for default and darker themes:
diff --git a/np_station/utils_graphics.py b/np_station/utils_graphics.py
index e43d3d06..a8796048 100644
--- a/np_station/utils_graphics.py
+++ b/np_station/utils_graphics.py
@@ -32,101 +32,116 @@ from bpy.app.handlers import persistent
from .utils_geometry import *
from .utils_function import *
- # GET ADDON COLOR SETTINGS AND PRODUCE VALUES:
+# GET ADDON COLOR SETTINGS AND PRODUCE VALUES:
-def addon_settings_graph():
+class SettingsStore:
+ add_set_graph_dict = None
+# Use global SettingsStore class to store dict so it is not recreated each call
+# todo : come up with better way for storing and checking add-on settings
+def addon_settings_graph(key):
addon_prefs = bpy.context.user_preferences.addons[__package__].preferences
- np_col_scheme = addon_prefs.np_col_scheme
- np_size_num = int(round(addon_prefs.np_size_num, 0))
- #np_print('size_num', np_size_num)
- np_scale_dist = addon_prefs.np_scale_dist
- np_suffix_dist = addon_prefs.np_suffix_dist
- np_display_badge = addon_prefs.np_display_badge
- np_size_badge = int(round(addon_prefs.np_size_badge, 0))
-
- add_set_graph_dict = {}
-
- if np_col_scheme == 'csc_default_grey':
- add_set_graph_dict['col_font_np'] = (0.95, 0.95, 0.95, 1.0)
- add_set_graph_dict['col_font_instruct_main'] = (0.67, 0.67, 0.67, 1.0)
- add_set_graph_dict['col_font_instruct_shadow'] = (0.15, 0.15, 0.15, 1.0)
- add_set_graph_dict['col_font_keys'] = (0.15, 0.15, 0.15, 1.0)
- add_set_graph_dict['col_field_keys_aff'] = (0.51, 0.51, 0.51, 1.0)
- add_set_graph_dict['col_field_keys_neg'] = (0.41, 0.41, 0.41, 1.0)
-
- add_set_graph_dict['col_line_main'] = (0.9, 0.9, 0.9, 1.0)
- add_set_graph_dict['col_line_shadow'] = (0.1, 0.1, 0.1, 0.25)
- add_set_graph_dict['col_num_main'] = (0.95, 0.95, 0.95, 1.0)
- add_set_graph_dict['col_num_shadow'] = (0.0, 0.0, 0.0, 0.75)
-
- add_set_graph_dict['col_gw_line_cross'] = (0.25, 0.35, 0.4, 0.87)
- add_set_graph_dict['col_gw_line_base_free'] = (1.0, 1.0, 1.0, 0.85)
- add_set_graph_dict['col_gw_line_base_lock_x'] = (1.0, 0.0, 0.0, 1.0)
- add_set_graph_dict['col_gw_line_base_lock_y'] = (0.5, 0.75, 0.0, 1.0)
- add_set_graph_dict['col_gw_line_base_lock_z'] = (0.0, 0.2, 0.85, 1.0)
- add_set_graph_dict['col_gw_line_base_lock_arb'] = (0.0, 0.0, 0.0, 0.5)
- add_set_graph_dict['col_gw_line_all'] = (1.0, 1.0, 1.0, 0.85)
-
- add_set_graph_dict['col_gw_fill_base_x'] = (1.0, 0.0, 0.0, 0.2)
- add_set_graph_dict['col_gw_fill_base_y'] = (0.0, 1.0, 0.0, 0.2)
- add_set_graph_dict['col_gw_fill_base_z'] = (0.0, 0.2, 0.85, 0.2)
- add_set_graph_dict['col_gw_fill_base_arb'] = (0.0, 0.0, 0.0, 0.15)
-
- add_set_graph_dict['col_bg_fill_main_run'] = (1.0, 0.5, 0.0, 1.0)
- add_set_graph_dict['col_bg_fill_main_nav'] = (0.5, 0.75 ,0.0 ,1.0)
- add_set_graph_dict['col_bg_fill_square'] = (0.0, 0.0, 0.0, 1.0)
- add_set_graph_dict['col_bg_fill_aux'] = (0.4, 0.15, 0.75, 1.0) #(0.4, 0.15, 0.75, 1.0) (0.2, 0.15, 0.55, 1.0)
- add_set_graph_dict['col_bg_line_symbol'] = (1.0, 1.0, 1.0, 1.0)
- add_set_graph_dict['col_bg_font_main'] = (1.0, 1.0, 1.0, 1.0)
- add_set_graph_dict['col_bg_font_aux'] = (1.0, 1.0, 1.0, 1.0)
-
- elif np_col_scheme == 'csc_school_marine':
- add_set_graph_dict['col_font_np'] = (0.25, 0.35, 0.4, 0.87)
- add_set_graph_dict['col_font_instruct_main'] = (1.0, 1.0, 1.0, 1.0)
- add_set_graph_dict['col_font_instruct_shadow'] = (0.25, 0.35, 0.4, 0.6)
- add_set_graph_dict['col_font_keys'] = (1.0, 1.0, 1.0, 1.0)
- add_set_graph_dict['col_field_keys_aff'] = (0.55, 0.6, 0.64, 1.0)
- add_set_graph_dict['col_field_keys_neg'] = (0.67, 0.72, 0.76, 1.0)
-
- add_set_graph_dict['col_line_main'] = (1.0, 1.0, 1.0, 1.0)
- add_set_graph_dict['col_line_shadow'] = (0.1, 0.1, 0.1, 0.25)
- add_set_graph_dict['col_num_main'] = (0.25, 0.35, 0.4, 1.0) #(1.0, 0.5, 0.0, 1.0)
- add_set_graph_dict['col_num_shadow'] = (1.0, 1.0, 1.0, 1.0)
-
- add_set_graph_dict['col_gw_line_cross'] = (0.25, 0.35, 0.4, 0.87)
- add_set_graph_dict['col_gw_line_base_free'] = (1.0, 1.0, 1.0, 0.85)
- add_set_graph_dict['col_gw_line_base_lock_x'] = (1.0, 0.0, 0.0, 1.0)
- add_set_graph_dict['col_gw_line_base_lock_y'] = (0.5, 0.75, 0.0, 1.0)
- add_set_graph_dict['col_gw_line_base_lock_z'] = (0.0, 0.2, 0.85, 1.0)
- add_set_graph_dict['col_gw_line_base_lock_arb'] = (0.0, 0.0, 0.0, 0.5)
- add_set_graph_dict['col_gw_line_all'] = (1.0, 1.0, 1.0, 0.85)
-
- add_set_graph_dict['col_gw_fill_base_x'] = (1.0, 0.0, 0.0, 0.2)
- add_set_graph_dict['col_gw_fill_base_y'] = (0.0, 1.0, 0.0, 0.2)
- add_set_graph_dict['col_gw_fill_base_z'] = (0.0, 0.2, 0.85, 0.2)
- add_set_graph_dict['col_gw_fill_base_arb'] = (0.0, 0.0, 0.0, 0.15)
-
- add_set_graph_dict['col_bg_fill_main_run'] = (1.0, 0.5, 0.0, 1.0)
- add_set_graph_dict['col_bg_fill_main_nav'] = (0.5, 0.75 ,0.0 ,1.0)
- add_set_graph_dict['col_bg_fill_square'] = (0.0, 0.0, 0.0, 1.0)
- add_set_graph_dict['col_bg_fill_aux'] = (0.4, 0.15, 0.75, 1.0) #(0.4, 0.15, 0.75, 1.0) (0.2, 0.15, 0.55, 1.0)
- add_set_graph_dict['col_bg_line_symbol'] = (1.0, 1.0, 1.0, 1.0)
- add_set_graph_dict['col_bg_font_main'] = (1.0, 1.0, 1.0, 1.0)
- add_set_graph_dict['col_bg_font_aux'] = (1.0, 1.0, 1.0, 1.0)
-
-
- add_set_graph_dict['size_num'] = np_size_num
- add_set_graph_dict['scale_dist'] = np_scale_dist
- add_set_graph_dict['suffix_dist'] = np_suffix_dist
- add_set_graph_dict['display_badge'] = np_display_badge
- add_set_graph_dict['size_badge'] = np_size_badge
-
- return add_set_graph_dict
-
-
- # ON-SCREEN INSTRUCTIONS:
+ if SettingsStore.add_set_graph_dict is not None:
+ add_set_graph_dict = SettingsStore.add_set_graph_dict
+ settings_change = (
+ add_set_graph_dict['col_scheme'] != addon_prefs.np_col_scheme,
+ add_set_graph_dict['size_num'] != addon_prefs.np_size_num,
+ add_set_graph_dict['scale_dist'] != addon_prefs.np_scale_dist,
+ add_set_graph_dict['suffix_dist'] != addon_prefs.np_suffix_dist,
+ add_set_graph_dict['display_badge'] != addon_prefs.np_display_badge,
+ add_set_graph_dict['size_badge'] != addon_prefs.np_size_badge)
+ if True in settings_change:
+ SettingsStore.add_set_graph_dict = None
+
+ if SettingsStore.add_set_graph_dict is None:
+ #print(" add_set_graph_dict == None ")
+ add_set_graph_dict = {}
+ add_set_graph_dict.update(
+ col_scheme = addon_prefs.np_col_scheme,
+ size_num = addon_prefs.np_size_num,
+ scale_dist = addon_prefs.np_scale_dist,
+ suffix_dist = addon_prefs.np_suffix_dist,
+ display_badge = addon_prefs.np_display_badge,
+ size_badge = addon_prefs.np_size_badge)
+
+ if addon_prefs.np_col_scheme == 'csc_default_grey':
+ add_set_graph_dict.update(
+ col_font_np = (0.95, 0.95, 0.95, 1.0),
+ col_font_instruct_main = (0.67, 0.67, 0.67, 1.0),
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list