From ec5a22c126ea778b8baea29a078dabb05184b65a Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 09 十月 2024 10:57:29 +0800
Subject: [PATCH] #
---
zy-acs-flow/src/map/tool.js | 9 ++++
zy-acs-flow/src/map/MapPage.jsx | 71 ++++++++++++++++++++++++++++-------
zy-acs-flow/src/map/Device.jsx | 12 ++++++
3 files changed, 78 insertions(+), 14 deletions(-)
diff --git a/zy-acs-flow/src/map/Device.jsx b/zy-acs-flow/src/map/Device.jsx
new file mode 100644
index 0000000..e65cf4e
--- /dev/null
+++ b/zy-acs-flow/src/map/Device.jsx
@@ -0,0 +1,12 @@
+
+
+const Device = () => {
+
+ return (
+ <>
+
+ </>
+ )
+}
+
+export default Device;
\ No newline at end of file
diff --git a/zy-acs-flow/src/map/MapPage.jsx b/zy-acs-flow/src/map/MapPage.jsx
index decde65..b205b29 100644
--- a/zy-acs-flow/src/map/MapPage.jsx
+++ b/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,6 +141,39 @@
}}
/>
<Box sx={{ flexGrow: 1 }} />
+
+ {mode === MapMode.OBSERVER_MODE && (
+ <>
+ <Button
+ variant="contained"
+ color="primary"
+ sx={{ mr: 1 }}
+ >
+ 鍋滄RCS杩愯浆
+ </Button>
+ <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) => {
@@ -136,7 +182,7 @@
variant="outlined"
size="small"
sx={{
- mr: 2,
+ ml: 2,
backgroundColor: '#fff',
borderRadius: 1,
}}
@@ -145,16 +191,6 @@
<MenuItem value={MapMode.MOVABLE_MODE}>缂栬緫妯″紡</MenuItem>
<MenuItem value={MapMode.SETTINGS_MODE}>閰嶇疆妯″紡</MenuItem>
</Select>
- <Button
- variant="contained"
- color="primary"
- sx={{ mr: 1 }}
- >
- 鍋滄RCS杩愯浆
- </Button>
- <Button variant="contained" color="secondary">
- 妯℃嫙AGV杩愯
- </Button>
</Box>
<Box
sx={{
@@ -196,6 +232,13 @@
))}
</SpeedDial>
</Box>
+ <Device
+ open={deviceVisible}
+ onCancel={() => {
+ setDeviceVisible(false);
+ }}
+ onDrop={onDrop}
+ />
</Box>
);
}
diff --git a/zy-acs-flow/src/map/tool.js b/zy-acs-flow/src/map/tool.js
index 26c7944..b78e7e4 100644
--- a/zy-acs-flow/src/map/tool.js
+++ b/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')) {
--
Gitblit v1.9.1