forked from bartvdbraak/blender
WM: rename manipulator to gizmo in Python API
This commit is contained in:
parent
5ebebcfbff
commit
89299f6620
@ -556,7 +556,7 @@ class RNAMetaPropGroup(StructMetaPropGroup, RNAMeta):
|
||||
|
||||
# Same as 'Operator'
|
||||
# only without 'as_keywords'
|
||||
class Manipulator(StructRNA):
|
||||
class Gizmo(StructRNA):
|
||||
__slots__ = ()
|
||||
|
||||
def __getattribute__(self, attr):
|
||||
@ -590,15 +590,15 @@ class Manipulator(StructRNA):
|
||||
# Convenience wrappers around private `_gawain` module.
|
||||
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.
|
||||
:type shape: Undefined.
|
||||
: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`
|
||||
: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
|
||||
"""
|
||||
import gpu
|
||||
@ -627,7 +627,7 @@ class Manipulator(StructRNA):
|
||||
@staticmethod
|
||||
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).
|
||||
:type type: string
|
||||
|
@ -5,8 +5,8 @@
|
||||
#
|
||||
import bpy
|
||||
from bpy.types import (
|
||||
Manipulator,
|
||||
ManipulatorGroup,
|
||||
Gizmo,
|
||||
GizmoGroup,
|
||||
)
|
||||
|
||||
# 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_target_properties = (
|
||||
{"id": "offset", "type": 'FLOAT', "array_length": 1},
|
||||
@ -108,11 +108,11 @@ class MyCustomShapeWidget(Manipulator):
|
||||
delta /= 10.0
|
||||
value = self.init_value + delta
|
||||
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'}
|
||||
|
||||
|
||||
class MyCustomShapeWidgetGroup(ManipulatorGroup):
|
||||
class MyCustomShapeWidgetGroup(GizmoGroup):
|
||||
bl_idname = "OBJECT_WGT_light_test"
|
||||
bl_label = "Test Light Widget"
|
||||
bl_space_type = 'VIEW_3D'
|
||||
@ -127,7 +127,7 @@ class MyCustomShapeWidgetGroup(ManipulatorGroup):
|
||||
def setup(self, context):
|
||||
# Assign the 'offset' target property to the light energy.
|
||||
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.matrix_basis = ob.matrix_world.normalized()
|
||||
|
||||
|
@ -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
|
||||
# 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 bmesh
|
||||
|
||||
from bpy.types import (
|
||||
Operator,
|
||||
ManipulatorGroup,
|
||||
GizmoGroup,
|
||||
)
|
||||
|
||||
from bpy.props import (
|
||||
@ -68,7 +68,7 @@ class SelectSideOfPlane(Operator):
|
||||
|
||||
if context.space_data.type == 'VIEW_3D':
|
||||
wm = context.window_manager
|
||||
wm.manipulator_group_type_add(SelectSideOfPlaneManipulatorGroup.bl_idname)
|
||||
wm.gizmo_group_type_add(SelectSideOfPlaneGizmoGroup.bl_idname)
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
@ -78,10 +78,10 @@ class SelectSideOfPlane(Operator):
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
# Manipulators for plane_co, plane_no
|
||||
class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
|
||||
# Gizmos for plane_co, plane_no
|
||||
class SelectSideOfPlaneGizmoGroup(GizmoGroup):
|
||||
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_region_type = 'WINDOW'
|
||||
bl_options = {'3D'}
|
||||
@ -106,7 +106,7 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
|
||||
op = cls.my_target_operator(context)
|
||||
if op is None:
|
||||
wm = context.window_manager
|
||||
wm.manipulator_group_type_remove(SelectSideOfPlaneManipulatorGroup.bl_idname)
|
||||
wm.gizmo_group_type_remove(SelectSideOfPlaneGizmoGroup.bl_idname)
|
||||
return False
|
||||
return True
|
||||
|
||||
@ -117,16 +117,16 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
|
||||
# Grab
|
||||
|
||||
def grab_get_cb():
|
||||
op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context)
|
||||
op = SelectSideOfPlaneGizmoGroup.my_target_operator(context)
|
||||
return op.plane_co
|
||||
|
||||
def grab_set_cb(value):
|
||||
op = SelectSideOfPlaneManipulatorGroup.my_target_operator(context)
|
||||
op = SelectSideOfPlaneGizmoGroup.my_target_operator(context)
|
||||
op.plane_co = value
|
||||
# XXX, this may change!
|
||||
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.use_draw_value = True
|
||||
@ -145,7 +145,7 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
|
||||
# Dial
|
||||
|
||||
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_b = Vector(op.plane_no)
|
||||
@ -155,13 +155,13 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
|
||||
return no_a.angle_signed(no_b)
|
||||
|
||||
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)
|
||||
no = matrix_rotate * self.widget_dial.matrix_basis.col[1].xyz
|
||||
op.plane_no = no
|
||||
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.draw_options = {'ANGLE_START_Y'}
|
||||
|
||||
@ -216,7 +216,7 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
|
||||
|
||||
classes = (
|
||||
SelectSideOfPlane,
|
||||
SelectSideOfPlaneManipulatorGroup,
|
||||
SelectSideOfPlaneGizmoGroup,
|
||||
)
|
||||
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
# Example of a manipulator that activates an operator
|
||||
# using the predefined dial manipulator to change the camera roll.
|
||||
# Example of a gizmo that activates an operator
|
||||
# using the predefined dial gizmo to change the camera roll.
|
||||
#
|
||||
# Usage: Run this script and select a camera in the 3D view.
|
||||
#
|
||||
import bpy
|
||||
from bpy.types import (
|
||||
ManipulatorGroup,
|
||||
GizmoGroup,
|
||||
)
|
||||
|
||||
|
||||
class MyCameraWidgetGroup(ManipulatorGroup):
|
||||
class MyCameraWidgetGroup(GizmoGroup):
|
||||
bl_idname = "OBJECT_WGT_test_camera"
|
||||
bl_label = "Object Camera Test Widget"
|
||||
bl_space_type = 'VIEW_3D'
|
||||
@ -22,9 +22,9 @@ class MyCameraWidgetGroup(ManipulatorGroup):
|
||||
return (ob and ob.type == 'CAMERA')
|
||||
|
||||
def setup(self, context):
|
||||
# Run an operator using the dial manipulator
|
||||
# Run an operator using the dial gizmo
|
||||
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.constraint_axis = False, False, True
|
||||
props.constraint_orientation = 'LOCAL'
|
||||
|
@ -1,16 +1,16 @@
|
||||
# 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
|
||||
# to change it's energy value.
|
||||
#
|
||||
import bpy
|
||||
from bpy.types import (
|
||||
ManipulatorGroup,
|
||||
GizmoGroup,
|
||||
)
|
||||
|
||||
|
||||
class MyLightWidgetGroup(ManipulatorGroup):
|
||||
class MyLightWidgetGroup(GizmoGroup):
|
||||
bl_idname = "OBJECT_WGT_light_test"
|
||||
bl_label = "Test Light Widget"
|
||||
bl_space_type = 'VIEW_3D'
|
||||
@ -23,9 +23,9 @@ class MyLightWidgetGroup(ManipulatorGroup):
|
||||
return (ob and ob.type == 'LIGHT')
|
||||
|
||||
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
|
||||
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.matrix_basis = ob.matrix_world.normalized()
|
||||
mpr.draw_style = 'BOX'
|
||||
|
Loading…
Reference in New Issue
Block a user