Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNBurn <nbwashburn@gmail.com>2017-08-12 08:01:05 +0300
committerNBurn <nbwashburn@gmail.com>2017-08-12 08:01:05 +0300
commit6451d10ff48f0bf4d95b504da295f760f64df14e (patch)
tree5460754389e01ec69cd2e22456e0cfc9975fabf6
parent8068085bda0192fff3bb28a27bdc3c269dd3bcef (diff)
MeasureIt: Refactored code and added align options
Added option to rotate measurements to be align to specified angles in degrees Added option to horizontally align text to left, center, or right Added option to expand or collapse all measurement subpanels Redesign of Number panel option so its easier to match colors with measurements Hid various measurement adjustment options when disabled and would have no affect Redesign of button layout to reduce text truncation and improve visibility Minor cleanup of comments and code for better readability and pep8 compliance
-rw-r--r--measureit/__init__.py105
-rw-r--r--measureit/measureit_geometry.py92
-rw-r--r--measureit/measureit_main.py202
3 files changed, 280 insertions, 119 deletions
diff --git a/measureit/__init__.py b/measureit/__init__.py
index bc9ce20f..a07eb662 100644
--- a/measureit/__init__.py
+++ b/measureit/__init__.py
@@ -141,6 +141,8 @@ def register():
bpy.utils.register_class(measureit_main.MeasureitConfPanel)
bpy.utils.register_class(measureit_main.MeasureitRenderPanel)
bpy.utils.register_class(measureit_main.RenderSegmentButton)
+ bpy.utils.register_class(measureit_main.ExpandAllSegmentButton)
+ bpy.utils.register_class(measureit_main.CollapseAllSegmentButton)
bpy.utils.register_class(Measure_Pref)
update_panel(None, bpy.context)
# Define properties
@@ -190,12 +192,12 @@ def register():
Scene.measureit_scale_font = IntProperty(name="Font",
description="Text size",
default=14, min=10, max=150)
- Scene.measureit_scale_pos_x = IntProperty(name="Position X",
+ Scene.measureit_scale_pos_x = IntProperty(name="X Position",
description="Margin on the X axis",
default=5,
min=0,
max=100)
- Scene.measureit_scale_pos_y = IntProperty(name="Position Y",
+ Scene.measureit_scale_pos_y = IntProperty(name="Y Position",
description="Margin on the Y axis",
default=5,
min=0,
@@ -205,7 +207,6 @@ def register():
default="Scale:")
Scene.measureit_scale_precision = IntProperty(name='Precision', min=0, max=5, default=0,
description="Number of decimal precision")
-
Scene.measureit_ovr = BoolProperty(name="Override",
description="Override colors and fonts",
default=False)
@@ -222,6 +223,13 @@ def register():
Scene.measureit_ovr_width = IntProperty(name='Override width', min=1, max=10, default=1,
description='override line width')
+ Scene.measureit_ovr_font_rotation = IntProperty(name='Rotate', min=0, max=360, default=0,
+ description="Text rotation in degrees")
+ Scene.measureit_ovr_font_align = EnumProperty(items=(('L', "Left Align", "Use current render"),
+ ('C', "Center Align", ""),
+ ('R', "Right Align", "")),
+ name="Align Font",
+ description="Set Font Alignment")
Scene.measureit_units = EnumProperty(items=(('1', "Automatic", "Use scene units"),
('2', "Meters", ""),
('3', "Centimeters", ""),
@@ -326,14 +334,14 @@ def register():
description="Display vertex index number",
default=True)
Scene.measureit_debug_objects = BoolProperty(name="Objects",
- description="Display object scene index number",
- default=False)
+ description="Display object scene index number",
+ default=False)
Scene.measureit_debug_vert_loc = BoolProperty(name="Location",
description="Display vertex location",
default=False)
Scene.measureit_debug_object_loc = BoolProperty(name="Location",
- description="Display object location",
- default=False)
+ description="Display object location",
+ default=False)
Scene.measureit_debug_edges = BoolProperty(name="Edges",
description="Display edge index number",
default=False)
@@ -351,40 +359,40 @@ def register():
description="Debug text size",
default=14, min=10, max=150)
Scene.measureit_debug_vert_color = FloatVectorProperty(name="Debug color",
- description="Debug Color",
- default=(1, 0, 0, 1.0),
- min=0.1,
- max=1,
- subtype='COLOR',
- size=4)
+ description="Debug Color",
+ default=(1, 0, 0, 1.0),
+ min=0.1,
+ max=1,
+ subtype='COLOR',
+ size=4)
Scene.measureit_debug_face_color = FloatVectorProperty(name="Debug face color",
- description="Debug face Color",
- default=(0, 1, 0, 1.0),
- min=0.1,
- max=1,
- subtype='COLOR',
- size=4)
+ description="Debug face Color",
+ default=(0, 1, 0, 1.0),
+ min=0.1,
+ max=1,
+ subtype='COLOR',
+ size=4)
Scene.measureit_debug_norm_color = FloatVectorProperty(name="Debug vector color",
- description="Debug vector Color",
- default=(1.0, 1.0, 0.1, 1.0),
- min=0.1,
- max=1,
- subtype='COLOR',
- size=4)
+ description="Debug vector Color",
+ default=(1.0, 1.0, 0.1, 1.0),
+ min=0.1,
+ max=1,
+ subtype='COLOR',
+ size=4)
Scene.measureit_debug_edge_color = FloatVectorProperty(name="Debug vector color",
- description="Debug vector Color",
- default=(0.1, 1.0, 1.0, 1.0),
- min=0.1,
- max=1,
- subtype='COLOR',
- size=4)
+ description="Debug vector Color",
+ default=(0.1, 1.0, 1.0, 1.0),
+ min=0.1,
+ max=1,
+ subtype='COLOR',
+ size=4)
Scene.measureit_debug_obj_color = FloatVectorProperty(name="Debug vector color",
- description="Debug vector Color",
- default=(1.0, 1.0, 1.0, 1.0),
- min=0.1,
- max=1,
- subtype='COLOR',
- size=4)
+ description="Debug vector Color",
+ default=(1.0, 1.0, 1.0, 1.0),
+ min=0.1,
+ max=1,
+ subtype='COLOR',
+ size=4)
Scene.measureit_debug_normal_size = FloatProperty(name='Len', min=0.001, max=9,
default=0.5,
precision=2,
@@ -394,11 +402,18 @@ def register():
Scene.measureit_debug_precision = IntProperty(name='Precision', min=0, max=5, default=1,
description="Number of decimal precision")
Scene.measureit_debug_vert_loc_toggle = EnumProperty(items=(('1', "Local",
- "Uses local coordinates"),
- ('2', "Global",
- "Uses global coordinates")),
- name="Coordinates",
- description="Choose coordinate system")
+ "Uses local coordinates"),
+ ('2', "Global",
+ "Uses global coordinates")),
+ name="Coordinates",
+ description="Choose coordinate system")
+ Scene.measureit_font_rotation = IntProperty(name='Rotate', min=0, max=360, default=0,
+ description="Default text rotation in degrees")
+ Scene.measureit_font_align = EnumProperty(items=(('L', "Left Align", "Use current render"),
+ ('C', "Center Align", ""),
+ ('R', "Right Align", "")),
+ name="Align Font",
+ description="Set Font Alignment")
# OpenGL flag
wm = WindowManager
@@ -425,6 +440,8 @@ def unregister():
bpy.utils.unregister_class(measureit_main.MeasureitConfPanel)
bpy.utils.unregister_class(measureit_main.MeasureitRenderPanel)
bpy.utils.unregister_class(measureit_main.RenderSegmentButton)
+ bpy.utils.unregister_class(measureit_main.ExpandAllSegmentButton)
+ bpy.utils.unregister_class(measureit_main.CollapseAllSegmentButton)
bpy.utils.unregister_class(Measure_Pref)
# Remove properties
@@ -448,6 +465,8 @@ def unregister():
del Scene.measureit_ovr_font
del Scene.measureit_ovr_color
del Scene.measureit_ovr_width
+ del Scene.measureit_ovr_font_rotation
+ del Scene.measureit_ovr_font_align
del Scene.measureit_units
del Scene.measureit_hide_units
del Scene.measureit_render
@@ -480,6 +499,8 @@ def unregister():
del Scene.measureit_debug_vert_loc
del Scene.measureit_debug_object_loc
del Scene.measureit_debug_vert_loc_toggle
+ del Scene.measureit_font_rotation
+ del Scene.measureit_font_align
# remove OpenGL data
measureit_main.RunHintDisplayButton.handle_remove(measureit_main.RunHintDisplayButton, bpy.context)
diff --git a/measureit/measureit_geometry.py b/measureit/measureit_geometry.py
index 87b97a20..8a23d817 100644
--- a/measureit/measureit_geometry.py
+++ b/measureit/measureit_geometry.py
@@ -29,6 +29,7 @@ import bpy
import bgl
# noinspection PyUnresolvedReferences
import blf
+from blf import ROTATION
from math import fabs, degrees, radians, sqrt, cos, sin, pi
from mathutils import Vector, Matrix
from bmesh import from_edit_mesh
@@ -54,8 +55,11 @@ def draw_segments(context, myobj, op, region, rv3d):
ovr = scene.measureit_ovr
ovrcolor = scene.measureit_ovr_color
ovrfsize = scene.measureit_ovr_font
+ ovrfang = get_angle_in_rad(scene.measureit_ovr_font_rotation)
+ ovrfaln = scene.measureit_ovr_font_align
ovrline = scene.measureit_ovr_width
units = scene.measureit_units
+ fang = get_angle_in_rad(scene.measureit_font_rotation)
# --------------------
# Scene Scale
# --------------------
@@ -66,7 +70,8 @@ def draw_segments(context, myobj, op, region, rv3d):
tx_dsp = fmts % scene.measureit_scale_factor
tx_scale = scene.measureit_gl_scaletxt + " 1:" + tx_dsp
draw_text(myobj, pos_2d,
- tx_scale, scene.measureit_scale_color, scene.measureit_scale_font)
+ tx_scale, scene.measureit_scale_color, scene.measureit_scale_font,
+ text_rot=fang)
# --------------------
# Loop
# --------------------
@@ -74,8 +79,12 @@ def draw_segments(context, myobj, op, region, rv3d):
ms = op.measureit_segments[idx]
if ovr is False:
fsize = ms.glfont_size
+ fang = get_angle_in_rad(ms.glfont_rotat)
+ faln = ms.glfont_align
else:
fsize = ovrfsize
+ fang = ovrfang
+ faln = ovrfaln
# ------------------------------
# only active and visible
# ------------------------------
@@ -239,8 +248,8 @@ def draw_segments(context, myobj, op, region, rv3d):
loc = get_location(myobj)
midpoint3d = interpolate3d(a_p1, b_p1, fabs(dist / 2))
vn = Vector((midpoint3d[0] - loc[0],
- midpoint3d[1] - loc[1],
- midpoint3d[2] - loc[2]))
+ midpoint3d[1] - loc[1],
+ midpoint3d[2] - loc[2]))
else:
vn = Vector((ms.glnormalx, ms.glnormaly, ms.glnormalz))
@@ -308,7 +317,7 @@ def draw_segments(context, myobj, op, region, rv3d):
screen_point_v22 = get_2d_point(region, rv3d, v22)
screen_point_v11a = get_2d_point(region, rv3d, v11a)
screen_point_v11b = get_2d_point(region, rv3d, v11b)
-
+
# ------------------------------------
# colour + line setup
# ------------------------------------
@@ -357,7 +366,7 @@ def draw_segments(context, myobj, op, region, rv3d):
if scene.measureit_gl_show_n is True and ms.glnames is True:
msg += ms.gltxt
if scene.measureit_gl_show_d is True or scene.measureit_gl_show_n is True:
- draw_text(myobj, txtpoint2d, msg, rgb, fsize)
+ draw_text(myobj, txtpoint2d, msg, rgb, fsize, faln, fang)
# ------------------------------
# if axis loc, show a indicator
@@ -372,7 +381,7 @@ def draw_segments(context, myobj, op, region, rv3d):
if ms.glocz is True:
txt += "Z"
txt += "]"
- draw_text(myobj, txtpoint2d, txt, rgb, fsize - 1)
+ draw_text(myobj, txtpoint2d, txt, rgb, fsize - 1, text_rot=fang)
except:
pass
@@ -381,16 +390,13 @@ def draw_segments(context, myobj, op, region, rv3d):
# ------------------------------------
# noinspection PyBroadException
if ms.gltype == 2 or ms.gltype == 9 or ms.gltype == 11:
- right = False
tx_dist = ""
# noinspection PyBroadException
try:
if ms.gltype == 2:
tx_dist = ms.gltxt
- right = False
if ms.gltype == 9: # Angles
ang = ang_1.angle(ang_2)
- right = True
if bpy.context.scene.unit_settings.system_rotation == "DEGREES":
ang = degrees(ang)
@@ -402,7 +408,6 @@ def draw_segments(context, myobj, op, region, rv3d):
if scene.measureit_gl_show_n is True:
tx_dist += " " + ms.gltxt
if ms.gltype == 11: # arc
- right = True
# print length or arc and angle
if ms.glarc_len is True:
tx_dist = ms.glarc_txlen + format_distance(fmt, units, arc_length)
@@ -424,14 +429,15 @@ def draw_segments(context, myobj, op, region, rv3d):
msg = tx_dist + " "
else:
msg = " "
+
if scene.measureit_gl_show_n is True and ms.glnames is True:
msg += ms.gltxt
if scene.measureit_gl_show_d is True or scene.measureit_gl_show_n is True:
# Normal vector
vna = Vector((b_p1[0] - a_p1[0],
- b_p1[1] - a_p1[1],
- b_p1[2] - a_p1[2]))
+ b_p1[1] - a_p1[1],
+ b_p1[2] - a_p1[2]))
vna.normalize()
via = vna * ms.glspace
@@ -439,9 +445,10 @@ def draw_segments(context, myobj, op, region, rv3d):
tmp_point = get_2d_point(region, rv3d, gap3d)
if tmp_point is not None:
txtpoint2d = tmp_point[0] + ms.glfontx, tmp_point[1] + ms.glfonty
- draw_text(myobj, txtpoint2d, msg, rgb, fsize, right)
+ draw_text(myobj, txtpoint2d, msg, rgb, fsize, faln, fang)
# Radius
- if scene.measureit_gl_show_d is True and ms.gldist is True and ms.glarc_rad is True:
+ if scene.measureit_gl_show_d is True and ms.gldist is True and \
+ ms.glarc_rad is True:
tx_dist = ms.glarc_txradio + format_distance(fmt, units,
dist * scene.measureit_scale_factor)
else:
@@ -454,7 +461,7 @@ def draw_segments(context, myobj, op, region, rv3d):
tmp_point = get_2d_point(region, rv3d, gap3d)
if tmp_point is not None:
txtpoint2d = tmp_point[0] + ms.glfontx, tmp_point[1] + ms.glfonty
- draw_text(myobj, txtpoint2d, tx_dist, rgb, fsize, right)
+ draw_text(myobj, txtpoint2d, tx_dist, rgb, fsize, faln, fang)
except:
pass
# ------------------------------------
@@ -468,7 +475,7 @@ def draw_segments(context, myobj, op, region, rv3d):
tmp_point = get_2d_point(region, rv3d, gap3d)
if tmp_point is not None:
txtpoint2d = tmp_point[0] + ms.glfontx, tmp_point[1] + ms.glfonty
- draw_text(myobj, txtpoint2d, tx_dist, rgb, fsize)
+ draw_text(myobj, txtpoint2d, tx_dist, rgb, fsize, faln, fang)
# ------------------------------------
# Draw lines
@@ -517,8 +524,8 @@ def draw_segments(context, myobj, op, region, rv3d):
draw_arrow(screen_point_ap1, screen_point_bp1, a_size, a_type, b_type)
else:
vne = Vector((b_p1[0] - a_p1[0],
- b_p1[1] - a_p1[1],
- b_p1[2] - a_p1[2]))
+ b_p1[1] - a_p1[1],
+ b_p1[2] - a_p1[2]))
vne.normalize()
vie = vne * ms.glspace
pe = (b_p1[0] + vie[0], b_p1[1] + vie[1], b_p1[2] + vie[2])
@@ -534,14 +541,14 @@ def draw_segments(context, myobj, op, region, rv3d):
step = arc_angle / n_step
else:
step = radians(360.0) / n_step
- #
+
mat_rot1 = Matrix.Rotation(step, 4, vn)
mat_trans2 = Matrix.Translation(c)
p1 = Vector(an_p1) # first point of arc
# Normal vector
vn = Vector((p1[0] - a_p1[0],
- p1[1] - a_p1[1],
- p1[2] - a_p1[2]))
+ p1[1] - a_p1[1],
+ p1[2] - a_p1[2]))
vn.normalize()
vi = vn * ms.glspace
@@ -560,8 +567,8 @@ def draw_segments(context, myobj, op, region, rv3d):
# Normal vector
vn = Vector((p2[0] - a_p1[0],
- p2[1] - a_p1[1],
- p2[2] - a_p1[2]))
+ p2[1] - a_p1[1],
+ p2[2] - a_p1[2]))
vn.normalize()
vi = vn * ms.glspace
@@ -634,7 +641,8 @@ def draw_segments(context, myobj, op, region, rv3d):
tmp_point = get_2d_point(region, rv3d, midpoint3d)
if tmp_point is not None:
txtpoint2d = tmp_point[0] + ms.glfontx, tmp_point[1] + ms.glfonty
- draw_text(myobj, txtpoint2d, msg, ms.glcolorarea, fsize)
+ # todo: swap ms.glcolorarea with ms.glcolor ?
+ draw_text(myobj, txtpoint2d, msg, ms.glcolorarea, fsize, faln, fang)
except IndexError:
ms.glfree = True
@@ -789,17 +797,17 @@ def get_group_sum(myobj, tag):
# -------------------------------------------------------------
# Create OpenGL text
#
-# right: Align to right
# -------------------------------------------------------------
-#def draw_text(myobj, x_pos, y_pos, display_text, rgb, fsize, right=False):
-def draw_text(myobj, pos2d, display_text, rgb, fsize, right=False):
+def draw_text(myobj, pos2d, display_text, rgb, fsize, align='L', text_rot=0.0):
if pos2d is None:
return
- x_pos, y_pos = pos2d
+ # dpi = bpy.context.user_preferences.system.dpi
gap = 12
+ x_pos, y_pos = pos2d
font_id = 0
blf.size(font_id, fsize, 72)
+ # blf.size(font_id, fsize, dpi)
# height of one line
mwidth, mheight = blf.dimensions(font_id, "Tp") # uses high/low letters
@@ -823,10 +831,14 @@ def draw_text(myobj, pos2d, display_text, rgb, fsize, right=False):
# -------------------
for line in mylines:
text_width, text_height = blf.dimensions(font_id, line)
- if right is True:
+ if align is 'C':
+ newx = x_pos - text_width / 2
+ elif align is 'R':
newx = x_pos - text_width - gap
else:
newx = x_pos
+ blf.enable(font_id, ROTATION)
+ blf.rotation(font_id, text_rot)
# calculate new Y position
new_y = y_pos + (mheight * idx)
# Draw
@@ -839,6 +851,9 @@ def draw_text(myobj, pos2d, display_text, rgb, fsize, right=False):
if maxwidth < text_width:
maxwidth = text_width
+ if align is 'L':
+ blf.disable(font_id, ROTATION)
+
return maxwidth, maxheight
@@ -1043,7 +1058,7 @@ def draw_vertices(context, myobj, region, rv3d):
if v.select is False:
continue
# noinspection PyBroadException
- #try:
+ # try:
a_p1 = get_point(v.co, myobj)
# colour
bgl.glColor4f(rgb[0], rgb[1], rgb[2], rgb[3])
@@ -1056,9 +1071,9 @@ def draw_vertices(context, myobj, region, rv3d):
if scene.measureit_debug_vert_loc is True:
txt += format_point(co_mult(v.co), precision)
draw_text(myobj, txtpoint2d, txt, rgb, fsize)
- #except:
- # print("Unexpected error:" + str(exc_info()))
- # pass
+ # except:
+ # print("Unexpected error:" + str(exc_info()))
+ # pass
return
@@ -1452,3 +1467,14 @@ def format_distance(fmt, units, value, factor=1):
tx_dist = fmt % value
return tx_dist
+
+
+# -------------------------------------------------------------
+# Get radian float based on angle choice
+#
+# -------------------------------------------------------------
+def get_angle_in_rad(fangle):
+ if fangle == 0:
+ return 0.0
+ else:
+ return radians(fangle)
diff --git a/measureit/measureit_main.py b/measureit/measureit_main.py
index 633a1754..f325f8ab 100644
--- a/measureit/measureit_main.py
+++ b/measureit/measureit_main.py
@@ -160,6 +160,13 @@ class MeasureitProperties(PropertyGroup):
glfont_size = IntProperty(name="Text Size",
description="Text size",
default=14, min=6, max=150)
+ glfont_align = EnumProperty(items=(('L', "Left Align", ""),
+ ('C', "Center Align", ""),
+ ('R', "Right Align", "")),
+ name="Align Font",
+ description="Set Font Alignment")
+ glfont_rotat = IntProperty(name='Rotate', min=0, max=360, default=0,
+ description="Text rotation in degrees")
gllink = StringProperty(name="gllink",
description="linked object for linked measures")
glocwarning = BoolProperty(name="glocwarning",
@@ -365,13 +372,16 @@ class MeasureitEditPanel(Panel):
row = box.row()
row.prop(scene, 'measureit_scale', text="Scale")
if scene.measureit_scale is True:
- row.prop(scene, 'measureit_scale_factor', text="1")
- row.prop(scene, 'measureit_scale_precision', text="")
- row.prop(scene, 'measureit_gl_scaletxt', text="")
+ split = row.split(percentage=0.25, align=False)
+ split.prop(scene, 'measureit_scale_color', text="")
+ split.prop(scene, 'measureit_scale_factor', text="1")
row = box.row()
- row.prop(scene, 'measureit_scale_color')
+ row.separator()
+ row.prop(scene, 'measureit_gl_scaletxt', text="")
row.prop(scene, 'measureit_scale_font')
+ row.prop(scene, 'measureit_scale_precision', text="")
row = box.row()
+ row.separator()
row.prop(scene, 'measureit_scale_pos_x')
row.prop(scene, 'measureit_scale_pos_y')
@@ -379,9 +389,15 @@ class MeasureitEditPanel(Panel):
row = box.row()
row.prop(scene, 'measureit_ovr', text="Override")
if scene.measureit_ovr is True:
- row.prop(scene, 'measureit_ovr_color', text="")
+ split = row.split(percentage=0.25, align=False)
+ split.prop(scene, 'measureit_ovr_color', text="")
+ split.prop(scene, 'measureit_ovr_width', text="Width")
+ row = box.row()
+ row.separator()
row.prop(scene, 'measureit_ovr_font', text="Font")
- row.prop(scene, 'measureit_ovr_width', text="Width")
+ row.prop(scene, 'measureit_ovr_font_align', text="")
+ if scene.measureit_ovr_font_align == 'L':
+ row.prop(scene, 'measureit_ovr_font_rotation', text="Rotate")
mp = context.object.MeasureGenerator[0]
# -----------------
@@ -389,6 +405,9 @@ class MeasureitEditPanel(Panel):
# -----------------
if mp.measureit_num > 0:
box = layout.box()
+ row = box.row(True)
+ row.operator("measureit.expandallsegmentbutton", text="Expand all", icon="ZOOMIN")
+ row.operator("measureit.collapseallsegmentbutton", text="Collapse all", icon="ZOOMOUT")
for idx in range(0, mp.measureit_num):
if mp.measureit_segments[idx].glfree is False:
add_item(box, idx, mp.measureit_segments[idx])
@@ -479,9 +498,10 @@ class MeasureitEditPanel(Panel):
# -----------------------------------------------------
-# Add segment to the panel.
+# Add segment options to the panel.
# -----------------------------------------------------
def add_item(box, idx, segment):
+ scene = bpy.context.scene
row = box.row(True)
if segment.glview is True:
icon = "VISIBLE_IPO_ON"
@@ -489,17 +509,27 @@ def add_item(box, idx, segment):
icon = "VISIBLE_IPO_OFF"
row.prop(segment, 'glview', text="", toggle=True, icon=icon)
- row.prop(segment, 'gladvance', text="", toggle=True, icon="MANIPUL")
- row.prop(segment, 'gltxt', text="")
- row.prop(segment, 'glcolor', text="")
+ row.prop(segment, 'gladvance', text="", toggle=True, icon="SCRIPTWIN")
+ if segment.gltype == 20: # Area special
+ split = row.split(percentage=0.15, align=True)
+ split.prop(segment, 'glcolorarea', text="")
+ split = split.split(percentage=0.20, align=True)
+ split.prop(segment, 'glcolor', text="")
+ else:
+ split = row.split(percentage=0.25, align=True)
+ split.prop(segment, 'glcolor', text="")
+ split.prop(segment, 'gltxt', text="")
op = row.operator("measureit.deletesegmentbutton", text="", icon="X")
op.tag = idx # saves internal data
if segment.gladvance is True:
row = box.row(True)
- if segment.gltype != 10 and segment.gltype != 20:
- row.prop(segment, 'glspace', text="Distance")
-
row.prop(segment, 'glfont_size', text="Font")
+ row.prop(segment, 'glfont_align', text="")
+ if segment.glfont_align == 'L':
+ row.prop(segment, 'glfont_rotat', text="Rotate")
+ row = box.row(True)
+ if segment.gltype != 9 and segment.gltype != 10 and segment.gltype != 20:
+ row.prop(segment, 'glspace', text="Distance")
row.prop(segment, 'glfontx', text="X")
row.prop(segment, 'glfonty', text="Y")
@@ -513,13 +543,15 @@ def add_item(box, idx, segment):
if segment.gltype != 2 and segment.gltype != 10:
row = box.row(True)
- row.prop(segment, 'gldist', text="Distance", toggle=True, icon="ALIGN")
- row.prop(segment, 'glnames', text="Text", toggle=True, icon="FONT_DATA")
+ if scene.measureit_gl_show_d is True and segment.gltype != 9:
+ row.prop(segment, 'gldist', text="Distance", toggle=True, icon="ALIGN")
+ if scene.measureit_gl_show_n is True:
+ row.prop(segment, 'glnames', text="Text", toggle=True, icon="FONT_DATA")
# sum distances
if segment.gltype == 1 or segment.gltype == 12 or segment.gltype == 13 or segment.gltype == 14:
row.prop(segment, 'gltot', text="Sum")
- if segment.gltype != 10 and segment.gltype != 20:
+ if segment.gltype != 9 and segment.gltype != 10 and segment.gltype != 20:
row = box.row(True)
row.prop(segment, 'glwidth', text="Line")
row.prop(segment, 'gldefault', text="Automatic position")
@@ -530,8 +562,9 @@ def add_item(box, idx, segment):
row.prop(segment, 'glnormalz', text="Z")
# Loc axis
- if segment.gltype != 2 and segment.gltype != 10 \
- and segment.gltype != 12 and segment.gltype != 13 and segment.gltype != 14 and segment.gltype != 20:
+ if segment.gltype != 2 and segment.gltype != 9 and segment.gltype != 10 \
+ and segment.gltype != 11 and segment.gltype != 12 and segment.gltype != 13 \
+ and segment.gltype != 14 and segment.gltype != 20:
row = box.row(True)
row.prop(segment, 'glocx', text="X", toggle=True)
row.prop(segment, 'glocy', text="Y", toggle=True)
@@ -568,12 +601,8 @@ def add_item(box, idx, segment):
row = box.row(True)
row.prop(segment, 'glarc_a', text="")
row.prop(segment, 'glarc_b', text="")
- row.prop(segment, 'glarc_s', text="Size")
-
- # Area special
- if segment.gltype == 20:
- row = box.row(True)
- row.prop(segment, 'glcolorarea', text="")
+ if segment.glarc_a != '99' or segment.glarc_b != '99':
+ row.prop(segment, 'glarc_s', text="Size")
# ------------------------------------------------------------------
@@ -723,18 +752,24 @@ class MeasureitConfPanel(Panel):
# Configuration data
box = layout.box()
row = box.row()
- row.prop(scene, "measureit_gl_txt", text="Text")
- row = box.row()
- row.prop(scene, "measureit_default_color", text="")
+ split = row.split(percentage=0.2, align=True)
+ split.label("Text")
+ split = split.split(percentage=0.2, align=True)
+ split.prop(scene, "measureit_default_color", text="")
+ split.prop(scene, "measureit_gl_txt", text="")
+ row = box.row(True)
row.prop(scene, "measureit_hint_space")
+ row.prop(scene, "measureit_font_align", text="")
# Arrow
row = box.row(True)
row.prop(scene, "measureit_glarrow_a", text="")
row.prop(scene, "measureit_glarrow_b", text="")
- row.prop(scene, "measureit_glarrow_s", text="Size")
-
- row = box.row()
+ if scene.measureit_glarrow_a != '99' or scene.measureit_glarrow_b != '99':
+ row.prop(scene, "measureit_glarrow_s", text="Size")
+ row = box.row(True)
row.prop(scene, "measureit_font_size")
+ if scene.measureit_font_align == 'L':
+ row.prop(scene, "measureit_font_rotation", text="Rotate")
# ------------------------------------------------------------------
@@ -773,7 +808,7 @@ class MeasureitRenderPanel(Panel):
# -------------------------------------------------------------
-# Defines button for add a measure segment
+# Defines button that adds a measure segment
#
# -------------------------------------------------------------
class AddSegmentButton(Operator):
@@ -840,6 +875,8 @@ class AddSegmentButton(Operator):
# text
ms.gltxt = scene.measureit_gl_txt
ms.glfont_size = scene.measureit_font_size
+ ms.glfont_align = scene.measureit_font_align
+ ms.glfont_rotat = scene.measureit_font_rotation
# Sum group
ms.gltot = scene.measureit_sum
# Add index
@@ -860,7 +897,7 @@ class AddSegmentButton(Operator):
# -------------------------------------------------------------
-# Defines button for add area measure
+# Defines button that adds an area measure
#
# -------------------------------------------------------------
class AddAreaButton(Operator):
@@ -927,6 +964,8 @@ class AddAreaButton(Operator):
# text
ms.gltxt = scene.measureit_gl_txt
ms.glfont_size = scene.measureit_font_size
+ ms.glfont_align = scene.measureit_font_align
+ ms.glfont_rotat = scene.measureit_font_rotation
# Sum group
ms.gltot = scene.measureit_sum
# Add index
@@ -946,7 +985,7 @@ class AddAreaButton(Operator):
# -------------------------------------------------------------
-# Defines button for add a measure segment to x/y/z origin
+# Defines button that adds a measure segment to x/y/z origin
#
# -------------------------------------------------------------
class AddSegmentOrtoButton(Operator):
@@ -1015,6 +1054,8 @@ class AddSegmentOrtoButton(Operator):
# text
ms.gltxt = scene.measureit_gl_txt
ms.glfont_size = scene.measureit_font_size
+ ms.glfont_align = scene.measureit_font_align
+ ms.glfont_rotat = scene.measureit_font_rotation
# Sum group
ms.gltot = scene.measureit_sum
# Add index
@@ -1035,7 +1076,7 @@ class AddSegmentOrtoButton(Operator):
# -------------------------------------------------------------
-# Defines button for add a angle
+# Defines button that adds an angle measure
#
# -------------------------------------------------------------
class AddAngleButton(Operator):
@@ -1096,6 +1137,8 @@ class AddAngleButton(Operator):
# text
ms.gltxt = scene.measureit_gl_txt
ms.glfont_size = scene.measureit_font_size
+ ms.glfont_align = scene.measureit_font_align
+ ms.glfont_rotat = scene.measureit_font_rotation
# Add index
mp.measureit_num += 1
@@ -1114,7 +1157,7 @@ class AddAngleButton(Operator):
# -------------------------------------------------------------
-# Defines button for add a arc
+# Defines button that adds an arc measure
#
# -------------------------------------------------------------
class AddArcButton(Operator):
@@ -1179,6 +1222,8 @@ class AddArcButton(Operator):
# text
ms.gltxt = scene.measureit_gl_txt
ms.glfont_size = scene.measureit_font_size
+ ms.glfont_align = scene.measureit_font_align
+ ms.glfont_rotat = scene.measureit_font_rotation
# Add index
mp.measureit_num += 1
@@ -1197,7 +1242,7 @@ class AddArcButton(Operator):
# -------------------------------------------------------------
-# Defines button for add a label segment
+# Defines button that adds a label segment
#
# -------------------------------------------------------------
class AddLabelButton(Operator):
@@ -1260,6 +1305,8 @@ class AddLabelButton(Operator):
# text
ms.gltxt = scene.measureit_gl_txt
ms.glfont_size = scene.measureit_font_size
+ ms.glfont_align = scene.measureit_font_align
+ ms.glfont_rotat = scene.measureit_font_rotation
# Add index
mp.measureit_num += 1
@@ -1278,7 +1325,7 @@ class AddLabelButton(Operator):
# -------------------------------------------------------------
-# Defines button for add a link
+# Defines button that adds a link
#
# -------------------------------------------------------------
class AddLinkButton(Operator):
@@ -1404,6 +1451,8 @@ class AddLinkButton(Operator):
# text
ms.gltxt = scene.measureit_gl_txt
ms.glfont_size = scene.measureit_font_size
+ ms.glfont_align = scene.measureit_font_align
+ ms.glfont_rotat = scene.measureit_font_rotation
# link
ms.gllink = linkobject
# Add index
@@ -1423,7 +1472,7 @@ class AddLinkButton(Operator):
# -------------------------------------------------------------
-# Defines button for add a origin segment
+# Defines button that adds an origin segment
#
# -------------------------------------------------------------
class AddOriginButton(Operator):
@@ -1505,6 +1554,8 @@ class AddOriginButton(Operator):
# text
ms.gltxt = scene.measureit_gl_txt
ms.glfont_size = scene.measureit_font_size
+ ms.glfont_align = scene.measureit_font_align
+ ms.glfont_rotat = scene.measureit_font_rotation
# Add index
mp.measureit_num += 1
@@ -1520,7 +1571,7 @@ class AddOriginButton(Operator):
# -------------------------------------------------------------
-# Defines button for delete a measure segment
+# Defines button that deletes a measure segment
#
# -------------------------------------------------------------
class DeleteSegmentButton(Operator):
@@ -1554,7 +1605,7 @@ class DeleteSegmentButton(Operator):
# -------------------------------------------------------------
-# Defines button for delete all measure segment
+# Defines button that deletes all measure segments
#
# -------------------------------------------------------------
class DeleteAllSegmentButton(Operator):
@@ -1589,7 +1640,7 @@ class DeleteAllSegmentButton(Operator):
# -------------------------------------------------------------
-# Defines button for delete all measure segment
+# Defines button that deletes all measure segment sums
#
# -------------------------------------------------------------
class DeleteAllSumButton(Operator):
@@ -1615,7 +1666,69 @@ class DeleteAllSumButton(Operator):
# -------------------------------------------------------------
-# Defines button for render
+# Defines button that expands all measure segments
+#
+# -------------------------------------------------------------
+class ExpandAllSegmentButton(Operator):
+ bl_idname = "measureit.expandallsegmentbutton"
+ bl_label = "Expand"
+ bl_description = "Expand all measure properties"
+ bl_category = 'Measureit'
+ tag = IntProperty()
+
+ # ------------------------------
+ # Execute button action
+ # ------------------------------
+ def execute(self, context):
+ if context.area.type == 'VIEW_3D':
+ # Add properties
+ mainobject = context.object
+ mp = mainobject.MeasureGenerator[0]
+
+ for i in mp.measureit_segments:
+ i.gladvance = True
+
+ return {'FINISHED'}
+ else:
+ self.report({'WARNING'},
+ "View3D not found, cannot run operator")
+
+ return {'CANCELLED'}
+
+
+# -------------------------------------------------------------
+# Defines button that collapses all measure segments
+#
+# -------------------------------------------------------------
+class CollapseAllSegmentButton(Operator):
+ bl_idname = "measureit.collapseallsegmentbutton"
+ bl_label = "Collapse"
+ bl_description = "Collapses all measure properties"
+ bl_category = 'Measureit'
+ tag = IntProperty()
+
+ # ------------------------------
+ # Execute button action
+ # ------------------------------
+ def execute(self, context):
+ if context.area.type == 'VIEW_3D':
+ # Add properties
+ mainobject = context.object
+ mp = mainobject.MeasureGenerator[0]
+
+ for i in mp.measureit_segments:
+ i.gladvance = False
+
+ return {'FINISHED'}
+ else:
+ self.report({'WARNING'},
+ "View3D not found, cannot run operator")
+
+ return {'CANCELLED'}
+
+
+# -------------------------------------------------------------
+# Defines button for render option
#
# -------------------------------------------------------------
class RenderSegmentButton(Operator):
@@ -1646,7 +1759,6 @@ class RenderSegmentButton(Operator):
# noinspection PyBroadException
try:
result = bpy.data.images['Render Result']
- #if result.has_data is False:
bpy.ops.render.render()
except:
bpy.ops.render.render()
@@ -1805,6 +1917,8 @@ class AddNoteButton(Operator):
# text
ms.gltxt = scene.measureit_gl_txt
ms.glfont_size = scene.measureit_font_size
+ ms.glfont_align = scene.measureit_font_align
+ ms.glfont_rotat = scene.measureit_font_rotation
# Add index
mp.measureit_num += 1
@@ -1819,7 +1933,7 @@ class AddNoteButton(Operator):
# -------------------------------------------------------------
-# Defines button for enable/disable the tip display
+# Defines button that enables/disables the tip display
#
# -------------------------------------------------------------
class RunHintDisplayButton(Operator):