diff options
Diffstat (limited to 'uv_magic_uv/legacy/op/select_uv.py')
-rw-r--r-- | uv_magic_uv/legacy/op/select_uv.py | 100 |
1 files changed, 12 insertions, 88 deletions
diff --git a/uv_magic_uv/legacy/op/select_uv.py b/uv_magic_uv/legacy/op/select_uv.py index bdc182d5..c4a7639d 100644 --- a/uv_magic_uv/legacy/op/select_uv.py +++ b/uv_magic_uv/legacy/op/select_uv.py @@ -24,46 +24,15 @@ __version__ = "5.2" __date__ = "17 Nov 2018" import bpy -import bmesh from bpy.props import BoolProperty -from ... import common from ...utils.bl_class_registry import BlClassRegistry from ...utils.property_class_registry import PropertyClassRegistry - - -__all__ = [ - 'Properties', - 'MUV_OT_SelectUV_SelectFlipped', - 'MUV_OT_SelectUV_SelectOverlapped', -] - - -def is_valid_context(context): - obj = context.object - - # only edit mode is allowed to execute - if obj is None: - return False - if obj.type != 'MESH': - return False - if context.object.mode != 'EDIT': - return False - - # 'IMAGE_EDITOR' and 'VIEW_3D' space is allowed to execute. - # If 'View_3D' space is not allowed, you can't find option in Tool-Shelf - # after the execution - for space in context.area.spaces: - if (space.type == 'IMAGE_EDITOR') or (space.type == 'VIEW_3D'): - break - else: - return False - - return True +from ...impl import select_uv_impl as impl @PropertyClassRegistry(legacy=True) -class Properties: +class _Properties: idname = "select_uv" @classmethod @@ -90,38 +59,15 @@ class MUV_OT_SelectUV_SelectOverlapped(bpy.types.Operator): bl_description = "Select faces which have overlapped UVs" bl_options = {'REGISTER', 'UNDO'} + def __init__(self): + self.__impl = impl.SelectOverlappedImpl() + @classmethod def poll(cls, context): - # we can not get area/space/region from console - if common.is_console_mode(): - return True - return is_valid_context(context) + return impl.SelectOverlappedImpl.poll(context) def execute(self, context): - obj = context.active_object - bm = bmesh.from_edit_mesh(obj.data) - if common.check_version(2, 73, 0) >= 0: - bm.faces.ensure_lookup_table() - uv_layer = bm.loops.layers.uv.verify() - - if context.tool_settings.use_uv_select_sync: - sel_faces = [f for f in bm.faces] - else: - sel_faces = [f for f in bm.faces if f.select] - - overlapped_info = common.get_overlapped_uv_info(bm, sel_faces, - uv_layer, 'FACE') - - for info in overlapped_info: - if context.tool_settings.use_uv_select_sync: - info["subject_face"].select = True - else: - for l in info["subject_face"].loops: - l[uv_layer].select = True - - bmesh.update_edit_mesh(obj.data) - - return {'FINISHED'} + return self.__impl.execute(self, context) @BlClassRegistry(legacy=True) @@ -135,34 +81,12 @@ class MUV_OT_SelectUV_SelectFlipped(bpy.types.Operator): bl_description = "Select faces which have flipped UVs" bl_options = {'REGISTER', 'UNDO'} + def __init__(self): + self.__impl = impl.SelectFlippedImpl() + @classmethod def poll(cls, context): - # we can not get area/space/region from console - if common.is_console_mode(): - return True - return is_valid_context(context) + return impl.SelectFlippedImpl.poll(context) def execute(self, context): - obj = context.active_object - bm = bmesh.from_edit_mesh(obj.data) - if common.check_version(2, 73, 0) >= 0: - bm.faces.ensure_lookup_table() - uv_layer = bm.loops.layers.uv.verify() - - if context.tool_settings.use_uv_select_sync: - sel_faces = [f for f in bm.faces] - else: - sel_faces = [f for f in bm.faces if f.select] - - flipped_info = common.get_flipped_uv_info(sel_faces, uv_layer) - - for info in flipped_info: - if context.tool_settings.use_uv_select_sync: - info["face"].select = True - else: - for l in info["face"].loops: - l[uv_layer].select = True - - bmesh.update_edit_mesh(obj.data) - - return {'FINISHED'} + return self.__impl.execute(self, context) |