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:
authorAntonioya <blendergit@gmail.com>2018-12-05 18:40:29 +0300
committerAntonioya <blendergit@gmail.com>2018-12-05 18:42:30 +0300
commita4e7c60ac814847686341230118c732594c15992 (patch)
tree0cea872c13d2c4d208727092a6df6f0f80faa1be /measureit/measureit_main.py
parent111b8f7f0f1441a04295238c74975ca9083868b8 (diff)
MeasureIt: First steps to migrate to 2.8 (WIP)
Migrate add-on to 2.8 with new API. Still problems in render
Diffstat (limited to 'measureit/measureit_main.py')
-rw-r--r--measureit/measureit_main.py454
1 files changed, 208 insertions, 246 deletions
diff --git a/measureit/measureit_main.py b/measureit/measureit_main.py
index 91d57ce8..82f269ac 100644
--- a/measureit/measureit_main.py
+++ b/measureit/measureit_main.py
@@ -46,7 +46,7 @@ from .measureit_render import *
# noinspection PyUnusedLocal
@persistent
def load_handler(dummy):
- RunHintDisplayButton.handle_remove(None, bpy.context)
+ MEASUREIT_OT_RunHintDisplay.handle_remove(None, bpy.context)
# ------------------------------------------------------
@@ -88,8 +88,7 @@ bpy.app.handlers.save_pre.append(save_handler)
# Define property group class for measureit faces index
# ------------------------------------------------------------------
class MeasureitIndex(PropertyGroup):
- glidx = IntProperty(name="index",
- description="vertex index")
+ glidx: IntProperty(name="index", description="vertex index")
# Register
@@ -100,10 +99,9 @@ bpy.utils.register_class(MeasureitIndex)
# Define property group class for measureit faces
# ------------------------------------------------------------------
class MeasureitFaces(PropertyGroup):
- glface = IntProperty(name="glface",
- description="Face number")
+ glface: IntProperty(name="glface", description="Face number")
# Array of index
- measureit_index = CollectionProperty(type=MeasureitIndex)
+ measureit_index: CollectionProperty(type=MeasureitIndex)
# Register
@@ -114,86 +112,86 @@ bpy.utils.register_class(MeasureitFaces)
# Define property group class for measureit data
# ------------------------------------------------------------------
class MeasureitProperties(PropertyGroup):
- gltype = IntProperty(name="gltype",
- description="Measure type (1-Segment, 2-Label, etc..)", default=1)
- glpointa = IntProperty(name="glpointa",
- description="Hidden property for opengl")
- glpointb = IntProperty(name="glpointb",
- description="Hidden property for opengl")
- glpointc = IntProperty(name="glpointc",
- description="Hidden property for opengl")
- glcolor = FloatVectorProperty(name="glcolor",
+ gltype: IntProperty(name="gltype",
+ description="Measure type (1-Segment, 2-Label, etc..)", default=1)
+ glpointa: IntProperty(name="glpointa",
+ description="Hidden property for opengl")
+ glpointb: IntProperty(name="glpointb",
+ description="Hidden property for opengl")
+ glpointc: IntProperty(name="glpointc",
+ description="Hidden property for opengl")
+ glcolor: FloatVectorProperty(name="glcolor",
description="Color for the measure",
default=(0.173, 0.545, 1.0, 1.0),
min=0.1,
max=1,
subtype='COLOR',
size=4)
- glview = BoolProperty(name="glview",
+ glview: BoolProperty(name="glview",
description="Measure visible/hide",
default=True)
- glspace = FloatProperty(name='glspace', min=-100, max=100, default=0.1,
+ glspace: FloatProperty(name='glspace', min=-100, max=100, default=0.1,
precision=3,
description='Distance to display measure')
- glwidth = IntProperty(name='glwidth', min=1, max=10, default=1,
+ glwidth: IntProperty(name='glwidth', min=1, max=10, default=1,
description='line width')
- glfree = BoolProperty(name="glfree",
+ glfree: BoolProperty(name="glfree",
description="This measure is free and can be deleted",
default=False)
- gltxt = StringProperty(name="gltxt", maxlen=256,
+ gltxt: StringProperty(name="gltxt", maxlen=256,
description="Short description (use | for line break)")
- gladvance = BoolProperty(name="gladvance",
+ gladvance: BoolProperty(name="gladvance",
description="Advanced options as line width or position",
default=False)
- gldefault = BoolProperty(name="gldefault",
+ gldefault: BoolProperty(name="gldefault",
description="Display measure in position calculated by default",
default=True)
- glnormalx = FloatProperty(name="glnormalx",
+ glnormalx: FloatProperty(name="glnormalx",
description="Change orientation in X axis",
default=1, min=-1, max=1, precision=2)
- glnormaly = FloatProperty(name="glnormaly",
+ glnormaly: FloatProperty(name="glnormaly",
description="Change orientation in Y axis",
default=0, min=-1, max=1, precision=2)
- glnormalz = FloatProperty(name="glnormalz",
+ glnormalz: FloatProperty(name="glnormalz",
description="Change orientation in Z axis",
default=0, min=-1, max=1, precision=2)
- glfont_size = IntProperty(name="Text Size",
+ glfont_size: IntProperty(name="Text Size",
description="Text size",
default=14, min=6, max=150)
- glfont_align = EnumProperty(items=(('L', "Left Align", ""),
+ 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,
+ glfont_rotat: IntProperty(name='Rotate', min=0, max=360, default=0,
description="Text rotation in degrees")
- gllink = StringProperty(name="gllink",
+ gllink: StringProperty(name="gllink",
description="linked object for linked measures")
- glocwarning = BoolProperty(name="glocwarning",
+ glocwarning: BoolProperty(name="glocwarning",
description="Display a warning if some axis is not used in distance",
default=True)
- glocx = BoolProperty(name="glocx",
+ glocx: BoolProperty(name="glocx",
description="Include changes in X axis for calculating the distance",
default=True)
- glocy = BoolProperty(name="glocy",
+ glocy: BoolProperty(name="glocy",
description="Include changes in Y axis for calculating the distance",
default=True)
- glocz = BoolProperty(name="glocz",
+ glocz: BoolProperty(name="glocz",
description="Include changes in Z axis for calculating the distance",
default=True)
- glfontx = IntProperty(name="glfontx",
+ glfontx: IntProperty(name="glfontx",
description="Change font position in X axis",
default=0, min=-3000, max=3000)
- glfonty = IntProperty(name="glfonty",
+ glfonty: IntProperty(name="glfonty",
description="Change font position in Y axis",
default=0, min=-3000, max=3000)
- gldist = BoolProperty(name="gldist",
+ gldist: BoolProperty(name="gldist",
description="Display distance for this measure",
default=True)
- glnames = BoolProperty(name="glnames",
+ glnames: BoolProperty(name="glnames",
description="Display text for this measure",
default=True)
- gltot = EnumProperty(items=(('99', "-", "Select a group for sum"),
+ gltot: EnumProperty(items=(('99', "-", "Select a group for sum"),
('0', "A", ""),
('1', "B", ""),
('2', "C", ""),
@@ -222,74 +220,74 @@ class MeasureitProperties(PropertyGroup):
('25', "Z", "")),
name="Sum in Group",
description="Add segment length in selected group")
- glorto = EnumProperty(items=(('99', "None", ""),
+ glorto: EnumProperty(items=(('99', "None", ""),
('0', "A", "Point A must use selected point B location"),
('1', "B", "Point B must use selected point A location")),
name="Orthogonal",
description="Display point selected as orthogonal (select axis to copy)")
- glorto_x = BoolProperty(name="ox",
+ glorto_x: BoolProperty(name="ox",
description="Copy X location",
default=False)
- glorto_y = BoolProperty(name="oy",
+ glorto_y: BoolProperty(name="oy",
description="Copy Y location",
default=False)
- glorto_z = BoolProperty(name="oz",
+ glorto_z: BoolProperty(name="oz",
description="Copy Z location",
default=False)
- glarrow_a = EnumProperty(items=(('99', "--", "No arrow"),
+ glarrow_a: EnumProperty(items=(('99', "--", "No arrow"),
('1', "Line", "The point of the arrow are lines"),
('2', "Triangle", "The point of the arrow is triangle"),
('3', "TShape", "The point of the arrow is a T")),
name="A end",
description="Add arrows to point A")
- glarrow_b = EnumProperty(items=(('99', "--", "No arrow"),
+ glarrow_b: EnumProperty(items=(('99', "--", "No arrow"),
('1', "Line", "The point of the arrow are lines"),
('2', "Triangle", "The point of the arrow is triangle"),
('3', "TShape", "The point of the arrow is a T")),
name="B end",
description="Add arrows to point B")
- glarrow_s = IntProperty(name="Size",
+ glarrow_s: IntProperty(name="Size",
description="Arrow size",
default=15, min=6, max=500)
- glarc_full = BoolProperty(name="arcfull",
+ glarc_full: BoolProperty(name="arcfull",
description="Create full circunference",
default=False)
- glarc_extrad = BoolProperty(name="arcextrad",
+ glarc_extrad: BoolProperty(name="arcextrad",
description="Adapt radio length to arc line",
default=True)
- glarc_rad = BoolProperty(name="arc rad",
+ glarc_rad: BoolProperty(name="arc rad",
description="Show arc radius",
default=True)
- glarc_len = BoolProperty(name="arc len",
+ glarc_len: BoolProperty(name="arc len",
description="Show arc length",
default=True)
- glarc_ang = BoolProperty(name="arc ang",
+ glarc_ang: BoolProperty(name="arc ang",
description="Show arc angle",
default=True)
- glarc_a = EnumProperty(items=(('99', "--", "No arrow"),
+ glarc_a: EnumProperty(items=(('99', "--", "No arrow"),
('1', "Line", "The point of the arrow are lines"),
('2', "Triangle", "The point of the arrow is triangle"),
('3', "TShape", "The point of the arrow is a T")),
name="Ar end",
description="Add arrows to point A")
- glarc_b = EnumProperty(items=(('99', "--", "No arrow"),
+ glarc_b: EnumProperty(items=(('99', "--", "No arrow"),
('1', "Line", "The point of the arrow are lines"),
('2', "Triangle", "The point of the arrow is triangle"),
('3', "TShape", "The point of the arrow is a T")),
name="Br end",
description="Add arrows to point B")
- glarc_s = IntProperty(name="Size",
+ glarc_s: IntProperty(name="Size",
description="Arrow size",
default=15, min=6, max=500)
- glarc_txradio = StringProperty(name="txradio",
+ glarc_txradio: StringProperty(name="txradio",
description="Text for radius", default="r=")
- glarc_txlen = StringProperty(name="txlen",
+ glarc_txlen: StringProperty(name="txlen",
description="Text for length", default="L=")
- glarc_txang = StringProperty(name="txang",
+ glarc_txang: StringProperty(name="txang",
description="Text for angle", default="A=")
- glcolorarea = FloatVectorProperty(name="glcolorarea",
+ glcolorarea: FloatVectorProperty(name="glcolorarea",
description="Color for the measure of area",
default=(0.1, 0.1, 0.1, 1.0),
min=0.1,
@@ -298,7 +296,7 @@ class MeasureitProperties(PropertyGroup):
size=4)
# Array of faces
- measureit_faces = CollectionProperty(type=MeasureitFaces)
+ measureit_faces: CollectionProperty(type=MeasureitFaces)
# Register
@@ -310,10 +308,10 @@ bpy.utils.register_class(MeasureitProperties)
# Measureit
# ------------------------------------------------------------------
class MeasureContainer(PropertyGroup):
- measureit_num = IntProperty(name='Number of measures', min=0, max=1000, default=0,
+ measureit_num: IntProperty(name='Number of measures', min=0, max=1000, default=0,
description='Number total of measureit elements')
# Array of segments
- measureit_segments = CollectionProperty(type=MeasureitProperties)
+ measureit_segments: CollectionProperty(type=MeasureitProperties)
bpy.utils.register_class(MeasureContainer)
@@ -324,12 +322,13 @@ Object.MeasureGenerator = CollectionProperty(type=MeasureContainer)
# Define UI class
# Measureit
# ------------------------------------------------------------------
-class MeasureitEditPanel(Panel):
- bl_idname = "measureit.editpanel"
- bl_label = "Measureit"
+class MEASUREIT_PT_Edit(Panel):
+ bl_idname = "MEASUREIT_PT_Edit"
+ bl_label = "Items"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
- bl_category = 'MeasureIt'
+ bl_category= 'View'
+ bl_parent_id = 'measureit_main_panel'
# -----------------------------------------------------
# Verify if visible
@@ -359,12 +358,12 @@ class MeasureitEditPanel(Panel):
if 'MeasureGenerator' in context.object:
box = layout.box()
row = box.row()
- row.label(context.object.name)
+ row.label(text=context.object.name)
row = box.row()
row.prop(scene, 'measureit_gl_precision', text="Precision")
row.prop(scene, 'measureit_units')
row = box.row()
- row.prop(scene, 'measureit_gl_show_d', text="Distances", toggle=True, icon="ALIGN")
+ row.prop(scene, 'measureit_gl_show_d', text="Distances", toggle=True, icon="ALIGN_CENTER")
row.prop(scene, 'measureit_gl_show_n', text="Texts", toggle=True, icon="FONT_DATA")
row = box.row()
row.prop(scene, 'measureit_hide_units', text="Hide measurement unit")
@@ -372,7 +371,7 @@ class MeasureitEditPanel(Panel):
row = box.row()
row.prop(scene, 'measureit_scale', text="Scale")
if scene.measureit_scale is True:
- split = row.split(percentage=0.25, align=False)
+ split = row.split(factor=0.25, align=False)
split.prop(scene, 'measureit_scale_color', text="")
split.prop(scene, 'measureit_scale_factor', text="1")
row = box.row()
@@ -389,7 +388,7 @@ class MeasureitEditPanel(Panel):
row = box.row()
row.prop(scene, 'measureit_ovr', text="Override")
if scene.measureit_ovr is True:
- split = row.split(percentage=0.25, align=False)
+ split = row.split(factor=0.25, align=False)
split.prop(scene, 'measureit_ovr_color', text="")
split.prop(scene, 'measureit_ovr_width', text="Width")
row = box.row()
@@ -405,15 +404,15 @@ 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")
+ row = box.row(align=True)
+ row.operator("measureit.expandallsegment", text="Expand all", icon="ZOOM_IN")
+ row.operator("measureit.collapseallsegment", text="Collapse all", icon="ZOOM_OUT")
for idx in range(mp.measureit_num):
if mp.measureit_segments[idx].glfree is False:
add_item(box, idx, mp.measureit_segments[idx])
row = box.row()
- row.operator("measureit.deleteallsegmentbutton", text="Delete all", icon="X")
+ row.operator("measureit.deleteallsegment", text="Delete all", icon="X")
# -----------------
# Sum loop segments
# -----------------
@@ -476,25 +475,25 @@ class MeasureitEditPanel(Panel):
if ac[idx] is True:
final += tot[idx]
tx_dist = format_distance(fmt, units, tot[idx])
- row = box.row(True)
- row.label("Group " + tx[idx] + ":")
- row.label(" ")
- row.label(tx_dist)
+ row = box.row(align=True)
+ row.label(text="Group " + tx[idx] + ":")
+ row.label(text=" ")
+ row.label(text=tx_dist)
# Grand total
- row = box.row(True)
- row.label("")
- row.label(" ")
- row.label("-" * 20)
+ row = box.row(align=True)
+ row.label(text="")
+ row.label(text=" ")
+ row.label(text="-" * 20)
tx_dist = format_distance(fmt, units, final)
- row = box.row(True)
- row.label("")
- row.label(" ")
- row.label(tx_dist)
+ row = box.row(align=True)
+ row.label(text="")
+ row.label(text=" ")
+ row.label(text=tx_dist)
# delete all
row = box.row()
- row.operator("measureit.deleteallsumbutton", text="Delete all", icon="X")
+ row.operator("measureit.deleteallsum", text="Delete all", icon="X")
# -----------------------------------------------------
@@ -502,32 +501,32 @@ class MeasureitEditPanel(Panel):
# -----------------------------------------------------
def add_item(box, idx, segment):
scene = bpy.context.scene
- row = box.row(True)
+ row = box.row(align=True)
if segment.glview is True:
icon = "VISIBLE_IPO_ON"
else:
icon = "VISIBLE_IPO_OFF"
row.prop(segment, 'glview', text="", toggle=True, icon=icon)
- row.prop(segment, 'gladvance', text="", toggle=True, icon="SCRIPTWIN")
+ row.prop(segment, 'gladvance', text="", toggle=True, icon="PREFERENCES")
if segment.gltype == 20: # Area special
- split = row.split(percentage=0.15, align=True)
+ split = row.split(factor=0.15, align=True)
split.prop(segment, 'glcolorarea', text="")
- split = split.split(percentage=0.20, align=True)
+ split = split.split(factor=0.20, align=True)
split.prop(segment, 'glcolor', text="")
else:
- split = row.split(percentage=0.25, align=True)
+ split = row.split(factor=0.25, align=True)
split.prop(segment, 'glcolor', text="")
split.prop(segment, 'gltxt', text="")
- op = row.operator("measureit.deletesegmentbutton", text="", icon="X")
+ op = row.operator("measureit.deletesegment", text="", icon="X")
op.tag = idx # saves internal data
if segment.gladvance is True:
- row = box.row(True)
+ row = box.row(align=True)
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)
+ row = box.row(align=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")
@@ -535,16 +534,16 @@ def add_item(box, idx, segment):
# Arrows
if segment.gltype != 9 and segment.gltype != 10 and segment.gltype != 20:
- row = box.row(True)
+ row = box.row(align=True)
row.prop(segment, 'glarrow_a', text="")
row.prop(segment, 'glarrow_b', text="")
if segment.glarrow_a != '99' or segment.glarrow_b != '99':
row.prop(segment, 'glarrow_s', text="Size")
if segment.gltype != 2 and segment.gltype != 10:
- row = box.row(True)
+ row = box.row(align=True)
if scene.measureit_gl_show_d is True and segment.gltype != 9:
- row.prop(segment, 'gldist', text="Distance", toggle=True, icon="ALIGN")
+ row.prop(segment, 'gldist', text="Distance", toggle=True, icon="ALIGN_CENTER")
if scene.measureit_gl_show_n is True:
row.prop(segment, 'glnames', text="Text", toggle=True, icon="FONT_DATA")
# sum distances
@@ -552,11 +551,11 @@ def add_item(box, idx, segment):
row.prop(segment, 'gltot', text="Sum")
if segment.gltype != 9 and segment.gltype != 10 and segment.gltype != 20:
- row = box.row(True)
+ row = box.row(align=True)
row.prop(segment, 'glwidth', text="Line")
row.prop(segment, 'gldefault', text="Automatic position")
if segment.gldefault is False:
- row = box.row(True)
+ row = box.row(align=True)
row.prop(segment, 'glnormalx', text="X")
row.prop(segment, 'glnormaly', text="Y")
row.prop(segment, 'glnormalz', text="Z")
@@ -565,7 +564,7 @@ def add_item(box, idx, segment):
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 = box.row(align=True)
row.prop(segment, 'glocx', text="X", toggle=True)
row.prop(segment, 'glocy', text="Y", toggle=True)
row.prop(segment, 'glocz', text="Z", toggle=True)
@@ -577,28 +576,28 @@ def add_item(box, idx, segment):
# ortogonal (only segments)
if segment.gltype == 1:
if segment.glorto != "99":
- row = box.row(True)
+ row = box.row(align=True)
row.prop(segment, 'glorto_x', text="X", toggle=True)
row.prop(segment, 'glorto_y', text="Y", toggle=True)
row.prop(segment, 'glorto_z', text="Z", toggle=True)
# Arc special
if segment.gltype == 11:
- row = box.row(True)
+ row = box.row(align=True)
row.prop(segment, 'glarc_rad', text="Radius")
row.prop(segment, 'glarc_len', text="Length")
row.prop(segment, 'glarc_ang', text="Angle")
- row = box.row(True)
+ row = box.row(align=True)
row.prop(segment, 'glarc_txradio', text="")
row.prop(segment, 'glarc_txlen', text="")
row.prop(segment, 'glarc_txang', text="")
- row = box.row(True)
+ row = box.row(align=True)
row.prop(segment, 'glarc_full', text="Full Circle")
if segment.glarc_rad is True:
row.prop(segment, 'glarc_extrad', text="Adapt radio")
- row = box.row(True)
+ row = box.row(align=True)
row.prop(segment, 'glarc_a', text="")
row.prop(segment, 'glarc_b', text="")
if segment.glarc_a != '99' or segment.glarc_b != '99':
@@ -608,12 +607,12 @@ def add_item(box, idx, segment):
# ------------------------------------------------------------------
# Define panel class for main functions.
# ------------------------------------------------------------------
-class MeasureitMainPanel(Panel):
+class MEASUREIT_PT_Main(Panel):
bl_idname = "measureit_main_panel"
bl_label = "MeasureIt Tools"
bl_space_type = 'VIEW_3D'
- bl_region_type = "TOOLS"
- bl_category = 'Measureit'
+ bl_region_type = 'UI'
+ bl_category= 'View'
# ------------------------------
# Draw UI
@@ -637,45 +636,45 @@ class MeasureitMainPanel(Panel):
icon = "PAUSE"
txt = 'Hide'
- row.operator("measureit.runopenglbutton", text=txt, icon=icon)
+ row.operator("measureit.runopengl", text=txt, icon=icon)
row.prop(scene, "measureit_gl_ghost", text="", icon='GHOST_ENABLED')
# Tools
box = layout.box()
- box.label("Add Measures")
+ box.label(text="Add Measures")
row = box.row()
- row.operator("measureit.addsegmentbutton", text="Segment", icon="ALIGN")
+ row.operator("measureit.addsegment", text="Segment")
row.prop(scene, "measureit_sum", text="Sum")
# To origin
row = box.row()
- op = row.operator("measureit.addsegmentortobutton", text="X", icon="ALIGN")
+ op = row.operator("measureit.addsegmentorto", text="X")
op.tag = 0 # saves internal data
- op = row.operator("measureit.addsegmentortobutton", text="Y", icon="ALIGN")
+ op = row.operator("measureit.addsegmentorto", text="Y")
op.tag = 1 # saves internal data
- op = row.operator("measureit.addsegmentortobutton", text="Z", icon="ALIGN")
+ op = row.operator("measureit.addsegmentorto", text="Z")
op.tag = 2 # saves internal data
row = box.row()
- row.operator("measureit.addanglebutton", text="Angle", icon="LINCURVE")
- row.operator("measureit.addarcbutton", text="Arc", icon="MAN_ROT")
+ row.operator("measureit.addangle", text="Angle", icon="LINCURVE")
+ row.operator("measureit.addarc", text="Arc")
row = box.row()
- row.operator("measureit.addlabelbutton", text="Label", icon="FONT_DATA")
- row.operator("measureit.addnotebutton", text="Annotation", icon="NEW")
+ row.operator("measureit.addlabel", text="Label", icon="FONT_DATA")
+ row.operator("measureit.addnote", text="Annotation")
row = box.row()
- row.operator("measureit.addlinkbutton", text="Link", icon="ROTATECENTER")
- row.operator("measureit.addoriginbutton", text="Origin", icon="CURSOR")
+ row.operator("measureit.addlink", text="Link")
+ row.operator("measureit.addorigin", text="Origin")
row = box.row()
- row.operator("measureit.addareabutton", text="Area", icon="MESH_GRID")
+ row.operator("measureit.addarea", text="Area", icon="MESH_GRID")
# ------------------------------
# Debug data
# ------------------------------
box = layout.box()
- row = box.row(False)
+ row = box.row(align=False)
if scene.measureit_debug is False:
row.prop(scene, "measureit_debug", icon="TRIA_RIGHT",
text="Mesh Debug", emboss=False)
@@ -684,43 +683,43 @@ class MeasureitMainPanel(Panel):
text="Mesh Debug", emboss=False)
row = box.row()
- split = row.split(percentage=0.10, align=True)
+ split = row.split(factor=0.10, align=True)
split.prop(scene, 'measureit_debug_obj_color', text="")
split.prop(scene, "measureit_debug_objects", icon="OBJECT_DATA")
split.prop(scene, "measureit_debug_object_loc", icon="EMPTY_DATA")
row = box.row()
- split = row.split(percentage=0.10, align=True)
+ split = row.split(factor=0.10, align=True)
split.prop(scene, 'measureit_debug_vert_color', text="")
- split.prop(scene, "measureit_debug_vertices", icon="LOOPSEL")
+ split.prop(scene, "measureit_debug_vertices", icon="VERTEXSEL")
split.prop(scene, "measureit_debug_vert_loc", icon="EMPTY_DATA")
if scene.measureit_debug_vert_loc is True:
split.prop(scene, 'measureit_debug_vert_loc_toggle', text="")
row = box.row()
- split = row.split(percentage=0.10, align=True)
+ split = row.split(factor=0.10, align=True)
split.prop(scene, 'measureit_debug_edge_color', text="")
- split = split.split(percentage=0.5, align=True)
+ split = split.split(factor=0.5, align=True)
split.prop(scene, "measureit_debug_edges", icon="EDGESEL")
row = box.row()
- split = row.split(percentage=0.10, align=True)
+ split = row.split(factor=0.10, align=True)
split.prop(scene, 'measureit_debug_face_color', text="")
- split = split.split(percentage=0.5, align=True)
+ split = split.split(factor=0.5, align=True)
split.prop(scene, "measureit_debug_faces", icon="FACESEL")
row = box.row()
- split = row.split(percentage=0.10, align=True)
+ split = row.split(factor=0.10, align=True)
split.prop(scene, 'measureit_debug_norm_color', text="")
if scene.measureit_debug_normals is False:
- split = split.split(percentage=0.50, align=True)
- split.prop(scene, "measureit_debug_normals", icon="MAN_TRANS")
+ split = split.split(factor=0.50, align=True)
+ split.prop(scene, "measureit_debug_normals", icon="OBJECT_ORIGIN")
else:
- split = split.split(percentage=0.5, align=True)
- split.prop(scene, "measureit_debug_normals", icon="MAN_TRANS")
+ split = split.split(factor=0.5, align=True)
+ split.prop(scene, "measureit_debug_normals", icon="OBJECT_ORIGIN")
split.prop(scene, "measureit_debug_normal_size")
row = box.row()
- split = row.split(percentage=0.10, align=True)
+ split = row.split(factor=0.10, align=True)
split.separator()
split.prop(scene, "measureit_debug_normal_details")
split.prop(scene, 'measureit_debug_width', text="Thickness")
@@ -734,12 +733,13 @@ class MeasureitMainPanel(Panel):
# ------------------------------------------------------------------
# Define panel class for conf functions.
# ------------------------------------------------------------------
-class MeasureitConfPanel(Panel):
+class MEASUREIT_PT_Conf(Panel):
bl_idname = "measureit_conf_panel"
- bl_label = "MeasureIt Configuration"
+ bl_label = "Configuration"
bl_space_type = 'VIEW_3D'
- bl_region_type = "TOOLS"
- bl_category = 'Measureit'
+ bl_region_type = 'UI'
+ bl_category= 'View'
+ bl_parent_id = 'measureit_main_panel'
bl_options = {'DEFAULT_CLOSED'}
# ------------------------------
@@ -752,21 +752,21 @@ class MeasureitConfPanel(Panel):
# Configuration data
box = layout.box()
row = box.row()
- split = row.split(percentage=0.2, align=True)
- split.label("Text")
- split = split.split(percentage=0.2, align=True)
+ split = row.split(factor=0.2, align=True)
+ split.label(text="Text")
+ split = split.split(factor=0.2, align=True)
split.prop(scene, "measureit_default_color", text="")
split.prop(scene, "measureit_gl_txt", text="")
- row = box.row(True)
+ row = box.row(align=True)
row.prop(scene, "measureit_hint_space")
row.prop(scene, "measureit_font_align", text="")
# Arrow
- row = box.row(True)
+ row = box.row(align=True)
row.prop(scene, "measureit_glarrow_a", text="")
row.prop(scene, "measureit_glarrow_b", text="")
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 = box.row(align=True)
row.prop(scene, "measureit_font_size")
if scene.measureit_font_align == 'L':
row.prop(scene, "measureit_font_rotation", text="Rotate")
@@ -775,12 +775,13 @@ class MeasureitConfPanel(Panel):
# ------------------------------------------------------------------
# Define panel class for render functions.
# ------------------------------------------------------------------
-class MeasureitRenderPanel(Panel):
+class MEASUREIT_PT_Render(Panel):
bl_idname = "measureit_render_panel"
- bl_label = "MeasureIt Render"
+ bl_label = "Render"
bl_space_type = 'VIEW_3D'
- bl_region_type = "TOOLS"
- bl_category = 'Measureit'
+ bl_region_type = 'UI'
+ bl_category= 'View'
+ bl_parent_id = 'measureit_main_panel'
bl_options = {'DEFAULT_CLOSED'}
# ------------------------------
@@ -795,7 +796,7 @@ class MeasureitRenderPanel(Panel):
row = box.row()
row.prop(scene, "measureit_render_type")
row = box.row()
- row.operator("measureit.rendersegmentbutton", icon='SCRIPT')
+ row.operator("measureit.rendersegment", icon='SCRIPT')
row = box.row()
row.prop(scene, "measureit_render", text="Save render image")
row = box.row()
@@ -811,11 +812,10 @@ class MeasureitRenderPanel(Panel):
# Defines button that adds a measure segment
#
# -------------------------------------------------------------
-class AddSegmentButton(Operator):
- bl_idname = "measureit.addsegmentbutton"
+class MEASUREIT_OT_AddSegment(Operator):
+ bl_idname = "measureit.addsegment"
bl_label = "Add"
bl_description = "(EDITMODE only) Add a new measure segment between 2 vertices (select 2 vertices or more)"
- bl_category = 'Measureit'
# ------------------------------
# Poll
@@ -900,11 +900,10 @@ class AddSegmentButton(Operator):
# Defines button that adds an area measure
#
# -------------------------------------------------------------
-class AddAreaButton(Operator):
- bl_idname = "measureit.addareabutton"
+class MEASUREIT_OT_AddArea(Operator):
+ bl_idname = "measureit.addarea"
bl_label = "Area"
bl_description = "(EDITMODE only) Add a new measure for area (select 1 o more faces)"
- bl_category = 'Measureit'
# ------------------------------
# Poll
@@ -988,13 +987,12 @@ class AddAreaButton(Operator):
# Defines button that adds a measure segment to x/y/z origin
#
# -------------------------------------------------------------
-class AddSegmentOrtoButton(Operator):
- bl_idname = "measureit.addsegmentortobutton"
+class MEASUREIT_OT_AddSegmentOrto(Operator):
+ bl_idname = "measureit.addsegmentorto"
bl_label = "Add"
bl_description = "(EDITMODE only) Add a new measure segment from vertex to object origin for one " \
"axis (select 1 vertex)"
- bl_category = 'Measureit'
- tag = IntProperty()
+ tag: IntProperty()
# ------------------------------
# Poll
@@ -1079,11 +1077,10 @@ class AddSegmentOrtoButton(Operator):
# Defines button that adds an angle measure
#
# -------------------------------------------------------------
-class AddAngleButton(Operator):
- bl_idname = "measureit.addanglebutton"
+class MEASUREIT_OT_AddAngle(Operator):
+ bl_idname = "measureit.addangle"
bl_label = "Angle"
bl_description = "(EDITMODE only) Add a new angle measure (select 3 vertices, 2nd is angle vertex)"
- bl_category = 'Measureit'
# ------------------------------
# Poll
@@ -1160,12 +1157,11 @@ class AddAngleButton(Operator):
# Defines button that adds an arc measure
#
# -------------------------------------------------------------
-class AddArcButton(Operator):
- bl_idname = "measureit.addarcbutton"
+class MEASUREIT_OT_AddArc(Operator):
+ bl_idname = "measureit.addarc"
bl_label = "Angle"
bl_description = "(EDITMODE only) Add a new arc measure (select 3 vertices of the arc," \
" vertices 1st and 3rd are arc extremes)"
- bl_category = 'Measureit'
# ------------------------------
# Poll
@@ -1245,11 +1241,10 @@ class AddArcButton(Operator):
# Defines button that adds a label segment
#
# -------------------------------------------------------------
-class AddLabelButton(Operator):
- bl_idname = "measureit.addlabelbutton"
+class MEASUREIT_OT_AddLabel(Operator):
+ bl_idname = "measureit.addlabel"
bl_label = "Add"
bl_description = "(EDITMODE only) Add a new measure label (select 1 vertex)"
- bl_category = 'Measureit'
# ------------------------------
# Poll
@@ -1328,12 +1323,11 @@ class AddLabelButton(Operator):
# Defines button that adds a link
#
# -------------------------------------------------------------
-class AddLinkButton(Operator):
- bl_idname = "measureit.addlinkbutton"
+class MEASUREIT_OT_AddLink(Operator):
+ bl_idname = "measureit.addlink"
bl_label = "Add"
bl_description = "(OBJECT mode only) Add a new measure between objects (select 2 " \
"objects and optionally 1 or 2 vertices)"
- bl_category = 'Measureit'
# ------------------------------
# Poll
@@ -1475,11 +1469,10 @@ class AddLinkButton(Operator):
# Defines button that adds an origin segment
#
# -------------------------------------------------------------
-class AddOriginButton(Operator):
- bl_idname = "measureit.addoriginbutton"
+class MEASUREIT_OT_AddOrigin(Operator):
+ bl_idname = "measureit.addorigin"
bl_label = "Add"
bl_description = "(OBJECT mode only) Add a new measure to origin (select object and optionally 1 vertex)"
- bl_category = 'Measureit'
# ------------------------------
# Poll
@@ -1574,12 +1567,11 @@ class AddOriginButton(Operator):
# Defines button that deletes a measure segment
#
# -------------------------------------------------------------
-class DeleteSegmentButton(Operator):
- bl_idname = "measureit.deletesegmentbutton"
+class MEASUREIT_OT_DeleteSegment(Operator):
+ bl_idname = "measureit.deletesegment"
bl_label = "Delete"
bl_description = "Delete a measure"
- bl_category = 'Measureit'
- tag = IntProperty()
+ tag: IntProperty()
# ------------------------------
# Execute button action
@@ -1608,12 +1600,11 @@ class DeleteSegmentButton(Operator):
# Defines button that deletes all measure segments
#
# -------------------------------------------------------------
-class DeleteAllSegmentButton(Operator):
- bl_idname = "measureit.deleteallsegmentbutton"
+class MEASUREIT_OT_DeleteAllSegment(Operator):
+ bl_idname = "measureit.deleteallsegment"
bl_label = "Delete"
bl_description = "Delete all measures (it cannot be undone)"
- bl_category = 'Measureit'
- tag = IntProperty()
+ tag: IntProperty()
# ------------------------------
# Execute button action
@@ -1643,12 +1634,11 @@ class DeleteAllSegmentButton(Operator):
# Defines button that deletes all measure segment sums
#
# -------------------------------------------------------------
-class DeleteAllSumButton(Operator):
- bl_idname = "measureit.deleteallsumbutton"
+class MEASUREIT_OT_DeleteAllSum(Operator):
+ bl_idname = "measureit.deleteallsum"
bl_label = "Delete"
bl_description = "Delete all sum groups"
- bl_category = 'Measureit'
- tag = IntProperty()
+ tag: IntProperty()
# ------------------------------
# Execute button action
@@ -1669,12 +1659,11 @@ class DeleteAllSumButton(Operator):
# Defines button that expands all measure segments
#
# -------------------------------------------------------------
-class ExpandAllSegmentButton(Operator):
- bl_idname = "measureit.expandallsegmentbutton"
+class MEASUREIT_OT_ExpandAllSegment(Operator):
+ bl_idname = "measureit.expandallsegment"
bl_label = "Expand"
bl_description = "Expand all measure properties"
- bl_category = 'Measureit'
- tag = IntProperty()
+ tag: IntProperty()
# ------------------------------
# Execute button action
@@ -1700,12 +1689,11 @@ class ExpandAllSegmentButton(Operator):
# Defines button that collapses all measure segments
#
# -------------------------------------------------------------
-class CollapseAllSegmentButton(Operator):
- bl_idname = "measureit.collapseallsegmentbutton"
+class MEASUREIT_OT_CollapseAllSegment(Operator):
+ bl_idname = "measureit.collapseallsegment"
bl_label = "Collapse"
bl_description = "Collapses all measure properties"
- bl_category = 'Measureit'
- tag = IntProperty()
+ tag: IntProperty()
# ------------------------------
# Execute button action
@@ -1731,12 +1719,11 @@ class CollapseAllSegmentButton(Operator):
# Defines button for render option
#
# -------------------------------------------------------------
-class RenderSegmentButton(Operator):
- bl_idname = "measureit.rendersegmentbutton"
+class MEASUREIT_OT_RenderSegment(Operator):
+ bl_idname = "measureit.rendersegment"
bl_label = "Render"
bl_description = "Create a render image with measures. Use UV/Image editor to view image generated"
- bl_category = 'Measureit'
- tag = IntProperty()
+ tag: IntProperty()
# ------------------------------
# Execute button action
@@ -1866,12 +1853,11 @@ class RenderSegmentButton(Operator):
# Defines a new note
#
# -------------------------------------------------------------
-class AddNoteButton(Operator):
- bl_idname = "measureit.addnotebutton"
+class MEASUREIT_OT_AddNote(Operator):
+ bl_idname = "measureit.addnote"
bl_label = "Note"
bl_description = "(OBJECT mode only) Add a new annotation"
- bl_category = 'Measureit'
- tag = IntProperty()
+ tag: IntProperty()
# ------------------------------
# Poll
@@ -1936,11 +1922,10 @@ class AddNoteButton(Operator):
# Defines button that enables/disables the tip display
#
# -------------------------------------------------------------
-class RunHintDisplayButton(Operator):
- bl_idname = "measureit.runopenglbutton"
+class MEASUREIT_OT_RunHintDisplay(Operator):
+ bl_idname = "measureit.runopengl"
bl_label = "Display hint data manager"
bl_description = "Main control for enabling or disabling the display of measurements in the viewport"
- bl_category = 'Measureit'
_handle = None # keep function handler
@@ -1949,8 +1934,8 @@ class RunHintDisplayButton(Operator):
# ----------------------------------
@staticmethod
def handle_add(self, context):
- if RunHintDisplayButton._handle is None:
- RunHintDisplayButton._handle = SpaceView3D.draw_handler_add(draw_callback_px, (self, context),
+ if MEASUREIT_OT_RunHintDisplay._handle is None:
+ MEASUREIT_OT_RunHintDisplay._handle = SpaceView3D.draw_handler_add(draw_callback_px, (self, context),
'WINDOW',
'POST_PIXEL')
context.window_manager.measureit_run_opengl = True
@@ -1961,9 +1946,9 @@ class RunHintDisplayButton(Operator):
# noinspection PyUnusedLocal
@staticmethod
def handle_remove(self, context):
- if RunHintDisplayButton._handle is not None:
- SpaceView3D.draw_handler_remove(RunHintDisplayButton._handle, 'WINDOW')
- RunHintDisplayButton._handle = None
+ if MEASUREIT_OT_RunHintDisplay._handle is not None:
+ SpaceView3D.draw_handler_remove(MEASUREIT_OT_RunHintDisplay._handle, 'WINDOW')
+ MEASUREIT_OT_RunHintDisplay._handle = None
context.window_manager.measureit_run_opengl = False
# ------------------------------
@@ -2011,22 +1996,9 @@ def draw_main(context):
rv3d = context.space_data.region_quadviews[i]
scene = bpy.context.scene
- local_view = context.area.spaces.active.local_view is not None
- layers = []
- if local_view is False:
- # Get visible layers
- if bpy.context.space_data.lock_camera_and_layers is True:
- for x in range(20):
- if bpy.context.scene.layers[x] is True:
- layers.append(x)
- else:
- # Lock disabled, use view dependent visible layers
- for x in range(20):
- if bpy.context.space_data.layers[x] is True:
- layers.append(x)
# Display selected or all
- if scene.measureit_gl_ghost is False or local_view is True:
+ if scene.measureit_gl_ghost is False:
objlist = context.selected_objects
else:
objlist = context.scene.objects
@@ -2037,20 +2009,11 @@ def draw_main(context):
# Generate all OpenGL calls for measures
# ---------------------------------------
for myobj in objlist:
- if myobj.hide is False:
+ if myobj.visible_get() is True:
if 'MeasureGenerator' in myobj:
- if local_view is False:
- # verify visible layer
- for x in range(20):
- if myobj.layers[x] is True and x in layers:
- op = myobj.MeasureGenerator[0]
- draw_segments(context, myobj, op, region, rv3d)
- break
- else:
- # Layer check not needed here, selected objects are not
- # added to context.selected_objects if in disabled layers
- op = myobj.MeasureGenerator[0]
- draw_segments(context, myobj, op, region, rv3d)
+ op = myobj.MeasureGenerator[0]
+ draw_segments(context, myobj, op, region, rv3d)
+
# ---------------------------------------
# Generate all OpenGL calls for debug
# ---------------------------------------
@@ -2075,7 +2038,6 @@ def draw_main(context):
# -----------------------
bgl.glLineWidth(1)
bgl.glDisable(bgl.GL_BLEND)
- bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
# -------------------------------------------------------------
@@ -2118,7 +2080,7 @@ def get_selected_vertex(myobject):
# meshes
# --------------------
oldobj = bpy.context.object
- bpy.context.scene.objects.active = myobject
+ bpy.context.view_layer.objects.active = myobject
flag = False
if myobject.mode != 'EDIT':
bpy.ops.object.mode_set(mode='EDIT')
@@ -2133,7 +2095,7 @@ def get_selected_vertex(myobject):
if flag is True:
bpy.ops.object.editmode_toggle()
# Back context object
- bpy.context.scene.objects.active = oldobj
+ bpy.context.view_layer.objects.active = oldobj
# if select all vertices, then use origin
if tv == len(mylist):
@@ -2154,7 +2116,7 @@ def get_selected_vertex_history(myobject):
# meshes
# --------------------
oldobj = bpy.context.object
- bpy.context.scene.objects.active = myobject
+ bpy.context.view_layer.objects.active = myobject
flag = False
if myobject.mode != 'EDIT':
bpy.ops.object.mode_set(mode='EDIT')
@@ -2167,7 +2129,7 @@ def get_selected_vertex_history(myobject):
if flag is True:
bpy.ops.object.editmode_toggle()
# Back context object
- bpy.context.scene.objects.active = oldobj
+ bpy.context.view_layer.objects.active = oldobj
return mylist
@@ -2184,7 +2146,7 @@ def get_smart_selected(myobject):
# meshes
# --------------------
oldobj = bpy.context.object
- bpy.context.scene.objects.active = myobject
+ bpy.context.view_layer.objects.active = myobject
flag = False
if myobject.mode != 'EDIT':
bpy.ops.object.mode_set(mode='EDIT')
@@ -2199,7 +2161,7 @@ def get_smart_selected(myobject):
if flag is True:
bpy.ops.object.editmode_toggle()
# Back context object
- bpy.context.scene.objects.active = oldobj
+ bpy.context.view_layer.objects.active = oldobj
return mylist
@@ -2216,7 +2178,7 @@ def get_selected_faces(myobject):
# meshes
# --------------------
oldobj = bpy.context.object
- bpy.context.scene.objects.active = myobject
+ bpy.context.view_layer.objects.active = myobject
flag = False
if myobject.mode != 'EDIT':
bpy.ops.object.mode_set(mode='EDIT')
@@ -2234,6 +2196,6 @@ def get_selected_faces(myobject):
if flag is True:
bpy.ops.object.editmode_toggle()
# Back context object
- bpy.context.scene.objects.active = oldobj
+ bpy.context.view_layer.objects.active = oldobj
return mylist