[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [716] Return space_view3d_panel_measure .py to trunk, with the "Broken" Category.
Brendon Murphy
meta.androcto1 at gmail.com
Mon Jun 7 12:34:17 CEST 2010
Revision: 716
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=716
Author: meta-androcto
Date: 2010-06-07 12:34:16 +0200 (Mon, 07 Jun 2010)
Log Message:
-----------
Return space_view3d_panel_measure.py to trunk, with the "Broken" Category.
Added Paths:
-----------
trunk/py/scripts/addons/space_view3d_panel_measure.py
Removed Paths:
-------------
repair_holding/space_view3d_panel_measure.py
Deleted: repair_holding/space_view3d_panel_measure.py
===================================================================
--- repair_holding/space_view3d_panel_measure.py 2010-06-07 10:08:10 UTC (rev 715)
+++ repair_holding/space_view3d_panel_measure.py 2010-06-07 10:34:16 UTC (rev 716)
@@ -1,985 +0,0 @@
-# ##### BEGIN GPL LICENSE BLOCK #####
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ##### END GPL LICENSE BLOCK #####
-
-import bpy
-from bpy.props import *
-from mathutils import Vector, Matrix
-import bgl
-import blf
-
-bl_addon_info = {
- 'name': '3D View: Measure panel',
- 'author': 'Buerbaum Martin (Pontiac)',
- 'version': '0.7',
- 'blender': (2, 5, 3),
- 'location': 'View3D > Properties > Measure',
- 'description': 'Measure distances between objects',
- '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?'\
- 'func=detail&aid=21445&group_id=153&atid=469',
- 'category': '3D View'}
-
-# More links:
-# http://gitorious.org/blender-scripts/blender-measure-panel-script
-# http://blenderartists.org/forum/showthread.php?t=177800
-
-__bpydoc__ = """
-Measure panel
-
-This script displays in OBJECT MODE:
-* The distance of the 3D cursor to the origin of the
- 3D space (if NOTHING is selected).
-* The distance of the 3D cursor to the center of an object
- (if exactly ONE object is selected).
-* The distance between 2 object centers
- (if exactly TWO objects are selected).
-* The surface area of any selected mesh object.
-
-Display in EDIT MODE (Local and Global space supported):
-* The distance of the 3D cursor to the origin
- (in Local space it is the object center instead).
-* The distance of the 3D cursor to a selected vertex.
-* The distance between 2 selected vertices.
-
-Usage:
-
-This functionality can be accessed via the
-"Properties" panel in 3D View ([N] key).
-
-It's very helpful to use one or two "Empty" objects with
-"Snap during transform" enabled for fast measurement.
-
-Version history:
-v0.7 - Initial support for drawing lines.
- (Thanks to Algorith for applying my perspective_matrix patch.)
- The distance value (in BUs) is also drawn in the 3D view now.
- Also fixed some wrong calculations of global/local distances.
- Now it's really "what you see is what is calculated".
- Use bl_addon_info for Add-On information.
- Use "3D View" in category & name
- Renamed reenter_editmode to view3d.reenter_editmode.
- Renamed panel_measure.py into space_view3d_panel_measure.py
- Active object is only used for edit-mode now. Measurement
- with exactly one sel. (but not neccessarily active) object
- now gets the obj via the sel-object array.
- API change Mathutils -> mathutils (r557)
- Deselecting 1 of 2 objects now works correctly (active object is ignored).
- Force a redraw of the area so disabling the "measure_panel_draw"
- checkbox will clear the line/text.
- Only calculate area (CPU heavy) if a "area" checkbox is enabled.
-v0.6.4 - Fixed unneeded meshdata duplication (sometimes crashes Blender).
- The script now correctly calculated the surface area (faceAreaGlobal)
- of scaled meshes.
- http://projects.blender.org/tracker/
- ?func=detail&atid=453&aid=21913&group_id=153
-v0.6.3 - Added register & unregister functions.
-v0.6.2 - Fixed precision of second area property.
- Reduced display precision to 5 (instead of 6).
- Added (commented out code) for shortcut [F5] for
- updating EditMode selection & calculation.
- Changed the script so it can be managed from the "Add-Ons" tab
- in the user preferences.
- Corrected FSF address.
-v0.6.1 - Updated reenter_editmode operator description.
- Fixed search for selected mesh objects.
- Added "BU^2" after values that are not yet translated via "unit".
-v0.6
- *) Fix: Removed EditMode/ObjectMode toggle stuff. This causes all the
- crashes and is generally not stable.
- Instead I've added a manual "refresh" button.
- I registered a new operator OBJECT_OT_reenter_editmode for this.
- *) Use "unit" settings (i.e. none/metric/imperial)
- *) Fix: Only display surface area (>=3 objects) if return value is >=0.
- *) Minor: Renamed objectFaceArea to objectSurfaceArea
- *) Updated Vector() and tuple() usage.
- *) Fixed some comments.
-v0.5 - Global surface area (object mode) is now calculated as well.
- Support area calculation for face selection.
- Also made measurement panel closed by default. (Area calculation
- may use up a lot of CPU/RAM in extreme cases)
-v0.4.1 - Various cleanups.
- Using the shorter "scene" instead of "context.scene"
- New functions measureGlobal() and measureLocal() for
- user-friendly access to the "space" setting.
-v0.4 - Calculate & display the surface area of mesh
- objects (local space only right now).
- Expanded global/local switch.
- Made "local" option for 3Dcursor-only in edit mode actually work.
- Fixed local/global calculation for 3Dcursor<->vertex in edit mode.
-v0.3.2 - Fixed calculation & display of local/global coordinates.
- The user can now select via dropdown which space is wanted/needed
- Basically this is a bugfix and new feature at the same time :-)
-v0.3.1 - Fixed bug where "measure_panel_dist" wasn't defined
- before it was used.
- Also added the distance calculation "origin -> 3D cursor" for edit mode.
-v0.3 - Support for mesh edit mode (1 or 2 selected vertices)
-v0.2.1 - Small fix (selecting nothing didn't calculate the distance
- of the cursor from the origin anymore)
-v0.2 - Distance value is now displayed via a FloatProperty widget (and
- therefore saved to file too right now [according to ideasman42].
- The value is save inside the scene right now.)
- Thanks goes to ideasman42 (Campbell Barton) for helping me out on this.
-v0.1 - Initial revision. Seems to work fine for most purposes.
-
-TODO:
-
-There is a random segmentation fault when moving the 3D cursor in edit mode.
-Mainly this happens when clicking inside the white circle of the translation
-manipulator. There may be other cases though.
-
-See the other "todo" comments below.
-"""
-
-# Precicion for display of float values.
-PRECISION = 4
-
-# Name of the custom properties as stored in the scene.
-COLOR_LOCAL = (1.0, 0.0, 0.0, 0.8)
-COLOR_GLOBAL = (0.0, 0.0, 1.0, 0.8)
-
-
-# Returns a single selected object.
-# Returns None if more than one (or nothing) is selected.
-# Note: Ignores the active object.
-def getSingleObject(context):
- if len(context.selected_objects) == 1:
- return context.selected_objects[0]
-
- return None
-
-
-# Returns a list with 2 3D points (Vector) and a color (RGBA)
-# depending on the current view mode and the selection.
-def getMeasurePoints(context):
- sce = context.scene
-
- # Get a single selected object (or nothing).
- obj = getSingleObject(context)
-
- if (context.mode == 'EDIT_MESH'):
- obj = context.active_object
-
- if (obj and obj.type == 'MESH' and obj.data):
- # Get mesh data from Object.
- mesh = obj.data
-
- # Get transformation matrix from object.
- ob_mat = obj.matrix
- # Also make an inversed copy! of the matrix.
- ob_mat_inv = ob_mat.copy()
- Matrix.invert(ob_mat_inv)
-
- # Get the selected vertices.
- # @todo: Better (more efficient) way to do this?
- verts_selected = [v for v in mesh.verts if v.selected == 1]
-
- if len(verts_selected) == 0:
- # Nothing selected.
- # We measure the distance from...
- # local ... the object center to the 3D cursor.
- # global ... the origin to the 3D cursor.
- cur_loc = sce.cursor_location
- obj_loc = obj.location.copy()
-
- # Convert to local space, if needed.
- if measureLocal(sce):
- p1 = cur_loc
- p2 = obj_loc
- return (p1, p2, COLOR_GLOBAL)
-
- else:
- p1 = Vector((0.0, 0.0, 0.0))
- p2 = cur_loc
- return (p1, p2, COLOR_GLOBAL)
-
- elif len(verts_selected) == 1:
- # One vertex selected.
- # We measure the distance from the
- # selected vertex object to the 3D cursor.
- cur_loc = sce.cursor_location
- vert_loc = verts_selected[0].co.copy()
- obj_loc = obj.location.copy()
-
- # Convert to local or global space.
- if measureLocal(sce):
- p1 = obj_loc + vert_loc
- p2 = cur_loc
- return (p1, p2, COLOR_LOCAL)
-
- else:
- p1 = vert_loc * ob_mat + obj_loc
- p2 = cur_loc
- return (p1, p2, COLOR_GLOBAL)
-
- elif len(verts_selected) == 2:
- # Two vertices selected.
- # We measure the distance between the
- # two selected vertices.
- obj_loc = obj.location.copy()
- vert1_loc = verts_selected[0].co.copy()
- vert2_loc = verts_selected[1].co.copy()
-
- # Convert to local or global space.
- if measureLocal(sce):
- p1 = obj_loc + vert1_loc
- p2 = obj_loc + vert2_loc
- return (p1, p2, COLOR_LOCAL)
-
- else:
- p1 = obj_loc + vert1_loc * ob_mat
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list