diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-12-22 19:11:11 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-12-22 19:11:11 +0300 |
commit | 22a892f4024db7da71ccdced00bf494c28443510 (patch) | |
tree | 591505ea18810778727110f1ef04b0b858e12c08 /release | |
parent | 68bc4d7355d8a13d6565d976180970af5c2d20e3 (diff) |
- make ToolSettings.mesh_selection_mode into an array of 3 bools rather then an enum since multiple can be set at once.
- ToolSettings had its id.data set to NULL when taken directly from the context (causing a crash in cases)
- menu for changing vert/edge/face selection now a python menu, removed operator.
- wm.context_set_value(), would really prefer not to have this since it evaluates the value as a python expression however there are no ways to define arrays in PyOperators
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/op/mesh_skin.py | 11 | ||||
-rw-r--r-- | release/scripts/op/wm.py | 38 | ||||
-rw-r--r-- | release/scripts/ui/space_view3d.py | 23 |
3 files changed, 62 insertions, 10 deletions
diff --git a/release/scripts/op/mesh_skin.py b/release/scripts/op/mesh_skin.py index 436cd21c9ee..a78da39c5d4 100644 --- a/release/scripts/op/mesh_skin.py +++ b/release/scripts/op/mesh_skin.py @@ -249,17 +249,16 @@ def mesh_faces_extend(me, faces, mat_idx = 0): def getSelectedEdges(context, me, ob): - MESH_MODE= context.scene.tool_settings.mesh_selection_mode + MESH_MODE = tuple(context.tool_settings.mesh_selection_mode) + context.tool_settings.mesh_selection_mode = False, True, False - if MESH_MODE in ('EDGE', 'VERTEX'): - context.scene.tool_settings.mesh_selection_mode = 'EDGE' + if not MESH_MODE[2]: edges= [ ed for ed in me.edges if ed.selected ] # print len(edges), len(me.edges) context.scene.tool_settings.mesh_selection_mode = MESH_MODE return edges - if MESH_MODE == 'FACE': - context.scene.tool_settings.mesh_selection_mode = 'EDGE' + else: # value is [edge, face_sel_user_in] edge_dict= dict((ed.key, [ed, 0]) for ed in me.edges) @@ -268,7 +267,7 @@ def getSelectedEdges(context, me, ob): for edkey in f.edge_keys: edge_dict[edkey][1] += 1 - context.scene.tool_settings.mesh_selection_mode = MESH_MODE + context.tool_settings.mesh_selection_mode = MESH_MODE return [ ed_data[0] for ed_data in edge_dict.values() if ed_data[1] == 1 ] diff --git a/release/scripts/op/wm.py b/release/scripts/op/wm.py index 5069d206a3f..45a9e91d2c6 100644 --- a/release/scripts/op/wm.py +++ b/release/scripts/op/wm.py @@ -68,7 +68,8 @@ def execute_context_assign(self, context): class WM_OT_context_set_boolean(bpy.types.Operator): '''Set a context value.''' bl_idname = "wm.context_set_boolean" - bl_label = "Context Set" + bl_label = "Context Set Boolean" + bl_undo = True path = rna_path_prop value = BoolProperty(name="Value", @@ -81,6 +82,7 @@ class WM_OT_context_set_int(bpy.types.Operator): # same as enum '''Set a context value.''' bl_idname = "wm.context_set_int" bl_label = "Context Set" + bl_undo = True path = rna_path_prop value = IntProperty(name="Value", description="Assign value", default=0) @@ -91,7 +93,8 @@ class WM_OT_context_set_int(bpy.types.Operator): # same as enum class WM_OT_context_set_float(bpy.types.Operator): # same as enum '''Set a context value.''' bl_idname = "wm.context_set_float" - bl_label = "Context Set" + bl_label = "Context Set Float" + bl_undo = True path = rna_path_prop value = FloatProperty(name="Value", @@ -103,7 +106,8 @@ class WM_OT_context_set_float(bpy.types.Operator): # same as enum class WM_OT_context_set_string(bpy.types.Operator): # same as enum '''Set a context value.''' bl_idname = "wm.context_set_string" - bl_label = "Context Set" + bl_label = "Context Set String" + bl_undo = True path = rna_path_prop value = StringProperty(name="Value", @@ -115,7 +119,8 @@ class WM_OT_context_set_string(bpy.types.Operator): # same as enum class WM_OT_context_set_enum(bpy.types.Operator): '''Set a context value.''' bl_idname = "wm.context_set_enum" - bl_label = "Context Set" + bl_label = "Context Set Enum" + bl_undo = True path = rna_path_prop value = StringProperty(name="Value", @@ -125,10 +130,30 @@ class WM_OT_context_set_enum(bpy.types.Operator): execute = execute_context_assign +class WM_OT_context_set_value(bpy.types.Operator): + '''Set a context value.''' + bl_idname = "wm.context_set_value" + bl_label = "Context Set Value" + bl_undo = True + + path = rna_path_prop + value = StringProperty(name="Value", + description="Assignment value (as a string)", + maxlen=1024, default="") + + def execute(self, context): + if context_path_validate(context, self.properties.path) is Ellipsis: + return ('PASS_THROUGH',) + exec("context.%s=%s" % (self.properties.path, self.properties.value)) + return ('FINISHED',) + + class WM_OT_context_toggle(bpy.types.Operator): '''Toggle a context value.''' bl_idname = "wm.context_toggle" bl_label = "Context Toggle" + bl_undo = True + path = rna_path_prop def execute(self, context): @@ -146,6 +171,7 @@ class WM_OT_context_toggle_enum(bpy.types.Operator): '''Toggle a context value.''' bl_idname = "wm.context_toggle_enum" bl_label = "Context Toggle Values" + bl_undo = True path = rna_path_prop value_1 = StringProperty(name="Value", \ @@ -172,6 +198,8 @@ class WM_OT_context_cycle_int(bpy.types.Operator): vertex keys, groups' etc.''' bl_idname = "wm.context_cycle_int" bl_label = "Context Int Cycle" + bl_undo = True + path = rna_path_prop reverse = rna_reverse_prop @@ -203,6 +231,7 @@ class WM_OT_context_cycle_enum(bpy.types.Operator): '''Toggle a context value.''' bl_idname = "wm.context_cycle_enum" bl_label = "Context Enum Cycle" + bl_undo = True path = rna_path_prop reverse = rna_reverse_prop @@ -384,6 +413,7 @@ bpy.ops.add(WM_OT_context_set_int) bpy.ops.add(WM_OT_context_set_float) bpy.ops.add(WM_OT_context_set_string) bpy.ops.add(WM_OT_context_set_enum) +bpy.ops.add(WM_OT_context_set_value) bpy.ops.add(WM_OT_context_toggle) bpy.ops.add(WM_OT_context_toggle_enum) bpy.ops.add(WM_OT_context_cycle_enum) diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index fa0a6a8c5fa..2ec0e44e184 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -1121,6 +1121,28 @@ class VIEW3D_MT_edit_mesh_specials(bpy.types.Menu): layout.operator("mesh.select_vertex_path") +class VIEW3D_MT_edit_mesh_selection_mode(bpy.types.Menu): + bl_label = "Mesh Select Mode" + + def draw(self, context): + layout = self.layout + + layout.operator_context = 'INVOKE_REGION_WIN' + path = "tool_settings.edit_select_vertex;tool_settings.edit_select_edge;tool_settings.edit_select_face" + + prop = layout.operator("wm.context_set_value", text="Vertex") + prop.value = "(True, False, False)" + prop.path = "tool_settings.mesh_selection_mode" + + prop = layout.operator("wm.context_set_value", text="Edge") + prop.value = "(False, True, False)" + prop.path = "tool_settings.mesh_selection_mode" + + prop = layout.operator("wm.context_set_value", text="Face") + prop.value = "(False, False, True)" + prop.path = "tool_settings.mesh_selection_mode" + + class VIEW3D_MT_edit_mesh_vertices(bpy.types.Menu): bl_label = "Vertices" @@ -1915,6 +1937,7 @@ bpy.types.register(VIEW3D_MT_pose_showhide) bpy.types.register(VIEW3D_MT_edit_mesh) bpy.types.register(VIEW3D_MT_edit_mesh_specials) # Only as a menu for keybindings +bpy.types.register(VIEW3D_MT_edit_mesh_selection_mode) # Only as a menu for keybindings bpy.types.register(VIEW3D_MT_edit_mesh_vertices) bpy.types.register(VIEW3D_MT_edit_mesh_edges) bpy.types.register(VIEW3D_MT_edit_mesh_faces) |