Add modal typing back in, and clean up old constraints code (#865)

* Revert "Revert "Improve Prop Typings for Modals. Remove instances of `any`. (… (#813)"

This reverts commit 9822576077.

* tsc

* refactor all buttons

* add parallel constraint

* typegen?

* add constraint removal constraint

* add perpendicular distance constraint

* state diagram layout

* fmt

* improve modal typing for setAngleLength
This commit is contained in:
Kurt Hutten
2023-10-16 08:54:38 +11:00
committed by GitHub
parent c6af62797d
commit b257b202c3
17 changed files with 602 additions and 1056 deletions

View File

@ -1,26 +1,13 @@
import { useStore, toolTips, ToolTip } from './useStore' import { ToolTip } from './useStore'
import { extrudeSketch, sketchOnExtrudedFace } from './lang/modifyAst'
import { getNodePathFromSourceRange } from './lang/queryAst'
// import { HorzVert } from './components/Toolbar/HorzVert'
// import { RemoveConstrainingValues } from './components/Toolbar/RemoveConstrainingValues'
// import { EqualLength } from './components/Toolbar/EqualLength'
// import { EqualAngle } from './components/Toolbar/EqualAngle'
// import { Intersect } from './components/Toolbar/Intersect'
// import { SetHorzVertDistance } from './components/Toolbar/SetHorzVertDistance'
// import { SetAngleLength } from './components/Toolbar/setAngleLength'
// import { SetAbsDistance } from './components/Toolbar/SetAbsDistance'
// import { SetAngleBetween } from './components/Toolbar/SetAngleBetween'
import { Fragment, WheelEvent, useRef, useMemo } from 'react' import { Fragment, WheelEvent, useRef, useMemo } from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faSearch, faX } from '@fortawesome/free-solid-svg-icons' import { faSearch, faX } from '@fortawesome/free-solid-svg-icons'
import { Popover, Transition } from '@headlessui/react' import { Popover, Transition } from '@headlessui/react'
import styles from './Toolbar.module.css' import styles from './Toolbar.module.css'
import { v4 as uuidv4 } from 'uuid'
import { isCursorInSketchCommandRange } from 'lang/util' import { isCursorInSketchCommandRange } from 'lang/util'
import { ActionIcon } from 'components/ActionIcon' import { ActionIcon } from 'components/ActionIcon'
import { engineCommandManager } from './lang/std/engineConnection' import { engineCommandManager } from './lang/std/engineConnection'
import { useModelingContext } from 'hooks/useModelingContext' import { useModelingContext } from 'hooks/useModelingContext'
import { kclManager } from 'lang/KclSinglton'
export const sketchButtonClassnames = { export const sketchButtonClassnames = {
background: background:
@ -178,24 +165,6 @@ export const Toolbar = () => {
Extrude Extrude
</button> </button>
)} )}
{/* <HorzVert horOrVert="horizontal" />
<HorzVert horOrVert="vertical" />
<EqualLength />
<EqualAngle />
<SetHorzVertDistance buttonType="alignEndsVertically" />
<SetHorzVertDistance buttonType="setHorzDistance" />
<SetAbsDistance buttonType="snapToYAxis" />
<SetAbsDistance buttonType="xAbs" />
<SetHorzVertDistance buttonType="alignEndsHorizontally" />
<SetAbsDistance buttonType="snapToXAxis" />
<SetHorzVertDistance buttonType="setVertDistance" />
<SetAbsDistance buttonType="yAbs" />
<SetAngleLength angleOrLength="setAngle" />
<SetAngleLength angleOrLength="setLength" />
<Intersect />
<RemoveConstrainingValues />
<SetAngleBetween /> */}
</span> </span>
) )
} }

View File

@ -41,6 +41,7 @@ import {
setCodeMirrorCursor, setCodeMirrorCursor,
useStore, useStore,
} from 'useStore' } from 'useStore'
import { applyConstraintIntersect } from './Toolbar/Intersect'
type MachineContext<T extends AnyStateMachine> = { type MachineContext<T extends AnyStateMachine> = {
state: StateFrom<T> state: StateFrom<T>
@ -372,6 +373,22 @@ export const ModelingMachineProvider = ({
), ),
} }
}, },
'Get perpendicular distance info': async ({
selectionRanges,
}): Promise<SetSelections> => {
const { modifiedAst, pathToNodeMap } = await applyConstraintIntersect({
selectionRanges,
})
await kclManager.updateAst(modifiedAst, true)
return {
selectionType: 'completeSelection',
selection: pathMapToSelections(
kclManager.ast,
selectionRanges,
pathToNodeMap
),
}
},
}, },
devTools: true, devTools: true,
}) })

View File

@ -1,5 +1,6 @@
import { Dialog, Transition } from '@headlessui/react' import { Dialog, Transition } from '@headlessui/react'
import { Fragment, useState } from 'react' import { Fragment, useState } from 'react'
import { type InstanceProps, create } from 'react-modal-promise'
import { Value } from '../lang/wasm' import { Value } from '../lang/wasm'
import { import {
AvailableVars, AvailableVars,
@ -9,6 +10,28 @@ import {
CreateNewVariable, CreateNewVariable,
} from './AvailableVarsHelpers' } from './AvailableVarsHelpers'
type ModalResolve = {
value: string
sign: number
valueNode: Value
variableName?: string
newVariableInsertIndex: number
}
type ModalReject = boolean
type SetAngleLengthModalProps = InstanceProps<ModalResolve, ModalReject> & {
value: number
valueName: string
shouldCreateVariable?: boolean
}
export const createSetAngleLengthModal = create<
SetAngleLengthModalProps,
ModalResolve,
ModalReject
>
export const SetAngleLengthModal = ({ export const SetAngleLengthModal = ({
isOpen, isOpen,
onResolve, onResolve,
@ -16,20 +39,7 @@ export const SetAngleLengthModal = ({
value: initialValue, value: initialValue,
valueName, valueName,
shouldCreateVariable: initialShouldCreateVariable = false, shouldCreateVariable: initialShouldCreateVariable = false,
}: { }: SetAngleLengthModalProps) => {
isOpen: boolean
onResolve: (a: {
value: string
sign: number
valueNode: Value
variableName?: string
newVariableInsertIndex: number
}) => void
onReject: (a: any) => void
value: number
valueName: string
shouldCreateVariable: boolean
}) => {
const [sign, setSign] = useState(Math.sign(Number(initialValue))) const [sign, setSign] = useState(Math.sign(Number(initialValue)))
const [value, setValue] = useState(String(initialValue * sign)) const [value, setValue] = useState(String(initialValue * sign))
const [shouldCreateVariable, setShouldCreateVariable] = useState( const [shouldCreateVariable, setShouldCreateVariable] = useState(

View File

@ -1,5 +1,6 @@
import { Dialog, Transition } from '@headlessui/react' import { Dialog, Transition } from '@headlessui/react'
import { Fragment, useState } from 'react' import { Fragment, useState } from 'react'
import { type InstanceProps, create } from 'react-modal-promise'
import { Value } from '../lang/wasm' import { Value } from '../lang/wasm'
import { import {
AvailableVars, AvailableVars,
@ -9,6 +10,30 @@ import {
CreateNewVariable, CreateNewVariable,
} from './AvailableVarsHelpers' } from './AvailableVarsHelpers'
type ModalResolve = {
value: string
segName: string
valueNode: Value
variableName?: string
newVariableInsertIndex: number
sign: number
}
type ModalReject = boolean
type GetInfoModalProps = InstanceProps<ModalResolve, ModalReject> & {
segName: string
isSegNameEditable: boolean
value?: number
initialVariableName: string
}
export const createInfoModal = create<
GetInfoModalProps,
ModalResolve,
ModalReject
>
export const GetInfoModal = ({ export const GetInfoModal = ({
isOpen, isOpen,
onResolve, onResolve,
@ -17,25 +42,12 @@ export const GetInfoModal = ({
isSegNameEditable, isSegNameEditable,
value: initialValue, value: initialValue,
initialVariableName, initialVariableName,
}: { }: GetInfoModalProps) => {
isOpen: boolean
onResolve: (a: {
value: string
segName: string
valueNode: Value
variableName?: string
newVariableInsertIndex: number
sign: number
}) => void
onReject: (a: any) => void
segName: string
isSegNameEditable: boolean
value: number
initialVariableName: string
}) => {
const [sign, setSign] = useState(Math.sign(Number(initialValue))) const [sign, setSign] = useState(Math.sign(Number(initialValue)))
const [segName, setSegName] = useState(initialSegName) const [segName, setSegName] = useState(initialSegName)
const [value, setValue] = useState(String(Math.abs(initialValue))) const [value, setValue] = useState(
initialValue === undefined ? '' : String(Math.abs(initialValue))
)
const [shouldCreateVariable, setShouldCreateVariable] = useState(false) const [shouldCreateVariable, setShouldCreateVariable] = useState(false)
const { const {

View File

@ -4,19 +4,26 @@ import { useCalc, CreateNewVariable } from './AvailableVarsHelpers'
import { ActionButton } from './ActionButton' import { ActionButton } from './ActionButton'
import { faPlus } from '@fortawesome/free-solid-svg-icons' import { faPlus } from '@fortawesome/free-solid-svg-icons'
import { toast } from 'react-hot-toast' import { toast } from 'react-hot-toast'
import { type InstanceProps, create } from 'react-modal-promise'
type ModalResolve = { variableName: string }
type ModalReject = boolean
type SetVarNameModalProps = InstanceProps<ModalResolve, ModalReject> & {
valueName: string
}
export const createSetVarNameModal = create<
SetVarNameModalProps,
ModalResolve,
ModalReject
>
export const SetVarNameModal = ({ export const SetVarNameModal = ({
isOpen, isOpen,
onResolve, onResolve,
onReject, onReject,
valueName, valueName,
}: { }: SetVarNameModalProps) => {
isOpen: boolean
onResolve: (a: { variableName?: string }) => void
onReject: (a: any) => void
value: number
valueName: string
}) => {
const { isNewVariableNameUnique, newVariableName, setNewVariableName } = const { isNewVariableNameUnique, newVariableName, setNewVariableName } =
useCalc({ value: '', initialVariableName: valueName }) useCalc({ value: '', initialVariableName: valueName })

View File

@ -1,30 +1,22 @@
import { useState, useEffect } from 'react' import { Selections, toolTips } from '../../useStore'
import { toolTips, useStore } from '../../useStore' import { Program, Value, VariableDeclarator } from '../../lang/wasm'
import { Value, VariableDeclarator } from '../../lang/wasm'
import { import {
getNodePathFromSourceRange, getNodePathFromSourceRange,
getNodeFromPath, getNodeFromPath,
} from '../../lang/queryAst' } from '../../lang/queryAst'
import { isSketchVariablesLinked } from '../../lang/std/sketchConstraints' import { isSketchVariablesLinked } from '../../lang/std/sketchConstraints'
import { import {
TransformInfo,
transformSecondarySketchLinesTagFirst, transformSecondarySketchLinesTagFirst,
getTransformInfos, getTransformInfos,
PathToNodeMap,
} from '../../lang/std/sketchcombos' } from '../../lang/std/sketchcombos'
import { ActionIcon } from 'components/ActionIcon'
import { sketchButtonClassnames } from 'Toolbar'
import { kclManager } from 'lang/KclSinglton' import { kclManager } from 'lang/KclSinglton'
/* export function equalAngleInfo({
export const EqualAngle = () => { selectionRanges,
const { guiMode, selectionRanges, setCursor } = useStore((s) => ({ }: {
guiMode: s.guiMode, selectionRanges: Selections
selectionRanges: s.selectionRanges, }) {
setCursor: s.setCursor,
}))
const [enableEqual, setEnableEqual] = useState(false)
const [transformInfos, setTransformInfos] = useState<TransformInfo[]>()
useEffect(() => {
const paths = selectionRanges.codeBasedSelections.map(({ range }) => const paths = selectionRanges.codeBasedSelections.map(({ range }) =>
getNodePathFromSourceRange(kclManager.ast, range) getNodePathFromSourceRange(kclManager.ast, range)
) )
@ -50,7 +42,7 @@ export const EqualAngle = () => {
toolTips.includes(node.callee.name as any) toolTips.includes(node.callee.name as any)
) )
const theTransforms = getTransformInfos( const transforms = getTransformInfos(
{ {
...selectionRanges, ...selectionRanges,
codeBasedSelections: selectionRanges.codeBasedSelections.slice(1), codeBasedSelections: selectionRanges.codeBasedSelections.slice(1),
@ -58,45 +50,29 @@ export const EqualAngle = () => {
kclManager.ast, kclManager.ast,
'equalAngle' 'equalAngle'
) )
setTransformInfos(theTransforms)
const _enableEqual = const enabled =
!!secondaryVarDecs.length && !!secondaryVarDecs.length &&
isAllTooltips && isAllTooltips &&
isOthersLinkedToPrimary && isOthersLinkedToPrimary &&
theTransforms.every(Boolean) transforms.every(Boolean)
setEnableEqual(_enableEqual) return { enabled, transforms }
}, [guiMode, selectionRanges]) }
if (guiMode.mode !== 'sketch') return null
return ( export function applyConstraintEqualAngle({
<button selectionRanges,
onClick={async () => { }: {
if (!transformInfos) return selectionRanges: Selections
const { modifiedAst, pathToNodeMap } = }): {
transformSecondarySketchLinesTagFirst({ modifiedAst: Program
pathToNodeMap: PathToNodeMap
} {
const { transforms } = equalAngleInfo({ selectionRanges })
const { modifiedAst, pathToNodeMap } = transformSecondarySketchLinesTagFirst({
ast: kclManager.ast, ast: kclManager.ast,
selectionRanges, selectionRanges,
transformInfos, transformInfos: transforms,
programMemory: kclManager.programMemory, programMemory: kclManager.programMemory,
}) })
kclManager.updateAst(modifiedAst, true, { return { modifiedAst, pathToNodeMap }
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
})
}}
disabled={!enableEqual}
title="Parallel (or equal angle)"
className="group"
>
<ActionIcon
icon="parallel"
className="!p-0.5"
bgClassName={sketchButtonClassnames.background}
iconClassName={sketchButtonClassnames.icon}
size="md"
/>
Parallel
</button>
)
} }
*/

View File

@ -1,5 +1,4 @@
import { useState, useEffect } from 'react' import { Selections, toolTips } from '../../useStore'
import { Selections, toolTips, useStore } from '../../useStore'
import { Program, Value, VariableDeclarator } from '../../lang/wasm' import { Program, Value, VariableDeclarator } from '../../lang/wasm'
import { import {
getNodePathFromSourceRange, getNodePathFromSourceRange,
@ -7,63 +6,12 @@ import {
} from '../../lang/queryAst' } from '../../lang/queryAst'
import { isSketchVariablesLinked } from '../../lang/std/sketchConstraints' import { isSketchVariablesLinked } from '../../lang/std/sketchConstraints'
import { import {
TransformInfo,
transformSecondarySketchLinesTagFirst, transformSecondarySketchLinesTagFirst,
getTransformInfos, getTransformInfos,
PathToNodeMap, PathToNodeMap,
} from '../../lang/std/sketchcombos' } from '../../lang/std/sketchcombos'
import { ActionIcon } from 'components/ActionIcon'
import { sketchButtonClassnames } from 'Toolbar'
import { kclManager } from 'lang/KclSinglton' import { kclManager } from 'lang/KclSinglton'
/*
export const EqualLength = () => {
const { guiMode, selectionRanges, setCursor } = useStore((s) => ({
guiMode: s.guiMode,
selectionRanges: s.selectionRanges,
setCursor: s.setCursor,
}))
const [enableEqual, setEnableEqual] = useState(false)
const [transformInfos, setTransformInfos] = useState<TransformInfo[]>()
useEffect(() => {
const { enabled, transforms } = setEqualLengthInfo({ selectionRanges })
setTransformInfos(transforms)
setEnableEqual(enabled)
}, [guiMode, selectionRanges])
if (guiMode.mode !== 'sketch') return null
return (
<button
onClick={() => {
if (!transformInfos) return
const { modifiedAst, pathToNodeMap } =
transformSecondarySketchLinesTagFirst({
ast: kclManager.ast,
selectionRanges,
transformInfos,
programMemory: kclManager.programMemory,
})
kclManager.updateAst(modifiedAst, true, {
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
})
}}
disabled={!enableEqual}
className="group"
title="Equal Length"
>
<ActionIcon
icon="equal"
className="!p-0.5"
bgClassName={sketchButtonClassnames.background}
iconClassName={sketchButtonClassnames.icon}
size="md"
/>
Equal Length
</button>
)
}
*/
export function setEqualLengthInfo({ export function setEqualLengthInfo({
selectionRanges, selectionRanges,
}: { }: {

View File

@ -1,5 +1,4 @@
import { useState, useEffect } from 'react' import { toolTips } from '../../useStore'
import { toolTips, useStore } from '../../useStore'
import { Program, ProgramMemory, Value } from '../../lang/wasm' import { Program, ProgramMemory, Value } from '../../lang/wasm'
import { import {
getNodePathFromSourceRange, getNodePathFromSourceRange,
@ -7,67 +6,12 @@ import {
} from '../../lang/queryAst' } from '../../lang/queryAst'
import { import {
PathToNodeMap, PathToNodeMap,
TransformInfo,
getTransformInfos, getTransformInfos,
transformAstSketchLines, transformAstSketchLines,
} from '../../lang/std/sketchcombos' } from '../../lang/std/sketchcombos'
import { ActionIcon } from 'components/ActionIcon'
import { sketchButtonClassnames } from 'Toolbar'
import { kclManager } from 'lang/KclSinglton' import { kclManager } from 'lang/KclSinglton'
import { Selections } from 'useStore' import { Selections } from 'useStore'
/*
export const HorzVert = ({
horOrVert,
}: {
horOrVert: 'vertical' | 'horizontal'
}) => {
const { guiMode, selectionRanges, setCursor } = useStore((s) => ({
guiMode: s.guiMode,
selectionRanges: s.selectionRanges,
setCursor: s.setCursor,
}))
const [enableHorz, setEnableHorz] = useState(false)
const [transformInfos, setTransformInfos] = useState<TransformInfo[]>()
useEffect(() => {
const { enabled, transforms } = horzVertInfo(selectionRanges, horOrVert)
setTransformInfos(transforms)
setEnableHorz(enabled)
}, [guiMode, selectionRanges])
if (guiMode.mode !== 'sketch') return null
return (
<button
onClick={() => {
if (!transformInfos) return
const { modifiedAst, pathToNodeMap } = transformAstSketchLines({
ast: kclManager.ast,
selectionRanges,
transformInfos,
programMemory: kclManager.programMemory,
referenceSegName: '',
})
kclManager.updateAst(modifiedAst, true, {
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
})
}}
disabled={!enableHorz}
className="group"
title={horOrVert === 'horizontal' ? 'Horizontal' : 'Vertical'}
>
<ActionIcon
icon={horOrVert === 'horizontal' ? 'horizontal' : 'vertical'}
className="!p-0.5"
bgClassName={sketchButtonClassnames.background}
iconClassName={sketchButtonClassnames.icon}
size="md"
/>
{horOrVert === 'horizontal' ? 'Horizontal' : 'Vertical'}
</button>
)
}
*/
export function horzVertInfo( export function horzVertInfo(
selectionRanges: Selections, selectionRanges: Selections,
horOrVert: 'vertical' | 'horizontal' horOrVert: 'vertical' | 'horizontal'
@ -110,7 +54,4 @@ export function applyConstraintHorzVert(
programMemory, programMemory,
referenceSegName: '', referenceSegName: '',
}) })
// kclManager.updateAst(modifiedAst, true, {
// callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
// })
} }

View File

@ -1,7 +1,5 @@
import { useState, useEffect } from 'react' import { Selections, toolTips } from '../../useStore'
import { create } from 'react-modal-promise' import { BinaryPart, Program, Value, VariableDeclarator } from '../../lang/wasm'
import { toolTips, useStore } from '../../useStore'
import { BinaryPart, Value, VariableDeclarator } from '../../lang/wasm'
import { import {
getNodePathFromSourceRange, getNodePathFromSourceRange,
getNodeFromPath, getNodeFromPath,
@ -9,33 +7,28 @@ import {
} from '../../lang/queryAst' } from '../../lang/queryAst'
import { isSketchVariablesLinked } from '../../lang/std/sketchConstraints' import { isSketchVariablesLinked } from '../../lang/std/sketchConstraints'
import { import {
TransformInfo,
transformSecondarySketchLinesTagFirst, transformSecondarySketchLinesTagFirst,
getTransformInfos, getTransformInfos,
PathToNodeMap,
} from '../../lang/std/sketchcombos' } from '../../lang/std/sketchcombos'
import { GetInfoModal } from '../SetHorVertDistanceModal' import { GetInfoModal, createInfoModal } from '../SetHorVertDistanceModal'
import { createVariableDeclaration } from '../../lang/modifyAst' import { createVariableDeclaration } from '../../lang/modifyAst'
import { removeDoubleNegatives } from '../AvailableVarsHelpers' import { removeDoubleNegatives } from '../AvailableVarsHelpers'
import { kclManager } from 'lang/KclSinglton' import { kclManager } from 'lang/KclSinglton'
const getModalInfo = create(GetInfoModal as any) const getModalInfo = createInfoModal(GetInfoModal)
/* export function intersectInfo({
export const Intersect = () => { selectionRanges,
const { guiMode, selectionRanges, setCursor } = useStore((s) => ({ }: {
guiMode: s.guiMode, selectionRanges: Selections
selectionRanges: s.selectionRanges, }) {
setCursor: s.setCursor,
}))
const [enable, setEnable] = useState(false)
const [transformInfos, setTransformInfos] = useState<TransformInfo[]>()
const [forecdSelectionRanges, setForcedSelectionRanges] =
useState<typeof selectionRanges>()
useEffect(() => {
if (selectionRanges.codeBasedSelections.length < 2) { if (selectionRanges.codeBasedSelections.length < 2) {
setEnable(false) return {
setForcedSelectionRanges({ ...selectionRanges }) enabled: false,
return transforms: [],
forcedSelectionRanges: { ...selectionRanges },
}
} }
const previousSegment = const previousSegment =
@ -63,7 +56,6 @@ export const Intersect = () => {
: selectionRanges.codeBasedSelections?.[1], : selectionRanges.codeBasedSelections?.[1],
], ],
} }
setForcedSelectionRanges(_forcedSelectionRanges)
const paths = _forcedSelectionRanges.codeBasedSelections.map(({ range }) => const paths = _forcedSelectionRanges.codeBasedSelections.map(({ range }) =>
getNodePathFromSourceRange(kclManager.ast, range) getNodePathFromSourceRange(kclManager.ast, range)
@ -96,13 +88,11 @@ export const Intersect = () => {
const theTransforms = getTransformInfos( const theTransforms = getTransformInfos(
{ {
...selectionRanges, ...selectionRanges,
codeBasedSelections: codeBasedSelections: _forcedSelectionRanges.codeBasedSelections.slice(1),
_forcedSelectionRanges.codeBasedSelections.slice(1),
}, },
kclManager.ast, kclManager.ast,
'intersect' 'intersect'
) )
setTransformInfos(theTransforms)
const _enableEqual = const _enableEqual =
secondaryVarDecs.length === 1 && secondaryVarDecs.length === 1 &&
@ -110,19 +100,30 @@ export const Intersect = () => {
isOthersLinkedToPrimary && isOthersLinkedToPrimary &&
theTransforms.every(Boolean) && theTransforms.every(Boolean) &&
_forcedSelectionRanges?.codeBasedSelections?.[1]?.type === 'line-end' _forcedSelectionRanges?.codeBasedSelections?.[1]?.type === 'line-end'
setEnable(_enableEqual)
}, [guiMode, selectionRanges])
if (guiMode.mode !== 'sketch') return null
return ( return {
<button enabled: _enableEqual,
onClick={async () => { transforms: theTransforms,
if (!(transformInfos && forecdSelectionRanges)) return forcedSelectionRanges: _forcedSelectionRanges,
}
}
export async function applyConstraintIntersect({
selectionRanges,
}: {
selectionRanges: Selections
}): Promise<{
modifiedAst: Program
pathToNodeMap: PathToNodeMap
}> {
const { transforms, forcedSelectionRanges } = intersectInfo({
selectionRanges,
})
const { modifiedAst, tagInfo, valueUsedInTransform, pathToNodeMap } = const { modifiedAst, tagInfo, valueUsedInTransform, pathToNodeMap } =
transformSecondarySketchLinesTagFirst({ transformSecondarySketchLinesTagFirst({
ast: JSON.parse(JSON.stringify(kclManager.ast)), ast: JSON.parse(JSON.stringify(kclManager.ast)),
selectionRanges: forecdSelectionRanges, selectionRanges: forcedSelectionRanges,
transformInfos, transformInfos: transforms,
programMemory: kclManager.programMemory, programMemory: kclManager.programMemory,
}) })
const { const {
@ -132,35 +133,29 @@ export const Intersect = () => {
variableName, variableName,
newVariableInsertIndex, newVariableInsertIndex,
sign, sign,
}: {
segName: string
value: number
valueNode: Value
variableName?: string
newVariableInsertIndex: number
sign: number
} = await getModalInfo({ } = await getModalInfo({
segName: tagInfo?.tag, segName: tagInfo?.tag,
isSegNameEditable: !tagInfo?.isTagExisting, isSegNameEditable: !tagInfo?.isTagExisting,
value: valueUsedInTransform, value: valueUsedInTransform,
initialVariableName: 'offset', initialVariableName: 'offset',
} as any)
if (segName === tagInfo?.tag && value === valueUsedInTransform) {
kclManager.updateAst(modifiedAst, true, {
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
}) })
} else { if (segName === tagInfo?.tag && Number(value) === valueUsedInTransform) {
return {
modifiedAst,
pathToNodeMap,
}
}
// transform again but forcing certain values // transform again but forcing certain values
const finalValue = removeDoubleNegatives( const finalValue = removeDoubleNegatives(
valueNode as BinaryPart, valueNode as BinaryPart,
sign, sign,
variableName variableName
) )
const { modifiedAst: _modifiedAst, pathToNodeMap } = const { modifiedAst: _modifiedAst, pathToNodeMap: _pathToNodeMap } =
transformSecondarySketchLinesTagFirst({ transformSecondarySketchLinesTagFirst({
ast: kclManager.ast, ast: kclManager.ast,
selectionRanges: forecdSelectionRanges, selectionRanges: forcedSelectionRanges,
transformInfos, transformInfos: transforms,
programMemory: kclManager.programMemory, programMemory: kclManager.programMemory,
forceSegName: segName, forceSegName: segName,
forceValueUsedInTransform: finalValue, forceValueUsedInTransform: finalValue,
@ -174,16 +169,8 @@ export const Intersect = () => {
) )
_modifiedAst.body = newBody _modifiedAst.body = newBody
} }
kclManager.updateAst(_modifiedAst, true, { return {
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap), modifiedAst: _modifiedAst,
}) pathToNodeMap: _pathToNodeMap,
} }
}}
disabled={!enable}
title="Set Perpendicular Distance"
>
Set Perpendicular Distance
</button>
)
} }
*/

View File

@ -1,27 +1,21 @@
import { useState, useEffect } from 'react' import { Selections, toolTips } from '../../useStore'
import { toolTips, useStore } from '../../useStore' import { Program, Value } from '../../lang/wasm'
import { Value } from '../../lang/wasm'
import { import {
getNodePathFromSourceRange, getNodePathFromSourceRange,
getNodeFromPath, getNodeFromPath,
} from '../../lang/queryAst' } from '../../lang/queryAst'
import { import {
TransformInfo, PathToNodeMap,
getRemoveConstraintsTransforms, getRemoveConstraintsTransforms,
transformAstSketchLines, transformAstSketchLines,
} from '../../lang/std/sketchcombos' } from '../../lang/std/sketchcombos'
import { kclManager } from 'lang/KclSinglton' import { kclManager } from 'lang/KclSinglton'
/* export function removeConstrainingValuesInfo({
export const RemoveConstrainingValues = () => { selectionRanges,
const { guiMode, selectionRanges, setCursor } = useStore((s) => ({ }: {
guiMode: s.guiMode, selectionRanges: Selections
selectionRanges: s.selectionRanges, }) {
setCursor: s.setCursor,
}))
const [enableHorz, setEnableHorz] = useState(false)
const [transformInfos, setTransformInfos] = useState<TransformInfo[]>()
useEffect(() => {
const paths = selectionRanges.codeBasedSelections.map(({ range }) => const paths = selectionRanges.codeBasedSelections.map(({ range }) =>
getNodePathFromSourceRange(kclManager.ast, range) getNodePathFromSourceRange(kclManager.ast, range)
) )
@ -35,41 +29,34 @@ export const RemoveConstrainingValues = () => {
) )
try { try {
const theTransforms = getRemoveConstraintsTransforms( const transforms = getRemoveConstraintsTransforms(
selectionRanges, selectionRanges,
kclManager.ast, kclManager.ast,
'removeConstrainingValues' 'removeConstrainingValues'
) )
setTransformInfos(theTransforms)
const _enableHorz = isAllTooltips && theTransforms.every(Boolean) const enabled = isAllTooltips && transforms.every(Boolean)
setEnableHorz(_enableHorz) return { enabled, transforms }
} catch (e) { } catch (e) {
console.error(e) console.error(e)
return { enabled: false, transforms: [] }
}
} }
}, [guiMode, selectionRanges])
if (guiMode.mode !== 'sketch') return null
return ( export function applyRemoveConstrainingValues({
<button selectionRanges,
onClick={() => { }: {
if (!transformInfos) return selectionRanges: Selections
const { modifiedAst, pathToNodeMap } = transformAstSketchLines({ }): {
modifiedAst: Program
pathToNodeMap: PathToNodeMap
} {
const { transforms } = removeConstrainingValuesInfo({ selectionRanges })
return transformAstSketchLines({
ast: kclManager.ast, ast: kclManager.ast,
selectionRanges, selectionRanges,
transformInfos, transformInfos: transforms,
programMemory: kclManager.programMemory, programMemory: kclManager.programMemory,
referenceSegName: '', referenceSegName: '',
}) })
kclManager.updateAst(modifiedAst, true, {
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
})
}}
disabled={!enableHorz}
title="Remove Constraining Values"
>
Remove Constraining Values
</button>
)
} }
*/

View File

@ -1,18 +1,18 @@
import { useState, useEffect } from 'react' import { Selections, toolTips } from '../../useStore'
import { create } from 'react-modal-promise' import { BinaryPart, Program, Value } from '../../lang/wasm'
import { toolTips, useStore } from '../../useStore'
import { Value } from '../../lang/wasm'
import { import {
getNodePathFromSourceRange, getNodePathFromSourceRange,
getNodeFromPath, getNodeFromPath,
} from '../../lang/queryAst' } from '../../lang/queryAst'
import { import {
TransformInfo,
getTransformInfos, getTransformInfos,
transformAstSketchLines, transformAstSketchLines,
ConstraintType, PathToNodeMap,
} from '../../lang/std/sketchcombos' } from '../../lang/std/sketchcombos'
import { SetAngleLengthModal } from '../SetAngleLengthModal' import {
SetAngleLengthModal,
createSetAngleLengthModal,
} from '../SetAngleLengthModal'
import { import {
createIdentifier, createIdentifier,
createVariableDeclaration, createVariableDeclaration,
@ -20,40 +20,29 @@ import {
import { removeDoubleNegatives } from '../AvailableVarsHelpers' import { removeDoubleNegatives } from '../AvailableVarsHelpers'
import { kclManager } from 'lang/KclSinglton' import { kclManager } from 'lang/KclSinglton'
const getModalInfo = create(SetAngleLengthModal as any) const getModalInfo = createSetAngleLengthModal(SetAngleLengthModal)
type ButtonType = 'xAbs' | 'yAbs' | 'snapToYAxis' | 'snapToXAxis' type Constraint = 'xAbs' | 'yAbs' | 'snapToYAxis' | 'snapToXAxis'
const buttonLabels: Record<ButtonType, string> = { export function absDistanceInfo({
xAbs: 'Set distance from X Axis', selectionRanges,
yAbs: 'Set distance from Y Axis', constraint,
snapToYAxis: 'Snap To Y Axis', }: {
snapToXAxis: 'Snap To X Axis', selectionRanges: Selections
} constraint: Constraint
}) {
/* const disType =
export const SetAbsDistance = ({ buttonType }: { buttonType: ButtonType }) => { constraint === 'xAbs' || constraint === 'yAbs'
const { guiMode, selectionRanges, setCursor } = useStore((s) => ({ ? constraint
guiMode: s.guiMode, : constraint === 'snapToYAxis'
selectionRanges: s.selectionRanges,
setCursor: s.setCursor,
}))
const disType: ConstraintType =
buttonType === 'xAbs' || buttonType === 'yAbs'
? buttonType
: buttonType === 'snapToYAxis'
? 'xAbs' ? 'xAbs'
: 'yAbs' : 'yAbs'
const [enableAngLen, setEnableAngLen] = useState(false)
const [transformInfos, setTransformInfos] = useState<TransformInfo[]>()
useEffect(() => {
const paths = selectionRanges.codeBasedSelections.map(({ range }) => const paths = selectionRanges.codeBasedSelections.map(({ range }) =>
getNodePathFromSourceRange(kclManager.ast, range) getNodePathFromSourceRange(kclManager.ast, range)
) )
const nodes = paths.map( const nodes = paths.map(
(pathToNode) => (pathToNode) =>
getNodeFromPath<Value>(kclManager.ast, pathToNode, 'CallExpression') getNodeFromPath<Value>(kclManager.ast, pathToNode, 'CallExpression').node
.node
) )
const isAllTooltips = nodes.every( const isAllTooltips = nodes.every(
(node) => (node) =>
@ -61,12 +50,7 @@ export const SetAbsDistance = ({ buttonType }: { buttonType: ButtonType }) => {
toolTips.includes(node.callee.name as any) toolTips.includes(node.callee.name as any)
) )
const theTransforms = getTransformInfos( const transforms = getTransformInfos(selectionRanges, kclManager.ast, disType)
selectionRanges,
kclManager.ast,
disType
)
setTransformInfos(theTransforms)
const enableY = const enableY =
disType === 'yAbs' && disType === 'yAbs' &&
@ -77,21 +61,29 @@ export const SetAbsDistance = ({ buttonType }: { buttonType: ButtonType }) => {
selectionRanges.otherSelections.length === 1 && selectionRanges.otherSelections.length === 1 &&
selectionRanges.otherSelections[0] === 'y-axis' // select the y axis to set the distance from it i.e. x selectionRanges.otherSelections[0] === 'y-axis' // select the y axis to set the distance from it i.e. x
const _enableHorz = const enabled =
isAllTooltips && isAllTooltips &&
theTransforms.every(Boolean) && transforms.every(Boolean) &&
selectionRanges.codeBasedSelections.length === 1 && selectionRanges.codeBasedSelections.length === 1 &&
(enableX || enableY) (enableX || enableY)
setEnableAngLen(_enableHorz)
}, [guiMode, selectionRanges])
if (guiMode.mode !== 'sketch') return null
const isAlign = buttonType === 'snapToYAxis' || buttonType === 'snapToXAxis' return { enabled, transforms }
}
return ( export async function applyConstraintAbsDistance({
<button selectionRanges,
onClick={async () => { constraint,
if (!transformInfos) return }: {
selectionRanges: Selections
constraint: 'xAbs' | 'yAbs'
}): Promise<{
modifiedAst: Program
pathToNodeMap: PathToNodeMap
}> {
const transformInfos = absDistanceInfo({
selectionRanges,
constraint,
}).transforms
const { valueUsedInTransform } = transformAstSketchLines({ const { valueUsedInTransform } = transformAstSketchLines({
ast: JSON.parse(JSON.stringify(kclManager.ast)), ast: JSON.parse(JSON.stringify(kclManager.ast)),
selectionRanges: selectionRanges, selectionRanges: selectionRanges,
@ -99,20 +91,19 @@ export const SetAbsDistance = ({ buttonType }: { buttonType: ButtonType }) => {
programMemory: kclManager.programMemory, programMemory: kclManager.programMemory,
referenceSegName: '', referenceSegName: '',
}) })
try {
let forceVal = valueUsedInTransform || 0 let forceVal = valueUsedInTransform || 0
const { valueNode, variableName, newVariableInsertIndex, sign } = const { valueNode, variableName, newVariableInsertIndex, sign } =
await (!isAlign && await getModalInfo({
getModalInfo({
value: forceVal, value: forceVal,
valueName: disType === 'yAbs' ? 'yDis' : 'xDis', valueName: constraint === 'yAbs' ? 'yDis' : 'xDis',
} as any)) })
let finalValue = isAlign let finalValue = removeDoubleNegatives(
? createIdentifier('_0') valueNode as BinaryPart,
: removeDoubleNegatives(valueNode, sign, variableName) sign,
variableName
)
const { modifiedAst: _modifiedAst, pathToNodeMap } = const { modifiedAst: _modifiedAst, pathToNodeMap } = transformAstSketchLines({
transformAstSketchLines({
ast: JSON.parse(JSON.stringify(kclManager.ast)), ast: JSON.parse(JSON.stringify(kclManager.ast)),
selectionRanges: selectionRanges, selectionRanges: selectionRanges,
transformInfos, transformInfos,
@ -129,19 +120,32 @@ export const SetAbsDistance = ({ buttonType }: { buttonType: ButtonType }) => {
) )
_modifiedAst.body = newBody _modifiedAst.body = newBody
} }
return { modifiedAst: _modifiedAst, pathToNodeMap }
}
kclManager.updateAst(_modifiedAst, true, { export function applyConstraintAxisAlign({
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap), selectionRanges,
constraint,
}: {
selectionRanges: Selections
constraint: 'snapToYAxis' | 'snapToXAxis'
}): {
modifiedAst: Program
pathToNodeMap: PathToNodeMap
} {
const transformInfos = absDistanceInfo({
selectionRanges,
constraint,
}).transforms
let finalValue = createIdentifier('_0')
return transformAstSketchLines({
ast: JSON.parse(JSON.stringify(kclManager.ast)),
selectionRanges: selectionRanges,
transformInfos,
programMemory: kclManager.programMemory,
referenceSegName: '',
forceValueUsedInTransform: finalValue,
}) })
} catch (e) {
console.log('error', e)
} }
}}
disabled={!enableAngLen}
title={buttonLabels[buttonType]}
>
{buttonLabels[buttonType]}
</button>
)
}
*/

View File

@ -1,6 +1,4 @@
import { useState, useEffect } from 'react' import { Selections, toolTips } from '../../useStore'
import { create } from 'react-modal-promise'
import { Selections, toolTips, useStore } from '../../useStore'
import { BinaryPart, Program, Value, VariableDeclarator } from '../../lang/wasm' import { BinaryPart, Program, Value, VariableDeclarator } from '../../lang/wasm'
import { import {
getNodePathFromSourceRange, getNodePathFromSourceRange,
@ -8,107 +6,16 @@ import {
} from '../../lang/queryAst' } from '../../lang/queryAst'
import { isSketchVariablesLinked } from '../../lang/std/sketchConstraints' import { isSketchVariablesLinked } from '../../lang/std/sketchConstraints'
import { import {
TransformInfo,
transformSecondarySketchLinesTagFirst, transformSecondarySketchLinesTagFirst,
getTransformInfos, getTransformInfos,
PathToNodeMap, PathToNodeMap,
} from '../../lang/std/sketchcombos' } from '../../lang/std/sketchcombos'
import { GetInfoModal } from '../SetHorVertDistanceModal' import { GetInfoModal, createInfoModal } from '../SetHorVertDistanceModal'
import { createVariableDeclaration } from '../../lang/modifyAst' import { createVariableDeclaration } from '../../lang/modifyAst'
import { removeDoubleNegatives } from '../AvailableVarsHelpers' import { removeDoubleNegatives } from '../AvailableVarsHelpers'
import { kclManager } from 'lang/KclSinglton' import { kclManager } from 'lang/KclSinglton'
const getModalInfo = create(GetInfoModal as any) const getModalInfo = createInfoModal(GetInfoModal)
/*
export const SetAngleBetween = () => {
const { guiMode, selectionRanges, setCursor } = useStore((s) => ({
guiMode: s.guiMode,
selectionRanges: s.selectionRanges,
setCursor: s.setCursor,
}))
const [enable, setEnable] = useState(false)
const [transformInfos, setTransformInfos] = useState<TransformInfo[]>()
useEffect(() => {
const { enabled, transforms } = angleBetweenInfo({ selectionRanges })
setTransformInfos(transforms)
setEnable(enabled)
}, [guiMode, selectionRanges])
if (guiMode.mode !== 'sketch') return null
return (
<button
onClick={async () => {
if (!transformInfos) return
const { modifiedAst, tagInfo, valueUsedInTransform, pathToNodeMap } =
transformSecondarySketchLinesTagFirst({
ast: JSON.parse(JSON.stringify(kclManager.ast)),
selectionRanges,
transformInfos,
programMemory: kclManager.programMemory,
})
const {
segName,
value,
valueNode,
variableName,
newVariableInsertIndex,
sign,
}: {
segName: string
value: number
valueNode: Value
variableName?: string
newVariableInsertIndex: number
sign: number
} = await getModalInfo({
segName: tagInfo?.tag,
isSegNameEditable: !tagInfo?.isTagExisting,
value: valueUsedInTransform,
initialVariableName: 'angle',
} as any)
if (segName === tagInfo?.tag && value === valueUsedInTransform) {
kclManager.updateAst(modifiedAst, true, {
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
})
} else {
const finalValue = removeDoubleNegatives(
valueNode as BinaryPart,
sign,
variableName
)
// transform again but forcing certain values
const { modifiedAst: _modifiedAst, pathToNodeMap } =
transformSecondarySketchLinesTagFirst({
ast: kclManager.ast,
selectionRanges,
transformInfos,
programMemory: kclManager.programMemory,
forceSegName: segName,
forceValueUsedInTransform: finalValue,
})
if (variableName) {
const newBody = [..._modifiedAst.body]
newBody.splice(
newVariableInsertIndex,
0,
createVariableDeclaration(variableName, valueNode)
)
_modifiedAst.body = newBody
}
kclManager.updateAst(_modifiedAst, true, {
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
})
}
}}
disabled={!enable}
title="Set Angle Between"
>
Set Angle Between
</button>
)
}
*/
export function angleBetweenInfo({ export function angleBetweenInfo({
selectionRanges, selectionRanges,
@ -183,28 +90,17 @@ export async function applyConstraintAngleBetween({
variableName, variableName,
newVariableInsertIndex, newVariableInsertIndex,
sign, sign,
}: {
segName: string
value: number
valueNode: Value
variableName?: string
newVariableInsertIndex: number
sign: number
} = await getModalInfo({ } = await getModalInfo({
segName: tagInfo?.tag, segName: tagInfo?.tag,
isSegNameEditable: !tagInfo?.isTagExisting, isSegNameEditable: !tagInfo?.isTagExisting,
value: valueUsedInTransform, value: valueUsedInTransform,
initialVariableName: 'angle', initialVariableName: 'angle',
} as any) } as any)
if (segName === tagInfo?.tag && value === valueUsedInTransform) { if (segName === tagInfo?.tag && Number(value) === valueUsedInTransform) {
return { return {
modifiedAst, modifiedAst,
pathToNodeMap, pathToNodeMap,
} }
// kclManager.updateAst(modifiedAst, true, {
// TODO handle cursor
// callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
// })
} }
const finalValue = removeDoubleNegatives( const finalValue = removeDoubleNegatives(
@ -235,8 +131,4 @@ export async function applyConstraintAngleBetween({
modifiedAst: _modifiedAst, modifiedAst: _modifiedAst,
pathToNodeMap: _pathToNodeMap, pathToNodeMap: _pathToNodeMap,
} }
// kclManager.updateAst(_modifiedAst, true, {
// TODO handle cursor
// callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
// })
} }

View File

@ -1,6 +1,4 @@
import { useState, useEffect } from 'react' import { toolTips } from '../../useStore'
import { create } from 'react-modal-promise'
import { toolTips, useStore } from '../../useStore'
import { BinaryPart, Program, Value, VariableDeclarator } from '../../lang/wasm' import { BinaryPart, Program, Value, VariableDeclarator } from '../../lang/wasm'
import { import {
getNodePathFromSourceRange, getNodePathFromSourceRange,
@ -8,139 +6,17 @@ import {
} from '../../lang/queryAst' } from '../../lang/queryAst'
import { isSketchVariablesLinked } from '../../lang/std/sketchConstraints' import { isSketchVariablesLinked } from '../../lang/std/sketchConstraints'
import { import {
TransformInfo,
transformSecondarySketchLinesTagFirst, transformSecondarySketchLinesTagFirst,
getTransformInfos, getTransformInfos,
ConstraintType,
PathToNodeMap, PathToNodeMap,
} from '../../lang/std/sketchcombos' } from '../../lang/std/sketchcombos'
import { GetInfoModal } from '../SetHorVertDistanceModal' import { GetInfoModal, createInfoModal } from '../SetHorVertDistanceModal'
import { createLiteral, createVariableDeclaration } from '../../lang/modifyAst' import { createLiteral, createVariableDeclaration } from '../../lang/modifyAst'
import { removeDoubleNegatives } from '../AvailableVarsHelpers' import { removeDoubleNegatives } from '../AvailableVarsHelpers'
import { kclManager } from 'lang/KclSinglton' import { kclManager } from 'lang/KclSinglton'
import { Selections } from 'useStore' import { Selections } from 'useStore'
const getModalInfo = create(GetInfoModal as any) const getModalInfo = createInfoModal(GetInfoModal)
type ButtonType =
| 'setHorzDistance'
| 'setVertDistance'
| 'alignEndsHorizontally'
| 'alignEndsVertically'
const buttonLabels: Record<ButtonType, string> = {
setHorzDistance: 'Set Horizontal Distance',
setVertDistance: 'Set Vertical Distance',
alignEndsHorizontally: 'Align Ends Horizontally',
alignEndsVertically: 'Align Ends Vertically',
}
/*
export const SetHorzVertDistance = ({
buttonType,
}: {
buttonType: ButtonType
}) => {
const { guiMode, selectionRanges, setCursor } = useStore((s) => ({
guiMode: s.guiMode,
selectionRanges: s.selectionRanges,
setCursor: s.setCursor,
}))
const constraint: ConstraintType =
buttonType === 'setHorzDistance' || buttonType === 'setVertDistance'
? buttonType
: buttonType === 'alignEndsHorizontally'
? 'setVertDistance'
: 'setHorzDistance'
const [enable, setEnable] = useState(false)
const [transformInfos, setTransformInfos] = useState<TransformInfo[]>()
useEffect(() => {
const { transforms, enabled } = horzVertDistanceInfo({
selectionRanges,
constraint,
})
setTransformInfos(transforms)
setEnable(enabled)
}, [guiMode, selectionRanges])
if (guiMode.mode !== 'sketch') return null
const isAlign =
buttonType === 'alignEndsHorizontally' ||
buttonType === 'alignEndsVertically'
return (
<button
onClick={async () => {
if (!transformInfos) return
const { modifiedAst, tagInfo, valueUsedInTransform, pathToNodeMap } =
transformSecondarySketchLinesTagFirst({
ast: JSON.parse(JSON.stringify(kclManager.ast)),
selectionRanges,
transformInfos,
programMemory: kclManager.programMemory,
})
const {
segName,
value,
valueNode,
variableName,
newVariableInsertIndex,
sign,
}: {
segName: string
value: number
valueNode: Value
variableName?: string
newVariableInsertIndex: number
sign: number
} = await (!isAlign &&
getModalInfo({
segName: tagInfo?.tag,
isSegNameEditable: !tagInfo?.isTagExisting,
value: valueUsedInTransform,
initialVariableName:
constraint === 'setHorzDistance' ? 'xDis' : 'yDis',
} as any))
if (segName === tagInfo?.tag && value === valueUsedInTransform) {
kclManager.updateAst(modifiedAst, true, {
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
})
} else {
let finalValue = isAlign
? createLiteral(0)
: removeDoubleNegatives(valueNode as BinaryPart, sign, variableName)
// transform again but forcing certain values
const { modifiedAst: _modifiedAst, pathToNodeMap } =
transformSecondarySketchLinesTagFirst({
ast: kclManager.ast,
selectionRanges,
transformInfos,
programMemory: kclManager.programMemory,
forceSegName: segName,
forceValueUsedInTransform: finalValue,
})
if (variableName) {
const newBody = [..._modifiedAst.body]
newBody.splice(
newVariableInsertIndex,
0,
createVariableDeclaration(variableName, valueNode)
)
_modifiedAst.body = newBody
}
kclManager.updateAst(_modifiedAst, true, {
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
})
}
}}
disabled={!enable}
title={buttonLabels[buttonType]}
>
{buttonLabels[buttonType]}
</button>
)
}
*/
export function horzVertDistanceInfo({ export function horzVertDistanceInfo({
selectionRanges, selectionRanges,
@ -201,7 +77,7 @@ export async function applyConstraintHorzVertDistance({
}: { }: {
selectionRanges: Selections selectionRanges: Selections
constraint: 'setHorzDistance' | 'setVertDistance' constraint: 'setHorzDistance' | 'setVertDistance'
isAlign?: boolean isAlign?: false
}): Promise<{ }): Promise<{
modifiedAst: Program modifiedAst: Program
pathToNodeMap: PathToNodeMap pathToNodeMap: PathToNodeMap
@ -224,29 +100,17 @@ export async function applyConstraintHorzVertDistance({
variableName, variableName,
newVariableInsertIndex, newVariableInsertIndex,
sign, sign,
}: { } = await getModalInfo({
segName: string
value: number
valueNode: Value
variableName?: string
newVariableInsertIndex: number
sign: number
} = await (!isAlign &&
getModalInfo({
segName: tagInfo?.tag, segName: tagInfo?.tag,
isSegNameEditable: !tagInfo?.isTagExisting, isSegNameEditable: !tagInfo?.isTagExisting,
value: valueUsedInTransform, value: valueUsedInTransform,
initialVariableName: constraint === 'setHorzDistance' ? 'xDis' : 'yDis', initialVariableName: constraint === 'setHorzDistance' ? 'xDis' : 'yDis',
} as any)) } as any)
if (segName === tagInfo?.tag && value === valueUsedInTransform) { if (segName === tagInfo?.tag && Number(value) === valueUsedInTransform) {
return { return {
modifiedAst, modifiedAst,
pathToNodeMap, pathToNodeMap,
} }
// TODO handle cursor stuff
// kclManager.updateAst(modifiedAst, true, {
// callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
// })
} else { } else {
let finalValue = isAlign let finalValue = isAlign
? createLiteral(0) ? createLiteral(0)
@ -274,10 +138,6 @@ export async function applyConstraintHorzVertDistance({
modifiedAst: _modifiedAst, modifiedAst: _modifiedAst,
pathToNodeMap, pathToNodeMap,
} }
// TODO handle cursor stuff
// kclManager.updateAst(_modifiedAst, true, {
// callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
// })
} }
} }
@ -307,8 +167,4 @@ export function applyConstraintHorzVertAlign({
modifiedAst: modifiedAst, modifiedAst: modifiedAst,
pathToNodeMap, pathToNodeMap,
} }
// TODO handle cursor stuff
// kclManager.updateAst(_modifiedAst, true, {
// callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
// })
} }

View File

@ -1,18 +1,18 @@
import { useState, useEffect } from 'react' import { Selections, toolTips } from '../../useStore'
import { create } from 'react-modal-promise' import { BinaryPart, Program, Value } from '../../lang/wasm'
import { Selections, toolTips, useStore } from '../../useStore'
import { Program, Value } from '../../lang/wasm'
import { import {
getNodePathFromSourceRange, getNodePathFromSourceRange,
getNodeFromPath, getNodeFromPath,
} from '../../lang/queryAst' } from '../../lang/queryAst'
import { import {
PathToNodeMap, PathToNodeMap,
TransformInfo,
getTransformInfos, getTransformInfos,
transformAstSketchLines, transformAstSketchLines,
} from '../../lang/std/sketchcombos' } from '../../lang/std/sketchcombos'
import { SetAngleLengthModal } from '../SetAngleLengthModal' import {
SetAngleLengthModal,
createSetAngleLengthModal,
} from '../SetAngleLengthModal'
import { import {
createBinaryExpressionWithUnary, createBinaryExpressionWithUnary,
createIdentifier, createIdentifier,
@ -22,128 +22,7 @@ import { removeDoubleNegatives } from '../AvailableVarsHelpers'
import { normaliseAngle } from '../../lib/utils' import { normaliseAngle } from '../../lib/utils'
import { kclManager } from 'lang/KclSinglton' import { kclManager } from 'lang/KclSinglton'
const getModalInfo = create(SetAngleLengthModal as any) const getModalInfo = createSetAngleLengthModal(SetAngleLengthModal)
type ButtonType = 'setAngle' | 'setLength'
const buttonLabels: Record<ButtonType, string> = {
setAngle: 'Set Angle',
setLength: 'Set Length',
}
/*
export const SetAngleLength = ({
angleOrLength,
}: {
angleOrLength: ButtonType
}) => {
const { guiMode, selectionRanges, setCursor } = useStore((s) => ({
guiMode: s.guiMode,
selectionRanges: s.selectionRanges,
setCursor: s.setCursor,
}))
const [enableAngLen, setEnableAngLen] = useState(false)
const [transformInfos, setTransformInfos] = useState<TransformInfo[]>()
useEffect(() => {
const { enabled, transforms } = setAngleLengthInfo({
selectionRanges,
angleOrLength,
})
setTransformInfos(transforms)
setEnableAngLen(enabled)
}, [guiMode, selectionRanges])
if (guiMode.mode !== 'sketch') return null
return (
<button
onClick={async () => {
if (!transformInfos) return
const { valueUsedInTransform } = transformAstSketchLines({
ast: JSON.parse(JSON.stringify(kclManager.ast)),
selectionRanges,
transformInfos,
programMemory: kclManager.programMemory,
referenceSegName: '',
})
try {
const isReferencingYAxis =
selectionRanges.otherSelections.length === 1 &&
selectionRanges.otherSelections[0] === 'y-axis'
const isReferencingYAxisAngle =
isReferencingYAxis && angleOrLength === 'setAngle'
const isReferencingXAxis =
selectionRanges.otherSelections.length === 1 &&
selectionRanges.otherSelections[0] === 'x-axis'
const isReferencingXAxisAngle =
isReferencingXAxis && angleOrLength === 'setAngle'
let forceVal = valueUsedInTransform || 0
let calcIdentifier = createIdentifier('_0')
if (isReferencingYAxisAngle) {
calcIdentifier = createIdentifier(forceVal < 0 ? '_270' : '_90')
forceVal = normaliseAngle(forceVal + (forceVal < 0 ? 90 : -90))
} else if (isReferencingXAxisAngle) {
calcIdentifier = createIdentifier(
Math.abs(forceVal) > 90 ? '_180' : '_0'
)
forceVal =
Math.abs(forceVal) > 90
? normaliseAngle(forceVal - 180)
: forceVal
}
const { valueNode, variableName, newVariableInsertIndex, sign } =
await getModalInfo({
value: forceVal,
valueName: angleOrLength === 'setAngle' ? 'angle' : 'length',
shouldCreateVariable: true,
} as any)
let finalValue = removeDoubleNegatives(valueNode, sign, variableName)
if (
isReferencingYAxisAngle ||
(isReferencingXAxisAngle && calcIdentifier.name !== '_0')
) {
finalValue = createBinaryExpressionWithUnary([
calcIdentifier,
finalValue,
])
}
const { modifiedAst: _modifiedAst, pathToNodeMap } =
transformAstSketchLines({
ast: JSON.parse(JSON.stringify(kclManager.ast)),
selectionRanges,
transformInfos,
programMemory: kclManager.programMemory,
referenceSegName: '',
forceValueUsedInTransform: finalValue,
})
if (variableName) {
const newBody = [..._modifiedAst.body]
newBody.splice(
newVariableInsertIndex,
0,
createVariableDeclaration(variableName, valueNode)
)
_modifiedAst.body = newBody
}
kclManager.updateAst(_modifiedAst, true, {
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
})
} catch (e) {
console.log('erorr', e)
}
}}
disabled={!enableAngLen}
title={buttonLabels[angleOrLength]}
>
{buttonLabels[angleOrLength]}
</button>
)
}
*/
export function setAngleLengthInfo({ export function setAngleLengthInfo({
selectionRanges, selectionRanges,
@ -220,8 +99,13 @@ export async function applyConstraintAngleLength({
value: forceVal, value: forceVal,
valueName: angleOrLength === 'setAngle' ? 'angle' : 'length', valueName: angleOrLength === 'setAngle' ? 'angle' : 'length',
shouldCreateVariable: true, shouldCreateVariable: true,
} as any) })
let finalValue = removeDoubleNegatives(valueNode, sign, variableName)
let finalValue = removeDoubleNegatives(
valueNode as BinaryPart,
sign,
variableName
)
if ( if (
isReferencingYAxisAngle || isReferencingYAxisAngle ||
(isReferencingXAxisAngle && calcIdentifier.name !== '_0') (isReferencingXAxisAngle && calcIdentifier.name !== '_0')
@ -251,9 +135,6 @@ export async function applyConstraintAngleLength({
modifiedAst: _modifiedAst, modifiedAst: _modifiedAst,
pathToNodeMap, pathToNodeMap,
} }
// kclManager.updateAst(_modifiedAst, true, {
// callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
// })
} catch (e) { } catch (e) {
console.log('erorr', e) console.log('erorr', e)
throw e throw e

View File

@ -1,12 +1,14 @@
import { SetVarNameModal } from 'components/SetVarNameModal' import {
SetVarNameModal,
createSetVarNameModal,
} from 'components/SetVarNameModal'
import { kclManager } from 'lang/KclSinglton' import { kclManager } from 'lang/KclSinglton'
import { moveValueIntoNewVariable } from 'lang/modifyAst' import { moveValueIntoNewVariable } from 'lang/modifyAst'
import { isNodeSafeToReplace } from 'lang/queryAst' import { isNodeSafeToReplace } from 'lang/queryAst'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { create } from 'react-modal-promise'
import { useModelingContext } from './useModelingContext' import { useModelingContext } from './useModelingContext'
const getModalInfo = create(SetVarNameModal as any) const getModalInfo = createSetVarNameModal(SetVarNameModal)
export function useConvertToVariable() { export function useConvertToVariable() {
const { context } = useModelingContext() const { context } = useModelingContext()
@ -28,7 +30,7 @@ export function useConvertToVariable() {
try { try {
const { variableName } = await getModalInfo({ const { variableName } = await getModalInfo({
valueName: 'var', valueName: 'var',
} as any) })
const { modifiedAst: _modifiedAst } = moveValueIntoNewVariable( const { modifiedAst: _modifiedAst } = moveValueIntoNewVariable(
kclManager.ast, kclManager.ast,

View File

@ -29,6 +29,15 @@ import { extrudeSketch } from 'lang/modifyAst'
import { getNodeFromPath } from '../lang/queryAst' import { getNodeFromPath } from '../lang/queryAst'
import { CallExpression, PipeExpression } from '../lang/wasm' import { CallExpression, PipeExpression } from '../lang/wasm'
import { getConstraintLevelFromSourceRange } from 'lang/std/sketchcombos' import { getConstraintLevelFromSourceRange } from 'lang/std/sketchcombos'
import {
applyConstraintEqualAngle,
equalAngleInfo,
} from 'components/Toolbar/EqualAngle'
import {
applyRemoveConstrainingValues,
removeConstrainingValuesInfo,
} from 'components/Toolbar/RemoveConstrainingValues'
import { intersectInfo } from 'components/Toolbar/Intersect'
export const MODELING_PERSIST_KEY = 'MODELING_PERSIST_KEY' export const MODELING_PERSIST_KEY = 'MODELING_PERSIST_KEY'
@ -52,7 +61,7 @@ export type SetSelections =
export const modelingMachine = createMachine( export const modelingMachine = createMachine(
{ {
/** @xstate-layout N4IgpgJg5mDOIC5QFkD2EwBsCWA7KAxAMICGuAxlgNoAMAuoqAA6qzYAu2qujIAHogDMAVgDsAOmEiAjLMGCAHIIAsAJlHKANCACeiaQDZBEsctGrVATm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zCmcFIcZzD0rkL0hSc4P02jejdgYMyZV+dhU0UUordSYsQjO3WoPKQXI4BM09IzEzXNdga4tre4g4WtBLE0TYm+ced05AmMjzV+TKerXzfkqTBdINMWC8clMwN9OoaQGuIbD-TTasHKJoypKbOxGbTNJrJMlMjrFaAczjJiaXUcqlQsO5YEZE2QEIuVVw9LebWbbLRDDgf+YKYIVVIHAKcIG8kEns9rYwdYAchUcoDBaoU0crPcmcQgzKQsGc4g08rskdC8q8oIB8tpdcFct84mIQ79FQY0Zk2QdQc2A6BUPdEMewTszLUsv1eCiXTIN8BoIGaEVQO+P9BLVdA6XAuQ-HShMHWg0nUPFcgxWzXRLSZacoLSWPUVfIbMXnJ5H-TCRi4PFXD3NQsnDi6rakOkdYSsGeEQUxccixPsIRNTbk00jPNI4yQfeg9il86s-onRMQLSMwaWC1JSERGoj0FQEk-JV5E8o-fS4A9XOS2QC8KQOkF8EMbcpSR+EmC5WwUMU4IgnvWmUghQygpQjg1iz3YyqsyvLbDIFQWoqEKQHTOwsXJ+avDvfjHSucg8dwzwtsZ8lK7WI4UWM1TGcNQsKilCRYc2HYukCxeyWWVI67DoxYuaLWN0XKC8CFYkpdTUqo4JbKJYAofKVE2WWY+YqATonlAazmbA4bFAjaHkWoPY0odIBPKcGwWvHsHCJwIAA */
id: 'Modeling', id: 'Modeling',
tsTypes: {} as import('./modelingMachine.typegen').Typegen0, tsTypes: {} as import('./modelingMachine.typegen').Typegen0,
@ -122,10 +131,13 @@ export const modelingMachine = createMachine(
| { type: 'Constrain horizontal distance' } | { type: 'Constrain horizontal distance' }
| { type: 'Constrain vertical distance' } | { type: 'Constrain vertical distance' }
| { type: 'Constrain angle' } | { type: 'Constrain angle' }
| { type: 'Constrain perpendicular distance' }
| { type: 'Constrain horizontally align' } | { type: 'Constrain horizontally align' }
| { type: 'Constrain vertically align' } | { type: 'Constrain vertically align' }
| { type: 'Constrain length' } | { type: 'Constrain length' }
| { type: 'Constrain equal length' } | { type: 'Constrain equal length' }
| { type: 'Constrain parallel' }
| { type: 'Constrain remove constraints' }
| { type: 'extrude intent' }, | { type: 'extrude intent' },
// , // ,
}, },
@ -356,6 +368,11 @@ export const modelingMachine = createMachine(
cond: 'Can constrain length', cond: 'Can constrain length',
}, },
'Constrain perpendicular distance': {
target: 'Await perpendicular distance info',
cond: 'Can constrain perpendicular distance',
},
'Constrain horizontally align': { 'Constrain horizontally align': {
cond: 'Can constrain horizontally align', cond: 'Can constrain horizontally align',
target: 'SketchIdle', target: 'SketchIdle',
@ -376,6 +393,20 @@ export const modelingMachine = createMachine(
internal: true, internal: true,
actions: ['Constrain equal length'], actions: ['Constrain equal length'],
}, },
'Constrain parallel': {
target: 'SketchIdle',
internal: true,
cond: 'Can canstrain parallel',
actions: ['Constrain parallel'],
},
'Constrain remove constraints': {
target: 'SketchIdle',
internal: true,
cond: 'Can constrain remove constraints',
actions: ['Constrain remove constraints'],
},
}, },
entry: 'equip select', entry: 'equip select',
@ -528,6 +559,18 @@ export const modelingMachine = createMachine(
onError: 'SketchIdle', onError: 'SketchIdle',
}, },
}, },
'Await perpendicular distance info': {
invoke: {
src: 'Get perpendicular distance info',
id: 'get-perpendicular-distance-info',
onDone: {
target: 'SketchIdle',
actions: 'Set selection',
},
onError: 'SketchIdle',
},
},
}, },
initial: 'SketchIdle', initial: 'SketchIdle',
@ -613,6 +656,8 @@ export const modelingMachine = createMachine(
angleBetweenInfo({ selectionRanges }).enabled, angleBetweenInfo({ selectionRanges }).enabled,
'Can constrain length': ({ selectionRanges }) => 'Can constrain length': ({ selectionRanges }) =>
setAngleLengthInfo({ selectionRanges }).enabled, setAngleLengthInfo({ selectionRanges }).enabled,
'Can constrain perpendicular distance': ({ selectionRanges }) =>
intersectInfo({ selectionRanges }).enabled,
'Can constrain horizontally align': ({ selectionRanges }) => 'Can constrain horizontally align': ({ selectionRanges }) =>
horzVertDistanceInfo({ selectionRanges, constraint: 'setHorzDistance' }) horzVertDistanceInfo({ selectionRanges, constraint: 'setHorzDistance' })
.enabled, .enabled,
@ -621,6 +666,10 @@ export const modelingMachine = createMachine(
.enabled, .enabled,
'Can constrain equal length': ({ selectionRanges }) => 'Can constrain equal length': ({ selectionRanges }) =>
setEqualLengthInfo({ selectionRanges }).enabled, setEqualLengthInfo({ selectionRanges }).enabled,
'Can canstrain parallel': ({ selectionRanges }) =>
equalAngleInfo({ selectionRanges }).enabled,
'Can constrain remove constraints': ({ selectionRanges }) =>
removeConstrainingValuesInfo({ selectionRanges }).enabled,
'has no selection': ({ selectionRanges }) => { 'has no selection': ({ selectionRanges }) => {
if (selectionRanges?.codeBasedSelections?.length < 1) return true if (selectionRanges?.codeBasedSelections?.length < 1) return true
const selection = selectionRanges?.codeBasedSelections?.[0] || {} const selection = selectionRanges?.codeBasedSelections?.[0] || {}
@ -825,6 +874,8 @@ export const modelingMachine = createMachine(
tool: 'move', tool: 'move',
}, },
}), }),
// TODO implement source ranges for all of these constraints
// need to make the async like the modal constraints
'Make selection horizontal': ({ selectionRanges }) => { 'Make selection horizontal': ({ selectionRanges }) => {
const { modifiedAst, pathToNodeMap } = applyConstraintHorzVert( const { modifiedAst, pathToNodeMap } = applyConstraintHorzVert(
selectionRanges, selectionRanges,
@ -832,10 +883,7 @@ export const modelingMachine = createMachine(
kclManager.ast, kclManager.ast,
kclManager.programMemory kclManager.programMemory
) )
kclManager.updateAst(modifiedAst, true, { kclManager.updateAst(modifiedAst, true)
// TODO re implement cursor shit
// callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
})
}, },
'Make selection vertical': ({ selectionRanges }) => { 'Make selection vertical': ({ selectionRanges }) => {
const { modifiedAst, pathToNodeMap } = applyConstraintHorzVert( const { modifiedAst, pathToNodeMap } = applyConstraintHorzVert(
@ -844,39 +892,39 @@ export const modelingMachine = createMachine(
kclManager.ast, kclManager.ast,
kclManager.programMemory kclManager.programMemory
) )
kclManager.updateAst(modifiedAst, true, { kclManager.updateAst(modifiedAst, true)
// TODO re implement cursor shit
// callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
})
}, },
'Constrain horizontally align': ({ selectionRanges }) => { 'Constrain horizontally align': ({ selectionRanges }) => {
const { modifiedAst, pathToNodeMap } = applyConstraintHorzVertAlign({ const { modifiedAst, pathToNodeMap } = applyConstraintHorzVertAlign({
selectionRanges, selectionRanges,
constraint: 'setVertDistance', constraint: 'setVertDistance',
}) })
kclManager.updateAst(modifiedAst, true, { kclManager.updateAst(modifiedAst, true)
// TODO re implement cursor shit
// callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
})
}, },
'Constrain vertically align': ({ selectionRanges }) => { 'Constrain vertically align': ({ selectionRanges }) => {
const { modifiedAst, pathToNodeMap } = applyConstraintHorzVertAlign({ const { modifiedAst, pathToNodeMap } = applyConstraintHorzVertAlign({
selectionRanges, selectionRanges,
constraint: 'setHorzDistance', constraint: 'setHorzDistance',
}) })
kclManager.updateAst(modifiedAst, true, { kclManager.updateAst(modifiedAst, true)
// TODO re implement cursor shit
// callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
})
}, },
'Constrain equal length': ({ selectionRanges }) => { 'Constrain equal length': ({ selectionRanges }) => {
const { modifiedAst, pathToNodeMap } = applyConstraintEqualLength({ const { modifiedAst, pathToNodeMap } = applyConstraintEqualLength({
selectionRanges, selectionRanges,
}) })
kclManager.updateAst(modifiedAst, true, { kclManager.updateAst(modifiedAst, true)
// TODO re implement cursor shit },
// callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap), 'Constrain parallel': ({ selectionRanges }) => {
const { modifiedAst, pathToNodeMap } = applyConstraintEqualAngle({
selectionRanges,
}) })
kclManager.updateAst(modifiedAst, true)
},
'Constrain remove constraints': ({ selectionRanges }) => {
const { modifiedAst, pathToNodeMap } = applyRemoveConstrainingValues({
selectionRanges,
})
kclManager.updateAst(modifiedAst, true)
}, },
'AST extrude': ({ selectionRanges }) => { 'AST extrude': ({ selectionRanges }) => {
const pathToNode = getNodePathFromSourceRange( const pathToNode = getNodePathFromSourceRange(

View File

@ -8,10 +8,12 @@
"done.invoke.get-angle-info": { type: "done.invoke.get-angle-info"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; "done.invoke.get-angle-info": { type: "done.invoke.get-angle-info"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." };
"done.invoke.get-horizontal-info": { type: "done.invoke.get-horizontal-info"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; "done.invoke.get-horizontal-info": { type: "done.invoke.get-horizontal-info"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." };
"done.invoke.get-length-info": { type: "done.invoke.get-length-info"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; "done.invoke.get-length-info": { type: "done.invoke.get-length-info"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." };
"done.invoke.get-perpendicular-distance-info": { type: "done.invoke.get-perpendicular-distance-info"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." };
"done.invoke.get-vertical-info": { type: "done.invoke.get-vertical-info"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." }; "done.invoke.get-vertical-info": { type: "done.invoke.get-vertical-info"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." };
"error.platform.get-angle-info": { type: "error.platform.get-angle-info"; data: unknown }; "error.platform.get-angle-info": { type: "error.platform.get-angle-info"; data: unknown };
"error.platform.get-horizontal-info": { type: "error.platform.get-horizontal-info"; data: unknown }; "error.platform.get-horizontal-info": { type: "error.platform.get-horizontal-info"; data: unknown };
"error.platform.get-length-info": { type: "error.platform.get-length-info"; data: unknown }; "error.platform.get-length-info": { type: "error.platform.get-length-info"; data: unknown };
"error.platform.get-perpendicular-distance-info": { type: "error.platform.get-perpendicular-distance-info"; data: unknown };
"error.platform.get-vertical-info": { type: "error.platform.get-vertical-info"; data: unknown }; "error.platform.get-vertical-info": { type: "error.platform.get-vertical-info"; data: unknown };
"xstate.init": { type: "xstate.init" }; "xstate.init": { type: "xstate.init" };
"xstate.stop": { type: "xstate.stop" }; "xstate.stop": { type: "xstate.stop" };
@ -20,13 +22,14 @@
"Get angle info": "done.invoke.get-angle-info"; "Get angle info": "done.invoke.get-angle-info";
"Get horizontal info": "done.invoke.get-horizontal-info"; "Get horizontal info": "done.invoke.get-horizontal-info";
"Get length info": "done.invoke.get-length-info"; "Get length info": "done.invoke.get-length-info";
"Get perpendicular distance info": "done.invoke.get-perpendicular-distance-info";
"Get vertical info": "done.invoke.get-vertical-info"; "Get vertical info": "done.invoke.get-vertical-info";
}; };
missingImplementations: { missingImplementations: {
actions: "AST add line segment" | "AST start new sketch" | "Modify AST" | "Set selection" | "Update code selection cursors" | "create path" | "set tool" | "show default planes" | "sketch exit execute" | "toast extrude failed"; actions: "AST add line segment" | "AST start new sketch" | "Modify AST" | "Set selection" | "Update code selection cursors" | "create path" | "set tool" | "show default planes" | "sketch exit execute" | "toast extrude failed";
delays: never; delays: never;
guards: "Selection contains axis" | "Selection contains edge" | "Selection contains face" | "Selection contains line" | "Selection contains point" | "Selection is not empty" | "Selection is one face"; guards: "Selection contains axis" | "Selection contains edge" | "Selection contains face" | "Selection contains line" | "Selection contains point" | "Selection is not empty" | "Selection is one face";
services: "Get angle info" | "Get horizontal info" | "Get length info" | "Get vertical info"; services: "Get angle info" | "Get horizontal info" | "Get length info" | "Get perpendicular distance info" | "Get vertical info";
}; };
eventsCausingActions: { eventsCausingActions: {
"AST add line segment": "Add point"; "AST add line segment": "Add point";
@ -37,19 +40,21 @@
"Clear selection": "Deselect all"; "Clear selection": "Deselect all";
"Constrain equal length": "Constrain equal length"; "Constrain equal length": "Constrain equal length";
"Constrain horizontally align": "Constrain horizontally align"; "Constrain horizontally align": "Constrain horizontally align";
"Constrain parallel": "Constrain parallel";
"Constrain remove constraints": "Constrain remove constraints";
"Constrain vertically align": "Constrain vertically align"; "Constrain vertically align": "Constrain vertically align";
"Make selection horizontal": "Make segment horizontal"; "Make selection horizontal": "Make segment horizontal";
"Make selection vertical": "Make segment vertical"; "Make selection vertical": "Make segment vertical";
"Modify AST": "Complete line"; "Modify AST": "Complete line";
"Remove from code-based selection": "Deselect edge" | "Deselect face" | "Deselect point"; "Remove from code-based selection": "Deselect edge" | "Deselect face" | "Deselect point";
"Remove from other selection": "Deselect axis"; "Remove from other selection": "Deselect axis";
"Set selection": "Set selection" | "done.invoke.get-angle-info" | "done.invoke.get-horizontal-info" | "done.invoke.get-length-info" | "done.invoke.get-vertical-info"; "Set selection": "Set selection" | "done.invoke.get-angle-info" | "done.invoke.get-horizontal-info" | "done.invoke.get-length-info" | "done.invoke.get-perpendicular-distance-info" | "done.invoke.get-vertical-info";
"Update code selection cursors": "Complete line" | "Deselect all" | "Deselect axis" | "Deselect edge" | "Deselect face" | "Deselect point" | "Deselect segment" | "Select edge" | "Select face" | "Select point" | "Select segment"; "Update code selection cursors": "Complete line" | "Deselect all" | "Deselect axis" | "Deselect edge" | "Deselect face" | "Deselect point" | "Deselect segment" | "Select edge" | "Select face" | "Select point" | "Select segment";
"create path": "Select default plane"; "create path": "Select default plane";
"default_camera_disable_sketch_mode": "Cancel"; "default_camera_disable_sketch_mode": "Cancel";
"edit mode enter": "Enter sketch"; "edit mode enter": "Enter sketch";
"edit_mode_exit": "Cancel"; "edit_mode_exit": "Cancel";
"equip select": "CancelSketch" | "Constrain equal length" | "Constrain horizontally align" | "Constrain vertically align" | "Deselect point" | "Deselect segment" | "Enter sketch" | "Make segment horizontal" | "Make segment vertical" | "Select default plane" | "Select point" | "Select segment" | "Set selection" | "done.invoke.get-angle-info" | "done.invoke.get-horizontal-info" | "done.invoke.get-length-info" | "done.invoke.get-vertical-info" | "error.platform.get-angle-info" | "error.platform.get-horizontal-info" | "error.platform.get-length-info" | "error.platform.get-vertical-info"; "equip select": "CancelSketch" | "Constrain equal length" | "Constrain horizontally align" | "Constrain parallel" | "Constrain remove constraints" | "Constrain vertically align" | "Deselect point" | "Deselect segment" | "Enter sketch" | "Make segment horizontal" | "Make segment vertical" | "Select default plane" | "Select point" | "Select segment" | "Set selection" | "done.invoke.get-angle-info" | "done.invoke.get-horizontal-info" | "done.invoke.get-length-info" | "done.invoke.get-perpendicular-distance-info" | "done.invoke.get-vertical-info" | "error.platform.get-angle-info" | "error.platform.get-horizontal-info" | "error.platform.get-length-info" | "error.platform.get-perpendicular-distance-info" | "error.platform.get-vertical-info";
"hide default planes": "Cancel" | "Select default plane" | "xstate.stop"; "hide default planes": "Cancel" | "Select default plane" | "xstate.stop";
"reset sketch metadata": "Cancel" | "Select default plane"; "reset sketch metadata": "Cancel" | "Select default plane";
"set default plane id": "Select default plane"; "set default plane id": "Select default plane";
@ -66,11 +71,14 @@
}; };
eventsCausingGuards: { eventsCausingGuards: {
"Can canstrain parallel": "Constrain parallel";
"Can constrain angle": "Constrain angle"; "Can constrain angle": "Constrain angle";
"Can constrain equal length": "Constrain equal length"; "Can constrain equal length": "Constrain equal length";
"Can constrain horizontal distance": "Constrain horizontal distance"; "Can constrain horizontal distance": "Constrain horizontal distance";
"Can constrain horizontally align": "Constrain horizontally align"; "Can constrain horizontally align": "Constrain horizontally align";
"Can constrain length": "Constrain length"; "Can constrain length": "Constrain length";
"Can constrain perpendicular distance": "Constrain perpendicular distance";
"Can constrain remove constraints": "Constrain remove constraints";
"Can constrain vertical distance": "Constrain vertical distance"; "Can constrain vertical distance": "Constrain vertical distance";
"Can constrain vertically align": "Constrain vertically align"; "Can constrain vertically align": "Constrain vertically align";
"Can make selection horizontal": "Make segment horizontal"; "Can make selection horizontal": "Make segment horizontal";
@ -92,9 +100,10 @@
"Get angle info": "Constrain angle"; "Get angle info": "Constrain angle";
"Get horizontal info": "Constrain horizontal distance"; "Get horizontal info": "Constrain horizontal distance";
"Get length info": "Constrain length"; "Get length info": "Constrain length";
"Get perpendicular distance info": "Constrain perpendicular distance";
"Get vertical info": "Constrain vertical distance"; "Get vertical info": "Constrain vertical distance";
}; };
matchesStates: "Sketch" | "Sketch no face" | "Sketch.Await angle info" | "Sketch.Await horizontal distance info" | "Sketch.Await length info" | "Sketch.Await vertical distance info" | "Sketch.Line Tool" | "Sketch.Line Tool.Done" | "Sketch.Line Tool.Init" | "Sketch.Line Tool.No Points" | "Sketch.Line Tool.Point Added" | "Sketch.Line Tool.Segment Added" | "Sketch.Move Tool" | "Sketch.Move Tool.Move init" | "Sketch.Move Tool.Move with execute" | "Sketch.Move Tool.Move without re-execute" | "Sketch.Move Tool.No move" | "Sketch.SketchIdle" | "awaiting selection" | "checking selection" | "idle" | { "Sketch"?: "Await angle info" | "Await horizontal distance info" | "Await length info" | "Await vertical distance info" | "Line Tool" | "Move Tool" | "SketchIdle" | { "Line Tool"?: "Done" | "Init" | "No Points" | "Point Added" | "Segment Added"; matchesStates: "Sketch" | "Sketch no face" | "Sketch.Await angle info" | "Sketch.Await horizontal distance info" | "Sketch.Await length info" | "Sketch.Await perpendicular distance info" | "Sketch.Await vertical distance info" | "Sketch.Line Tool" | "Sketch.Line Tool.Done" | "Sketch.Line Tool.Init" | "Sketch.Line Tool.No Points" | "Sketch.Line Tool.Point Added" | "Sketch.Line Tool.Segment Added" | "Sketch.Move Tool" | "Sketch.Move Tool.Move init" | "Sketch.Move Tool.Move with execute" | "Sketch.Move Tool.Move without re-execute" | "Sketch.Move Tool.No move" | "Sketch.SketchIdle" | "awaiting selection" | "checking selection" | "idle" | { "Sketch"?: "Await angle info" | "Await horizontal distance info" | "Await length info" | "Await perpendicular distance info" | "Await vertical distance info" | "Line Tool" | "Move Tool" | "SketchIdle" | { "Line Tool"?: "Done" | "Init" | "No Points" | "Point Added" | "Segment Added";
"Move Tool"?: "Move init" | "Move with execute" | "Move without re-execute" | "No move"; }; }; "Move Tool"?: "Move init" | "Move with execute" | "Move without re-execute" | "No move"; }; };
tags: never; tags: never;
} }