diff --git a/boxes.py b/boxes.py index 9cb1124..9657ed9 100755 --- a/boxes.py +++ b/boxes.py @@ -75,7 +75,6 @@ class Bolts(BoltPolicy): #print pos, result, ((float(pos)*(self.bolts+1)/self.fingers)-0.01), ((float(pos+1)*(self.bolts+1)/self.fingers)-0.01) return result - ############################################################################# ### Settings ############################################################################# @@ -153,6 +152,45 @@ class OutSetEdge(Edge): def width(self): return self.boxes.thickness +class Slot(Edge): + def __init__(self, boxes, depth): + Edge.__init__(self, boxes, None) + self.depth = depth + + def __call__(self, length, **kw): + if self.depth: + self.boxes.corner(90) + self.boxes.edge(self.depth) + self.boxes.corner(-90) + self.boxes.edge(length) + self.boxes.corner(-90) + self.boxes.edge(self.depth) + self.boxes.corner(90) + else: + self.boxes.edge(self.length) + +class SlottedEdge(Edge): + + def __init__(self, boxes, sections, edge="e", slots=0): + Edge.__init__(self, boxes, None) + self.edge = self.edges.get(edge, edge) + self.sections = sections + self.slots = slots + + def width(self): + return self.edge.width() + + def margin(self): + return self.edge.margin() + + def __call__(self, length, **kw): + for l in self.sections[:-1]: + self.edge(l) + if self.slots: + Slot(self.boxes, self.slots)(self.thickness) + else: + self.edge(self.thickness) + self.edge(self.sections[-1]) class FingerJointSettings(Settings): absolute_params = { diff --git a/typetray.py b/typetray.py index 89b938a..6360d1d 100755 --- a/typetray.py +++ b/typetray.py @@ -16,42 +16,6 @@ from boxes import * -class BottomEdge(FingerJointEdge): - def __init__(self, boxes, sections, slot=0): - FingerJointEdge.__init__(self, boxes, None) - self.sections = sections - self.slot = slot - - def _slot(self): - if self.slot: - self.boxes.corner(90) - self.boxes.edge(self.slot) - self.boxes.corner(-90) - self.boxes.edge(self.thickness) - self.boxes.corner(-90) - self.boxes.edge(self.slot) - self.boxes.corner(90) - else: - self.boxes.edge(self.thickness) - - def __call__(self, l, **kw): - for x in self.sections[:-1]: - self.boxes.fingerJointEdge(x) - self._slot() - self.boxes.fingerJointEdge(self.sections[-1]) - -class TopEdge(BottomEdge): - - - margin = Edge.margin - width = Edge.width - - def __call__(self, l, **kw): - for x in self.sections[:-1]: - self.boxes.edge(x) - self._slot() - self.boxes.edge(self.sections[-1]) - class TypeTray(Boxes): def __init__(self, x, y, h, hi=None, **kw): self.x, self.y, self.h = x, y, h @@ -124,12 +88,12 @@ class TypeTray(Boxes): move="right") # Inner walls for i in range(len(self.x)-1): - e = [BottomEdge(self, self.y, 0.5*hi), "f", "e", "f"] + e = [SlottedEdge(self, self.y, "f", slots=0.5*hi), "f", "e", "f"] self.rectangularWall(y, hi, e, move="up") for i in range(len(self.y)-1): - e = [BottomEdge(self, self.x), "f", - TopEdge(self, self.x, 0.5*hi), "f"] + e = [SlottedEdge(self, self.x, "f"), "f", + SlottedEdge(self, self.x[::-1], "e", slots=0.5*hi), "f"] self.rectangularWall(x, hi, e, move="up") self.close()