#
luxiaotao1123
2024-10-09 ec5a22c126ea778b8baea29a078dabb05184b65a
#
2个文件已修改
1个文件已添加
104 ■■■■ 已修改文件
zy-acs-flow/src/map/Device.jsx 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-flow/src/map/MapPage.jsx 83 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-flow/src/map/tool.js 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-flow/src/map/Device.jsx
New file
@@ -0,0 +1,12 @@
const Device = () => {
    return (
        <>
        </>
    )
}
export default Device;
zy-acs-flow/src/map/MapPage.jsx
@@ -21,20 +21,23 @@
import Player from './player';
import * as Tool from './tool';
import { NotificationProvider, useNotification } from './Notification';
import Device from "./Device";
let player;
const Map = () => {
    const theme = useTheme();
    const themeMode = theme.palette.mode;
    const notify = useNotification();
    const mapRef = useRef();
    const contentRef = useRef();
    const [app, setApp] = useState(null);
    const [mapContainer, setMapContainer] = useState(null);
    const notify = useNotification();
    const [mode, setMode] = useState(MapMode.OBSERVER_MODE);
    const [deviceVisible, setDeviceVisible] = React.useState(false);
    const theme = useTheme();
    const themeMode = theme.palette.mode;
    useEffect(() => {
        Tool.patchRaLayout('0px');
@@ -90,6 +93,16 @@
        switchMode(mode);
    }, [mode]);
    const onDrop = (sprite, type, x, y) => {
        const { mapX, mapY } = Tool.getRealPosition(x, y);
        sprite.x = mapX;
        sprite.y = mapY;
        // Utils.initSprite(sprite, type);
        // mapContainer.addChild(sprite);
        // Utils.beMovable(sprite);
    };
    const actions = [
        { icon: <FileCopyIcon />, name: '复制' },
        { icon: <SaveIcon />, name: '保存' },
@@ -128,23 +141,9 @@
                    }}
                />
                <Box sx={{ flexGrow: 1 }} />
                <Select
                    value={mode}
                    onChange={(event) => {
                        setMode(event.target.value);
                    }}
                    variant="outlined"
                    size="small"
                    sx={{
                        mr: 2,
                        backgroundColor: '#fff',
                        borderRadius: 1,
                    }}
                >
                    <MenuItem value={MapMode.OBSERVER_MODE}>监控模式</MenuItem>
                    <MenuItem value={MapMode.MOVABLE_MODE}>编辑模式</MenuItem>
                    <MenuItem value={MapMode.SETTINGS_MODE}>配置模式</MenuItem>
                </Select>
                {mode === MapMode.OBSERVER_MODE && (
                    <>
                <Button
                    variant="contained"
                    color="primary"
@@ -155,6 +154,43 @@
                <Button variant="contained" color="secondary">
                    模拟AGV运行
                </Button>
                    </>
                )}
                {mode === MapMode.MOVABLE_MODE && (
                    <>
                        <Button
                            variant="contained"
                            color="primary"
                            sx={{ mr: 1 }}
                        >
                            添加模型
                        </Button>
                    </>
                )}
                {mode === MapMode.SETTINGS_MODE && (
                    <>
                    </>
                )}
                <Select
                    value={mode}
                    onChange={(event) => {
                        setMode(event.target.value);
                    }}
                    variant="outlined"
                    size="small"
                    sx={{
                        ml: 2,
                        backgroundColor: '#fff',
                        borderRadius: 1,
                    }}
                >
                    <MenuItem value={MapMode.OBSERVER_MODE}>监控模式</MenuItem>
                    <MenuItem value={MapMode.MOVABLE_MODE}>编辑模式</MenuItem>
                    <MenuItem value={MapMode.SETTINGS_MODE}>配置模式</MenuItem>
                </Select>
            </Box>
            <Box
                sx={{
@@ -196,6 +232,13 @@
                    ))}
                </SpeedDial>
            </Box>
            <Device
                open={deviceVisible}
                onCancel={() => {
                    setDeviceVisible(false);
                }}
                onDrop={onDrop}
            />
        </Box>
    );
}
zy-acs-flow/src/map/tool.js
@@ -19,6 +19,15 @@
    return mapContainer;
}
export const getRealPosition = (x, y) => {
    const rect = app.view.getBoundingClientRect();
    return {
        mapX: (x - rect.left) / mapContainer.scale.x - mapContainer.x / mapContainer.scale.x,
        mapY: (y - rect.top) / mapContainer.scale.y - mapContainer.y / mapContainer.scale.y
    }
}
export const patchRaLayout = (param) => {
    const parentElement = document.getElementById('main-content');
    if (parentElement && parentElement.classList.contains('RaLayout-content')) {