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:
authorMartin Buerbaum <martin.buerbaum@gmx.at>2011-03-29 13:30:55 +0400
committerMartin Buerbaum <martin.buerbaum@gmx.at>2011-03-29 13:30:55 +0400
commit395821bc8f5c981ef8b876a142f00dde76adffe7 (patch)
treef8b9ea0c2e73b011338f4e4ceec2db674de7874b /space_view3d_panel_measure.py
parentad974de4793a7714e9e77f50dd216eab9bb9ebeb (diff)
* Measure Panel - Version 0.7.13
* Moved property definitions to registration function. * Changed automatic callback adding to manual, the current API doesn't seem to allow this top be automatically yet.
Diffstat (limited to 'space_view3d_panel_measure.py')
-rw-r--r--space_view3d_panel_measure.py114
1 files changed, 68 insertions, 46 deletions
diff --git a/space_view3d_panel_measure.py b/space_view3d_panel_measure.py
index cbb1f1d6..5dc6029f 100644
--- a/space_view3d_panel_measure.py
+++ b/space_view3d_panel_measure.py
@@ -19,12 +19,12 @@
bl_info = {
"name": "Measure Panel",
"author": "Buerbaum Martin (Pontiac)",
- "version": (0, 7, 12),
+ "version": (0, 7, 13),
"blender": (2, 5, 7),
- "api": 35622,
+ "api": 35864,
"location": "View3D > Properties > Measure Panel",
"description": "Measure distances between objects",
- "warning": "Script returns errors",
+ "warning": "",
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/" \
"Scripts/3D_interaction/Panel_Measure",
"tracker_url": "https://projects.blender.org/tracker/index.php?" \
@@ -58,7 +58,11 @@ It's very helpful to use one or two "Empty" objects with
"Snap during transform" enabled for fast measurement.
Version history:
-v0.7.12 - Moved setting of properties to callback function
+v0.7.13 - Moved property definitions to registration function.
+ Changed automatic callback adding to manual,
+ the current API doesn't seem to allow this top be automatically yet.
+ Various API fixes.
+v0.7.12 - Moved setting of properties to callback function
(it is bad practise to set it in the draw code).
Fixed distance calculation of parented objects.
API change: add_modal_handler -> modal_handler_add
@@ -259,7 +263,7 @@ def getMeasurePoints(context):
# Convert to local or global space.
if measureLocal(sce):
- p1 = vert_loc
+ p1 = vert_loc
p2 = cur_loc
return (p1, p2, COLOR_LOCAL)
@@ -725,6 +729,20 @@ class VIEW3D_OT_display_measurements(bpy.types.Operator):
return {'CANCELLED'}
+class VIEW3D_OT_activate_measure_panel(bpy.types.Operator):
+ bl_label = "Activate"
+ bl_idname = "view3d.activate_measure_panel"
+ bl_description = "Activate the callback needed to draw the lines."
+ bl_options = {'REGISTER'}
+
+ def invoke(self, context, event):
+
+ # Execute operator (this adds the callback)
+ # if it wasn't done yet.
+ bpy.ops.view3d.display_measurements()
+ return {'FINISHED'}
+
+
class VIEW3D_OT_reenter_editmode(bpy.types.Operator):
bl_label = "Re-enter EditMode"
bl_idname = "view3d.reenter_editmode"
@@ -772,23 +790,15 @@ class VIEW3D_PT_measure(bpy.types.Panel):
# @todo Better solution?
context.area.tag_redraw()
- # Execute operator (this adds the callback)
- # if it wasn't done yet.
- bpy.ops.view3d.display_measurements()
-
- # Define property for the draw setting.
- bpy.types.Scene.measure_panel_draw = bpy.props.BoolProperty(
- description="Draw distances in 3D View",
- default=1)
-
- # Define property for the calc-area setting.
- # @todo prevent double calculations for each refresh automatically?
- bpy.types.Scene.measure_panel_calc_area = bpy.props.BoolProperty(
- description="Calculate mesh surface area (heavy CPU" \
- " usage on bigger meshes)",
- default=0)
+ mgr_ops = context.window_manager.operators.values()
+ if (not "VIEW3D_OT_display_measurements"
+ in [op.bl_idname for op in mgr_ops]):
+ layout.operator("view3d.activate_measure_panel",
+ text="Activate")
+ else:
+ layout.prop(sce, "measure_panel_draw")
- layout.prop(sce, "measure_panel_draw")
+ context.area.tag_redraw()
def draw(self, context):
layout = self.layout
@@ -797,31 +807,6 @@ class VIEW3D_PT_measure(bpy.types.Panel):
# Get a single selected object (or nothing).
obj = getSingleObject(context)
- # Define a temporary attribute for the distance value
- bpy.types.Scene.measure_panel_dist = bpy.props.FloatProperty(
- name="Distance",
- precision=PRECISION,
- unit="LENGTH")
- bpy.types.Scene.measure_panel_area1 = bpy.props.FloatProperty(
- precision=PRECISION,
- unit="AREA")
- bpy.types.Scene.measure_panel_area2 = bpy.props.FloatProperty(
- precision=PRECISION,
- unit="AREA")
-
- TRANSFORM = [
- ("measure_global", "Global",
- "Calculate values in global space."),
- ("measure_local", "Local",
- "Calculate values inside the local object space.")]
-
- # Define dropdown for the global/local setting
- bpy.types.Scene.measure_panel_transform = bpy.props.EnumProperty(
- name="Space",
- description="Choose in which space you want to measure.",
- items=TRANSFORM,
- default='measure_global')
-
if (context.mode == 'EDIT_MESH'):
obj = context.active_object
@@ -1102,6 +1087,43 @@ class VIEW3D_PT_measure(bpy.types.Panel):
def register():
bpy.utils.register_module(__name__)
+ # Define a temporary attribute for the distance value
+ bpy.types.Scene.measure_panel_dist = bpy.props.FloatProperty(
+ name="Distance",
+ precision=PRECISION,
+ unit="LENGTH")
+ bpy.types.Scene.measure_panel_area1 = bpy.props.FloatProperty(
+ precision=PRECISION,
+ unit="AREA")
+ bpy.types.Scene.measure_panel_area2 = bpy.props.FloatProperty(
+ precision=PRECISION,
+ unit="AREA")
+
+ TRANSFORM = [
+ ("measure_global", "Global",
+ "Calculate values in global space."),
+ ("measure_local", "Local",
+ "Calculate values inside the local object space.")]
+
+ # Define dropdown for the global/local setting
+ bpy.types.Scene.measure_panel_transform = bpy.props.EnumProperty(
+ name="Space",
+ description="Choose in which space you want to measure.",
+ items=TRANSFORM,
+ default='measure_global')
+
+ # Define property for the draw setting.
+ bpy.types.Scene.measure_panel_draw = bpy.props.BoolProperty(
+ description="Draw distances in 3D View",
+ default=1)
+
+ # Define property for the calc-area setting.
+ # @todo prevent double calculations for each refresh automatically?
+ bpy.types.Scene.measure_panel_calc_area = bpy.props.BoolProperty(
+ description="Calculate mesh surface area (heavy CPU" \
+ " usage on bigger meshes)",
+ default=0)
+
pass