New generator: ABox

A simple box that is easier to use for beginners than the UniversalBox

Related: #356
This commit is contained in:
Florian Festi 2022-01-07 11:05:16 +01:00
parent 64448d7902
commit 83fc970d7c
1 changed files with 65 additions and 0 deletions

65
boxes/generators/abox.py Normal file
View File

@ -0,0 +1,65 @@
#!/usr/bin/env python3
# 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/>.
from boxes import *
class ABox(Boxes):
"""A simple Box"""
description = "This box is kept simple on purpose. If you need more features have a look at the UniversalBox."
ui_group = "Box"
def __init__(self):
Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
self.buildArgParser("x", "y", "h", "outside", "bottom_edge")
#self.argparser.add_argument(
# "--lid", action="store", type=str, default="default (none)",
# choices=("default (none)", "chest", "flat"),
# help="additional lid (for straight top_edge only)")
def render(self):
x, y, h = self.x, self.y, self.h
t = self.thickness
t1, t2, t3, t4 = "eeee"
b = self.edges.get(self.bottom_edge, self.edges["F"])
sideedge = "F" # if self.vertical_edges == "finger joints" else "h"
if self.outside:
self.x = x = self.adjustSize(x, sideedge, sideedge)
self.y = y = self.adjustSize(y)
self.h = h = self.adjustSize(h, b, t1)
with self.saved_context():
self.rectangularWall(x, h, [b, sideedge, t1, sideedge],
ignore_widths=[1, 6], move="up")
self.rectangularWall(x, h, [b, sideedge, t3, sideedge],
ignore_widths=[1, 6], move="up")
if self.bottom_edge != "e":
self.rectangularWall(x, y, "ffff", move="up")
#self.drawAddOnLid(x, y, self.lid)
self.rectangularWall(x, h, [b, sideedge, t3, sideedge],
ignore_widths=[1, 6], move="right only")
self.rectangularWall(y, h, [b, "f", t2, "f"],
ignore_widths=[1, 6], move="up")
self.rectangularWall(y, h, [b, "f", t4, "f"],
ignore_widths=[1, 6], move="up")