From 4aa3f51bbae93a7a2c410730401e0764ba9dba88 Mon Sep 17 00:00:00 2001 From: meta-androcto Date: Sat, 1 Jun 2019 13:42:17 +1000 Subject: space_view3d_pie_menus: fix edit selection modes --- space_view3d_pie_menus/pie_modes_menu.py | 133 ++++++++++++++++-------------- space_view3d_pie_menus/pie_select_menu.py | 98 +++++++++++++++++----- 2 files changed, 149 insertions(+), 82 deletions(-) (limited to 'space_view3d_pie_menus') diff --git a/space_view3d_pie_menus/pie_modes_menu.py b/space_view3d_pie_menus/pie_modes_menu.py index 566c3cc3..e32a160a 100644 --- a/space_view3d_pie_menus/pie_modes_menu.py +++ b/space_view3d_pie_menus/pie_modes_menu.py @@ -51,51 +51,6 @@ class PIE_OT_ClassObject(Operator): return {'FINISHED'} -class PIE_OT_ClassVertex(Operator): - bl_idname = "class.vertex" - bl_label = "Class Vertex" - bl_description = "Vert Select" - bl_options = {'REGISTER', 'UNDO'} - - def execute(self, context): - if context.object.mode != "EDIT": - bpy.ops.object.mode_set(mode="EDIT") - bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT') - if bpy.ops.mesh.select_mode != "EDGE, FACE": - bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT') - return {'FINISHED'} - - -class PIE_OT_ClassEdge(Operator): - bl_idname = "class.edge" - bl_label = "Class Edge" - bl_description = "Edge Select" - bl_options = {'REGISTER', 'UNDO'} - - def execute(self, context): - if context.object.mode != "EDIT": - bpy.ops.object.mode_set(mode="EDIT") - bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE') - if bpy.ops.mesh.select_mode != "VERT, FACE": - bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE') - return {'FINISHED'} - - -class PIE_OT_ClassFace(Operator): - bl_idname = "class.face" - bl_label = "Class Face" - bl_description = "Face Select" - bl_options = {'REGISTER', 'UNDO'} - - def execute(self, context): - if context.object.mode != "EDIT": - bpy.ops.object.mode_set(mode="EDIT") - bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE') - if bpy.ops.mesh.select_mode != "VERT, EDGE": - bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE') - return {'FINISHED'} - - class PIE_OT_ClassTexturePaint(Operator): bl_idname = "class.pietexturepaint" bl_label = "Class Texture Paint" @@ -177,64 +132,118 @@ class PIE_OT_SetObjectModePie(Operator): return {'FINISHED'} -# Components Selection Mode +# Edit Selection Modes +class PIE_OT_ClassVertex(Operator): + bl_idname = "class.vertex" + bl_label = "Class Vertex" + bl_description = "Vert Select Mode" + bl_options = {'REGISTER', 'UNDO'} + + def execute(self, context): + if context.object.mode != "EDIT": + bpy.ops.object.mode_set(mode="EDIT") + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT') + if bpy.ops.mesh.select_mode != "EDGE, FACE": + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT') + return {'FINISHED'} + + +class PIE_OT_ClassEdge(Operator): + bl_idname = "class.edge" + bl_label = "Class Edge" + bl_description = "Edge Select Mode" + bl_options = {'REGISTER', 'UNDO'} + + def execute(self, context): + if context.object.mode != "EDIT": + bpy.ops.object.mode_set(mode="EDIT") + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE') + if bpy.ops.mesh.select_mode != "VERT, FACE": + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE') + return {'FINISHED'} + + +class PIE_OT_ClassFace(Operator): + bl_idname = "class.face" + bl_label = "Class Face" + bl_description = "Face Select Mode" + bl_options = {'REGISTER', 'UNDO'} + + def execute(self, context): + if context.object.mode != "EDIT": + bpy.ops.object.mode_set(mode="EDIT") + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE') + if bpy.ops.mesh.select_mode != "VERT, EDGE": + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE') + return {'FINISHED'} + + class PIE_OT_VertsEdges(Operator): bl_idname = "verts.edges" bl_label = "Verts Edges" - bl_description = "Vert/Edge Select" + bl_description = "Vert/Edge Select Mode" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): if context.object.mode != "EDIT": bpy.ops.object.mode_set(mode="EDIT") - context.tool_settings.mesh_select_mode = (True, True, False) - if context.object.mode == "EDIT": - context.tool_settings.mesh_select_mode = (True, True, False) + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT') + if bpy.ops.mesh.select_mode != "VERT, EDGE, FACE": + bpy.ops.object.mode_set(mode="EDIT") + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT') + bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='EDGE') return {'FINISHED'} class PIE_OT_EdgesFaces(Operator): bl_idname = "edges.faces" bl_label = "EdgesFaces" - bl_description = "Edge/Face Select" + bl_description = "Edge/Face Select Mode" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): if context.object.mode != "EDIT": bpy.ops.object.mode_set(mode="EDIT") - context.tool_settings.mesh_select_mode = (False, True, True) - if context.object.mode == "EDIT": - context.tool_settings.mesh_select_mode = (False, True, True) + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE') + if bpy.ops.mesh.select_mode != "VERT, EDGE, FACE": + bpy.ops.object.mode_set(mode="EDIT") + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE') + bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='FACE') return {'FINISHED'} class PIE_OT_VertsFaces(Operator): bl_idname = "verts.faces" bl_label = "Verts Faces" - bl_description = "Vert/Face Select" + bl_description = "Vert/Face Select Mode" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): if context.object.mode != "EDIT": bpy.ops.object.mode_set(mode="EDIT") - context.tool_settings.mesh_select_mode = (True, False, True) - if context.object.mode == "EDIT": - context.tool_settings.mesh_select_mode = (True, False, True) + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT') + if bpy.ops.mesh.select_mode != "VERT, EDGE, FACE": + bpy.ops.object.mode_set(mode="EDIT") + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT') + bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='FACE') return {'FINISHED'} class PIE_OT_VertsEdgesFaces(Operator): bl_idname = "verts.edgesfaces" bl_label = "Verts Edges Faces" - bl_description = "Vert/Edge/Face Select" + bl_description = "Vert/Edge/Face Select Mode" bl_options = {'REGISTER', 'UNDO'} def execute(self, context): if context.object.mode != "EDIT": bpy.ops.object.mode_set(mode="EDIT") - context.tool_settings.mesh_select_mode = (True, True, True) - if context.object.mode == "EDIT": - context.tool_settings.mesh_select_mode = (True, True, True) + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT') + if bpy.ops.mesh.select_mode != "VERT, EDGE, FACE": + bpy.ops.object.mode_set(mode="EDIT") + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT') + bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='EDGE') + bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='FACE') return {'FINISHED'} diff --git a/space_view3d_pie_menus/pie_select_menu.py b/space_view3d_pie_menus/pie_select_menu.py index 4f5f8c0b..48819c13 100644 --- a/space_view3d_pie_menus/pie_select_menu.py +++ b/space_view3d_pie_menus/pie_select_menu.py @@ -31,7 +31,11 @@ bl_info = { } import bpy -from bpy.types import Menu +from bpy.types import ( + Menu, + Operator +) + # Pie Selection Object Mode - A @@ -106,7 +110,7 @@ class PIE_MT_SelectionsEM(Menu): pie.operator("view3d.select_circle", text="Circle Select", icon='NONE') # 3 - BOTTOM - RIGHT - pie.menu("PIE_MT_selectallbyselection", text="Multi Select Menu", icon='SNAP_EDGE') + pie.menu("PIE_MT_selectallbyselection", text="Edit Modes", icon='VERTEXSEL') # Select All By Selection @@ -117,28 +121,78 @@ class PIE_MT_SelectAllBySelection(Menu): def draw(self, context): layout = self.layout - layout.operator_context = 'INVOKE_REGION_WIN' + pie = layout.menu_pie() + box = pie.split().column() + + box.operator("class.vertexop", text="Vertex", icon='VERTEXSEL') + box.operator("class.edgeop", text="Edge", icon='EDGESEL') + box.operator("class.faceop", text="Face", icon='FACESEL') + box.operator("verts.edgesfacesop", text="Vertex/Edges/Faces", icon='OBJECT_DATAMODE') + + +# Edit Selection Modes +class PIE_OT_classvertexop(Operator): + bl_idname = "class.vertexop" + bl_label = "Class Vertex" + bl_description = "Vert Select Mode" + bl_options = {'REGISTER', 'UNDO'} + + def execute(self, context): + if context.object.mode != "EDIT": + bpy.ops.object.mode_set(mode="EDIT") + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT') + if bpy.ops.mesh.select_mode != "EDGE, FACE": + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT') + return {'FINISHED'} - prop = layout.operator("wm.context_set_value", text="Vertex Select", - icon='VERTEXSEL') - prop.value = "(True, False, False)" - prop.data_path = "tool_settings.mesh_select_mode" - prop = layout.operator("wm.context_set_value", text="Edge Select", - icon='EDGESEL') - prop.value = "(False, True, False)" - prop.data_path = "tool_settings.mesh_select_mode" +class PIE_OT_classedgeop(Operator): + bl_idname = "class.edgeop" + bl_label = "Class Edge" + bl_description = "Edge Select Mode" + bl_options = {'REGISTER', 'UNDO'} + + def execute(self, context): + if context.object.mode != "EDIT": + bpy.ops.object.mode_set(mode="EDIT") + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE') + if bpy.ops.mesh.select_mode != "VERT, FACE": + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE') + return {'FINISHED'} + + +class PIE_OT_classfaceop(Operator): + bl_idname = "class.faceop" + bl_label = "Class Face" + bl_description = "Face Select Mode" + bl_options = {'REGISTER', 'UNDO'} - prop = layout.operator("wm.context_set_value", text="Face Select", - icon='FACESEL') - prop.value = "(False, False, True)" - prop.data_path = "tool_settings.mesh_select_mode" + def execute(self, context): + if context.object.mode != "EDIT": + bpy.ops.object.mode_set(mode="EDIT") + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE') + if bpy.ops.mesh.select_mode != "VERT, EDGE": + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE') + return {'FINISHED'} + + +# Combined Selection Mode +class PIE_OT_vertsedgesfacesop(Operator): + bl_idname = "verts.edgesfacesop" + bl_label = "Verts Edges Faces" + bl_description = "Vert/Edge/Face Select Mode" + bl_options = {'REGISTER', 'UNDO'} - prop = layout.operator("wm.context_set_value", - text="Vertex & Edge & Face Select", - icon='SNAP_VOLUME') - prop.value = "(True, True, True)" - prop.data_path = "tool_settings.mesh_select_mode" + def execute(self, context): + if context.object.mode != "EDIT": + bpy.ops.object.mode_set(mode="EDIT") + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT') + if bpy.ops.mesh.select_mode != "VERT, EDGE, FACE": + bpy.ops.object.mode_set(mode="EDIT") + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT') + bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='EDGE') + bpy.ops.mesh.select_mode(use_extend=True, use_expand=False, type='FACE') + return {'FINISHED'} class PIE_MT_SelectLoopSelection(Menu): @@ -161,6 +215,10 @@ classes = ( PIE_MT_SelectAllBySelection, PIE_MT_SelectionsMore, PIE_MT_SelectLoopSelection, + PIE_OT_classvertexop, + PIE_OT_classedgeop, + PIE_OT_classfaceop, + PIE_OT_vertsedgesfacesop ) addon_keymaps = [] -- cgit v1.2.3