!1942 功能:修改封边可以保存配置

pull/2002/MERGE
黄诗津 2 years ago committed by ChenX
parent 8cbc7240fd
commit 1de9c16ee0

@ -52,4 +52,5 @@ export enum BoardModalType
BBSEditor = "BBSEditor", //编辑BBS
BatchCurtail = "curtail", //批量内缩
BatchModifyPanel = "BatchModifyPanel", //批量修改板件
Sealing = "Sealing", //封边
}

@ -39,61 +39,55 @@ export class KeyWordContextMenu extends React.Component<{ keywordStore?: GetKeyW
store.keywordList.map((k, i) =>
{
return (
<React.Fragment key={i}>
{
(k.key === MenuDividerKWD.key) ? <MenuDivider />
: <MenuItem
text={k.key === "" ? `${k.msg}` : `${k.msg}(${k.key.length > 2 ? k.key.charAt(0) : k.key})`}
disabled={k.disable}
key={i}
active={store.selectIndex === i}
isShowChildren={
this.props.keywordStore.m_ShowChildrenIndex === i
}
onClick={(e: React.MouseEvent<HTMLElement, MouseEvent>) =>
{
if (k.children && k.children.length > 0)
(k.key === MenuDividerKWD.key) ? <MenuDivider key={i} />
: <MenuItem
text={k.key === "" ? `${k.msg}` : `${k.msg}(${k.key.length > 2 ? k.key.charAt(0) : k.key})`}
disabled={k.disable}
key={i}
active={store.selectIndex === i}
isShowChildren={this.props.keywordStore.m_ShowChildrenIndex === i}
onClick={(e: React.MouseEvent<HTMLElement, MouseEvent>) =>
{
if (k.children && k.children.length > 0)
{
e.preventDefault();
e.stopPropagation();
}
else
store._Return({
Status: PromptStatus.Keyword,
StringResult: k.key
});
}}
onMouseMove={() =>
{
store.selectIndex = i;
this.props.keywordStore.m_ShowChildrenIndex = i;
store.childSelectIndex = 0;
}}
>
{
k.children ? k.children.map((k1, i1) =>
<MenuItem
data-id="child"
text={k1.key === "" ? `${k1.msg}` : `${k1.msg}(${k1.key})`}
key={i1}
active={store.childSelectIndex === i1}
onClick={() =>
{
e.preventDefault();
e.stopPropagation();
}
else
store._Return({
Status: PromptStatus.Keyword,
StringResult: k.key
StringResult: k1.key === "" ? k1.msg : k1.key,
isChild: true,
Parent: k.msg
});
}}
onMouseMove={() =>
{
store.selectIndex = i;
this.props.keywordStore.m_ShowChildrenIndex = i;
store.childSelectIndex = 0;
}}
>
{
k.children ? k.children.map((k1, i1) =>
<MenuItem
data-id="child"
text={k1.key === "" ? `${k1.msg}` : `${k1.msg}(${k1.key})`}
key={i1}
active={store.childSelectIndex === i1}
onClick={() =>
{
store._Return({
Status: PromptStatus.Keyword,
StringResult: k1.key === "" ? k1.msg : k1.key,
isChild: true,
Parent: k.msg
});
}}
onMouseMove={() => { store.childSelectIndex = i1; }}
/>
)
: null
}
</MenuItem>
}
</React.Fragment>
}}
onMouseMove={() => { store.childSelectIndex = i1; }}
/>
)
: null
}
</MenuItem>
);
})
}

@ -11,10 +11,10 @@
import classNames from "classnames";
import * as React from "react";
import { ActionProps, Classes, DISPLAYNAME_PREFIX, Icon, IPopoverProps, LinkProps, Menu, Popover, PopoverInteractionKind, Position, Text } from "@blueprintjs/core";
import { Modifiers } from "popper.js";
import { IActionProps, ILinkProps, IPopoverProps, DISPLAYNAME_PREFIX, Classes, Icon, Popover, PopoverInteractionKind, Position, Menu, Text } from "@blueprintjs/core";
export interface IMenuItemProps extends IActionProps, ILinkProps
export interface IMenuItemProps extends ActionProps, LinkProps
{
// override from IActionProps to make it required
/** Item text, required for usability. */
@ -101,6 +101,7 @@ export class MenuItem extends React.PureComponent<IMenuItemProps & React.AnchorH
multiline,
popoverProps,
shouldDismissPopover,
isShowChildren,
text,
tagName = "a",
...htmlProps

@ -5,6 +5,9 @@ import { ColorMaterial } from '../../../Common/ColorPalette';
import { safeEval } from '../../../Common/eval';
import { Board_Editor_Key } from '../../Store/RightPanelStore/BoardEdgesEditor';
import { RightPanelStore } from '../../Store/RightPanelStore/RightPanelStore';
import { SealingStore } from '../../Store/RightPanelStore/SealingStore';
import { BoardModalType } from '../Board/BoardModalType';
import { UserConfig } from '../Board/UserConfig';
import { AppToaster } from '../Toaster';
@inject("store")
@ -13,17 +16,17 @@ export class SealingComponent extends React.Component<{ store?: RightPanelStore;
{
render()
{
const store = this.props.store.sealingStore;
let store = SealingStore.GetInstance();
return (
<>
<div className="modeing-config">
<ul className={"modeling " + Classes.LIST_UNSTYLED}>
<li>
<Label></Label>
<Label></Label>
</li>
{
store.highSizes.map((v, i) =>
store.option.highSizes.map((v, i) =>
{
return (
<li key={i}>
@ -46,13 +49,13 @@ export class SealingComponent extends React.Component<{ store?: RightPanelStore;
className={Classes.INPUT}
onChange={(e) =>
{
store.highSizes[i] = e.target.value;
store.option.highSizes[i] = e.target.value;
}}
onBlur={e =>
{
let val = safeEval(e.target.value);
if (isNaN(val))
store.highSizes[i] = "0";
store.option.highSizes[i] = "0";
}}
/>
</li>
@ -60,13 +63,17 @@ export class SealingComponent extends React.Component<{ store?: RightPanelStore;
})
}
</ul>
<div className="flex-arround">
<div className="flex-arround" style={{ marginBottom: 20 }}>
<Button text="写入" intent={Intent.SUCCESS}
onClick={this.ok} />
<Button text="退出" intent={Intent.DANGER}
onClick={this.exit} />
</div>
</>
<UserConfig
store={store}
type={BoardModalType.Sealing}
/>
</div>
);
}
private ok = () =>

@ -450,8 +450,20 @@ export class TempalteActionDialog extends React.Component<ITempalteActionDialogP
let brs = allEnts.filter(e => e instanceof Board) as Board[];
//#region
//ref sealingStore.ts 初始化曲线列表
let allSeals: Set<number> = new Set();
let sealStore = RightPanelStore.GetInstance().sealingStore;
let dataColorMap = new Map<string, number>();//data->color
let canUseColor: number[] = [];//可使用的颜色
let highSizes = sealStore.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 brs)
{
let cus = GetBoardSealingCurves(br, true);
@ -460,17 +472,42 @@ export class TempalteActionDialog extends React.Component<ITempalteActionDialogP
{
for (let i = 0; i < highseals.length; i++)
{
let sealData = highseals[i];
allSeals.add(sealData.size);
let color = [...allSeals].indexOf(sealData.size) + 1;
let s = highseals[i];
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;
sealStore.highSizes[color - 1] = sealData.size.toString();
}
}
else
{
allSeals.add(1);
let color = [...allSeals].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);
}

@ -22,7 +22,7 @@ export class RightPanelStore
@observable templateParamInputRefs: HTMLInputElement[] = [];
modelingStore = new ModelingStore();
lightStore = LightStore.GetInstance();
sealingStore = new SealingStore();
sealingStore = SealingStore.GetInstance();
drillingStore = new DrillingStore();
modeling2Store = new Modeling2Store();
modeling3Store = new Modeling2Store();

@ -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) });
}
}

Loading…
Cancel
Save