feat: 更新编辑器服务以确保点位在路线上方,并调整锚点配置以优化图形显示

This commit is contained in:
xudan 2025-08-15 15:11:24 +08:00
parent 4cbc6d1897
commit f3b993d31d
2 changed files with 32 additions and 4 deletions

View File

@ -147,8 +147,8 @@ export const EDITOR_CONFIG: Options = {
disableRotate: true,
/** 禁用尺寸调整 - 允许图形大小调整 */
disableSize: false,
/** 禁用锚点 - 禁用连接锚点显示 */
disableAnchor: false,
/** 禁用锚点 - 禁用连接锚点显示,点位不需要锚点,只有区域需要 */
disableAnchor: true,
/** 禁用空线条 - 不允许创建没有连接点的线条 */
disableEmptyLine: true,
/** 禁用重复线条 - 不允许在同一对点之间创建多条线 */

View File

@ -70,6 +70,10 @@ export class EditorService extends Meta2d {
await this.#loadScenePoints(points, isImport);
this.#loadSceneRoutes(routes, isImport);
await this.#loadSceneAreas(areas, isImport);
// 确保加载的点位在路线上方
this.#ensurePointsOnTop();
this.store.historyIndex = undefined;
this.store.histories = [];
// this.scale(scale);与xd 自定义缩放冲突,暂时去掉
@ -496,6 +500,17 @@ export class EditorService extends Meta2d {
}
return area;
}
/**
* 线
*
*/
#ensurePointsOnTop(): void {
const points = this.find('point');
if (points.length > 0) {
this.top(points);
}
}
//#endregion
/**
@ -967,7 +982,10 @@ export class EditorService extends Meta2d {
};
pen.x! -= pen.width! / 2;
pen.y! -= pen.height! / 2;
await this.addPen(pen, false, true, true);
const addedPen = await this.addPen(pen, false, true, true);
// 将点位移到最上层,确保它们始终显示在路线之上
this.top([addedPen]);
}
public updatePoint(id: string, info: Partial<MapPointInfo>): void {
@ -1052,9 +1070,19 @@ export class EditorService extends Meta2d {
const line = this.connectLine(p1, p2, undefined, undefined, false);
id ||= line.id!;
this.changePenId(line.id!, id);
const pen: MapPen = { tags: ['route'], route: { type }, lineWidth: 1, locked: LockState.DisableEdit };
const pen: MapPen = {
tags: ['route'],
route: { type },
lineWidth: 1,
locked: LockState.DisableEdit,
canvasLayer: CanvasLayer.CanvasMain,
};
this.setValue({ id, ...pen }, { render: false, history: false, doEvent: false });
this.updateLineType(line, type);
// 将路线移到底层,确保点位能覆盖在路线之上
this.bottom([line]);
this.active(id);
this.render();
}