PaintStorage: Add additional_bottom and additional_top option

This commit is contained in:
Patrick van der Leer 2023-01-21 15:26:30 +01:00 committed by Florian Festi
parent 98d6d949fa
commit f954e4e857
1 changed files with 52 additions and 24 deletions

View File

@ -23,6 +23,14 @@ class PaintStorage(Boxes):
webinterface = True
ui_group = "Shelf" # see ./__init__.py for names
canheight: int
candiameter: int
minspace: int
additional_bottom: int
additional_top: int
hexpattern: bool
drawer: bool
def __init__(self) -> None:
Boxes.__init__(self)
@ -40,6 +48,12 @@ class PaintStorage(Boxes):
self.argparser.add_argument(
"--minspace", action="store", type=int, default=10,
help="Minimum space between the paintcans")
self.argparser.add_argument(
"--additional_bottom", action="store", type=boolarg, default=False,
help="Additional bottom/floor with holes the paintcans go through")
self.argparser.add_argument(
"--additional_top", action="store", type=boolarg, default=False,
help="Additional top/floor with holes the paintcans go through")
self.argparser.add_argument(
"--hexpattern", action="store", type=boolarg, default=False,
help="Use hexagonal arrangement for the holes instead of orthogonal")
@ -74,6 +88,27 @@ class PaintStorage(Boxes):
j * (self.candiameter + spacing_x) + (self.candiameter + spacing_x) / 2,
self.candiameter / 2)
def sidesCb(self):
x, y = self.x, self.y
t = self.thickness
stack = self.edges['s'].settings
h = self.canheight - stack.height - stack.holedistance + t
hx = 1 / 2. * x
hh = h / 4.
hr = min(hx, hh) / 2
if not self.drawer:
self.rectangularHole(h / 3, (x / 2.0) - t, hh, hx, r=hr)
self.fingerHolesAt(((self.canheight/3)*2)-t*2, -t, x, 90)
if self.additional_bottom:
self.fingerHolesAt((self.canheight / 6) - (t / 2), -t, x, 90)
if self.additional_top:
self.fingerHolesAt(self.canheight - ((self.canheight / 6) + t), -t, x, 90)
else:
self.rectangularHole(h / 3, (x / 2.0) - t, hh, hx, r=hr)
def render(self):
# adjust to the variables you want in the local scope
x, y = self.x, self.y
@ -82,25 +117,14 @@ class PaintStorage(Boxes):
stack = self.edges['s'].settings
h = self.canheight - stack.height - stack.holedistance + t
hx = 1/2.*x
hh = h/4.
hr = min(hx, hh) / 2
wall_callbacks = [self.sidesCb]
if not self.drawer:
wall_keys = "EsES"
wall_callbacks = [
lambda: self.rectangularHole(h / 3, (x / 2.0) - t, hh, hx, r=hr),
lambda: self.fingerHolesAt(0, self.canheight / 3, x, 0),
]
bottom_keys = "EfEf"
else:
wall_keys = "FsFS"
wall_callbacks = [
lambda: self.rectangularHole(h / 3, (x / 2.0) - t, hh, hx, r=hr)
]
bottom_keys = "FfFf"
# Walls
self.rectangularWall(
h, x - 2 * t, wall_keys,
@ -129,6 +153,10 @@ class PaintStorage(Boxes):
if not self.drawer:
# Top
self.rectangularWall(y, x, "efef", callback=[self.paintholes], move="up")
if self.additional_bottom:
self.rectangularWall(y, x, "efef", callback=[self.paintholes], move="up")
if self.additional_top:
self.rectangularWall(y, x, "efef", callback=[self.paintholes], move="up")
else:
# Sides
self.rectangularWall(y, h, "efff", move="up")