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' }
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-20 11:04:42 +11:00
/ * * @ x s t a t e - l a y o u t N 4 I g p g J g 5 m D O I C 5 Q F k D 2 E w B s C W A 7 K A x A M I C G u A x l g N o A M A u o q A A 6 q z Y A u 2 q u j I A H o g C 0 A d g C s A Z g B 0 4 g E y j h A D n E A 2 G g o U A W J Q B o Q A T 0 Q B G G u I C c k m o Z k b T M 4 2 Y W K A v k 9 1 o M O f A Q D K Y d g A J Y L D B y T m 5 a B i Q Q F j Y w n i i B B F t p G h l x D R p h G g 1 Z U R l h X Q M E c R L D S V F 5 U w V 8 4 X E K 8 R c 3 d C w 8 K E l s C E w w H z 9 A 4 N C u X A j e G I 5 B 3 k T B 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 o h W O 3 U h 2 U O S s m m h h n 2 j P y N G U o l M h j W w v Z o o 8 r U k 3 m J H 2 I Z E o m E d b 0 + 9 B G V N + q o Q h o U P O M w g R i 1 B p l k B q O Z U D C k N 4 k s C l E C l t 5 z a H p J 7 w d T v e A E k r j 0 A k E u g N w t 7 v r 6 V a B E o Z Q 2 U K s I O c m r P M D R C L I K a O a 6 o K U 6 I 0 + L M x 8 c 5 6 C 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 i u i V Z p - q s F s k R x k m i b m l S B X 0 R g 0 h i k i f B c g k + S U G k H 9 u H 2 f f 4 + 6 k + n Q T n C 4 C d 5 U A e b A A C 9 u H Y D c t x + a t + C M e F J F U I N u 0 N f J k R k A 1 x E N c o N H k S w V m M C o Z F f C 5 3 1 H L M v 2 I b h Y B l E g 8 H 8 I C Q P A u 4 N 3 8 C B s B o 1 0 w G g n d 4 h r e D R A 0 T s 0 h o K p 0 g t d R o T S d k L A q U R w V w i 0 b x I j N c 3 I j 5 K K I a j a P o l c H j X V j 2 M 4 i h u I r J V q T 4 u C A 2 W B R J G F Y 9 U R 1 Y x N A w y 8 E B k V l y m s A V Y S B M 0 X 1 c U 4 x T f N T P 0 L L T c B o h 4 6 N w f w A E E A C F v H 8 A A N H j l V 3 f j r O T W Z x D E Q w b C w m R b H E K T h S E 4 V k U W V J z V q B p A s x E L P X U - N w u 0 6 L 6 M S 5 K A E 1 0 o s 2 k 9 W 2 a w 7 G U O R 9 j N U b o U T d R J C B O T L T U U M A q a O 1 S N C 3 N N P a m L - D I K A u j 6 v 0 s p v H J p C U a p k 0 U O t T C k + S 4 X 7 X z 1 W E U x T G E F S W p a z b I p 0 2 K u n w d g v Q p b c M s s 2 s S h m F R 1 V E m 8 0 n 2 K T D l s p t T G v J 6 w x U V 6 G u C t b m r C 3 E I q i 7 a m E e Q n c H Y 8 h Z U w E g n i M y C T I O 2 D a w 8 2 y b E j K w M i O V R l C k + M h P 5 K o X q B B E N D E N 6 y J x 7 o 8 e + h j g L A i C N 0 w P Q d p w K A h j M o H + r 3 Z Y Z C Z F M t A k X C M h W A 1 H M k Y q d d h f J 1 R K E X 1 r H N q v o 6 2 K 9 I M z B 5 c V 7 B l b p z K r K s J 7 c u P J 7 H L M V E D V G 7 Y U x e q o 1 m K x x 6 p W 9 N 3 r F q j 7 e 2 2 B c B I J h - H Y V B U s 9 k G j C w q R l h B N Q X u q M w p O y L W P P V e Z V B T I F i I x 1 b V O x j a 7 f x + j U - T z P s 9 6 1 W Y K 9 0 G b w s J s s N h P L j A 0 K S C p m Q T H D k C 1 Q x 1 W O g u b h O 2 9 x r b 6 L A A B H W V W N + q B - t z g b i q k V E h a e r I 8 g k C 8 i j r R N c p M c F u w m 0 x r d b 2 3 N + T + i m E p u X q D 9 1 4 g N W Q M w l g E R 7 M j K e b l D C R j A a U Q 4 z 1 M h q A H E 3 e O o s N 7 i y 3 r F B 4 Y B Z y o B X P 4 c g 2 D 2 C w B P h r L Q i F W b q m P N e F M p U Y F K D K P h W w 2 Q w R B k b n H I c N s K K F g A E p g E E G A P g I R Z T 3 H I U d O o U g b y w M T G k I W F R D D Q n U F r d I q R k S 1 y U I c D + W Y P q F m u H v b A G c A A y e A w A 9 1 Q J u I B w M B o K B k h I F Q z M 9 a S T c k o M O m R h p y D m K i Q w O i R y J w M b K I x m d d o A W w K x S m 5 A e 4 S K s i N W y I J L a W n k G 4 h h 9 9 j B l F P H X R Q 6 Q 5 j L V X u g t S c U A D u d F A L S 2 Y p B T A b E O I 0 0 o P 4 P A A A z V A B A I D c D A O 0 X A S 5 U C v E k D A d g g h G I y x Y p g Q Q j T U A x M S C J I S C I d S i V q M 9 c e U l r z m G T M e G G y h b C P T 8 d m Y p p S p Z M V l l U 6 m X F 6 m 4 C a Q Q R 4 D x g K S C Y B T d g T S H i z l 6 X 4 A Z 5 T D m j L O e M 6 x 6 s s o i W 2 I a B E C Z c L H h e l J E E W t s i m n B H U N C v i 0 H c O a r s j g y 5 V z Y H X E c m p J y x k t L a R 0 r p P S + m C C d m i j c H y m k T M Q D D L W N 5 L o m G R L A - I U l j x S E c D f O w p Q g T b M k E i g I x L 0 X V O M n U 7 F l z r m 3 J I P c 4 C T z C V 8 t J W M i l 7 k i p M m 7 G I R e O s m W C k P B N V I I J z p K C 5 T y + K S V U q n P O a 0 3 A 7 S 8 D 4 v a Y S k g A A j W A g g + B k q + Y D A e e c F W W l m q N e 8 c g 6 j r D c s V U a h 4 M j X m X p r W o + q S n I q 6 s a 4 V D w r k P B u X c h 5 U q X l 2 o d U 6 u V 3 z D q x L H r l H V d R I R z z K p 6 v 1 Z o s L Z F D O - e F T V d E G p j d 1 E 1 z S z U W s 6 d 0 6 1 a b 7 W C D 0 M 6 + V 6 z p C N g q L Y O B u E p q m h m D Y O x 8 l 6 H d j y Y 1 L G d a o 0 B A b U 2 i 5 8 b R X J s l c 8 - p 6 b u 2 9 u z f T S l e b z w r D 8 i s U N U 1 L R C V N O y U a Y 0 8 q c P y Q i x d e z d p d F X S 2 v F 7 b t 2 C D f Y I r N r r g H + h h u D S w N 4 b 7 P W D g G i o P J I z d j A x U I M s J I 2 v v w O + u N C a k 3 i p T T + v 9 + 7 A M 2 O A 1 h B G 2 Q 9 R W B L n W G 6 d Z D z g a y H I b s y x 0 Z c N r S O A 1 h 9 - o f t x Z a 7 9 h L 2 P v H w z 6 Q j v y s L b B y N J K B M h z x w x y q a D l K g 6 x W B Q 8 i v j q 6 R W J r F R K x 5 P 6 + M C c r E J 3 N n r j A m B T J a E 8 r k i j L A 1 f M a w d i F E o n R D W h d r G l 3 + E J g 8 Y m p N y a U w F b U 8 x 2 L P 3 c Y J S 8 t z H m 0 V e Y e I I Y 5 J l d P m R z Z M z W d l 6 H W D v V H U Q X M 5 D S H 5 H M M 0 k H f V K Y C C F h c n m K Z U 0 x S Z V T 6 7 1 O b q 0 4 S w r J M w s l c i 2 V y g M W 1 Z x c p Q l 4 U S h k s e V S 1 J X y m W C r z H N P Z C Q X L T H m o s Z g I s f R S x x D 7 Z J 8 w 1 5 J N H E y E c P I q T K U v U P F 1 0 S N m k K P v n S 3 X R E 3 z F Z 0 s X i Q x G c a Y w D u O E q p k T o k H s H p S 2 E Q l 9 h m H B O o P m n M 3 L 8 3 z Y o W E o k H P M a c 9 m U 7 U 3 J B 5 l w B w A g C 2 V B M g S a t p G C 8 u T x h N i C S M k I 8 p P T S O N s x k P o e w 7 J A R n 5 s T 8 h a 3 k s e K 9 5 G N n Q l h E t l Y E h N k b P B K g 0 H x 2 R w Q - O 5 g S Q u B J U b h m y W E I 8 3 n v u u s L U a Q x 5 4 w c I y D X L k Q t Z r X g U d z a 8 W F 8 e T Z 5 5 I A A c t n A A C q g P A p C C B x Q g B A Q I k F 9 K u c N 3 c P t 8 w K q v 3 N I K R Y O o u Q b N y h H L I i g z o a 7 O 6 g S x O v 9 c 2 + N 6 Q E y V j S f t Y D J o c w J g 0 j V F E r r F x R Q s h l B s I g 0 o x 4 V h c q J + w O H Y u B r 4 V m B d O l D G E 8 G m B L M D R y w o W W b h R z 9 6 O e 4 f k k E 2 T 2 s K E m S Q k h H M W Q 4 I C r l 4 P I o P W h x L O R h B 0 + l j 2 Y A A q o S 7 s R I e F E r O Q v + i i 4 j 4 e 9 y o 1 z A b K U M K R M t h i r l + v E y K 9 k n L C 4 R T F y 6 f + A w l z 4 X 8 0 w J w T u f + - D y 3 y P l n p m J k H 8 K U 0 5 n E B I x 5 O b N I P C U 0 O Y J j c f M H S Q W U E m b O T i f S d 8 A A e V w B x X N S - R 6 T i m 8 E n 0 E E g N a U E B g P Y H g J V l X x e w D F k C k D m B M F w l E k y E W D v k Q H N F s h b E Q x p S c W 2 X 8 H 5 3 8 A a R I E o B 6 D m z Y j A A 4 P J g K w p n N X l U E A K n M A S W M 0 N F D A k F g S 5 A y y R n Z C G 0 s A f F A K O 0 k D I G w F n H F V a B 7 l c y E O 6 A C z b R 6 Q 0 K 0 P u E E C z k E A 4 M o H l U U U P G o M W A y C W C h D c l G n i S s D B B B V D H U D e h M O 0 P w F 0 L F X N S X z m 0 G D 7 S B B o z k A X i Q l D G h D n k P F W D s H B B W B q B 8 J h 1 M J 0 K z n 8 G E R q R 0 K J E 9 C Q N b S t X U L S P F U E Q s L y K z B s L N C o V Z G e g 8 j S F h G h D o Q H W P G A L s D m F o R c E C n 5 w w H g C i C O x f z X 0 E E W D K F y G y S Q k 0 B 0 D c k E E E i V S g X 2 D y F G k t D e h x D A E G K I P p E o U e h e h B F w h P G U X R w k D U A + 3 c M s G r X r 3 f H W P d X Z C Z m L x U F L y R i m i 1 g 2 U q E D m c n Z z A M 5 w - E w S u J A W e h N h 1 H j D y m q F 2 G j G S B v D y l S G q A t B h P y 3 2 S G U q R 8 y x U + V + L 3 C D C Z g y F L n 5 B q F S D B W S A B D v H m F s H 5 D h J l Q x U F T 8 x R L 0 1 b y M B U U 1 V 7 y k Q 3 y U Q D X o w s G 8 m 5 m G 1 R D h J j R S i b V R K O j s S k D U C K l H 0 S N
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 ,
} ,
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-02-14 05:35:05 +11:00
entry : [ 'add axis n grid' , 'conditionally equip line tool' ] ,
2023-10-11 13:36:54 +11:00
} ,
'Sketch no face' : {
entry : 'show default planes' ,
exit : 'hide default planes' ,
on : {
'Select default plane' : {
2024-02-11 12:59:00 +11:00
target : 'animating to plane' ,
actions : [ 'reset sketch metadata' ] ,
} ,
} ,
} ,
'animating to plane' : {
invoke : {
src : 'animate-to-face' ,
id : 'animate-to-face' ,
onDone : {
2023-10-11 13:36:54 +11:00
target : 'Sketch' ,
2024-02-11 12:59:00 +11:00
actions : 'set new sketch metadata' ,
} ,
} ,
on : {
'Set selection' : {
target : 'animating to plane' ,
internal : true ,
2023-10-11 13:36:54 +11:00
} ,
} ,
} ,
2024-02-11 12:59:00 +11:00
'animating to existing sketch' : {
invoke : [
{
src : 'animate-to-sketch' ,
id : 'animate-to-sketch' ,
onDone : 'Sketch' ,
} ,
] ,
} ,
2023-10-11 13:36:54 +11:00
} ,
initial : 'idle' ,
on : {
Cancel : {
target : 'idle' ,
2023-11-01 17:34:54 -05:00
// TODO what if we're existing extrude equipped, should these actions still be fired?
// maybe cancel needs to have a guard for if else logic?
2024-02-13 07:41:37 +11:00
actions : [ 'reset sketch metadata' ] ,
2023-10-11 13:36:54 +11:00
} ,
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
'Set selection' : {
target : '#Modeling' ,
internal : true ,
actions : 'Set selection' ,
} ,
2023-10-11 13:36:54 +11:00
} ,
} ,
{
guards : {
2024-02-11 12:59:00 +11:00
'is editing existing sketch' : ( { sketchPathToNode } ) = > {
// should check that the variable declaration is a pipeExpression
// and that the pipeExpression contains a "startProfileAt" callExpression
if ( ! sketchPathToNode ) return false
const variableDeclaration = getNodeFromPath < VariableDeclarator > (
kclManager . ast ,
sketchPathToNode ,
'VariableDeclarator'
) . node
if ( variableDeclaration . type !== 'VariableDeclarator' ) return false
const pipeExpression = variableDeclaration . init
if ( pipeExpression . type !== 'PipeExpression' ) return false
const hasStartProfileAt = pipeExpression . body . some (
( item ) = >
item . type === 'CallExpression' &&
item . callee . name === 'startProfileAt'
)
return hasStartProfileAt && pipeExpression . body . length > 2
} ,
2023-10-11 13:36:54 +11:00
'Can make selection horizontal' : ( { selectionRanges } ) = >
horzVertInfo ( selectionRanges , 'horizontal' ) . enabled ,
'Can make selection vertical' : ( { selectionRanges } ) = >
horzVertInfo ( selectionRanges , 'vertical' ) . enabled ,
'Can constrain horizontal distance' : ( { selectionRanges } ) = >
horzVertDistanceInfo ( { selectionRanges , constraint : 'setHorzDistance' } )
. enabled ,
'Can constrain vertical distance' : ( { selectionRanges } ) = >
horzVertDistanceInfo ( { selectionRanges , constraint : 'setVertDistance' } )
. enabled ,
2023-12-01 20:18:51 +11:00
'Can constrain ABS X' : ( { selectionRanges } ) = >
absDistanceInfo ( { selectionRanges , constraint : 'xAbs' } ) . enabled ,
'Can constrain ABS Y' : ( { selectionRanges } ) = >
absDistanceInfo ( { selectionRanges , constraint : 'yAbs' } ) . enabled ,
2023-10-11 13:36:54 +11:00
'Can constrain angle' : ( { selectionRanges } ) = >
2023-12-01 20:18:51 +11:00
angleBetweenInfo ( { selectionRanges } ) . enabled ||
angleLengthInfo ( { selectionRanges , angleOrLength : 'setAngle' } ) . enabled ,
2023-10-11 13:36:54 +11:00
'Can constrain length' : ( { selectionRanges } ) = >
2023-12-01 20:18:51 +11:00
angleLengthInfo ( { selectionRanges } ) . enabled ,
2023-10-16 08:54:38 +11:00
'Can constrain perpendicular distance' : ( { selectionRanges } ) = >
intersectInfo ( { selectionRanges } ) . enabled ,
2023-10-11 13:36:54 +11:00
'Can constrain horizontally align' : ( { selectionRanges } ) = >
horzVertDistanceInfo ( { selectionRanges , constraint : 'setHorzDistance' } )
. enabled ,
'Can constrain vertically align' : ( { selectionRanges } ) = >
horzVertDistanceInfo ( { selectionRanges , constraint : 'setHorzDistance' } )
. enabled ,
2023-12-01 20:18:51 +11:00
'Can constrain snap to X' : ( { selectionRanges } ) = >
absDistanceInfo ( { selectionRanges , constraint : 'snapToXAxis' } ) . enabled ,
'Can constrain snap to Y' : ( { selectionRanges } ) = >
absDistanceInfo ( { selectionRanges , constraint : 'snapToYAxis' } ) . enabled ,
2023-10-11 13:36:54 +11:00
'Can constrain equal length' : ( { selectionRanges } ) = >
setEqualLengthInfo ( { selectionRanges } ) . enabled ,
2023-10-16 08:54:38 +11:00
'Can canstrain parallel' : ( { selectionRanges } ) = >
equalAngleInfo ( { selectionRanges } ) . enabled ,
'Can constrain remove constraints' : ( { selectionRanges } ) = >
removeConstrainingValuesInfo ( { selectionRanges } ) . enabled ,
2023-10-11 13:36:54 +11:00
} ,
2024-02-11 12:59:00 +11:00
// end guards
2023-10-11 13:36:54 +11:00
actions : {
2023-10-18 08:03:02 +11:00
'set sketchMetadata from pathToNode' : assign ( ( { sketchPathToNode } ) = > {
if ( ! sketchPathToNode ) return { }
return getSketchMetadataFromPathToNode ( sketchPathToNode )
} ) ,
2024-02-17 07:04:24 +11:00
'hide default planes' : ( ) = > {
sceneInfra . removeDefaultPlanes ( )
kclManager . hidePlanes ( )
} ,
2023-10-11 13:36:54 +11:00
'reset sketch metadata' : assign ( {
sketchPathToNode : null ,
sketchEnginePathId : '' ,
sketchPlaneId : '' ,
} ) ,
'set sketch metadata' : assign ( ( { selectionRanges } ) = > {
const sourceRange = selectionRanges . codeBasedSelections [ 0 ] . range
const sketchPathToNode = getNodePathFromSourceRange (
kclManager . ast ,
sourceRange
)
2023-10-18 08:03:02 +11:00
return getSketchMetadataFromPathToNode (
2023-10-11 13:36:54 +11:00
sketchPathToNode ,
2023-10-18 08:03:02 +11:00
selectionRanges
)
2023-10-11 13:36:54 +11:00
} ) ,
2024-02-11 12:59:00 +11:00
'set new sketch metadata' : assign ( ( _ , { data } ) = > data ) ,
2023-10-16 08:54:38 +11:00
// TODO implement source ranges for all of these constraints
// need to make the async like the modal constraints
2024-02-11 12:59:00 +11:00
'Make selection horizontal' : ( { selectionRanges , sketchPathToNode } ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyConstraintHorzVert (
2023-10-11 13:36:54 +11:00
selectionRanges ,
'horizontal' ,
kclManager . ast ,
kclManager . programMemory
)
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . updateAstAndRejigSketch (
2024-02-11 12:59:00 +11:00
sketchPathToNode || [ ] ,
modifiedAst
)
2023-10-11 13:36:54 +11:00
} ,
2024-02-11 12:59:00 +11:00
'Make selection vertical' : ( { selectionRanges , sketchPathToNode } ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyConstraintHorzVert (
2023-10-11 13:36:54 +11:00
selectionRanges ,
'vertical' ,
kclManager . ast ,
kclManager . programMemory
)
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . updateAstAndRejigSketch (
2024-02-11 12:59:00 +11:00
sketchPathToNode || [ ] ,
modifiedAst
)
2023-10-11 13:36:54 +11:00
} ,
2024-02-11 12:59:00 +11:00
'Constrain horizontally align' : ( {
selectionRanges ,
sketchPathToNode ,
} ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyConstraintHorzVertAlign ( {
2023-10-11 13:36:54 +11:00
selectionRanges ,
constraint : 'setVertDistance' ,
} )
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . updateAstAndRejigSketch (
2024-02-11 12:59:00 +11:00
sketchPathToNode || [ ] ,
modifiedAst
)
2023-10-11 13:36:54 +11:00
} ,
2024-02-11 12:59:00 +11:00
'Constrain vertically align' : ( { selectionRanges , sketchPathToNode } ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyConstraintHorzVertAlign ( {
2023-10-11 13:36:54 +11:00
selectionRanges ,
constraint : 'setHorzDistance' ,
} )
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . updateAstAndRejigSketch (
2024-02-11 12:59:00 +11:00
sketchPathToNode || [ ] ,
modifiedAst
)
2023-10-11 13:36:54 +11:00
} ,
2024-02-11 12:59:00 +11:00
'Constrain snap to X' : ( { selectionRanges , sketchPathToNode } ) = > {
2023-12-01 20:18:51 +11:00
const { modifiedAst } = applyConstraintAxisAlign ( {
selectionRanges ,
constraint : 'snapToXAxis' ,
} )
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . updateAstAndRejigSketch (
2024-02-11 12:59:00 +11:00
sketchPathToNode || [ ] ,
modifiedAst
)
2023-12-01 20:18:51 +11:00
} ,
2024-02-11 12:59:00 +11:00
'Constrain snap to Y' : ( { selectionRanges , sketchPathToNode } ) = > {
2023-12-01 20:18:51 +11:00
const { modifiedAst } = applyConstraintAxisAlign ( {
selectionRanges ,
constraint : 'snapToYAxis' ,
} )
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . updateAstAndRejigSketch (
2024-02-11 12:59:00 +11:00
sketchPathToNode || [ ] ,
modifiedAst
)
2023-12-01 20:18:51 +11:00
} ,
2024-02-11 12:59:00 +11:00
'Constrain equal length' : ( { selectionRanges , sketchPathToNode } ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyConstraintEqualLength ( {
2023-10-11 13:36:54 +11:00
selectionRanges ,
} )
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . updateAstAndRejigSketch (
2024-02-11 12:59:00 +11:00
sketchPathToNode || [ ] ,
modifiedAst
)
2023-10-16 08:54:38 +11:00
} ,
2024-02-11 12:59:00 +11:00
'Constrain parallel' : ( { selectionRanges , sketchPathToNode } ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyConstraintEqualAngle ( {
2023-10-16 08:54:38 +11:00
selectionRanges ,
} )
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . updateAstAndRejigSketch (
2024-02-11 12:59:00 +11:00
sketchPathToNode || [ ] ,
modifiedAst
)
2023-10-16 08:54:38 +11:00
} ,
2024-02-11 12:59:00 +11:00
'Constrain remove constraints' : ( {
selectionRanges ,
sketchPathToNode ,
} ) = > {
2023-11-01 07:39:31 -04:00
const { modifiedAst } = applyRemoveConstrainingValues ( {
2023-10-16 08:54:38 +11:00
selectionRanges ,
2023-10-11 13:36:54 +11:00
} )
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . updateAstAndRejigSketch (
2024-02-11 12:59:00 +11:00
sketchPathToNode || [ ] ,
modifiedAst
)
2023-10-11 13:36:54 +11:00
} ,
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
'AST extrude' : ( _ , event ) = > {
if ( ! event . data ) return
const { selection , distance } = event . data
2023-10-11 13:36:54 +11:00
const pathToNode = getNodePathFromSourceRange (
kclManager . ast ,
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
selection . codeBasedSelections [ 0 ] . range
2023-10-11 13:36:54 +11:00
)
const { modifiedAst , pathToExtrudeArg } = extrudeSketch (
kclManager . ast ,
Command bar: add extrude command, nonlinear editing, etc (#1204)
* Tweak toaster look and feel
* Add icons, tweak plus icon names
* Rename commandBarMeta to commandBarConfig
* Refactor command bar, add support for icons
* Create a tailwind plugin for aria-pressed button state
* Remove overlay from behind command bar
* Clean up toolbar
* Button and other style tweaks
* Icon tweaks follow-up: make old icons work with new sizing
* Delete unused static icons
* More CSS tweaks
* Small CSS tweak to project sidebar
* Add command bar E2E test
* fumpt
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* fix typo in a comment
* Fix icon padding (built version only)
* Update onboarding and warning banner icons padding
* Misc minor style fixes
* Get Extrude opening and canceling from command bar
* Iconography tweaks
* Get extrude kind of working
* Refactor command bar config types and organization
* Move command bar configs to be co-located with each other
* Start building a state machine for the command bar
* Start converting command bar to state machine
* Add support for multiple args, confirmation step
* Submission behavior, hotkeys, code organization
* Add new test for extruding from command bar
* Polish step back and selection hotkeys, CSS tweaks
* Loading style tweaks
* Validate selection inputs, polish UX of args re-editing
* Prevent submission with multiple selection on singlular arg
* Remove stray console logs
* Tweak test, CSS nit, remove extrude "result" argument
* Fix linting warnings
* Show Ctrl+/ instead of ⌘K on all platforms but Mac
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)
* Add "Enter sketch" to command bar
* fix command bar test
* Fix flaky cmd bar extrude test by waiting for engine select response
* Cover both button labels '⌘K' and 'Ctrl+/' in test
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 12:49:01 -05:00
pathToNode ,
true ,
distance
2023-10-11 13:36:54 +11:00
)
// TODO not handling focusPath correctly I think
2024-02-11 12:59:00 +11:00
kclManager . updateAst ( modifiedAst , true , {
2023-10-11 13:36:54 +11:00
focusPath : pathToExtrudeArg ,
} )
} ,
2024-02-14 05:35:05 +11:00
'conditionally equip line tool' : ( _ , { type } ) = > {
if ( type === 'done.invoke.animate-to-face' ) {
2024-02-14 08:03:20 +11:00
sceneInfra . modelingSend ( 'Equip Line tool' )
2024-02-14 05:35:05 +11:00
}
} ,
2024-02-11 12:59:00 +11:00
'setup client side sketch segments' : ( { sketchPathToNode } , { type } ) = > {
2024-02-14 08:03:20 +11:00
if ( Object . keys ( sceneEntitiesManager . activeSegments ) . length > 0 ) {
sceneEntitiesManager
. tearDownSketch ( { removeAxis : false } )
. then ( ( ) = > {
sceneEntitiesManager . setupSketch ( {
sketchPathToNode : sketchPathToNode || [ ] ,
} )
2024-02-14 05:35:05 +11:00
} )
} else {
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . setupSketch ( {
2024-02-11 12:59:00 +11:00
sketchPathToNode : sketchPathToNode || [ ] ,
} )
}
} ,
'animate after sketch' : ( ) = > {
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . animateAfterSketch ( )
2024-02-11 12:59:00 +11:00
} ,
2024-02-14 05:35:05 +11:00
'tear down client sketch' : ( ) = > {
2024-02-14 08:03:20 +11:00
if ( sceneEntitiesManager . activeSegments ) {
sceneEntitiesManager . tearDownSketch ( { removeAxis : false } )
2024-02-14 05:35:05 +11:00
}
} ,
2024-02-14 08:03:20 +11:00
'remove sketch grid' : ( ) = > sceneEntitiesManager . removeSketchGrid ( ) ,
2024-02-11 12:59:00 +11:00
'set up draft line' : ( { sketchPathToNode } ) = > {
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . setUpDraftLine ( sketchPathToNode || [ ] )
2024-02-11 12:59:00 +11:00
} ,
'set up draft arc' : ( { sketchPathToNode } ) = > {
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . setUpDraftArc ( sketchPathToNode || [ ] )
2024-02-11 12:59:00 +11:00
} ,
'set up draft line without teardown' : ( { sketchPathToNode } ) = >
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . setupSketch ( {
2024-02-11 12:59:00 +11:00
sketchPathToNode : sketchPathToNode || [ ] ,
draftSegment : 'line' ,
} ) ,
'show default planes' : ( ) = > {
2024-02-14 08:03:20 +11:00
sceneInfra . showDefaultPlanes ( )
sceneEntitiesManager . setupDefaultPlaneHover ( )
2024-02-17 07:04:24 +11:00
kclManager . showPlanes ( )
2024-02-11 12:59:00 +11:00
} ,
'setup noPoints onClick listener' : ( { sketchPathToNode } ) = > {
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . createIntersectionPlane ( )
2024-02-11 12:59:00 +11:00
const sketchGroup = sketchGroupFromPathToNode ( {
pathToNode : sketchPathToNode || [ ] ,
ast : kclManager.ast ,
programMemory : kclManager.programMemory ,
} )
const quaternion = quaternionFromSketchGroup ( sketchGroup )
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . intersectionPlane &&
sceneEntitiesManager . intersectionPlane . setRotationFromQuaternion (
2024-02-11 12:59:00 +11:00
quaternion
)
2024-02-14 08:03:20 +11:00
sceneInfra . setCallbacks ( {
2024-02-11 12:59:00 +11:00
onClick : async ( args ) = > {
if ( ! args ) return
2024-02-19 12:41:36 +11:00
if ( args . event . which !== 1 ) return
2024-02-11 12:59:00 +11:00
const { intersection2d } = args
if ( ! intersection2d || ! sketchPathToNode ) return
const { modifiedAst } = addStartProfileAt (
kclManager . ast ,
sketchPathToNode ,
[ intersection2d . x , intersection2d . y ]
)
await kclManager . updateAst ( modifiedAst , false )
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . removeIntersectionPlane ( )
sceneInfra . modelingSend ( 'Add start point' )
2024-02-11 12:59:00 +11:00
} ,
} )
} ,
'add axis n grid' : ( { sketchPathToNode } ) = >
2024-02-14 08:03:20 +11:00
sceneEntitiesManager . createSketchAxis ( sketchPathToNode || [ ] ) ,
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
} ,
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 ,
}
}