!2626 优化:二维刀路深度能引用BH参数

pull/2606/MERGE
钱若寒 5 months ago committed by ChenX
parent 6f6547398b
commit 6fd5f09fa9

@ -113,6 +113,7 @@ export function SerializeBoard2DModeingData(file: CADFiler, modelList: I2DModeli
file.Write(item.knife.radius);
file.Write(item.knife.angle);
file.Write(item.knife.name);
file.Write(item.depthExpr);
}
}
}
@ -160,8 +161,17 @@ export function DeserializationBoard2DModeingData(file: CADFiler, data: I2DModel
let knifeRad = file.Read();
let knifeAngle = file.Read();
let knifeName = file.Read();
let depthExpr: string;
if (ver > 19)
{
depthExpr = file.Read();
}
else
{
depthExpr = depth.toString();
}
m.items.push({
depth, offset, knife: { id: knifeId, radius: knifeRad, angle: knifeAngle, name: knifeName }
depth, offset, knife: { id: knifeId, radius: knifeRad, angle: knifeAngle, name: knifeName }, depthExpr
});
}
data.push(m);

@ -23,6 +23,7 @@ export enum CheckObjectType
BMP = "batchmodifypanel",
BF = "boardFind",//查找修改
CONF = "configuration",//配置
Modeling2Depth = "modeling2Depth",// 大于0且支持BH
}
export namespace CheckoutValid
@ -135,6 +136,13 @@ export namespace CheckoutValid
let val = safeEval(v);
if (val < 0)
return "数值不能小于0";
case CheckObjectType.Modeling2Depth:
if (v === "")
return "数值不能为空";
if (isNaN(safeEval(v, { BH: 1 })))
return "表达式错误";
if (safeEval(v) < 0)
return "数值不能小于0";
default:
return "";
}

@ -17,6 +17,7 @@ import { Log, LogType } from '../../Common/Log';
import { TransformVector, tempMatrix1 } from '../../Common/Matrix4Utils';
import { UpdateDraw } from '../../Common/Status';
import { FixedNotZero } from '../../Common/Utils';
import { safeEval } from '../../Common/eval';
import { ObjectSnapMode } from '../../Editor/ObjectSnapMode';
import { SelectPick } from '../../Editor/SelectPick';
import { Board2DModelCSGBuilder } from '../../Geometry/Board2DModelCSG/Board2DModelCSGBuilder';
@ -80,6 +81,7 @@ export interface IKnifeInfo
export interface I2DModeingItem
{
depth: number;
depthExpr: string;
offset: number;
knife: IKnifeInfo;
}
@ -916,6 +918,18 @@ export class Board extends ExtrudeSolid
//二维刀路
get Modeling2D()
{
for (const m of this._2DModelingList)
{
for (const item of m.items)
{
let d = safeEval(item.depthExpr, { BH: this.thickness });
if (!isNaN(d) && d != item.depth)
{
item.depth = d;
}
}
}
return [...this._2DModelingList];
}
@ -2974,7 +2988,7 @@ export class Board extends ExtrudeSolid
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(19);
file.Write(20);
// file.Write(this._SpaceOCS.toArray()); ver < 6
file.Write(this._BoardType);
file.Write(this._Name);

@ -36,6 +36,7 @@ export class TempateThicknessAction extends TemplateAction
let br = id.Object as Board;
br.Clear2DPathCache();
br.Thickness += paramDiff;
if (d.Direction === ThicknessDirection.Back)
br.Position = br.Position.sub(br.Normal.multiplyScalar(paramDiff));

@ -18,7 +18,7 @@ import { NormalMatrix } from "../../../Common/Matrix4Utils";
import { PostJson, RequestStatus } from "../../../Common/Request";
import { toplineFileIn } from "../../../Common/SerializeMaterial";
import { FixedNotZero, GetEntity } from "../../../Common/Utils";
import { safeEval } from "../../../Common/eval";
import { CheckExpr, safeEval } from "../../../Common/eval";
import { inflateBase64 } from "../../../Common/inflate";
import { CADFiler } from "../../../DatabaseServices/CADFiler";
import { Contour } from "../../../DatabaseServices/Contour";
@ -565,10 +565,11 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>
for (let c of g)
{
let cd = rightStore.modeling2Store.modelingItems[c.ColorIndex - 1];//cd可能为空,因为颜色不受控制
if (!cd || cd.items.every(item => item.depth === 0) || cd.items.every(item => item.knife.id === ""))
if (!cd || cd.items.every(item => CheckExpr(item.depth as string, { BH: br.Thickness }).res <= 0)
|| cd.items.every(item => item.knife.id === ""))
{
AppToaster.show({
message: "部分颜色未设置深度或者刀具",
message: "部分颜色未设置深度或者刀具或者设置的值无效",
timeout: 5000,
intent: Intent.WARNING,
}, "unSetDepthKnife");
@ -1068,12 +1069,14 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>
path,
dir: cd.dir,
items: cd.items
.filter(item => item.depth > 0 && item.knife.id)
.filter(item => CheckExpr(item.depth as string, { BH: br.Thickness }).res > 0 && item.knife.id)
.map(
item =>
{
let result = CheckExpr(item.depth as string, { BH: br.Thickness });
return {
depth: item.depth,
depth: result.res,
depthExpr: item.depth.toString(),
offset: item.offset,
knife: {
angle: MathUtils.degToRad(item.knife.props.angle),

@ -368,6 +368,7 @@ export function AddCommonBoardProps(Com: React.ComponentType<ICommonOptionProps>
});
Log(`排钻关联解除锁定成功,共解除了${associationBoards.length}块板`, LogType.Info, [...associationBoards]);
}
board.Clear2DPathCache();
app.Editor.ModalManage.Destory();

@ -81,7 +81,7 @@ export class ModelingComponent2 extends React.Component<{ store?: Modeling2Store
}
{
!is3D && <ToasterInput
type={CheckObjectType.SmoothEdge}
type={CheckObjectType.Modeling2Depth}
optKey="depth"
option={d1items[i]}
uiOption={item}

@ -16,7 +16,7 @@ export interface IVModelingInfo
{
id: string;
offset: number;
depth: number;
depth: string;
knife: IKnifeInfo2;
}
type IUIVModelingInfo = Pick<IUiOption<IVModelingInfo>, "offset" | "depth">[];
@ -67,7 +67,7 @@ export class Modeling2Store implements IConfigStore
{
id: this.Id,
offset: 0,
depth: 0,
depth: '0',
knife: { id: "", name: "", props: { radius: 3, angle: 45 } }
}
]
@ -91,7 +91,7 @@ export class Modeling2Store implements IConfigStore
this.modelingItems[i].dir = FaceDirection.Front;
this.modelingItems[i].items.length = 1;
this.modelingItems[i].items[0].offset = 0;
this.modelingItems[i].items[0].depth = 0;
this.modelingItems[i].items[0].depth = '0';
this.modelingItems[i].items[0].knife.id = "";
this.modelingItems[i].items[0].knife.name = "";
@ -129,7 +129,7 @@ export class Modeling2Store implements IConfigStore
let newItems: IVModelingInfo[] = data.items.map(item => ({
id: this.Id,
offset: item.offset,
depth: item.depth,
depth: item.depthExpr,
knife: {
id: item.knife.id,
name: item.knife.name,
@ -150,7 +150,7 @@ export class Modeling2Store implements IConfigStore
id: this.Id,
dir: item.dir,
offset: 0,
depth: 0,
depth: '0',
knife: {
id: item.knife.id,
name: item.knife.name,
@ -205,6 +205,16 @@ export class Modeling2Store implements IConfigStore
@action
UpdateOption(cof: IConfigOption)
{
cof.option.forEach(option =>
{
option.items = option.items.map(item =>
{
if (typeof item.depth !== 'string')
return { ...item, depth: item.depth.toString() };
else
return item;
});
});
observable(this.modelingItems).replace(cof.option as IModeling2Item[]);
this.UpdateUIOption();
}

Loading…
Cancel
Save