NotesHolder: Move to sx parameter
to allow multiple compartments
This commit is contained in:
parent
0d51f56916
commit
e1677ced62
|
@ -15,13 +15,14 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from boxes import *
|
||||
from boxes.edges import Edge
|
||||
from boxes.edges import Edge, CompoundEdge
|
||||
|
||||
class USlotEdge(Edge):
|
||||
|
||||
def __call__(self, length, bedBolts=None, bedBoltSettings=None, **kw):
|
||||
l = length
|
||||
d = self.settings
|
||||
o = self.settings
|
||||
d = length * (1-o/100) / 2
|
||||
r = min(3*self.thickness, (l-2*d)/2)
|
||||
self.edges["f"](d)
|
||||
self.polyline(0, 90, 0, (-90, r), l-2*d-2*r, (-90, r), 0, 90)
|
||||
|
@ -61,14 +62,25 @@ class NotesHolder(Boxes):
|
|||
Boxes.__init__(self)
|
||||
self.addSettingsArgs(edges.FingerJointSettings, surroundingspaces=1)
|
||||
self.addSettingsArgs(edges.StackableSettings)
|
||||
self.buildArgParser(x=78, y=78, h=35, bottom_edge="s")
|
||||
self.buildArgParser(sx="78", y=78, h=35, bottom_edge="s")
|
||||
self.argparser.add_argument(
|
||||
"--opening", action="store", type=float, default=40,
|
||||
help="percent of front that's open")
|
||||
|
||||
def render(self):
|
||||
x, y, h = self.x, self.y, self.h
|
||||
def fingerHoleCB(self, lengths, height, posy=0.0):
|
||||
def CB():
|
||||
t = self.thickness
|
||||
px = -0.5 * t
|
||||
for x in lengths[:-1]:
|
||||
px += x + t
|
||||
self.fingerHolesAt(px, posy, height, 90)
|
||||
return CB
|
||||
|
||||
def render(self):
|
||||
sx, y, h = self.sx, self.y, self.h
|
||||
t = self.thickness
|
||||
|
||||
x = sum(sx) + (len(sx) - 1) * t
|
||||
|
||||
o = max(0, min(self.opening, 100))
|
||||
sides = x * (1-o/100) / 2
|
||||
|
@ -77,19 +89,39 @@ class NotesHolder(Boxes):
|
|||
if self.bottom_edge == "s":
|
||||
b2 = HalfStackableEdge(self, self.edges["s"].settings,
|
||||
self.edges["f"].settings)
|
||||
b3 = self.edges["h"]
|
||||
else:
|
||||
b2 = b
|
||||
b3 = b
|
||||
|
||||
b4 = Edge(self, None)
|
||||
b4.startwidth = lambda: b3.startwidth()
|
||||
|
||||
with self.saved_context():
|
||||
self.rectangularWall(y, h, [b, "F", "e", "F"],
|
||||
ignore_widths=[1, 6], move="right")
|
||||
# front walls
|
||||
if self.opening == 0.0:
|
||||
self.rectangularWall(x, h, [b, "f", "e", "f"],
|
||||
ignore_widths=[1, 6], move="right")
|
||||
else:
|
||||
self.rectangularWall(sides, h, [b2, "e", "e", "f"],
|
||||
self.rectangularWall(sx[0] * (1-o/100) / 2, h,
|
||||
[b2, "e", "e", "f"],
|
||||
ignore_widths=[1, 6], move="right")
|
||||
self.rectangularWall(sides, h, [b2, "e", "e", "f"],
|
||||
for ix in range(len(sx)-1):
|
||||
left = sx[ix] * (1-o/100) / 2
|
||||
right = sx[ix+1] * (1-o/100) / 2
|
||||
h_e = t
|
||||
bottom_edge = CompoundEdge(
|
||||
self, [b3, b4, b3], [left, t, right])
|
||||
self.rectangularWall(
|
||||
left+right+t, h,
|
||||
[bottom_edge, "e", "e", "e"],
|
||||
callback=[lambda: self.fingerHolesAt(left+t/2, 0, h, 90)],
|
||||
move="right")
|
||||
|
||||
self.rectangularWall(sx[-1] * (1-o/100) / 2, h,
|
||||
[b2, "e", "e", "f"],
|
||||
ignore_widths=[1, 6], move="right mirror")
|
||||
|
||||
self.rectangularWall(x, h, [b, "F", "e", "F"],
|
||||
|
@ -97,12 +129,26 @@ class NotesHolder(Boxes):
|
|||
|
||||
with self.saved_context():
|
||||
self.rectangularWall(y, h, [b, "F", "e", "F"], ignore_widths=[1, 6], move="right")
|
||||
self.rectangularWall(x, h, [b, "f", "e", "f"], ignore_widths=[1, 6], move="right")
|
||||
self.rectangularWall(x, h, [b, "f", "e", "f"],
|
||||
callback=[self.fingerHoleCB(sx, h)],
|
||||
ignore_widths=[1, 6], move="right")
|
||||
self.rectangularWall(y, h, [b, "F", "e", "F"], move="up only")
|
||||
|
||||
if self.bottom_edge != "e":
|
||||
if self.opening == 0.0:
|
||||
self.rectangularWall(x, y, ["f", "f", "f", "f"], move="up")
|
||||
else:
|
||||
self.rectangularWall(x, y, [USlotEdge(self, sides), "f", "f", "f"], move="up")
|
||||
|
||||
u_edge = USlotEdge(self, o)
|
||||
print([l for x in sx for l in (x, t)])
|
||||
front = CompoundEdge(
|
||||
self,
|
||||
([u_edge, "e"]*len(sx))[:-1],
|
||||
([l for x in sx for l in (x, t)])[:-1])
|
||||
self.rectangularWall(x, y, [front, "f", "f", "f"],
|
||||
callback=[self.fingerHoleCB(sx, y)],
|
||||
move="up")
|
||||
# innner walls
|
||||
for i in range(len(sx)-1):
|
||||
self.rectangularWall(
|
||||
y, h, ("e" if self.bottom_edge=="e" else "f") + "fef",
|
||||
move="right")
|
||||
|
|
Loading…
Reference in New Issue