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/>.
|
2014-02-25 20:01:14 +01:00
|
|
|
|
|
|
|
from boxes import *
|
|
|
|
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-07-31 14:15:06 +02:00
|
|
|
class MagazinFile(Boxes):
|
2016-03-15 21:29:03 +01:00
|
|
|
"""Open magazine file"""
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-03-03 13:27:22 +01:00
|
|
|
def __init__(self):
|
|
|
|
Boxes.__init__(self)
|
2016-07-09 22:52:48 +02:00
|
|
|
self.buildArgParser("x", "y", "h", "hi", "outside")
|
2017-02-09 18:47:20 +01:00
|
|
|
self.addSettingsArgs(edges.FingerJointSettings)
|
2014-02-25 20:01:14 +01:00
|
|
|
|
2016-03-03 13:27:22 +01:00
|
|
|
def side(self, w, h, hi):
|
2016-08-17 15:07:41 +02:00
|
|
|
r = min(h - hi, w) / 2.0
|
|
|
|
|
|
|
|
if (h - hi) > w:
|
2014-02-25 20:01:14 +01:00
|
|
|
r = w / 2.0
|
|
|
|
lx = 0
|
2016-08-17 15:07:41 +02:00
|
|
|
ly = (h - hi) - w
|
2014-02-25 20:01:14 +01:00
|
|
|
else:
|
2016-03-03 13:27:22 +01:00
|
|
|
r = (h - hi) / 2.0
|
2016-08-17 15:07:41 +02:00
|
|
|
lx = (w - 2 * r) / 2.0
|
2014-02-25 20:01:14 +01:00
|
|
|
ly = 0
|
|
|
|
|
2016-04-18 22:05:11 +02:00
|
|
|
e_w = self.edges["F"].startwidth()
|
2014-02-25 20:01:14 +01:00
|
|
|
self.moveTo(3, 3)
|
|
|
|
self.edge(e_w)
|
|
|
|
self.edges["F"](w)
|
|
|
|
self.edge(e_w)
|
|
|
|
self.corner(90)
|
|
|
|
self.edge(e_w)
|
2016-03-03 13:27:22 +01:00
|
|
|
self.edges["F"](hi)
|
2014-02-25 20:01:14 +01:00
|
|
|
self.corner(90)
|
|
|
|
self.edge(e_w)
|
|
|
|
self.edge(lx)
|
|
|
|
self.corner(-90, r)
|
|
|
|
self.edge(ly)
|
|
|
|
self.corner(90, r)
|
2016-08-17 15:07:41 +02:00
|
|
|
self.edge(lx)
|
2014-02-25 20:01:14 +01:00
|
|
|
self.edge(e_w)
|
|
|
|
self.corner(90)
|
|
|
|
self.edges["F"](h)
|
|
|
|
self.edge(e_w)
|
|
|
|
self.corner(90)
|
|
|
|
|
|
|
|
def render(self):
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-07-09 22:52:48 +02:00
|
|
|
if self.outside:
|
|
|
|
self.x = self.adjustSize(self.x)
|
|
|
|
self.y = self.adjustSize(self.y)
|
|
|
|
self.h = self.adjustSize(self.h, e2=False)
|
|
|
|
|
2016-03-03 13:27:22 +01:00
|
|
|
x, y, h, = self.x, self.y, self.h
|
|
|
|
self.hi = hi = self.hi or (h / 2.0)
|
2014-02-25 20:01:14 +01:00
|
|
|
t = self.thickness
|
|
|
|
|
2016-03-03 13:27:22 +01:00
|
|
|
|
2019-01-12 23:16:11 +01:00
|
|
|
with self.saved_context():
|
|
|
|
self.rectangularWall(x, h, "Ffef", move="up")
|
|
|
|
self.rectangularWall(x, hi, "Ffef", move="up")
|
|
|
|
self.rectangularWall(x, y, "ffff")
|
2014-02-25 20:01:14 +01:00
|
|
|
|
|
|
|
self.rectangularWall(x, h, "Ffef", move="right only")
|
2016-03-03 13:27:22 +01:00
|
|
|
self.side(y, h, hi)
|
2016-08-17 15:07:41 +02:00
|
|
|
self.moveTo(y + 15, h + hi + 15, 180)
|
2016-03-03 13:27:22 +01:00
|
|
|
self.side(y, h, hi)
|
2014-02-25 20:01:14 +01:00
|
|
|
|
|
|
|
|
2016-08-17 15:07:41 +02:00
|
|
|
|