Circle function and UI tool (#3860)
* circle * fix another example * fix bad comment * toPoint fix * cargo fmt * resolve most of the tests * fix last test * missed circle in bracket * remove console error * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * trigger ci * remove three dot menu for circle * make sure circle can be extruded * fix up after merge * add extrude test for circle * clean up * typo * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest)" This reverts commit03f8eeb542
. * update docs again * cmd bar test serialisation improvements * tiny clean up * fix after: Replace kittycad crate with kittycad-modeling-cmds * fmt * rename fix * Update src/lib/toolbar.ts Co-authored-by: Frank Noirot <frank@zoo.dev> * add another error to list * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * image updates * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)" This reverts commit505bb20bea
. * update markdown * skip un reproducable windows test failure * rust review * leave issue todo comment --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Frank Noirot <frank@zoo.dev>
This commit is contained in:
@ -2,9 +2,11 @@ import { CustomIconName } from 'components/CustomIcon'
|
||||
import { DEV } from 'env'
|
||||
import { commandBarMachine } from 'machines/commandBarMachine'
|
||||
import {
|
||||
canRectangleTool,
|
||||
canRectangleOrCircleTool,
|
||||
isClosedSketch,
|
||||
isEditingExistingSketch,
|
||||
modelingMachine,
|
||||
pipeHasCircle,
|
||||
} from 'machines/modelingMachine'
|
||||
import { EventFrom, StateFrom } from 'xstate'
|
||||
|
||||
@ -308,7 +310,11 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
|
||||
state.matches('Sketch no face') ||
|
||||
state.matches({
|
||||
Sketch: { 'Rectangle tool': 'Awaiting second corner' },
|
||||
}),
|
||||
}) ||
|
||||
state.matches({
|
||||
Sketch: { 'Circle tool': 'Awaiting Radius' },
|
||||
}) ||
|
||||
isClosedSketch(state.context),
|
||||
title: 'Line',
|
||||
hotkey: (state) =>
|
||||
state.matches({ Sketch: 'Line tool' }) ? ['Esc', 'L'] : 'L',
|
||||
@ -331,8 +337,9 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
|
||||
icon: 'arc',
|
||||
status: 'available',
|
||||
disabled: (state) =>
|
||||
!isEditingExistingSketch(state.context) &&
|
||||
!state.matches({ Sketch: 'Tangential arc to' }),
|
||||
(!isEditingExistingSketch(state.context) &&
|
||||
!state.matches({ Sketch: 'Tangential arc to' })) ||
|
||||
pipeHasCircle(state.context),
|
||||
title: 'Tangential Arc',
|
||||
hotkey: (state) =>
|
||||
state.matches({ Sketch: 'Tangential arc to' }) ? ['Esc', 'A'] : 'A',
|
||||
@ -370,10 +377,24 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
|
||||
[
|
||||
{
|
||||
id: 'circle-center',
|
||||
onClick: () => console.error('Center circle not yet implemented'),
|
||||
onClick: ({ modelingState, modelingSend }) =>
|
||||
modelingSend({
|
||||
type: 'change tool',
|
||||
data: {
|
||||
tool: !modelingState.matches({ Sketch: 'Circle tool' })
|
||||
? 'circle'
|
||||
: 'none',
|
||||
},
|
||||
}),
|
||||
icon: 'circle',
|
||||
status: 'unavailable',
|
||||
status: 'available',
|
||||
title: 'Center circle',
|
||||
disabled: (state) =>
|
||||
!canRectangleOrCircleTool(state.context) &&
|
||||
!state.matches({ Sketch: 'Circle tool' }),
|
||||
isActive: (state) => state.matches({ Sketch: 'Circle tool' }),
|
||||
hotkey: (state) =>
|
||||
state.matches({ Sketch: 'Circle tool' }) ? ['Esc', 'C'] : 'C',
|
||||
showTitle: false,
|
||||
description: 'Start drawing a circle from its center',
|
||||
links: [
|
||||
@ -389,7 +410,6 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
|
||||
console.error('Three-point circle not yet implemented'),
|
||||
icon: 'circle',
|
||||
status: 'unavailable',
|
||||
disabled: () => true,
|
||||
title: 'Three-point circle',
|
||||
showTitle: false,
|
||||
description: 'Draw a circle defined by three points',
|
||||
@ -411,7 +431,7 @@ export const toolbarConfig: Record<ToolbarModeName, ToolbarMode> = {
|
||||
icon: 'rectangle',
|
||||
status: 'available',
|
||||
disabled: (state) =>
|
||||
!canRectangleTool(state.context) &&
|
||||
!canRectangleOrCircleTool(state.context) &&
|
||||
!state.matches({ Sketch: 'Rectangle tool' }),
|
||||
title: 'Corner rectangle',
|
||||
hotkey: (state) =>
|
||||
|
Reference in New Issue
Block a user