Skip to content

Commit

Permalink
feat: add scene unit scale support for operator overlay values
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm committed Jan 15, 2023
1 parent f3340c1 commit f9b8368
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 31 deletions.
6 changes: 4 additions & 2 deletions bevels/bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,13 @@ def revert(self, context):

def draw_text_callback(self):
draw_header(self)

unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length

draw_property(
self,
"Width: {0:.2f}".format(self.width * 1000),
"(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_width_factor * 1000, (self.base_width_factor / 10) * 1000),
"Width: {0:.2f}".format(self.width * unit_scale),
"(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_width_factor * unit_scale, (self.base_width_factor / 10) * unit_scale),
active=self.key_no_modifiers,
alt_mode=self.key_shift_no_modifiers,
mouse_value=True,
Expand Down
6 changes: 4 additions & 2 deletions bevels/edge_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,12 @@ def revert(self, context):

def draw_text_callback(self):
draw_header(self)

unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length

draw_property(
self,
"Weight: {0:.2f} ({1:.2f})".format(self.weight, self.width * 1000 * self.weight),
"Weight: {0:.2f} ({1:.2f})".format(self.weight, self.width * unit_scale * self.weight),
"(±0.1) | Shift (±0.01)",
active=self.key_no_modifiers,
alt_mode=self.key_shift_no_modifiers,
Expand All @@ -395,7 +397,7 @@ def draw_text_callback(self):

draw_property(
self,
"Width: {0:.2f}".format(self.width * 1000),
"Width: {0:.2f}".format(self.width * unit_scale),
"Ctrl + Alt (±100) | Shift + Ctrl + Alt (±10)",
active=self.key_ctrl_alt,
alt_mode=self.key_shift_ctrl_alt,
Expand Down
6 changes: 4 additions & 2 deletions bevels/vertex_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,12 @@ def revert(self, context):
def draw_text_callback(self):
draw_header(self)

unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length

draw_property(
self,
"Width: {0:.2f}".format(self.width * 1000),
"(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_width_factor * 1000, (self.base_width_factor / 10) * 1000),
"Width: {0:.2f}".format(self.width * unit_scale),
"(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_width_factor * unit_scale, (self.base_width_factor / 10) * unit_scale),
active=self.key_no_modifiers,
alt_mode=self.key_shift_no_modifiers,
mouse_value=True,
Expand Down
6 changes: 4 additions & 2 deletions bevels/weighted_normal_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,13 @@ def revert(self, context):

def draw_text_callback(self):
draw_header(self)

unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length

draw_property(
self,
"Width: {0:.2f}".format(self.width * 1000),
"(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_width_factor * 1000, (self.base_width_factor / 10) * 1000),
"Width: {0:.2f}".format(self.width * unit_scale),
"(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_width_factor * unit_scale, (self.base_width_factor / 10) * unit_scale),
active=self.key_no_modifiers,
alt_mode=self.key_shift_no_modifiers,
mouse_value=True,
Expand Down
6 changes: 4 additions & 2 deletions booleans/boolean_inset.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,12 @@ def revert(self, context):
def draw_text_callback(self):
draw_header(self)

unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length

draw_property(
self,
"Thickness: {0:.2f}".format(self.thickness * 1000),
"(±{0:.2f}) | Shift + (±{1:.2f})".format(self.base_thickness_factor * 1000, (self.base_thickness_factor / 10) * 1000),
"Thickness: {0:.2f}".format(self.thickness * unit_scale),
"(±{0:.2f}) | Shift + (±{1:.2f})".format(self.base_thickness_factor * unit_scale, (self.base_thickness_factor / 10) * unit_scale),
active=self.key_no_modifiers,
alt_mode=self.key_shift_no_modifiers,
mouse_value=True,
Expand Down
10 changes: 6 additions & 4 deletions extrusion/profile_extrude.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,19 +306,21 @@ def revert(self, context):
def draw_text_callback(self):
draw_header(self)

unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length

draw_property(
self,
"Extrusion: {0:.2f}".format(self.extrusion_length * 1000),
"(±{0:.2f}) | Shift + (±{1:.2f})".format(self.base_extrude_factor * 1000, (self.base_extrude_factor / 10) * 1000),
"Extrusion: {0:.2f}".format(self.extrusion_length * unit_scale),
"(±{0:.2f}) | Shift + (±{1:.2f})".format(self.base_extrude_factor * unit_scale, (self.base_extrude_factor / 10) * unit_scale),
active=self.key_no_modifiers,
alt_mode=self.key_shift_no_modifiers,
mouse_value=True,
input_stream=self.extrusion_length_input_stream)

draw_property(
self,
"Offset: {0:.2f}".format(self.offset * 1000),
"Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * 1000, (self.base_offset_factor / 10) * 1000),
"Offset: {0:.2f}".format(self.offset * unit_scale),
"Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * unit_scale, (self.base_offset_factor / 10) * unit_scale),
active=self.key_ctrl,
alt_mode=self.key_shift_ctrl,
mouse_value=True,
Expand Down
4 changes: 3 additions & 1 deletion extrusion/screw.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ def revert(self, context):
def draw_text_callback(self):
draw_header(self)

unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length

draw_property(
self,
"Segments: {}".format(self.segments),
Expand All @@ -339,7 +341,7 @@ def draw_text_callback(self):
draw_property(
self,
"Offset: {0:.2f}".format(self.offset),
"Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * 1000, (self.base_offset_factor / 10) * 1000),
"Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * unit_scale, (self.base_offset_factor / 10) * unit_scale),
active=self.key_ctrl,
alt_mode=self.key_shift_ctrl,
mouse_value=True,
Expand Down
12 changes: 7 additions & 5 deletions extrusion/solidify.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,21 @@ def revert(self, context):
def draw_text_callback(self):
draw_header(self)

unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length

draw_property(
self,
"Thickness: {0:.2f}".format(self.thickness * 1000),
"(±{0:.2f}) | Shift + (±{1:.2f})".format(self.base_thickness_factor * 1000, (self.base_thickness_factor / 10) * 1000),
"Thickness: {0:.2f}".format(self.thickness * unit_scale),
"(±{0:.2f}) | Shift + (±{1:.2f})".format(self.base_thickness_factor * unit_scale, (self.base_thickness_factor / 10) * unit_scale),
active=self.key_no_modifiers,
alt_mode=self.key_shift_no_modifiers,
mouse_value=True,
input_stream=self.thickness_input_stream)

draw_property(
self,
"Offset: {0:.2f}".format(self.offset * 1000),
"Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * 1000, (self.base_offset_factor / 10) * 1000),
self,
"Offset: {0:.2f}".format(self.offset * unit_scale),
"Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * unit_scale, (self.base_offset_factor / 10) * unit_scale),
active=self.key_ctrl,
alt_mode=self.key_shift_ctrl,
mouse_value=True,
Expand Down
4 changes: 3 additions & 1 deletion replicate/array_cubed.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ def revert(self, context):
def draw_text_callback(self):
draw_header(self)

unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length

draw_property(
self,
"Count: {0}".format(self.axes[self.axis][1]),
Expand All @@ -281,7 +283,7 @@ def draw_text_callback(self):
draw_property(
self,
"Offset: {0:.2f}".format(self.axes[self.axis][2]),
"Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * 1000, (self.base_offset_factor / 10) * 1000),
"Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * unit_scale, (self.base_offset_factor / 10) * unit_scale),
active=self.key_ctrl,
alt_mode=self.key_shift_ctrl,
mouse_value=True,
Expand Down
6 changes: 4 additions & 2 deletions replicate/circular_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ def revert(self, context):
def draw_text_callback(self):
draw_header(self)

unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length

draw_property(
self,
"Count: {}".format(self.count),
Expand All @@ -420,8 +422,8 @@ def draw_text_callback(self):

draw_property(
self,
"Offset: {0:.2f}".format(self.offset * 1000),
"Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * 1000, (self.base_offset_factor / 10) * 1000),
"Offset: {0:.2f}".format(self.offset * unit_scale),
"Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * unit_scale, (self.base_offset_factor / 10) * unit_scale),
active=self.key_ctrl,
alt_mode=self.key_shift_ctrl,
mouse_value=True,
Expand Down
6 changes: 4 additions & 2 deletions sketch/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,16 @@ def revert(self, context):
def draw_text_callback(self):
draw_header(self)

unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length

if self.stage == 0:
draw_hint(self, "Confirm Geometry [Space]", "Comfirm the geometry to extract")

if self.stage == 1:
draw_property(
self,
"Inset Amount: {0:.2f}".format(self.inset * 1000),
"(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_inset_factor * 1000, (self.base_inset_factor / 10) * 1000),
"Inset Amount: {0:.2f}".format(self.inset * unit_scale),
"(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_inset_factor * unit_scale, (self.base_inset_factor / 10) * unit_scale),
active=self.key_no_modifiers,
alt_mode=self.key_shift_no_modifiers,
mouse_value=True,
Expand Down
10 changes: 6 additions & 4 deletions sketch/recon_poly.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,12 @@ def revert(self, context):
def draw_text_callback(self):
draw_header(self)

unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length

draw_property(
self,
"{0}: {1:.2f}".format("Width" if self.inner_radius > 0 else "Radius", self.width * 1000),
"(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_width_factor * 1000, (self.base_width_factor / 10) * 1000),
"{0}: {1:.2f}".format("Width" if self.inner_radius > 0 else "Radius", self.width * unit_scale),
"(±{0:.2f}) | Shift (±{1:.2f})".format(self.base_width_factor * unit_scale, (self.base_width_factor / 10) * unit_scale),
active=self.key_no_modifiers,
alt_mode=self.key_shift_no_modifiers,
mouse_value=True,
Expand All @@ -433,8 +435,8 @@ def draw_text_callback(self):

draw_property(
self,
"Inner Radius: {0:.2f}".format(self.inner_radius * 1000),
"Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_inner_radius_factor * 1000, (self.base_inner_radius_factor / 10) * 1000),
"Inner Radius: {0:.2f}".format(self.inner_radius * unit_scale),
"Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_inner_radius_factor * unit_scale, (self.base_inner_radius_factor / 10) * unit_scale),
active=self.key_ctrl,
alt_mode=self.key_shift_ctrl,
mouse_value=True,
Expand Down
6 changes: 4 additions & 2 deletions sketch/screw_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ def revert(self, context):
def draw_text_callback(self):
draw_header(self)

unit_scale = 1000 * bpy.data.scenes["Scene"].unit_settings.scale_length

draw_property(
self,
"Type: {0}".format(self.objects[self.head_type_index][1]),
Expand All @@ -271,8 +273,8 @@ def draw_text_callback(self):

draw_property(
self,
"Offset: {0:.2f}".format(self.offset * 1000),
"Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * 1000, (self.base_offset_factor / 10) * 1000),
"Offset: {0:.2f}".format(self.offset * unit_scale),
"Ctrl (±{0:.2f}) | Shift + Ctrl (±{1:.2f})".format(self.base_offset_factor * unit_scale, (self.base_offset_factor / 10) * unit_scale),
active=self.key_ctrl,
alt_mode=self.key_shift_ctrl,
mouse_value=True,
Expand Down

0 comments on commit f9b8368

Please sign in to comment.