feat: 更新编辑器服务以确保点位在路线上方,并调整锚点配置以优化图形显示
This commit is contained in:
parent
4cbc6d1897
commit
f3b993d31d
@ -147,8 +147,8 @@ export const EDITOR_CONFIG: Options = {
|
|||||||
disableRotate: true,
|
disableRotate: true,
|
||||||
/** 禁用尺寸调整 - 允许图形大小调整 */
|
/** 禁用尺寸调整 - 允许图形大小调整 */
|
||||||
disableSize: false,
|
disableSize: false,
|
||||||
/** 禁用锚点 - 禁用连接锚点显示 */
|
/** 禁用锚点 - 禁用连接锚点显示,点位不需要锚点,只有区域需要 */
|
||||||
disableAnchor: false,
|
disableAnchor: true,
|
||||||
/** 禁用空线条 - 不允许创建没有连接点的线条 */
|
/** 禁用空线条 - 不允许创建没有连接点的线条 */
|
||||||
disableEmptyLine: true,
|
disableEmptyLine: true,
|
||||||
/** 禁用重复线条 - 不允许在同一对点之间创建多条线 */
|
/** 禁用重复线条 - 不允许在同一对点之间创建多条线 */
|
||||||
|
@ -70,6 +70,10 @@ export class EditorService extends Meta2d {
|
|||||||
await this.#loadScenePoints(points, isImport);
|
await this.#loadScenePoints(points, isImport);
|
||||||
this.#loadSceneRoutes(routes, isImport);
|
this.#loadSceneRoutes(routes, isImport);
|
||||||
await this.#loadSceneAreas(areas, isImport);
|
await this.#loadSceneAreas(areas, isImport);
|
||||||
|
|
||||||
|
// 确保加载的点位在路线上方
|
||||||
|
this.#ensurePointsOnTop();
|
||||||
|
|
||||||
this.store.historyIndex = undefined;
|
this.store.historyIndex = undefined;
|
||||||
this.store.histories = [];
|
this.store.histories = [];
|
||||||
// this.scale(scale);与xd 自定义缩放冲突,暂时去掉
|
// this.scale(scale);与xd 自定义缩放冲突,暂时去掉
|
||||||
@ -496,6 +500,17 @@ export class EditorService extends Meta2d {
|
|||||||
}
|
}
|
||||||
return area;
|
return area;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确保所有点位在路线上方
|
||||||
|
* 将所有点位移到绘制顺序的最上层
|
||||||
|
*/
|
||||||
|
#ensurePointsOnTop(): void {
|
||||||
|
const points = this.find('point');
|
||||||
|
if (points.length > 0) {
|
||||||
|
this.top(points);
|
||||||
|
}
|
||||||
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -967,7 +982,10 @@ export class EditorService extends Meta2d {
|
|||||||
};
|
};
|
||||||
pen.x! -= pen.width! / 2;
|
pen.x! -= pen.width! / 2;
|
||||||
pen.y! -= pen.height! / 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 {
|
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);
|
const line = this.connectLine(p1, p2, undefined, undefined, false);
|
||||||
id ||= line.id!;
|
id ||= line.id!;
|
||||||
this.changePenId(line.id!, 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.setValue({ id, ...pen }, { render: false, history: false, doEvent: false });
|
||||||
this.updateLineType(line, type);
|
this.updateLineType(line, type);
|
||||||
|
|
||||||
|
// 将路线移到底层,确保点位能覆盖在路线之上
|
||||||
|
this.bottom([line]);
|
||||||
|
|
||||||
this.active(id);
|
this.active(id);
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user