|
@@ -4,9 +4,12 @@ import { HoverType, Meta2d, Options, Pen } from "@meta2d/core";
|
|
|
import ContextMenu from "../components/ContextMenu.vue";
|
|
|
import SvgIcon from "../components/SvgIcon.vue";
|
|
|
import { registerAreaPens } from "./pens/register";
|
|
|
-import { useSelection } from '@/services/selections';
|
|
|
+import { useSelection } from "@/services/selections";
|
|
|
+import { useMonitorPointPen } from "@/services/monitor-point-pen";
|
|
|
+import { monitorPointData } from "./pens/monitorPoint";
|
|
|
|
|
|
const { select } = useSelection();
|
|
|
+const { setMonitorPointPens } = useMonitorPointPen();
|
|
|
|
|
|
const meta2dOptions: Options = {
|
|
|
x: 0,
|
|
@@ -21,31 +24,51 @@ const meta2dOptions: Options = {
|
|
|
|
|
|
onMounted(() => {
|
|
|
new Meta2d("env-area-meta2d", meta2dOptions);
|
|
|
- meta2d.lock(0)
|
|
|
- meta2d.on('active', active);
|
|
|
- meta2d.on('inactive', inactive);
|
|
|
- meta2d.on('contextmenu', onContextmenu);
|
|
|
- meta2d.on('click', canvasClick);
|
|
|
- registerAreaPens()
|
|
|
+ meta2d.lock(0);
|
|
|
+ meta2d.on("active", active);
|
|
|
+ meta2d.on("inactive", inactive);
|
|
|
+
|
|
|
+ meta2d.on("undo", patchFlag);
|
|
|
+ meta2d.on("redo", patchFlag);
|
|
|
+ meta2d.on("add", patchFlag);
|
|
|
+ meta2d.on("delete", patchFlag);
|
|
|
+ meta2d.on("rotatePens", patchFlag);
|
|
|
+ meta2d.on("translatePens", patchFlag);
|
|
|
+
|
|
|
+ // 所有编辑栏所做修改
|
|
|
+ meta2d.on("components-update-value", patchFlag);
|
|
|
+ meta2d.on("contextmenu", onContextmenu);
|
|
|
+ meta2d.on("click", canvasClick);
|
|
|
+ registerAreaPens();
|
|
|
});
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
- meta2d.off('active', active);
|
|
|
- meta2d.off('inactive', inactive);
|
|
|
- meta2d.off('contextmenu', onContextmenu);
|
|
|
- meta2d.off('click', canvasClick);
|
|
|
+ meta2d.off("active", active);
|
|
|
+ meta2d.off("inactive", inactive);
|
|
|
+
|
|
|
+ meta2d.off("undo", patchFlag);
|
|
|
+ meta2d.off("redo", patchFlag);
|
|
|
+ meta2d.off("add", patchFlag);
|
|
|
+ meta2d.off("delete", patchFlag);
|
|
|
+ meta2d.off("rotatePens", patchFlag);
|
|
|
+ meta2d.off("translatePens", patchFlag);
|
|
|
+
|
|
|
+ // 所有编辑栏所做修改
|
|
|
+ meta2d.off("components-update-value", patchFlag);
|
|
|
+ meta2d.off("contextmenu", onContextmenu);
|
|
|
+ meta2d.off("click", canvasClick);
|
|
|
meta2d?.destroy();
|
|
|
});
|
|
|
|
|
|
const inactive = () => {
|
|
|
- if(fitFlag.value){
|
|
|
+ if (fitFlag.value) {
|
|
|
return;
|
|
|
}
|
|
|
select();
|
|
|
};
|
|
|
|
|
|
const active = (pens: Pen[]) => {
|
|
|
- if(fitFlag.value){
|
|
|
+ if (fitFlag.value) {
|
|
|
return;
|
|
|
}
|
|
|
select(pens);
|
|
@@ -57,6 +80,15 @@ const active = (pens: Pen[]) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+const patchFlag = () => {
|
|
|
+ const data = meta2d.data();
|
|
|
+ const monitorPointPens = data.pens.filter(
|
|
|
+ (item) => item.name === monitorPointData.name
|
|
|
+ );
|
|
|
+
|
|
|
+ setMonitorPointPens(monitorPointPens);
|
|
|
+};
|
|
|
+
|
|
|
const fitFlag = ref(false);
|
|
|
const one = ref(false);
|
|
|
const always = ref(false);
|
|
@@ -68,29 +100,29 @@ const contextmenu = reactive({
|
|
|
});
|
|
|
|
|
|
const onContextmenu = ({ e, rect }: { e: any; rect: any }) => {
|
|
|
- contextmenu.type = '';
|
|
|
+ contextmenu.type = "";
|
|
|
contextmenu.style = {
|
|
|
- left: e.clientX + 'px',
|
|
|
- top: e.clientY + 'px',
|
|
|
+ left: e.clientX + "px",
|
|
|
+ top: e.clientY + "px",
|
|
|
};
|
|
|
|
|
|
if (
|
|
|
meta2d.store.hoverAnchor &&
|
|
|
meta2d.canvas.hoverType === HoverType.LineAnchor
|
|
|
) {
|
|
|
- contextmenu.type = 'anchor';
|
|
|
+ contextmenu.type = "anchor";
|
|
|
if (document.body.clientHeight - e.clientY < 128) {
|
|
|
contextmenu.style = {
|
|
|
- left: e.clientX + 'px',
|
|
|
- bottom: '4px',
|
|
|
+ left: e.clientX + "px",
|
|
|
+ bottom: "4px",
|
|
|
};
|
|
|
}
|
|
|
} else {
|
|
|
- contextmenu.type = 'pen';
|
|
|
+ contextmenu.type = "pen";
|
|
|
if (document.body.clientHeight - e.clientY < 450) {
|
|
|
contextmenu.style = {
|
|
|
- left: e.clientX + 'px',
|
|
|
- bottom: '4px',
|
|
|
+ left: e.clientX + "px",
|
|
|
+ bottom: "4px",
|
|
|
};
|
|
|
}
|
|
|
}
|