@wandelbots/wandelbots-js-react-components 1.7.1 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/README.md +30 -16
  2. package/dist/components/3d-viewport/SafetyZonesRenderer.d.ts +1 -1
  3. package/dist/components/3d-viewport/SafetyZonesRenderer.d.ts.map +1 -1
  4. package/dist/components/CopyableText.d.ts +5 -0
  5. package/dist/components/CopyableText.d.ts.map +1 -0
  6. package/dist/components/LoadingButton.d.ts +1 -1
  7. package/dist/components/LoadingButton.stories.d.ts +1 -1
  8. package/dist/components/LoadingButton.stories.d.ts.map +1 -1
  9. package/dist/components/ThemeSelect.d.ts.map +1 -1
  10. package/dist/components/VelocitySlider.d.ts.map +1 -1
  11. package/dist/components/VelocitySlider.stories.d.ts +2 -2
  12. package/dist/components/VelocitySlider.stories.d.ts.map +1 -1
  13. package/dist/components/jogging/JoggingCartesianAxisControl.stories.d.ts +1 -1
  14. package/dist/components/jogging/JoggingCartesianAxisControl.stories.d.ts.map +1 -1
  15. package/dist/components/jogging/JoggingCartesianTab.d.ts.map +1 -1
  16. package/dist/components/jogging/JoggingCartesianValues.d.ts +1 -1
  17. package/dist/components/jogging/JoggingCartesianValues.d.ts.map +1 -1
  18. package/dist/components/jogging/JoggingJointLimitDetector.d.ts +2 -2
  19. package/dist/components/jogging/JoggingJointLimitDetector.d.ts.map +1 -1
  20. package/dist/components/jogging/JoggingJointRotationControl.d.ts.map +1 -1
  21. package/dist/components/jogging/JoggingJointRotationControl.stories.d.ts +2 -2
  22. package/dist/components/jogging/JoggingJointRotationControl.stories.d.ts.map +1 -1
  23. package/dist/components/jogging/JoggingJointValues.d.ts +1 -1
  24. package/dist/components/jogging/JoggingJointValues.d.ts.map +1 -1
  25. package/dist/components/jogging/JoggingOptions.d.ts.map +1 -1
  26. package/dist/components/jogging/JoggingPanel.d.ts +8 -1
  27. package/dist/components/jogging/JoggingPanel.d.ts.map +1 -1
  28. package/dist/components/jogging/JoggingPanel.stories.d.ts +2 -2
  29. package/dist/components/jogging/JoggingPanel.stories.d.ts.map +1 -1
  30. package/dist/components/jogging/JoggingStore.d.ts +14 -1
  31. package/dist/components/jogging/JoggingStore.d.ts.map +1 -1
  32. package/dist/components/jogging/JoggingVelocitySlider.d.ts.map +1 -1
  33. package/dist/components/robots/FANUC_CRX20iAL.d.ts +3 -0
  34. package/dist/components/robots/FANUC_CRX20iAL.d.ts.map +1 -0
  35. package/dist/components/robots/SupportedRobot.d.ts.map +1 -1
  36. package/dist/components/wandelscript-editor/WandelscriptEditor.d.ts +2 -2
  37. package/dist/components/wandelscript-editor/WandelscriptEditor.d.ts.map +1 -1
  38. package/dist/components/wandelscript-editor/WandelscriptEditor.stories.d.ts +2 -2
  39. package/dist/components/wandelscript-editor/WandelscriptEditor.stories.d.ts.map +1 -1
  40. package/dist/externalizeComponent.d.ts +7 -0
  41. package/dist/externalizeComponent.d.ts.map +1 -0
  42. package/dist/index.cjs +29 -48
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.d.ts +49 -9
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +11672 -12089
  47. package/dist/index.js.map +1 -1
  48. package/dist/themes/color.d.ts +1 -1
  49. package/dist/themes/color.d.ts.map +1 -1
  50. package/dist/themes/novaTheme.stories.d.ts +5 -0
  51. package/dist/themes/novaTheme.stories.d.ts.map +1 -0
  52. package/dist/themes/theming.d.ts +49 -0
  53. package/dist/themes/theming.d.ts.map +1 -0
  54. package/package.json +20 -13
  55. package/src/components/3d-viewport/SafetyZonesRenderer.tsx +2 -2
  56. package/src/components/CopyableText.tsx +30 -0
  57. package/src/components/LoadingButton.stories.tsx +19 -26
  58. package/src/components/ThemeSelect.tsx +3 -4
  59. package/src/components/VelocitySlider.stories.tsx +10 -15
  60. package/src/components/VelocitySlider.tsx +7 -2
  61. package/src/components/jogging/JoggingCartesianAxisControl.stories.tsx +21 -21
  62. package/src/components/jogging/JoggingCartesianAxisControl.tsx +1 -1
  63. package/src/components/jogging/JoggingCartesianTab.tsx +37 -44
  64. package/src/components/jogging/JoggingCartesianValues.tsx +37 -33
  65. package/src/components/jogging/JoggingJointLimitDetector.tsx +10 -7
  66. package/src/components/jogging/JoggingJointRotationControl.stories.tsx +31 -19
  67. package/src/components/jogging/JoggingJointRotationControl.tsx +44 -30
  68. package/src/components/jogging/JoggingJointValues.tsx +35 -33
  69. package/src/components/jogging/JoggingOptions.tsx +130 -80
  70. package/src/components/jogging/JoggingPanel.stories.tsx +20 -17
  71. package/src/components/jogging/JoggingPanel.tsx +29 -31
  72. package/src/components/jogging/JoggingStore.tsx +69 -18
  73. package/src/components/jogging/JoggingVelocitySlider.tsx +24 -22
  74. package/src/components/robots/FANUC_CRX20iAL.tsx +176 -0
  75. package/src/components/robots/SupportedRobot.tsx +4 -0
  76. package/src/components/wandelscript-editor/WandelscriptEditor.stories.tsx +7 -7
  77. package/src/components/wandelscript-editor/WandelscriptEditor.tsx +48 -23
  78. package/src/externalizeComponent.tsx +37 -0
  79. package/src/i18n/locales/de/translations.json +2 -1
  80. package/src/i18n/locales/en/translations.json +2 -1
  81. package/src/icons/orientation-coord-system.svg +3 -0
  82. package/src/icons/orientation-tool.svg +3 -0
  83. package/src/index.ts +39 -9
  84. package/src/themes/color.tsx +29 -19
  85. package/src/themes/novaTheme.stories.tsx +77 -0
  86. package/src/themes/themeTypes.d.ts +11 -0
  87. package/src/themes/theming.ts +174 -0
  88. package/dist/themes/theme.d.ts +0 -144
  89. package/dist/themes/theme.d.ts.map +0 -1
  90. package/dist/themes/wbTheme.d.ts +0 -73
  91. package/dist/themes/wbTheme.d.ts.map +0 -1
  92. package/dist/themes/wbTheme.stories.d.ts +0 -7
  93. package/dist/themes/wbTheme.stories.d.ts.map +0 -1
  94. package/src/themes/theme.ts +0 -150
  95. package/src/themes/wbTheme.stories.tsx +0 -64
  96. package/src/themes/wbTheme.ts +0 -186
@@ -1,45 +1,49 @@
1
1
  import { observer } from "mobx-react-lite"
2
- import { Stack, Typography } from "@mui/material"
2
+ import { Stack } from "@mui/material"
3
3
  import { useRef } from "react"
4
4
  import { poseToWandelscriptString } from "@wandelbots/wandelbots-js"
5
5
  import { useAnimationFrame } from "../utils/hooks"
6
- import { JoggingStore } from "./JoggingStore"
6
+ import type { JoggingStore } from "./JoggingStore"
7
+ import { CopyableText } from "../CopyableText"
7
8
 
8
- export const JoggingCartesianValues = observer(({ store }: { store: JoggingStore }) => {
9
- const poseStringRef = useRef<HTMLPreElement>(null)
9
+ export const JoggingCartesianValues = observer(
10
+ ({ store }: { store: JoggingStore }) => {
11
+ const poseHolderRef = useRef<HTMLPreElement>(null)
10
12
 
11
- function getCurrentPoseString() {
12
- const tcpPose = store.jogger.motionStream.rapidlyChangingMotionState.tcp_pose
13
- if (!tcpPose) return ""
14
- return poseToWandelscriptString(tcpPose)
15
- }
16
-
17
- useAnimationFrame(() => {
18
- if (!poseStringRef.current) {
19
- return
13
+ function getCurrentPoseString() {
14
+ const tcpPose =
15
+ store.jogger.motionStream.rapidlyChangingMotionState.tcp_pose
16
+ if (!tcpPose) return ""
17
+ return poseToWandelscriptString(tcpPose)
20
18
  }
21
19
 
22
- poseStringRef.current.textContent = getCurrentPoseString()
23
- })
20
+ useAnimationFrame(() => {
21
+ if (!poseHolderRef.current) {
22
+ return
23
+ }
24
+
25
+ poseHolderRef.current.textContent = getCurrentPoseString()
26
+ })
24
27
 
25
- return (
26
- <Stack alignItems="center" marginTop="0.8rem">
27
- <Typography
28
+ return (
29
+ <Stack
30
+ alignItems="left"
31
+ spacing={2}
28
32
  sx={{
29
- fontSize: "12px",
30
- marginTop: "0.8rem",
33
+ padding: "16px",
34
+ "& label": {
35
+ opacity: 0.7,
36
+ fontSize: "12px",
37
+ marginBottom: "4px",
38
+ },
31
39
  }}
32
40
  >
33
- {store.selectedTcpId} - {store.selectedCoordSystem?.name}
34
- </Typography>
35
- <Typography
36
- component="pre"
37
- ref={poseStringRef}
38
- sx={{
39
- fontSize: "14px",
40
- opacity: 0.6,
41
- }}
42
- ></Typography>
43
- </Stack>
44
- )
45
- })
41
+ <CopyableText
42
+ label={"Pose"}
43
+ value={getCurrentPoseString()}
44
+ ref={poseHolderRef}
45
+ />
46
+ </Stack>
47
+ )
48
+ },
49
+ )
@@ -2,26 +2,29 @@ import { Typography } from "@mui/material"
2
2
  import { useTranslation } from "react-i18next"
3
3
  import { useState } from "react"
4
4
  import { isEqual } from "lodash-es"
5
- import { MotionStreamConnection } from "@wandelbots/wandelbots-js"
6
5
  import { useAnimationFrame } from "../utils/hooks"
7
- import { JoggingStore } from "./JoggingStore"
6
+ import type { JoggingStore } from "./JoggingStore"
8
7
 
9
8
  /**
10
9
  * Monitors the active robot motion state and displays a message if
11
10
  * any joint limits are reached.
12
11
  */
13
- export const JoggingJointLimitDetector = ({ store }: { store: JoggingStore }) => {
12
+ export const JoggingJointLimitDetector = ({
13
+ store,
14
+ }: {
15
+ store: JoggingStore
16
+ }) => {
14
17
  const { t } = useTranslation()
15
18
 
16
19
  const [jointLimitsReached, setJointLimitsReached] = useState(
17
- store.jogger.motionStream.rapidlyChangingMotionState.state.joint_limit_reached
18
- .limit_reached,
20
+ store.jogger.motionStream.rapidlyChangingMotionState.state
21
+ .joint_limit_reached.limit_reached,
19
22
  )
20
23
 
21
24
  useAnimationFrame(() => {
22
25
  const newLimitsReached =
23
- store.jogger.motionStream.rapidlyChangingMotionState.state.joint_limit_reached
24
- .limit_reached
26
+ store.jogger.motionStream.rapidlyChangingMotionState.state
27
+ .joint_limit_reached.limit_reached
25
28
 
26
29
  if (!isEqual(jointLimitsReached, newLimitsReached)) {
27
30
  setJointLimitsReached(newLimitsReached)
@@ -1,7 +1,7 @@
1
- import { Meta, StoryObj } from "@storybook/react";
2
- import { JoggingJointRotationControl } from "./JoggingJointRotationControl";
3
- import { useRef } from "react";
4
- import { useAnimationFrame } from "../utils/hooks";
1
+ import type { Meta, StoryObj } from "@storybook/react"
2
+ import { JoggingJointRotationControl } from "../../index"
3
+ import { useRef } from "react"
4
+ import { useAnimationFrame } from "../utils/hooks"
5
5
 
6
6
  const meta: Meta<typeof JoggingJointRotationControl> = {
7
7
  component: JoggingJointRotationControl,
@@ -12,27 +12,39 @@ const meta: Meta<typeof JoggingJointRotationControl> = {
12
12
  disabled: false,
13
13
  },
14
14
  render: function Component(args) {
15
- const joggingDirRef = useRef<"+" | "-" | null>(null);
16
- const joggingValueRef = useRef(0);
15
+ const joggingDirRef = useRef<"+" | "-" | null>(null)
16
+ const joggingValueRef = useRef(0)
17
17
 
18
18
  useAnimationFrame(() => {
19
19
  if (joggingDirRef.current === "+") {
20
- joggingValueRef.current += 1;
20
+ joggingValueRef.current += 1
21
+ if (args.upperLimitDegs != null) {
22
+ joggingValueRef.current = Math.min(
23
+ joggingValueRef.current,
24
+ args.upperLimitDegs,
25
+ )
26
+ }
21
27
  } else if (joggingDirRef.current === "-") {
22
- joggingValueRef.current -= 1;
28
+ joggingValueRef.current -= 1
29
+ if (args.lowerLimitDegs != null) {
30
+ joggingValueRef.current = Math.max(
31
+ joggingValueRef.current,
32
+ args.lowerLimitDegs,
33
+ )
34
+ }
23
35
  }
24
36
  })
25
37
 
26
- return <JoggingJointRotationControl
27
- {...args}
28
- startJogging={(direction) => joggingDirRef.current = direction}
29
- stopJogging={() => joggingDirRef.current = null}
30
- getValueDegs={() => joggingValueRef.current}
31
- />;
38
+ return (
39
+ <JoggingJointRotationControl
40
+ {...args}
41
+ startJogging={(direction) => (joggingDirRef.current = direction)}
42
+ stopJogging={() => (joggingDirRef.current = null)}
43
+ getValueDegs={() => joggingValueRef.current}
44
+ />
45
+ )
32
46
  },
47
+ }
48
+ export default meta
33
49
 
34
- };
35
- export default meta;
36
-
37
- export const Default: StoryObj<typeof JoggingJointRotationControl> = {
38
- };
50
+ export const Default: StoryObj<typeof JoggingJointRotationControl> = {}
@@ -1,18 +1,18 @@
1
- import { IconButton, Slider, Typography } from "@mui/material"
1
+ import { IconButton, Slider, Typography, useTheme } from "@mui/material"
2
2
  import Stack from "@mui/material/Stack"
3
3
  import { observer, useLocalObservable } from "mobx-react-lite"
4
- import { I18nextProvider, useTranslation } from "react-i18next"
5
4
  import { ChevronLeft, ChevronRight } from "@mui/icons-material"
6
5
  import { useAnimationFrame } from "../utils/hooks"
7
6
  import { useState } from "react"
8
- import i18n from '../../i18n/config';
7
+ import { throttle } from "lodash-es"
8
+ import { useTranslation } from "react-i18next"
9
9
 
10
10
  type JoggingJointRotationControlProps = {
11
11
  startJogging: (direction: "-" | "+") => void
12
12
  stopJogging: () => void
13
13
  lowerLimitDegs?: number
14
14
  upperLimitDegs?: number
15
- getValueDegs: () => number|undefined
15
+ getValueDegs: () => number | undefined
16
16
 
17
17
  disabled?: boolean
18
18
  } & React.ComponentProps<typeof Stack>
@@ -28,7 +28,7 @@ export const JoggingJointRotationControl = observer(
28
28
  ...rest
29
29
  }: JoggingJointRotationControlProps) => {
30
30
  const { t } = useTranslation()
31
- const [currentValue, setCurrentValue] = useState<number|undefined>()
31
+ const [currentValue, setCurrentValue] = useState<number | undefined>()
32
32
 
33
33
  const state = useLocalObservable(() => ({
34
34
  activeJoggingDir: null as "-" | "+" | null,
@@ -44,9 +44,11 @@ export const JoggingJointRotationControl = observer(
44
44
  },
45
45
  }))
46
46
 
47
- useAnimationFrame(() => {
47
+ const updateValue = throttle(() => {
48
48
  setCurrentValue(getValueDegs())
49
- })
49
+ }, 50)
50
+
51
+ useAnimationFrame(updateValue)
50
52
 
51
53
  function onPointerDownMinus(ev: React.PointerEvent) {
52
54
  // Stop right click from triggering jog
@@ -57,6 +59,17 @@ export const JoggingJointRotationControl = observer(
57
59
  if (ev.button === 0) state.startJogging("+")
58
60
  }
59
61
 
62
+ function onPointerUp(ev: React.PointerEvent) {
63
+ state.stopJogging()
64
+ }
65
+
66
+ function onPointerOut(ev: React.PointerEvent) {
67
+ // Prevent subelements of button from stopping jogging
68
+ if (ev.target !== ev.currentTarget) return
69
+
70
+ state.stopJogging()
71
+ }
72
+
60
73
  function formatDegrees(value: number | undefined, precision = 1) {
61
74
  if (value === undefined || isNaN(value)) return ""
62
75
 
@@ -72,30 +85,38 @@ export const JoggingJointRotationControl = observer(
72
85
  }
73
86
 
74
87
  return (
75
- <I18nextProvider i18n={i18n}>
76
88
  <Stack
77
89
  height="64px"
78
90
  width="100%"
79
91
  maxWidth="300px"
80
92
  direction="row"
81
93
  {...rest}
82
- >
83
- <IconButton
84
- onPointerDown={onPointerDownMinus}
85
- onPointerUp={state.stopJogging}
86
- onPointerOut={state.stopJogging}
87
- disabled={disabled}
88
- sx={{
94
+ sx={{
95
+ "& .MuiIconButton-root": {
89
96
  width: "52px",
90
97
  color: "white",
91
98
  alignContent: "center",
92
- borderRadius: "16px 0px 0px 16px",
93
- backgroundColor:
94
- state.activeJoggingDir === "-" ? "#495975 !important" : "#38445A",
99
+ backgroundColor: "#38445A",
100
+ "&:disabled": {
101
+ opacity: 0.5,
102
+ backgroundColor: "#38445A",
103
+ },
95
104
  "& svg": {
96
105
  width: "42px",
97
106
  height: "42px",
98
107
  },
108
+ },
109
+ }}
110
+ >
111
+ <IconButton
112
+ onPointerDown={onPointerDownMinus}
113
+ onPointerUp={onPointerUp}
114
+ onPointerOut={onPointerOut}
115
+ disabled={disabled}
116
+ sx={{
117
+ borderRadius: "16px 0px 0px 16px",
118
+ backgroundColor:
119
+ state.activeJoggingDir === "-" ? "#495975" : undefined,
99
120
  }}
100
121
  >
101
122
  <ChevronLeft />
@@ -123,6 +144,7 @@ export const JoggingJointRotationControl = observer(
123
144
  fontSize: "15px",
124
145
  position: "relative",
125
146
  top: "5px",
147
+ color: "white",
126
148
  }}
127
149
  >
128
150
  {formatDegrees(currentValue)}
@@ -133,7 +155,7 @@ export const JoggingJointRotationControl = observer(
133
155
  aria-label="Joint position"
134
156
  min={lowerLimitDegs}
135
157
  max={upperLimitDegs}
136
- value={currentValue}
158
+ value={currentValue || 0}
137
159
  track={false}
138
160
  sx={{
139
161
  "& .MuiSlider-mark": {
@@ -147,6 +169,7 @@ export const JoggingJointRotationControl = observer(
147
169
  "& .MuiSlider-markLabel": {
148
170
  top: "20px",
149
171
  fontSize: "12px",
172
+ color: "white",
150
173
  },
151
174
  "& .MuiSlider-rail": {
152
175
  backgroundColor: "#1F283A",
@@ -171,27 +194,18 @@ export const JoggingJointRotationControl = observer(
171
194
 
172
195
  <IconButton
173
196
  onPointerDown={onPointerDownPlus}
174
- onPointerUp={state.stopJogging}
175
- onPointerOut={state.stopJogging}
197
+ onPointerUp={onPointerUp}
198
+ onPointerOut={onPointerOut}
176
199
  disabled={disabled}
177
200
  sx={{
178
- width: "52px",
179
- color: "white",
180
- alignContent: "center",
181
- fontSize: "37px",
182
201
  borderRadius: "0px 16px 16px 0px",
183
202
  backgroundColor:
184
203
  state.activeJoggingDir === "+" ? "#495975 !important" : "#38445A",
185
- "& svg": {
186
- width: "42px",
187
- height: "42px",
188
- },
189
204
  }}
190
205
  >
191
206
  <ChevronRight />
192
207
  </IconButton>
193
208
  </Stack>
194
- </I18nextProvider>
195
209
  )
196
210
  },
197
211
  )
@@ -2,44 +2,46 @@ import { observer } from "mobx-react-lite"
2
2
  import { Stack, Typography } from "@mui/material"
3
3
  import { useRef } from "react"
4
4
  import { useTranslation } from "react-i18next"
5
- import { JoggingStore } from "./JoggingStore"
5
+ import type { JoggingStore } from "./JoggingStore"
6
6
  import { useAnimationFrame } from "../utils/hooks"
7
+ import { CopyableText } from "../CopyableText"
7
8
 
8
- export const JoggingJointValues = observer(({ store }: { store: JoggingStore }) => {
9
- const valueHolderRef = useRef<HTMLPreElement>(null)
10
- const { t } = useTranslation()
9
+ export const JoggingJointValues = observer(
10
+ ({ store }: { store: JoggingStore }) => {
11
+ const poseHolderRef = useRef<HTMLPreElement>(null)
12
+ const { t } = useTranslation()
11
13
 
12
- function getCurrentValueString() {
13
- const { joints } =
14
- store.jogger.motionStream.rapidlyChangingMotionState.state.joint_position
15
- return `{${joints.map((j) => parseFloat(j.toFixed(4))).join(", ")}}`
16
- }
14
+ function getCurrentPoseString() {
15
+ const { joints } =
16
+ store.jogger.motionStream.rapidlyChangingMotionState.state
17
+ .joint_position
18
+ return `{${joints.map((j) => parseFloat(j.toFixed(4))).join(", ")}}`
19
+ }
17
20
 
18
- useAnimationFrame(() => {
19
- if (!valueHolderRef.current) return
20
- valueHolderRef.current.textContent = getCurrentValueString()
21
- })
21
+ useAnimationFrame(() => {
22
+ if (!poseHolderRef.current) return
23
+ poseHolderRef.current.textContent = getCurrentPoseString()
24
+ })
22
25
 
23
- return (
24
- <Stack alignItems="center" marginTop="0.8rem">
25
- <Typography
26
+ return (
27
+ <Stack
28
+ alignItems="left"
29
+ spacing={2}
26
30
  sx={{
27
- fontSize: "12px",
28
- marginTop: "0.8rem",
31
+ padding: "16px",
32
+ "& label": {
33
+ opacity: 0.7,
34
+ fontSize: "12px",
35
+ marginBottom: "4px",
36
+ },
29
37
  }}
30
38
  >
31
- {t("Jogging.Joints.JointValues.lb")}
32
- </Typography>
33
- <Typography
34
- component="pre"
35
- ref={valueHolderRef}
36
- sx={{
37
- fontSize: "14px",
38
- opacity: 0.6,
39
- }}
40
- >
41
- {getCurrentValueString()}
42
- </Typography>
43
- </Stack>
44
- )
45
- })
39
+ <CopyableText
40
+ label={"Pose"}
41
+ value={getCurrentPoseString()}
42
+ ref={poseHolderRef}
43
+ />
44
+ </Stack>
45
+ )
46
+ },
47
+ )
@@ -1,96 +1,146 @@
1
- import { Stack, MenuItem, InputLabel, Select } from "@mui/material"
1
+ import {
2
+ Stack,
3
+ MenuItem,
4
+ InputLabel,
5
+ Select,
6
+ ToggleButtonGroup,
7
+ ToggleButton,
8
+ } from "@mui/material"
2
9
  import { observer } from "mobx-react-lite"
3
10
  import type { IncrementOptionId, JoggingStore } from "./JoggingStore"
4
11
  import { useTranslation } from "react-i18next"
5
- import { useThemeColors } from "../../themes/wbTheme"
6
- import { ThemeSelect } from "../ThemeSelect"
12
+ import OrientationCoordSysIcon from "../../icons/orientation-coord-system.svg"
13
+ import OrientationToolIcon from "../../icons/orientation-tool.svg"
7
14
 
8
15
  export const JoggingOptions = observer(({ store }: { store: JoggingStore }) => {
9
16
  const { t } = useTranslation()
10
- const colors = useThemeColors()
17
+
18
+ function onOrientationChange(
19
+ _event: React.MouseEvent<HTMLElement>,
20
+ newOrientation: string,
21
+ ) {
22
+ if (newOrientation === "coordsys" || newOrientation === "tool")
23
+ store.setSelectedOrientation(newOrientation)
24
+ }
11
25
 
12
26
  return (
13
- <Stack
14
- direction={"row"}
15
- alignItems={"center"}
16
- spacing={1}
17
- sx={{
18
- padding: "16px",
19
- "& label": {
20
- color: colors.textSubtle,
21
- fontSize: "12px",
22
- marginBottom: "4px",
23
- },
24
- }}
25
- >
26
- {/* Coordinate system */}
27
- <Stack width="33%">
28
- <InputLabel id="jogging-coord-select">{"Coordinate Sys."}</InputLabel>
29
- <ThemeSelect
30
- kind="filled"
31
- labelId="jogging-coord-select"
32
- value={store.selectedCoordSystemId}
33
- displayEmpty={true}
34
- onChange={(event) => {
35
- store.setSelectedCoordSystemId(event.target.value as string)
36
- }}
37
- disabled={store.isLocked}
38
- >
39
- {store.coordSystems.map((cs) => (
40
- <MenuItem key={cs.coordinate_system} value={cs.coordinate_system}>
41
- {cs.name || cs.coordinate_system}
42
- </MenuItem>
43
- ))}
44
- </ThemeSelect>
45
- </Stack>
27
+ <>
28
+ <Stack
29
+ direction={"row"}
30
+ alignItems={"center"}
31
+ spacing={2}
32
+ sx={{
33
+ padding: "16px",
34
+ paddingTop: "8px",
35
+ "& label": {
36
+ opacity: 0.7,
37
+ fontSize: "12px",
38
+ marginBottom: "4px",
39
+ },
40
+ }}
41
+ >
42
+ {/* Coordinate system */}
43
+ <Stack width="50%">
44
+ <InputLabel id="jogging-coord-select">{"Coordinate Sys."}</InputLabel>
45
+ <Select
46
+ labelId="jogging-coord-select"
47
+ value={store.selectedCoordSystemId}
48
+ displayEmpty={true}
49
+ onChange={(event) => {
50
+ store.setSelectedCoordSystemId(event.target.value as string)
51
+ }}
52
+ disabled={store.isLocked}
53
+ >
54
+ {store.coordSystems.map((cs) => (
55
+ <MenuItem key={cs.coordinate_system} value={cs.coordinate_system}>
56
+ {cs.name || cs.coordinate_system}
57
+ </MenuItem>
58
+ ))}
59
+ </Select>
60
+ </Stack>
46
61
 
47
- {/* TCP selection */}
48
- <Stack width="33%">
49
- <InputLabel id="jogging-tcp-select">TCP</InputLabel>
50
- <ThemeSelect
51
- kind="filled"
52
- labelId="jogging-tcp-select"
53
- value={store.selectedTcpId}
54
- onChange={(event) => {
55
- store.setSelectedTcpId(event.target.value as string)
56
- }}
57
- disabled={store.isLocked}
58
- >
59
- {store.tcps.map((tcp) => (
60
- <MenuItem key={tcp.id} value={tcp.id}>
61
- {tcp.id}
62
- </MenuItem>
63
- ))}
64
- </ThemeSelect>
62
+ {/* TCP selection */}
63
+ <Stack width="50%">
64
+ <InputLabel id="jogging-tcp-select">TCP</InputLabel>
65
+ <Select
66
+ labelId="jogging-tcp-select"
67
+ value={store.selectedTcpId}
68
+ onChange={(event) => {
69
+ store.setSelectedTcpId(event.target.value as string)
70
+ }}
71
+ disabled={store.isLocked}
72
+ >
73
+ {store.tcps.map((tcp) => (
74
+ <MenuItem key={tcp.id} value={tcp.id}>
75
+ {tcp.id}
76
+ </MenuItem>
77
+ ))}
78
+ </Select>
79
+ </Stack>
65
80
  </Stack>
66
81
 
67
- {/* Increment selection */}
68
- <Stack width="33%">
69
- <InputLabel id="jogging-increment-select">{"Increment"}</InputLabel>
70
- <ThemeSelect
71
- kind="filled"
72
- labelId="jogging-increment-select"
73
- value={store.selectedIncrementId}
74
- onChange={(event) => {
75
- store.setSelectedIncrementId(
76
- event.target.value as IncrementOptionId,
77
- )
78
- }}
79
- disabled={store.isLocked}
80
- >
81
- <MenuItem key="continuous" value="continuous">
82
- {t("Jogging.Increment.Continuous.dd")}
83
- </MenuItem>
82
+ <Stack
83
+ direction={"row"}
84
+ alignItems={"center"}
85
+ spacing={2}
86
+ sx={{
87
+ padding: "16px",
88
+ paddingTop: "8px",
89
+ "& label": {
90
+ opacity: 0.7,
91
+ fontSize: "12px",
92
+ marginBottom: "4px",
93
+ },
94
+ }}
95
+ >
96
+ {/* Orientation */}
97
+ <Stack width="35%">
98
+ <InputLabel id="orientation-select">
99
+ {t("Jogging.Cartesian.Orientation.lb")}
100
+ </InputLabel>
101
+ <ToggleButtonGroup
102
+ value={store.selectedOrientation}
103
+ onChange={onOrientationChange}
104
+ exclusive
105
+ aria-labelledby="orientation-select"
106
+ disabled={store.isLocked}
107
+ >
108
+ <ToggleButton value="coordsys">
109
+ <OrientationCoordSysIcon />
110
+ </ToggleButton>
111
+ <ToggleButton value="tool">
112
+ <OrientationToolIcon />
113
+ </ToggleButton>
114
+ </ToggleButtonGroup>
115
+ </Stack>
84
116
 
85
- {store.discreteIncrementOptions.map((inc) => (
86
- <MenuItem key={inc.id} value={inc.id}>
87
- {store.currentMotionType === "translate"
88
- ? `${inc.mm}mm`
89
- : `${inc.degrees}°`}
117
+ {/* Increment selection */}
118
+ <Stack width="65%">
119
+ <InputLabel id="jogging-increment-select">{"Increment"}</InputLabel>
120
+ <Select
121
+ labelId="jogging-increment-select"
122
+ value={store.selectedIncrementId}
123
+ onChange={(event) => {
124
+ store.setSelectedIncrementId(
125
+ event.target.value as IncrementOptionId,
126
+ )
127
+ }}
128
+ disabled={store.isLocked}
129
+ >
130
+ <MenuItem key="continuous" value="continuous">
131
+ {t("Jogging.Increment.Continuous.dd")}
90
132
  </MenuItem>
91
- ))}
92
- </ThemeSelect>
133
+
134
+ {store.discreteIncrementOptions.map((inc) => (
135
+ <MenuItem key={inc.id} value={inc.id}>
136
+ {store.currentMotionType === "translate"
137
+ ? `${inc.mm}mm`
138
+ : `${inc.degrees}°`}
139
+ </MenuItem>
140
+ ))}
141
+ </Select>
142
+ </Stack>
93
143
  </Stack>
94
- </Stack>
144
+ </>
95
145
  )
96
146
  })