Skip to content

Commit

Permalink
feat: add enhanced wireframe mode toggle to all bevel operators
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm committed May 20, 2022
1 parent 7aec17d commit 03933cf
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 4 deletions.
16 changes: 16 additions & 0 deletions power_mods/bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ def modal(self, context, event):
self.harden_normals = not self.harden_normals
self.dirty = True

elif pressed(event, {'W'}):
self.target_object.show_wire = not self.target_object.show_wire
self.target_object.show_in_front = not self.target_object.show_in_front

elif self.key_step_up:
if no_stream(self.segments_input_stream) and self.key_alt:
self.segments = 2 if self.segments == 1 else self.segments + segment_factor
Expand Down Expand Up @@ -149,6 +153,8 @@ def invoke(self, context, event):
self.width_input_stream = new_stream()
self.profile_input_stream = new_stream()

self.target_object = context.active_object

mods = context.active_object.modifiers
mod_names = list(map(lambda x: x.name, mods))
previous_op = all(m in mod_names for m in mod_summon_list)
Expand Down Expand Up @@ -223,11 +229,16 @@ def operate(self, context):


def finish(self, context):
self.target_object.show_wire = False
self.target_object.show_in_front = False
self.add_weld_modifier(context)
unregister_draw_handler()


def revert(self, context):
self.target_object.show_wire = False
self.target_object.show_in_front = False

if not self.summoned:
bpy.ops.object.modifier_remove(modifier=self.bevel.name)

Expand Down Expand Up @@ -273,6 +284,11 @@ def draw_text_callback(self):
"Harden Normals [H]: {0}".format("Yes" if self.harden_normals else "No"),
"Match normals of new faces to adjacent faces")

draw_hint(
self,
"Enhanced Wireframe [W]: {0}".format("Yes" if self.target_object.show_wire else "No"),
"Display the objects's wireframe over solid shading")


def menu_func(self, context):
self.layout.operator(ND_OT_bevel.bl_idname, text=ND_OT_bevel.bl_label)
Expand Down
16 changes: 16 additions & 0 deletions power_mods/edge_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ def modal(self, context, event):
self.harden_normals = not self.harden_normals
self.dirty = True

elif pressed(event, {'W'}):
self.target_object.show_wire = not self.target_object.show_wire
self.target_object.show_in_front = not self.target_object.show_in_front

elif self.key_increase_factor:
if no_stream(self.weight_input_stream) and self.key_no_modifiers:
self.base_weight_factor = min(1, self.base_weight_factor * 10.0)
Expand Down Expand Up @@ -167,6 +171,8 @@ def invoke(self, context, event):
self.width_input_stream = new_stream()
self.profile_input_stream = new_stream()

self.target_object = context.active_object

if not context.object.data.use_customdata_edge_bevel:
context.object.data.use_customdata_edge_bevel = True

Expand Down Expand Up @@ -269,11 +275,16 @@ def operate(self, context):


def finish(self, context):
self.target_object.show_wire = False
self.target_object.show_in_front = False
self.add_weld_modifier(context)
unregister_draw_handler()


def revert(self, context):
self.target_object.show_wire = False
self.target_object.show_in_front = False

if not self.summoned:
bpy.ops.object.modifier_remove(modifier=self.bevel.name)

Expand Down Expand Up @@ -338,6 +349,11 @@ def draw_text_callback(self):
"Harden Normals [H]: {0}".format("Yes" if self.harden_normals else "No"),
"Match normals of new faces to adjacent faces")

draw_hint(
self,
"Enhanced Wireframe [W]: {0}".format("Yes" if self.target_object.show_wire else "No"),
"Display the objects's wireframe over solid shading")


def menu_func(self, context):
self.layout.operator(ND_OT_edge_bevel.bl_idname, text=ND_OT_edge_bevel.bl_label)
Expand Down
20 changes: 18 additions & 2 deletions power_mods/vertex_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import bpy
import bmesh
from .. lib.overlay import update_overlay, init_overlay, toggle_pin_overlay, toggle_operator_passthrough, register_draw_handler, unregister_draw_handler, draw_header, draw_property
from .. lib.events import capture_modifier_keys
from .. lib.overlay import update_overlay, init_overlay, toggle_pin_overlay, toggle_operator_passthrough, register_draw_handler, unregister_draw_handler, draw_header, draw_property, draw_hint
from .. lib.events import capture_modifier_keys, pressed
from .. lib.preferences import get_preferences
from .. lib.numeric_input import update_stream, no_stream, get_stream_value, new_stream

Expand Down Expand Up @@ -80,6 +80,10 @@ def modal(self, context, event):
self.profile = 0.5
self.dirty = True

elif pressed(event, {'W'}):
self.target_object.show_wire = not self.target_object.show_wire
self.target_object.show_in_front = not self.target_object.show_in_front

elif self.key_increase_factor:
if no_stream(self.width_input_stream) and self.key_no_modifiers:
self.base_width_factor = min(1, self.base_width_factor * 10.0)
Expand Down Expand Up @@ -148,6 +152,8 @@ def invoke(self, context, event):
self.width_input_stream = new_stream()
self.profile_input_stream = new_stream()

self.target_object = context.active_object

previous_op = False

bm = bmesh.from_edit_mesh(context.object.data)
Expand Down Expand Up @@ -267,6 +273,8 @@ def operate(self, context):


def finish(self, context):
self.target_object.show_wire = False
self.target_object.show_in_front = False
self.add_weld_modifier(context)

# TODO: Find a better solution. This is a workaround for the fact that
Expand All @@ -279,6 +287,9 @@ def finish(self, context):


def revert(self, context):
self.target_object.show_wire = False
self.target_object.show_in_front = False

if self.summoned:
self.bevel.width = self.width_prev
self.bevel.segments = self.segments_prev
Expand Down Expand Up @@ -325,6 +336,11 @@ def draw_text_callback(self):
mouse_value=True,
input_stream=self.profile_input_stream)

draw_hint(
self,
"Enhanced Wireframe [W]: {0}".format("Yes" if self.target_object.show_wire else "No"),
"Display the objects's wireframe over solid shading")


def menu_func(self, context):
self.layout.operator(ND_OT_vertex_bevel.bl_idname, text=ND_OT_vertex_bevel.bl_label)
Expand Down
20 changes: 18 additions & 2 deletions power_mods/weighted_normal_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import bpy
import bmesh
from math import radians
from .. lib.overlay import update_overlay, init_overlay, toggle_pin_overlay, toggle_operator_passthrough, register_draw_handler, unregister_draw_handler, draw_header, draw_property
from .. lib.events import capture_modifier_keys
from .. lib.overlay import update_overlay, init_overlay, toggle_pin_overlay, toggle_operator_passthrough, register_draw_handler, unregister_draw_handler, draw_header, draw_property, draw_hint
from .. lib.events import capture_modifier_keys, pressed
from .. lib.preferences import get_preferences
from .. lib.numeric_input import update_stream, no_stream, get_stream_value, new_stream

Expand Down Expand Up @@ -61,6 +61,10 @@ def modal(self, context, event):
self.width = 0
self.dirty = True

elif pressed(event, {'W'}):
self.target_object.show_wire = not self.target_object.show_wire
self.target_object.show_in_front = not self.target_object.show_in_front

elif self.key_increase_factor:
if no_stream(self.width_input_stream) and self.key_no_modifiers:
self.base_width_factor = min(1, self.base_width_factor * 10.0)
Expand Down Expand Up @@ -106,6 +110,8 @@ def invoke(self, context, event):

self.width_input_stream = new_stream()

self.target_object = context.active_object

mods = context.active_object.modifiers
mod_names = list(map(lambda x: x.name, mods))
previous_op = all(m in mod_names for m in mod_summon_list)
Expand Down Expand Up @@ -182,10 +188,15 @@ def operate(self, context):


def finish(self, context):
self.target_object.show_wire = False
self.target_object.show_in_front = False
unregister_draw_handler()


def revert(self, context):
self.target_object.show_wire = False
self.target_object.show_in_front = False

if not self.summoned:
bpy.ops.object.modifier_remove(modifier=self.bevel.name)
bpy.ops.object.modifier_remove(modifier=self.wn.name)
Expand All @@ -208,6 +219,11 @@ def draw_text_callback(self):
mouse_value=True,
input_stream=self.width_input_stream)

draw_hint(
self,
"Enhanced Wireframe [W]: {0}".format("Yes" if self.target_object.show_wire else "No"),
"Display the objects's wireframe over solid shading")


def menu_func(self, context):
self.layout.operator(ND_OT_weighted_normal_bevel.bl_idname, text=ND_OT_weighted_normal_bevel.bl_label)
Expand Down

0 comments on commit 03933cf

Please sign in to comment.