PaintStorage: Add additional_bottom and additional_top option
This commit is contained in:
parent
98d6d949fa
commit
f954e4e857
|
@ -23,6 +23,14 @@ class PaintStorage(Boxes):
|
||||||
webinterface = True
|
webinterface = True
|
||||||
ui_group = "Shelf" # see ./__init__.py for names
|
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:
|
def __init__(self) -> None:
|
||||||
Boxes.__init__(self)
|
Boxes.__init__(self)
|
||||||
|
|
||||||
|
@ -40,6 +48,12 @@ class PaintStorage(Boxes):
|
||||||
self.argparser.add_argument(
|
self.argparser.add_argument(
|
||||||
"--minspace", action="store", type=int, default=10,
|
"--minspace", action="store", type=int, default=10,
|
||||||
help="Minimum space between the paintcans")
|
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(
|
self.argparser.add_argument(
|
||||||
"--hexpattern", action="store", type=boolarg, default=False,
|
"--hexpattern", action="store", type=boolarg, default=False,
|
||||||
help="Use hexagonal arrangement for the holes instead of orthogonal")
|
help="Use hexagonal arrangement for the holes instead of orthogonal")
|
||||||
|
@ -51,28 +65,49 @@ class PaintStorage(Boxes):
|
||||||
"""Place holes for the paintcans evenly"""
|
"""Place holes for the paintcans evenly"""
|
||||||
|
|
||||||
if self.hexpattern:
|
if self.hexpattern:
|
||||||
self.moveTo(self.minspace/2, self.minspace/2)
|
self.moveTo(self.minspace / 2, self.minspace / 2)
|
||||||
settings = self.hexHolesSettings
|
settings = self.hexHolesSettings
|
||||||
settings.diameter = self.candiameter
|
settings.diameter = self.candiameter
|
||||||
settings.distance = self.minspace
|
settings.distance = self.minspace
|
||||||
settings.style = 'circle'
|
settings.style = 'circle'
|
||||||
self.hexHolesRectangle(self.y - 1*self.minspace,
|
self.hexHolesRectangle(self.y - 1 * self.minspace,
|
||||||
self.x - 1*self.minspace,
|
self.x - 1 * self.minspace,
|
||||||
settings)
|
settings)
|
||||||
return
|
return
|
||||||
n_x = int(self.x / (self.candiameter+self.minspace))
|
n_x = int(self.x / (self.candiameter + self.minspace))
|
||||||
n_y = int(self.y / (self.candiameter+self.minspace))
|
n_y = int(self.y / (self.candiameter + self.minspace))
|
||||||
|
|
||||||
if n_x <= 0 or n_y <= 0:
|
if n_x <= 0 or n_y <= 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
spacing_x = (self.x - n_x*self.candiameter)/n_x
|
spacing_x = (self.x - n_x * self.candiameter) / n_x
|
||||||
spacing_y = (self.y - n_y*self.candiameter)/n_y
|
spacing_y = (self.y - n_y * self.candiameter) / n_y
|
||||||
for i in range(n_y):
|
for i in range(n_y):
|
||||||
for j in range(n_x):
|
for j in range(n_x):
|
||||||
self.hole(i * (self.candiameter+spacing_y) + (self.candiameter+spacing_y)/2,
|
self.hole(i * (self.candiameter + spacing_y) + (self.candiameter + spacing_y) / 2,
|
||||||
j * (self.candiameter+spacing_x) + (self.candiameter+spacing_x)/2,
|
j * (self.candiameter + spacing_x) + (self.candiameter + spacing_x) / 2,
|
||||||
self.candiameter/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):
|
def render(self):
|
||||||
# adjust to the variables you want in the local scope
|
# adjust to the variables you want in the local scope
|
||||||
|
@ -82,25 +117,14 @@ class PaintStorage(Boxes):
|
||||||
stack = self.edges['s'].settings
|
stack = self.edges['s'].settings
|
||||||
h = self.canheight - stack.height - stack.holedistance + t
|
h = self.canheight - stack.height - stack.holedistance + t
|
||||||
|
|
||||||
hx = 1/2.*x
|
wall_callbacks = [self.sidesCb]
|
||||||
hh = h/4.
|
|
||||||
hr = min(hx, hh) / 2
|
|
||||||
|
|
||||||
if not self.drawer:
|
if not self.drawer:
|
||||||
wall_keys = "EsES"
|
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"
|
bottom_keys = "EfEf"
|
||||||
else:
|
else:
|
||||||
wall_keys = "FsFS"
|
wall_keys = "FsFS"
|
||||||
wall_callbacks = [
|
|
||||||
lambda: self.rectangularHole(h / 3, (x / 2.0) - t, hh, hx, r=hr)
|
|
||||||
]
|
|
||||||
bottom_keys = "FfFf"
|
bottom_keys = "FfFf"
|
||||||
|
|
||||||
|
|
||||||
# Walls
|
# Walls
|
||||||
self.rectangularWall(
|
self.rectangularWall(
|
||||||
h, x - 2 * t, wall_keys,
|
h, x - 2 * t, wall_keys,
|
||||||
|
@ -123,12 +147,16 @@ class PaintStorage(Boxes):
|
||||||
|
|
||||||
# Bottom
|
# Bottom
|
||||||
self.rectangularWall(
|
self.rectangularWall(
|
||||||
y, x-2*t, bottom_keys, ignore_widths=[1, 2, 5, 6], move="up"
|
y, x - 2 * t, bottom_keys, ignore_widths=[1, 2, 5, 6], move="up"
|
||||||
)
|
)
|
||||||
|
|
||||||
if not self.drawer:
|
if not self.drawer:
|
||||||
# Top
|
# Top
|
||||||
self.rectangularWall(y, x, "efef", callback=[self.paintholes], move="up")
|
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:
|
else:
|
||||||
# Sides
|
# Sides
|
||||||
self.rectangularWall(y, h, "efff", move="up")
|
self.rectangularWall(y, h, "efff", move="up")
|
||||||
|
|
Loading…
Reference in New Issue