handle cases with 'only' in cutting layout
This commit is contained in:
parent
b146f6271f
commit
47953e8e27
4 changed files with 18 additions and 8 deletions
|
@ -58,6 +58,8 @@ const useFabricList = (draft) => {
|
||||||
const cutList = draft.setStores[0].get('cutlist')
|
const cutList = draft.setStores[0].get('cutlist')
|
||||||
const fabricList = ['fabric']
|
const fabricList = ['fabric']
|
||||||
for (const partName in cutList) {
|
for (const partName in cutList) {
|
||||||
|
if (draft.settings[0].only && !draft.settings[0].only.includes(partName)) continue
|
||||||
|
|
||||||
for (const matName in cutList[partName].materials) {
|
for (const matName in cutList[partName].materials) {
|
||||||
if (!fabricList.includes(matName)) fabricList.push(matName)
|
if (!fabricList.includes(matName)) fabricList.push(matName)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { addToOnly } from '../plugin-layout-part.mjs'
|
||||||
const prefix = 'mirroredOnFold'
|
const prefix = 'mirroredOnFold'
|
||||||
|
|
||||||
// types of path operations
|
// types of path operations
|
||||||
|
@ -14,12 +15,16 @@ export const cutLayoutPlugin = function (material, grainAngle) {
|
||||||
hooks: {
|
hooks: {
|
||||||
// after each part
|
// after each part
|
||||||
postPartDraft: (pattern) => {
|
postPartDraft: (pattern) => {
|
||||||
// get the part that's just been drafted
|
// if it's a duplicated cut part, the fabric part, or it's not wanted by the pattern
|
||||||
const part = pattern.parts[pattern.activeSet][pattern.activePart]
|
if (
|
||||||
// if it's a duplicated cut part, the fabric part, or it's hidden, leave it alone
|
pattern.activePart.startsWith('cut.') ||
|
||||||
if (pattern.activePart.startsWith('cut.') || pattern.activePart === 'fabric' || part.hidden)
|
pattern.activePart === 'fabric' ||
|
||||||
|
!pattern.__wants(pattern.activePart)
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
// get the part that's just been drafted
|
||||||
|
const part = pattern.parts[pattern.activeSet][pattern.activePart]
|
||||||
// get this part's cutlist configuration
|
// get this part's cutlist configuration
|
||||||
let partCutlist = pattern.setStores[pattern.activeSet].get(['cutlist', pattern.activePart])
|
let partCutlist = pattern.setStores[pattern.activeSet].get(['cutlist', pattern.activePart])
|
||||||
// if there isn't one, we're done here
|
// if there isn't one, we're done here
|
||||||
|
@ -71,6 +76,9 @@ export const cutLayoutPlugin = function (material, grainAngle) {
|
||||||
return part
|
return part
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// add it to the only list if there is one
|
||||||
|
addToOnly(pattern, dupPartName)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ const FabricSizer = ({ gist, updateGist, activeFabric, sheetWidth }) => {
|
||||||
<input
|
<input
|
||||||
key="input-fabricWidth"
|
key="input-fabricWidth"
|
||||||
type="text"
|
type="text"
|
||||||
className="input input-bordered grow text-base-content border-r-0"
|
className="input input-bordered grow text-base-content border-r-0 w-20"
|
||||||
value={val}
|
value={val}
|
||||||
onChange={update}
|
onChange={update}
|
||||||
/>
|
/>
|
||||||
|
@ -119,7 +119,7 @@ export const CutLayoutSettings = ({
|
||||||
<SheetIcon className="h-6 w-6 mr-2 inline align-middle" />
|
<SheetIcon className="h-6 w-6 mr-2 inline align-middle" />
|
||||||
<span className="text-xl font-bold align-middle">{fabricLength}</span>
|
<span className="text-xl font-bold align-middle">{fabricLength}</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div className="flex">
|
||||||
<ShowButtonsToggle
|
<ShowButtonsToggle
|
||||||
gist={gist}
|
gist={gist}
|
||||||
updateGist={updateGist}
|
updateGist={updateGist}
|
||||||
|
@ -128,7 +128,7 @@ export const CutLayoutSettings = ({
|
||||||
<button
|
<button
|
||||||
key="reset"
|
key="reset"
|
||||||
onClick={() => unsetGist(['layouts', 'cuttingLayout', activeFabric])}
|
onClick={() => unsetGist(['layouts', 'cuttingLayout', activeFabric])}
|
||||||
className="btn btn-primary btn-outline"
|
className="btn btn-primary btn-outline ml-4"
|
||||||
>
|
>
|
||||||
<ClearIcon className="h-6 w-6 mr-2" />
|
<ClearIcon className="h-6 w-6 mr-2" />
|
||||||
{t('reset')}
|
{t('reset')}
|
||||||
|
|
|
@ -94,7 +94,7 @@ const doScanForBlanks = (stacks, layout, x, y, w, h) => {
|
||||||
return hasContent
|
return hasContent
|
||||||
}
|
}
|
||||||
|
|
||||||
function addToOnly(pattern, partName) {
|
export function addToOnly(pattern, partName) {
|
||||||
const only = pattern.settings[0].only
|
const only = pattern.settings[0].only
|
||||||
if (only && !only.includes(partName)) {
|
if (only && !only.includes(partName)) {
|
||||||
pattern.settings[0].only = [].concat(only, partName)
|
pattern.settings[0].only = [].concat(only, partName)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue