Py io_utils: deprecate orientation_helper_factory and add new orientation_helper decorator.
This fixes warning about not using annotations, and a decorator here is a much cleaner solution anyway.
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
__all__ = (
|
__all__ = (
|
||||||
"ExportHelper",
|
"ExportHelper",
|
||||||
"ImportHelper",
|
"ImportHelper",
|
||||||
|
"orientation_helper",
|
||||||
"orientation_helper_factory",
|
"orientation_helper_factory",
|
||||||
"axis_conversion",
|
"axis_conversion",
|
||||||
"axis_conversion_ensure",
|
"axis_conversion_ensure",
|
||||||
@@ -121,7 +122,53 @@ class ImportHelper:
|
|||||||
return _check_axis_conversion(self)
|
return _check_axis_conversion(self)
|
||||||
|
|
||||||
|
|
||||||
|
def orientation_helper(axis_forward='Y', axis_up='Z'):
|
||||||
|
def wrapper(cls):
|
||||||
|
def _update_axis_forward(self, context):
|
||||||
|
if self.axis_forward[-1] == self.axis_up[-1]:
|
||||||
|
self.axis_up = (self.axis_up[0:-1] +
|
||||||
|
'XYZ'[('XYZ'.index(self.axis_up[-1]) + 1) % 3])
|
||||||
|
|
||||||
|
cls.__annotations__['axis_forward'] = EnumProperty(
|
||||||
|
name="Forward",
|
||||||
|
items=(
|
||||||
|
('X', "X Forward", ""),
|
||||||
|
('Y', "Y Forward", ""),
|
||||||
|
('Z', "Z Forward", ""),
|
||||||
|
('-X', "-X Forward", ""),
|
||||||
|
('-Y', "-Y Forward", ""),
|
||||||
|
('-Z', "-Z Forward", ""),
|
||||||
|
),
|
||||||
|
default=axis_forward,
|
||||||
|
update=_update_axis_forward,
|
||||||
|
)
|
||||||
|
|
||||||
|
def _update_axis_up(self, context):
|
||||||
|
if self.axis_up[-1] == self.axis_forward[-1]:
|
||||||
|
self.axis_forward = (self.axis_forward[0:-1] +
|
||||||
|
'XYZ'[('XYZ'.index(self.axis_forward[-1]) + 1) % 3])
|
||||||
|
|
||||||
|
cls.__annotations__['axis_up'] = EnumProperty(
|
||||||
|
name="Up",
|
||||||
|
items=(
|
||||||
|
('X', "X Up", ""),
|
||||||
|
('Y', "Y Up", ""),
|
||||||
|
('Z', "Z Up", ""),
|
||||||
|
('-X', "-X Up", ""),
|
||||||
|
('-Y', "-Y Up", ""),
|
||||||
|
('-Z', "-Z Up", ""),
|
||||||
|
),
|
||||||
|
default=axis_up,
|
||||||
|
update=_update_axis_up,
|
||||||
|
)
|
||||||
|
|
||||||
|
return cls
|
||||||
|
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
def orientation_helper_factory(name, axis_forward='Y', axis_up='Z'):
|
def orientation_helper_factory(name, axis_forward='Y', axis_up='Z'):
|
||||||
|
print("WARNING! Using this helper function is deprecated, please switch to orientation_helper decorator instead.")
|
||||||
members = {}
|
members = {}
|
||||||
|
|
||||||
def _update_axis_forward(self, context):
|
def _update_axis_forward(self, context):
|
||||||
|
|||||||
Reference in New Issue
Block a user