[Bf-extensions-cvs] [623a552f] master: np station: updating to 2017_05_12_golden_overlap
NBurn
noreply at git.blender.org
Wed Jun 7 05:49:51 CEST 2017
Commit: 623a552f16cb00fe021a7e0b61c2fbb3d5bfb8aa
Author: NBurn
Date: Tue Jun 6 23:47:33 2017 -0400
Branches: master
https://developer.blender.org/rBAC623a552f16cb00fe021a7e0b61c2fbb3d5bfb8aa
np station: updating to 2017_05_12_golden_overlap
===================================================================
M np_station/__init__.py
M np_station/np_point_distance.py
M np_station/utils_graphics.py
===================================================================
diff --git a/np_station/__init__.py b/np_station/__init__.py
index 1db8a481..d181c399 100644
--- a/np_station/__init__.py
+++ b/np_station/__init__.py
@@ -379,6 +379,11 @@ class NP020Preferences(bpy.types.AddonPreferences):
description = 'Include an extra step to display the last measured distance in the viewport',
default = False)
+ nppd_gold = bpy.props.BoolProperty(
+ name = 'Golden ratio',
+ description = 'Display a marker showing the position of the golden division point (1.61803 : 1)',
+ default = False)
+
nppd_info = bpy.props.BoolProperty(
name = 'Value to header info',
description = 'Display last measured distance on the header',
@@ -799,6 +804,7 @@ class NP020Preferences(bpy.types.AddonPreferences):
col = split.column()
col.prop(self, "nppd_hold")
col = split.column()
+ col.prop(self, "nppd_gold")
col = split.column()
col.prop(self, "nppd_info")
col = split.column()
diff --git a/np_station/np_point_distance.py b/np_station/np_point_distance.py
index a5df50b5..eeae8cf9 100644
--- a/np_station/np_point_distance.py
+++ b/np_station/np_point_distance.py
@@ -267,6 +267,7 @@ def draw_callback_px_TRANS(self, context):
xyz_distances = addon_prefs.nppd_xyz_distances
xyz_backdrop = addon_prefs.nppd_xyz_backdrop
stereo_cage = addon_prefs.nppd_stereo_cage
+ gold = addon_prefs.nppd_gold
if addon_prefs.nppd_col_line_main_DEF == False:
col_line_main = addon_prefs.nppd_col_line_main
@@ -341,8 +342,13 @@ def draw_callback_px_TRANS(self, context):
np_print(startloc2d, endloc2d)
# np_print('1')
dist = (mathutils.Vector(endloc3d) - mathutils.Vector(startloc3d))
+ distgold = dist / 1.6180339887
+ goldloc3d = mathutils.Vector(startloc3d) + distgold
+ goldloc2d = view3d_utils.location_3d_to_region_2d(
+ region, rv3d, goldloc3d)
distn = dist.length * scale
distn = str(abs(round(distn, 2)))
+
dist = dist.length * scale
if suffix is not None:
@@ -625,6 +631,70 @@ def draw_callback_px_TRANS(self, context):
bgl.glVertex2f(x, y)
bgl.glEnd()
+ if gold and phase != 0:
+ '''
+ goldtriangle = [[0, 0], [-1, 1], [1, 1]]
+ for co in goldtriangle:
+ co[0] = round((co[0] * 10), 0) + goldloc2d[0]
+ co[1] = round((co[1] * 10), 0) + goldloc2d[1]
+ bgl.glColor4f(1.0, 0.5, 0.0, 1.0)
+ bgl.glBegin(bgl.GL_TRIANGLE_FAN)
+ for x, y in goldtriangle:
+ bgl.glVertex2f(x, y)
+ bgl.glEnd()
+ '''
+ goldvec1 = mathutils.Vector((1.0 , 0.0))
+ goldvec2 = endloc2d - startloc2d
+ if goldvec1.length != 0.0 and goldvec2.length != 0.0:
+ ang = goldvec1.angle_signed(goldvec2)
+ coy = round(cos(ang), 8)
+ cox = round(sin(ang), 8)
+ goldtick = [[-cox, -coy], [0, 0], [cox, coy]]
+ for co in goldtick:
+ co[0] = round((co[0] * 10), 0) + goldloc2d[0]
+ co[1] = round((co[1] * 10), 0) + goldloc2d[1]
+ bgl.glColor4f(0.95, 0.55, 0.0, 1.0)
+ bgl.glLineWidth(2)
+ bgl.glBegin(bgl.GL_LINE_STRIP)
+ for x, y in goldtick:
+ bgl.glVertex2f(x, y)
+ bgl.glEnd()
+ bgl.glLineWidth(1)
+ if xyz_distances:
+ distgold_first = (goldloc3d - startloc3d).length * scale
+ distgold_first = str(abs(round(distgold_first, 2)))
+ distgold_sec = (endloc3d - goldloc3d).length * scale
+ distgold_sec = str(abs(round(distgold_sec, 2)))
+ goldloc_first = [((startloc2d[0] + goldloc2d[0]) / 2), ((startloc2d[1] + goldloc2d[1]) / 2)]
+ goldloc_sec = [((goldloc2d[0] + endloc2d[0]) / 2), ((goldloc2d[1] + endloc2d[1]) / 2)]
+ if xyz_backdrop:
+ bgl.glColor4f(1.0, 0.5, 0.0, 1.0)
+ bgl.glBegin(bgl.GL_TRIANGLE_FAN)
+ bgl.glVertex2f(goldloc_first[0]-2, goldloc_first[1]-2)
+ bgl.glVertex2f(goldloc_first[0]-2, goldloc_first[1]+10)
+ bgl.glVertex2f(goldloc_first[0]+50, goldloc_first[1]+10)
+ bgl.glVertex2f(goldloc_first[0]+50, goldloc_first[1]-2)
+ bgl.glEnd()
+ bgl.glColor4f(0.95, 0.55, 0.0, 1.0)
+ if xyz_backdrop:
+ bgl.glColor4f(1.0, 1.0, 1.0, 1.0)
+ blf.position(font_id, goldloc_first[0], goldloc_first[1], 0)
+ blf.draw(font_id, distgold_first)
+ if xyz_backdrop:
+ bgl.glColor4f(1.0, 0.5, 0.0, 1.0)
+ bgl.glBegin(bgl.GL_TRIANGLE_FAN)
+ bgl.glVertex2f(goldloc_sec[0]-2, goldloc_sec[1]-2)
+ bgl.glVertex2f(goldloc_sec[0]-2, goldloc_sec[1]+10)
+ bgl.glVertex2f(goldloc_sec[0]+50, goldloc_sec[1]+10)
+ bgl.glVertex2f(goldloc_sec[0]+50, goldloc_sec[1]-2)
+ bgl.glEnd()
+ bgl.glColor4f(0.95, 0.55, 0.0, 1.0)
+ if xyz_backdrop:
+ bgl.glColor4f(1.0, 1.0, 1.0, 1.0)
+ blf.position(font_id, goldloc_sec[0], goldloc_sec[1], 0)
+ blf.draw(font_id, distgold_sec)
+
+
# NUMERICAL DISTANCE:
square = [[17, 30], [17, 40], [27, 40], [27, 30]]
diff --git a/np_station/utils_graphics.py b/np_station/utils_graphics.py
index 1abd1900..111a60ec 100644
--- a/np_station/utils_graphics.py
+++ b/np_station/utils_graphics.py
@@ -130,6 +130,29 @@ def addon_settings_graph():
def display_instructions(region, rv3d, instruct, keys_aff, keys_nav, keys_neg):
+
+ userpref = bpy.context.user_preferences
+ system = userpref.system
+ rwtools = 0
+ rwui = 0
+
+ np_print(system.window_draw_method, system.use_region_overlap)
+
+
+ if system.use_region_overlap:
+ if system.window_draw_method in ('TRIPLE_BUFFER', 'AUTOMATIC') :
+
+ area = bpy.context.area
+ np_print('GO', area.regions)
+ for r in area.regions:
+ if r.type == 'TOOLS':
+ rwtools = r.width
+ elif r.type == 'UI':
+ rwui = r.width
+
+ np_print('rwtools', rwtools, 'rwui', rwui)
+ field_keys_y = 46
+ field_keys_x = 80
rw = region.width
rh = region.height
np_print('rw, rh', rw, rh)
@@ -137,7 +160,7 @@ def display_instructions(region, rv3d, instruct, keys_aff, keys_nav, keys_neg):
expand = False
crop = False
- len_aff_max = rw - 140
+ len_aff_max = rw - 140 - rwtools - rwui
len_aff = len(keys_aff) * 5
len_neg = len(keys_neg) * 5
len_ins = len(instruct) * 18
@@ -145,7 +168,7 @@ def display_instructions(region, rv3d, instruct, keys_aff, keys_nav, keys_neg):
rw_min = 480
rh_min = 280
- if rw < rw_min or rh < rh_min: crop = True
+ if rw - rwtools - rwui < rw_min or rh < rh_min: crop = True
version = '020'
@@ -170,42 +193,41 @@ def display_instructions(region, rv3d, instruct, keys_aff, keys_nav, keys_neg):
np_print(keys_aff_1)
np_print(keys_aff_2)
- field_keys_y = 46
- field_keys_x = 80
- field_keys_aff_1 = [[field_keys_x, field_keys_y + 21], [field_keys_x, field_keys_y + 39], [rw - int(field_keys_x / 2), field_keys_y + 39], [rw - int(field_keys_x / 2), field_keys_y + 21]]
+
+ field_keys_aff_1 = [[field_keys_x + rwtools, field_keys_y + 21], [field_keys_x + rwtools, field_keys_y + 39], [rw - int(field_keys_x / 2) - rwui, field_keys_y + 39], [rw - int(field_keys_x / 2) - rwui, field_keys_y + 21]]
field_keys_aff_2 = copy.deepcopy(field_keys_aff_1)
- field_keys_neg = [[field_keys_x, field_keys_y], [field_keys_x, field_keys_y + 18], [rw - field_keys_x / 2, field_keys_y + 18], [rw - field_keys_x / 2, field_keys_y]]
+ field_keys_neg = [[field_keys_x + rwtools, field_keys_y], [field_keys_x + rwtools, field_keys_y + 18], [rw - int(field_keys_x / 2) - rwui, field_keys_y + 18], [rw - int(field_keys_x / 2) - rwui, field_keys_y]]
if expand:
field_keys_aff_2 = copy.deepcopy(field_keys_neg)
- field_keys_neg = [[field_keys_x, field_keys_y - 21], [field_keys_x, field_keys_y - 3], [rw - field_keys_x / 2, field_keys_y - 3], [rw - field_keys_x / 2, field_keys_y - 21]]
+ field_keys_neg = [[field_keys_x + rwtools, field_keys_y - 21], [field_keys_x + rwtools, field_keys_y - 3], [rw - int(field_keys_x / 2) - rwui, field_keys_y - 3], [rw - int(field_keys_x / 2) - rwui, field_keys_y - 21]]
size_font_np = 25
size_font_instruct = 21
size_font_keys = 11
len_np_ins = len_ins + int(size_font_np * 2.1)
- pos_font_np_x = (rw - (len_np_ins / 2)) / 2
+ pos_font_np_x = (rw - len_np_ins / 2) / 2 + rwtools / 2 - rwui / 2
pos_font_np_y = 150
if crop: pos_font_np_y = 75
pos_font_instruct_x = pos_font_np_x + int(size_font_np * 2.1)
pos_font_instruct_y = pos_font_np_y + 4
- pos_font_keys_aff_1_x = field_keys_x + 8
+ pos_font_keys_aff_1_x = field_keys_x + 8 + rwtools
pos_font_keys_aff_1_y = field_keys_y + 26
pos_font_keys_aff_2_x = copy.deepcopy(pos_font_keys_aff_1_x)
pos_font_keys_aff_2_y = copy.deepcopy(pos_font_keys_aff_1_y)
- pos_font_keys_nav_x = field_keys_x + 8
+ pos_font_keys_nav_x = field_keys_x + 8 + rwtools
pos_font_keys_nav_y = field_keys_y + 5
- pos_font_keys_neg_x = rw - 52 - len_neg
+ pos_font_keys_neg_x = rw - 52 - len_neg - rwui
np_print('len_neg', len_neg)
np_print('pos_font_keys_neg_x', pos_font_keys_neg_x)
pos_font_keys_neg_y = field_keys_y + 5
if expand:
- pos_font_keys_aff_2_x = field_keys_x + 8
+ pos_font_keys_aff_2_x = field_keys_x + 8 + rwtools
pos_font_keys_aff_2_y = field_keys_y + 5
- pos_font_keys_nav_x = field_keys_x + 8
+ pos_font_keys_nav_x = field_keys_x + 8 + rwtools
pos_font_keys_nav_y = field_keys_y - 16
- pos_font_keys_neg_x = rw - 52 - len_neg
- pos_font_keys_neg_y = field_keys_y
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list