1
0
Fork 0

feat(plugin-cutlist): New plugin to manage cutlist

This also removed the cutlist-related functionality that was added to
core as an early v3 feature.
This commit is contained in:
Joost De Cock 2022-09-07 21:16:44 +02:00
parent ef4a70c8f3
commit 55e5dc3d0c
11 changed files with 664 additions and 182 deletions

View file

@ -354,62 +354,6 @@ Part.prototype.generateTransform = function(transforms) {
}
}
/** Chainable way to add the cut info */
Part.prototype.addCut = function (cut=2, material='fabric', identical=false) {
if (cut === false) {
if (this.cut.materials[material]) delete this.cut.materials[material]
else this.context.raise.warning(`Tried to remove a material that is not set`)
return this
}
if (typeof this.cut.materials[material] === 'undefined') this.cut.materials[material] = {}
if (!(Number.isInteger(cut) && cut > -1)) {
this.context.raise.error(`Tried to set cut to a value that is not a positive integer`)
return this
}
if (typeof material !== 'string') {
this.context.raise.warning(`Tried to set material to a value that is not a string`)
return this
}
this.cut.materials[material].cut = cut
this.cut.materials[material].identical = identical
return this
}
/** Chainable way to remove (some) cut info */
Part.prototype.removeCut = function (material=false) {
return this.addCut(false, material)
}
/** Chainable way to add the grain info */
Part.prototype.setGrain = function (grain=false) {
if (grain === false) {
this.cut.grain = false
return this
}
if (typeof grain !== 'number') {
this.context.raise.error('Called part.setGrain() with a value that is not a number')
return this
}
this.cut.grain = grain
return this
}
/** Chainable way to add the cutOnFold info */
Part.prototype.setCutOnFold = function (p1, p2) {
if (p1 === false && typeof p2 === 'undefined') {
delete this.cut.cutOnFold
return this
}
if (p1 instanceof Point && p2 instanceof Point) {
this.cut.cutOnFold = [p1, p2]
}
else this.context.raise.error('Called part.setCutOnFold() but at least one parameter is not a Point instance')
return this
}
Part.prototype.isEmpty = function() {
if (Object.keys(this.snippets).length > 0) return false