2022-09-05 17:42:47 -07:00
|
|
|
import { sidepanel } from './sidepanel.mjs'
|
|
|
|
|
2022-09-11 14:34:00 +02:00
|
|
|
function draftHortensiaFrontpanel({
|
|
|
|
store,
|
|
|
|
options,
|
|
|
|
Point,
|
|
|
|
Path,
|
|
|
|
points,
|
|
|
|
paths,
|
|
|
|
Snippet,
|
|
|
|
snippets,
|
|
|
|
complete,
|
|
|
|
sa,
|
|
|
|
paperless,
|
|
|
|
macro,
|
|
|
|
part,
|
|
|
|
}) {
|
2021-01-31 09:22:15 +01:00
|
|
|
let w = store.get('frontPanelLength')
|
|
|
|
let h = store.get('depth')
|
2021-01-30 13:15:25 +01:00
|
|
|
|
2021-01-31 09:22:15 +01:00
|
|
|
points.topLeft = new Point(0, 0)
|
|
|
|
points.topRight = new Point(w, 0)
|
|
|
|
points.bottomLeft = new Point(0, h)
|
|
|
|
points.bottomRight = new Point(w, h)
|
2021-01-30 13:15:25 +01:00
|
|
|
|
|
|
|
paths.bottom = new Path()
|
|
|
|
.move(points.topLeft)
|
|
|
|
.line(points.bottomLeft)
|
|
|
|
.attr('data-text', 'Bottom')
|
2021-01-31 09:22:15 +01:00
|
|
|
.attr('data-text-class', 'center text-xs')
|
2021-01-30 13:15:25 +01:00
|
|
|
|
|
|
|
paths.top = new Path()
|
|
|
|
.move(points.bottomRight)
|
|
|
|
.line(points.topRight)
|
|
|
|
.attr('data-text', 'Top')
|
2021-01-31 09:22:15 +01:00
|
|
|
.attr('data-text-class', 'center text-xs')
|
2021-01-30 13:15:25 +01:00
|
|
|
|
|
|
|
//paths.seam = new Path()
|
|
|
|
paths.seam = paths.bottom
|
|
|
|
.line(points.bottomRight)
|
|
|
|
.join(paths.top)
|
|
|
|
.line(points.topLeft)
|
|
|
|
.close()
|
2021-01-31 09:22:15 +01:00
|
|
|
.attr('class', 'fabric')
|
2021-01-30 13:15:25 +01:00
|
|
|
|
2021-01-31 09:22:15 +01:00
|
|
|
let pctHandleVert = options.pctHandleVert
|
2021-09-12 18:23:42 +02:00
|
|
|
let handleWidth = options.width * options.handleWidth
|
2021-01-31 09:22:15 +01:00
|
|
|
let handleSpace = (h - handleWidth * 2) * (options.pctHandleSpace / 100)
|
2021-01-30 13:15:25 +01:00
|
|
|
if (handleSpace > options.maxHandleSpaceWidth) {
|
2021-01-31 09:22:15 +01:00
|
|
|
handleSpace = options.maxHandleSpaceWidth
|
2021-01-30 13:15:25 +01:00
|
|
|
} else if (handleSpace < options.minHandleSpaceWidth) {
|
2021-01-31 09:22:15 +01:00
|
|
|
handleSpace = options.minHandleSpaceWidth
|
2021-01-30 13:15:25 +01:00
|
|
|
if (handleSpace < h - handleWidth * 2) {
|
2021-01-31 09:22:15 +01:00
|
|
|
handleSpace = h - handleWidth * 2
|
2021-01-30 13:15:25 +01:00
|
|
|
}
|
|
|
|
}
|
2021-01-31 09:22:15 +01:00
|
|
|
let handleVertPos = w * (pctHandleVert / 100)
|
2021-01-30 13:15:25 +01:00
|
|
|
if (handleVertPos + handleWidth * 2 > w) {
|
2021-01-31 09:22:15 +01:00
|
|
|
handleVertPos = w - handleWidth * 2
|
2021-01-30 13:15:25 +01:00
|
|
|
}
|
|
|
|
|
2021-01-31 09:22:15 +01:00
|
|
|
points.attachPoint1TL = new Point(handleVertPos, 0 + h / 2 - handleSpace / 2)
|
|
|
|
points.attachPoint2TL = new Point(handleVertPos, h - h / 2 + handleSpace / 2 - handleWidth)
|
|
|
|
points.attachPoint2TLtemp = new Point(handleVertPos, h - h / 2 + handleSpace / 2)
|
2021-01-30 13:15:25 +01:00
|
|
|
points.attachPoint1BR = new Point(
|
|
|
|
handleVertPos + handleWidth * 2,
|
|
|
|
0 + h / 2 - handleSpace / 2 + handleWidth
|
2021-01-31 09:22:15 +01:00
|
|
|
)
|
|
|
|
points.attachPoint2BR = new Point(handleVertPos + handleWidth * 2, h - h / 2 + handleSpace / 2)
|
2021-01-30 13:15:25 +01:00
|
|
|
|
2023-03-03 22:13:09 +00:00
|
|
|
macro('crossbox', {
|
2021-01-30 13:15:25 +01:00
|
|
|
from: points.attachPoint1TL,
|
|
|
|
to: points.attachPoint1BR,
|
2021-04-24 10:16:31 +02:00
|
|
|
text: 'attachment',
|
2021-01-31 09:22:15 +01:00
|
|
|
})
|
2021-01-30 13:15:25 +01:00
|
|
|
|
2023-03-03 22:13:09 +00:00
|
|
|
macro('crossbox', {
|
2021-01-30 13:15:25 +01:00
|
|
|
from: points.attachPoint2TL,
|
|
|
|
to: points.attachPoint2BR,
|
2021-04-24 10:16:31 +02:00
|
|
|
text: 'attachment',
|
2021-01-31 09:22:15 +01:00
|
|
|
})
|
2021-01-30 13:15:25 +01:00
|
|
|
|
2023-05-21 07:36:13 -07:00
|
|
|
store.cutlist.addCut()
|
|
|
|
store.cutlist.addCut({ material: 'lining' })
|
|
|
|
|
2021-01-30 13:15:25 +01:00
|
|
|
// Complete?
|
|
|
|
if (complete) {
|
2021-01-31 09:22:15 +01:00
|
|
|
points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5)
|
|
|
|
snippets.logo = new Snippet('logo', points.logo)
|
|
|
|
points.title = points.logo.shift(-90, 50).attr('data-text-class', 'center')
|
2021-01-30 13:15:25 +01:00
|
|
|
|
2021-01-31 09:22:15 +01:00
|
|
|
macro('title', {
|
2021-01-30 13:15:25 +01:00
|
|
|
at: points.title,
|
|
|
|
nr: 2,
|
2021-04-24 10:16:31 +02:00
|
|
|
title: 'FrontBackPanel',
|
2023-09-08 11:48:45 +02:00
|
|
|
align: 'center',
|
2021-01-31 09:22:15 +01:00
|
|
|
})
|
2021-01-30 13:15:25 +01:00
|
|
|
|
|
|
|
if (sa) {
|
2021-01-31 09:22:15 +01:00
|
|
|
paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa')
|
2021-01-30 13:15:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Paperless?
|
|
|
|
if (paperless) {
|
2021-01-31 09:22:15 +01:00
|
|
|
macro('hd', {
|
2021-01-30 13:15:25 +01:00
|
|
|
from: points.bottomLeft,
|
|
|
|
to: points.bottomRight,
|
2021-04-24 10:16:31 +02:00
|
|
|
y: points.bottomLeft.y + sa + 15,
|
2021-01-31 09:22:15 +01:00
|
|
|
})
|
|
|
|
macro('hd', {
|
2021-01-30 13:15:25 +01:00
|
|
|
from: points.topLeft,
|
|
|
|
to: points.attachPoint1TL,
|
2021-04-24 10:16:31 +02:00
|
|
|
y: points.attachPoint1TL.y,
|
2021-01-31 09:22:15 +01:00
|
|
|
})
|
|
|
|
macro('hd', {
|
2021-01-30 13:15:25 +01:00
|
|
|
from: points.topLeft,
|
|
|
|
to: points.attachPoint2TLtemp,
|
2021-04-24 10:16:31 +02:00
|
|
|
y: points.attachPoint2TLtemp.y,
|
2021-01-31 09:22:15 +01:00
|
|
|
})
|
|
|
|
macro('vd', {
|
2021-01-30 13:15:25 +01:00
|
|
|
from: points.bottomRight,
|
|
|
|
to: points.topRight,
|
2021-04-24 10:16:31 +02:00
|
|
|
x: points.topRight.x + sa + 15,
|
2021-01-31 09:22:15 +01:00
|
|
|
})
|
|
|
|
macro('vd', {
|
2021-01-30 13:15:25 +01:00
|
|
|
from: points.topLeft,
|
|
|
|
to: points.attachPoint1TL,
|
2021-04-24 10:16:31 +02:00
|
|
|
x: points.attachPoint1TL.x,
|
2021-01-31 09:22:15 +01:00
|
|
|
})
|
|
|
|
macro('vd', {
|
2021-01-30 13:15:25 +01:00
|
|
|
from: points.attachPoint2TLtemp,
|
|
|
|
to: points.bottomLeft,
|
2021-04-24 10:16:31 +02:00
|
|
|
x: points.attachPoint2TLtemp.x,
|
2021-01-31 09:22:15 +01:00
|
|
|
})
|
2021-01-30 13:15:25 +01:00
|
|
|
}
|
|
|
|
|
2021-01-31 09:22:15 +01:00
|
|
|
return part
|
2021-01-30 13:15:25 +01:00
|
|
|
}
|
2022-09-05 17:42:47 -07:00
|
|
|
|
|
|
|
export const frontpanel = {
|
|
|
|
name: 'hortensia.frontpanel',
|
|
|
|
after: sidepanel,
|
|
|
|
options: {
|
|
|
|
minHandleSpaceWidth: 80,
|
|
|
|
maxHandleSpaceWidth: 250,
|
|
|
|
pctHandleSpace: 50,
|
|
|
|
pctHandleVert: 42,
|
|
|
|
handleWidth: { pct: 8.6, min: 4, max: 25, menu: 'style' },
|
|
|
|
},
|
|
|
|
draft: draftHortensiaFrontpanel,
|
|
|
|
}
|