TypeTray: Add support for all top_edges

This commit is contained in:
Florian Festi 2019-01-03 11:13:27 +01:00
parent c2615d4b38
commit c0a782b745
1 changed files with 17 additions and 18 deletions

View File

@ -15,20 +15,18 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from boxes import * from boxes import *
from boxes.lids import _TopEdge
class TypeTray(_TopEdge):
class TypeTray(Boxes):
"""Type tray - allows only continuous walls""" """Type tray - allows only continuous walls"""
ui_group = "Tray" ui_group = "Tray"
def __init__(self): def __init__(self):
Boxes.__init__(self) Boxes.__init__(self)
self.buildArgParser("sx", "sy", "h", "hi", "outside", "bottom_edge") self.addTopEdgeSettings()
self.addSettingsArgs(edges.FingerJointSettings, surroundingspaces=0.5) self.buildArgParser("sx", "sy", "h", "hi", "outside", "bottom_edge",
self.argparser.add_argument( "top_edge")
"--closedtop", action="store", type=boolarg, default=False,
help="close the box on top")
self.argparser.add_argument( self.argparser.add_argument(
"--gripheight", action="store", type=float, default=30, "--gripheight", action="store", type=float, default=30,
dest="gh", help="height of the grip hole in mm") dest="gh", help="height of the grip hole in mm")
@ -93,30 +91,31 @@ class TypeTray(Boxes):
# outer walls # outer walls
b = self.bottom_edge b = self.bottom_edge
e1 = b + "fef" t1, t2, t3, t4 = self.topEdges(self.top_edge)
e2 = b + "FeF" self.closedtop = self.top_edge in "fF"
if self.closedtop:
e1 = b + "fFf"
e2 = b + "FFF"
# x sides # x sides
self.ctx.save() self.ctx.save()
# outer walls # outer walls
self.rectangularWall(x, h, e1, callback=[self.xHoles, None, self.gripHole], move="up") self.rectangularWall(x, h, [b, "f", t1, "f"], callback=[self.xHoles, None, self.gripHole], move="up")
self.rectangularWall(x, h, e1, callback=[self.xHoles, ], move="up") self.rectangularWall(x, h, [b, "f", t3, "f"], callback=[self.xHoles, ], move="up")
# floor # floor
if b != "e": if b != "e":
self.rectangularWall(x, y, "ffff", callback=[ self.rectangularWall(x, y, "ffff", callback=[
self.xSlots, self.ySlots], move="up") self.xSlots, self.ySlots], move="up")
if self.closedtop: if self.closedtop:
if self.top_edge == "f":
e = "FFFF"
else:
e = "ffff"
if sameh: if sameh:
self.rectangularWall(x, y, "ffff", callback=[ self.rectangularWall(x, y, e, callback=[
self.xSlots, self.ySlots], move="up") self.xSlots, self.ySlots], move="up")
else: else:
self.rectangularWall(x, y, "ffff", move="up") self.rectangularWall(x, y, e, move="up")
# Inner walls # Inner walls
@ -137,8 +136,8 @@ class TypeTray(Boxes):
# y walls # y walls
# outer walls # outer walls
self.rectangularWall(y, h, e2, callback=[self.yHoles, ], move="up") self.rectangularWall(y, h, [b, "F", t2, "F"], callback=[self.yHoles, ], move="up")
self.rectangularWall(y, h, e2, callback=[self.yHoles, ], move="up") self.rectangularWall(y, h, [b, "F", t4, "F"], callback=[self.yHoles, ], move="up")
# inner walls # inner walls
for i in range(len(self.sx) - 1): for i in range(len(self.sx) - 1):