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))
|
|
|
|
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
|
|
|
|
|
|
|
|
# Initialize canvas
|
|
|
|
self.open()
|
|
|
|
|
|
|
|
h = t*(self.Stackable_holedistance+2*self.Stackable_height+1)+self.canheight
|
|
|
|
# render your parts here
|
2018-10-29 15:44:18 +01:00
|
|
|
self.rectangularWall(h, x, "eseS", callback=[None, 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")
|
|
|
|
|
|
|
|
self.rectangularWall(t*(self.Stackable_holedistance+2*self.Stackable_height), x, "eeee",
|
2018-10-29 15:44:18 +01:00
|
|
|
move="up")
|
2018-10-27 18:32:09 +02:00
|
|
|
self.rectangularWall(t*(self.Stackable_holedistance+2*self.Stackable_height), x, "eeee",
|
2018-10-29 15:44:18 +01:00
|
|
|
move="")
|
|
|
|
self.rectangularWall(y, x, "efef", callback=[self.paintholes],
|
|
|
|
move="left")
|
|
|
|
self.rectangularWall(h, x, "eseS", callback=[None, lambda: self.fingerHolesAt(0, self.canheight/3, x, 0)],
|
|
|
|
move="left")
|
2018-10-27 18:32:09 +02:00
|
|
|
self.close()
|