Make Pulley a part with callback and move params

This commit is contained in:
Florian Festi 2016-07-13 13:35:57 +02:00
parent 9cdb2e8dc4
commit 01312788bb
1 changed files with 12 additions and 1 deletions

View File

@ -84,7 +84,7 @@ class Pulley:
self.boxes.ctx.line_to(*lines[0])
self.boxes.ctx.restore()
def __call__(self, teeth, profile):
def __call__(self, teeth, profile, move="", r_axle=None, callback=None):
# ********************************
# ** Scaling tooth for good fit **
@ -106,6 +106,14 @@ class Pulley:
tooth_width_scale = (tooth_width + additional_tooth_width ) / tooth_width
tooth_depth_scale = ((tooth_depth + additional_tooth_depth ) / tooth_depth)
total_width = pulley_OD + 2 * self.boxes.spacing
if self.boxes.move(total_width, total_width, move, before=True):
return
self.boxes.ctx.save()
self.boxes.moveTo(total_width/2, total_width/2)
self.boxes.cc(callback, None, 0.0, 0.0)
if r_axle:
self.boxes.hole(0, 0, r_axle)
points = []
for i in range(teeth):
m = [[tooth_width_scale, 0, 0],
@ -113,3 +121,6 @@ class Pulley:
m = mmul(m, rotm(i*2*pi/teeth))
points.extend((vtransl(pt, m) for pt in self.teeth[profile][1:-1]))
self.drawPoints(points)
self.boxes.ctx.restore()
self.boxes.move(total_width, total_width, move)