|
|
@ -15,7 +15,8 @@ import { |
|
|
|
updateMeasureData, |
|
|
|
updateTaskState, |
|
|
|
updateMeasureStatus, |
|
|
|
updateMeasureFinish |
|
|
|
updateMeasureFinish, |
|
|
|
updateShowCalibration |
|
|
|
} from '../store/features/measureSlice'; |
|
|
|
import Bridge from '../utils/bridge'; |
|
|
|
import { selectLabeledKtjOrgs, updateRailPoints } from '../store/features/baseData'; |
|
|
@ -40,7 +41,7 @@ export default function Measure() { |
|
|
|
const [railId, setRailId] = useState<(number | string | null)[]>([]); |
|
|
|
const canvasRef = useRef<MeasurementCanvasRef>(null); |
|
|
|
const [railSize, setRailSize] = useState<number | string | null>(); |
|
|
|
const iconWidth = 35; |
|
|
|
const iconWidth = 40; |
|
|
|
const [showStandard, setShowStandard] = useState(false); |
|
|
|
|
|
|
|
// 默认选中第一个轨型
|
|
|
@ -101,9 +102,6 @@ export default function Measure() { |
|
|
|
}, 100); |
|
|
|
canvasRef.current?.setMeasurementCalibrationData(measureState.measureFinishData); |
|
|
|
setShowMeasureFinish(true) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
}, [baseState.railTypes, measureState.measureFinishData, railId]); |
|
|
|
|
|
|
@ -186,15 +184,16 @@ export default function Measure() { |
|
|
|
}; |
|
|
|
|
|
|
|
const [loading, setLoading] = useState(false); |
|
|
|
const [showCalibration, setShowCalibration] = useState(false); |
|
|
|
const [showMeasureFinish, setShowMeasureFinish] = useState(false); |
|
|
|
const onCalibrationBtnClick = () => { |
|
|
|
setLoading(true); |
|
|
|
Bridge.alignPoints({ railSize: railSize || 'GX-60' }) |
|
|
|
.then((res) => { |
|
|
|
if (res.success) { |
|
|
|
setShowCalibration(true); |
|
|
|
// setShowCalibration(true);
|
|
|
|
dispatch(updateShowCalibration(true)) |
|
|
|
canvasRef.current?.setMeasurementCalibrationData(res.data); |
|
|
|
dispatch(updateMeasureFinish(res.data)) |
|
|
|
} else { |
|
|
|
} |
|
|
|
setLoading(false); |
|
|
@ -225,7 +224,8 @@ export default function Measure() { |
|
|
|
|
|
|
|
const onStartClick = () => { |
|
|
|
setMeasurementCanvasKey(measurementCanvasKey+1) |
|
|
|
setShowCalibration(false); |
|
|
|
// setShowCalibration(false);
|
|
|
|
dispatch(updateShowCalibration(false)) |
|
|
|
setShowMeasureFinish(false) |
|
|
|
dispatch(updateMeasureData([])); |
|
|
|
if (!contextState.device.connected) { |
|
|
@ -410,19 +410,22 @@ export default function Measure() { |
|
|
|
} |
|
|
|
|
|
|
|
//上下移动
|
|
|
|
const timerRef = useRef<NodeJS.Timeout | null>(null); |
|
|
|
let timerRef = useRef<any>(null); |
|
|
|
const handlePressStart = (type: string) => { |
|
|
|
console.log('你进行了长按操作!'); |
|
|
|
if (timerRef.current) { |
|
|
|
return |
|
|
|
} |
|
|
|
timerRef.current = setInterval(() => { |
|
|
|
console.log('你进行了长按操作!'); |
|
|
|
console.log('111!'); |
|
|
|
onHandleMove(type); |
|
|
|
}, 500); |
|
|
|
console.log(timerRef.current) |
|
|
|
}; |
|
|
|
|
|
|
|
const handlePressEnd = () => { |
|
|
|
if (timerRef.current) { |
|
|
|
clearInterval(timerRef.current); |
|
|
|
timerRef.current = null; |
|
|
|
} |
|
|
|
timerRef.current = null; |
|
|
|
}; |
|
|
|
|
|
|
|
const onMoveLine = (type: string) => { |
|
|
@ -432,27 +435,25 @@ export default function Measure() { |
|
|
|
|
|
|
|
const onHandleMove = (type: string) => { |
|
|
|
let list = canvasRef.current?.getMeasurementCalibrationData(); |
|
|
|
console.log(list) |
|
|
|
if (list && list.length) { |
|
|
|
list.forEach((item) => { |
|
|
|
const updatedList = list.map((item) => { |
|
|
|
const mutableItem = { ...item }; // 创建副本
|
|
|
|
if (type === 'up') { |
|
|
|
//向上移动,原数据减y X轴不动
|
|
|
|
item.y = item.y - distance / 1000; |
|
|
|
} |
|
|
|
if (type === 'down') { |
|
|
|
//向上移动,原数据加y X轴不动
|
|
|
|
item.y = item.y + distance / 1000; |
|
|
|
} |
|
|
|
if (type === 'left') { |
|
|
|
//向左移动,原数据减x Y轴不动
|
|
|
|
item.x = item.x - distance / 1000; |
|
|
|
} |
|
|
|
if (type === 'right') { |
|
|
|
//向右移动,原数据加x Y轴不动
|
|
|
|
item.x = item.x + distance / 1000; |
|
|
|
mutableItem.y -= distance / 1000; |
|
|
|
} else if (type === 'down') { |
|
|
|
mutableItem.y += distance / 1000; |
|
|
|
} else if (type === 'left') { |
|
|
|
mutableItem.x -= distance / 1000; |
|
|
|
} else if (type === 'right') { |
|
|
|
mutableItem.x += distance / 1000; |
|
|
|
} |
|
|
|
return mutableItem; |
|
|
|
}); |
|
|
|
canvasRef.current?.setMeasurementCalibrationData(list); |
|
|
|
setNewMeasureData(list); |
|
|
|
|
|
|
|
canvasRef.current?.setMeasurementCalibrationData(updatedList); |
|
|
|
dispatch(updateMeasureFinish(list)); |
|
|
|
setNewMeasureData(updatedList); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
@ -479,13 +480,17 @@ export default function Measure() { |
|
|
|
} |
|
|
|
let list = canvasRef.current?.getMeasurementCalibrationData(); |
|
|
|
if (list && list.length) { |
|
|
|
list.forEach((item, index) => { |
|
|
|
let cloneItem = rotatePoint(item, mrValue); |
|
|
|
item.x = cloneItem.x; |
|
|
|
item.y = cloneItem.y; |
|
|
|
const updatedList = list.map((item) => { |
|
|
|
const mutableItem = { ...item }; // 创建副本
|
|
|
|
let cloneItem = rotatePoint(mutableItem, mrValue); |
|
|
|
mutableItem.x = cloneItem.x; |
|
|
|
mutableItem.y = cloneItem.y; |
|
|
|
return mutableItem; |
|
|
|
}); |
|
|
|
canvasRef.current?.setMeasurementCalibrationData(list); |
|
|
|
setNewMeasureData(list); |
|
|
|
|
|
|
|
canvasRef.current?.setMeasurementCalibrationData(updatedList); |
|
|
|
dispatch(updateMeasureFinish(list)); |
|
|
|
setNewMeasureData(updatedList); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
@ -537,7 +542,7 @@ export default function Measure() { |
|
|
|
showScale={false} |
|
|
|
scaleInterval={1} |
|
|
|
showCoordinates={false} |
|
|
|
showCalibration={showCalibration || showMeasureFinish} |
|
|
|
showCalibration={measureState.showCalibration || showMeasureFinish} |
|
|
|
ref={canvasRef} |
|
|
|
key={measurementCanvasKey} |
|
|
|
/> |
|
|
@ -562,7 +567,7 @@ export default function Measure() { |
|
|
|
<span className="text-primary underline">修改</span> |
|
|
|
</section> |
|
|
|
{/**手动校准区 */} |
|
|
|
{showCalibration && ( |
|
|
|
{(measureState.showCalibration && measureState.measureFinishData.length>0) && ( |
|
|
|
<section className="h-10 bg-[#e3e8f5] flex justify-between items-center px-4"> |
|
|
|
<img |
|
|
|
width={iconWidth} |
|
|
|