2018-10-27 18:32:09 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# Copyright (C) 2013-2016 Florian Festi
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2018-10-29 18:16:16 +01:00
|
|
|
from boxes import Boxes, edges, boolarg
|
2018-10-27 18:32:09 +02:00
|
|
|
|
|
|
|
class PaintStorage(Boxes):
|
|
|
|
"""Stackable paint storage"""
|
|
|
|
|
|
|
|
webinterface = True
|
|
|
|
ui_group = "Shelf" # see ./__init__.py for names
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
Boxes.__init__(self)
|
|
|
|
|
|
|
|
self.addSettingsArgs(edges.FingerJointSettings)
|
|
|
|
self.addSettingsArgs(edges.StackableSettings)
|
|
|
|
|
|
|
|
self.buildArgParser(x=100, y=300)
|
|
|
|
|
|
|
|
self.argparser.add_argument(
|
|
|
|
"--canheight", action="store", type=int, default=50,
|
|
|
|
help="Height of the paintcans")
|
|
|
|
self.argparser.add_argument(
|
|
|
|
"--candiameter", action="store", type=int, default=30,
|
|
|
|
help="Diameter of the paintcans")
|
|
|
|
self.argparser.add_argument(
|
|
|
|
"--minspace", action="store", type=int, default=10,
|
|
|
|
help="Minimum space between the paintcans")
|
2018-10-29 18:16:16 +01:00
|
|
|
self.argparser.add_argument(
|
|
|
|
"--hexpattern", action="store", type=boolarg, default=False,
|
|
|
|
help="Use hexagonal arrangement for the holes instead of orthogonal")
|
2018-10-27 18:32:09 +02:00
|
|
|
|
|
|
|
def paintholes(self):
|
|
|
|
"Place holes for the paintcans evenly"
|
2018-10-29 18:16:16 +01:00
|
|
|
|
|
|
|
if self.hexpattern:
|
|
|
|
self.moveTo(self.minspace/2, self.minspace/2)
|
|
|
|
self.hexHolesRectangle(self.y - 1*self.minspace,
|
|
|
|
self.x - 1*self.minspace,
|
|
|
|
(self.candiameter/2, self.minspace, 'circle'))
|
|
|
|
return
|
2018-10-27 18:32:09 +02:00
|
|
|
n_x = int(self.x / (self.candiameter+self.minspace))
|
|
|
|
n_y = int(self.y / (self.candiameter+self.minspace))
|
2020-02-01 14:31:24 +01:00
|
|
|
|
|
|
|
if n_x <= 0 or n_y <= 0:
|
|
|
|
return
|
|
|
|
|
2018-10-27 18:32:09 +02:00
|
|
|
spacing_x = (self.x - n_x*self.candiameter)/n_x
|
|
|
|
spacing_y = (self.y - n_y*self.candiameter)/n_y
|
|
|
|
for i in range(n_y):
|
|
|
|
for j in range(n_x):
|
|
|
|
self.hole(i * (self.candiameter+spacing_y) + (self.candiameter+spacing_y)/2,
|
|
|
|
j * (self.candiameter+spacing_x) + (self.candiameter+spacing_x)/2,
|
|
|
|
self.candiameter/2)
|
|
|
|
|
|
|
|
|
|
|
|
def render(self):
|
|
|
|
# adjust to the variables you want in the local scope
|
|
|
|
x, y = self.x, self.y
|
|
|
|
t = self.thickness
|
|
|
|
|
|
|
|
|
2018-11-24 22:47:35 +01:00
|
|
|
stack = self.edges['s'].settings
|
2018-11-15 22:10:19 +01:00
|
|
|
h = self.canheight - stack.height - stack.holedistance + t
|
|
|
|
|
2019-01-10 22:09:10 +01:00
|
|
|
hx = 1/2.*x
|
|
|
|
hh = h/4.
|
|
|
|
hr = min(hx, hh) / 2
|
|
|
|
|
2018-10-27 18:32:09 +02:00
|
|
|
# render your parts here
|
2018-12-08 12:36:29 +01:00
|
|
|
self.rectangularWall(h, x, "eseS", callback=[
|
2019-01-10 22:09:10 +01:00
|
|
|
lambda: self.rectangularHole(h/3, x/2., hh, hx, r=hr),
|
2018-12-08 12:36:29 +01:00
|
|
|
lambda: self.fingerHolesAt(0, self.canheight/3, x, 0)],
|
2018-10-27 18:32:09 +02:00
|
|
|
move="right")
|
|
|
|
self.rectangularWall(y, x, "efef",
|
|
|
|
move="right")
|
|
|
|
|
2018-11-15 22:10:19 +01:00
|
|
|
self.rectangularWall(0.8*stack.height+stack.holedistance, x, "eeee",
|
2018-10-29 15:44:18 +01:00
|
|
|
move="up")
|
2018-11-15 22:10:19 +01:00
|
|
|
self.rectangularWall(0.8*stack.height+stack.holedistance, x, "eeee",
|
2018-10-29 15:44:18 +01:00
|
|
|
move="")
|
|
|
|
self.rectangularWall(y, x, "efef", callback=[self.paintholes],
|
|
|
|
move="left")
|
2018-12-08 12:36:29 +01:00
|
|
|
self.rectangularWall(h, x, "eseS", callback=[
|
2019-01-10 22:09:10 +01:00
|
|
|
lambda: self.rectangularHole(h/3, x/2., hh, hx, r=hr),
|
2018-12-08 12:36:29 +01:00
|
|
|
lambda: self.fingerHolesAt(0, self.canheight/3, x, 0)],
|
2018-10-29 15:44:18 +01:00
|
|
|
move="left")
|