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 =
2024-02-19 17:23:03 +11:00
| {
type : 'Enter sketch'
data ? : {
forceNewSketch? : boolean
}
}
2023-10-16 21:20:05 +11:00
| {
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' }
2024-03-04 16:06:43 -05:00
| { type : 'Export' ; data : ModelingCommandSchema [ 'Export' ] }
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-03-04 16:06:43 -05: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 L W F J D W V 5 h V S Z Z T r l B U K j S 1 F Z i U r D e W V D a s a 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 a F 0 7 b C N L i R Y l G i Z U y Z D b F Y Q z f I a L S Q 5 S w 0 T G Z Q n M 6 e N o d L o E W 7 3 J 6 w V 7 s D 5 U Q y R Z i s M b c P 4 I Q R r G i S d R m f I q U x r C r Q l b K c o Q 4 R H D T W U x 5 D H N L G X X H X P j s B 4 A V w w X 0 p s X G C S E F T h k N E y m F G l E C k M 0 M M + 0 Z M g U a 1 M w u y p g R h l F H l a E p u f B Y D 3 Y i u i V N + q r p d g 0 k l M w k F a U 0 e r m w u h w l U k i B h x U y K U a z t 5 z a 3 m J H 2 I Z E o m F T b 0 + 9 B G n p V o E S R r N k m M g a 0 a h M p l k h q O Z V L + s M 4 k s C j 1 S f F O Z J 7 0 k 3 Y + A E k r j 0 A k E u g N w v n v o W a d 7 D I G y u q O e 2 r P N D R C L I K a K J a 6 J B X r R J 2 H f 3 e y e h 7 j k C R X n 0 o A B b M B 3 f w A N 0 e n H I J E w 7 p + R f 4 R h k p k b a p N E j T R U g K f Q j A 0 F s U n B O Q J H y J Q N C P C 4 T z 7 N N 3 n P b p L 2 v I I 7 w f A J 3 l Q B 5 s A A L 2 4 d g P y - G d 4 m L P 9 A 0 k V Q z W 3 I 1 8 m R G R D X E I 1 y l 1 L J D B W Y w K h k Z C U 3 Q t D c 0 w 4 h u F g G U S D w f x C O I s i 7 g - f w I G w a T M z A K j l V n W i E C s P d N z S G g q n S A D 1 G h N J 2 Q s C p R H B X U A J b Y S x J 7 F z B 2 H I g p J k u S X 1 d b B 3 0 w V T 1 I o i g t K n J V q R o 3 9 9 O W B R - T y F d l C g t R B U s 1 l y m s A V Y R j P d n N Q s 8 P K 8 h 5 Z N w f w A E E A C F v H 8 A A N b T I t p K x 2 1 m c Q x E M G x O P - N J L J 1 e L 4 1 g n d a g a V x T j F Y 9 R I K 3 F P N w a T i r k y r q o A T X q r 0 9 K a 7 Z r D s Z Q 5 H 2 Z Q t X Y i D i j U O K g V s v i 1 E r P K J v Q i T p t m k r - D I K A u h W n 8 S 3 S K Q Q R B U 1 5 H 1 Y R T E s u y 4 Q P b K t X + g M r t z N y M M K m b v N K r p 8 H Y P M K Q 9 H S o v e 1 r p D 2 1 Q A N k T j R E s w 4 T u 1 K D - o R B N h E h 1 z J u 6 O 7 4 f 8 J h H i Z 3 A 1 P I W V M B I J 4 1 I 0 0 L X t 0 6 K r F N W Y L U 6 j I j l U Z R L P 1 P 1 + S q A M g Q R D Q x G p j 5 o d u o q H o U 0 j y I - T A 9 E e n A o C G c K 0 Y a u d l h k J l Q 3 b A E M h W Q 1 U R 5 f 9 Q 1 h f I t R K V X T x u 2 H 7 p 8 1 9 - L 1 g 2 P 2 w Y 3 + Y x u j z B y U 1 - q d s x U U N b b t j 1 A M q j W f 9 H G G p p 7 R Q 6 7 x N 9 h n Y F w E g m H 8 d h U F q 8 P G s 4 q R l h B N Q A 2 q M x L O y K 2 Z D k e Z 5 m 3 R x 2 6 9 9 W C 7 m 0 q i 5 L s u K + W 0 3 v w F 9 7 o M y f j Y V a 4 w N E s 9 q Z j 3 H u d 3 n O Y c j 7 2 n J L h w f - D A A B H W U V M R q B k a r i 3 a 3 K F f - q y P I J H A o p 5 1 b F q T H B b c c d M H e f a m z W 5 J M C 5 n r a g E 9 q L V 3 y B Y d u - E d z p E 3 o a W s M w T C c U O B a T I a h D w j U x O N K G u 9 6 Y H w e G A W 8 q A X z + H I A A u 4 s A r 5 r W s H F Q 4 1 h 9 q a H 2 D o Q 6 R x O I W D 4 r Y b I Y I z R C S w W N X O u C - 7 d A A E p g E E G A P g I R Z T 3 G o Y L O o U g W y G F r K k d I Y g E 6 H X U F b d I q R k S d w T L a f h O c R J C P z p K E + 2 B S 4 A B k 8 B g F H q g T 8 Y D 0 a N Q U N Z C Q K g b D C n S B Z T R d R e S K 3 b n u P a R p f 5 m J u B Y 0 u I U Y B 3 G w C p L m 5 B R 5 y M S F t O K I I P Z 8 V + g o + s l h o x r F U J k h E S U + 5 l Q A O 6 y Q I k R H W y l A o 8 x C p Q f w e A A B m q A C A Q G 4 G A d o u A n y o F e J I G A 7 B B D a y U h R T A g g m m o C S Y g Y y f p C k Z A D G Y B W 4 h L J Q X M O 2 U 0 a R O E d y p k Y 5 M 0 N J C l P K f J S p w y V K 1 M 0 g 0 3 A z S C C P A e E R S Q T B O b s G a Q 8 W 8 f S - C D O O b r U Z 4 z J k I G M t s I 0 N o W y 6 l N A G S y 3 1 N w 0 F U C Y P I k Z D H Z 1 2 a h A 5 H B n w B w C k F X m 9 T x m t P a Z 0 7 p v T + m C F 8 m + D 8 Y z L k T K c e b P S G y r Y t k U P Y Z E y j 8 h p S U E y M Q c g 7 C l C B M U s p K L i W B x q c F c 5 2 K b l 3 I e S Q J 5 R F X m E v 5 Q F M l z T f k 0 q Z N u M Q A E x C a D S o K c s O N V F a O Z D y w 5 C 1 a o X K u W 0 3 A H S 8 D 4 o 6 Y S k g A A j W A g g + D y o p a j S e E c - k o N y T I W C c g 6 j r E O v + b a 5 Y M h Q S S r I b a t Q D U o q N T V E 1 L T R U P H u Y 8 5 5 0 r 3 l 2 o d U 6 n 5 l L V r R Q 2 T M H I I I l A 7 m 3 F o H q f F p B 6 j 2 p x b I g Y f 4 7 K 7 K J Z F A Q j W L T j T i 8 1 e K e n W r T f a w Q e h n W K s 9 X U e Q F R b C I N 1 N C V s y I R a u L s n q V s u V 6 0 4 N c k 2 8 q V V - C t p F Q 8 W 5 i b x W S p e W 8 g Z 6 a + 0 D u z W 9 K Z n E k G s V a s s F Y o b J 1 8 T 9 F C 9 k 2 0 d o 3 q j Q E J 6 X Q 2 1 m o t V 0 r t h 7 B B f v E V m 1 1 4 D v R 5 p S E a O o c g L Q a K K H B H k K i 7 J G g q G a W E H 7 H r 4 G - V u n d S a J U p s A 8 B 0 9 Y H n E Q c 4 i d b I T U r A N 3 n I D e c 5 Y W z y F S H O 5 Y 2 y E U N q h q u 8 + y M f 2 4 s t Q B w l P H 3 g k Y L G R 6 l B M W p W T J l u Z l A a O Q W B W J e l Q 8 4 r C Y e E 2 2 h N + H 9 2 p o G c J 0 T 0 5 x O 5 s 9 c Y G F + o 1 j K w O g h p K V t 5 i 0 O t G I F E 6 I l 2 C J X b y g I T M H g s z Z h z L m G K 6 l 2 O x b + z t B L 3 m e e 8 - 5 X z D x B B n N C g Z i K O b k m W 3 i k o a w r 7 0 6 E w D d U b Y C 8 5 h 7 T g 7 6 z D 4 W H w + c 5 t z I V o V N P b r F c m q V g H i u s 0 i 2 V m L F X K D x b N o l q Z y X h S p b m N A 7 L l l s r S H 5 H l n c w p C s u Z M a 5 G x 5 r 7 G Y B H H 0 c c c R F X e q j j R o 4 m Q j h 5 C W Q G g M 5 Y e s m V o Y x P h H H l 1 q x m 3 Y 8 u D i 8 Q R L L k 9 f C s T A r x M S W e q e U z Y R + n 2 G Y c E 6 h 5 Z S 0 O g r F q r V H B Z H Z H 3 C 7 c 3 J A D l w B w A g K 2 V B M j S R t 6 0 s G u T 6 k k M G W s k J W r - T S O D 2 x k P o e w 7 J K R q l u b 8 h W z s q a R 9 N H t Q R n + r M F Y E h b B a k h N u f H s 2 r u Y E k L g K V H 4 F t j h C M t 1 7 7 r r C 1 G k K a f U v C M h a n + 0 U J K M w F z K z 1 O 1 K C n E O e X d Q A 4 y Q A A 5 C u A A F V A e B 2 C w A I G V C A E B A g U V d I z I 3 d x F X z D 9 J q f L g p F h J S 5 N q F q q c s i K C U A o D X k O 9 f + E N 8 b 0 3 p B Q q O N J 5 1 - S m h z A m G D K t r Q e p - V F F 4 i L V B p R T Q r D 7 k T 9 g c O R e N U s D y J P W Q V D b k T 4 a Y E j P I z L C h b o q C O e Y d 5 5 J 2 J s n J Z m J M k h J C O Y s h w T t U r w B a M t s 5 i r g 6 s 5 0 7 r m 1 Y A B V 7 s x L i Q 8 B J 5 c B f 9 G F 1 H 8 9 f z t r m G 1 E o L x h 3 - y V 6 g k y R 9 3 r L C 6 g 7 J N v Z M - 8 A P f n 4 v l p 1 x b s Q 6 5 w 7 h E 7 9 F A 7 j s t t a E 1 o e R u z S M x q F O Y d j U a Y x P Z W U V m C u D S V 0 E 8 A A e V w H b T - S t X 2 W 8 C n 0 E H A L a U E C g P Y F g J N j X z e 3 0 n x k Z x M F 1 B M k y E W G f k Q B 3 D i h X D Q z p U 8 U w Q n y m w + H 8 F 5 3 8 E a R I E o B 6 C W 1 U j A H Y I 5 g 8 0 5 n N V + U E H a n M D S R h S N E D A k G U S 5 D k H 9 B s E O D m E s D g m A O w Q u D I G w F v A l V a F H k Z k E O 6 G C w E 1 6 Q 0 K 0 P u E E H L k E H Y M o F + Q q E A j I O y B 9 S h E O m 2 l S S s D B F B U D H U G c h M O 0 P w F 0 P F X N W X y W 0 G E V S B E Y w 5 R 3 E Y k D G h D X n L F W D s H B B W B q G 8 J h 1 M J 0 P L k P j 4 G C h 0 K J F z A Q J C w 6 R 8 L M I s N y J 7 B s L 2 g Y i s F q A t H b j S F h G h C g h y w S k A N 9 B c K Q h O F 5 w w H g C i D U K g F b 2 j 0 E E W D K F y E U D L 3 U C 0 B 2 y K E G J N C 1 E s F q C F G M D N G c h x D A H 6 P X 3 p C 0 H K G R H m R D G A m h H U E X F b H 1 G k O M m U S 9 j W P w P Z D i h L x M H y Q r 0 O i Q Q W G t E G l s H m A w w v 3 y m E Q u P d R b A t A x y S n 1 G B 1 9 U y x f i Z T i N a l S G q A A m h M w y G S + X 8 2 F X J W + J c T W F m D m U U H 5 B q F S H B W S A B F b C h W 1 H y H h R A M R U b X c 1 R T 8 n R V i y x S R M M z b y M C 0 W 1 T 7 w U U 3 w N A D T k E Z F S C g h l n m F s M w x j T j W R L n F c S k D U E
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' ,
2024-02-19 17:23:03 +11:00
cond : 'Selection is on 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 ,
} ,
2024-03-04 16:06:43 -05:00
Export : {
target : 'idle' ,
internal : true ,
cond : 'Has exportable geometry' ,
actions : 'Engine export' ,
} ,
2023-10-11 13:36:54 +11:00
} ,
2024-02-19 12:41:36 +11:00
entry : 'reset client scene mouse handlers' ,
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' : {
2024-02-20 11:04:42 +11:00
exit : [ ] ,
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-03-02 08:20:50 +11:00
'engineToClient cam sync direction' ,
2024-02-11 12:59:00 +11:00
] ,
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-03-02 08:20:50 +11:00
entry : 'clientToEngine cam sync direction' ,
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' ,
} ,
] ,
2024-03-02 08:20:50 +11:00
entry : 'clientToEngine cam sync direction' ,
2024-02-11 12:59:00 +11:00
} ,
2024-03-04 16:06:43 -05:00
'animating to plane (copy)' : { } ,
'animating to plane (copy) (copy)' : { } ,
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
2024-02-23 11:24:22 -05:00
let ast = kclManager . ast
if (
'variableName' in distance &&
distance . variableName &&
distance . insertIndex !== undefined
) {
console . log ( 'adding variable!' , distance )
const newBody = [ . . . ast . body ]
newBody . splice (
distance . insertIndex ,
0 ,
distance . variableDeclarationAst
)
ast . body = newBody
}
2023-10-11 13:36:54 +11:00
const pathToNode = getNodePathFromSourceRange (
2024-02-23 11:24:22 -05:00
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 (
2024-02-23 11:24:22 -05:00
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 ,
2024-02-23 11:24:22 -05:00
'variableName' in distance
? distance . variableIdentifierAst
: distance . valueAst
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
2024-03-03 16:23:16 +11:00
if ( args . mouseEvent . which !== 1 ) return
const { intersectionPoint } = args
if ( ! intersectionPoint ? . twoD || ! sketchPathToNode ) return
2024-02-11 12:59:00 +11:00
const { modifiedAst } = addStartProfileAt (
kclManager . ast ,
sketchPathToNode ,
2024-03-03 16:23:16 +11:00
[ intersectionPoint . twoD . x , intersectionPoint . twoD . y ]
2024-02-11 12:59:00 +11:00
)
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 || [ ] ) ,
2024-02-19 12:41:36 +11:00
'reset client scene mouse handlers' : ( ) = > {
// when not in sketch mode we don't need any mouse listeners
// (note the orbit controls are always active though)
2024-02-20 11:04:42 +11:00
sceneInfra . resetMouseListeners ( )
2024-02-19 12:41:36 +11:00
} ,
2024-03-02 08:20:50 +11:00
'clientToEngine cam sync direction' : ( ) = > {
sceneInfra . camControls . syncDirection = 'clientToEngine'
} ,
'engineToClient cam sync direction' : ( ) = > {
sceneInfra . camControls . syncDirection = 'engineToClient'
} ,
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 ,
}
}