2024-02-11 12:59:00 +11:00
import { PathToNode , VariableDeclarator } from 'lang/wasm'
2023-10-11 13:36:54 +11:00
import { engineCommandManager } from 'lang/std/engineConnection'
2023-10-16 21:20:05 +11:00
import {
Axis ,
Selection ,
SelectionRangeTypeMap ,
Selections ,
} from 'lib/selections'
2023-10-11 13:36:54 +11:00
import { assign , createMachine } from 'xstate'
2023-10-11 15:12:29 +11:00
import { isCursorInSketchCommandRange } from 'lang/util'
2024-01-31 10:17:24 +01:00
import { getNodePathFromSourceRange } from 'lang/queryAst'
2024-02-11 12:59:00 +11:00
import { kclManager } from 'lang/KclSingleton'
2023-10-11 13:36:54 +11:00
import {
horzVertInfo ,
applyConstraintHorzVert ,
} from 'components/Toolbar/HorzVert'
import {
applyConstraintHorzVertAlign ,
horzVertDistanceInfo ,
} from 'components/Toolbar/SetHorzVertDistance'
import { angleBetweenInfo } from 'components/Toolbar/SetAngleBetween'
2023-12-01 20:18:51 +11:00
import { angleLengthInfo } from 'components/Toolbar/setAngleLength'
2023-10-11 13:36:54 +11:00
import {
applyConstraintEqualLength ,
setEqualLengthInfo ,
} from 'components/Toolbar/EqualLength'
2024-02-11 12:59:00 +11:00
import { addStartProfileAt , extrudeSketch } from 'lang/modifyAst'
2023-10-11 13:36:54 +11:00
import { getNodeFromPath } from '../lang/queryAst'
import { CallExpression , PipeExpression } from '../lang/wasm'
2023-10-16 08:54:38 +11:00
import {
applyConstraintEqualAngle ,
equalAngleInfo ,
} from 'components/Toolbar/EqualAngle'
import {
applyRemoveConstrainingValues ,
removeConstrainingValuesInfo ,
} from 'components/Toolbar/RemoveConstrainingValues'
import { intersectInfo } from 'components/Toolbar/Intersect'
2023-12-01 20:18:51 +11:00
import {
absDistanceInfo ,
applyConstraintAxisAlign ,
} from 'components/Toolbar/SetAbsDistance'
2024-02-11 12:59:00 +11:00
import { Models } from '@kittycad/lib/dist/types/src'
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
import { ModelingCommandSchema } from 'lib/commandBarConfigs/modelingCommandConfig'
2024-02-11 12:59:00 +11:00
import {
DefaultPlaneStr ,
2024-02-14 08:03:20 +11:00
sceneEntitiesManager ,
2024-02-11 12:59:00 +11:00
quaternionFromSketchGroup ,
sketchGroupFromPathToNode ,
2024-02-14 08:03:20 +11:00
} from 'clientSideScene/sceneEntities'
import { sceneInfra } from 'clientSideScene/sceneInfra'
2023-10-11 13:36:54 +11:00
export const MODELING_PERSIST_KEY = 'MODELING_PERSIST_KEY'
export type SetSelections =
| {
selectionType : 'singleCodeCursor'
selection? : Selection
}
| {
selectionType : 'otherSelection'
selection : Axis
}
| {
selectionType : 'completeSelection'
selection : Selections
}
| {
selectionType : 'mirrorCodeMirrorSelections'
selection : Selections
}
2023-10-16 21:20:05 +11:00
export type ModelingMachineEvent =
| { type : 'Enter sketch' }
| {
2024-02-11 12:59:00 +11:00
type : 'Select default plane'
data : { plane : DefaultPlaneStr ; normal : [ number , number , number ] }
2023-10-16 21:20:05 +11:00
}
2024-02-11 12:59:00 +11:00
| { type : 'Set selection' ; data : SetSelections }
2023-10-16 21:20:05 +11:00
| { type : 'Sketch no face' }
| { type : 'Toggle gui mode' }
| { type : 'Cancel' }
| { type : 'CancelSketch' }
2024-02-11 12:59:00 +11:00
| { type : 'Add start point' }
2023-10-16 21:20:05 +11:00
| { type : 'Make segment horizontal' }
| { type : 'Make segment vertical' }
| { type : 'Constrain horizontal distance' }
2023-12-01 20:18:51 +11:00
| { type : 'Constrain ABS X' }
| { type : 'Constrain ABS Y' }
2023-10-16 21:20:05 +11:00
| { type : 'Constrain vertical distance' }
| { type : 'Constrain angle' }
| { type : 'Constrain perpendicular distance' }
| { type : 'Constrain horizontally align' }
| { type : 'Constrain vertically align' }
2023-12-01 20:18:51 +11:00
| { type : 'Constrain snap to X' }
| { type : 'Constrain snap to Y' }
2023-10-16 21:20:05 +11:00
| { type : 'Constrain length' }
| { type : 'Constrain equal length' }
| { type : 'Constrain parallel' }
| { type : 'Constrain remove constraints' }
2023-10-18 08:03:02 +11:00
| { type : 'Re-execute' }
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
| { type : 'Extrude' ; data? : ModelingCommandSchema [ 'Extrude' ] }
2024-02-11 12:59:00 +11:00
| { type : 'Equip Line tool' }
| { type : 'Equip tangential arc to' }
| {
type : 'done.invoke.animate-to-face'
data : {
sketchPathToNode : PathToNode
sketchNormalBackUp : [ number , number , number ] | null
}
}
export type MoveDesc = { line : number ; snippet : string }
2023-10-16 21:20:05 +11:00
2023-10-11 13:36:54 +11:00
export const modelingMachine = createMachine (
{
2024-02-14 05:35:05 +11:00
/ * * @ x s t a t e - l a y o u t N 4 I g p g J g 5 m D O I C 5 Q F k D 2 E w B s C W A 7 K A x A M I C G u A x l g N o A M A u o q A A 6 q z Y A u 2 q u j I A H o g C 0 A d g C s A Z g B 0 4 g E y j h A D n E A 2 G g o U A W J Q B o Q A T 0 Q B G G u I C c k m o Z k b T M 4 2 Y W K A v k 9 1 o M O f A Q D K Y d g A J Y L D B y T m 5 a B i Q Q F j Y w n i i B B F t p G h l x D R p h G g 1 Z U R l h X Q M E c R L D S V F 5 U w V 8 4 X E K 8 R c 3 d C w 8 K E l s C E w w H z 9 A 4 N C u X A j e G I 5 B 3 k T B D O F J Y W V l Q 2 U l Y 3 U r Q s Q F U Q V y 0 Q 0 0 w 3 F L G V N T B t c Q d x b 8 d s 7 u g F F c d j A A J 0 C A a z 9 y A A t h q N G 4 i Z C d K i W Z p c Q K E y H T K m T L r Y r C G b 5 D R a G H K B G i Y z K R o X Z q e N o d L o E B 5 P V 6 w D 7 s b 5 U Q y R Z i s M b c Q E I Q R L G i S d R m f I q U x L C p w 5 Q q c r Q 4 S G T T W U x 5 b G X P E 3 Q l 3 P j s Z 4 A V w w v 1 p s X G C S E M j k k h k N F E - M N B x o 4 v E c M 2 2 w q O Q x i k M K w U k t x r U k 3 n J 3 2 I Z E o m F d n x + 9 B G d I B m o Q d o U y k k x m E y I h E L M s j h o b K o Y U d s O I q 2 j o 8 z p 9 F K + L r d X w A k r c e g E g l 0 B u F - X 9 A x r Q I l D H s p P z R K Y b A s t t Y z f o j C Y Z B Y a E s 5 u C a C Z u Z m r m 0 c 9 9 8 7 7 i 4 T k C Q P n 0 o A B b M C P f w A N x e n H I J E w q u i t Y Z w a s p i T 1 U 0 c 0 0 q Q K P Z D G g O K V H c g k + S U G g n 0 u n e d - 8 + 6 R d l y C N c N w C L 5 U G e b A A C 9 u H Y A 8 j 3 + O t + C M J F J F U M N 9 T t f I 0 R k B N x D t c o N H k S x + W M C o Z G - b M C 1 n X M A O I b h Y A V E g 8 H 8 C C o N g x 4 D 3 8 C B s C Y z 0 w E Q k 9 4 n r V D d g s J s T U - C 9 1 D h N J u Q s C p R F H Y i L w O K j r l - W j v n o o h G O Y 1 i d 2 e P d u N 4 - i K E E 6 s 1 X p E S U J D G Q l k k c U Z E 2 R Y n z U P Y 5 M 5 c p r B F D Q E W E B z d g 0 q c a P - E s 9 N w J j n h Y 3 B - A A Q Q A I W 8 f w A A 0 h P V U 9 R P s z Z J B y M R G 1 O c 8 0 j k 8 U N C c g 1 F F f V t a j O J o s 0 0 s K C 1 0 - S Y t Y p K U o A T Q y m z G S s X L r D s Z Q 5 E M A 0 D T w h 9 D n U U E l M W N Q o y - c 4 p W o 3 1 t K L C L W t i - w y C g L o e q D b K D h y a Q l C v e Q U 2 E U w 5 O U x E t n k d E 0 R O Y Q Q r W t a W q i g y 4 q 6 f B 2 D 9 G l j 0 y 2 y G x K G Y V A N E 0 D n 2 U Q 5 I W b Y 5 j b Q x L u j F R n q W p 1 G t W 8 L C U i 6 K t q Y F 5 8 d w X j y E V T A S F e M z 4 I s - b k I b b V t h s I r r E s T D l D k l N y u F K p T A R a x k T E F 6 t K x 7 o c c + t j I J g u C D 0 w P R t p w K A h i s g H e r P B z + w t L Q J G I j J + Q T D F w 2 O L Z - M C s R + T q n E G t C z H m o 2 j 6 2 r i o y T M w G W 5 e w B W a a y u y r E u v L Z E c c V F j M D E E 2 G k E t h 5 q o l m O R x z e W j H c z e 2 3 c d Y 2 B c B I J h - H Y V A 0 o 9 o G j A I q Q H J H B Q e e q M w 5 O y f t t Q N e Z V C 2 Q L K L R y 3 X u F h i 7 a 2 1 P 0 8 z 7 P u q V p D P e B 5 9 M j I h F x G F b I 5 M b G Z d k c O Q L y j Z Q c k F p q 5 y T s W w A A R 0 V b j v q g X 7 c 7 6 4 4 p A x Y 2 e f 1 O Q x 4 T W p W R y E x R 3 1 Z Q D V M Z f r d X 7 H N t Y p h y e l 6 g + + E v r Z A z F S E X U a p w n x R g T K c I B p Q F g n E y G o U Q L 8 E 6 t 1 F v b f w z w w C r l Q D u f w 5 A P 6 P F g A f V W W h 0 J W G I s N T Q o 0 d A P h F A R C w i x b D Z B K G o Y a S C Z y t w A E p g E E G A P g I R F R P C I Y d O o U g D i G F O K k d I Y h g 4 P n U P 2 d I q Q 0 S 1 y U A s N h f 4 b a y i 3 t g D O A A Z P A Y B u 6 o E P H - Q G f V U S C n q L Y M Q 1 C i i B X D M i A i 2 o 1 C K P H E 3 S c L c N H 3 C 0 R n K m M B H j Y G 4 u T c g 3 c h F 2 S G t s c E B o C K P 0 U C I h M x g y g 3 j r r E 5 E i 8 1 G S H i g A d x Y u B C W n F 4 K Y B 4 n x K m l B - B 4 A A G a o A I B A b g Y B 2 i 4 C 3 K g D 4 k g Y D s E E O x S W X F M C C A q a g U J i Q 0 j Z D y h o R e J p a h P V q H J J 8 5 h N g u X 2 M o W w l V 0 l Z J y e L D i U t C m U w E m U 3 A l S C A v G e J B S Q T A y b s E q c 8 V c L S - D t L y R s n p u y + k m J V t l Q Z I I 7 T I l T M R F y P M 5 L g n 7 N k Q c o 4 6 g 4 U M M s 7 J H B t y 7 m w P u T Z x T t m 9 O q b U + p j T m m t M E I 7 a F B 5 7 m V P 6 Y g f Y - Y D i 2 h M G i c R + Q v J K D Z G I O Q d h S i B T B a s j F M K i n m V K Q i g 5 R y T k k D O Z B S 5 a L G V Y t 6 b i h A + K 2 T 6 j E P P I 2 X k 9 g R k f q o N I c j 2 T 0 o h R 1 N K O y 9 k 1 N w H U v A K K 6 l o p I A A I 1 g I I P g 2 L H n - X 7 n n Y V 0 T Z j D V f B f L Y p V h o R g y E + R e s h h q 1 C V Q E F V q U 1 V V P Z c 8 Y 5 p z z m 8 u u Q a o 1 J r B V P I O m E g i M w c j g i U K 2 f U W h S q L G k F s R + B F s h R m f m 4 n 8 N E V n K u S v 4 T q f r E W a u R U 0 3 V Y b D W C D 0 K a o V 8 y M 3 y A q L Y K B x E 4 S H D R H l b m y k t i H G C v m l a C c i 3 e p L W W t l z x D m B s 5 d y i 5 V y 2 n h v r Y 2 6 N t M 8 V x o s D h M e D l + S u q 7 W 5 C w C z 5 j V 0 J Y 3 e q 7 i t J j u 2 v g L o 5 a N V a o a d W x d g g d p d F X e a - + w Z 9 i g 0 s A c P I r Y A 7 X Q N E 5 Q d f 6 K h h g R F 6 m 9 u 0 D F T p n U G r l I a X 1 v u 4 V G z 9 p j v 0 E T h t k f q V g 1 D z 2 u o j C M - 6 s h y H P m i a D u 9 f r 3 q R d q 5 9 a L q N f A - Q G T D L y C I g h y P J c B e w 7 w w 1 y o O W l K h E Z W C o x u P e X x y 0 B s Q - O 0 N b S m M s Z r G x 2 N 6 b j A m C 2 I s a 8 E 0 i g O W l S e l E - l 7 o G m g - j Z 4 h N i a k 3 J s y k p c G H k V s f T q l 9 p n z P Q s s 8 8 Q Q W y L K K e s j G g Z a s K p K G s M N B y 1 R o Y P j m S C M e j Z 5 i A Y A 7 H d G V t R 3 g o C M 5 j c F m y Y U z h R Z K T 0 6 O X B p 5 U 5 g m a X X M Z Y 8 1 l y g 3 n l a + b x f 5 8 U g W R n a i j m F n T A V p D C h G Y - E 4 c X 0 l 6 M 1 Y Y z A p Y + g V j i E 2 v U 5 g n x 6 h F J k d M J V w s 8 w j H V k 0 1 h M L V B 6 - o - r R J v G Z x 2 m B A J h S g k h L X Q P P F C J y q j T M K O d Q 3 M 2 Y P h 5 v G k G j g s i u I v Q W 1 a v W D F Z y M Z I Q s u A O A E F G x I a Q 3 a I T p n 8 p f B 8 J L 0 I l 0 u h z f U j h Q X D v j j O d 7 - X v u - f Y P 9 6 k r H n l h J c t s E 4 N h F D K T 9 i o O E 8 M n K N g c H U b k p o 1 t 9 c + 5 g S Q u A e U H k G + W E I I 2 j u W u W - j 1 s u x h T Q 7 D G T m E G b S U L L - X a P N L 2 R 3 I - W w z y Q A A 5 b O A A F V A e B 2 C w A I P F C A E B A j w W M v 4 F g 6 u m 3 z H K j C M a b Y X K D g 0 H y B Z v s I 5 Z E U K d d J P 2 - t C o S f Y z Y W Q V D n x N D b m h Y I 8 p K I c o C 3 T C P p d I 7 z K 7 j H V I M M 4 4 b F h N k M I Y Q j N k K O R s C Z j i J M 2 O k B Y u n T h Y k R 4 l m c A A V H b - j A n P G C V n N n - R O d x + q 8 K 4 a 5 g F l K F N E t 4 4 m e n x s j c n q S w x E M x F 9 e m X - A u 3 K - V 6 q X c L b K O G c m + R L 7 T I m x x S D m 0 4 g N s 4 Z e Z p B I t b y j Q + t K K i J t n f i x l f w A H l c D 2 a r c 0 + K 3 g S + C A P z U w Q x - 2 B n 8 V g 3 9 d I Y o Q V Q W h i e m + o 4 R G y z A L R h g u R k J P h q L + D M 7 + D l I k C U A 9 D D Y 8 R g A w G k w p Z k y a p C q C C F Q n T E 4 Y i I z E Q E R X Q Q 4 6 h t j c j R Z H A V C o w R 5 t B k D Y C r h c q t D d y G 5 o H d A P p X 5 1 I 0 F 0 F P C C B Z y C A w G U B C o V C X i L 4 A r A K w h E E R J W D M L f J R j q A v Q c H 0 H 4 C M G c q a q 1 7 D a D B N q B Q k b U q t g Y Q Q I P g z w R h 1 D D R q b 8 g 1 B y G - a c E M F Z z + C 8 L F I M F k i + i X 7 0 b N L y F c E 8 E O G 5 g C G P y k K c g n D a h p A I h w h P i R Z 5 A Q i L x 2 A N a a B 0 4 f a o B f Z K 7 + C q 7 q 6 a 6 k A W T G L v 7 H b C p j a 9 p i C H A 5 C I w m B w i n D q z i K K A T b u p V A u D n D M 4 Y D w B R B x x Q D Y 6 N 6 C A g 7 S B y C x I Y S a A 2 J C D i Q Q j T I 8 x 6 g O R I y I J D 4 E h g C N E f 7 M g k K V Q 8 z g j E T X j m g p j l B T T n a S G W B S 4 W y X o F j j E Z H c g M x e 7 E q + 5 t h d r 9 g L K V C H B R a O D 8 j p L C z b G W o H A n C 6 i L w p h j y h Z 1 D x L J A H B j y p D V A X i - H Q Y d L 5 K m T l a 2 a V K 3 F 9 R h g M w Z C l z C g 1 C p C - L J D A h Q j z B W L h 4 b G v Z J Y M p Q p M q e a s o P J g l n h y I y r p 4 i L N 6 G B e T K R b p P g c w x Y Y j Q Y + p + r 4 m H Q l x S B q C O I F 5 2 C j i E E 6 Z F R 5 S V S Y R z S d h 0 k T o M l K b x 5
2023-10-11 13:36:54 +11:00
id : 'Modeling' ,
tsTypes : { } as import ( './modelingMachine.typegen' ) . Typegen0 ,
predictableActionArguments : true ,
preserveActionOrder : true ,
context : {
guiMode : 'default' ,
2024-02-11 12:59:00 +11:00
tool : null as Models [ 'SceneToolType_type' ] | null ,
2023-10-11 13:36:54 +11:00
selection : [ ] as string [ ] ,
selectionRanges : {
otherSelections : [ ] ,
codeBasedSelections : [ ] ,
} as Selections ,
selectionRangeTypeMap : { } as SelectionRangeTypeMap ,
sketchPathToNode : null as PathToNode | null , // maybe too specific, and we should have a generic pathToNode, but being specific seems less risky when I'm not sure
sketchEnginePathId : '' as string ,
sketchPlaneId : '' as string ,
2024-02-11 12:59:00 +11:00
sketchNormalBackUp : null as null | [ number , number , number ] ,
moveDescs : [ ] as MoveDesc [ ] ,
2023-10-11 13:36:54 +11:00
} ,
schema : {
2023-10-16 21:20:05 +11:00
events : { } as ModelingMachineEvent ,
2023-10-11 13:36:54 +11:00
} ,
states : {
idle : {
on : {
'Set selection' : {
target : 'idle' ,
internal : true ,
actions : 'Set selection' ,
} ,
'Enter sketch' : [
{
2024-02-11 12:59:00 +11:00
target : 'animating to existing sketch' ,
2023-10-11 13:36:54 +11:00
cond : 'Selection is one face' ,
2024-02-11 12:59:00 +11:00
actions : [ 'set sketch metadata' ] ,
2023-10-11 13:36:54 +11:00
} ,
'Sketch no face' ,
] ,
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
Extrude : {
target : 'idle' ,
cond : 'has valid extrude selection' ,
actions : [ 'AST extrude' ] ,
internal : true ,
} ,
2023-10-11 13:36:54 +11:00
} ,
} ,
Sketch : {
states : {
SketchIdle : {
on : {
'Set selection' : {
target : 'SketchIdle' ,
internal : true ,
actions : 'Set selection' ,
} ,
'Make segment vertical' : {
cond : 'Can make selection vertical' ,
target : 'SketchIdle' ,
internal : true ,
actions : [ 'Make selection vertical' ] ,
} ,
'Make segment horizontal' : {
target : 'SketchIdle' ,
internal : true ,
cond : 'Can make selection horizontal' ,
actions : [ 'Make selection horizontal' ] ,
} ,
'Constrain horizontal distance' : {
target : 'Await horizontal distance info' ,
cond : 'Can constrain horizontal distance' ,
} ,
'Constrain vertical distance' : {
target : 'Await vertical distance info' ,
cond : 'Can constrain vertical distance' ,
} ,
2023-12-01 20:18:51 +11:00
'Constrain ABS X' : {
target : 'Await ABS X info' ,
cond : 'Can constrain ABS X' ,
} ,
'Constrain ABS Y' : {
target : 'Await ABS Y info' ,
cond : 'Can constrain ABS Y' ,
} ,
2023-10-11 13:36:54 +11:00
'Constrain angle' : {
target : 'Await angle info' ,
cond : 'Can constrain angle' ,
} ,
'Constrain length' : {
target : 'Await length info' ,
cond : 'Can constrain length' ,
} ,
2023-10-16 08:54:38 +11:00
'Constrain perpendicular distance' : {
target : 'Await perpendicular distance info' ,
cond : 'Can constrain perpendicular distance' ,
} ,
2023-10-11 13:36:54 +11:00
'Constrain horizontally align' : {
cond : 'Can constrain horizontally align' ,
target : 'SketchIdle' ,
internal : true ,
actions : [ 'Constrain horizontally align' ] ,
} ,
'Constrain vertically align' : {
cond : 'Can constrain vertically align' ,
target : 'SketchIdle' ,
internal : true ,
actions : [ 'Constrain vertically align' ] ,
} ,
2023-12-01 20:18:51 +11:00
'Constrain snap to X' : {
cond : 'Can constrain snap to X' ,
target : 'SketchIdle' ,
internal : true ,
actions : [ 'Constrain snap to X' ] ,
} ,
'Constrain snap to Y' : {
cond : 'Can constrain snap to Y' ,
target : 'SketchIdle' ,
internal : true ,
actions : [ 'Constrain snap to Y' ] ,
} ,
2023-10-11 13:36:54 +11:00
'Constrain equal length' : {
cond : 'Can constrain equal length' ,
target : 'SketchIdle' ,
internal : true ,
actions : [ 'Constrain equal length' ] ,
} ,
2023-10-16 08:54:38 +11:00
'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' ] ,
} ,
2023-10-18 08:03:02 +11:00
'Re-execute' : {
target : 'SketchIdle' ,
internal : true ,
2024-02-13 07:41:37 +11:00
actions : [ 'set sketchMetadata from pathToNode' ] ,
2023-10-18 08:03:02 +11:00
} ,
2023-10-11 13:36:54 +11:00
2024-02-11 12:59:00 +11:00
'Equip Line tool' : 'Line tool' ,
2023-10-11 13:36:54 +11:00
2024-02-11 12:59:00 +11:00
'Equip tangential arc to' : {
target : 'Tangential arc to' ,
cond : 'is editing existing sketch' ,
2023-10-11 13:36:54 +11:00
} ,
} ,
2024-02-14 05:35:05 +11:00
entry : 'setup client side sketch segments' ,
2023-10-11 13:36:54 +11:00
} ,
'Await horizontal distance info' : {
invoke : {
src : 'Get horizontal info' ,
id : 'get-horizontal-info' ,
onDone : {
target : 'SketchIdle' ,
actions : 'Set selection' ,
} ,
onError : 'SketchIdle' ,
} ,
} ,
'Await vertical distance info' : {
invoke : {
src : 'Get vertical info' ,
id : 'get-vertical-info' ,
onDone : {
target : 'SketchIdle' ,
actions : 'Set selection' ,
} ,
onError : 'SketchIdle' ,
} ,
} ,
2023-12-01 20:18:51 +11:00
'Await ABS X info' : {
invoke : {
src : 'Get ABS X info' ,
id : 'get-abs-x-info' ,
onDone : {
target : 'SketchIdle' ,
actions : 'Set selection' ,
} ,
onError : 'SketchIdle' ,
} ,
} ,
'Await ABS Y info' : {
invoke : {
src : 'Get ABS Y info' ,
id : 'get-abs-y-info' ,
onDone : {
target : 'SketchIdle' ,
actions : 'Set selection' ,
} ,
onError : 'SketchIdle' ,
} ,
} ,
2023-10-11 13:36:54 +11:00
'Await angle info' : {
invoke : {
src : 'Get angle info' ,
id : 'get-angle-info' ,
onDone : {
target : 'SketchIdle' ,
actions : 'Set selection' ,
} ,
onError : 'SketchIdle' ,
} ,
} ,
'Await length info' : {
invoke : {
src : 'Get length info' ,
id : 'get-length-info' ,
onDone : {
target : 'SketchIdle' ,
actions : 'Set selection' ,
} ,
onError : 'SketchIdle' ,
} ,
} ,
2023-10-16 08:54:38 +11:00
'Await perpendicular distance info' : {
invoke : {
src : 'Get perpendicular distance info' ,
id : 'get-perpendicular-distance-info' ,
onDone : {
target : 'SketchIdle' ,
actions : 'Set selection' ,
} ,
onError : 'SketchIdle' ,
} ,
} ,
2024-02-11 12:59:00 +11:00
'Line tool' : {
exit : [
2024-02-14 05:35:05 +11:00
// 'tear down client sketch',
// 'setup client side sketch segments',
2024-02-11 12:59:00 +11:00
] ,
on : {
'Set selection' : {
target : 'Line tool' ,
description : ` This is just here to stop one of the higher level "Set selections" firing when we are just trying to set the IDE code without triggering a full engine-execute ` ,
internal : true ,
} ,
'Equip tangential arc to' : {
target : 'Tangential arc to' ,
cond : 'is editing existing sketch' ,
} ,
} ,
states : {
Init : {
always : [
{
target : 'normal' ,
cond : 'is editing existing sketch' ,
actions : 'set up draft line' ,
} ,
'No Points' ,
] ,
} ,
normal : {
on : {
'Set selection' : {
target : 'normal' ,
internal : true ,
} ,
} ,
} ,
'No Points' : {
entry : 'setup noPoints onClick listener' ,
on : {
'Add start point' : {
target : 'normal' ,
actions : 'set up draft line without teardown' ,
} ,
2024-02-14 05:35:05 +11:00
Cancel : '#Modeling.Sketch.undo startSketchOn' ,
2024-02-11 12:59:00 +11:00
} ,
} ,
} ,
initial : 'Init' ,
} ,
Init : {
always : [
{
target : 'SketchIdle' ,
cond : 'is editing existing sketch' ,
} ,
'Line tool' ,
] ,
} ,
'Tangential arc to' : {
entry : 'set up draft arc' ,
on : {
'Set selection' : {
target : 'Tangential arc to' ,
internal : true ,
} ,
'Equip Line tool' : 'Line tool' ,
} ,
} ,
2024-02-14 05:35:05 +11:00
'undo startSketchOn' : {
invoke : {
src : 'AST-undo-startSketchOn' ,
id : 'AST-undo-startSketchOn' ,
onDone : '#Modeling.idle' ,
} ,
} ,
2023-10-11 13:36:54 +11:00
} ,
2024-02-11 12:59:00 +11:00
initial : 'Init' ,
2023-10-11 13:36:54 +11:00
on : {
CancelSketch : '.SketchIdle' ,
} ,
2024-02-11 12:59:00 +11:00
exit : [
'sketch exit execute' ,
'animate after sketch' ,
'tear down client sketch' ,
'remove sketch grid' ,
] ,
2024-02-14 05:35:05 +11:00
entry : [ 'add axis n grid' , 'conditionally equip line tool' ] ,
2023-10-11 13:36:54 +11:00
} ,
'Sketch no face' : {
entry : 'show default planes' ,
exit : 'hide default planes' ,
on : {
'Select default plane' : {
2024-02-11 12:59:00 +11:00
target : 'animating to plane' ,
actions : [ 'reset sketch metadata' ] ,
} ,
} ,
} ,
'animating to plane' : {
invoke : {
src : 'animate-to-face' ,
id : 'animate-to-face' ,
onDone : {
2023-10-11 13:36:54 +11:00
target : 'Sketch' ,
2024-02-11 12:59:00 +11:00
actions : 'set new sketch metadata' ,
} ,
} ,
on : {
'Set selection' : {
target : 'animating to plane' ,
internal : true ,
2023-10-11 13:36:54 +11:00
} ,
} ,
} ,
2024-02-11 12:59:00 +11:00
'animating to existing sketch' : {
invoke : [
{
src : 'animate-to-sketch' ,
id : 'animate-to-sketch' ,
onDone : 'Sketch' ,
} ,
] ,
} ,
2023-10-11 13:36:54 +11:00
} ,
initial : 'idle' ,
on : {
Cancel : {
target : 'idle' ,
2023-11-01 17:34:54 -05:00
// TODO what if we're existing extrude equipped, should these actions still be fired?
// maybe cancel needs to have a guard for if else logic?
2024-02-13 07:41:37 +11:00
actions : [ 'reset sketch metadata' ] ,
2023-10-11 13:36:54 +11:00
} ,
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
'Set selection' : {
target : '#Modeling' ,
internal : true ,
actions : 'Set selection' ,
} ,
2023-10-11 13:36:54 +11:00
} ,
} ,
{
guards : {
2024-02-11 12:59:00 +11:00
'is editing existing sketch' : ( { sketchPathToNode } ) = > {
// should check that the variable declaration is a pipeExpression
// and that the pipeExpression contains a "startProfileAt" callExpression
if ( ! sketchPathToNode ) return false
const variableDeclaration = getNodeFromPath < VariableDeclarator > (
kclManager . ast ,
sketchPathToNode ,
'VariableDeclarator'
) . node
if ( variableDeclaration . type !== 'VariableDeclarator' ) return false
const pipeExpression = variableDeclaration . init
if ( pipeExpression . type !== 'PipeExpression' ) return false
const hasStartProfileAt = pipeExpression . body . some (
( item ) = >
item . type === 'CallExpression' &&
item . callee . name === 'startProfileAt'
)
return hasStartProfileAt && pipeExpression . body . length > 2
} ,
2023-10-11 13:36:54 +11:00
'Can make selection horizontal' : ( { selectionRanges } ) = >
horzVertInfo ( selectionRanges , 'horizontal' ) . enabled ,
'Can make selection vertical' : ( { selectionRanges } ) = >
horzVertInfo ( selectionRanges , 'vertical' ) . enabled ,
'Can constrain horizontal distance' : ( { selectionRanges } ) = >
horzVertDistanceInfo ( { selectionRanges , constraint : 'setHorzDistance' } )
. enabled ,
'Can constrain vertical distance' : ( { selectionRanges } ) = >
horzVertDistanceInfo ( { selectionRanges , constraint : 'setVertDistance' } )
. enabled ,
2023-12-01 20:18:51 +11:00
'Can constrain ABS X' : ( { selectionRanges } ) = >
absDistanceInfo ( { selectionRanges , constraint : 'xAbs' } ) . enabled ,
'Can constrain ABS Y' : ( { selectionRanges } ) = >
absDistanceInfo ( { selectionRanges , constraint : 'yAbs' } ) . enabled ,
2023-10-11 13:36:54 +11:00
'Can constrain angle' : ( { selectionRanges } ) = >
2023-12-01 20:18:51 +11:00
angleBetweenInfo ( { selectionRanges } ) . enabled ||
angleLengthInfo ( { selectionRanges , angleOrLength : 'setAngle' } ) . enabled ,
2023-10-11 13:36:54 +11:00
'Can constrain length' : ( { selectionRanges } ) = >
2023-12-01 20:18:51 +11:00
angleLengthInfo ( { selectionRanges } ) . enabled ,
2023-10-16 08:54:38 +11:00
'Can constrain perpendicular distance' : ( { selectionRanges } ) = >
intersectInfo ( { selectionRanges } ) . enabled ,
2023-10-11 13:36:54 +11:00
'Can constrain horizontally align' : ( { selectionRanges } ) = >
horzVertDistanceInfo ( { selectionRanges , constraint : 'setHorzDistance' } )
. enabled ,
'Can constrain vertically align' : ( { selectionRanges } ) = >
horzVertDistanceInfo ( { selectionRanges , constraint : 'setHorzDistance' } )
. enabled ,
2023-12-01 20:18:51 +11:00
'Can constrain snap to X' : ( { selectionRanges } ) = >
absDistanceInfo ( { selectionRanges , constraint : 'snapToXAxis' } ) . enabled ,
'Can constrain snap to Y' : ( { selectionRanges } ) = >
absDistanceInfo ( { selectionRanges , constraint : 'snapToYAxis' } ) . enabled ,
2023-10-11 13:36:54 +11:00
'Can constrain equal length' : ( { selectionRanges } ) = >
setEqualLengthInfo ( { selectionRanges } ) . enabled ,
2023-10-16 08:54:38 +11:00
'Can canstrain parallel' : ( { selectionRanges } ) = >
equalAngleInfo ( { selectionRanges } ) . enabled ,
'Can constrain remove constraints' : ( { selectionRanges } ) = >
removeConstrainingValuesInfo ( { selectionRanges } ) . enabled ,
2023-10-11 13:36:54 +11:00
} ,
2024-02-11 12:59:00 +11:00
// end guards
2023-10-11 13:36:54 +11:00
actions : {
2023-10-18 08:03:02 +11:00
'set sketchMetadata from pathToNode' : assign ( ( { sketchPathToNode } ) = > {
if ( ! sketchPathToNode ) return { }
return getSketchMetadataFromPathToNode ( sketchPathToNode )
} ) ,
2024-02-17 07:04:24 +11:00
'hide default planes' : ( ) = > {
sceneInfra . removeDefaultPlanes ( )
kclManager . hidePlanes ( )
} ,
2023-10-11 13:36:54 +11:00
'reset sketch metadata' : assign ( {
sketchPathToNode : null ,
sketchEnginePathId : '' ,
sketchPlaneId : '' ,
} ) ,
'set sketch metadata' : assign ( ( { selectionRanges } ) = > {
const sourceRange = selectionRanges . codeBasedSelections [ 0 ] . range
const sketchPathToNode = getNodePathFromSourceRange (
kclManager . ast ,
sourceRange
)
2023-10-18 08:03:02 +11:00
return getSketchMetadataFromPathToNode (
2023-10-11 13:36:54 +11:00
sketchPathToNode ,
2023-10-18 08:03:02 +11:00
selectionRanges
)
2023-10-11 13:36:54 +11:00
} ) ,
2024-02-11 12:59:00 +11:00
'set new sketch metadata' : assign ( ( _ , { data } ) = > data ) ,
2023-10-16 08:54:38 +11:00
// TODO implement source ranges for all of these constraints
// need to make the async like the modal constraints
2024-02-11 12:59:00 +11:00
'Make selection horizontal' : ( { selectionRanges , sketchPathToNode } ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyConstraintHorzVert (
2023-10-11 13:36:54 +11:00
selectionRanges ,
'horizontal' ,
kclManager . ast ,
kclManager . programMemory
)
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . updateAstAndRejigSketch (
2024-02-11 12:59:00 +11:00
sketchPathToNode || [ ] ,
modifiedAst
)
2023-10-11 13:36:54 +11:00
} ,
2024-02-11 12:59:00 +11:00
'Make selection vertical' : ( { selectionRanges , sketchPathToNode } ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyConstraintHorzVert (
2023-10-11 13:36:54 +11:00
selectionRanges ,
'vertical' ,
kclManager . ast ,
kclManager . programMemory
)
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . updateAstAndRejigSketch (
2024-02-11 12:59:00 +11:00
sketchPathToNode || [ ] ,
modifiedAst
)
2023-10-11 13:36:54 +11:00
} ,
2024-02-11 12:59:00 +11:00
'Constrain horizontally align' : ( {
selectionRanges ,
sketchPathToNode ,
} ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyConstraintHorzVertAlign ( {
2023-10-11 13:36:54 +11:00
selectionRanges ,
constraint : 'setVertDistance' ,
} )
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . updateAstAndRejigSketch (
2024-02-11 12:59:00 +11:00
sketchPathToNode || [ ] ,
modifiedAst
)
2023-10-11 13:36:54 +11:00
} ,
2024-02-11 12:59:00 +11:00
'Constrain vertically align' : ( { selectionRanges , sketchPathToNode } ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyConstraintHorzVertAlign ( {
2023-10-11 13:36:54 +11:00
selectionRanges ,
constraint : 'setHorzDistance' ,
} )
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . updateAstAndRejigSketch (
2024-02-11 12:59:00 +11:00
sketchPathToNode || [ ] ,
modifiedAst
)
2023-10-11 13:36:54 +11:00
} ,
2024-02-11 12:59:00 +11:00
'Constrain snap to X' : ( { selectionRanges , sketchPathToNode } ) = > {
2023-12-01 20:18:51 +11:00
const { modifiedAst } = applyConstraintAxisAlign ( {
selectionRanges ,
constraint : 'snapToXAxis' ,
} )
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . updateAstAndRejigSketch (
2024-02-11 12:59:00 +11:00
sketchPathToNode || [ ] ,
modifiedAst
)
2023-12-01 20:18:51 +11:00
} ,
2024-02-11 12:59:00 +11:00
'Constrain snap to Y' : ( { selectionRanges , sketchPathToNode } ) = > {
2023-12-01 20:18:51 +11:00
const { modifiedAst } = applyConstraintAxisAlign ( {
selectionRanges ,
constraint : 'snapToYAxis' ,
} )
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . updateAstAndRejigSketch (
2024-02-11 12:59:00 +11:00
sketchPathToNode || [ ] ,
modifiedAst
)
2023-12-01 20:18:51 +11:00
} ,
2024-02-11 12:59:00 +11:00
'Constrain equal length' : ( { selectionRanges , sketchPathToNode } ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyConstraintEqualLength ( {
2023-10-11 13:36:54 +11:00
selectionRanges ,
} )
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . updateAstAndRejigSketch (
2024-02-11 12:59:00 +11:00
sketchPathToNode || [ ] ,
modifiedAst
)
2023-10-16 08:54:38 +11:00
} ,
2024-02-11 12:59:00 +11:00
'Constrain parallel' : ( { selectionRanges , sketchPathToNode } ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyConstraintEqualAngle ( {
2023-10-16 08:54:38 +11:00
selectionRanges ,
} )
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . updateAstAndRejigSketch (
2024-02-11 12:59:00 +11:00
sketchPathToNode || [ ] ,
modifiedAst
)
2023-10-16 08:54:38 +11:00
} ,
2024-02-11 12:59:00 +11:00
'Constrain remove constraints' : ( {
selectionRanges ,
sketchPathToNode ,
} ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyRemoveConstrainingValues ( {
2023-10-16 08:54:38 +11:00
selectionRanges ,
2023-10-11 13:36:54 +11:00
} )
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . updateAstAndRejigSketch (
2024-02-11 12:59:00 +11:00
sketchPathToNode || [ ] ,
modifiedAst
)
2023-10-11 13:36:54 +11:00
} ,
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
'AST extrude' : ( _ , event ) = > {
if ( ! event . data ) return
const { selection , distance } = event . data
2023-10-11 13:36:54 +11:00
const pathToNode = getNodePathFromSourceRange (
kclManager . ast ,
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
selection . codeBasedSelections [ 0 ] . range
2023-10-11 13:36:54 +11:00
)
const { modifiedAst , pathToExtrudeArg } = extrudeSketch (
kclManager . ast ,
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
pathToNode ,
true ,
distance
2023-10-11 13:36:54 +11:00
)
// TODO not handling focusPath correctly I think
2024-02-11 12:59:00 +11:00
kclManager . updateAst ( modifiedAst , true , {
2023-10-11 13:36:54 +11:00
focusPath : pathToExtrudeArg ,
} )
} ,
2024-02-14 05:35:05 +11:00
'conditionally equip line tool' : ( _ , { type } ) = > {
if ( type === 'done.invoke.animate-to-face' ) {
2024-02-14 08:03:20 +11:00
sceneInfra . modelingSend ( 'Equip Line tool' )
2024-02-14 05:35:05 +11:00
}
} ,
2024-02-11 12:59:00 +11:00
'setup client side sketch segments' : ( { sketchPathToNode } , { type } ) = > {
2024-02-14 08:03:20 +11:00
if ( Object . keys ( sceneEntitiesManager . activeSegments ) . length > 0 ) {
sceneEntitiesManager
. tearDownSketch ( { removeAxis : false } )
. then ( ( ) = > {
sceneEntitiesManager . setupSketch ( {
sketchPathToNode : sketchPathToNode || [ ] ,
} )
2024-02-14 05:35:05 +11:00
} )
} else {
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . setupSketch ( {
2024-02-11 12:59:00 +11:00
sketchPathToNode : sketchPathToNode || [ ] ,
} )
}
} ,
'animate after sketch' : ( ) = > {
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . animateAfterSketch ( )
2024-02-11 12:59:00 +11:00
} ,
2024-02-14 05:35:05 +11:00
'tear down client sketch' : ( ) = > {
2024-02-14 08:03:20 +11:00
if ( sceneEntitiesManager . activeSegments ) {
sceneEntitiesManager . tearDownSketch ( { removeAxis : false } )
2024-02-14 05:35:05 +11:00
}
} ,
2024-02-14 08:03:20 +11:00
'remove sketch grid' : ( ) = > sceneEntitiesManager . removeSketchGrid ( ) ,
2024-02-11 12:59:00 +11:00
'set up draft line' : ( { sketchPathToNode } ) = > {
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . setUpDraftLine ( sketchPathToNode || [ ] )
2024-02-11 12:59:00 +11:00
} ,
'set up draft arc' : ( { sketchPathToNode } ) = > {
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . setUpDraftArc ( sketchPathToNode || [ ] )
2024-02-11 12:59:00 +11:00
} ,
'set up draft line without teardown' : ( { sketchPathToNode } ) = >
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . setupSketch ( {
2024-02-11 12:59:00 +11:00
sketchPathToNode : sketchPathToNode || [ ] ,
draftSegment : 'line' ,
} ) ,
'show default planes' : ( ) = > {
2024-02-14 08:03:20 +11:00
sceneInfra . showDefaultPlanes ( )
sceneEntitiesManager . setupDefaultPlaneHover ( )
2024-02-17 07:04:24 +11:00
kclManager . showPlanes ( )
2024-02-11 12:59:00 +11:00
} ,
'setup noPoints onClick listener' : ( { sketchPathToNode } ) = > {
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . createIntersectionPlane ( )
2024-02-11 12:59:00 +11:00
const sketchGroup = sketchGroupFromPathToNode ( {
pathToNode : sketchPathToNode || [ ] ,
ast : kclManager.ast ,
programMemory : kclManager.programMemory ,
} )
const quaternion = quaternionFromSketchGroup ( sketchGroup )
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . intersectionPlane &&
sceneEntitiesManager . intersectionPlane . setRotationFromQuaternion (
2024-02-11 12:59:00 +11:00
quaternion
)
2024-02-14 08:03:20 +11:00
sceneInfra . setCallbacks ( {
2024-02-11 12:59:00 +11:00
onClick : async ( args ) = > {
if ( ! args ) return
const { intersection2d } = args
if ( ! intersection2d || ! sketchPathToNode ) return
const { modifiedAst } = addStartProfileAt (
kclManager . ast ,
sketchPathToNode ,
[ intersection2d . x , intersection2d . y ]
)
await kclManager . updateAst ( modifiedAst , false )
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . removeIntersectionPlane ( )
sceneInfra . modelingSend ( 'Add start point' )
2024-02-11 12:59:00 +11:00
} ,
} )
} ,
'add axis n grid' : ( { sketchPathToNode } ) = >
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . createSketchAxis ( sketchPathToNode || [ ] ) ,
2023-10-11 13:36:54 +11:00
} ,
2024-02-11 12:59:00 +11:00
// end actions
2023-10-11 13:36:54 +11:00
}
)
2023-10-18 08:03:02 +11:00
function getSketchMetadataFromPathToNode (
pathToNode : PathToNode ,
selectionRanges? : Selections
) {
const pipeExpression = getNodeFromPath < PipeExpression > (
kclManager . ast ,
pathToNode ,
'PipeExpression'
) . node
if ( pipeExpression . type !== 'PipeExpression' ) return { }
const sketchCallExpression = pipeExpression . body . find (
( e ) = > e . type === 'CallExpression' && e . callee . name === 'startSketchOn'
) as CallExpression
if ( ! sketchCallExpression ) return { }
let sketchEnginePathId : string
if ( selectionRanges ) {
sketchEnginePathId =
isCursorInSketchCommandRange (
engineCommandManager . artifactMap ,
selectionRanges
) || ''
} else {
const _selectionRanges : Selections = {
otherSelections : [ ] ,
codeBasedSelections : [
{ range : [ pipeExpression . start , pipeExpression . end ] , type : 'default' } ,
] ,
}
sketchEnginePathId =
isCursorInSketchCommandRange (
engineCommandManager . artifactMap ,
_selectionRanges
) || ''
}
return {
sketchPathToNode : pathToNode ,
sketchEnginePathId ,
}
}