修改LWH的表达式解析

pull/451/MERGE
ChenX 5 years ago
parent de9dbb3e2c
commit e1821be7f4

@ -1,11 +1,11 @@
import { DrawUprightWineRackTool } from "../../src/Add-on/DrawWineRack/DrawUprightWineRackTool";
import { Vector3 } from "three";
import { DrawBlisWineRackTool } from "../../src/Add-on/DrawWineRack/DrawBlisWineRackTool";
import { IWineRackOption, EWineRackType, EWRackArrayType, EFullType, EFullDir } from "../../src/UI/Store/WineRackInterface";
import { ISpaceParse } from "../../src/Geometry/SpaceParse/ISpaceParse";
import { Box3, Vector3, Matrix4 } from "three";
import { DrawUprightWineRackTool } from "../../src/Add-on/DrawWineRack/DrawUprightWineRackTool";
import { Board } from "../../src/DatabaseServices/Entity/Board";
import { Box3Ext } from "../../src/Geometry/Box";
import { ISpaceParse } from "../../src/Geometry/SpaceParse/ISpaceParse";
import { EFullDir, EFullType, EWineRackType, EWRackArrayType, IWineRackOption } from "../../src/UI/Store/WineRackInterface";
import { LoadEntityFromFileData } from "../Utils/LoadEntity.util";
import { Board } from "../../src/DatabaseServices/Entity/Board";
const UprightTool = DrawUprightWineRackTool.GetInstance() as DrawUprightWineRackTool;
const blisTool = DrawBlisWineRackTool.GetInstance() as DrawBlisWineRackTool;
@ -21,7 +21,7 @@ const option: IWineRackOption = {
isTotalDepth: true,
depth: 0,
gripWidth: 100,
calcDepth: "L",
calcDepth: "W",
boardThick: 18,
grooveWidthAdd: 0,
leftEdge: 1,

@ -30,10 +30,7 @@ export class DrawBehindBoard extends DrawBoardTool
if (opt.boardPosition === BehindHeightPositon.AllHeight)
height = size.z;
else
{
let lengthExpr = opt.calcHeight.replace(/["H"|"L"]/, size.z.toString());
height = eval(lengthExpr);
}
height = safeEval(opt.calcHeight, { L: size.x, W: size.y, H: size.z });
let moveDist = opt.moveDist;

@ -1,14 +1,15 @@
import { Matrix4, Vector3 } from 'three';
import { app } from '../../ApplicationServices/Application';
import { arrayLast } from '../../Common/ArrayExt';
import { safeEval } from '../../Common/eval';
import { GangDrill, GangDrillType } from '../../DatabaseServices/3DSolid/GangDrill';
import { Board, BoardType } from '../../DatabaseServices/Entity/Board';
import { ObjectId } from '../../DatabaseServices/ObjectId';
import { JigUtils } from '../../Editor/JigUtils';
import { MoveMatrix } from '../../Geometry/GeUtils';
import { BrRelativePos, LayerBoardOption } from '../../UI/Store/BoardInterface';
import { LayerBoardStore } from '../../UI/Store/BoardStore';
import { DrawBoardTool } from './DrawBoardTool';
import { ObjectId } from '../../DatabaseServices/ObjectId';
import { arrayLast } from '../../Common/ArrayExt';
import { JigUtils } from '../../Editor/JigUtils';
enum NailPos
{
@ -40,9 +41,7 @@ export class DrawLayerBoard extends DrawBoardTool
width = size.y;
else
{
//解析高度表达式
let heightExpr = opt.calcHeight.replace(/["H"|"L"]/, size.y.toString());
width = eval(heightExpr);
width = safeEval(opt.calcHeight, { L: size.x, W: size.y, H: size.z });
}
let count = opt.count;
let type = opt.boardRelative;

@ -1,10 +1,11 @@
import { Vector3 } from 'three';
import { app } from '../../ApplicationServices/Application';
import { safeEval } from '../../Common/eval';
import { Board, BoardType } from '../../DatabaseServices/Entity/Board';
import { JigUtils } from '../../Editor/JigUtils';
import { MoveMatrix } from '../../Geometry/GeUtils';
import { BrRelativePos, VerticalBoardOption } from '../../UI/Store/BoardInterface';
import { DrawBoardTool } from './DrawBoardTool';
import { JigUtils } from '../../Editor/JigUtils';
export class DrawVerticalBoard extends DrawBoardTool
{
@ -24,9 +25,7 @@ export class DrawVerticalBoard extends DrawBoardTool
width = size.y - frontShrink;
else
{
//解析宽度表达式
let widthExpr = opt.calcWidth.replace(/["H"|"L"]/, size.y.toString());
width = eval(widthExpr);
width = safeEval(opt.calcWidth, { L: size.x, W: size.y, H: size.z });
}
let length: number;
@ -34,8 +33,7 @@ export class DrawVerticalBoard extends DrawBoardTool
length = size.z - bottomShink;
else
{
let lengthExpr = opt.calcHeight.replace(/["H"|"L"]/, size.z.toString());
length = eval(lengthExpr);
length = safeEval(opt.calcHeight, { L: size.x, W: size.y, H: size.z });
}
let count = opt.count;

@ -1,10 +1,10 @@
import { Singleton } from "../../Common/Singleton";
import { ISpaceParse } from "../../Geometry/SpaceParse/ISpaceParse";
import { EWRackArrayType, EFullType, EFullDir, IWineRackOption } from "../../UI/Store/WineRackInterface";
import { Vector3 } from "three";
import { operationExpReg } from "../../Common/Utils";
import { safeEval } from "../../Common/eval";
import { Singleton } from "../../Common/Singleton";
import { Board, BoardType } from "../../DatabaseServices/Entity/Board";
import { IHighSealedItem, DrillType, FaceDirection } from "../../UI/Store/BoardInterface";
import { ISpaceParse } from "../../Geometry/SpaceParse/ISpaceParse";
import { DrillType, FaceDirection, IHighSealedItem } from "../../UI/Store/BoardInterface";
import { EFullDir, EFullType, EWRackArrayType, IWineRackOption } from "../../UI/Store/WineRackInterface";
export const SIN45 = Math.sin(Math.PI / 4);
@ -25,14 +25,10 @@ export class DrawWineRackTool extends Singleton
//处理格子深
if (!config.isTotalDepth)
{
let calcDepth = config.calcDepth.replace("L", space.Size.y.toString());
if (operationExpReg.test(calcDepth))
let depth = safeEval(config.calcDepth, { L: space.Size.x, W: space.Size.y, H: space.Size.z });;
if (!isNaN(depth))
{
let depth = eval(calcDepth);
if (depth)
{
space.m_SpaceBox.max.setY(space.m_SpaceBox.min.y + depth);
}
space.m_SpaceBox.max.setY(space.m_SpaceBox.min.y + depth);
}
}
//处理前缩
@ -159,4 +155,3 @@ export class DrawWineRackTool extends Singleton
}
}
}

@ -3,8 +3,6 @@ import { Entity } from "../DatabaseServices/Entity/Entity";
import { equaln } from "../Geometry/GeUtils";
import { safeEval } from "./eval";
//四则运算表达式正则
export const operationExpReg = /^(\d+([.]\d)?)+([+|\-|*|/](\d+([.]\d)?))*$/;
export const commandReg = /[^A-Za-z0-9]/g;
//仅可输入英文
export const onlyEnExpReg = /[^A-Za-z]/g;

@ -34,7 +34,7 @@ export class TemplateWineRackRecord extends TemplateRecord
isTotalDepth: true,
depth: 0,
gripWidth: 100,
calcDepth: "L",
calcDepth: "W",
boardThick: 18,
grooveWidthAdd: 0,
leftEdge: 1,

@ -28,7 +28,7 @@ export const LayerBoardModal =
<Checkbox checked={brOpt.isTotalLength} className="widthHalf" label="总深" onChange={() =>
{
brOpt.isTotalLength = !brOpt.isTotalLength;
uiOption["calcHeight"] = brOpt.isTotalLength ? "L" : uiOption["calcHeight"];
uiOption["calcHeight"] = brOpt.isTotalLength ? "W" : uiOption["calcHeight"];
}} />
<Checkbox checked={brOpt.isActive} label="活动" className="widthHalf" onChange={() =>
{
@ -40,8 +40,8 @@ export const LayerBoardModal =
brOpt.leftShrink = 1;
brOpt.rightShrink = 1;
brOpt.isTotalLength = false;
uiOption['calcHeight'] = "L-1";
brOpt.calcHeight = "L-1";
uiOption['calcHeight'] = "W-1";
brOpt.calcHeight = "W-1";
}
else
{

@ -196,8 +196,8 @@ export class WineRackModal extends React.Component<{ store?: WineRackStore }, {}
m_Option.isTotalDepth = !m_Option.isTotalDepth;
if (m_Option.isTotalDepth)
{
m_Option.calcDepth = "L";
UIOption.calcDepth = "L";
m_Option.calcDepth = "W";
UIOption.calcDepth = "W";
}
}} />
</div>

@ -277,7 +277,7 @@ export class LayerBoardStore extends BoardStore
frontShrink: 0,
leftShrink: 0,
rightShrink: 0,
calcHeight: "L",
calcHeight: "W",
isTotalLength: true,
boardRelative: BrRelativePos.Div,
thickness: 18,
@ -346,7 +346,7 @@ export class VerticalBoardStore extends BoardStore
name: "立板",
frontShrink: 0,
bottomShrink: 0,
calcWidth: "L",
calcWidth: "W",
calcHeight: "H",
isTotalLength: true,
isTotalWidth: true,

@ -19,7 +19,7 @@ export class WineRackStore extends BoardStore
isTotalDepth: true,
depth: 0,
gripWidth: 100,
calcDepth: "L",
calcDepth: "W",
boardThick: 18,
grooveWidthAdd: 0,
leftEdge: 1,

Loading…
Cancel
Save