Update addons for changes to proportional edit mode
[blender-addons.git] / space_view3d_pie_menus / pie_views_numpad_menu.py
blob19e72bdd63a36350718bbe898ae2fb3a5f0d0c8b
1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
19 # <pep8 compliant>
21 bl_info = {
22 "name": "Hotkey: 'Q'",
23 "description": "Viewport Numpad Menus",
24 "author": "pitiwazou, meta-androcto",
25 "version": (0, 1, 1),
26 "blender": (2, 80, 0),
27 "location": "Q key",
28 "warning": "",
29 "wiki_url": "",
30 "category": "View Numpad Pie"
33 import bpy
34 from bpy.types import (
35 Menu,
36 Operator,
40 # Lock Camera Transforms
41 class LockTransforms(Operator):
42 bl_idname = "object.locktransforms"
43 bl_label = "Lock Object Transforms"
44 bl_description = ("Enable or disable the editing of objects transforms in the 3D View\n"
45 "Needs an existing Active Object")
46 bl_options = {'REGISTER', 'UNDO'}
48 @classmethod
49 def poll(cls, context):
50 return context.active_object is not None
52 def execute(self, context):
53 obj = context.active_object
54 if obj.lock_rotation[0] is False:
55 obj.lock_rotation[0] = True
56 obj.lock_rotation[1] = True
57 obj.lock_rotation[2] = True
58 obj.lock_scale[0] = True
59 obj.lock_scale[1] = True
60 obj.lock_scale[2] = True
62 elif context.object.lock_rotation[0] is True:
63 obj.lock_rotation[0] = False
64 obj.lock_rotation[1] = False
65 obj.lock_rotation[2] = False
66 obj.lock_scale[0] = False
67 obj.lock_scale[1] = False
68 obj.lock_scale[2] = False
70 return {'FINISHED'}
73 # Pie View All Sel Glob Etc - Q
74 class PieViewallSelGlobEtc(Menu):
75 bl_idname = "PIE_MT_vieallselglobetc"
76 bl_label = "Pie View All Sel Glob..."
78 def draw(self, context):
79 layout = self.layout
81 # 4 - LEFT
82 layout.operator("view3d.view_all", text="View All").center = True
83 # 6 - RIGHT
84 layout.operator("view3d.view_selected", text="View Selected")
85 # 2 - BOTTOM
86 layout.operator("view3d.view_persportho", text="Persp/Ortho", icon='RESTRICT_VIEW_OFF')
87 # 8 - TOP
88 layout.operator("view3d.localview", text="Local/Global")
89 # 7 - TOP - LEFT
90 layout.operator("screen.region_quadview", text="Toggle Quad View", icon='NONE')
91 # 1 - BOTTOM - LEFT
92 layout.operator("wm.call_menu_pie", text="Previous Menu", icon='BACK').name = "PIE_MT_viewnumpad"
93 # 9 - TOP - RIGHT
94 layout.operator("screen.screen_full_area", text="Full Screen", icon='FULLSCREEN_ENTER')
95 # 3 - BOTTOM - RIGHT
98 # Pie views numpad - Q
99 class PieViewNumpad(Menu):
100 bl_idname = "PIE_MT_viewnumpad"
101 bl_label = "Pie Views Ortho"
103 def draw(self, context):
104 layout = self.layout
105 ob = context.active_object
106 pie = layout.menu_pie()
107 scene = context.scene
108 rd = scene.render
110 # 4 - LEFT
111 pie.operator("view3d.view_axis", text="Left", icon='TRIA_LEFT').type = 'LEFT'
112 # 6 - RIGHT
113 pie.operator("view3d.view_axis", text="Right", icon='TRIA_RIGHT').type = 'RIGHT'
114 # 2 - BOTTOM
115 pie.operator("view3d.view_axis", text="Bottom", icon='TRIA_DOWN').type = 'BOTTOM'
116 # 8 - TOP
117 pie.operator("view3d.view_axis", text="Top", icon='TRIA_UP').type = 'TOP'
118 # 7 - TOP - LEFT
119 pie.operator("view3d.view_axis", text="Front").type = 'FRONT'
120 # 9 - TOP - RIGHT
121 pie.operator("view3d.view_axis", text="Back").type = 'BACK'
122 # 1 - BOTTOM - LEFT
123 box = pie.split().column()
124 row = box.row(align=True)
126 if context.space_data.lock_camera is False:
127 row.operator("wm.context_toggle", text="Lock Cam to View",
128 icon='UNLOCKED').data_path = "space_data.lock_camera"
129 elif context.space_data.lock_camera is True:
130 row.operator("wm.context_toggle", text="Lock Cam to View",
131 icon='LOCKED').data_path = "space_data.lock_camera"
133 row = box.row(align=True)
134 row.operator("view3d.view_camera", text="View Cam", icon='VISIBLE_IPO_ON')
135 row.operator("view3d.camera_to_view", text="Cam to view", icon='NONE')
137 icon_locked = 'LOCKED' if ob and ob.lock_rotation[0] is False else \
138 'UNLOCKED' if ob and ob.lock_rotation[0] is True else 'LOCKED'
140 row = box.row(align=True)
141 row.operator("object.locktransforms", text="Lock Transforms", icon=icon_locked)
143 row = box.row(align=True)
144 row.prop(rd, "use_border", text="Border")
145 # 3 - BOTTOM - RIGHT
146 pie.menu(PieViewallSelGlobEtc.bl_idname, text="View Menu", icon='NONE')
149 classes = (
150 PieViewNumpad,
151 LockTransforms,
152 PieViewallSelGlobEtc,
155 addon_keymaps = []
158 def register():
159 for cls in classes:
160 bpy.utils.register_class(cls)
162 wm = bpy.context.window_manager
163 if wm.keyconfigs.addon:
164 # Views numpad
165 km = wm.keyconfigs.addon.keymaps.new(name='3D View Generic', space_type='VIEW_3D')
166 kmi = km.keymap_items.new('wm.call_menu_pie', 'Q', 'PRESS')
167 kmi.properties.name = "PIE_MT_viewnumpad"
168 addon_keymaps.append((km, kmi))
171 def unregister():
172 for cls in classes:
173 bpy.utils.unregister_class(cls)
175 wm = bpy.context.window_manager
176 kc = wm.keyconfigs.addon
177 if kc:
178 for km, kmi in addon_keymaps:
179 km.keymap_items.remove(kmi)
180 addon_keymaps.clear()
183 if __name__ == "__main__":
184 register()