Slatwall Edges: Redimentary DIN rail support

Added type parameter to SlatwallSettings
This commit is contained in:
Florian Festi 2022-02-11 19:17:40 +01:00
parent b8c8a9ec8d
commit 7eca5a6c05
1 changed files with 46 additions and 16 deletions

View File

@ -2262,6 +2262,7 @@ Values:
""" """
absolute_params = { absolute_params = {
"type" : ("slatwall", "dinrail"),
"bottom_hook" : ("hook", "spring", "stud", "none"), "bottom_hook" : ("hook", "spring", "stud", "none"),
"pitch" : 101.6, "pitch" : 101.6,
"hook_depth" : 4.0, "hook_depth" : 4.0,
@ -2291,19 +2292,28 @@ class SlatWallEdge(BaseEdge):
reversed_ = False reversed_ = False
def _top_hook(self, reversed_=False): def _top_hook(self, reversed_=False):
w = 6 # vertical width of hook if self.settings.type == "slatwall":
hd = self.settings.hook_depth w = 6 # vertical width of hook
ro = 6 # outer radius hd = self.settings.hook_depth
ri = 2 # inner radius ro = 6 # outer radius
rt = min(1, hd/2) # top radius ri = 2 # inner radius
poly = [0, -90, 5.5-ri, (-90, ri), 12-ri-w-rt, (90, rt), rt = min(1, hd/2) # top radius
hd-2*rt, (90, rt), 12-ro-rt, (90, ro), 5.5+hd-ro, -90, poly = [0, -90, 5.5-ri, (-90, ri), 12-ri-w-rt, (90, rt),
self.settings.hook_extra_height] hd-2*rt, (90, rt), 12-ro-rt, (90, ro), 5.5+hd-ro, -90,
self.settings.hook_extra_height]
else:
r = 1.
poly = [0, -90, 7.5-r, (90, r), 15+3-2*r, (90, r), 6-2*r, (90, r),
3-r, -90, 1.5, -90, 5+self.settings.hook_extra_height]
if reversed_: if reversed_:
poly = reversed(poly) poly = reversed(poly)
self.polyline(*poly) self.polyline(*poly)
def _top_hook_len(self): def _top_hook_len(self):
if self.settings.type == "dinrail":
return (20, self.settings.hook_extra_height)
w = 6 + 1 w = 6 + 1
return (w, self.settings.hook_extra_height - 1) return (w, self.settings.hook_extra_height - 1)
@ -2311,7 +2321,16 @@ class SlatWallEdge(BaseEdge):
slot = 8 slot = 8
hd = self.settings.hook_depth hd = self.settings.hook_depth
if self.settings.bottom_hook == "spring": if self.settings.type == "dinrail":
slot = 20
if self.settings.bottom_hook == "stud":
r = 1.
poly = [0, -90, 7.5-r, (90, r),
slot - 2*r + 2*self.settings.hook_extra_height,
(90, r), 7.5-r, -90, 0]
else:
poly = [2*self.settings.hook_extra_height + slot]
elif self.settings.bottom_hook == "spring":
r_plug = slot*.4 r_plug = slot*.4
slotslot = slot - r_plug * 2**0.5 slotslot = slot - r_plug * 2**0.5
poly = [self.settings.hook_extra_height, -90, poly = [self.settings.hook_extra_height, -90,
@ -2336,6 +2355,9 @@ class SlatWallEdge(BaseEdge):
self.polyline(*poly) self.polyline(*poly)
def _bottom_hook_len(self): def _bottom_hook_len(self):
if self.settings.type == "dinrail":
return (20 + self.settings.hook_extra_height,
self.settings.hook_extra_height)
slot = 8 slot = 8
return (slot + self.settings.hook_extra_height, return (slot + self.settings.hook_extra_height,
self.settings.hook_extra_height) self.settings.hook_extra_height)
@ -2348,13 +2370,21 @@ class SlatWallEdge(BaseEdge):
tht, thb = self._top_hook_len() tht, thb = self._top_hook_len()
bht, bhb = self._bottom_hook_len() bht, bhb = self._bottom_hook_len()
if (length >= pitch + tht + bhb and if self.settings.type == "dinrail":
self.settings.bottom_hook != "none"): if length >= tht + thb + bht + bhb:
top_len = ((length-tht-1) // pitch) * pitch - thb - bht top_len = length - (tht + thb + bht + bhb)
bottom_len = (length-tht) % pitch - bhb bottom_len = 0
else: else:
top_len = length-tht-thb top_len = length - (tht + thb)
bottom_len = None bottom_len = None
else: # slatwall
if (length >= pitch + tht + bhb and
self.settings.bottom_hook != "none"):
top_len = ((length-tht-1) // pitch) * pitch - thb - bht
bottom_len = (length-tht) % pitch - bhb
else:
top_len = length-tht-thb
bottom_len = None
if self.reversed_: if self.reversed_:
if bottom_len is not None: if bottom_len is not None: