boxespy/boxes/generators/abox.py

64 lines
2.4 KiB
Python
Raw Normal View History

#!/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 *
from boxes.lids import LidSettings
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"
2023-01-08 19:41:02 +01:00
def __init__(self) -> None:
Boxes.__init__(self)
self.addSettingsArgs(edges.FingerJointSettings)
self.addSettingsArgs(LidSettings)
self.buildArgParser("x", "y", "h", "outside", "bottom_edge")
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.lid(x, y)
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")