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'
2024-02-11 12:59:00 +11:00
import { isReducedMotion } from 'lib/utils'
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'
import { v4 as uuidv4 } from 'uuid'
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 ,
clientSideScene ,
quaternionFromSketchGroup ,
sketchGroupFromPathToNode ,
} from 'clientSideScene/clientSideScene'
import { setupSingleton } from 'clientSideScene/setup'
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-11 12:59:00 +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 D M A J h o A 6 Y Q H Y a M g K w A 2 A I w A W A J z C R A G h A B P R I p H i A H I t U 1 F R 2 c M W y r 8 g L 7 3 t a D D n w E A y m H Y A C W F j B y T m 5 a B i Q Q F j Z g n n C B B E U b W T F J Y V l l Q V k T e W V l e V V t P Q R B e V l V M R s c x W E 1 S V V Z R 2 d 0 L D w o M W w I T D B P b z 8 A o K 5 c U N 5 I j g H e O J K k k r z h e S N z a p p l A v 0 L e X L Z G n k l G l S 8 + U E G k B d m - D a O r o B R X H Y w A C c - A G t v c g A L I f C R 6 P H E S U V J M R 5 V R - Z S S I y i Z S p F Y I a T K M R G a S q C y 1 a z K c F H E 5 u V r t T o E a 6 3 B 6 w Z 7 s N 5 U R R h Z i s U b c H 5 F c F i W S C J H y S S S S H p J T Q 1 T Z c p L Z T m B R z d S H J z H J p Y 8 6 4 y 5 8 d h 3 A C u G A + l K i Y 1 i i C M g i M E n + y k y k k 2 J m E 0 I S R n W N h o Y P N t h o m Q x 4 p a Y g 8 x L e x D I l E w T p e 7 3 o w y p 3 z V C G E 1 T K j J t 6 V M q R s x o N y R s 1 U U u 3 k q X q o s x D s 9 J N e j u d r w A k h d u r 5 - J 1 + i E f Z 8 - a r Q H F q g i x D a z D k U r V c s a M m V 5 D R B I I t g m c s U H K n 7 W c M 2 9 s 1 7 8 7 j k C R n r 0 o A B b M A 3 H w A N 3 u n H I J E w S o i l Z p A Y 0 a U B D c h t S U a P k x r Z x m 5 u q s s j + 8 2 U d t c 6 Z z 4 8 z k 6 6 0 9 n - g X S 9 8 V 5 U D u b A A C 9 u H Y L c d y + K t + E Q D R N X r Q R - h k I M 0 S M f J d H 0 A 4 y h U a x k I y N I r G E F 9 T l a U c s w o r 9 i G 4 W B Z R I P A f C A k D w J u L c f A g b A 6 L d M B o L 3 G J q 3 g 5 C A V y N I l l U U E l h t a E p A 0 Q F Z F M H s L A y R R S I l C i P z e a i i F o + j G L X O 4 N 3 Y z j u I o X j y 2 V a k B L g w N u 2 E M R B H 1 C S W U Z U R L y w w N O 0 U c o 3 J U T Z F G 2 K Q 1 L f L 1 N L z A s d N w O i 7 g Y 3 A f A A Q Q A I Q 8 H w A A 0 + J V f d B N s t F 4 U 7 H Y l k E Z Q V G h E R 6 V s Q x g U 2 R y t m C k d 3 y o i L d J i x i k p S g B N D K r N p D R c u 2 e 9 J C T V k w V K 4 r 1 h E U w T G 7 Z D i r q 8 i G p z b T m t i n w y C g T o u v 9 b L F n W e Y Z m K M w e w t G S N T h S x N g t N E E m B O a w r C p a o r 0 u L O n w d h v Q p X d M u s m t + X E M E E S W a p + z m G T n I c k o j F B b Z h W f I d X 3 q 0 L G t x S L o p W p h 7 n R 3 B O P I O V M B I B 4 T M g s z N t g m t h C R M R 1 E W f U D F U c F B F K v C H I C k Q 2 X Q p t b o 0 p G u h R p 6 m O A s C I K 3 T A d F W n A o E G C z P u 6 g 8 R H W Y Q T E y J Y H y s I x j U h w R 4 S p 1 l d V M T t Y c a e H 5 s R x a m s e l q 4 o M o z M B F s X s A l k m s p s 3 r 7 P O 4 F c g V h T J G N O p N b W I N I Y t T V 0 k 5 h a J z N 1 H G N g X A S C Y H x 2 F Q N L H e + o T B s B U 1 G x o Q 7 O 2 9 j y N D y e E g y z g 4 e 1 m d R Q 5 N 8 P k e W q O Y 7 j h O f E 6 q W Y K d m t H P W N Q J K q S G q f c w p q n 1 c p d d s b I 1 h s C v M 3 u i O + b A A B H O V 2 J e q A 3 u T n q M n W V R H I R K 7 J E c t I Z J t L V E x S Y F 5 m 5 Q d D b I u 7 u Z o 8 2 0 f x 4 X q G b - i 1 7 M M Q c g f W Z p A q z D + 9 m O E k x 1 C R H 8 B S N o L 5 i i N t f U 2 1 c 7 6 M T u G A e c q A 1 w + H I D X G 4 s B V 6 y y q E h W w C k m R J j V n n G w W o l D d n 8 g + N E I p L 7 q T D p + A s A A l M A A B a M A f B A h y l u J g 7 a Y 0 G T W l S E V O Y r J j S i D K J v a G u 8 k Q I Q n m O G + l x 5 7 Y D j g A G T w G A e O q B U D b m f l 9 H q 3 J R E K w O O k B E d R - j G j D E h O o C k n z b D y N I y i 0 C r j y P r m t A C 2 B 2 L 4 3 I G o r h N k R D I X h D Q B E X 8 g Q P m N J C M o x R q r W j B O k F M 1 C Q q T 3 i g A d w Y o B A W r F I K Y A 4 l x I m l A f B 4 A A G a o A I B A b g Y A 2 i 4 B X K g Z 4 Y g Y D s C Y c x Q W b F M B M P y a g L x c R u w s j y n U J Y l g R G - 3 g m y E S a h U g K z E W k W x Y h E n J P 5 i x I W G T C Y 8 V y b g A p B B 7 h 3 G A m I J g e N 2 A F L u P O a p 3 g 6 m p L m c 0 5 Z r S t E y 2 y h 0 r U j J 9 R b F 1 G y B I y w 8 6 I k B D V I 6 r J i E T K m R w V c 6 5 s C b n m V k x Z L S i k l L K R U q p N S m F W w B V u U 5 B S 2 l C D 3 g y T s Z g 0 i 1 B m s 8 - u S h v K g g C i Y S w + o 8 g G w g V f D S P z f C w s B Z k 0 y O T Q V r I 2 V s k g O z g L 7 O h d S + F L S k V F H b h I B W l h I R G K T D J B Q Z R B q i A m l U O Y C h v l J N + W 1 N K S y V n F N w K U v A k L S n Q p I A A I 1 g E w v g C L z k f R b i n X l 8 x y i W C z r v E o 0 g o w e T K u K 4 o k M l A P l 2 L q O V 0 z F W p W V Y U x l d x N n b N 2 e y w 5 u r 9 W G u 5 R c r a 3 j N T G D F W C a Q s w 8 i y F K t U T W F j - E K 3 J i o J M n q F X J U b r 6 s F a q I W V K 1 a G v V T C d B G p 5 d 2 W o y R - q g O K m o P u y K 6 j 1 l 9 v M H s b I 8 F 5 t 8 I q 9 q R b - W B p Z c G g 5 t S w 1 V p r V G 0 m y K L W 6 i D h o K J J d R o U 2 s V n U w + p B q q D 7 a t f A n Q i 2 q v V e U s t 4 6 m F r U 6 N O k 1 L 8 A z d g t S k S E P Z H K i G b C d S G D I y 4 9 i M P M W Y M S y U 0 N C p S v d 6 1 V E M r u O s g N z L W V 7 L P R e 5 h k b r 3 a N v Z q e y V Q U g a A Q u Y I q J 0 c j J C z q o A j 7 t 1 C k r T A j e J 8 r f B L z e o e 8 F G r T 3 Q q o 6 8 K 9 v o k N X K 3 v C W w a J 1 C m h E D k U q C x 5 L u 2 k K a B M m 9 d 2 M a H e B p l Q a 2 V n s Y 8 x i s r G Y 3 1 q s E V V y 8 x S j Y v g s C c Q q Q M I R h k P 8 K h - 6 4 l j i A + j O 4 m N s a 4 3 x r S 7 J o G z n F u P Z q s 9 F m r M A p s 3 c J h C y z I K c s t G 9 p c s H I m G K s C I q T 4 j Q O r j J T F k G E D g a F 7 r u t z S 5 r N 4 w J s C s y k m I M j u g y G 2 p y W s Y e b S 9 5 j L l A - P S w C 8 i 2 Y w W V C b v C 4 D R m S w Y t g m 5 D 4 x L c N y X v m U W q t R G j C y 9 B L N E W t s l 4 Q q Q M M p d 2 0 I k x w h R B o D C u 8 5 A k e H M b S e 3 X V E J z 6 3 I u U C j 4 7 O J u K 4 j J 7 j P E z t b k I D U A I H x A k 7 L s c w + o 2 w 2 i Q r s H U 3 Y C O S A m W t 3 r m A x C 5 l w B w A g t b k L r H 1 I 5 f U 5 M n L 7 w 8 o R i Q p o g x g m y H T S E 7 2 V G f e + 7 9 9 g - 3 y Q s c u T G q w 7 8 L B B 1 d f y R k p j g Q M g T O C e Y g d 1 B - t I y t s c H 2 N t f d w G y r c - X i y B C G y d s 1 h F 7 I o e y B o c w Z g h E e Q S P 8 S m l D B T J i z i R D r A H V v I 8 Z 2 I A A c o n A A C q g P A 7 B Y A E H i h A C A f h I K G R 8 C w T X t a U h a j K v q X U - I 1 h c l J 1 2 J M s w u 2 H l U r L 0 z W Y f t - Z 5 S + 0 R - j a g I i M 8 h a M S h 6 z Z B t A + F 1 S g Z e x L I 2 O T 3 6 O y S I e x z W B I S Q C K E b Z l U B m I u l B h J M K y T I B o z D g N p 3 d A A K n t z g b i 7 g e I T m z v o n O k + V a K H k P 2 q J G z 4 U 2 L n Q o N g C 7 F Q V j U T U F i J k V - w C 4 6 v t f C l b Z 2 w z 9 R m i m + z p b 7 Y B y C x U J z H y v d p I X Y n t s h e z d N 3 s f X g + G Z z 4 P J J B K D d E G x x M A Z - c a + G Z W q n l S I 4 R d g 0 4 R 3 I c w t M I F 9 g y X I f I R A K C q y 3 R k D Y D z g s o t B q L G 5 4 x q p O a l p V I g F g G 3 B M I J x M J n 6 U A 8 o B Q q D H i a j 6 g K Q u z Z 6 F A W K U x + 7 X a 1 a 5 C u 4 x 6 t A I H g H 4 C Q E P 5 d B e B F g N 4 D A Y F k I M j r z W A W j k x 1 C t o I A I h J C 7 y i B d 7 d q 1 j A G - a I E Q E N y s J Z I Q F E h e i w F 0 b w H i E s r M I o F y G Z g Y G A I 4 I a j V T R K b z Q h s j 2 Q S T C j n i Z C D i i j M 4 Y D w D h C 0 5 Y 7 N 4 j Z S A y B g I q D C i R b 9 w p D J D q C m D n x 2 Q j y 3 Q 4 h g B 2 G L 7 N o c Z 4 H S p D S 5 B f 5 V B Z w + Q P r V T Q w 7 o H 5 0 6 v B B G n a B h d j e R m B G I B 6 7 z I S K C l S d g S B U x Z x E Q B R z A T L c y p F m r V B J j p y 1 D + I Y S i T b D R i m D J B K Q A G M i Z A Y S 7 r 1 J p L G S l Y O Y F J V E 6 K + K m j 8 i 7 z g h c Z u E D K t F d w L Z M g D i Q y 7 q c p A p 0 q D G o D D E H g S R J C Z D I T + L Z C Q x o a i q s i A i + T X R Z x o j R 4 m a H 6 T I U Y J Q F o + o t K b H b Q 8 E M h b B o S g i Q h B i 8 E A F l A 2 g T Q U L K y 2 C 7 o D q + r P H O x E H G J 2 D M g T T d 5 t q u z W B 0 y C E i C z C 7 p w Z g m K b J 7 a a l D 1 i M g G C W A J g l D 5 F 5 w a g d y i C e x 2 Q 3 Z v Z J F 3 R A Y S Z P G Y n 2 E - 7 g j r q b w q D f o E H a Y 8 i a i H H X i a i d F J Y Y w p Z F a 2 Y + b
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 ,
actions : [
'set sketchMetadata from pathToNode' ,
'sketch mode enabled' ,
'edit mode enter' ,
] ,
} ,
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-11 12:59:00 +11:00
entry : [ 'equip select' ] ,
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 : [
'tear down client sketch' ,
'setup client side sketch segments' ,
] ,
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' ,
} ,
} ,
} ,
} ,
initial : 'Init' ,
} ,
Init : {
always : [
{
target : 'SketchIdle' ,
cond : 'is editing existing sketch' ,
} ,
'Line tool' ,
] ,
} ,
'Tangential arc to' : {
exit : [
'tear down client sketch' ,
'setup client side sketch segments' ,
] ,
entry : 'set up draft arc' ,
on : {
'Set selection' : {
target : 'Tangential arc to' ,
internal : true ,
} ,
'Equip Line tool' : 'Line tool' ,
} ,
} ,
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' ,
] ,
entry : [ 'add axis n grid' , 'setup client side sketch segments' ] ,
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?
2023-10-11 13:36:54 +11:00
actions : [
'edit_mode_exit' ,
'default_camera_disable_sketch_mode' ,
'reset sketch metadata' ,
] ,
} ,
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 : {
'sketch mode enabled' : ( { sketchPlaneId } ) = > {
2024-02-11 12:59:00 +11:00
engineCommandManager . sendSceneCommand ( {
2023-10-11 13:36:54 +11:00
type : 'modeling_cmd_req' ,
cmd_id : uuidv4 ( ) ,
cmd : {
type : 'sketch_mode_enable' ,
plane_id : sketchPlaneId ,
ortho : true ,
animated : ! isReducedMotion ( ) ,
} ,
} )
} ,
2023-10-18 08:03:02 +11:00
'set sketchMetadata from pathToNode' : assign ( ( { sketchPathToNode } ) = > {
if ( ! sketchPathToNode ) return { }
return getSketchMetadataFromPathToNode ( sketchPathToNode )
} ) ,
2023-10-11 13:36:54 +11:00
'edit mode enter' : ( { selectionRanges } ) = > {
const pathId = isCursorInSketchCommandRange (
engineCommandManager . artifactMap ,
selectionRanges
)
pathId &&
2024-02-11 12:59:00 +11:00
engineCommandManager . sendSceneCommand ( {
2023-10-11 13:36:54 +11:00
type : 'modeling_cmd_req' ,
cmd_id : uuidv4 ( ) ,
cmd : {
type : 'edit_mode_enter' ,
target : pathId ,
} ,
} )
} ,
2024-02-11 12:59:00 +11:00
'hide default planes' : ( ) = > setupSingleton . removeDefaultPlanes ( ) ,
2023-10-11 13:36:54 +11:00
edit_mode_exit : ( ) = >
engineCommandManager . sendSceneCommand ( {
type : 'modeling_cmd_req' ,
cmd_id : uuidv4 ( ) ,
cmd : { type : 'edit_mode_exit' } ,
} ) ,
default_camera_disable_sketch_mode : ( ) = >
engineCommandManager . sendSceneCommand ( {
type : 'modeling_cmd_req' ,
cmd_id : uuidv4 ( ) ,
cmd : { type : 'default_camera_disable_sketch_mode' } ,
} ) ,
'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
// TODO figure out why data isn't typed with sketchPathToNode and sketchNormalBackUp
'set new sketch metadata' : assign ( ( _ , { data } ) = > data ) ,
2023-10-11 13:36:54 +11:00
'equip select' : ( ) = >
engineCommandManager . sendSceneCommand ( {
type : 'modeling_cmd_req' ,
cmd_id : uuidv4 ( ) ,
cmd : {
type : 'set_tool' ,
tool : 'select' ,
} ,
} ) ,
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-11 12:59:00 +11:00
clientSideScene . updateAstAndRejigSketch (
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-11 12:59:00 +11:00
clientSideScene . updateAstAndRejigSketch (
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-11 12:59:00 +11:00
clientSideScene . updateAstAndRejigSketch (
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-11 12:59:00 +11:00
clientSideScene . updateAstAndRejigSketch (
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-11 12:59:00 +11:00
clientSideScene . updateAstAndRejigSketch (
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-11 12:59:00 +11:00
clientSideScene . updateAstAndRejigSketch (
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-11 12:59:00 +11:00
clientSideScene . updateAstAndRejigSketch (
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-11 12:59:00 +11:00
clientSideScene . updateAstAndRejigSketch (
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-11 12:59:00 +11:00
clientSideScene . updateAstAndRejigSketch (
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-11 12:59:00 +11:00
'setup client side sketch segments' : ( { sketchPathToNode } , { type } ) = > {
if ( type !== 'done.invoke.animate-to-face' ) {
clientSideScene . setupSketch ( {
sketchPathToNode : sketchPathToNode || [ ] ,
} )
} else {
setupSingleton . modelingSend ( 'Equip Line tool' )
}
} ,
'animate after sketch' : ( ) = > {
clientSideScene . animateAfterSketch ( )
} ,
'tear down client sketch' : ( ) = >
clientSideScene . tearDownSketch ( { removeAxis : false } ) ,
'remove sketch grid' : ( ) = > clientSideScene . removeSketchGrid ( ) ,
'set up draft line' : ( { sketchPathToNode } ) = > {
clientSideScene . setUpDraftLine ( sketchPathToNode || [ ] )
} ,
'set up draft arc' : ( { sketchPathToNode } ) = > {
clientSideScene . setUpDraftArc ( sketchPathToNode || [ ] )
} ,
'set up draft line without teardown' : ( { sketchPathToNode } ) = >
clientSideScene . setupSketch ( {
sketchPathToNode : sketchPathToNode || [ ] ,
draftSegment : 'line' ,
} ) ,
'show default planes' : ( ) = > {
setupSingleton . showDefaultPlanes ( )
clientSideScene . setupDefaultPlaneHover ( )
} ,
'setup noPoints onClick listener' : ( { sketchPathToNode } ) = > {
clientSideScene . createIntersectionPlane ( )
const sketchGroup = sketchGroupFromPathToNode ( {
pathToNode : sketchPathToNode || [ ] ,
ast : kclManager.ast ,
programMemory : kclManager.programMemory ,
} )
const quaternion = quaternionFromSketchGroup ( sketchGroup )
clientSideScene . intersectionPlane &&
clientSideScene . intersectionPlane . setRotationFromQuaternion (
quaternion
)
setupSingleton . setCallbacks ( {
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 )
clientSideScene . removeIntersectionPlane ( )
setupSingleton . modelingSend ( 'Add start point' )
} ,
} )
} ,
'add axis n grid' : ( { sketchPathToNode } ) = >
clientSideScene . 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 ,
}
}