2016-07-11 23:01:57 +02:00
|
|
|
#!/usr/bin/env python3
|
2014-03-16 18:26:12 +01:00
|
|
|
# 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/>.
|
2013-04-16 05:07:26 +02:00
|
|
|
|
|
|
|
from boxes import Boxes
|
|
|
|
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2013-04-16 05:07:26 +02:00
|
|
|
class Silverware(Boxes):
|
2018-10-27 22:23:42 +02:00
|
|
|
"""
|
|
|
|
Cuttlery stand with carrying grip
|
|
|
|
using flex for rounded corners
|
|
|
|
"""
|
2016-03-15 21:29:03 +01:00
|
|
|
|
2017-02-15 15:55:01 +01:00
|
|
|
ui_group = "Unstable"
|
2017-02-13 17:31:58 +01:00
|
|
|
|
2018-10-27 22:23:42 +02:00
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
Boxes.__init__(self)
|
|
|
|
|
|
|
|
self.buildArgParser(x=250, y=154, h=120)
|
|
|
|
|
|
|
|
self.argparser.add_argument(
|
|
|
|
"--cornerradius", action="store", type=int, default=30,
|
|
|
|
help="Radius of the corners")
|
|
|
|
self.argparser.add_argument(
|
|
|
|
"--handleheight", action="store", type=int, default=150,
|
|
|
|
help="Height of the handle")
|
|
|
|
self.argparser.add_argument(
|
|
|
|
"--handlewidth", action="store", type=int, default=120,
|
|
|
|
help="Width of the handle")
|
|
|
|
|
|
|
|
|
2013-04-16 05:07:26 +02:00
|
|
|
####################################################################
|
|
|
|
### Parts
|
|
|
|
####################################################################
|
|
|
|
|
2013-04-16 05:22:20 +02:00
|
|
|
def basePlate(self, x, y, r):
|
|
|
|
self.roundedPlate(x, y, r, callback=[
|
2016-08-17 15:07:41 +02:00
|
|
|
lambda: self.fingerHolesAt(x / 3.0 - r, 0, 0.5 * (y - self.thickness)),
|
|
|
|
lambda: self.fingerHolesAt(x / 6.0, 0, 0.5 * (y - self.thickness)),
|
|
|
|
lambda: self.fingerHolesAt(y / 2.0 - r, 0, x),
|
|
|
|
lambda: self.fingerHolesAt(x / 2.0 - r, 0, 0.5 * (y - self.thickness))
|
|
|
|
])
|
2013-04-16 05:07:26 +02:00
|
|
|
|
|
|
|
def wall(self, x=100, y=100, h=100, r=0):
|
2016-08-17 15:07:41 +02:00
|
|
|
self.surroundingWall(x, y, r, h, bottom='h', callback={
|
|
|
|
0: lambda: self.fingerHolesAt(x / 6.0, 0, h - 10),
|
|
|
|
4: lambda: self.fingerHolesAt(x / 3.0 - r, 0, h - 10),
|
|
|
|
1: lambda: self.fingerHolesAt(y / 2.0 - r, 0, h - 10),
|
|
|
|
3: lambda: self.fingerHolesAt(y / 2.0 - r, 0, h - 10),
|
|
|
|
2: lambda: self.fingerHolesAt(x / 2.0 - r, 0, h - 10),
|
|
|
|
},
|
2013-07-20 10:49:45 +02:00
|
|
|
move="up")
|
2013-04-16 05:07:26 +02:00
|
|
|
|
|
|
|
def centerWall(self, x, h):
|
|
|
|
self.ctx.save()
|
|
|
|
|
2016-04-02 20:52:27 +02:00
|
|
|
self.moveTo(self.edges["f"].spacing(), self.edges["f"].spacing())
|
2013-04-16 05:07:26 +02:00
|
|
|
for i in range(2, 5):
|
2016-08-17 15:07:41 +02:00
|
|
|
self.fingerHolesAt(i * x / 6.0, 0, h - 10)
|
2013-04-16 05:07:26 +02:00
|
|
|
|
2016-04-02 20:52:27 +02:00
|
|
|
self.edges["f"](x)
|
2013-04-16 05:07:26 +02:00
|
|
|
self.corner(90)
|
2016-08-17 15:07:41 +02:00
|
|
|
self.edges["f"](h - 10)
|
2013-04-16 05:07:26 +02:00
|
|
|
self.corner(90)
|
|
|
|
|
2018-10-27 22:23:42 +02:00
|
|
|
self.handle(x, self.handleheight, self.handlewidth)
|
2013-04-16 05:07:26 +02:00
|
|
|
|
|
|
|
self.corner(90)
|
2016-08-17 15:07:41 +02:00
|
|
|
self.edges["f"](h - 10)
|
2013-04-16 05:07:26 +02:00
|
|
|
self.corner(90)
|
|
|
|
self.ctx.restore()
|
|
|
|
|
2016-08-17 15:07:41 +02:00
|
|
|
self.moveTo(x + 2 * self.edges["f"].spacing())
|
2013-07-20 10:49:45 +02:00
|
|
|
|
2013-04-16 05:07:26 +02:00
|
|
|
##################################################
|
|
|
|
### main
|
|
|
|
##################################################
|
|
|
|
|
2016-03-08 22:27:55 +01:00
|
|
|
def render(self):
|
2018-10-27 22:23:42 +02:00
|
|
|
x = self.x
|
|
|
|
y = self.y
|
|
|
|
h = self.h
|
|
|
|
r = self.cornerradius
|
|
|
|
|
2016-06-07 20:20:35 +02:00
|
|
|
self.open()
|
2013-06-29 13:57:56 +02:00
|
|
|
t = self.thickness
|
|
|
|
b = self.burn
|
2013-04-16 05:07:26 +02:00
|
|
|
|
2013-06-29 13:57:56 +02:00
|
|
|
self.wall(x, y, h, r)
|
2016-08-17 15:07:41 +02:00
|
|
|
self.centerWall(x, h)
|
|
|
|
|
|
|
|
l = (y - t) / 2.0
|
2013-04-16 05:07:26 +02:00
|
|
|
|
2018-10-27 22:23:42 +02:00
|
|
|
for _ in range(3):
|
2016-08-17 15:07:41 +02:00
|
|
|
self.rectangularWall(l, h - 10, edges="ffef", move="right")
|
2013-04-16 05:07:26 +02:00
|
|
|
|
2016-08-17 15:07:41 +02:00
|
|
|
self.moveTo(-3.0 * (l + 2 * t + 8 * b), h - 10 + 2 * t + 8 * b)
|
2013-04-16 05:07:26 +02:00
|
|
|
self.basePlate(x, y, r)
|
|
|
|
|
2014-03-21 21:08:54 +01:00
|
|
|
self.close()
|