|
@@ -45,7 +45,7 @@ const getSizePlaceBoxImage = ({ width, height }: Size) => {
|
|
|
borderWidth / 2,
|
|
borderWidth / 2,
|
|
|
borderWidth / 2,
|
|
borderWidth / 2,
|
|
|
width - borderWidth,
|
|
width - borderWidth,
|
|
|
- height - borderWidth
|
|
|
|
|
|
|
+ height - borderWidth,
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
return canvas.toDataURL(); // 返回图片的Data URL字符串
|
|
return canvas.toDataURL(); // 返回图片的Data URL字符串
|
|
@@ -94,7 +94,7 @@ const getCoverShapes = (cover: SceneResource["cover"]) => {
|
|
|
const height = cover.bound.y_max - cover.bound.y_min;
|
|
const height = cover.bound.y_max - cover.bound.y_min;
|
|
|
const mat = new Transform().translate(
|
|
const mat = new Transform().translate(
|
|
|
cover.bound.x_min + width / 2,
|
|
cover.bound.x_min + width / 2,
|
|
|
- cover.bound.y_min + height / 2
|
|
|
|
|
|
|
+ cover.bound.y_min + height / 2,
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
const thumb: ImageData = {
|
|
const thumb: ImageData = {
|
|
@@ -203,14 +203,14 @@ const getTaggingShapes = async (taggings: SceneResource["taggings"]) => {
|
|
|
}
|
|
}
|
|
|
const shape = {
|
|
const shape = {
|
|
|
...getBaseItem(),
|
|
...getBaseItem(),
|
|
|
- ...(item.size || { width: 100, height: 100 }),
|
|
|
|
|
name: item.name,
|
|
name: item.name,
|
|
|
key: item.key,
|
|
key: item.key,
|
|
|
createTime: now + ndx,
|
|
createTime: now + ndx,
|
|
|
url: item.url,
|
|
url: item.url,
|
|
|
mat: mat.m,
|
|
mat: mat.m,
|
|
|
zIndex: 1,
|
|
zIndex: 1,
|
|
|
- ...iconDefaultStyle
|
|
|
|
|
|
|
+ ...iconDefaultStyle,
|
|
|
|
|
+ ...item.size,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
if (!item.url.includes(".svg")) {
|
|
if (!item.url.includes(".svg")) {
|
|
@@ -224,13 +224,12 @@ const getTaggingShapes = async (taggings: SceneResource["taggings"]) => {
|
|
|
icons.push({ ...shape, ...style });
|
|
icons.push({ ...shape, ...style });
|
|
|
})
|
|
})
|
|
|
.catch((e) => {
|
|
.catch((e) => {
|
|
|
- console.error('获取url失败', e, item)
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ console.error("获取url失败", e, item);
|
|
|
|
|
+ }),
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
await Promise.all(reqs);
|
|
await Promise.all(reqs);
|
|
|
- console.log(texts, images, icons)
|
|
|
|
|
return {
|
|
return {
|
|
|
texts,
|
|
texts,
|
|
|
images,
|
|
images,
|
|
@@ -254,10 +253,10 @@ const getBorderTaggingShapes = (taggings: SceneResource["borderTaggings"]) => {
|
|
|
|
|
|
|
|
const w = Math.min(
|
|
const w = Math.min(
|
|
|
taggings[i].points[1].x - taggings[i].points[0].x,
|
|
taggings[i].points[1].x - taggings[i].points[0].x,
|
|
|
- textDefaultStyle.fontSize * taggings[i].text.length
|
|
|
|
|
- )
|
|
|
|
|
- const y = taggings[i].center.y - textDefaultStyle.fontSize / 2
|
|
|
|
|
- const x = taggings[i].center.x - w / 2
|
|
|
|
|
|
|
+ textDefaultStyle.fontSize * taggings[i].text.length,
|
|
|
|
|
+ );
|
|
|
|
|
+ const y = taggings[i].center.y - textDefaultStyle.fontSize / 2;
|
|
|
|
|
+ const x = taggings[i].center.x - w / 2;
|
|
|
|
|
|
|
|
const mat = new Transform();
|
|
const mat = new Transform();
|
|
|
mat.translate(x, y);
|
|
mat.translate(x, y);
|
|
@@ -270,7 +269,7 @@ const getBorderTaggingShapes = (taggings: SceneResource["borderTaggings"]) => {
|
|
|
mat: mat.m,
|
|
mat: mat.m,
|
|
|
width: w,
|
|
width: w,
|
|
|
createTime: now + taggings.length + i,
|
|
createTime: now + taggings.length + i,
|
|
|
- }
|
|
|
|
|
|
|
+ };
|
|
|
texts.push(text);
|
|
texts.push(text);
|
|
|
}
|
|
}
|
|
|
return {
|
|
return {
|
|
@@ -281,7 +280,7 @@ const getBorderTaggingShapes = (taggings: SceneResource["borderTaggings"]) => {
|
|
|
|
|
|
|
|
const getWallTaggingShapes = async (
|
|
const getWallTaggingShapes = async (
|
|
|
taggings: SceneResource["wallTaggings"],
|
|
taggings: SceneResource["wallTaggings"],
|
|
|
- lineData: LineData
|
|
|
|
|
|
|
+ lineData: LineData,
|
|
|
) => {
|
|
) => {
|
|
|
const lineIcons: LineIconData[] = [];
|
|
const lineIcons: LineIconData[] = [];
|
|
|
const now = Date.now();
|
|
const now = Date.now();
|
|
@@ -290,10 +289,10 @@ const getWallTaggingShapes = async (
|
|
|
for (let ndx = 0; ndx < taggings.length; ndx++) {
|
|
for (let ndx = 0; ndx < taggings.length; ndx++) {
|
|
|
const item = taggings[ndx];
|
|
const item = taggings[ndx];
|
|
|
const points = item.pointIds.map(
|
|
const points = item.pointIds.map(
|
|
|
- (key) => lineData.points.find((p: any) => p.key === key)!
|
|
|
|
|
|
|
+ (key) => lineData.points.find((p: any) => p.key === key)!,
|
|
|
);
|
|
);
|
|
|
const line = lineData.lines.find(
|
|
const line = lineData.lines.find(
|
|
|
- (line) => line.a === points[0].id && line.b === points[1].id
|
|
|
|
|
|
|
+ (line) => line.a === points[0].id && line.b === points[1].id,
|
|
|
)!;
|
|
)!;
|
|
|
if (!line) {
|
|
if (!line) {
|
|
|
break;
|
|
break;
|
|
@@ -319,7 +318,7 @@ const getWallTaggingShapes = async (
|
|
|
}
|
|
}
|
|
|
lineIcons.push({ ...shape, fill: style.fill, stroke: style.stroke });
|
|
lineIcons.push({ ...shape, fill: style.fill, stroke: style.stroke });
|
|
|
})
|
|
})
|
|
|
- .catch(() => {})
|
|
|
|
|
|
|
+ .catch(() => {}),
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
await Promise.all(reqs);
|
|
await Promise.all(reqs);
|
|
@@ -329,7 +328,7 @@ const getWallTaggingShapes = async (
|
|
|
const getDrawResourceOffset = (
|
|
const getDrawResourceOffset = (
|
|
|
draw: Draw,
|
|
draw: Draw,
|
|
|
bound: ReturnType<typeof genBound>,
|
|
bound: ReturnType<typeof genBound>,
|
|
|
- thumb?: ImageData
|
|
|
|
|
|
|
+ thumb?: ImageData,
|
|
|
) =>
|
|
) =>
|
|
|
new Promise<Pos>((resolve, reject) => {
|
|
new Promise<Pos>((resolve, reject) => {
|
|
|
ElMessage.warning("请在画图面板中选择放置位置,按右键取消");
|
|
ElMessage.warning("请在画图面板中选择放置位置,按右键取消");
|
|
@@ -343,7 +342,7 @@ const getDrawResourceOffset = (
|
|
|
|
|
|
|
|
stopWatch();
|
|
stopWatch();
|
|
|
const item = draw.store.items.find(
|
|
const item = draw.store.items.find(
|
|
|
- (item) => item.key === key
|
|
|
|
|
|
|
+ (item) => item.key === key,
|
|
|
) as ImageData;
|
|
) as ImageData;
|
|
|
|
|
|
|
|
if (!item) {
|
|
if (!item) {
|
|
@@ -386,9 +385,9 @@ const drawSceneResource = async (resource: SceneResource, draw: Draw) => {
|
|
|
const { icons, images, texts } = await getTaggingShapes(resource.taggings);
|
|
const { icons, images, texts } = await getTaggingShapes(resource.taggings);
|
|
|
|
|
|
|
|
// 这版本的icons先不用 用border
|
|
// 这版本的icons先不用 用border
|
|
|
- const border = getBorderTaggingShapes(resource.borderTaggings)
|
|
|
|
|
- texts.push(...border.texts)
|
|
|
|
|
- const rects = border.rects
|
|
|
|
|
|
|
+ const border = getBorderTaggingShapes(resource.borderTaggings);
|
|
|
|
|
+ texts.push(...border.texts);
|
|
|
|
|
+ const rects = border.rects;
|
|
|
|
|
|
|
|
const tagShapes = [...icons, ...images, ...texts, thumb];
|
|
const tagShapes = [...icons, ...images, ...texts, thumb];
|
|
|
tagShapes.forEach((shape) => {
|
|
tagShapes.forEach((shape) => {
|
|
@@ -398,14 +397,14 @@ const drawSceneResource = async (resource: SceneResource, draw: Draw) => {
|
|
|
bound.update({ x: shape.mat[4], y: shape.mat[5] });
|
|
bound.update({ x: shape.mat[4], y: shape.mat[5] });
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- const lineShapes = [...rects]
|
|
|
|
|
- lineShapes.forEach(item => {
|
|
|
|
|
- item.points.forEach(p => {
|
|
|
|
|
- p.x += offset.x
|
|
|
|
|
- p.y += offset.y
|
|
|
|
|
- bound.update(p)
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ const lineShapes = [...rects];
|
|
|
|
|
+ lineShapes.forEach((item) => {
|
|
|
|
|
+ item.points.forEach((p) => {
|
|
|
|
|
+ p.x += offset.x;
|
|
|
|
|
+ p.y += offset.y;
|
|
|
|
|
+ bound.update(p);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
const lineIcons = await getWallTaggingShapes(resource.wallTaggings, geo);
|
|
const lineIcons = await getWallTaggingShapes(resource.wallTaggings, geo);
|
|
|
|
|
|
|
@@ -422,7 +421,7 @@ const drawSceneResource = async (resource: SceneResource, draw: Draw) => {
|
|
|
draw.store.addItems("icon", icons);
|
|
draw.store.addItems("icon", icons);
|
|
|
draw.store.addItems("text", texts);
|
|
draw.store.addItems("text", texts);
|
|
|
draw.store.addItems("image", images);
|
|
draw.store.addItems("image", images);
|
|
|
- draw.store.addItems('rectangle', rects)
|
|
|
|
|
|
|
+ draw.store.addItems("rectangle", rects);
|
|
|
if (thumb) {
|
|
if (thumb) {
|
|
|
draw.store.addItem("image", thumb);
|
|
draw.store.addItem("image", thumb);
|
|
|
}
|
|
}
|
|
@@ -432,10 +431,13 @@ const drawSceneResource = async (resource: SceneResource, draw: Draw) => {
|
|
|
|
|
|
|
|
export const drawPlatformResource = async (
|
|
export const drawPlatformResource = async (
|
|
|
sceneData: SelectSceneData,
|
|
sceneData: SelectSceneData,
|
|
|
- draw: Draw
|
|
|
|
|
|
|
+ draw: Draw,
|
|
|
) => {
|
|
) => {
|
|
|
// 默认为米,转为厘米
|
|
// 默认为米,转为厘米
|
|
|
- const resource = await getResource({ ...sceneData, scale: 1000 * overviewMMToPixel });
|
|
|
|
|
|
|
+ const resource = await getResource({
|
|
|
|
|
+ ...sceneData,
|
|
|
|
|
+ scale: 1000 * overviewMMToPixel,
|
|
|
|
|
+ });
|
|
|
let bound = null as ReturnType<ReturnType<typeof genBound>["get"]>;
|
|
let bound = null as ReturnType<ReturnType<typeof genBound>["get"]>;
|
|
|
|
|
|
|
|
await draw.history.onceTrack(async () => {
|
|
await draw.history.onceTrack(async () => {
|
|
@@ -467,7 +469,7 @@ export const drawPlatformResource = async (
|
|
|
const viewHeight = Math.max(bound.height, size.height);
|
|
const viewHeight = Math.max(bound.height, size.height);
|
|
|
const padding = Math.max(
|
|
const padding = Math.max(
|
|
|
Math.min((viewWidth - bound.width) / 2, (viewHeight - bound.height) / 2),
|
|
Math.min((viewWidth - bound.width) / 2, (viewHeight - bound.height) / 2),
|
|
|
- 40
|
|
|
|
|
|
|
+ 40,
|
|
|
);
|
|
);
|
|
|
draw.viewer.setBound({ targetBound: bound, padding });
|
|
draw.viewer.setBound({ targetBound: bound, padding });
|
|
|
}
|
|
}
|