WM: rename manipulator to gizmo in Python API

This commit is contained in:
Campbell Barton
2018-07-14 23:55:20 +02:00
parent 5ebebcfbff
commit 89299f6620
5 changed files with 37 additions and 37 deletions

View File

@@ -556,7 +556,7 @@ class RNAMetaPropGroup(StructMetaPropGroup, RNAMeta):
# Same as 'Operator' # Same as 'Operator'
# only without 'as_keywords' # only without 'as_keywords'
class Manipulator(StructRNA): class Gizmo(StructRNA):
__slots__ = () __slots__ = ()
def __getattribute__(self, attr): def __getattribute__(self, attr):
@@ -590,15 +590,15 @@ class Manipulator(StructRNA):
# Convenience wrappers around private `_gawain` module. # Convenience wrappers around private `_gawain` module.
def draw_custom_shape(self, shape, *, matrix=None, select_id=None): def draw_custom_shape(self, shape, *, matrix=None, select_id=None):
""" """
Draw a shape created form :class:`bpy.types.Manipulator.draw_custom_shape`. Draw a shape created form :class:`bpy.types.Gizmo.draw_custom_shape`.
:arg shape: The cached shape to draw. :arg shape: The cached shape to draw.
:type shape: Undefined. :type shape: Undefined.
:arg matrix: 4x4 matrix, when not given :arg matrix: 4x4 matrix, when not given
:class:`bpy.types.Manipulator.matrix_world` is used. :class:`bpy.types.Gizmo.matrix_world` is used.
:type matrix: :class:`mathutils.Matrix` :type matrix: :class:`mathutils.Matrix`
:arg select_id: The selection id. :arg select_id: The selection id.
Only use when drawing within :class:`bpy.types.Manipulator.draw_select`. Only use when drawing within :class:`bpy.types.Gizmo.draw_select`.
:type select_it: int :type select_it: int
""" """
import gpu import gpu
@@ -627,7 +627,7 @@ class Manipulator(StructRNA):
@staticmethod @staticmethod
def new_custom_shape(type, verts): def new_custom_shape(type, verts):
""" """
Create a new shape that can be passed to :class:`bpy.types.Manipulator.draw_custom_shape`. Create a new shape that can be passed to :class:`bpy.types.Gizmo.draw_custom_shape`.
:arg type: The type of shape to create in (POINTS, LINES, TRIS, LINE_STRIP). :arg type: The type of shape to create in (POINTS, LINES, TRIS, LINE_STRIP).
:type type: string :type type: string

View File

@@ -5,8 +5,8 @@
# #
import bpy import bpy
from bpy.types import ( from bpy.types import (
Manipulator, Gizmo,
ManipulatorGroup, GizmoGroup,
) )
# Coordinates (each one is a triangle). # Coordinates (each one is a triangle).
@@ -62,7 +62,7 @@ custom_shape_verts = (
) )
class MyCustomShapeWidget(Manipulator): class MyCustomShapeWidget(Gizmo):
bl_idname = "VIEW3D_WT_auto_facemap" bl_idname = "VIEW3D_WT_auto_facemap"
bl_target_properties = ( bl_target_properties = (
{"id": "offset", "type": 'FLOAT', "array_length": 1}, {"id": "offset", "type": 'FLOAT', "array_length": 1},
@@ -108,11 +108,11 @@ class MyCustomShapeWidget(Manipulator):
delta /= 10.0 delta /= 10.0
value = self.init_value + delta value = self.init_value + delta
self.target_set_value("offset", value) self.target_set_value("offset", value)
context.area.header_text_set("My Manipulator: %.4f" % value) context.area.header_text_set("My Gizmo: %.4f" % value)
return {'RUNNING_MODAL'} return {'RUNNING_MODAL'}
class MyCustomShapeWidgetGroup(ManipulatorGroup): class MyCustomShapeWidgetGroup(GizmoGroup):
bl_idname = "OBJECT_WGT_light_test" bl_idname = "OBJECT_WGT_light_test"
bl_label = "Test Light Widget" bl_label = "Test Light Widget"
bl_space_type = 'VIEW_3D' bl_space_type = 'VIEW_3D'
@@ -127,7 +127,7 @@ class MyCustomShapeWidgetGroup(ManipulatorGroup):
def setup(self, context): def setup(self, context):
# Assign the 'offset' target property to the light energy. # Assign the 'offset' target property to the light energy.
ob = context.object ob = context.object
mpr = self.manipulators.new(MyCustomShapeWidget.bl_idname) mpr = self.gizmos.new(MyCustomShapeWidget.bl_idname)
mpr.target_set_prop("offset", ob.data, "energy") mpr.target_set_prop("offset", ob.data, "energy")
mpr.matrix_basis = ob.matrix_world.normalized() mpr.matrix_basis = ob.matrix_world.normalized()

View File

@@ -1,15 +1,15 @@
# Example of an operator which uses manipulators to control its properties. # Example of an operator which uses gizmos to control its properties.
# #
# Usage: Run this script, then in mesh edit-mode press Spacebar # Usage: Run this script, then in mesh edit-mode press Spacebar
# to activate the operator "Select Side of Plane" # to activate the operator "Select Side of Plane"
# The manipulators can then be used to adjust the plane in the 3D view. # The gizmos can then be used to adjust the plane in the 3D view.
# #
import bpy import bpy
import bmesh import bmesh
from bpy.types import ( from bpy.types import (
Operator, Operator,
ManipulatorGroup, GizmoGroup,
) )
from bpy.props import ( from bpy.props import (
@@ -68,7 +68,7 @@ class SelectSideOfPlane(Operator):
if context.space_data.type == 'VIEW_3D': if context.space_data.type == 'VIEW_3D':
wm = context.window_manager wm = context.window_manager
wm.manipulator_group_type_add(SelectSideOfPlaneManipulatorGroup.bl_idname) wm.gizmo_group_type_add(SelectSideOfPlaneGizmoGroup.bl_idname)
return {'FINISHED'} return {'FINISHED'}
@@ -78,10 +78,10 @@ class SelectSideOfPlane(Operator):
return {'FINISHED'} return {'FINISHED'}
# Manipulators for plane_co, plane_no # Gizmos for plane_co, plane_no
class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup): class SelectSideOfPlaneGizmoGroup(GizmoGroup):
bl_idname = "MESH_WGT_select_side_of_plane" bl_idname = "MESH_WGT_select_side_of_plane"
bl_label = "Side of Plane Manipulator" bl_label = "Side of Plane Gizmo"
bl_space_type = 'VIEW_3D' bl_space_type = 'VIEW_3D'
bl_region_type = 'WINDOW' bl_region_type = 'WINDOW'
bl_options = {'3D'} bl_options = {'3D'}
@@ -106,7 +106,7 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
op = cls.my_target_operator(context) op = cls.my_target_operator(context)
if op is None: if op is None:
wm = context.window_manager wm = context.window_manager
wm.manipulator_group_type_remove(SelectSideOfPlaneManipulatorGroup.bl_idname) wm.gizmo_group_type_remove(SelectSideOfPlaneGizmoGroup.bl_idname)
return False return False
return True return True
@@ -117,16 +117,16 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
# Grab # Grab
def grab_get_cb(): def grab_get_cb():
op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context) op = SelectSideOfPlaneGizmoGroup.my_target_operator(context)
return op.plane_co return op.plane_co
def grab_set_cb(value): def grab_set_cb(value):
op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context) op = SelectSideOfPlaneGizmoGroup.my_target_operator(context)
op.plane_co = value op.plane_co = value
# XXX, this may change! # XXX, this may change!
op.execute(context) op.execute(context)
mpr = self.manipulators.new("MANIPULATOR_WT_grab_3d") mpr = self.gizmos.new("GIZMO_WT_grab_3d")
mpr.target_set_handler("offset", get=grab_get_cb, set=grab_set_cb) mpr.target_set_handler("offset", get=grab_get_cb, set=grab_set_cb)
mpr.use_draw_value = True mpr.use_draw_value = True
@@ -145,7 +145,7 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
# Dial # Dial
def direction_get_cb(): def direction_get_cb():
op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context) op = SelectSideOfPlaneGizmoGroup.my_target_operator(context)
no_a = self.widget_dial.matrix_basis.col[1].xyz no_a = self.widget_dial.matrix_basis.col[1].xyz
no_b = Vector(op.plane_no) no_b = Vector(op.plane_no)
@@ -155,13 +155,13 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
return no_a.angle_signed(no_b) return no_a.angle_signed(no_b)
def direction_set_cb(value): def direction_set_cb(value):
op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context) op = SelectSideOfPlaneGizmoGroup.my_target_operator(context)
matrix_rotate = Matrix.Rotation(-value, 3, self.rotate_axis) matrix_rotate = Matrix.Rotation(-value, 3, self.rotate_axis)
no = matrix_rotate * self.widget_dial.matrix_basis.col[1].xyz no = matrix_rotate * self.widget_dial.matrix_basis.col[1].xyz
op.plane_no = no op.plane_no = no
op.execute(context) op.execute(context)
mpr = self.manipulators.new("MANIPULATOR_WT_dial_3d") mpr = self.gizmos.new("GIZMO_WT_dial_3d")
mpr.target_set_handler("offset", get=direction_get_cb, set=direction_set_cb) mpr.target_set_handler("offset", get=direction_get_cb, set=direction_set_cb)
mpr.draw_options = {'ANGLE_START_Y'} mpr.draw_options = {'ANGLE_START_Y'}
@@ -216,7 +216,7 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
classes = ( classes = (
SelectSideOfPlane, SelectSideOfPlane,
SelectSideOfPlaneManipulatorGroup, SelectSideOfPlaneGizmoGroup,
) )

View File

@@ -1,15 +1,15 @@
# Example of a manipulator that activates an operator # Example of a gizmo that activates an operator
# using the predefined dial manipulator to change the camera roll. # using the predefined dial gizmo to change the camera roll.
# #
# Usage: Run this script and select a camera in the 3D view. # Usage: Run this script and select a camera in the 3D view.
# #
import bpy import bpy
from bpy.types import ( from bpy.types import (
ManipulatorGroup, GizmoGroup,
) )
class MyCameraWidgetGroup(ManipulatorGroup): class MyCameraWidgetGroup(GizmoGroup):
bl_idname = "OBJECT_WGT_test_camera" bl_idname = "OBJECT_WGT_test_camera"
bl_label = "Object Camera Test Widget" bl_label = "Object Camera Test Widget"
bl_space_type = 'VIEW_3D' bl_space_type = 'VIEW_3D'
@@ -22,9 +22,9 @@ class MyCameraWidgetGroup(ManipulatorGroup):
return (ob and ob.type == 'CAMERA') return (ob and ob.type == 'CAMERA')
def setup(self, context): def setup(self, context):
# Run an operator using the dial manipulator # Run an operator using the dial gizmo
ob = context.object ob = context.object
mpr = self.manipulators.new("MANIPULATOR_WT_dial_3d") mpr = self.gizmos.new("GIZMO_WT_dial_3d")
props = mpr.target_set_operator("transform.rotate") props = mpr.target_set_operator("transform.rotate")
props.constraint_axis = False, False, True props.constraint_axis = False, False, True
props.constraint_orientation = 'LOCAL' props.constraint_orientation = 'LOCAL'

View File

@@ -1,16 +1,16 @@
# Example of a group that edits a single property # Example of a group that edits a single property
# using the predefined manipulator arrow. # using the predefined gizmo arrow.
# #
# Usage: Select a light in the 3D view and drag the arrow at it's rear # Usage: Select a light in the 3D view and drag the arrow at it's rear
# to change it's energy value. # to change it's energy value.
# #
import bpy import bpy
from bpy.types import ( from bpy.types import (
ManipulatorGroup, GizmoGroup,
) )
class MyLightWidgetGroup(ManipulatorGroup): class MyLightWidgetGroup(GizmoGroup):
bl_idname = "OBJECT_WGT_light_test" bl_idname = "OBJECT_WGT_light_test"
bl_label = "Test Light Widget" bl_label = "Test Light Widget"
bl_space_type = 'VIEW_3D' bl_space_type = 'VIEW_3D'
@@ -23,9 +23,9 @@ class MyLightWidgetGroup(ManipulatorGroup):
return (ob and ob.type == 'LIGHT') return (ob and ob.type == 'LIGHT')
def setup(self, context): def setup(self, context):
# Arrow manipulator has one 'offset' property we can assign to the light energy. # Arrow gizmo has one 'offset' property we can assign to the light energy.
ob = context.object ob = context.object
mpr = self.manipulators.new("MANIPULATOR_WT_arrow_3d") mpr = self.gizmos.new("GIZMO_WT_arrow_3d")
mpr.target_set_prop("offset", ob.data, "energy") mpr.target_set_prop("offset", ob.data, "energy")
mpr.matrix_basis = ob.matrix_world.normalized() mpr.matrix_basis = ob.matrix_world.normalized()
mpr.draw_style = 'BOX' mpr.draw_style = 'BOX'