mirror of https://gitee.com/cf-fz/WebCAD.git
!2334 功能:增加板边备注
parent
77be29f30b
commit
a8050622ad
@ -0,0 +1,85 @@
|
||||
import { Button, Classes, Intent, Label } from '@blueprintjs/core';
|
||||
import { inject, observer } from 'mobx-react';
|
||||
import * as React from 'react';
|
||||
import { ColorMaterial } from '../../../Common/ColorPalette';
|
||||
import { BoardEdgeRemarksStore } from '../../Store/RightPanelStore/BoardEdgeRemarksStore';
|
||||
import { Board_Editor_Key } from '../../Store/RightPanelStore/BoardEdgesEditor';
|
||||
import { RightPanelStore } from '../../Store/RightPanelStore/RightPanelStore';
|
||||
import { BoardModalType } from '../Board/BoardModalType';
|
||||
import { UserConfigComponent } from '../Board/UserConfigComponent';
|
||||
import { AppToaster } from '../Toaster';
|
||||
|
||||
@inject("store")
|
||||
@observer
|
||||
export class BoardEdgeRemarksComponent extends React.Component<{ store?: RightPanelStore; }>
|
||||
{
|
||||
render()
|
||||
{
|
||||
const boardEdgeRemarksStore = BoardEdgeRemarksStore.GetInstance();
|
||||
|
||||
return (
|
||||
<div className='rightTab'>
|
||||
<div className='tabBody'>
|
||||
<ul className={"modeling dataList " + Classes.LIST_UNSTYLED}>
|
||||
<li>
|
||||
<Label>颜色</Label>
|
||||
<Label>备注</Label>
|
||||
</li>
|
||||
{
|
||||
boardEdgeRemarksStore.option.boardEdgeRemarks.map((v, i) =>
|
||||
{
|
||||
return (
|
||||
<li key={i}>
|
||||
<span
|
||||
className={Classes.INPUT}
|
||||
style={{
|
||||
background: ColorMaterial.GetColor(i + 1).getStyle(),
|
||||
width: "50%",
|
||||
color: i >= 10 ? "white" : "black"
|
||||
}}
|
||||
>{i + 1}</span>
|
||||
<input
|
||||
style={{ width: "50%" }}
|
||||
tabIndex={1}
|
||||
value={v}
|
||||
onFocus={e =>
|
||||
{
|
||||
e.target.setSelectionRange(0, e.target.value.length);
|
||||
}}
|
||||
className={Classes.INPUT}
|
||||
onChange={(e) =>
|
||||
{
|
||||
boardEdgeRemarksStore.option.boardEdgeRemarks[i] = e.target.value;
|
||||
}}
|
||||
/>
|
||||
</li>
|
||||
);
|
||||
})
|
||||
}
|
||||
</ul>
|
||||
<div className="flex-arround">
|
||||
<Button text="写入" intent={Intent.SUCCESS}
|
||||
onClick={this.ok} />
|
||||
<Button text="退出" intent={Intent.DANGER}
|
||||
onClick={this.exit} />
|
||||
</div>
|
||||
</div>
|
||||
<UserConfigComponent
|
||||
className="modeing-config"
|
||||
store={boardEdgeRemarksStore}
|
||||
type={BoardModalType.BoardEdgeRemarks}
|
||||
isNotUpdateStore={boardEdgeRemarksStore.isNotUpdateStore}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
private ok = () =>
|
||||
{
|
||||
this.props.store.boardEdgeRemarksStore.IsApplyData = true;
|
||||
this.exit();
|
||||
};
|
||||
private exit()
|
||||
{
|
||||
AppToaster.dismiss(Board_Editor_Key);
|
||||
}
|
||||
}
|
@ -0,0 +1,173 @@
|
||||
import { observable, toJS } from "mobx";
|
||||
import { CommandNames } from "../../../Common/CommandNames";
|
||||
import { Log, LogType } from "../../../Common/Log";
|
||||
import { Intent } from "../../../Common/Toaster";
|
||||
import { Board } from "../../../DatabaseServices/Entity/Board";
|
||||
import { CommandWrap } from "../../../Editor/CommandMachine";
|
||||
import { GetBoardSealingCurves, GetHighBoardEdgeRemark, SetBoardEdgeRemarkData } from "../../../GraphicsSystem/CalcEdgeSealing";
|
||||
import { IConfigOption } from "../../Components/Board/UserConfigComponent";
|
||||
import { ShowLinesToaster } from "../../Components/Toaster";
|
||||
import { IConfigStore } from "../BoardStore";
|
||||
import { IHighEdgeRemarkItem } from "../OptionInterface/IHighSealedItem";
|
||||
import { BoardEdgesEditor, Board_Editor_Key } from "./BoardEdgesEditor";
|
||||
|
||||
export class BoardEdgeRemarksStore extends BoardEdgesEditor implements IConfigStore
|
||||
{
|
||||
isNotUpdateStore = false;
|
||||
|
||||
@observable boardEdgeRemarks: string[] = Array(20).fill("");
|
||||
private static _SingleInstance: BoardEdgeRemarksStore;
|
||||
static GetInstance(): BoardEdgeRemarksStore
|
||||
{
|
||||
if (this._SingleInstance) return this._SingleInstance;
|
||||
this._SingleInstance = new BoardEdgeRemarksStore;
|
||||
return this._SingleInstance;
|
||||
}
|
||||
|
||||
@observable option = { boardEdgeRemarks: this.boardEdgeRemarks };
|
||||
async InitData()
|
||||
{
|
||||
}
|
||||
|
||||
@observable configName: string = "默认";
|
||||
@observable configsNames: string[] = [];
|
||||
InitOption()
|
||||
{
|
||||
const initBoardEdgeRemarks = Array(20).fill("");
|
||||
//禁止再次初始化,避免用户没有配置的时候,使用板边备注编辑,导致面板属性被还原
|
||||
Object.assign(this.option, { boardEdgeRemarks: initBoardEdgeRemarks });
|
||||
}
|
||||
SaveConfig()
|
||||
{
|
||||
return { option: toJS(this.option) };
|
||||
}
|
||||
|
||||
UpdateOption(cof: IConfigOption)
|
||||
{
|
||||
Object.assign(this.option, cof.option);
|
||||
}
|
||||
protected InitCurve()
|
||||
{
|
||||
const dataColorMap = new Map<string, number>();//data->color
|
||||
const canUseColor: number[] = [];//可使用的颜色
|
||||
|
||||
const boardEdgeRemarks = this.option.boardEdgeRemarks;
|
||||
|
||||
for (let i = 0; i < boardEdgeRemarks.length; i++)
|
||||
{
|
||||
if (dataColorMap.has(boardEdgeRemarks[i]) || boardEdgeRemarks[i] === "")
|
||||
canUseColor.push(i);//可以被覆盖
|
||||
else
|
||||
dataColorMap.set(boardEdgeRemarks[i], i);//记录颜色
|
||||
}
|
||||
|
||||
for (const br of this._boardList)
|
||||
{
|
||||
const curves = GetBoardSealingCurves(br, true);
|
||||
const highBoardEdgeRemark = GetHighBoardEdgeRemark(br, curves);
|
||||
|
||||
if (highBoardEdgeRemark.length === curves.length)
|
||||
{
|
||||
for (let i = 0; i < highBoardEdgeRemark.length; i++)
|
||||
{
|
||||
const remark = highBoardEdgeRemark[i];
|
||||
if (!dataColorMap.has(remark.description))
|
||||
{
|
||||
if (canUseColor.length)
|
||||
{
|
||||
dataColorMap.set(remark.description, canUseColor[0]);
|
||||
boardEdgeRemarks[canUseColor[0]] = remark.description;
|
||||
canUseColor.shift();
|
||||
}
|
||||
else
|
||||
{
|
||||
boardEdgeRemarks.push(remark.description);
|
||||
dataColorMap.set(remark.description, boardEdgeRemarks.length - 1);
|
||||
}
|
||||
}
|
||||
const color = dataColorMap.get(remark.description) + 1;
|
||||
curves[i].ColorIndex = color;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!dataColorMap.has(""))
|
||||
{
|
||||
if (canUseColor.length)
|
||||
{
|
||||
dataColorMap.set("", canUseColor[0]);
|
||||
boardEdgeRemarks[canUseColor[0]] = "";
|
||||
canUseColor.shift();
|
||||
}
|
||||
else
|
||||
{
|
||||
boardEdgeRemarks.push("");
|
||||
dataColorMap.set("", boardEdgeRemarks.length - 1);
|
||||
}
|
||||
}
|
||||
const color = dataColorMap.get("") + 1;
|
||||
curves.forEach(cu => cu.ColorIndex = color);
|
||||
}
|
||||
this._brMap.set(br, curves);
|
||||
}
|
||||
}
|
||||
protected ShowToaster()
|
||||
{
|
||||
ShowLinesToaster(
|
||||
["正在编辑板边备注...", "点击<写入>写入板边备注数据到板件,", "点击<退出>或者关闭退出编辑状态"],
|
||||
{
|
||||
intent: Intent.PRIMARY,
|
||||
timeout: 0,
|
||||
onDismiss: () =>
|
||||
{
|
||||
this.EndEditor();
|
||||
}
|
||||
}, Board_Editor_Key);
|
||||
}
|
||||
#dataMap: Map<Board, IHighEdgeRemarkItem[]> = new Map();
|
||||
protected ParseData()
|
||||
{
|
||||
const boardEdgeRemarks = this.option.boardEdgeRemarks;
|
||||
|
||||
for (const [br, cus] of this._brMap)
|
||||
{
|
||||
const data: IHighEdgeRemarkItem[] = [];
|
||||
for (const cu of cus)
|
||||
{
|
||||
//检查不存在配置的colorIndex
|
||||
const color = cu.ColorIndex;
|
||||
if (color > boardEdgeRemarks.length)
|
||||
{
|
||||
Log(color + "号色未设置数据,默认为空", LogType.Warning);
|
||||
data.push({ description: "" });
|
||||
}
|
||||
else
|
||||
{
|
||||
let remark = boardEdgeRemarks[color - 1];
|
||||
if (color === 0)
|
||||
{
|
||||
remark = "";
|
||||
Log(color + "不支持号色为 0 ,默认为空", LogType.Warning);
|
||||
}
|
||||
data.push({ description: remark });
|
||||
}
|
||||
}
|
||||
this.#dataMap.set(br, data);
|
||||
}
|
||||
}
|
||||
|
||||
protected async WriteData()
|
||||
{
|
||||
await CommandWrap(() =>
|
||||
{
|
||||
for (let [b, cus] of this._brMap)
|
||||
{
|
||||
let data = this.#dataMap.get(b);
|
||||
let ocsInv = b.OCSInv;
|
||||
SetBoardEdgeRemarkData(b, data, cus.map(c => c.ApplyMatrix(ocsInv)));
|
||||
b.BoardProcessOption.highBoardEdgeRemark = data;
|
||||
}
|
||||
this.#dataMap.clear();
|
||||
}, CommandNames.板边备注编辑);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue