From 83fc970d7c3d7c0c9c5fb20b27a0cdba81d8272a Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Fri, 7 Jan 2022 11:05:16 +0100 Subject: [PATCH] New generator: ABox A simple box that is easier to use for beginners than the UniversalBox Related: #356 --- boxes/generators/abox.py | 65 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 boxes/generators/abox.py diff --git a/boxes/generators/abox.py b/boxes/generators/abox.py new file mode 100644 index 0000000..93e1b0e --- /dev/null +++ b/boxes/generators/abox.py @@ -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 . + +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") + +