| | |
| | | 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'); |
| | |
| | | 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: '保存' }, |
| | |
| | | }} |
| | | /> |
| | | <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" |
| | |
| | | <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={{ |
| | |
| | | ))} |
| | | </SpeedDial> |
| | | </Box> |
| | | <Device |
| | | open={deviceVisible} |
| | | onCancel={() => { |
| | | setDeviceVisible(false); |
| | | }} |
| | | onDrop={onDrop} |
| | | /> |
| | | </Box> |
| | | ); |
| | | } |