kopia lustrzana https://github.com/inkstitch/inkstitch
add pull_compensation_percent
rodzic
ea13c42997
commit
4285a6fb7f
|
@ -132,6 +132,18 @@ class SatinColumn(EmbroideryElement):
|
|||
# peak-to-peak distance between zigzags
|
||||
return max(self.get_float_param("zigzag_spacing_mm", 0.4), 0.01)
|
||||
|
||||
@property
|
||||
@param(
|
||||
'pull_compensation_percent',
|
||||
_('Pull compensation percentage'),
|
||||
tooltip=_('pull compensation in percentage'),
|
||||
unit='%',
|
||||
type='int',
|
||||
default=0)
|
||||
def pull_compensation_percent(self):
|
||||
# pull compensation as a percentage of the width
|
||||
return max(self.get_int_param("pull_compensation_percent", 0), 0)
|
||||
|
||||
@property
|
||||
@param(
|
||||
'pull_compensation_mm',
|
||||
|
@ -147,6 +159,18 @@ class SatinColumn(EmbroideryElement):
|
|||
# wider than we desire the column to end up.
|
||||
return self.get_float_param("pull_compensation_mm", 0)
|
||||
|
||||
@property
|
||||
@param(
|
||||
'pull_compensation_rails',
|
||||
_('Apply pull compensation to '),
|
||||
tooltip=_('decide wether the pull compensations should be applied to both side or only to a given one'),
|
||||
type='dropdown',
|
||||
options=[_("Both rails"), _("First rail only"), _("Second rail only")],
|
||||
default=0)
|
||||
def pull_compensation_rails(self):
|
||||
# 0=Both | 1 = First Rail | 2 = Second Rail
|
||||
return self.get_int_param("pull_compensation_rails", 0)
|
||||
|
||||
@property
|
||||
@param('contour_underlay', _('Contour underlay'), type='toggle', group=_('Contour Underlay'))
|
||||
def contour_underlay(self):
|
||||
|
@ -619,11 +643,16 @@ class SatinColumn(EmbroideryElement):
|
|||
center_walk, _ = self.plot_points_on_rails(self.zigzag_spacing, -100000)
|
||||
return shgeo.LineString(center_walk)
|
||||
|
||||
def offset_points(self, pos1, pos2, offset_px):
|
||||
def offset_points(self, pos1, pos2, offset, offset_percent=0, offset_rails=0):
|
||||
# Expand or contract two points about their midpoint. This is
|
||||
# useful for pull compensation and insetting underlay.
|
||||
|
||||
distance = (pos1 - pos2).length()
|
||||
offset_px = 0
|
||||
if offset:
|
||||
offset_px += offset
|
||||
if offset_percent:
|
||||
offset_px += ((offset_percent / 100) * distance)
|
||||
|
||||
if distance < 0.0001:
|
||||
# if they're the same point, we don't know which direction
|
||||
|
@ -634,8 +663,21 @@ class SatinColumn(EmbroideryElement):
|
|||
if offset_px < -distance / 2.0:
|
||||
offset_px = -distance / 2.0
|
||||
|
||||
pos1 = pos1 + (pos1 - pos2).unit() * offset_px
|
||||
pos2 = pos2 + (pos2 - pos1).unit() * offset_px
|
||||
# chose how to apply on the rails
|
||||
|
||||
coeff1 = 1
|
||||
coeff2 = 1
|
||||
|
||||
if offset_rails == 1:
|
||||
coeff1 = 2
|
||||
coeff2 = 0
|
||||
|
||||
if offset_rails == 2:
|
||||
coeff1 = 0
|
||||
coeff2 = 2
|
||||
|
||||
pos1 = pos1 + (pos1 - pos2).unit() * offset_px * coeff1
|
||||
pos2 = pos2 + (pos2 - pos1).unit() * offset_px * coeff2
|
||||
|
||||
return pos1, pos2
|
||||
|
||||
|
@ -672,13 +714,13 @@ class SatinColumn(EmbroideryElement):
|
|||
distance_remaining -= segment_length
|
||||
pos = segment_end
|
||||
|
||||
def plot_points_on_rails(self, spacing, offset):
|
||||
def plot_points_on_rails(self, spacing, offset, offset_percent=0, offset_rails=0):
|
||||
# Take a section from each rail in turn, and plot out an equal number
|
||||
# of points on both rails. Return the points plotted. The points will
|
||||
# be contracted or expanded by offset using self.offset_points().
|
||||
|
||||
def add_pair(pos0, pos1):
|
||||
pos0, pos1 = self.offset_points(pos0, pos1, offset)
|
||||
pos0, pos1 = self.offset_points(pos0, pos1, offset, offset_percent, offset_rails)
|
||||
points[0].append(pos0)
|
||||
points[1].append(pos1)
|
||||
|
||||
|
@ -836,7 +878,8 @@ class SatinColumn(EmbroideryElement):
|
|||
# print >> dbg, "satin", self.zigzag_spacing, self.pull_compensation
|
||||
|
||||
patch = StitchGroup(color=self.color)
|
||||
sides = self.plot_points_on_rails(self.zigzag_spacing, self.pull_compensation)
|
||||
sides = self.plot_points_on_rails(self.zigzag_spacing, self.pull_compensation, self.pull_compensation_percent,
|
||||
self.pull_compensation_rails)
|
||||
|
||||
if self.max_stitch_length:
|
||||
return self.do_split_stitch(patch, sides)
|
||||
|
@ -866,7 +909,7 @@ class SatinColumn(EmbroideryElement):
|
|||
|
||||
patch = StitchGroup(color=self.color)
|
||||
|
||||
sides = self.plot_points_on_rails(self.zigzag_spacing, self.pull_compensation)
|
||||
sides = self.plot_points_on_rails(self.zigzag_spacing, self.pull_compensation, self.pull_compensation_percent, self.pull_compensation_rails)
|
||||
|
||||
# "left" and "right" here are kind of arbitrary designations meaning
|
||||
# a point from the first and second rail respectively
|
||||
|
|
|
@ -116,6 +116,8 @@ inkstitch_attribs = [
|
|||
'zigzag_underlay_max_stitch_length_mm',
|
||||
'e_stitch',
|
||||
'pull_compensation_mm',
|
||||
'pull_compensation_percent',
|
||||
'pull_compensation_rails',
|
||||
'stroke_first',
|
||||
# stitch_plan
|
||||
'invisible_layers',
|
||||
|
|
Ładowanie…
Reference in New Issue