|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import { Intent } from "@blueprintjs/core";
|
|
|
|
|
import { observable } from "mobx";
|
|
|
|
|
import { observable, toJS } from "mobx";
|
|
|
|
|
import { app } from "../../../ApplicationServices/Application";
|
|
|
|
|
import { CommandNames } from "../../../Common/CommandNames";
|
|
|
|
|
import { safeEval } from "../../../Common/eval";
|
|
|
|
@ -8,21 +8,56 @@ import { Board } from "../../../DatabaseServices/Entity/Board";
|
|
|
|
|
import { Entity } from "../../../DatabaseServices/Entity/Entity";
|
|
|
|
|
import { CommandWrap } from "../../../Editor/CommandMachine";
|
|
|
|
|
import { GetBoardHighSeal, GetBoardSealingCurves, GetSealedBoardContour, HandleRectBoardSealingData } from "../../../GraphicsSystem/CalcEdgeSealing";
|
|
|
|
|
import { IConfigOption } from "../../Components/Board/UserConfig";
|
|
|
|
|
import { AppToaster, ShowLinesToaster } from "../../Components/Toaster";
|
|
|
|
|
import { IHighSealedItem } from "../BoardInterface";
|
|
|
|
|
import { IConfigStore } from "../BoardStore";
|
|
|
|
|
import { BoardEdgesEditor, Board_Editor_Key } from "./BoardEdgesEditor";
|
|
|
|
|
|
|
|
|
|
export class SealingStore extends BoardEdgesEditor
|
|
|
|
|
export class SealingStore extends BoardEdgesEditor implements IConfigStore
|
|
|
|
|
{
|
|
|
|
|
@observable highSizes: string[] = Array(15).fill("1");
|
|
|
|
|
private static _SingleInstance: SealingStore;
|
|
|
|
|
static GetInstance(): SealingStore
|
|
|
|
|
{
|
|
|
|
|
if (this._SingleInstance) return this._SingleInstance;
|
|
|
|
|
this._SingleInstance = new SealingStore;
|
|
|
|
|
return this._SingleInstance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@observable option = { highSizes: this.highSizes };
|
|
|
|
|
async InitData()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@observable configName: string = "默认";
|
|
|
|
|
@observable configsNames: string[] = [];
|
|
|
|
|
InitOption()
|
|
|
|
|
{
|
|
|
|
|
Object.assign(this.option, { highSizes: Array(15).fill("1") });
|
|
|
|
|
}
|
|
|
|
|
SaveConfig()
|
|
|
|
|
{
|
|
|
|
|
return { option: toJS(this.option) };
|
|
|
|
|
}
|
|
|
|
|
UpdateOption(cof: IConfigOption)
|
|
|
|
|
{
|
|
|
|
|
Object.assign(this.option, cof.option);
|
|
|
|
|
}
|
|
|
|
|
protected InitCurve()
|
|
|
|
|
{
|
|
|
|
|
let totalHighSeals: Set<number> = new Set();
|
|
|
|
|
let dataColorMap = new Map<string, number>();//data->color
|
|
|
|
|
let canUseColor: number[] = [];//可使用的颜色
|
|
|
|
|
let highSizes = this.option.highSizes;
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < highSizes.length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (dataColorMap.has(highSizes[i]))
|
|
|
|
|
canUseColor.push(i);//可以被覆盖
|
|
|
|
|
else
|
|
|
|
|
dataColorMap.set(highSizes[i], i);//记录颜色
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (let br of this._boardList)
|
|
|
|
|
{
|
|
|
|
|
let cus = GetBoardSealingCurves(br, true);
|
|
|
|
@ -32,16 +67,41 @@ export class SealingStore extends BoardEdgesEditor
|
|
|
|
|
for (let i = 0; i < highseals.length; i++)
|
|
|
|
|
{
|
|
|
|
|
let s = highseals[i];
|
|
|
|
|
totalHighSeals.add(s.size);
|
|
|
|
|
let color = [...totalHighSeals].indexOf(s.size) + 1;
|
|
|
|
|
if (!dataColorMap.has(s.size.toString()))
|
|
|
|
|
{
|
|
|
|
|
if (canUseColor[0])
|
|
|
|
|
{
|
|
|
|
|
dataColorMap.set(s.size.toString(), canUseColor[0]);
|
|
|
|
|
highSizes[canUseColor[0]] = s.size.toString();
|
|
|
|
|
canUseColor.shift();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
highSizes.push(s.size.toString());
|
|
|
|
|
dataColorMap.set(s.size.toString(), highSizes.length - 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let color = dataColorMap.get(s.size.toString()) + 1;
|
|
|
|
|
cus[i].ColorIndex = color;
|
|
|
|
|
this.highSizes[color - 1] = s.size.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
totalHighSeals.add(1);
|
|
|
|
|
let color = [...totalHighSeals].indexOf(1) + 1;
|
|
|
|
|
if (!dataColorMap.has("1"))
|
|
|
|
|
{
|
|
|
|
|
if (canUseColor[0])
|
|
|
|
|
{
|
|
|
|
|
dataColorMap.set("1", canUseColor[0]);
|
|
|
|
|
highSizes[canUseColor[0]] = "1";
|
|
|
|
|
canUseColor.shift();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
highSizes.push("1");
|
|
|
|
|
dataColorMap.set("1", highSizes.length - 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let color = dataColorMap.get("1") + 1;
|
|
|
|
|
cus.forEach(cu => cu.ColorIndex = color);
|
|
|
|
|
}
|
|
|
|
|
this._brMap.set(br, cus);
|
|
|
|
@ -70,14 +130,14 @@ export class SealingStore extends BoardEdgesEditor
|
|
|
|
|
for (let cu of cus)
|
|
|
|
|
{
|
|
|
|
|
const color = cu.ColorIndex;
|
|
|
|
|
if (color > this.highSizes.length)
|
|
|
|
|
if (color > this.option.highSizes.length)
|
|
|
|
|
{
|
|
|
|
|
Log(color + "号色未设置数据,默认为1");
|
|
|
|
|
data.push({ size: 1 });
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const size = this.highSizes[color - 1];
|
|
|
|
|
const size = this.option.highSizes[color - 1];
|
|
|
|
|
data.push({ size: safeEval(size) });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|