2018-10-04 20:34:57 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# Copyright (C) 2013-2014 Florian Festi
|
|
|
|
# Copyright (C) 2018 jens persson <jens@persson.cx>
|
|
|
|
#
|
|
|
|
# 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 edges, Boxes
|
|
|
|
|
|
|
|
|
|
|
|
class InsetEdgeSettings(edges.Settings):
|
|
|
|
"""Settings for InsetEdge"""
|
|
|
|
absolute_params = {
|
|
|
|
"thickness": 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class InsetEdge(edges.BaseEdge):
|
|
|
|
"""An edge with space to slide in a lid"""
|
|
|
|
def __call__(self, length, **kw):
|
|
|
|
t = self.settings.thickness
|
|
|
|
self.corner(90)
|
|
|
|
self.edge(t, tabs=2)
|
|
|
|
self.corner(-90)
|
|
|
|
self.edge(length, tabs=2)
|
|
|
|
self.corner(-90)
|
|
|
|
self.edge(t, tabs=2)
|
|
|
|
self.corner(90)
|
|
|
|
|
|
|
|
|
|
|
|
class FingerHoleEdgeSettings(edges.Settings):
|
|
|
|
"""Settings for FingerHoleEdge"""
|
|
|
|
absolute_params = {
|
|
|
|
"wallheight": 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class FingerHoleEdge(edges.BaseEdge):
|
|
|
|
"""An edge with room to get your fingers around cards"""
|
|
|
|
def __call__(self, length, **kw):
|
2021-09-03 13:57:11 +02:00
|
|
|
depth = self.settings.wallheight-self.thickness-10
|
2018-10-04 20:34:57 +02:00
|
|
|
self.edge(length/2-10, tabs=2)
|
|
|
|
self.corner(90)
|
|
|
|
self.edge(depth, tabs=2)
|
|
|
|
self.corner(-180, 10)
|
|
|
|
self.edge(depth, tabs=2)
|
|
|
|
self.corner(90)
|
|
|
|
self.edge(length/2-10, tabs=2)
|
|
|
|
|
|
|
|
|
|
|
|
class CardBox(Boxes):
|
2020-05-26 18:05:45 +02:00
|
|
|
"""Box for storage of playing cards"""
|
2018-10-04 20:34:57 +02:00
|
|
|
ui_group = "Box"
|
|
|
|
|
2020-05-26 18:05:45 +02:00
|
|
|
description = """
|
|
|
|
#### Building instructions
|
|
|
|
|
2020-05-27 17:27:23 +02:00
|
|
|
Place inner walls on floor first (if any). Then add the outer walls. Glue the two walls without finger joins to the inside of the side walls. Make sure there is no squeeze out on top, as this is going to form the rail for the lid.
|
2020-05-26 18:05:45 +02:00
|
|
|
|
2022-01-02 11:08:23 +01:00
|
|
|
Add the top of the rails to the sides and the grip rail to the lid (still missing in the picture at the bottom):
|
2020-05-26 18:05:45 +02:00
|
|
|
|
|
|
|
![Details](static/samples/CardBox-detail.jpg)
|
|
|
|
"""
|
|
|
|
|
2018-10-04 20:34:57 +02:00
|
|
|
def __init__(self):
|
|
|
|
Boxes.__init__(self)
|
|
|
|
self.addSettingsArgs(edges.FingerJointSettings)
|
|
|
|
self.buildArgParser(h=30)
|
|
|
|
self.argparser.add_argument(
|
|
|
|
"--cardwidth", action="store", type=float, default=65,
|
|
|
|
help="Width of the cards")
|
|
|
|
self.argparser.add_argument(
|
|
|
|
"--cardheight", action="store", type=float, default=90,
|
|
|
|
help="Height of the cards")
|
2018-10-10 23:06:57 +02:00
|
|
|
self.argparser.add_argument(
|
|
|
|
"--num", action="store", type=int, default=2,
|
|
|
|
help="number of compartments")
|
2018-10-04 20:34:57 +02:00
|
|
|
|
|
|
|
@property
|
|
|
|
def boxwidth(self):
|
2018-10-10 23:06:57 +02:00
|
|
|
return self.num * (self.cardwidth + self.thickness) + self.thickness
|
2018-10-04 20:34:57 +02:00
|
|
|
|
|
|
|
def divider_bottom(self):
|
2018-10-10 23:06:57 +02:00
|
|
|
t = self.thickness
|
|
|
|
c = self.cardwidth
|
2018-10-04 20:34:57 +02:00
|
|
|
y = self.cardheight
|
|
|
|
|
2018-10-10 23:06:57 +02:00
|
|
|
for i in range(1, self.num):
|
|
|
|
self.fingerHolesAt(0.5*t + (c+t)*i, 0, y, 90)
|
2018-10-04 20:34:57 +02:00
|
|
|
|
|
|
|
def divider_back_and_front(self):
|
2018-10-10 23:06:57 +02:00
|
|
|
t = self.thickness
|
|
|
|
c = self.cardwidth
|
2021-09-03 13:57:11 +02:00
|
|
|
y = self.h
|
2018-10-10 23:06:57 +02:00
|
|
|
for i in range(1, self.num):
|
|
|
|
self.fingerHolesAt(0.5*t + (c+t)*i, 0, y, 90)
|
2018-10-04 20:34:57 +02:00
|
|
|
|
|
|
|
def render(self):
|
|
|
|
h = self.h
|
|
|
|
t = self.thickness
|
|
|
|
|
|
|
|
x = self.boxwidth
|
|
|
|
y = self.cardheight
|
|
|
|
|
|
|
|
s = InsetEdgeSettings(thickness=t)
|
|
|
|
p = InsetEdge(self, s)
|
|
|
|
p.char = "a"
|
|
|
|
self.addPart(p)
|
|
|
|
|
|
|
|
s = FingerHoleEdgeSettings(thickness=t, wallheight=h)
|
|
|
|
p = FingerHoleEdge(self, s)
|
|
|
|
p.char = "A"
|
|
|
|
self.addPart(p)
|
|
|
|
|
2019-01-12 23:16:11 +01:00
|
|
|
with self.saved_context():
|
2021-06-27 12:53:56 +02:00
|
|
|
self.rectangularWall(x-t*.2, y, "Feee", move="right", label="Lid")
|
2019-01-12 23:16:11 +01:00
|
|
|
self.rectangularWall(x, y, "ffff", callback=[self.divider_bottom],
|
2021-06-27 12:53:56 +02:00
|
|
|
move="right", label="Bottom")
|
2018-10-04 20:34:57 +02:00
|
|
|
self.rectangularWall(x, y, "EEEE", move="up only")
|
2019-01-12 23:16:11 +01:00
|
|
|
|
|
|
|
with self.saved_context():
|
2021-09-03 13:57:11 +02:00
|
|
|
self.rectangularWall(x, h+t, "FFEF",
|
2019-01-12 23:16:11 +01:00
|
|
|
callback=[self.divider_back_and_front],
|
2021-06-27 12:53:56 +02:00
|
|
|
move="right",
|
|
|
|
label="Back")
|
2021-09-03 13:57:11 +02:00
|
|
|
self.rectangularWall(x, h+t, "FFaF",
|
2019-01-12 23:16:11 +01:00
|
|
|
callback=[self.divider_back_and_front],
|
2021-06-27 12:53:56 +02:00
|
|
|
move="right",
|
|
|
|
label="Front")
|
2021-09-03 13:57:11 +02:00
|
|
|
self.rectangularWall(x, h+t, "EEEE", move="up only")
|
2018-12-11 19:33:52 +01:00
|
|
|
|
2021-06-27 12:53:56 +02:00
|
|
|
self.rectangularWall(x-t*.2, t, "fEeE", move="up", label="Lid Lip")
|
2018-10-04 20:34:57 +02:00
|
|
|
|
2021-06-27 12:53:56 +02:00
|
|
|
with self.saved_context():
|
2021-09-03 13:57:11 +02:00
|
|
|
self.rectangularWall(y, h+t, "FfFf", move="right", label="Outer Side Left")
|
|
|
|
self.rectangularWall(y, h+t, "FfFf", move="right", label="Outer Side Right")
|
|
|
|
self.rectangularWall(y, h+t, "fFfF", move="up only")
|
2018-10-04 20:34:57 +02:00
|
|
|
|
2021-06-27 12:53:56 +02:00
|
|
|
with self.saved_context():
|
2021-09-03 13:57:11 +02:00
|
|
|
self.rectangularWall(y, h, "Aeee", move="right", label="Inner Side Left")
|
|
|
|
self.rectangularWall(y, h, "Aeee", move="right", label="Inner Side Right")
|
|
|
|
self.rectangularWall(y, h, "eAee", move="up only")
|
2018-10-04 20:34:57 +02:00
|
|
|
|
2021-06-27 12:53:56 +02:00
|
|
|
with self.saved_context():
|
|
|
|
self.rectangularWall(y, t, "eefe", move="right", label="Lip Left")
|
|
|
|
self.rectangularWall(y, t, "feee", move="right", label="Lip Right")
|
|
|
|
self.rectangularWall(y, t*2, "efee", move="up only")
|
2018-10-04 20:34:57 +02:00
|
|
|
|
2018-10-10 23:06:57 +02:00
|
|
|
for i in range(self.num - 1):
|
2021-09-03 13:57:11 +02:00
|
|
|
self.rectangularWall(h, y, "fAff", move="right", label="Divider")
|
2018-10-04 20:34:57 +02:00
|
|
|
|