Welcome to mirror list, hosted at ThFree Co, Russian Federation.

pie_manipulator_of.py « pie_menus_official - git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ef25d369b5a54dfb32d37948e5b4df1a37ef8e45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

bl_info = {
    "name": "Manipulator Menu: Key: 'Ctrl Space'",
    "description": "Manipulator Modes",
    "author": "Antony Riakiotakis, Sebastian Koenig",
    "version": (0, 1, 1),
    "blender": (2, 77, 0),
    "location": "Ctrl Space",
    "warning": "",
    "wiki_url": "",
    "category": "3d View"
}

import bpy
from bpy.types import (
        Menu,
        Operator,
        )
from bpy.props import (
        EnumProperty,
        )


# Pie Manipulator Mode - Ctrl Space
class VIEW3D_manipulator_set_of(Operator):
    bl_label = "Set Manipulator"
    bl_idname = "view3d.manipulator_set"

    type = EnumProperty(
            name="Type",
            items=(('TRANSLATE', "Translate", "Use the manipulator for movement transformations"),
                   ('ROTATE', "Rotate", "Use the manipulator for rotation transformations"),
                   ('SCALE', "Scale", "Use the manipulator for scale transformations"),
                   ),
            )

    def execute(self, context):
        # show manipulator if user selects an option
        context.space_data.show_manipulator = True
        context.space_data.transform_manipulators = {self.type}

        return {'FINISHED'}


class VIEW3D_PIE_manipulator_of(Menu):
    bl_label = "Manipulator"
    bl_idname = "view3d.manipulator_of"

    def draw(self, context):
        layout = self.layout

        pie = layout.menu_pie()
        pie.operator("wm.tool_set_by_name", icon='MAN_TRANS', text="Translate").name = "Move"
        pie.operator("wm.tool_set_by_name", icon='MAN_ROT', text="Rotate").name = "Rotate"
        pie.operator("wm.tool_set_by_name", icon='MAN_SCALE', text="Scale").name = "Scale"
        pie.prop(context.space_data, "show_manipulator")


classes = (
    VIEW3D_manipulator_set_of,
    VIEW3D_PIE_manipulator_of,
    )

addon_keymaps = []


def register():
    for cls in classes:
        bpy.utils.register_class(cls)
    wm = bpy.context.window_manager

    if wm.keyconfigs.addon:
        # Align
        km = wm.keyconfigs.addon.keymaps.new(name='Object Non-modal')
        kmi = km.keymap_items.new('wm.call_menu_pie', 'SPACE', 'PRESS', ctrl=True)
        kmi.properties.name = "view3d.manipulator_of"
        addon_keymaps.append((km, kmi))


def unregister():
    for cls in classes:
        bpy.utils.unregister_class(cls)

    wm = bpy.context.window_manager
    kc = wm.keyconfigs.addon
    if kc:
        for km, kmi in addon_keymaps:
            km.keymap_items.remove(kmi)
    addon_keymaps.clear()


if __name__ == "__main__":
    register()