Use new Point3d for named views (#6102)
* Use new Point3d for named views * Wait a bit for the file menu to be created --------- Co-authored-by: Jace Browning <jacebrowning@gmail.com> Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
This commit is contained in:
@ -10,6 +10,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
|
||||
test('File.Create project', async ({ tronApp, cmdBar, page }) => {
|
||||
if (!tronApp) fail()
|
||||
// Run electron snippet to find the Menu!
|
||||
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
|
||||
await tronApp.electron.evaluate(async ({ app }) => {
|
||||
if (!app || !app.applicationMenu) fail()
|
||||
const newProject =
|
||||
@ -29,6 +30,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
|
||||
test('File.Open project', async ({ tronApp, cmdBar, page }) => {
|
||||
if (!tronApp) fail()
|
||||
// Run electron snippet to find the Menu!
|
||||
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
|
||||
await tronApp.electron.evaluate(async ({ app }) => {
|
||||
if (!app || !app.applicationMenu) fail()
|
||||
const openProject =
|
||||
@ -52,6 +54,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
|
||||
}) => {
|
||||
if (!tronApp) fail()
|
||||
// Run electron snippet to find the Menu!
|
||||
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
|
||||
await tronApp.electron.evaluate(async ({ app }) => {
|
||||
if (!app || !app.applicationMenu) fail()
|
||||
const userSettings = app.applicationMenu.getMenuItemById(
|
||||
@ -75,6 +78,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
|
||||
}) => {
|
||||
if (!tronApp) fail()
|
||||
// Run electron snippet to find the Menu!
|
||||
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
|
||||
await tronApp.electron.evaluate(async ({ app }) => {
|
||||
if (!app || !app.applicationMenu) fail()
|
||||
const keybindings = app.applicationMenu.getMenuItemById(
|
||||
@ -96,6 +100,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
|
||||
}) => {
|
||||
if (!tronApp) fail()
|
||||
// Run electron snippet to find the Menu!
|
||||
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
|
||||
await tronApp.electron.evaluate(async ({ app }) => {
|
||||
if (!app || !app.applicationMenu) fail()
|
||||
const menu = app.applicationMenu.getMenuItemById(
|
||||
@ -112,6 +117,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
|
||||
test('File.Preferences.Theme', async ({ tronApp, cmdBar, page }) => {
|
||||
if (!tronApp) fail()
|
||||
// Run electron snippet to find the Menu!
|
||||
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
|
||||
await tronApp.electron.evaluate(async ({ app }) => {
|
||||
if (!app || !app.applicationMenu) fail()
|
||||
const menu = app.applicationMenu.getMenuItemById(
|
||||
@ -136,6 +142,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
|
||||
}) => {
|
||||
if (!tronApp) fail()
|
||||
// Run electron snippet to find the Menu!
|
||||
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
|
||||
await tronApp.electron.evaluate(async ({ app }) => {
|
||||
if (!app || !app.applicationMenu) fail()
|
||||
const menu = app.applicationMenu.getMenuItemById(
|
||||
@ -152,6 +159,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
|
||||
test('File.Preferences.Sign out', async ({ tronApp, cmdBar, page }) => {
|
||||
if (!tronApp) fail()
|
||||
// Run electron snippet to find the Menu!
|
||||
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
|
||||
await tronApp.electron.evaluate(async ({ app }) => {
|
||||
if (!app || !app.applicationMenu) fail()
|
||||
const menu = app.applicationMenu.getMenuItemById('File.Sign out')
|
||||
@ -170,6 +178,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
|
||||
test('Edit.Rename project', async ({ tronApp, cmdBar, page }) => {
|
||||
if (!tronApp) fail()
|
||||
// Run electron snippet to find the Menu!
|
||||
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
|
||||
await tronApp.electron.evaluate(async ({ app }) => {
|
||||
if (!app || !app.applicationMenu) fail()
|
||||
const menu = app.applicationMenu.getMenuItemById(
|
||||
@ -188,6 +197,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
|
||||
test('Edit.Delete project', async ({ tronApp, cmdBar, page }) => {
|
||||
if (!tronApp) fail()
|
||||
// Run electron snippet to find the Menu!
|
||||
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
|
||||
await tronApp.electron.evaluate(async ({ app }) => {
|
||||
if (!app || !app.applicationMenu) fail()
|
||||
const menu = app.applicationMenu.getMenuItemById(
|
||||
@ -210,6 +220,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
|
||||
}) => {
|
||||
if (!tronApp) fail()
|
||||
// Run electron snippet to find the Menu!
|
||||
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
|
||||
await tronApp.electron.evaluate(async ({ app }) => {
|
||||
if (!app || !app.applicationMenu) fail()
|
||||
const menu = app.applicationMenu.getMenuItemById(
|
||||
@ -228,6 +239,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
|
||||
test('View.Command Palette...', async ({ tronApp, cmdBar, page }) => {
|
||||
if (!tronApp) fail()
|
||||
// Run electron snippet to find the Menu!
|
||||
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
|
||||
await tronApp.electron.evaluate(async ({ app }) => {
|
||||
if (!app || !app.applicationMenu) fail()
|
||||
const menu = app.applicationMenu.getMenuItemById(
|
||||
@ -245,6 +257,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
|
||||
test('Help.Show all commands', async ({ tronApp, cmdBar, page }) => {
|
||||
if (!tronApp) fail()
|
||||
// Run electron snippet to find the Menu!
|
||||
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
|
||||
await tronApp.electron.evaluate(async ({ app }) => {
|
||||
if (!app || !app.applicationMenu) fail()
|
||||
const menu = app.applicationMenu.getMenuItemById(
|
||||
@ -260,6 +273,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
|
||||
test('Help.KCL code samples', async ({ tronApp, cmdBar, page }) => {
|
||||
if (!tronApp) fail()
|
||||
// Run electron snippet to find the Menu!
|
||||
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
|
||||
await tronApp.electron.evaluate(async ({ app }) => {
|
||||
if (!app || !app.applicationMenu) fail()
|
||||
const menu = app.applicationMenu.getMenuItemById(
|
||||
@ -275,6 +289,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
|
||||
}) => {
|
||||
if (!tronApp) fail()
|
||||
// Run electron snippet to find the Menu!
|
||||
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
|
||||
await tronApp.electron.evaluate(async ({ app }) => {
|
||||
if (!app || !app.applicationMenu) fail()
|
||||
const menu = app.applicationMenu.getMenuItemById(
|
||||
@ -293,6 +308,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
|
||||
test('Help.Reset onboarding', async ({ tronApp, cmdBar, page }) => {
|
||||
if (!tronApp) fail()
|
||||
// Run electron snippet to find the Menu!
|
||||
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
|
||||
await tronApp.electron.evaluate(async ({ app }) => {
|
||||
if (!app || !app.applicationMenu) fail()
|
||||
const menu = app.applicationMenu.getMenuItemById(
|
||||
|
@ -26,7 +26,7 @@
|
||||
"@fortawesome/react-fontawesome": "^0.2.0",
|
||||
"@headlessui/react": "^1.7.19",
|
||||
"@headlessui/tailwindcss": "^0.2.2",
|
||||
"@kittycad/lib": "2.0.23",
|
||||
"@kittycad/lib": "2.0.25",
|
||||
"@lezer/highlight": "^1.2.1",
|
||||
"@lezer/lr": "^1.4.1",
|
||||
"@react-hook/resize-observer": "^2.0.1",
|
||||
|
@ -7,6 +7,8 @@ import { settingsActor, getSettings } from 'machines/appMachine'
|
||||
import { err, reportRejection } from 'lib/trap'
|
||||
import {
|
||||
CameraViewState_type,
|
||||
Point3d_type,
|
||||
Point4d_type,
|
||||
WorldCoordinateSystem_type,
|
||||
} from '@kittycad/lib/dist/types/src/models'
|
||||
|
||||
@ -16,6 +18,31 @@ function isWorldCoordinateSystemType(
|
||||
return x === 'right_handed_up_z' || x === 'right_handed_up_y'
|
||||
}
|
||||
|
||||
type Tuple3 = [number, number, number]
|
||||
type Tuple4 = [number, number, number, number]
|
||||
|
||||
function point3DToNumberArray(value: Point3d_type): Tuple3 {
|
||||
return [value.x, value.y, value.z]
|
||||
}
|
||||
function numberArrayToPoint3D(value: Tuple3): Point3d_type {
|
||||
return {
|
||||
x: value[0],
|
||||
y: value[1],
|
||||
z: value[2],
|
||||
}
|
||||
}
|
||||
function point4DToNumberArray(value: Point4d_type): Tuple4 {
|
||||
return [value.x, value.y, value.z, value.w]
|
||||
}
|
||||
function numberArrayToPoint4D(value: Tuple4): Point4d_type {
|
||||
return {
|
||||
x: value[0],
|
||||
y: value[1],
|
||||
z: value[2],
|
||||
w: value[3],
|
||||
}
|
||||
}
|
||||
|
||||
function namedViewToCameraViewState(
|
||||
namedView: NamedView
|
||||
): CameraViewState_type | Error {
|
||||
@ -32,8 +59,8 @@ function namedViewToCameraViewState(
|
||||
ortho_scale_factor: namedView.ortho_scale_factor,
|
||||
world_coord_system: worldCoordinateSystem,
|
||||
is_ortho: namedView.is_ortho,
|
||||
pivot_position: namedView.pivot_position,
|
||||
pivot_rotation: namedView.pivot_rotation,
|
||||
pivot_position: numberArrayToPoint3D(namedView.pivot_position),
|
||||
pivot_rotation: numberArrayToPoint4D(namedView.pivot_rotation),
|
||||
}
|
||||
|
||||
return cameraViewState
|
||||
@ -43,29 +70,11 @@ function cameraViewStateToNamedView(
|
||||
name: string,
|
||||
cameraViewState: CameraViewState_type
|
||||
): NamedView | Error {
|
||||
let pivot_position: [number, number, number] | null = null
|
||||
let pivot_rotation: [number, number, number, number] | null = null
|
||||
let pivot_position: Tuple3 | null = null
|
||||
let pivot_rotation: Tuple4 | null = null
|
||||
|
||||
if (cameraViewState.pivot_position.length === 3) {
|
||||
pivot_position = [
|
||||
cameraViewState.pivot_position[0],
|
||||
cameraViewState.pivot_position[1],
|
||||
cameraViewState.pivot_position[2],
|
||||
]
|
||||
} else {
|
||||
return new Error(`invalid pivot position ${cameraViewState.pivot_position}`)
|
||||
}
|
||||
|
||||
if (cameraViewState.pivot_rotation.length === 4) {
|
||||
pivot_rotation = [
|
||||
cameraViewState.pivot_rotation[0],
|
||||
cameraViewState.pivot_rotation[1],
|
||||
cameraViewState.pivot_rotation[2],
|
||||
cameraViewState.pivot_rotation[3],
|
||||
]
|
||||
} else {
|
||||
return new Error(`invalid pivot rotation ${cameraViewState.pivot_rotation}`)
|
||||
}
|
||||
pivot_position = point3DToNumberArray(cameraViewState.pivot_position)
|
||||
pivot_rotation = point4DToNumberArray(cameraViewState.pivot_rotation)
|
||||
|
||||
// Create a new named view
|
||||
const requestedView: NamedView = {
|
||||
|
@ -1866,10 +1866,10 @@
|
||||
"@jridgewell/resolve-uri" "^3.1.0"
|
||||
"@jridgewell/sourcemap-codec" "^1.4.14"
|
||||
|
||||
"@kittycad/lib@2.0.23":
|
||||
version "2.0.23"
|
||||
resolved "https://registry.yarnpkg.com/@kittycad/lib/-/lib-2.0.23.tgz#0d215d458b35f6d207eeb90443889fa77b21b913"
|
||||
integrity sha512-5T7+gHB21RX5bE7ILp3TnLzp0rA7CP1BucNctHynANG/sXV44tD7U8YEcQsi+/ZmMkvrxmZ/3r/UQjgzhQUh7w==
|
||||
"@kittycad/lib@2.0.25":
|
||||
version "2.0.25"
|
||||
resolved "https://registry.yarnpkg.com/@kittycad/lib/-/lib-2.0.25.tgz#ad3e9a548752440b18102ca9b83e10811c2c08ab"
|
||||
integrity sha512-Qw5veBEX37lOfdg93OiSKFcTC+3y5q3hcfjML53BbRwE7bzwE/PlPFAouqqnts4a9PEETHxeO1CsKe3YUW+ysA==
|
||||
dependencies:
|
||||
openapi-types "^12.0.0"
|
||||
ts-node "^10.9.1"
|
||||
|
Reference in New Issue
Block a user