diff --git a/designs/bella/src/back.mjs b/designs/bella/src/back.mjs index 9d4565bf127..ae112ec74dc 100644 --- a/designs/bella/src/back.mjs +++ b/designs/bella/src/back.mjs @@ -65,7 +65,6 @@ export const back = { measurements, log, part, - addCut, }) => { // Get to work points.cbNeck = new Point(0, measurements.neck * options.backNeckCutout) @@ -270,7 +269,7 @@ export const back = { on: ['armholePitch', 'bustCenter'], }) - addCut() + if (typeof store.addCut === 'function') store.addCut() if (sa) paths.sa = paths.saBase.offset(sa).attr('class', 'fabric sa') diff --git a/designs/carlita/src/front.mjs b/designs/carlita/src/front.mjs index 8d9ca2c66a8..a7b9e0c506f 100644 --- a/designs/carlita/src/front.mjs +++ b/designs/carlita/src/front.mjs @@ -18,7 +18,6 @@ function draftCarlitaFront({ paths, Path, part, - addCut, }) { /** * we're adding half of the proportionate amount of chest east for the bust span @@ -349,9 +348,9 @@ function draftCarlitaFront({ .attr('class', 'fabric help') if (complete) { - if (typeof addCut === 'function') { - addCut() - addCut({ material: 'lining' }) + if (typeof store.addCut === 'function') { + store.addCut() + store.addCut({ material: 'lining' }) } snippets.button1Left = new Snippet('button', points.button1Left).attr('data-scale', 2) snippets.button1Right = new Snippet('button', points.button1Right).attr('data-scale', 2) diff --git a/designs/carlita/src/side.mjs b/designs/carlita/src/side.mjs index 90187faab84..d60993a05af 100644 --- a/designs/carlita/src/side.mjs +++ b/designs/carlita/src/side.mjs @@ -13,7 +13,6 @@ function draftCarlitaSide({ paths, Path, part, - addCut, }) { // Give points their original names for (let i of store.get('side')) points[i] = points[i + 'Rot2'].clone() @@ -39,9 +38,9 @@ function draftCarlitaSide({ paths.seam = paths.saBase.clone().line(points.hem).close().attr('class', 'fabric') if (complete) { - if (typeof addCut === 'function') { - addCut() - addCut({ material: 'lining' }) + if (typeof store.addCut === 'function') { + store.addCut() + store.addCut({ material: 'lining' }) } points.title = points.bustPoint.shiftFractionTowards(points.waist, 0.5) macro('title', { diff --git a/designs/carlton/src/back.mjs b/designs/carlton/src/back.mjs index 22c42e97f92..e5a62362ca3 100644 --- a/designs/carlton/src/back.mjs +++ b/designs/carlton/src/back.mjs @@ -18,7 +18,6 @@ function draftCarltonBack({ paths, Path, part, - addCut, }) { calculateRatios(part) // Belt width @@ -98,10 +97,18 @@ function draftCarltonBack({ .line(points.bpStart) .attr('class', 'dashed') - addCut() - addCut({ cut: 2, material: 'lining' }) + if (typeof store.addCut === 'function') { + store.addCut() + store.addCut({ cut: 2, material: 'lining' }) + } if (complete) { + macro('title', { + at: points.title, + nr: '2', + title: 'back', + }) + macro('sprinkle', { snippet: 'bnotch', on: ['shoulder', 'bpTriangleTip'], diff --git a/designs/carlton/src/belt.mjs b/designs/carlton/src/belt.mjs index 00bf0b748fe..5ca8b04f9e6 100644 --- a/designs/carlton/src/belt.mjs +++ b/designs/carlton/src/belt.mjs @@ -13,7 +13,6 @@ function draftCarltonBelt({ paths, Path, part, - addCut, }) { let length = 1.6 * (store.get('cbToDart') + store.get('dartToSide')) let width = store.get('beltWidth') @@ -50,7 +49,7 @@ function draftCarltonBelt({ .close() .attr('class', 'fabric') - addCut({ cut: 4 }) + if (typeof store.addCut === 'function') store.addCut({ cut: 4 }) if (complete) { snippets.button = new Snippet('button', points.button).attr('data-scale', 2) points.title = new Point(points.bottomRight.x / 2, points.bottomRight.y / 2) diff --git a/designs/carlton/src/chestpocketbag.mjs b/designs/carlton/src/chestpocketbag.mjs index b13b943b7a1..a0e81b43f0c 100644 --- a/designs/carlton/src/chestpocketbag.mjs +++ b/designs/carlton/src/chestpocketbag.mjs @@ -12,7 +12,6 @@ function draftCarltonChestPocketBag({ paths, Path, part, - addCut, }) { points.topLeft = new Point(0, 0) points.bottomRight = new Point( @@ -44,7 +43,7 @@ function draftCarltonChestPocketBag({ .line(points.startRight) .attr('class', 'lining dashed') - addCut({ material: 'lining' }) + if (typeof store.addCut === 'function') store.addCut({ material: 'lining' }) if (complete) { points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) diff --git a/designs/carlton/src/chestpocketwelt.mjs b/designs/carlton/src/chestpocketwelt.mjs index ee5715b707b..1b7032065fd 100644 --- a/designs/carlton/src/chestpocketwelt.mjs +++ b/designs/carlton/src/chestpocketwelt.mjs @@ -11,7 +11,6 @@ function draftCarltonChestPocketWelt({ paths, Path, part, - addCut, }) { points.topLeft = new Point(0, 0) points.bottomRight = new Point(store.get('chestPocketWidth') * 2, store.get('chestPocketHeight')) @@ -31,8 +30,10 @@ function draftCarltonChestPocketWelt({ paths.fold = new Path().move(points.topMid).line(points.bottomMid).attr('class', 'dashed') - addCut() - addCut({ material: 'lmhCanvas' }) + if (typeof store.addCut === 'function') { + store.addCut() + store.addCut({ material: 'lmhCanvas' }) + } if (complete) { points.title = new Point(points.bottomRight.x / 4, points.bottomRight.y / 2) diff --git a/designs/carlton/src/collar.mjs b/designs/carlton/src/collar.mjs index 7f38719cb75..725f0f30a7c 100644 --- a/designs/carlton/src/collar.mjs +++ b/designs/carlton/src/collar.mjs @@ -16,7 +16,7 @@ function draftCarltonCollar({ paths, Path, part, - addCut, + store, }) { // We're going to slash and spread this collar. Slashing first: // Divide top in 5 parts @@ -187,9 +187,11 @@ function draftCarltonCollar({ grainline: true, }) - addCut({ cut: 1 }) - addCut({ cut: 1, bias: true }) - addCut({ cut: 2, material: 'lining', bias: true, ignoreOnFold: true }) + if (typeof store.addCut === 'function') { + store.addCut({ cut: 1 }) + store.addCut({ cut: 1, bias: true }) + store.addCut({ cut: 2, material: 'lining', bias: true, ignoreOnFold: true }) + } points.title = points.standTopCp.clone() macro('title', { diff --git a/designs/carlton/src/collarstand.mjs b/designs/carlton/src/collarstand.mjs index 01add0ef39f..9353c8b45d3 100644 --- a/designs/carlton/src/collarstand.mjs +++ b/designs/carlton/src/collarstand.mjs @@ -14,7 +14,6 @@ function draftCarltonCollarStand({ paths, Path, part, - addCut, }) { let height = measurements.chest * options.collarHeight let length = store.get('frontCollarLength') + store.get('backCollarLength') @@ -46,8 +45,10 @@ function draftCarltonCollarStand({ .close() .attr('class', 'fabric') - addCut() - addCut({ cut: 1, material: 'lmhCanvas' }) + if (typeof store.addCut === 'function') { + store.addCut() + store.addCut({ cut: 1, material: 'lmhCanvas' }) + } if (complete) { points.title = points.bottomLeftCp.clone() diff --git a/designs/carlton/src/cufffacing.mjs b/designs/carlton/src/cufffacing.mjs index 04d625800fb..fbd375d02c8 100644 --- a/designs/carlton/src/cufffacing.mjs +++ b/designs/carlton/src/cufffacing.mjs @@ -12,7 +12,6 @@ function draftCarltonCuffFacing({ paths, Path, part, - addCut, }) { points.topLeft = new Point(0, 0) points.bottomRight = new Point( @@ -47,8 +46,10 @@ function draftCarltonCuffFacing({ .close() .attr('class', 'fabric') - addCut() - addCut({ cut: 2, material: 'lmhCanvas' }) + if (typeof store.addCut === 'function') { + store.addCut() + store.addCut({ cut: 2, material: 'lmhCanvas' }) + } if (complete) { points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) diff --git a/designs/carlton/src/front.mjs b/designs/carlton/src/front.mjs index 97700df2efc..2cf72b51d7e 100644 --- a/designs/carlton/src/front.mjs +++ b/designs/carlton/src/front.mjs @@ -19,7 +19,6 @@ function draftCarltonFront({ paths, Path, part, - addCut, }) { calculateRatios(part) @@ -301,7 +300,7 @@ function draftCarltonFront({ .close() .attr('class', 'fabric help') - addCut() + if (typeof store.addCut === 'function') store.addCut() if (complete) { snippets.button1Left = new Snippet('button', points.button1Left).attr('data-scale', 2) diff --git a/designs/carlton/src/innerpocketbag.mjs b/designs/carlton/src/innerpocketbag.mjs index b51971730c9..a8425695a93 100644 --- a/designs/carlton/src/innerpocketbag.mjs +++ b/designs/carlton/src/innerpocketbag.mjs @@ -13,7 +13,6 @@ function draftCarltonInnerPocketBag({ paths, Path, part, - addCut, }) { points.topLeft = new Point(0, 0) points.bottomRight = new Point( @@ -45,7 +44,7 @@ function draftCarltonInnerPocketBag({ .line(points.startRight) .attr('class', 'lining dashed') - addCut({ material: 'lining' }) + if (typeof store.addCut === 'function') store.addCut({ material: 'lining' }) if (complete) { points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) diff --git a/designs/carlton/src/innerpockettab.mjs b/designs/carlton/src/innerpockettab.mjs index d91da082578..05076ad7f60 100644 --- a/designs/carlton/src/innerpockettab.mjs +++ b/designs/carlton/src/innerpockettab.mjs @@ -11,7 +11,6 @@ function draftCarltonInnerPocketTab({ paths, Path, part, - addCut, }) { points.topLeft = new Point(0, 0) points.topRight = new Point(store.get('innerPocketWidth') * 1.2, 0) @@ -31,7 +30,7 @@ function draftCarltonInnerPocketTab({ paths.hint = new Path().move(points.top).line(points.bottom).attr('class', 'lining dashed') - addCut({ cut: 1, material: 'lining' }) + if (typeof store.addCut === 'function') store.addCut({ cut: 1, material: 'lining' }) if (complete) { points.title = points.top.shiftFractionTowards(points.bottom, 0.5) diff --git a/designs/carlton/src/innerpocketwelt.mjs b/designs/carlton/src/innerpocketwelt.mjs index 436feb9b7a9..862306cbce7 100644 --- a/designs/carlton/src/innerpocketwelt.mjs +++ b/designs/carlton/src/innerpocketwelt.mjs @@ -11,7 +11,6 @@ function draftCarltonInnerPocketWelt({ paths, Path, part, - addCut, }) { points.topLeft = new Point(0, 0) points.bottomRight = new Point( @@ -50,8 +49,10 @@ function draftCarltonInnerPocketWelt({ .close() .attr('class', 'lashed') - addCut() - addCut({ material: 'lmhCanvas' }) + if (typeof store.addCut === 'function') { + store.addCut() + store.addCut({ material: 'lmhCanvas' }) + } if (complete) { points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) diff --git a/designs/carlton/src/pocket.mjs b/designs/carlton/src/pocket.mjs index bf04daedabd..fc98cdde0eb 100644 --- a/designs/carlton/src/pocket.mjs +++ b/designs/carlton/src/pocket.mjs @@ -12,7 +12,6 @@ function draftCarltonPocket({ paths, Path, part, - addCut, }) { points.topLeft = new Point(0, 0) points.bottomRight = new Point(store.get('pocketWidth'), store.get('pocketHeight')) @@ -54,7 +53,7 @@ function draftCarltonPocket({ paths.fold = new Path().move(points.topLeft).line(points.topRight).attr('class', 'fabric dashed') - addCut() + if (typeof store.addCut === 'function') store.addCut() if (complete) { points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) diff --git a/designs/carlton/src/pocketflap.mjs b/designs/carlton/src/pocketflap.mjs index f72bd4e1288..3f6cae40f28 100644 --- a/designs/carlton/src/pocketflap.mjs +++ b/designs/carlton/src/pocketflap.mjs @@ -12,7 +12,6 @@ function draftCarltonPocketFlap({ paths, Path, part, - addCut, }) { points.topLeft = new Point(0, 0) points.bottomRight = new Point(store.get('pocketWidth'), store.get('pocketFlapHeight')) @@ -46,8 +45,10 @@ function draftCarltonPocketFlap({ paths.seam = paths.seam.line(points.topRight).line(points.topLeft).close().attr('class', 'fabric') - addCut({ cut: 4 }) - addCut({ material: 'lmhCanvas' }) + if (typeof store.addCut === 'function') { + store.addCut({ cut: 4 }) + store.addCut({ material: 'lmhCanvas' }) + } if (complete) { points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) diff --git a/designs/carlton/src/pocketlining.mjs b/designs/carlton/src/pocketlining.mjs index 9091be47017..d3d05c5e4be 100644 --- a/designs/carlton/src/pocketlining.mjs +++ b/designs/carlton/src/pocketlining.mjs @@ -12,7 +12,6 @@ function draftCarltonPocketLining({ paths, Path, part, - addCut, }) { points.topLeft = points.bottomLeft.shiftFractionTowards(points.topLeft, 0.75) points.topRight = new Point(points.bottomRight.x, points.topLeft.y) @@ -46,7 +45,7 @@ function draftCarltonPocketLining({ delete paths.fold - addCut({ material: 'lining' }) + if (typeof store.addCut === 'function') store.addCut({ material: 'lining' }) if (complete) { points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) diff --git a/designs/carlton/src/tail.mjs b/designs/carlton/src/tail.mjs index c88d55de646..955c68a3388 100644 --- a/designs/carlton/src/tail.mjs +++ b/designs/carlton/src/tail.mjs @@ -13,7 +13,6 @@ function draftCarltonTail({ paths, Path, part, - addCut, }) { let length = store.get('waistToHem') - store.get('beltWidth') / 2 @@ -69,8 +68,10 @@ function draftCarltonTail({ .line(points.fold5Bottom) .attr('class', 'fabric dashed') - addCut() - addCut({ material: 'lining' }) + if (typeof store.addCut === 'function') { + store.addCut() + store.addCut({ material: 'lining' }) + } if (complete) { points.title = points.fold4Top.shiftFractionTowards(points.waistBottom, 0.5) diff --git a/designs/carlton/src/topsleeve.mjs b/designs/carlton/src/topsleeve.mjs index 7af55e2f372..3f1c85e9382 100644 --- a/designs/carlton/src/topsleeve.mjs +++ b/designs/carlton/src/topsleeve.mjs @@ -16,7 +16,6 @@ function draftCarltonTopSleeve({ Snippet, snippets, part, - addCut, }) { // Add cuff let length = measurements.shoulderToWrist * options.cuffLength @@ -55,10 +54,17 @@ function draftCarltonTopSleeve({ .close() .attr('class', 'fabric') - addCut() - addCut({ material: 'lining' }) + if (typeof store.addCut === 'function') { + store.addCut() + store.addCut({ material: 'lining' }) + } if (complete) { + macro('title', { + at: points.armCenter, + nr: 3, + title: 'topsleeve', + }) macro('grainline', { from: points.boxBottom, to: points.top, diff --git a/designs/carlton/src/undersleeve.mjs b/designs/carlton/src/undersleeve.mjs index e16a298ba5f..b6e5dc0f48d 100644 --- a/designs/carlton/src/undersleeve.mjs +++ b/designs/carlton/src/undersleeve.mjs @@ -15,7 +15,6 @@ function draftCarltonUnderSleeve({ paths, Path, part, - addCut, }) { // Add cuff let length = measurements.shoulderToWrist * options.cuffLength @@ -51,9 +50,18 @@ function draftCarltonUnderSleeve({ .close() .attr('class', 'fabric') - addCut() - addCut({ material: 'lining' }) + if (typeof store.addCut === 'function') { + store.addCut() + store.addCut({ material: 'lining' }) + } + if (complete) { + macro('title', { + at: points.armCenter, + nr: 4, + title: 'undersleeve', + }) + macro('grainline', { from: points.boxBottom, to: new Point(points.top.x, points.usLeftEdge.y), diff --git a/packages/core/src/part.mjs b/packages/core/src/part.mjs index ce4a393d2b2..6c1579c5985 100644 --- a/packages/core/src/part.mjs +++ b/packages/core/src/part.mjs @@ -135,15 +135,6 @@ Part.prototype.shorthand = function () { utils: utils, Bezier: Bezier, } - // Add top-level store methods and add a part name parameter - const partName = this.name - for (const [key, method] of Object.entries(this.context.store)) { - if (typeof method === 'function') - shorthand[key] = function (...args) { - return method(partName, ...args) - } - } - // We'll need this let self = this diff --git a/packages/core/src/pattern.mjs b/packages/core/src/pattern.mjs index 1e5d184a0c0..126d3997d65 100644 --- a/packages/core/src/pattern.mjs +++ b/packages/core/src/pattern.mjs @@ -160,6 +160,7 @@ Pattern.prototype.createPartForSet = function (partName, set = 0) { Pattern.prototype.draftPartForSet = function (partName, set) { if (typeof this.config.parts?.[partName]?.draft === 'function') { this.activePart = partName + this.setStores[set].set('activePart', partName) try { this.__runHooks('prePartDraft') const result = this.config.parts[partName].draft(this.parts[set][partName].shorthand()) diff --git a/plugins/plugin-cutlist/src/index.mjs b/plugins/plugin-cutlist/src/index.mjs index 9ff14095d57..4a7bb41551f 100644 --- a/plugins/plugin-cutlist/src/index.mjs +++ b/plugins/plugin-cutlist/src/index.mjs @@ -19,7 +19,6 @@ export const pluginCutlist = plugin /** * Add a set of cutting instructions for the part * @param {Store} store the Store - * @param {string} partName the name of the part * @param {Object} so a set of cutting instructions for a material * @param {number} so.cut = 2 the number of pieces to cut from the specified fabric * @param {string} so.material = fabric the name of the material to cut from @@ -27,8 +26,9 @@ export const pluginCutlist = plugin * @param {boolean} so.bias = false should the pieces in these cutting instructions be cut on the bias * @param {boolean} so.ignoreOnFold should these cutting instructions ignore any cutOnFold information set by the part */ -function addCut(store, partName, so = {}) { +function addCut(store, so = {}) { const { cut = 2, material = 'fabric', identical = false, bias = false, ignoreOnFold = false } = so + const partName = store.get('activePart') if (cut === false) { if (material === false) store.unset(['cutlist', partName, 'materials']) else store.unset(['cutlist', partName, 'materials', material]) @@ -50,12 +50,13 @@ function addCut(store, partName, so = {}) { } /** Method to remove the cut info */ -function removeCut(store, partName, material = false) { - return addCut(store, partName, { cut: false, material }) +function removeCut(store, material = false) { + return addCut(store, { cut: false, material }) } /** Method to add the grain info */ -function setGrain(store, partName, grain = false) { +function setGrain(store, grain = false) { + const partName = store.get('activePart') const path = ['cutlist', partName, 'grain'] if (grain === false) return store.unset(path) if (typeof grain !== 'number') { @@ -66,7 +67,8 @@ function setGrain(store, partName, grain = false) { } /** Method to add the cutOnFold info */ -function setCutOnFold(store, partName, p1, p2) { +function setCutOnFold(store, p1, p2) { + const partName = store.get('activePart') const path = ['cutlist', partName, 'cutOnFold'] if (p1 === false && typeof p2 === 'undefined') { return store.unset(path) diff --git a/plugins/plugin-cutonfold/src/index.mjs b/plugins/plugin-cutonfold/src/index.mjs index b3d18b421d7..4766a6ae86b 100644 --- a/plugins/plugin-cutonfold/src/index.mjs +++ b/plugins/plugin-cutonfold/src/index.mjs @@ -18,7 +18,7 @@ export const plugin = { }, }, macros: { - cutonfold: function (so, { points, paths, Path, complete, setCutOnFold, setGrain, scale }) { + cutonfold: function (so, { points, paths, Path, complete, store, scale }) { if (so === false) { delete points.cutonfoldFrom delete points.cutonfoldTo @@ -26,8 +26,8 @@ export const plugin = { delete points.cutonfoldVia2 delete paths.cutonfoldCutonfold // setCutOnFold relies on plugin-cutlist - if (typeof setCutOnFold === 'function') { - setCutOnFold(false) // Restore default + if (typeof store.setCutOnFold === 'function') { + store.setCutOnFold(false) // Restore default } return true } @@ -37,9 +37,9 @@ export const plugin = { prefix: 'cutonfold', ...so, } - if (typeof setCutOnFold === 'function') { - setCutOnFold(so.from, so.to) - if (so.grainline) setGrain(so.from.angle(so.to)) + if (typeof store.setCutOnFold === 'function') { + store.setCutOnFold(so.from, so.to) + if (so.grainline) store.setGrain(so.from.angle(so.to)) } if (complete) { points[so.prefix + 'From'] = so.from.shiftFractionTowards(so.to, so.margin / 100) diff --git a/plugins/plugin-grainline/src/index.mjs b/plugins/plugin-grainline/src/index.mjs index eb56aebda63..a0c0c2ac87c 100644 --- a/plugins/plugin-grainline/src/index.mjs +++ b/plugins/plugin-grainline/src/index.mjs @@ -19,12 +19,14 @@ export const plugin = { }, }, macros: { - grainline: function (so = {}, { points, paths, Path, complete, setGrain }) { + grainline: function (so = {}, { points, paths, Path, complete, store }) { if (so === false) { delete points.grainlineFrom delete points.grainlineTo delete paths.grainline - setGrain(90) // Restoring default + if (typeof store.setGrain === 'function') { + setGrain(false) // Restoring default + } return true } so = { @@ -32,8 +34,8 @@ export const plugin = { ...so, } // setGrain relies on plugin-cutlist - if (typeof setGrain === 'function') { - setGrain(so.from.angle(so.to)) + if (typeof store.setGrain === 'function') { + store.setGrain(so.from.angle(so.to)) } if (complete) { points.grainlineFrom = so.from.shiftFractionTowards(so.to, 0.05)