2019-03-30 23:48:59 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# Copyright (C) 2013-2014 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/>.
|
|
|
|
|
|
|
|
from boxes import *
|
|
|
|
from boxes.lids import _TopEdge
|
|
|
|
|
|
|
|
class StorageShelf(_TopEdge):
|
|
|
|
"""StorageShelf can be used to store Typetray"""
|
|
|
|
|
|
|
|
ui_group = "Shelf"
|
|
|
|
description = "This is a simple shelf box."
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
Boxes.__init__(self)
|
|
|
|
self.addTopEdgeSettings(fingerjoint={"surroundingspaces": 0.5},
|
|
|
|
roundedtriangle={"outset" : 1})
|
|
|
|
self.buildArgParser("x", "sy", "sh", "outside", "bottom_edge",
|
|
|
|
"top_edge")
|
2019-11-09 16:08:17 +01:00
|
|
|
self.argparser.add_argument(
|
|
|
|
"--retainer", action="store", type=float, default=0.0,
|
|
|
|
help="height of wall atthe front edges")
|
|
|
|
|
2019-03-30 23:48:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
def ySlots(self):
|
|
|
|
posy = -0.5 * self.thickness
|
2019-11-09 23:31:26 +01:00
|
|
|
h = sum(self.sh) + self.thickness * (len(self.sh) - 1)
|
2019-03-30 23:48:59 +01:00
|
|
|
for y in self.sy[:-1]:
|
|
|
|
posy += y + self.thickness
|
2019-11-09 23:31:26 +01:00
|
|
|
self.fingerHolesAt(posy, 0, h, 90)
|
2019-03-30 23:48:59 +01:00
|
|
|
|
|
|
|
def hSlots(self):
|
|
|
|
posh = -0.5 * self.thickness
|
|
|
|
for h in self.sh[:-1]:
|
|
|
|
posh += h + self.thickness
|
|
|
|
posy = 0
|
|
|
|
for y in reversed(self.sy):
|
|
|
|
self.fingerHolesAt(posh, posy, y)
|
|
|
|
posy += y + self.thickness
|
|
|
|
|
|
|
|
def yHoles(self):
|
|
|
|
posy = -0.5 * self.thickness
|
|
|
|
for y in self.sy[:-1]:
|
|
|
|
posy += y + self.thickness
|
|
|
|
self.fingerHolesAt(posy, 0, self.x)
|
|
|
|
|
|
|
|
def hHoles(self):
|
|
|
|
posh = -0.5 * self.thickness
|
|
|
|
for h in self.sh[:-1]:
|
|
|
|
posh += h + self.thickness
|
|
|
|
self.fingerHolesAt(posh, 0, self.x)
|
|
|
|
|
|
|
|
def render(self):
|
|
|
|
if self.outside:
|
|
|
|
self.sy = self.adjustSize(self.sy)
|
2019-09-01 15:44:34 +02:00
|
|
|
self.sh = self.adjustSize(self.sh, self.top_edge, self.bottom_edge)
|
2019-03-30 23:48:59 +01:00
|
|
|
self.x = self.adjustSize(self.x, e2=False)
|
|
|
|
|
|
|
|
y = sum(self.sy) + self.thickness * (len(self.sy) - 1)
|
|
|
|
h = sum(self.sh) + self.thickness * (len(self.sh) - 1)
|
|
|
|
x = self.x
|
|
|
|
t = self.thickness
|
|
|
|
|
|
|
|
|
|
|
|
# outer walls
|
|
|
|
b = self.bottom_edge
|
|
|
|
t1, t2, t3, t4 = self.topEdges(self.top_edge)
|
|
|
|
#if top_edge is t put the handle on the x walls
|
|
|
|
if(self.top_edge=='t'):
|
|
|
|
t1,t2,t3,t4=(t2,t1,t4,t3)
|
|
|
|
self.closedtop = self.top_edge in "fF"
|
|
|
|
|
|
|
|
# x sides
|
|
|
|
|
|
|
|
self.ctx.save()
|
|
|
|
|
|
|
|
# outer walls
|
2019-11-09 16:08:17 +01:00
|
|
|
# XXX retainer
|
2019-11-09 16:10:30 +01:00
|
|
|
self.rectangularWall(x, h, [b, "F", t1, "e"], callback=[None, self.hHoles, ], move="up")
|
|
|
|
self.rectangularWall(x, h, [b, "e", t3, "F"], callback=[None, self.hHoles, ], move="up")
|
2019-03-30 23:48:59 +01:00
|
|
|
|
|
|
|
# floor
|
|
|
|
if b != "e":
|
2019-11-09 16:08:17 +01:00
|
|
|
e = "fffe"
|
|
|
|
if self.retainer:
|
|
|
|
e = "ffff"
|
|
|
|
self.rectangularWall(x, y, e, callback=[None, self.yHoles], move="up")
|
2019-03-30 23:48:59 +01:00
|
|
|
|
|
|
|
# inner walls
|
|
|
|
|
|
|
|
be = "f" if b != "e" else "e"
|
|
|
|
|
|
|
|
for i in range(len(self.sh) - 1):
|
2019-11-09 16:10:30 +01:00
|
|
|
e = ["f", edges.SlottedEdge(self, self.sy[::-1], "f", slots=0.5 * x), "f", "e"]
|
2019-11-09 16:08:17 +01:00
|
|
|
if self.retainer:
|
|
|
|
e[3] = "f"
|
|
|
|
|
2019-03-30 23:48:59 +01:00
|
|
|
self.rectangularWall(x, y, e, move="up")
|
|
|
|
|
|
|
|
# top / lid
|
|
|
|
if self.closedtop:
|
2019-11-09 16:10:30 +01:00
|
|
|
e = "FFFe" if self.top_edge == "f" else "fffe"
|
2019-03-30 23:48:59 +01:00
|
|
|
self.rectangularWall(x, y, e, callback=[None, self.yHoles, ], move="up")
|
|
|
|
else:
|
|
|
|
self.drawLid(x, y, self.top_edge)
|
|
|
|
|
|
|
|
self.ctx.restore()
|
|
|
|
self.rectangularWall(x, h, "ffff", move="right only")
|
|
|
|
|
|
|
|
# y walls
|
|
|
|
|
|
|
|
# outer walls
|
|
|
|
self.rectangularWall(y, h, [b, "f", t2, "f"], callback=[self.ySlots, self.hSlots,], move="up")
|
|
|
|
|
|
|
|
# inner walls
|
|
|
|
for i in range(len(self.sy) - 1):
|
2019-11-09 16:08:17 +01:00
|
|
|
# XXX retainer
|
2019-11-09 16:10:30 +01:00
|
|
|
e = [be, edges.SlottedEdge(self, self.sh, "e", slots=0.5 * x),
|
2019-03-30 23:48:59 +01:00
|
|
|
"e", "f"]
|
|
|
|
if self.closedtop:
|
2019-11-09 16:10:30 +01:00
|
|
|
e = [be, edges.SlottedEdge(self, self.sh, "e", slots=0.5 * x),"f", "f"]
|
2019-03-30 23:48:59 +01:00
|
|
|
self.rectangularWall(x, h, e, move="up")
|
|
|
|
|
|
|
|
|
2019-11-09 16:08:17 +01:00
|
|
|
if self.retainer:
|
|
|
|
for i in range(len(self.sh)):
|
|
|
|
# XXX finger holes, F edges, left and right
|
|
|
|
self.rectangularWall(y, self.retainer, "FEeE", move="up")
|