!2675 优化圆弧板配置功能

pull/2686/MERGE
黄诗津 6 months ago committed by ChenX
parent e77f8bff26
commit e664e481cf

@ -139,6 +139,7 @@ export class ArcBoardBuild
}
this._SweepLengths = this._SweepCurves1.map(c => c.Length);
return this;
}
get SweepLengths()

@ -181,6 +181,7 @@ export namespace CheckoutValid
case "divCount":
case "startDist":
case "endDist":
case "arcExtension":
{
let val = safeEval(v);
if (typeof v === "string" && v.includes(','))//v类型不是字符串时,这个代码出错了
@ -205,6 +206,9 @@ export namespace CheckoutValid
case "knifeRadius":
case "fzThickness":
case "fzWidth":
case "grooveSpacing":
case "grooveWidth":
case "retainedThickness":
{
let val = safeEval(v);
if (isNaN(val))
@ -245,7 +249,6 @@ export namespace CheckoutValid
case "grooveAddLength":
case "grooveAddDepth":
case "grooveAddWidth":
case "sweepAngle":
case "back":
{
let val = safeEval(v);
@ -263,6 +266,15 @@ export namespace CheckoutValid
return "绘制个数必须大于1且小于50!";
break;
}
case "sweepAngle":
{
let val = safeEval(v);
if (isNaN(val))
return "数值不能为空且必须为数字!";
if (val < 0 || val > 360)
return "角度区间为0—360!";
break;
}
}
return "";
}

@ -184,18 +184,16 @@ export class Board extends ExtrudeSolid
if (this._ArcBoardOptions.size > 0)
return this._ArcBoardOptions;
let cus = this._SweepPath.Explode();
let cus = new ArcBoardBuild(this).ParseSweepCurves().SweepCurves1;
//key=-1 为通用转角槽配置
this._ArcBoardOptions.set(-1, defultArcBoardOption);
for (let i = 0; i < cus.length; i++)
cus.forEach((cu, i) =>
{
if (cus[i] instanceof Arc)
{
this._ArcBoardOptions.set(i, { ...defultArcBoardOption, arcLength: parseFloat(FixedNotZero(cus[i].Length, 5)) });
}
}
if (cu instanceof Arc)
this._ArcBoardOptions.set(i, { ...defultArcBoardOption, arcLength: parseFloat(FixedNotZero(cu.Length, 5)) });
});
return this._ArcBoardOptions;
}
@ -203,9 +201,28 @@ export class Board extends ExtrudeSolid
{
this.WriteAllObjectRecord();
this._ArcBoardOptions = opt;
this.UpdateArcBoardOptions();
this.Update();
}
UpdateArcBoardOptions(): void
{
//更新ArcBuild曲线数据
this._SweepArcBoardBuild = new ArcBoardBuild(this).ParseSweepCurves();
let cus = this.GetSweepPathInWCS().Explode();
if (cus.filter(cu => cu instanceof Arc).length <= this._ArcBoardOptions.size - 1)
{
let newOpts = new Map<number, ArcBoardOptions>();
newOpts.set(-1, this._ArcBoardOptions.get(-1));
cus.forEach((cu, i) =>
{
if (cu instanceof Arc && this._ArcBoardOptions.has(i))
newOpts.set(i, { ...this._ArcBoardOptions.get(i), arcLength: parseFloat(FixedNotZero(cu.Length, 5)) });
});
this._ArcBoardOptions = newOpts;
}
}
get IsArcBoard()
{
return this._SweepPath != undefined;
@ -308,6 +325,7 @@ export class Board extends ExtrudeSolid
this._SweepPath = ArcBoardBuild.OffsetPolyline(path, this.thickness);
}
}
this.UpdateArcBoardOptions();
}
ParseBoardLengthInArcSweep(): number
@ -2901,7 +2919,7 @@ export class Board extends ExtrudeSolid
};
if (ver > 18)
opt.arcExtension = file.Read();
this.ArcBoardOptions.set(key, opt);
this._ArcBoardOptions.set(key, opt);
}
}
}

@ -70,7 +70,7 @@ export const ArcBoardOption = (observer(({ showCurveBoardOpt, arcBoardOptions, a
>
<div>
<Checkbox
style={{ marginRight: 7 }}
style={{ marginRight: 7, width: 70 }}
checked={!arcBoardConfig.isDrawArcGroove}
label="不开槽"
onChange={async () =>
@ -79,7 +79,12 @@ export const ArcBoardOption = (observer(({ showCurveBoardOpt, arcBoardOptions, a
}}
/>
</div>
<div style={{ display: "flex" }}>
<div
style={{
display: "flex",
maxWidth: 1000,
overflow: "scroll"
}}>
{
[...arcBoardOptions.entries()].map(([key, opt], i) =>
{
@ -90,7 +95,8 @@ export const ArcBoardOption = (observer(({ showCurveBoardOpt, arcBoardOptions, a
className="curveBoardOption"
style={{
padding: 5,
border: "1px solid #ccc"
border: "1px solid #ccc",
width: 160
}}>
<SetBoardDataItem
type={CheckObjectType.OnlyNumber}
@ -106,7 +112,7 @@ export const ArcBoardOption = (observer(({ showCurveBoardOpt, arcBoardOptions, a
let display = (i === 0 && index <= 2);
return (
<SetBoardDataItem
type={CheckObjectType.OnlyNumber}
type={CheckObjectType.BR}
isDisabled={display}
option={opt}
uiOption={UIArcBoardOptions.get(key)}

@ -3,7 +3,6 @@ import { IObservableValue, observable } from "mobx";
import { observer } from "mobx-react";
import * as React from 'react';
import { MathUtils, Matrix4, Scene, Vector3 } from "three";
import { ArcBoardBuild } from "../../../Add-on/ArcBoard/ArcBoardBuild";
import { ArcBoardOptions } from "../../../Add-on/ArcBoard/ArcBoardFeeding";
import { GetArcBoardParams, Path2BoardPath } from "../../../Add-on/ArcBoard/DrawArcBoard";
import { ExtrudeApplyContour, SelectExtrudeContour, selectOutlinePosition } from "../../../Add-on/DrawBoard/DrawSpecialShapeBoardTool";
@ -257,7 +256,7 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>
disabled={!canCurve.get()}
intent={Intent.PRIMARY}
text="应用"
onClick={this.ChangeCurveBoard}
onClick={this.ApplyCurveBoard}
/>
<label className="bp3-label bp3-inline .modifier">
<span style={{ width: 65 }}>:</span>
@ -791,12 +790,11 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>
app.Editor.MaskManage.Clear();
let br = this.props.br;
let build = new ArcBoardBuild(br);
build.ParseSweepCurves();
let pls = build.SweepCurves1.map(c => c.Clone());
let pl = Polyline.Combine(pls);
pl.ApplyMatrix(new Matrix4().makeRotationX(Math.PI / 2)).ApplyMatrix(br.OCS).ApplyMatrix(build.Rotate2OCSMtx);
let cu = JigUtils.Draw(pl);
let path = br.GetSweepPathInWCS().Clone();
//路径更新出错,数据和线对不上,再更新一下
path.Update();
path.ColorIndex = 7;
let cu = JigUtils.Draw(path);
await selectOutlinePosition(cu);
app.Editor.ModalManage.ToggleShow();
@ -806,7 +804,7 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>
}, "提取圆弧板曲线");
};
ChangeCurveBoard = async () =>
ApplyCurveBoard = async () =>
{
const DrawBoardByParams = async (br: Board, path1: Polyline, path2: Polyline, odir: number, faceRes: PromptPointResult) =>
{

@ -323,12 +323,19 @@ export function AddCommonBoardProps(Com: React.ComponentType<ICommonOptionProps>
board.ConverToRectSolid();
board.IsChaiDan = this.otherBoardData.isChaiDan;
board.ArcBoardOptions = this.arcBoardOptions;
board.SweepVisibleFace = this.arcBoardConfig.sweepVisibleFace;
board.SweepAngle = MathUtils.degToRad(this.arcBoardConfig.sweepAngle);
board.IsDrawArcGroove = this.arcBoardConfig.isDrawArcGroove;
if (!this.canCurve.get() && board.IsArcBoard)
board.ClearSweepPath();
if (board.IsArcBoard)
{
if (this.canCurve.get())
{
board.SweepVisibleFace = this.arcBoardConfig.sweepVisibleFace;
board.SweepAngle = MathUtils.degToRad(this.arcBoardConfig.sweepAngle);
board.IsDrawArcGroove = this.arcBoardConfig.isDrawArcGroove;
board.ArcBoardOptions = this.arcBoardOptions;
}
else
board.ClearSweepPath();
}
if (this.CurrentBoard.DrillLock != this.otherBoardData.isDrillLock)
{

@ -179,7 +179,7 @@
.curveBoardOption {
.br-set {
&>span {
>:first-child {
display: inline-block;
width: 7rem;
}

Loading…
Cancel
Save