Add a StorageSelf generator. This is a shelf for storing TypeTray boxes.

It is based on TypeTray generator. The sh parameter replace the sx parameter.
It is not a subclasse of TypeTray in order to have the top and bottom at
the right place.
This commit is contained in:
Germain Lemasson 2019-03-30 23:48:59 +01:00 committed by Florian Festi
parent a6ca723759
commit e8e248994b
3 changed files with 138 additions and 4 deletions

View File

@ -322,7 +322,7 @@ class Boxes:
Supported parameters are
* floats: x, y, h, hi
* argparseSections: sx, sy
* argparseSections: sx, sy, sh
* ArgparseEdgeType: bottom_edge, top_edge
* boolarg: outside
* str (selection): nema_mount
@ -345,14 +345,19 @@ class Boxes:
self.argparser.add_argument(
"--sx", action="store", type=argparseSections,
default=default,
help="""sections left to right in mm. Possible formats: overallwidth/numberof sections e.g. "250/5"; sectionwidth*numberofsections e.g. "50*5"; section widths separated by ":" e.g. "30:25.5:70"
""")
help="""sections left to right in mm. See --sy for format""")
elif arg == "sy":
if default is None: default = "50*3"
self.argparser.add_argument(
"--sy", action="store", type=argparseSections,
default=default,
help="""sections back to front in mm. See --sx for format""")
help="""sections back to front in mm. Possible formats: overallwidth/numberof sections e.g. "250/5"; sectionwidth*numberofsections e.g. "50*5"; section widths separated by ":" e.g. "30:25.5:70""")
elif arg == "sh":
if default is None: default = "50*3"
self.argparser.add_argument(
"--sh", action="store", type=argparseSections,
default=default,
help="""sections bottom to top in mm. See --sy for format""")
elif arg == "h":
if default is None: default = 100.0
self.argparser.add_argument(

View File

@ -0,0 +1,129 @@
#!/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")
def ySlots(self):
posy = -0.5 * self.thickness
for y in self.sy[:-1]:
posy += y + self.thickness
posh = 0
for h in self.sh:
self.fingerHolesAt(posy, posh, h)
posh += h + self.thickness
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)
self.sh = self.adjustSize(self.sh)
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
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")
# floor
if b != "e":
self.rectangularWall(x, y, "fffE", callback=[None, self.yHoles], move="up")
# inner walls
be = "f" if b != "e" else "e"
for i in range(len(self.sh) - 1):
e = ["f", edges.SlottedEdge(self, self.sy[::-1], "f", slots=0.5 * x), "f", "E"]
self.rectangularWall(x, y, e, move="up")
# top / lid
if self.closedtop:
e = "FFFE" if self.top_edge == "f" else "fffE"
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):
e = [be, edges.SlottedEdge(self, self.sh, "E", slots=0.5 * x),
"e", "f"]
if self.closedtop:
e = [be, edges.SlottedEdge(self, self.sh, "E", slots=0.5 * x),"f", "f"]
self.rectangularWall(x, h, e, move="up")

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB