Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add offset plane point-and-click user flow #4552

Merged
merged 21 commits into from
Nov 26, 2024

Conversation

franknoirot
Copy link
Collaborator

@franknoirot franknoirot commented Nov 22, 2024

Closes #4468. Users can now use the Offset plane tool in the modeling mode toolbar or the corresponding command palette entry. They must select a default plane to sketch on, then enter an offset distance value.

Adds one new E2E playwright test. I couldn't make it an electron and fixture-based test, because I ran into issues with the selectors within cmdBar.page never being correct in the electron context. I am unsure if this is because I attempted to add this as the first electron test in the point-and-click.spec.ts file, and I was missing something about the imports or beforeEach that was needed for that to work, but I've made it a browser playwright test for now. @lf94 has a big migration of all our tests to electron right now, so I imagine a lot of test infra stuff will be shifted slightly in the near future that I can use to swap it back over to electron without much trouble.

Limitations

One important note is that we'd like to treat the default planes differently in the near future (see #4504), so that will impact and hopefully simplify some of the special case code needed to handle selection of default planes. I had to extend the Selections type, and add default planes as a possible otherSelections in addition to the Axis type currently used in some sketch mode code. I've grouped them under a "NonCodeSelections" type, but some of the strategies proposed for #4504 have included actually including the default planes in the code as a sort of prelude, so further tweaks may be necessary.

Demo

Screenshare.-.2024-11-22.6_03_49.PM-compressed.mp4

@franknoirot franknoirot added the enhancement New feature or request label Nov 22, 2024
Copy link

qa-wolf bot commented Nov 22, 2024

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

Copy link

vercel bot commented Nov 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview Nov 26, 2024 4:26pm

@franknoirot
Copy link
Collaborator Author

tsc is high VS Code knows that my Map functions are correct

@nadr0
Copy link
Collaborator

nadr0 commented Nov 25, 2024

nitpick, does the icon for offset plane look disabled? At first I thought it wasn't enabled.
image

I couldn't use the cmdBar fixture with an electron test for some reason.
@@ -35,7 +35,7 @@ export class CmdBarFixture {
}

private _serialiseCmdBar = async (): Promise<CmdBarSerialised> => {
const reviewForm = await this.page.locator('#review-form')
const reviewForm = this.page.locator('#review-form')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Playwright locators are not async in and of themselves. Only awaited expectations from them or things like .innerText() are async.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I know my issue was writing the electron version of this test I can extend it if we need. Should I do any combination of these?

  1. Create offsets from other planes
  2. Create variables for the distances of multiple planes to test the insertion order
  3. Sketch on an offset plane after creating it

commandBarState.context.currentArgument?.inputType === 'selection'
)
)
return
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should live somewhere more centralized when we have an actor-based state system really driving

programMemory: ProgramMemory,
engineCommandManager: EngineCommandManager
) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
programMemory.hasSketchOrSolid() &&
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check acted as a second blocker to default plane selections for the offset plane command bar, duplicate from the one found in Stream.tsx

@@ -527,6 +527,45 @@ export function sketchOnExtrudedFace(
}
}

/**
* Append an offset plane to the AST
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appends because there is no concern of inserting it intelligently after a specific item, but you can reference named constants for the distance value, so the end is the easiest place to add it.

const varInfo = findAllPreviousVariables(
kclManager.ast,
kclManager.programMemory,
selectionRange
// If there is no selection, use the end of the code
selectionRange || [code.length, code.length]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hook wouldn't work if nothing was selected within the code, which is true of operations like offset plane. I still can't get the autocompletions to work in the KCL argument input box though.

@franknoirot
Copy link
Collaborator Author

@jtran figured out that my TSC issues are because we're running 5.0.0 and the Map.entries() type inference I'm trying to use wasn't introduced until ^5.5.2, so he's doing me a solid and opening a PR to bump our TS version.

Copy link
Collaborator

@pierremtb pierremtb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks all sound to me, but would for sure prefer for this to get a second approval by folks more involved in this code. Super exciting stuff!!

@@ -536,7 +560,8 @@ export function canSweepSelection(selection: Selections) {
}

// This accounts for non-geometry selections under "other"
export type ResolvedSelectionType = [Artifact['type'] | 'other', number]
export type ResolvedSelectionType = Artifact['type'] | 'other'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is other still needed, not sure it ever get's used now?

Copy link
Collaborator Author

@franknoirot franknoirot Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used it for an Axis selection in getSelectionCountByType(), which doesn't have an Artifact type that I could see.

Copy link
Collaborator

@Irev-Dev Irev-Dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, left a couple of comments.

@franknoirot
Copy link
Collaborator Author

franknoirot commented Nov 26, 2024

nitpick, does the icon for offset plane look disabled? At first I thought it wasn't enabled.

Super fair point, let me try a different one real quick

@franknoirot franknoirot enabled auto-merge (squash) November 26, 2024 16:25
@franknoirot franknoirot merged commit 4423ae1 into main Nov 26, 2024
26 checks passed
@franknoirot franknoirot deleted the franknoirot/2213/offset-plane-ui branch November 26, 2024 16:36
Comment on lines +554 to +562
const pathToNode: PathToNode = [
['body', ''],
[modifiedAst.body.length - 1, 'index'],
['declarations', 'VariableDeclaration'],
['0', 'index'],
['init', 'VariableDeclarator'],
['arguments', 'CallExpression'],
[0, 'index'],
]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate how we assume AST structure all over like this. I guess it doesn't have a source range, so we can't call getNodePathFromSourceRange(). So I don't have a better suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show offsetPlanes as selectable planes in the scene
5 participants