mirror of https://gitee.com/cf-fz/WebCAD.git
!1538 增强:选择薄背板可以设置厚度,厚度可以在云端同步
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue