!1998 功能:一键布局按房名出图

pull/1989/MERGE
黄诗津 2 years ago committed by ChenX
parent 56788ac24d
commit e87016f059

@ -63,7 +63,8 @@ export class OneKeyLayout implements Command
let file: string;
let ens: Entity[] = [];
const keyWordList = [{ msg: "使用默认", key: "D" }, { msg: "选择图框", key: "S" }];
let compose: boolean = false;
let compose: ("contact" | "section" | "roomName") = "contact";
let composeMap = new Map([["contact", ["靠在一起", "N"]], ["section", ["同竖轴柜体合并", "Y"]], ["roomName", ["按房名区分", "R"]]]);
const handleEntitys = (ents: Entity[]) =>
{
@ -101,9 +102,16 @@ export class OneKeyLayout implements Command
while (true)
{
let keyword = [];
for (const [k, v] of composeMap)
{
if (k !== compose)
keyword.push({ msg: v[0], key: v[1] });
}
let gRes = await app.Editor.GetEntity({
Msg: "选择一键布局的图框:",
KeyWordList: keyWordList.concat(compose ? { msg: "取消同竖轴柜体合并", key: "N" } : { msg: "同竖轴柜体合并", key: "Y" }),
Msg: `选择一键布局的图框<当前出图方式[${composeMap.get(compose)[0]}]>:`,
KeyWordList: keyWordList.concat(keyword),
// NotNone: true,
Filter: {
filterFunction: (o, e) => e?.GroupId?.Object !== undefined
@ -119,13 +127,17 @@ export class OneKeyLayout implements Command
{
if (gRes.StringResult === "Y")
{
compose = true;
compose = "section";
}
else if (gRes.StringResult === "N")
{
compose = "contact";
}
if (gRes.StringResult === "N")
else if (gRes.StringResult === "R")
{
compose = false;
compose = "roomName";
}
if (gRes.StringResult === "D" || gRes.Status === PromptStatus.Other)
else if (gRes.StringResult === "D" || gRes.Status === PromptStatus.Other)
{
let data = await PostJson(ToplineUrls.get, {
dir_id: "",
@ -263,7 +275,7 @@ export class OneKeyLayout implements Command
(bs as Entity[]).push(text);
}
if (compose) //同Y轴柜体合并
if (compose === "section") //同Y轴柜体合并
{
let boxs = Array.from(boxBoardMap.keys());
boxs.sort((box1, box2) => box1.min.x - box2.min.x);
@ -274,6 +286,17 @@ export class OneKeyLayout implements Command
arrayRemoveIf(boxs, (box) => this.checkBoxOnY(firstBox, box, boxBoardMap));
}
}
else if (compose === "roomName") //默认一个块里面都是同一个房名(不会有人会做房名不一样的吧)
{
let boxs = Array.from(boxBoardMap.keys());
boxs.sort((box1, box2) => box1.min.x - box2.min.x);
while (boxs.length > 1)
{
let firstBox = boxs[0];
boxs.shift();
arrayRemoveIf(boxs, (box) => this.checkBoxbyRoomName(firstBox, box, boxBoardMap));
}
}
const Total_Length = frameWidth * 9 / 8;
let left = 600;
@ -571,6 +594,30 @@ export class OneKeyLayout implements Command
return true;
}
}
private checkBoxbyRoomName(firstBox: Box3Ext, box: Box3Ext, boxBoardMap: Map<Box3Ext, Entity[]>)
{
const getRoomName = (box: Box3Ext) =>
{
for (const en of boxBoardMap.get(box))
{
if (en instanceof Board)
{
return en.BoardProcessOption.roomName;
}
}
};
if (getRoomName(firstBox) !== getRoomName(box))
return false;
else
{
for (let br of boxBoardMap.get(box))
boxBoardMap.get(firstBox).push(br);
firstBox.union(box);
boxBoardMap.delete(box);
return true;
}
}
private HandleTextMetaData(text: Text, en?: Board)
{

Loading…
Cancel
Save