2016-07-11 23:01:57 +02:00
|
|
|
#!/usr/bin/env python3
|
2016-03-08 18:04:49 +01:00
|
|
|
# Copyright (C) 2016 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/>.
|
|
|
|
|
|
|
|
import sys, re
|
|
|
|
from boxes import *
|
2016-03-16 10:16:56 +01:00
|
|
|
import boxes
|
2016-03-08 18:04:49 +01:00
|
|
|
|
2016-07-31 17:18:17 +02:00
|
|
|
|
2016-08-17 15:07:41 +02:00
|
|
|
class Layout(Boxes):
|
2016-03-08 18:04:49 +01:00
|
|
|
"""Generate a typetray from a layout file"""
|
2016-07-31 17:18:17 +02:00
|
|
|
|
|
|
|
webinterface = False
|
|
|
|
|
2016-03-16 10:16:56 +01:00
|
|
|
def __init__(self, input=None, webargs=False):
|
2016-03-08 18:04:49 +01:00
|
|
|
Boxes.__init__(self)
|
2016-11-01 14:03:07 +01:00
|
|
|
self.addSettingsArgs(boxes.edges.FingerJointSettings)
|
2016-07-09 22:52:48 +02:00
|
|
|
self.buildArgParser("h", "hi", "outside")
|
2016-03-16 10:16:56 +01:00
|
|
|
if not webargs:
|
|
|
|
self.argparser.add_argument(
|
2016-08-17 15:07:41 +02:00
|
|
|
"--input", action="store", type=argparse.FileType('r'),
|
2016-03-16 10:16:56 +01:00
|
|
|
help="layout file")
|
|
|
|
self.argparser.add_argument(
|
2016-08-17 15:07:41 +02:00
|
|
|
"--x", action="store", type=int, default=None,
|
2016-03-16 10:16:56 +01:00
|
|
|
help="number of compartments side by side")
|
|
|
|
self.argparser.add_argument(
|
2016-08-17 15:07:41 +02:00
|
|
|
"--y", action="store", type=int, default=None,
|
2016-03-16 10:16:56 +01:00
|
|
|
help="number of compartments back to front")
|
|
|
|
else:
|
|
|
|
self.argparser.add_argument(
|
2016-08-17 15:07:41 +02:00
|
|
|
"--layout", action="store", type=str)
|
2016-03-08 18:04:49 +01:00
|
|
|
|
|
|
|
def fillDefault(self, x, y):
|
|
|
|
self.x = [0.0] * x
|
|
|
|
self.y = [0.0] * y
|
2016-08-17 15:07:41 +02:00
|
|
|
self.hwalls = [[True for i in range(x)] for j in range(y + 1)]
|
|
|
|
self.vwalls = [[True for i in range(x + 1)] for j in range(y)]
|
2016-03-08 18:04:49 +01:00
|
|
|
self.floors = [[True for i in range(x)] for j in range(y)]
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
def __str__(self):
|
|
|
|
r = []
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
for i, x in enumerate(self.x):
|
|
|
|
r.append(" |" * (i) + " ,> %.1fmm\n" % x)
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
for hwalls, vwalls, floors, y in zip(
|
|
|
|
self.hwalls, self.vwalls, self.floors, self.y):
|
2016-08-17 15:07:41 +02:00
|
|
|
r.append("".join(("+" + " -"[h] for h in hwalls)) + "+\n")
|
2016-03-08 18:04:49 +01:00
|
|
|
r.append("".join((" |"[v] + "X "[f] for v, f in zip(vwalls, floors)))
|
2016-08-17 15:07:41 +02:00
|
|
|
+ " |"[vwalls[-1]] + " %.1fmm\n" % y)
|
2016-03-08 18:04:49 +01:00
|
|
|
r.append("".join(("+" + " -"[h] for h in self.hwalls[-1])) + "+\n")
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
return "".join(r)
|
|
|
|
|
|
|
|
def vWalls(self, x, y):
|
|
|
|
"Number of vertical walls at a crossing"
|
|
|
|
result = 0
|
2016-08-17 15:07:41 +02:00
|
|
|
if y > 0 and self.vwalls[y - 1][x]:
|
2016-03-08 18:04:49 +01:00
|
|
|
result += 1
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
if y < len(self.y) and self.vwalls[y][x]:
|
|
|
|
result += 1
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
return result
|
|
|
|
|
|
|
|
def hWalls(self, x, y):
|
|
|
|
"Number of horizontal walls at a crossing"
|
|
|
|
result = 0
|
2016-08-17 15:07:41 +02:00
|
|
|
if x > 0 and self.hwalls[y][x - 1]:
|
2016-03-08 18:04:49 +01:00
|
|
|
result += 1
|
2016-08-17 15:07:41 +02:00
|
|
|
if x < len(self.x) and self.hwalls[y][x]:
|
2016-03-08 18:04:49 +01:00
|
|
|
result += 1
|
|
|
|
return result
|
|
|
|
|
2016-04-17 18:08:09 +02:00
|
|
|
def vFloor(self, x, y):
|
|
|
|
"Is there floor under vertical wall"
|
2016-08-17 15:07:41 +02:00
|
|
|
return ((x > 0 and self.floors[y][x - 1]) or
|
|
|
|
(x < len(self.x) and self.floors[y][x]))
|
2016-04-17 18:08:09 +02:00
|
|
|
|
|
|
|
def hFloor(self, x, y):
|
|
|
|
"Is there foor under horizontal wall"
|
2016-08-17 15:07:41 +02:00
|
|
|
return ((y > 0 and self.floors[y - 1][x]) or
|
|
|
|
(y < len(self.y) and self.floors[y][x]))
|
2016-04-17 18:08:09 +02:00
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
@restore
|
|
|
|
def edgeAt(self, edge, x, y, length, angle=0):
|
|
|
|
self.moveTo(x, y, angle)
|
|
|
|
edge = self.edges.get(edge, edge)
|
|
|
|
edge(length)
|
|
|
|
|
|
|
|
def render(self):
|
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-08-17 15:07:41 +02:00
|
|
|
|
2016-07-09 22:52:48 +02:00
|
|
|
if self.hi:
|
|
|
|
self.hi = self.adjustSize(self.hi, e2=False)
|
2016-03-08 18:04:49 +01:00
|
|
|
|
|
|
|
self.hi = hi = self.hi or self.h
|
|
|
|
|
|
|
|
lx = len(self.x)
|
|
|
|
ly = len(self.y)
|
|
|
|
t = self.thickness
|
|
|
|
t2 = self.thickness / 2.0
|
2016-04-19 09:49:58 +02:00
|
|
|
|
|
|
|
hasfloor = False
|
|
|
|
|
|
|
|
for line in self.floors:
|
|
|
|
for f in line:
|
|
|
|
hasfloor |= f
|
|
|
|
|
2016-06-07 20:20:35 +02:00
|
|
|
self.open()
|
2016-04-19 09:49:58 +02:00
|
|
|
|
2016-08-17 15:07:41 +02:00
|
|
|
self.edges["s"] = boxes.edges.Slot(self, self.hi / 2.0)
|
2016-04-19 09:49:58 +02:00
|
|
|
self.edges["C"] = boxes.edges.CrossingFingerHoleEdge(self, self.hi)
|
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
self.ctx.save()
|
|
|
|
|
|
|
|
# Horizontal Walls
|
2016-04-18 17:41:26 +02:00
|
|
|
for y in range(ly + 1):
|
2016-03-08 18:04:49 +01:00
|
|
|
if y == 0 or y == ly:
|
|
|
|
h = self.h
|
|
|
|
else:
|
|
|
|
h = self.hi
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
start = 0
|
|
|
|
end = 0
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
while end < lx:
|
|
|
|
lengths = []
|
|
|
|
edges = []
|
2016-08-17 15:07:41 +02:00
|
|
|
|
|
|
|
while start < lx and not self.hwalls[y][start]:
|
|
|
|
start += 1
|
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
if start == lx:
|
|
|
|
break
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
end = start
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
while end < lx and self.hwalls[y][end]:
|
2016-04-17 18:08:09 +02:00
|
|
|
if self.hFloor(end, y):
|
|
|
|
edges.append("f")
|
|
|
|
else:
|
2016-08-17 15:07:41 +02:00
|
|
|
edges.append("e") # XXX E?
|
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
lengths.append(self.x[end])
|
2016-08-17 15:07:41 +02:00
|
|
|
edges.append("eCs"[self.vWalls(end + 1, y)])
|
2016-03-08 18:04:49 +01:00
|
|
|
lengths.append(self.thickness)
|
|
|
|
end += 1
|
|
|
|
|
|
|
|
# remove last "slot"
|
|
|
|
lengths.pop()
|
|
|
|
edges.pop()
|
|
|
|
self.rectangularWall(sum(lengths), h, [
|
2016-03-25 14:02:52 +01:00
|
|
|
boxes.edges.CompoundEdge(self, edges, lengths),
|
2016-03-08 18:04:49 +01:00
|
|
|
"f" if self.vWalls(end, y) else "e",
|
|
|
|
"e",
|
|
|
|
"f" if self.vWalls(start, y) else "e"],
|
|
|
|
move="right")
|
|
|
|
start = end
|
|
|
|
|
|
|
|
self.ctx.restore()
|
|
|
|
self.rectangularWall(10, h, "ffef", move="up only")
|
|
|
|
self.ctx.save()
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
# Vertical Walls
|
2016-04-18 17:41:26 +02:00
|
|
|
for x in range(lx + 1):
|
2016-03-08 18:04:49 +01:00
|
|
|
if x == 0 or x == lx:
|
|
|
|
h = self.h
|
|
|
|
else:
|
|
|
|
h = self.hi
|
|
|
|
start = 0
|
|
|
|
end = 0
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
while end < ly:
|
|
|
|
lengths = []
|
|
|
|
edges = []
|
2016-08-17 15:07:41 +02:00
|
|
|
while start < ly and not self.vwalls[start][x]:
|
|
|
|
start += 1
|
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
if start == ly:
|
|
|
|
break
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
end = start
|
2016-08-17 15:07:41 +02:00
|
|
|
|
|
|
|
while end < ly and self.vwalls[end][x]:
|
2016-04-17 18:08:09 +02:00
|
|
|
if self.vFloor(x, end):
|
|
|
|
edges.append("f")
|
|
|
|
else:
|
2016-08-17 15:07:41 +02:00
|
|
|
edges.append("e") # XXX E?
|
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
lengths.append(self.y[end])
|
2016-08-17 15:07:41 +02:00
|
|
|
edges.append("eCs"[self.hWalls(x, end + 1)])
|
2016-03-08 18:04:49 +01:00
|
|
|
lengths.append(self.thickness)
|
|
|
|
end += 1
|
|
|
|
# remove last "slot"
|
|
|
|
lengths.pop()
|
|
|
|
edges.pop()
|
|
|
|
|
|
|
|
upper = [{
|
2016-08-17 15:07:41 +02:00
|
|
|
"f": "e",
|
|
|
|
"s": "s",
|
|
|
|
"e": "e",
|
|
|
|
"E": "e",
|
|
|
|
"C": "e"}[e] for e in reversed(edges)]
|
2016-03-08 18:04:49 +01:00
|
|
|
edges = ["e" if e == "s" else e for e in edges]
|
|
|
|
self.rectangularWall(sum(lengths), h, [
|
2016-03-25 14:02:52 +01:00
|
|
|
boxes.edges.CompoundEdge(self, edges, lengths),
|
2016-03-08 18:04:49 +01:00
|
|
|
"eFf"[self.hWalls(x, end)],
|
2016-03-25 14:02:52 +01:00
|
|
|
boxes.edges.CompoundEdge(self, upper, list(reversed(lengths))),
|
2016-08-17 15:07:41 +02:00
|
|
|
"eFf"[self.hWalls(x, start)]],
|
|
|
|
move="right")
|
2016-03-08 18:04:49 +01:00
|
|
|
start = end
|
|
|
|
|
|
|
|
self.ctx.restore()
|
|
|
|
self.rectangularWall(10, h, "ffef", move="up only")
|
2016-08-17 15:07:41 +02:00
|
|
|
self.moveTo(2 * self.thickness, 2 * self.thickness)
|
2016-03-08 18:04:49 +01:00
|
|
|
self.ctx.save()
|
|
|
|
|
|
|
|
##########################################################
|
|
|
|
### Baseplate
|
|
|
|
##########################################################
|
|
|
|
|
|
|
|
# Horizontal lines
|
|
|
|
posy = 0
|
|
|
|
for y in range(ly, -1, -1):
|
|
|
|
posx = self.thickness
|
|
|
|
for x in range(lx):
|
|
|
|
if self.hwalls[y][x]:
|
|
|
|
e = "F"
|
|
|
|
else:
|
|
|
|
e = "e"
|
|
|
|
if y < ly and self.floors[y][x]:
|
2016-08-17 15:07:41 +02:00
|
|
|
if y > 0 and self.floors[y - 1][x]:
|
2016-03-08 18:04:49 +01:00
|
|
|
# Inside Wall
|
|
|
|
if self.hwalls[y][x]:
|
2016-08-17 15:07:41 +02:00
|
|
|
self.fingerHolesAt(posx, posy + t2, self.x[x], angle=0)
|
2016-03-08 18:04:49 +01:00
|
|
|
else:
|
|
|
|
# Top edge
|
2016-08-17 15:07:41 +02:00
|
|
|
self.edgeAt(e, posx + self.x[x], posy + t, self.x[x],
|
2016-03-08 18:04:49 +01:00
|
|
|
-180)
|
2016-08-17 15:07:41 +02:00
|
|
|
if x == 0 or y == 0 or not self.floors[y - 1][x - 1]:
|
|
|
|
self.edgeAt("e", posx, posy + t, t, -180)
|
|
|
|
if x == lx - 1 or y == 0 or not self.floors[y - 1][x + 1]:
|
|
|
|
self.edgeAt("e", posx + self.x[x] + t, posy + t, t, -180)
|
|
|
|
elif y > 0 and self.floors[y - 1][x]:
|
2016-03-08 18:04:49 +01:00
|
|
|
# Bottom Edge
|
|
|
|
self.edgeAt(e, posx, posy, self.x[x])
|
2016-08-17 15:07:41 +02:00
|
|
|
if x == 0 or y == ly or not self.floors[y][x - 1]:
|
|
|
|
self.edgeAt("e", posx - t, posy, t)
|
|
|
|
if x == lx - 1 or y == ly or not self.floors[y][x + 1]:
|
|
|
|
self.edgeAt("e", posx + self.x[x], posy, t)
|
|
|
|
posx += self.x[x] + self.thickness
|
|
|
|
posy += self.y[y - 1] + self.thickness
|
2016-03-08 18:04:49 +01:00
|
|
|
|
|
|
|
posx = 0
|
2016-08-17 15:07:41 +02:00
|
|
|
for x in range(lx + 1):
|
2016-03-08 18:04:49 +01:00
|
|
|
posy = self.thickness
|
2016-08-17 15:07:41 +02:00
|
|
|
for y in range(ly - 1, -1, -1):
|
2016-03-08 18:04:49 +01:00
|
|
|
if self.vwalls[y][x]:
|
|
|
|
e = "F"
|
|
|
|
else:
|
|
|
|
e = "e"
|
2016-08-17 15:07:41 +02:00
|
|
|
if x > 0 and self.floors[y][x - 1]:
|
2016-03-08 18:04:49 +01:00
|
|
|
if x < lx and self.floors[y][x]:
|
|
|
|
# Inside wall
|
|
|
|
if self.vwalls[y][x]:
|
2016-08-17 15:07:41 +02:00
|
|
|
self.fingerHolesAt(posx + t2, posy, self.y[y])
|
2016-03-08 18:04:49 +01:00
|
|
|
else:
|
|
|
|
# Right edge
|
2016-08-17 15:07:41 +02:00
|
|
|
self.edgeAt(e, posx + t, posy, self.y[y], 90)
|
|
|
|
if x == lx or y == 0 or not self.floors[y - 1][x]:
|
|
|
|
self.edgeAt("e", posx + t, posy + self.y[y], t, 90)
|
|
|
|
if x == lx or y == ly - 1 or not self.floors[y + 1][x]:
|
|
|
|
self.edgeAt("e", posx + t, posy - t, t, 90)
|
2016-03-08 18:04:49 +01:00
|
|
|
elif x < lx and self.floors[y][x]:
|
|
|
|
# Left edge
|
2016-08-17 15:07:41 +02:00
|
|
|
self.edgeAt(e, posx, posy + self.y[y], self.y[y], -90)
|
|
|
|
if x == 0 or y == 0 or not self.floors[y - 1][x - 1]:
|
|
|
|
self.edgeAt("e", posx, posy + self.y[y] + t, t, -90)
|
|
|
|
if x == 0 or y == ly - 1 or not self.floors[y + 1][x - 1]:
|
2016-04-18 17:41:31 +02:00
|
|
|
self.edgeAt("e", posx, posy, t, -90)
|
2016-03-08 18:04:49 +01:00
|
|
|
posy += self.y[y] + self.thickness
|
|
|
|
if x < lx:
|
|
|
|
posx += self.x[x] + self.thickness
|
|
|
|
|
|
|
|
self.close()
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
def parse(self, input):
|
|
|
|
x = []
|
|
|
|
y = []
|
|
|
|
hwalls = []
|
|
|
|
vwalls = []
|
|
|
|
floors = []
|
|
|
|
for line in input:
|
2016-03-16 10:16:56 +01:00
|
|
|
if not line or line[0] == "#":
|
2016-03-08 18:04:49 +01:00
|
|
|
continue
|
|
|
|
m = re.match(r"( \|)* ,>\s*(\d*\.?\d+)\s*mm\s*", line)
|
|
|
|
if m:
|
|
|
|
x.append(float(m.group(2)))
|
|
|
|
continue
|
|
|
|
if line[0] == '+':
|
|
|
|
w = []
|
|
|
|
for n, c in enumerate(line):
|
|
|
|
if n % 2:
|
|
|
|
if c == ' ':
|
|
|
|
w.append(False)
|
|
|
|
elif c == '-':
|
|
|
|
w.append(True)
|
|
|
|
else:
|
|
|
|
pass
|
2016-08-17 15:07:41 +02:00
|
|
|
# raise ValueError(line)
|
2016-03-08 18:04:49 +01:00
|
|
|
else:
|
|
|
|
if c != '+':
|
|
|
|
pass
|
2016-08-17 15:07:41 +02:00
|
|
|
# raise ValueError(line)
|
2016-03-08 18:04:49 +01:00
|
|
|
|
|
|
|
hwalls.append(w)
|
|
|
|
if line[0] in " |":
|
|
|
|
w = []
|
|
|
|
f = []
|
2016-08-17 15:07:41 +02:00
|
|
|
for n, c in enumerate(line[:len(x) * 2 + 1]):
|
2016-03-08 18:04:49 +01:00
|
|
|
if n % 2:
|
|
|
|
if c == 'X':
|
|
|
|
f.append(False)
|
|
|
|
elif c == ' ':
|
|
|
|
f.append(True)
|
|
|
|
else:
|
|
|
|
raise ValueError(line)
|
|
|
|
else:
|
|
|
|
if c == ' ':
|
|
|
|
w.append(False)
|
|
|
|
elif c == '|':
|
|
|
|
w.append(True)
|
|
|
|
else:
|
|
|
|
raise ValueError(line)
|
|
|
|
|
|
|
|
floors.append(f)
|
|
|
|
vwalls.append(w)
|
|
|
|
m = re.match(r"([ |][ X])+[ |]\s*(\d*\.?\d+)\s*mm\s*", line)
|
|
|
|
if not m:
|
|
|
|
raise ValueError(line)
|
|
|
|
else:
|
|
|
|
y.append(float(m.group(2)))
|
|
|
|
|
|
|
|
# check sizes
|
|
|
|
lx = len(x)
|
|
|
|
ly = len(y)
|
2016-08-17 15:07:41 +02:00
|
|
|
if len(hwalls) != ly + 1:
|
|
|
|
raise ValueError("Wrong number of horizontal wall lines: %i (%i expected)" % (len(hwalls), ly + 1))
|
2016-03-08 18:04:49 +01:00
|
|
|
for nr, walls in enumerate(hwalls):
|
2016-08-17 15:07:41 +02:00
|
|
|
if len(walls) != lx:
|
2016-03-08 18:04:49 +01:00
|
|
|
raise ValueError("Wrong number of horizontal walls in line %i: %i (%i expected)" % (nr, len(walls), lx))
|
|
|
|
if len(vwalls) != ly:
|
|
|
|
raise ValueError("Wrong number of vertical wall lines: %i (%i expected)" % (len(vwalls), ly))
|
|
|
|
for nr, walls in enumerate(vwalls):
|
2016-08-17 15:07:41 +02:00
|
|
|
if len(walls) != lx + 1:
|
|
|
|
raise ValueError(
|
|
|
|
"Wrong number of vertical walls in line %i: %i (%i expected)" % (nr, len(walls), lx + 1))
|
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
self.x = x
|
|
|
|
self.y = y
|
|
|
|
self.hwalls = hwalls
|
|
|
|
self.vwalls = vwalls
|
|
|
|
self.floors = floors
|
2016-03-16 10:16:56 +01:00
|
|
|
|
2016-04-02 18:02:00 +02:00
|
|
|
|
2016-08-17 15:07:41 +02:00
|
|
|
class TrayLayout(Layout):
|
2016-04-02 18:02:00 +02:00
|
|
|
"""Type tray with each wall and floor tile being optional"""
|
|
|
|
|
2016-07-31 17:18:17 +02:00
|
|
|
webinterface = True
|
|
|
|
|
2016-03-16 10:16:56 +01:00
|
|
|
def __init__(self):
|
|
|
|
Boxes.__init__(self)
|
|
|
|
self.argparser = boxes.ArgumentParser()
|
|
|
|
self.argparser.add_argument(
|
2016-08-17 15:07:41 +02:00
|
|
|
"--x", action="store", type=int, default=2,
|
2016-03-16 10:16:56 +01:00
|
|
|
help="number of compartments side by side")
|
|
|
|
self.argparser.add_argument(
|
2016-08-17 15:07:41 +02:00
|
|
|
"--y", action="store", type=int, default=2,
|
2016-03-16 10:16:56 +01:00
|
|
|
help="number of compartments back to front")
|
|
|
|
|
|
|
|
def render(self):
|
|
|
|
return
|
|
|
|
|
2016-07-31 17:18:17 +02:00
|
|
|
|
2016-08-17 15:07:41 +02:00
|
|
|
class TrayLayout2(Layout):
|
2016-07-31 17:18:17 +02:00
|
|
|
"""Generate a typetray from a layout file"""
|
|
|
|
|
|
|
|
webinterface = True
|
|
|
|
|
|
|
|
def __init__(self, input=None):
|
|
|
|
Boxes.__init__(self)
|
2016-11-01 14:03:07 +01:00
|
|
|
self.addSettingsArgs(boxes.edges.FingerJointSettings)
|
2016-07-31 17:18:17 +02:00
|
|
|
self.buildArgParser("h", "hi", "outside")
|
|
|
|
self.argparser.add_argument(
|
2016-08-17 15:07:41 +02:00
|
|
|
"--layout", action="store", type=str)
|
|
|
|
|
2016-07-31 17:18:17 +02:00
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
def main():
|
|
|
|
l = Layout()
|
|
|
|
l.parseArgs()
|
|
|
|
if l.x and l.y:
|
|
|
|
l.fillDefault(l.x, l.y)
|
2016-03-28 12:16:06 +02:00
|
|
|
if l.output:
|
|
|
|
with open(l.output, "w") as f:
|
|
|
|
f.write(str(l))
|
|
|
|
else:
|
|
|
|
print(l)
|
2016-03-08 18:04:49 +01:00
|
|
|
elif l.input:
|
|
|
|
l.parse(l.input)
|
|
|
|
l.render()
|
|
|
|
else:
|
|
|
|
l.argparser.print_usage()
|
|
|
|
|
2016-08-17 15:07:41 +02:00
|
|
|
|
2016-03-08 18:04:49 +01:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|