!1087 功能:参数化板件绘制

pull/1087/MERGE
ZoeLeeFZ 4 years ago committed by ChenX
parent 68c5043e99
commit 00dd1f67d3

@ -5,6 +5,7 @@ import { TemplateRecord } from "../../DatabaseServices/Template/TemplateRecord";
import { MoveMatrix } from "../../Geometry/GeUtils";
import { ISpaceParse } from "../../Geometry/SpaceParse/ISpaceParse";
import { BehindBoardOption, BehindHeightPositon, BrRelativePos, IGrooveOption, LayerBoardOption, VerticalBoardOption, BoardType } from "../../UI/Store/BoardInterface";
import { Log } from "../../Common/Log";
export function BuildLayerBoards(opt: LayerBoardOption, space: ISpaceParse): Board[]
{
@ -21,15 +22,26 @@ export function BuildLayerBoards(opt: LayerBoardOption, space: ISpaceParse): Boa
}
let count = opt.count;
let type = opt.boardRelative;
let spaceSize = opt.spaceSize;
let frontShrink = opt.frontShrink;
let spaceSize = safeEval(opt.calcSpaceSize, { L: size.x, W: size.y, H: size.z });
let frontShrink = safeEval(opt.calcFrontShrink, { L: size.x, W: size.y, H: size.z });
width -= frontShrink;
let leftShrink = opt.leftShrink;
let rightShrink = opt.rightShrink;
if (width <= 0)
{
Log("宽度无效,可能前缩过大,请修正");
return [];
}
let leftShrink = safeEval(opt.calcLeftShrink, { L: size.x, W: size.y, H: size.z });
let rightShrink = safeEval(opt.calcRightShrink, { L: size.x, W: size.y, H: size.z });
let thickness = opt.thickness;
let len = size.x - leftShrink - rightShrink;
if (len <= 0)
{
Log("长度无效,可能左缩右缩过大,请修正");
return [];
}
let board = Board.CreateBoard(len, width, thickness, BoardType.Layer);
opt.height = len;
opt.width = width;
@ -73,8 +85,8 @@ export function BuildVerticalBoards(opt: VerticalBoardOption, space: ISpaceParse
const spaceOCS = space.SpaceOCS;
let size = spaceBox.getSize(new Vector3());
let frontShrink = opt.frontShrink;
let bottomShink = opt.bottomShrink;
let frontShrink = safeEval(opt.calcFrontShrink, { L: size.x, W: size.y, H: size.z });
let bottomShink = safeEval(opt.calcBottomShrink, { L: size.x, W: size.y, H: size.z });
let width: number;
if (opt.isTotalWidth)
@ -84,6 +96,12 @@ export function BuildVerticalBoards(opt: VerticalBoardOption, space: ISpaceParse
width = safeEval(opt.calcWidth, { L: size.x, W: size.y, H: size.z });
}
if (width <= 0)
{
Log("宽度无效,可能前缩过大,请修正");
return [];
}
let length: number;
if (opt.isTotalLength)
length = size.z - bottomShink;
@ -94,7 +112,7 @@ export function BuildVerticalBoards(opt: VerticalBoardOption, space: ISpaceParse
let count = opt.count;
let type = opt.boardRelative;
let spaceSize = opt.spaceSize;
let spaceSize = safeEval(opt.calcSpaceSize, { L: size.x, W: size.y, H: size.z });
let thickness = opt.thickness;
let board = Board.CreateBoard(length, width, thickness, BoardType.Vertical);
@ -150,7 +168,7 @@ export function BuildBehindBoards(opt: BehindBoardOption, space: ISpaceParse, gr
else
height = safeEval(opt.calcHeight, { L: size.x, W: size.y, H: size.z });
let moveDist = opt.moveDist;
let moveDist = safeEval(opt.calcMoveDist, { L: size.x, W: size.y, H: size.z });
//判断背板位置,更新背板高度
switch (opt.boardPosition)
@ -169,7 +187,7 @@ export function BuildBehindBoards(opt: BehindBoardOption, space: ISpaceParse, gr
//相对位置
let relPos = opt.boardRelative;
//单层空间宽度
let spaceSize = opt.spaceSize;
let spaceSize = safeEval(opt.calcSpaceSize, { L: size.x, W: size.y, H: size.z });
let thickness = opt.thickness;
let board = Board.CreateBoard(height, size.x, thickness, BoardType.Behind);

@ -134,7 +134,7 @@ export class DrawWineRackTool extends Singleton
}
if (config.isDrawVer && (config.arrayType === EWRackArrayType.Fixed || config.fullType === EFullType.ByHeight))
{
let len = actHeight;
let len = actHeight + config.topCut;
if (isDrawLy)
len += config.brThick2;

@ -3,15 +3,12 @@ import { IBaseOption, IGrooveOption, IUiOption } from "../../UI/Store/BoardInter
import { CheckoutValid, CheckObjectType } from "../../Common/CheckoutVaildValue";
import { DataAdapter } from "../../Common/DataAdapter";
import { TemplateRecord } from "../../DatabaseServices/Template/TemplateRecord";
import { observable } from "mobx";
import { EBoardKeyList } from "../../Common/BoardKeyList";
import { IConfigOption } from "../../UI/Components/Board/UserConfig";
import { updateBoardInfoStore } from "../../UI/Store/UpdateBoardInfoStore";
export class Rec2BrStore extends BoardStore
export class Rec2BrStore extends BoardStore<IRec2BrOption>
{
@observable m_Option: IRec2BrOption;
protected m_UiOption: IUiOption<IRec2BrOption>;
constructor()
{
super();

@ -129,6 +129,12 @@ export namespace CheckoutValid
{
case "calcHeight":
case "calcWidth":
case "calcSpaceSize":
case "calcFrontShrink":
case "calcBottomShrink":
case "calcLeftShrink":
case "calcRightShrink":
case "calcMoveDist":
if (isNaN(safeEval(v, { L: 1, H: 1, W: 1 })))
return "表达式错误";
return "";

@ -9,7 +9,7 @@ import { Curve2RecOption } from "../Add-on/twoD2threeD/Modals/Curve2RecModal";
import { IUpdateBoardInfosOption } from "../UI/Components/Board/UpdateBoardInfointerface";
export const DefaultLayerBoardConfig: LayerBoardOption = {
version: 1,
version: 2,
type: BoardType.Layer,
name: "层板",
frontShrink: 0,
@ -21,7 +21,11 @@ export const DefaultLayerBoardConfig: LayerBoardOption = {
thickness: 18,
count: 1,
spaceSize: 300,
isActive: false
isActive: false,
calcSpaceSize: "0",
calcFrontShrink: "0",
calcLeftShrink: "0",
calcRightShrink: "0",
};
Object.freeze(DefaultLayerBoardConfig);
@ -37,12 +41,12 @@ export const DefaultLayerNailOption: LayerNailOption = {
count: 2,
rad: 5,
length: 34,
depth: 13.5
depth: 13.5,
};
Object.freeze(DefaultLayerNailOption);
export const DefaultVerticalBoardConfig: VerticalBoardOption = {
version: 1,
version: 2,
type: BoardType.Vertical,
name: "立板",
frontShrink: 0,
@ -54,12 +58,15 @@ export const DefaultVerticalBoardConfig: VerticalBoardOption = {
boardRelative: BrRelativePos.Div,
thickness: 18,
count: 1,
spaceSize: 0
spaceSize: 0,
calcSpaceSize: "0",
calcBottomShrink: "0",
calcFrontShrink: "0",
};
Object.freeze(DefaultVerticalBoardConfig);
export const DefaultBehindBoardConfig: BehindBoardOption = {
version: 1,
version: 2,
type: BoardType.Behind,
name: "背板",
leftExt: 0,
@ -72,7 +79,9 @@ export const DefaultBehindBoardConfig: BehindBoardOption = {
moveDist: 0,
boardRelative: BrRelativePos.Back,
spaceSize: 0,
count: 1
count: 1,
calcSpaceSize: "0",
calcMoveDist: "0",
};
Object.freeze(DefaultBehindBoardConfig);

@ -66,11 +66,11 @@ export class BehindBoardModal extends React.Component<{ store?: BehindBoardStore
else
{
store.m_Option.calcHeight = "H";
store.UIOption["calcHeight"] = "H";
store.UIOption.calcHeight = "H";
}
}}
selectedValue={store.UIOption["boardPosition"]}
selectedValue={store.UIOption.boardPosition}
>
<Radio label="总高" value={BehindHeightPositon.AllHeight} />
<Radio label="靠上" value={BehindHeightPositon.ForTop} />
@ -83,15 +83,14 @@ export class BehindBoardModal extends React.Component<{ store?: BehindBoardStore
option={store.m_Option}
uiOption={store.UIOption}
title="板高"
isDisabled={store.UIOption["boardPosition"] === BehindHeightPositon.AllHeight}
isDisabled={store.UIOption.boardPosition === BehindHeightPositon.AllHeight}
/>
<SetBoardDataItem
type={CheckObjectType.BR}
optKey="moveDist"
optKey="calcMoveDist"
option={store.m_Option}
uiOption={store.UIOption}
title={this.moveDir}
isDisabled={store.UIOption["boardPosition"] === BehindHeightPositon.AllHeight}
isDisabled={store.UIOption.boardPosition === BehindHeightPositon.AllHeight}
/>
</div>
</div>
@ -141,4 +140,3 @@ export class BehindBoardModal extends React.Component<{ store?: BehindBoardStore
);
}
}

@ -54,12 +54,7 @@ interface TBProps
uiOption: Object;
istop: boolean;
}
interface BroadPosProps
{
uiOption: Object;
option: IBaseOption;
posPars: [BrRelativePos, string][];
}
//设置板件数据组件
@observer
export class SetBoardDataItem extends React.Component<ISetItemOption, {}>
@ -173,21 +168,32 @@ export const BoardDirectionIcon = () =>
<span className="arrow arrowbottom"></span>
</label>;
type ISpaceProps = { calcSpaceSize: string, spaceSize?: number, count?: number, thickness?: number; boardRelative?: BrRelativePos; };
interface BroadPosProps
{
uiOption: IUiOption<ISpaceProps>;
option: ISpaceProps;
posPars: [BrRelativePos, string][];
}
@observer
export class BoardRePosBlock extends React.Component<BroadPosProps> {
private pars =
[["spaceSize", "空间"], ["count", "板数"], ["thickness", "板厚"]];
[["calcSpaceSize", "空间"], ["count", "板数"], ["thickness", "板厚"]];
private spaceSizeInputEl: HTMLInputElement;
private countInputEl: HTMLInputElement;
private updateFocus = (k: string) =>
{
if (k === "spaceSize"
&& this.props.option["boardRelative"] !== BrRelativePos.Div)
if (!this.spaceSizeInputEl)
return;
if (k === "calcSpaceSize"
&& this.props.option.boardRelative !== BrRelativePos.Div)
{
this.spaceSizeInputEl.focus();
this.spaceSizeInputEl.setSelectionRange(0, this.spaceSizeInputEl.value.length);
}
else if (k === 'count' && this.props.option["boardRelative"] === BrRelativePos.Div)
else if (k === 'count' && this.props.option.boardRelative === BrRelativePos.Div)
{
this.countInputEl.focus();
this.countInputEl.setSelectionRange(0, this.spaceSizeInputEl.value.length);
@ -196,15 +202,15 @@ export class BoardRePosBlock extends React.Component<BroadPosProps> {
private handleChangePos = (e) =>
{
let value = e.currentTarget.value as BrRelativePos;
this.props.option["boardRelative"] = value;
this.props.option.boardRelative = value;
setTimeout(() =>
{
if (value !== BrRelativePos.Div)
{
this.spaceSizeInputEl.focus();
this.spaceSizeInputEl.setSelectionRange(0, this.spaceSizeInputEl.value.length);
this.props.option["count"] = 1;
this.props.uiOption["count"] = 1;
this.props.option.count = 1;
this.props.uiOption.count = "1";
}
else
{
@ -221,7 +227,7 @@ export class BoardRePosBlock extends React.Component<BroadPosProps> {
<RadioGroup
className="boardRadio"
onChange={this.handleChangePos}
selectedValue={this.props.option["boardRelative"]}
selectedValue={this.props.option.boardRelative}
>
{
this.props.posPars.map(([k, v], i) =>
@ -236,7 +242,7 @@ export class BoardRePosBlock extends React.Component<BroadPosProps> {
<SetBoardDataItem
inputRef={el =>
{
if (k === "spaceSize")
if (k === "calcSpaceSize")
this.spaceSizeInputEl = el;
else if (k === 'count')
this.countInputEl = el;
@ -247,8 +253,7 @@ export class BoardRePosBlock extends React.Component<BroadPosProps> {
uiOption={this.props.uiOption}
option={this.props.option}
title={v}
isDisabled={(k === "spaceSize" && this.props.option["boardRelative"] === BrRelativePos.Div)}
// update={() => this.updateFocus(k)}
isDisabled={(k === "calcSpaceSize" && this.props.option.boardRelative === BrRelativePos.Div)}
mounted={() => this.updateFocus(k)}
/>
)

@ -27,7 +27,7 @@ export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore;
};
UNSAFE_componentWillMount()
{
this.uiOption = this.props.store.UIOption;
this.uiOption = this.props.store.UIOption as IUiOption<IDoorConfigOption & IDrawerConfigOption>;
this.isDoor = this.props.store instanceof DoorStore;
}
render()

@ -9,7 +9,7 @@ import { CheckObjectType } from '../../../Common/CheckoutVaildValue';
export const LayerBoardModal =
(observer((props: { store?: LayerBoardStore; }) =>
{
const scalePars = [["frontShrink", "前缩"], ["leftShrink", "左缩"], ["calcHeight", "板深"], ["rightShrink", "右缩"]];
const scalePars = [["calcFrontShrink", "前缩"], ["calcLeftShrink", "左缩"], ["calcHeight", "板深"], ["calcRightShrink", "右缩"]];
const nailPars1 = [["addCount", "增"], ["dist", "距离"]];
const nailPars2 = [["front", "前边"], ["behind", "后边"], ["count", "个数"], ["rad", "半径"], ["length", "长度"], ["depth", "深度"]];

@ -10,7 +10,7 @@ export const VerticalBoardModal =
(observer((props: { store?: VerticalBoardStore; }) =>
{
const store = props.store;
const scalePars = [["frontShrink", "前缩"], ["bottomShrink", "位高"], ["calcWidth", "板深"], ["calcHeight", "板高"]];
const scalePars = [["calcFrontShrink", "前缩"], ["calcBottomShrink", "位高"], ["calcWidth", "板深"], ["calcHeight", "板高"]];
const brOpt = store.m_Option;
const uiOption = props.store.UIOption;

@ -22,7 +22,7 @@ interface IRotateLayerBoardOption extends IBaseOption
frontDist: number;
backDist: number;
}
export class RotateLayerBoardStore extends BoardStore
export class RotateLayerBoardStore extends BoardStore<IRotateLayerBoardOption>
{
@observable m_Option: IRotateLayerBoardOption = {
angle: 15,

@ -6,7 +6,7 @@ import { observable, toJS } from "mobx";
import { IConfigOption } from "../Components/Board/UserConfig";
import { CheckoutValid, CheckObjectType } from "../../Common/CheckoutVaildValue";
export class ActivityLayerBoardStore extends BoardStore
export class ActivityLayerBoardStore extends BoardStore<IShinkOption>
{
@observable m_Option: IShinkOption = {
front: 1,

@ -156,6 +156,8 @@ export interface BehindBoardOption extends BoardConfigOption
//板件相对位置
boardRelative?: BrRelativePos;
calcHeight: string;//高度表达式
calcSpaceSize: string;
calcMoveDist: string;
}
/**
@ -176,6 +178,10 @@ export interface LayerBoardOption extends BoardConfigOption
spaceSize?: number;
count?: number;
boardRelative?: BrRelativePos;
calcSpaceSize: string;
calcFrontShrink: string;
calcLeftShrink: string;
calcRightShrink: string;
}
/**
@ -197,15 +203,10 @@ export interface LayerNailOption extends IBaseOption
rad: number;
length: number;
depth: number;
}
/**
*
*
* @export
* @interface VerticalBoardOption
* @extends {BoardConfigOption}
*/
export interface VerticalBoardOption extends BoardConfigOption
{
@ -218,6 +219,9 @@ export interface VerticalBoardOption extends BoardConfigOption
boardRelative?: BrRelativePos;
calcWidth: string; //板深表达式
calcHeight: string;
calcSpaceSize: string;
calcFrontShrink: string;
calcBottomShrink: string;
}
export interface TBBoardOption extends BoardConfigOption
{

@ -30,13 +30,13 @@ export interface IConfigStore
EditorTemplate?: TemplateRecord;
}
export class BoardStore extends Singleton implements IConfigStore
export class BoardStore<T = IBaseOption> extends Singleton implements IConfigStore
{
@observable configName = "默认";
@observable configsNames: string[] = [];
EditorTemplate: TemplateRecord;
m_Option: IBaseOption;
protected m_UiOption;
m_Option: T;
protected m_UiOption: IUiOption<T>;
readonly title: string;
@observable UseBoardProcessOption = true;
@observable m_BoardProcessOption: BoardProcessOption = { ...DefaultBoardProcessOption };
@ -101,7 +101,7 @@ export class BoardStore extends Singleton implements IConfigStore
this.rectDrillOption.left = highDrill[3];
}
}
get UIOption()
get UIOption(): IUiOption<T>
{
if (!this.m_UiOption)
this.m_UiOption = DataAdapter.ConvertUIData(this.m_Option);
@ -217,7 +217,7 @@ export class BoardStore extends Singleton implements IConfigStore
}
}
export class SideBoardStore extends BoardStore
export class SideBoardStore extends BoardStore<SideBoardOption>
{
//板数据
@observable m_Option: SideBoardOption = Object.assign({}, DefaultSideBoardOption);
@ -334,7 +334,7 @@ export class TopBottomBoardStore extends BoardStore
}
export class BehindBoardStore extends BoardStore
export class BehindBoardStore extends BoardStore<BehindBoardOption>
{
title = "背板";
@observable m_Option: BehindBoardOption = Object.assign({}, DefaultBehindBoardConfig);
@ -368,8 +368,14 @@ export class BehindBoardStore extends BoardStore
newConfig.grooveData = toJS(this.grooveOption);
return newConfig;
}
UpdateOption(cof: IConfigOption)
UpdateOption(cof: IConfigOption<BehindBoardOption>)
{
if (cof.option.version < 2)
{
cof.option.calcSpaceSize = cof.option.spaceSize.toString();
cof.option.calcMoveDist = cof.option.moveDist.toString();
cof.option.version = 2;
}
super.UpdateOption(cof);
Object.assign(this.grooveOption, cof.grooveData);
}
@ -379,7 +385,7 @@ export class BehindBoardStore extends BoardStore
}
}
export class LayerBoardStore extends BoardStore
export class LayerBoardStore extends BoardStore<LayerBoardOption>
{
title = "层板";
@observable m_Option: LayerBoardOption = Object.assign({}, DefaultLayerBoardConfig);
@ -416,8 +422,24 @@ export class LayerBoardStore extends BoardStore
newConfig.nailData = toJS(this.layerNailOption);
return newConfig;
}
UpdateOption(cof: IConfigOption)
UpdateOption(cof: IConfigOption<LayerBoardOption>)
{
if (this.m_Option.version === undefined)
{
cof.option.version = 1;
if (cof.option.calcHeight === "L")
{
cof.option.calcHeight = "W";
}
}
else if (cof.option.version < 2)
{
cof.option.calcSpaceSize = cof.option.spaceSize.toString();
cof.option.calcLeftShrink = cof.option.leftShrink.toString();
cof.option.calcRightShrink = cof.option.rightShrink.toString();
cof.option.calcFrontShrink = cof.option.frontShrink.toString();
cof.option.version = 2;
}
super.UpdateOption(cof);
if (!cof.nailData)
cof.nailData = this.layerNailOption;
@ -426,15 +448,8 @@ export class LayerBoardStore extends BoardStore
if (this.uiLayerNailOption)
Object.assign(this.uiLayerNailOption, DataAdapter.ConvertUIData(this.layerNailOption));
if (this.m_Option.version === undefined)
{
this.m_Option.version = 1;
if (this.m_Option.calcHeight === "L")
{
this.m_Option.calcHeight = "W";
this.UIOption.calcHeight = "W";
}
}
}
HasInvailValue()
{
@ -442,7 +457,7 @@ export class LayerBoardStore extends BoardStore
}
}
export class VerticalBoardStore extends BoardStore
export class VerticalBoardStore extends BoardStore<VerticalBoardOption>
{
title = "立板";
@ -453,9 +468,20 @@ export class VerticalBoardStore extends BoardStore
Object.assign(this.m_Option, DefaultVerticalBoardConfig);
super.InitOption();
}
UpdateOption(cof: IConfigOption<VerticalBoardOption>)
{
if (cof.option.version < 2)
{
cof.option.calcSpaceSize = cof.option.spaceSize.toString();
cof.option.calcFrontShrink = cof.option.frontShrink.toString();
cof.option.calcBottomShrink = cof.option.bottomShrink.toString();
cof.option.version = 2;
}
super.UpdateOption(cof);
}
}
export class SingleBoardStore extends BoardStore
export class SingleBoardStore extends BoardStore<SingleBoardOption>
{
title = "单板";
@observable m_Option: SingleBoardOption = {
@ -476,7 +502,7 @@ export class SingleBoardStore extends BoardStore
super.InitOption();
}
}
export class ClosingStripStore extends BoardStore
export class ClosingStripStore extends BoardStore<ClosingStripOption>
{
title = "收口条";
@observable m_Option: ClosingStripOption = {
@ -530,7 +556,7 @@ export class ClosingStripStore extends BoardStore
super.UpdateOption(cof);
}
}
export class SpecialShapeStore extends BoardStore
export class SpecialShapeStore extends BoardStore<BoardConfigOption>
{
title = "绘制异型板";
@observable m_Option: BoardConfigOption = {

@ -16,7 +16,7 @@ const DIVRegExpr = /((\d+(\.\d)?)\*)?D(\*\d+(\.\d)?)?/g;
type IDoorDrawer = IDoorInfo | IDrawerInfo;
export class DoorDrawerStore extends BoardStore
export class DoorDrawerStore extends BoardStore<IDoorAndDrawerConfigOption>
{
m_Option: IDoorAndDrawerConfigOption;
protected m_UiOption: IUiOption<IDoorAndDrawerConfigOption>;

@ -4,11 +4,16 @@ import { DoorDrawerStore } from "./DoorDrawerStore";
import { DefaultDrawerOption } from "../../../Editor/DefaultConfig";
import { IConfigOption } from "../../Components/Board/UserConfig";
import { FixErrorDataConfig } from "../BoardStore";
import { IUiOption } from "../BoardInterface";
import { safeEval } from "../../../Common/eval";
export class DrawerStore extends DoorDrawerStore
{
title = "抽屉";
@observable m_Option: IDrawerConfigOption = { ...DefaultDrawerOption };
get UIOption()
{
return super.UIOption as IUiOption<IDrawerConfigOption>;
}
InitInfos()
{
let row = this.m_Option.row;

@ -7,7 +7,7 @@ import { IConfigOption } from "../Components/Board/UserConfig";
import { BoardStore } from "./BoardStore";
import { IWineRackOption } from "./WineRackInterface";
export class WineRackStore extends BoardStore
export class WineRackStore extends BoardStore<IWineRackOption>
{
EditorTemplate: TemplateWineRackRecord;
@observable m_Option: IWineRackOption = Object.assign({}, DefaultWineRackConfig);

Loading…
Cancel
Save