!1538 增强:选择薄背板可以设置厚度,厚度可以在云端同步

pull/1538/MERGE
林三 3 years ago committed by ChenX
parent 2c0a5862d5
commit bbf648947d

@ -1,25 +1,94 @@
import { app } from "../../ApplicationServices/Application";
import { FixedNotZero } from "../../Common/Utils";
import { Board } from "../../DatabaseServices/Entity/Board";
import { Command } from "../../Editor/CommandMachine";
import { PromptStatus } from "../../Editor/PromptResult";
import { BoardModalType } from "../../UI/Components/Board/BoardModal";
import { IConfigOption } from "../../UI/Components/Board/UserConfig";
import { BoardType } from "../../UI/Store/BoardInterface";
import { IConfigStore } from "../../UI/Store/BoardStore";
import { userConfigStore } from "../../UI/Store/UserConfigStore";
export class SelectThinBehindBoard implements Command
{
store: SelectThinBehindBoardStore;
async exec()
{
let ssRes = await app.Editor.GetSelection({
Msg: "选择薄背板",
AllowNone: true,
UseSelect: true,
Filter: {
filterFunction: (obj, ent) =>
{
return (ent instanceof Board) && (ent.BoardType === BoardType.Behind) && (ent.Thickness < 15);
if (!this.store)
{
this.store = new SelectThinBehindBoardStore;
await userConfigStore.UpdateBoardOption(this.store.configName, BoardModalType.SelectThinBehindBoard, this.store);
}
while (true)
{
let ssRes = await app.Editor.GetSelection({
Msg: `当前规定薄背板厚度为小于:${FixedNotZero(this.store.config.option.thickness)}`,
AllowNone: true,
KeyWordList: [{ msg: "重新设置厚度输入:", key: "S" }],
Filter: {
filterFunction: (obj, ent) =>
{
return (ent instanceof Board) && (ent.BoardType === BoardType.Behind) && (ent.Thickness < this.store.config.option.thickness);
}
}
});
switch (ssRes.Status)
{
case PromptStatus.OK:
app.Editor.SetSelection(ssRes.SelectSet.SelectEntityList);
return;
case PromptStatus.Cancel:
return;
case PromptStatus.Keyword:
if (ssRes.StringResult === "S")
{
let ret = await app.Editor.GetDistance({ Msg: "当前规定薄背板厚度为小于:", Default: this.store.config.option.thickness });
if (ret.Status === PromptStatus.OK)
{
if (ret.Distance <= 0 || isNaN(ret.Distance))
{
app.Editor.Prompt("请输入为正数的厚度!");
return;
}
this.store.config.option.thickness = Math.abs(ret.Distance);
userConfigStore.SaveConfig(BoardModalType.SelectThinBehindBoard, this.store, { toaster: false });
}
else if (ret.Status === PromptStatus.Cancel)
return;
break;
}
default:
return;
}
});
if (ssRes.Status === PromptStatus.OK)
app.Editor.SetSelection(ssRes.SelectSet.SelectEntityList);
}
}
}
//只是用来保存配置
class SelectThinBehindBoardStore implements IConfigStore
{
configName = "默认";
configsNames = ['默认'];
config = {
option: {
thickness: 15
}
};
InitOption()
{
this.config = {
option: {
thickness: 15
}
};
}
SaveConfig()
{
return this.config;
}
UpdateOption(conf: IConfigOption<any>)
{
Object.assign(this.config, conf);
}
}

@ -53,6 +53,7 @@ export enum BoardModalType
HS = "hideSelect",//隐藏-选中
ParseBrName = "ParseBrName",//分析板件名
AutoDimBrs = "AutoDimBrs",//自动标注
SelectThinBehindBoard = "SelectThinBehindBoard",//选择薄背板
ChangeColorByMaterial = "ChangeColorByMaterial",
ModifyTexts = "ModifyTexts",//批量修改文本
}

Loading…
Cancel
Save