2021-01-30 13:15:25 +01:00
|
|
|
export default function (part) {
|
|
|
|
let {
|
|
|
|
store,
|
|
|
|
options,
|
|
|
|
Point,
|
|
|
|
Path,
|
|
|
|
points,
|
|
|
|
paths,
|
|
|
|
Snippet,
|
|
|
|
snippets,
|
|
|
|
complete,
|
|
|
|
sa,
|
|
|
|
paperless,
|
2021-04-24 10:16:31 +02:00
|
|
|
macro,
|
2021-01-31 09:22:15 +01:00
|
|
|
} = part.shorthand()
|
2021-01-30 13:15:25 +01:00
|
|
|
|
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
|
|
|
|
let handleWidth = options.handleWidth
|
|
|
|
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
|
|
|
|
2021-01-31 09:22:15 +01: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
|
|
|
|
2021-01-31 09:22:15 +01: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
|
|
|
|
|
|
|
// 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',
|
2021-01-31 09:22:15 +01:00
|
|
|
})
|
|
|
|
points.__titleNr.attr('data-text-class', 'center')
|
|
|
|
points.__titleName.attr('data-text-class', 'center')
|
|
|
|
points.__titlePattern.attr('data-text-class', 'center')
|
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
|
|
|
}
|