Skip to content

Commit

Permalink
feat: add toggleable exclusive view (x-ray option) option to geo_lift…
Browse files Browse the repository at this point in the history
…, panel, and view_align operators
  • Loading branch information
tristan-hm committed Jul 15, 2022
1 parent 3d8a16e commit 9fc75c1
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def create_duplicate_liftable_geometry(context, mode, object_name, ignore_comple
object_eval = context.active_object.evaluated_get(depsgraph)

context.active_object.modifiers.clear()
context.active_object.show_in_front = True

vertex_groups = context.active_object.vertex_groups.values()
for vg in vertex_groups:
Expand Down
19 changes: 19 additions & 0 deletions sketch/geo_lift.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ def modal(self, context, event):
self.selection_type = (self.selection_type + 1) % 3
self.set_selection_mode(context)

elif pressed(event, {'E'}):
self.xray_mode = not self.xray_mode
self.dirty = True

elif self.key_one:
self.selection_type = 0
self.set_selection_mode(context)
Expand All @@ -78,13 +82,18 @@ def modal(self, context, event):
elif self.key_movement_passthrough:
return {'PASS_THROUGH'}

if self.dirty:
self.operate(context)

update_overlay(self, context, event)

return {'RUNNING_MODAL'}


def invoke(self, context, event):
self.dirty = False
self.selection_type = 2 # ['VERT', 'EDGE', 'FACE']
self.xray_mode = False
self.register_mode()

self.target_obj = context.active_object
Expand Down Expand Up @@ -141,6 +150,11 @@ def has_invalid_selection(self, context):
return False


def operate(self, context):
context.active_object.show_in_front = self.xray_mode
self.dirty = False


def finish(self, context):
if self.has_invalid_selection(context):
self.clean_up(context)
Expand Down Expand Up @@ -179,6 +193,11 @@ def draw_text_callback(self):
"Selection Type [S,1,2,3]: {0}".format(['Vertex', 'Edge', 'Face'][self.selection_type]),
"Type of geometry to select (Vertex, Edge, Face)")

draw_hint(
self,
"Exclusive View [E]: {0}".format("On" if self.xray_mode else "Off"),
"Show the target object in front of all other objects")


def register():
bpy.utils.register_class(ND_OT_geo_lift)
Expand Down
12 changes: 12 additions & 0 deletions sketch/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def modal(self, context, event):
self.individual = not self.individual
self.dirty = True

elif pressed(event, {'E'}):
self.xray_mode = not self.xray_mode
self.dirty = True

elif self.key_step_up:
if self.stage == 1:
if no_stream(self.inset_input_stream) and self.key_no_modifiers:
Expand Down Expand Up @@ -136,6 +140,7 @@ def invoke(self, context, event):

self.dirty = False

self.xray_mode = False
self.individual = False
self.inset = 0
self.stage = 0
Expand Down Expand Up @@ -198,6 +203,8 @@ def delete_panel_faces(self, faces):


def operate(self, context):
self.panel_obj.show_in_front = self.xray_mode

if self.stage == 1:
bmesh.ops.delete(self.panel_bm, geom=self.panel_bm.verts, context='VERTS')
self.panel_bm.from_mesh(self.panel_mesh_snapshot)
Expand Down Expand Up @@ -280,6 +287,11 @@ def draw_text_callback(self):
"Individual Faces [F]: {}".format("Yes" if self.individual else "No"),
"Inset individual faces (Yes, No)")

draw_hint(
self,
"Exclusive View [E]: {0}".format("On" if self.xray_mode else "Off"),
"Show the target object in front of all other objects")


def register():
bpy.utils.register_class(ND_OT_panel)
Expand Down
19 changes: 19 additions & 0 deletions sketch/view_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def modal(self, context, event):
self.selection_type = (self.selection_type + 1) % 3
self.set_selection_mode(context)

elif pressed(event, {'E'}):
self.xray_mode = not self.xray_mode
self.dirty = True

elif self.key_one:
self.selection_type = 0
self.set_selection_mode(context)
Expand All @@ -80,12 +84,17 @@ def modal(self, context, event):
elif self.key_movement_passthrough:
return {'PASS_THROUGH'}

if self.dirty:
self.operate(context)

update_overlay(self, context, event)

return {'RUNNING_MODAL'}


def invoke(self, context, event):
self.dirty = False
self.xray_mode = False
self.selection_type = 2 # ['VERT', 'EDGE', 'FACE']

self.skip_geo_select = event.alt
Expand Down Expand Up @@ -216,6 +225,11 @@ def determine_selection_type(self, context):
self.selection_type = 2


def operate(self, context):
context.active_object.show_in_front = self.xray_mode
self.dirty = False


def finish(self, context):
if self.has_invalid_selection(context):
self.clean_up(context)
Expand Down Expand Up @@ -253,6 +267,11 @@ def draw_text_callback(self):
"Selection Type [S,1,2,3]: {0}".format(['Vertex', 'Edge', 'Face'][self.selection_type]),
"Type of geometry to select (Vertex, Edge, Face)")

draw_hint(
self,
"Exclusive View [E]: {0}".format("On" if self.xray_mode else "Off"),
"Show the target object in front of all other objects")


def register():
bpy.utils.register_class(ND_OT_view_align)
Expand Down

0 comments on commit 9fc75c1

Please sign in to comment.