Users should be able to select points (not just lines) (#97)

* update selection datastructure to accomodate more selection metadata

* Users should be able to select points (not just lines)
This commit is contained in:
Kurt Hutten
2023-04-03 16:05:25 +10:00
committed by GitHub
parent 7013eb861d
commit a8b68bab6a
25 changed files with 292 additions and 146 deletions

View File

@ -64,7 +64,7 @@ export function getCoordsFromPaths(skGroup: SketchGroup, index = 0): Coords2d {
export function createFirstArg(
sketchFn: TooTip,
val: Value | [Value, Value],
val: Value | [Value, Value] | [Value, Value, Value],
tag?: Value
): Value {
if (!tag) {
@ -84,6 +84,13 @@ export function createFirstArg(
return createObjectExpression({ angle: val[0], length: val[1], tag })
if (['angledLineToX', 'angledLineToY'].includes(sketchFn))
return createObjectExpression({ angle: val[0], to: val[1], tag })
if (['angledLineThatIntersects'].includes(sketchFn) && val[2])
return createObjectExpression({
angle: val[0],
offset: val[1],
intersectTag: val[2],
tag,
})
} else {
if (['xLine', 'yLine'].includes(sketchFn))
return createObjectExpression({ length: val, tag })
@ -1678,7 +1685,7 @@ function getFirstArgValuesForXYLineFns(callExpression: CallExpression): {
const getAngledLineThatIntersects = (
callExp: CallExpression
): {
val: [Value, Value]
val: [Value, Value, Value]
tag?: Value
} => {
const firstArg = callExp.arguments[0]
@ -1688,15 +1695,18 @@ const getAngledLineThatIntersects = (
const offset = firstArg.properties.find(
(p) => p.key.name === 'offset'
)?.value
if (angle && offset) {
return { val: [angle, offset], tag }
const intersectTag = firstArg.properties.find(
(p) => p.key.name === 'intersectTag'
)?.value
if (angle && offset && intersectTag) {
return { val: [angle, offset, intersectTag], tag }
}
}
throw new Error('expected ArrayExpression or ObjectExpression')
}
export function getFirstArg(callExp: CallExpression): {
val: Value | [Value, Value]
val: Value | [Value, Value] | [Value, Value, Value]
tag?: Value
} {
const name = callExp?.callee?.name