Add a bottom to the divider tray.

This add support for the generation of a bottom for the divider tray.
The bottom can be generated by passing the --bottom=True flag.

This makes it possible to generate ./static/samples/DividerTray.jpg
This commit is contained in:
Erwin Jansen 2020-02-15 22:20:15 -08:00 committed by Florian Festi
parent 842769b69d
commit a0338a559f
1 changed files with 22 additions and 6 deletions

View File

@ -17,7 +17,7 @@
from boxes import Boxes, edges, boolarg
import math
from functools import partial
class DividerTray(Boxes):
"""Divider tray - rows and dividers"""
@ -84,6 +84,12 @@ class DividerTray(Boxes):
default=True,
help="generate wall on the right side",
)
self.argparser.add_argument(
"--bottom",
type=boolarg,
default=False,
help="generate wall on the bottom",
)
def render(self):
@ -107,12 +113,13 @@ class DividerTray(Boxes):
# Facing walls (outer) with finger holes to support side walls
facing_wall_length = sum(self.sx) + self.thickness * (len(self.sx) - 1)
side_edge = lambda with_wall: "F" if with_wall else "e"
bottom_edge = lambda with_wall: "F" if with_wall else "e"
for _ in range(2):
self.rectangularWall(
facing_wall_length,
self.h,
["e", side_edge(self.right_wall), "e", side_edge(self.left_wall)],
callback=[self.generate_finger_holes],
[bottom_edge(self.bottom), side_edge(self.right_wall), "e", side_edge(self.left_wall)],
callback=[partial(self.generate_finger_holes, self.h)],
move="up",
)
@ -121,7 +128,7 @@ class DividerTray(Boxes):
for _ in range(side_walls_number):
se = DividerSlotsEdge(self, slot_descriptions.descriptions)
self.rectangularWall(
side_wall_length, self.h, ["e", "f", se, "f"], move="up"
side_wall_length, self.h, [bottom_edge(self.bottom), "f", se, "f"], move="up"
)
# Switch to right side of the file
@ -130,6 +137,15 @@ class DividerTray(Boxes):
max(facing_wall_length, side_wall_length), self.h, "ffff", move="right only"
)
# Bottom piece.
if self.bottom:
self.rectangularWall(facing_wall_length, side_wall_length,
["f",
"f" if self.right_wall else "e",
"f",
"f" if self.left_wall else "e"],
callback=[partial(self.generate_finger_holes, side_wall_length)], move="up")
# Dividers
divider_height = (
# h, with angle adjustement
@ -242,11 +258,11 @@ class DividerTray(Boxes):
return descriptions
def generate_finger_holes(self):
def generate_finger_holes(self, length):
posx = -0.5 * self.thickness
for x in self.sx[:-1]:
posx += x + self.thickness
self.fingerHolesAt(posx, 0, self.h)
self.fingerHolesAt(posx, 0, length)
def generate_divider(self, width, height, move, only_one_wall=False):
second_tab_width = 0 if only_one_wall else self.thickness