[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34637] trunk/blender: mathutils.Matrix. OrthoProjection(plane, size, axis), merged axis and plane args.
Campbell Barton
ideasman42 at gmail.com
Fri Feb 4 10:35:21 CET 2011
Revision: 34637
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34637
Author: campbellbarton
Date: 2011-02-04 09:35:20 +0000 (Fri, 04 Feb 2011)
Log Message:
-----------
mathutils.Matrix.OrthoProjection(plane, size, axis), merged axis and plane args. since axis was only allowed when plane was 'R'.
This was already done with Matrix.Rotation().
Modified Paths:
--------------
trunk/blender/intern/tools/bpy_introspect_ui.py
trunk/blender/intern/tools/dump_rna2xml.py
trunk/blender/source/blender/python/generic/mathutils.c
trunk/blender/source/blender/python/generic/mathutils_matrix.c
trunk/blender/source/blender/python/rna_dump.py
Modified: trunk/blender/intern/tools/bpy_introspect_ui.py
===================================================================
--- trunk/blender/intern/tools/bpy_introspect_ui.py 2011-02-04 09:27:25 UTC (rev 34636)
+++ trunk/blender/intern/tools/bpy_introspect_ui.py 2011-02-04 09:35:20 UTC (rev 34637)
@@ -21,6 +21,8 @@
#
# ***** END GPL LICENSE BLOCK *****
+# <pep8 compliant>
+
# This script dumps ui definitions as XML.
# useful for finding bad api usage.
@@ -30,54 +32,52 @@
import sys
ModuleType = type(sys)
+
def module_add(name):
mod = sys.modules[name] = ModuleType(name)
return mod
+
class AttributeBuilder(object):
"""__slots__ = (
"_attr", "_attr_list", "_item_set", "_args",
"active", "operator_context", "enabled", "index", "data"
)"""
-
-
+
def _as_py(self):
data = [self._attr_single, self._args, [child._as_py() for child in self._attr_list]]
return data
-
+
def _as_xml(self, indent=" "):
-
+
def to_xml_str(value):
if type(value) == str:
# quick shoddy clean
value = value.replace("&", " ")
value = value.replace("<", " ")
value = value.replace(">", " ")
-
-
-
+
return '"' + value + '"'
else:
return '"' + str(value) + '"'
-
+
def dict_to_kw(args, dict_args):
args_str = ""
if args:
# args_str += " ".join([to_xml_str(a) for a in args])
for i, a in enumerate(args):
args_str += "arg" + str(i + 1) + "=" + to_xml_str(a) + " "
-
-
+
if dict_args:
args_str += " ".join(["%s=%s" % (key, to_xml_str(value)) for key, value in sorted(dict_args.items())])
-
+
if args_str:
return " " + args_str
return ""
-
+
lines = []
-
+
def py_to_xml(item, indent_ctx):
if item._attr_list:
lines.append("%s<%s%s>" % (indent_ctx, item._attr_single, dict_to_kw(item._args_tuple, item._args)))
@@ -87,11 +87,11 @@
lines.append("%s</%s>" % (indent_ctx, item._attr_single))
else:
lines.append("%s<%s%s/>" % (indent_ctx, item._attr_single, dict_to_kw(item._args_tuple, item._args)))
-
+
py_to_xml(self, indent)
-
+
return "\n".join(lines)
-
+
def __init__(self, attr, attr_single):
self._attr = attr
self._attr_single = attr_single
@@ -99,11 +99,13 @@
self._item_set = []
self._args = {}
self._args_tuple = ()
+
def __call__(self, *args, **kwargs):
# print(self._attr, args, kwargs)
self._args_tuple = args
self._args = kwargs
return self
+
def __getattr__(self, attr):
attr_obj = NewAttr(self._attr + "." + attr, attr)
self._attr_list.append(attr_obj)
@@ -111,14 +113,14 @@
# def __setattr__(self, attr, value):
# setatte
-
+
def __getitem__(self, item):
item_obj = NewAttr(self._attr + "[" + repr(item) + "]", item)
self._item_set.append(item_obj)
return item_obj
-
+
def __setitem__(self, item, value):
- pass # TODO?
+ pass # TODO?
def __repr__(self):
return self._attr
@@ -128,13 +130,13 @@
#def __len__(self):
# return 0
-
+
def __int__(self):
return 0
-
+
def __cmp__(self, other):
return -1
-
+
def __lt__(self, other):
return -1
@@ -149,12 +151,14 @@
def __sub__(self, other):
return self
-
+
# Custom functions
def lower(self):
return ""
+
def upper(self):
return ""
+
def keys(self):
return []
@@ -163,29 +167,36 @@
obj = AttributeBuilder(attr, attr_single)
return obj
+
class BaseFakeUI():
def __init__(self):
self.layout = NewAttr("self.layout", "layout")
+
class Panel(BaseFakeUI):
pass
+
class Header(BaseFakeUI):
pass
+
class Menu(BaseFakeUI):
def draw_preset(self, context):
pass
- def path_menu(self, a, b,c):
+
+ def path_menu(self, a, b, c):
pass
+
class Operator(BaseFakeUI):
pass
+
class IDPropertyGroup():
pass
-
+
# setup fake module
def fake_main():
bpy = module_add("bpy")
@@ -196,7 +207,7 @@
bpy.types.Menu = Menu
bpy.types.IDPropertyGroup = IDPropertyGroup
bpy.types.Operator = Operator
-
+
bpy.types.Armature = type("Armature", (), {})
bpy.types.Bone = type("Bone", (), {})
bpy.types.EditBone = type("EditBone", (), {})
@@ -217,13 +228,13 @@
bpy.types.Scene = type("Scene", (), {})
bpy.types.Scene.EnumProperty = NewAttr("bpy.types.Scene.EnumProperty", "EnumProperty")
bpy.types.Scene.StringProperty = NewAttr("bpy.types.Scene.StringProperty", "StringProperty")
-
+
bpy.props = module_add("bpy.props")
bpy.props.StringProperty = dict
bpy.props.BoolProperty = dict
bpy.props.IntProperty = dict
bpy.props.EnumProperty = dict
-
+
bpy.data = module_add("bpy.data")
bpy.data.scenes = ()
bpy.data.groups = ()
@@ -237,13 +248,13 @@
bpy.data.metaballs = ()
bpy.data.armatures = ()
bpy.data.particles = ()
-
+
bpy.data.file_is_saved = True
-
+
bpy.utils = module_add("bpy.utils")
bpy.utils.smpte_from_frame = lambda f: ""
bpy.utils.script_paths = lambda f: []
-
+
bpy.app = module_add("bpy.app")
bpy.app.debug = False
bpy.app.version = 2, 55, 1
@@ -251,6 +262,7 @@
bpy.path = module_add("bpy.path")
bpy.path.display_name = lambda f: ""
+
def fake_helper():
class PropertyPanel():
@@ -271,6 +283,7 @@
sys.path.insert(0, "/b/release/scripts/ui/")
+
def module_classes(mod):
classes = []
for value in mod.__dict__.values():
@@ -281,7 +294,7 @@
if is_subclass:
classes.append(value)
-
+
return classes
@@ -297,7 +310,7 @@
if f.endswith(".py"):
# print(f)
mod = __import__(f[:-3])
-
+
classes = module_classes(mod)
for cls in classes:
@@ -311,7 +324,7 @@
mod = __import__(f[:-3])
classes = module_classes(mod)
-
+
for cls in classes:
# want to check if the draw function is directly in the class
# print("draw")
Modified: trunk/blender/intern/tools/dump_rna2xml.py
===================================================================
--- trunk/blender/intern/tools/dump_rna2xml.py 2011-02-04 09:27:25 UTC (rev 34636)
+++ trunk/blender/intern/tools/dump_rna2xml.py 2011-02-04 09:35:20 UTC (rev 34637)
@@ -21,6 +21,8 @@
#
# ***** END GPL LICENSE BLOCK *****
+# <pep8 compliant>
+
# This script dumps rna into xml.
# useful for finding bugs in RNA api.
@@ -34,9 +36,9 @@
bpy.types.KeyingSet,
bpy.types.Header)
+
def build_property_typemap():
-
property_typemap = {}
for attr in dir(bpy.types):
@@ -57,13 +59,14 @@
def print_ln(data):
print(data, end="")
+
def rna2xml(fw=print_ln, ident_val=" "):
from xml.sax.saxutils import quoteattr
property_typemap = build_property_typemap()
def rna2xml_node(ident, value, parent):
ident_next = ident + ident_val
-
+
# divide into attrs and nodes.
node_attrs = []
nodes_items = []
@@ -73,10 +76,10 @@
if issubclass(value_type, invalid_classes):
return
-
+
if value == parent:
return
-
+
value_type_name = value_type.__name__
for prop in property_typemap[value_type_name]:
@@ -116,7 +119,7 @@
return str(s)
else:
return " ".join([str_recursive(si) for si in s])
-
+
node_attrs.append("%s=\"%s\"" % (prop, " ".join(str_recursive(v) for v in subvalue_rna)))
else:
nodes_lists.append((prop, subvalue_ls, subvalue_type))
@@ -138,11 +141,9 @@
fw("%s</%s>\n" % (ident, value_type_name))
-
-
fw("<root>\n")
for attr in dir(bpy.data):
-
+
# exceptions
if attr.startswith("_"):
continue
@@ -154,15 +155,16 @@
ls = value[:]
except:
ls = None
-
+
if type(ls) == list:
fw("%s<%s>\n" % (ident_val, attr))
- for blend_id in ls:
+ for blend_id in ls:
rna2xml_node(ident_val + ident_val, blend_id, None)
fw("%s</%s>\n" % (ident_val, attr))
fw("</root>\n")
+
def main():
filename = bpy.data.filepath.rstrip(".blend") + ".xml"
file = open(filename, 'w')
Modified: trunk/blender/source/blender/python/generic/mathutils.c
===================================================================
--- trunk/blender/source/blender/python/generic/mathutils.c 2011-02-04 09:27:25 UTC (rev 34636)
+++ trunk/blender/source/blender/python/generic/mathutils.c 2011-02-04 09:35:20 UTC (rev 34637)
@@ -37,6 +37,7 @@
* - Mathutils.Slerp --> quat.slerp(other, fac)
* - Mathutils.Rand: removed, use pythons random module
* - Mathutils.RotationMatrix(angle, size, axis_flag, axis) --> Mathutils.RotationMatrix(angle, size, axis); merge axis & axis_flag args
+ * - Mathutils.OrthoProjectionMatrix(plane, size, axis) --> Mathutils.OrthoProjectionMatrix(axis, size); merge axis & plane args
* - Matrix.scalePart --> Matrix.scale_part
* - Matrix.translationPart --> Matrix.translation_part
* - Matrix.rotationPart --> Matrix.rotation_part
Modified: trunk/blender/source/blender/python/generic/mathutils_matrix.c
===================================================================
--- trunk/blender/source/blender/python/generic/mathutils_matrix.c 2011-02-04 09:27:25 UTC (rev 34636)
+++ trunk/blender/source/blender/python/generic/mathutils_matrix.c 2011-02-04 09:35:20 UTC (rev 34637)
@@ -163,8 +163,8 @@
" :arg axis: a string in ['X', 'Y', 'Z'] or a 3D Vector Object (optional when size is 2).\n"
" :type axis: string or :class:`Vector`\n"
" :return: A new rotation matrix.\n"
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list