|
|
|
@ -20,7 +20,7 @@ import { Arc } from "../../../DatabaseServices/Entity/Arc";
|
|
|
|
|
import { Board, I2DModeling, I3DModeling, IPathItem } from "../../../DatabaseServices/Entity/Board";
|
|
|
|
|
import { Circle } from "../../../DatabaseServices/Entity/Circle";
|
|
|
|
|
import { Curve } from "../../../DatabaseServices/Entity/Curve";
|
|
|
|
|
import { ExtrudeSolid } from "../../../DatabaseServices/Entity/Extrude";
|
|
|
|
|
import { ExtrudeContour, ExtrudeSolid } from "../../../DatabaseServices/Entity/Extrude";
|
|
|
|
|
import { Line } from "../../../DatabaseServices/Entity/Line";
|
|
|
|
|
import { Polyline } from "../../../DatabaseServices/Entity/Polyline";
|
|
|
|
|
import { Region } from "../../../DatabaseServices/Entity/Region";
|
|
|
|
@ -30,7 +30,7 @@ import { PromptStatus } from "../../../Editor/PromptResult";
|
|
|
|
|
import { SelectBox, SelectType } from "../../../Editor/SelectBox";
|
|
|
|
|
import { CreateContours } from "../../../Geometry/CreateContour2";
|
|
|
|
|
import { ContourTreeNode } from "../../../Geometry/ExtrudeMeshGeomBuilder/ExtrudeEdgeGeometry2";
|
|
|
|
|
import { AsVector2, MoveMatrix, equaln, isParallelTo } from "../../../Geometry/GeUtils";
|
|
|
|
|
import { AsVector2, IdentityMtx4, MoveMatrix, ZAxisN, equaln, isParallelTo } from "../../../Geometry/GeUtils";
|
|
|
|
|
import { BoardProcessOption } from "../../Store/OptionInterface/BoardProcessOption";
|
|
|
|
|
import { BoardConfigOption, IGrooveOption, IUiOption } from "../../Store/OptionInterface/IOptionInterface";
|
|
|
|
|
import { RightPanelStore } from "../../Store/RightPanelStore/RightPanelStore";
|
|
|
|
@ -53,7 +53,7 @@ interface BoardConfigProps
|
|
|
|
|
uiBoardConfig: IUiOption<BoardConfigOption>;
|
|
|
|
|
isRightToolbar?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const EDITOR_2D_PATH = "editor2dpath";
|
|
|
|
|
const EDITOR_3D_PATH = "editor3dpath";
|
|
|
|
|
|
|
|
|
|
@observer
|
|
|
|
@ -144,7 +144,7 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
|
|
|
|
|
<div>
|
|
|
|
|
<Checkbox
|
|
|
|
|
style={{
|
|
|
|
|
marginRight: 10
|
|
|
|
|
marginRight: 7
|
|
|
|
|
}}
|
|
|
|
|
checked={canDrawSpeical.get()}
|
|
|
|
|
label="异型"
|
|
|
|
@ -153,7 +153,7 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
|
|
|
|
|
/>
|
|
|
|
|
<Checkbox
|
|
|
|
|
style={{
|
|
|
|
|
marginRight: 10
|
|
|
|
|
marginRight: 7
|
|
|
|
|
}}
|
|
|
|
|
checked={canModeling.get()}
|
|
|
|
|
label="造型"
|
|
|
|
@ -171,16 +171,12 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
|
|
|
|
|
text="修改" />
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex">
|
|
|
|
|
<div style={{ marginRight: 5 }}>
|
|
|
|
|
<div style={{ marginRight: 10 }}>
|
|
|
|
|
<Button
|
|
|
|
|
intent={Intent.PRIMARY}
|
|
|
|
|
text="二维刀路"
|
|
|
|
|
onClick={this.PickUpModelingOutline2}
|
|
|
|
|
/>
|
|
|
|
|
<Button
|
|
|
|
|
intent={Intent.PRIMARY}
|
|
|
|
|
onClick={this.ChangeModeling2}
|
|
|
|
|
text="修改" />
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<Button
|
|
|
|
@ -324,56 +320,172 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
|
|
|
|
|
}
|
|
|
|
|
}, "_pick");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_RenderToasterMessage = (brCurve: ExtrudeContour) =>
|
|
|
|
|
{
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex-between toaster-message">
|
|
|
|
|
<span>正在编辑二维刀路</span>
|
|
|
|
|
<div>
|
|
|
|
|
<Button text="保存" minimal onClick={() => { this.ChangeModeling2(brCurve); }} />
|
|
|
|
|
<Button text="取消" minimal onClick={() => { AppToaster.clear(); }} />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//提取二维刀路到编辑模式
|
|
|
|
|
PickUpModelingOutline2 = async () =>
|
|
|
|
|
{
|
|
|
|
|
await app.Editor.ModalManage.EndExecingCmd();
|
|
|
|
|
CommandWrap(async () =>
|
|
|
|
|
if (TempEditor.EditorIng)
|
|
|
|
|
{
|
|
|
|
|
app.Editor.SelectCtrl.Cancel();
|
|
|
|
|
app.Editor.ModalManage.ToggleShow();
|
|
|
|
|
app.Editor.MaskManage.Clear();
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
message: "请先退出编辑模式...",
|
|
|
|
|
timeout: 3000,
|
|
|
|
|
intent: Intent.DANGER,
|
|
|
|
|
}, "error");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TempEditor.Start();
|
|
|
|
|
//禁止初始化动作被撤销
|
|
|
|
|
app.Database.hm.lockIndex++;
|
|
|
|
|
|
|
|
|
|
//记录初始世界UCS
|
|
|
|
|
let backUCSMatrix = app.Editor.UCSMatrix;
|
|
|
|
|
let br = this.props.br;
|
|
|
|
|
app.Viewer.CameraCtrl.LookAt(br.Normal.negate());
|
|
|
|
|
app.Viewer.CameraCtrl.ZoomExtentsBox3(br.BoundingBox.expandByScalar(1000));
|
|
|
|
|
app.Editor.UCSMatrix = new Matrix4().extractRotation(br.OCS);
|
|
|
|
|
let brCurve = br.ContourCurve.Clone();
|
|
|
|
|
|
|
|
|
|
let cu = JigUtils.Draw(br.ContourCurve.Clone().ApplyMatrix(br.OCS));
|
|
|
|
|
let moveCus: Curve[] = [cu];
|
|
|
|
|
//UCS W0
|
|
|
|
|
app.Editor.UCSMatrix = IdentityMtx4;
|
|
|
|
|
|
|
|
|
|
let store = RightPanelStore.GetInstance();
|
|
|
|
|
//改变观察视角
|
|
|
|
|
app.Viewer.CameraCtrl.LookAt(ZAxisN);
|
|
|
|
|
app.Viewer.CameraCtrl.ZoomExtentsBox3(brCurve.BoundingBox.expandByScalar(1000));
|
|
|
|
|
|
|
|
|
|
await CommandWrap(async () =>
|
|
|
|
|
{
|
|
|
|
|
//提取板轮廓 设置冻结
|
|
|
|
|
brCurve.Freeze = true;
|
|
|
|
|
app.Database.ModelSpace.Append(brCurve);
|
|
|
|
|
|
|
|
|
|
//载入配置,设置配置
|
|
|
|
|
let store = RightPanelStore.GetInstance();
|
|
|
|
|
let config = new DialogUserConfig(store.modeling2Store, BoardModalType.ZX2);
|
|
|
|
|
await config.LoadAndInitConfig(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//初始化造型数据,提取出形状
|
|
|
|
|
//初始化造型数据Store
|
|
|
|
|
store.modeling2Store.InitModelingItems();
|
|
|
|
|
|
|
|
|
|
//提取出二维造型轮廓
|
|
|
|
|
for (let data of br.Modeling2D)
|
|
|
|
|
{
|
|
|
|
|
let color = data.path.ColorIndex;
|
|
|
|
|
store.modeling2Store.ChangeModelingValue(color - 1, data);
|
|
|
|
|
|
|
|
|
|
let cu = JigUtils.Draw(data.path.Clone().Z0().ApplyMatrix(br.OCS));
|
|
|
|
|
moveCus.push(cu);
|
|
|
|
|
let cu = data.path.Clone().Z0();
|
|
|
|
|
app.Database.ModelSpace.Append(cu);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let isOk = await selectOutlinePosition(moveCus);
|
|
|
|
|
app.Editor.ModalManage.ToggleShow();
|
|
|
|
|
app.Editor.MaskManage.ShowMask();
|
|
|
|
|
if (isOk)
|
|
|
|
|
{
|
|
|
|
|
//显示右侧状态栏
|
|
|
|
|
//呼出右侧二维刀路对照表
|
|
|
|
|
store.modeling2Store.isNotUpdateStore = true;
|
|
|
|
|
store.modeling2Store.configName = "";
|
|
|
|
|
store.m_IsShow = true;
|
|
|
|
|
store.m_TabId = RightTabId.Model2;
|
|
|
|
|
app.Editor.MaskManage.OnFocusEvent();
|
|
|
|
|
store.m_TabId = RightTabId.Model2;
|
|
|
|
|
store.modeling2Store.isNotUpdateStore = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}, "提取二维刀路");
|
|
|
|
|
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
message: this._RenderToasterMessage(brCurve),
|
|
|
|
|
timeout: 0,
|
|
|
|
|
intent: Intent.PRIMARY,
|
|
|
|
|
onDismiss()
|
|
|
|
|
{
|
|
|
|
|
if (TempEditor.EditorIng)
|
|
|
|
|
{
|
|
|
|
|
TempEditor.End();
|
|
|
|
|
app.Editor.UCSMatrix = backUCSMatrix;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, EDITOR_2D_PATH);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//应用二维刀路
|
|
|
|
|
ChangeModeling2 = async (brCurve: ExtrudeContour) =>
|
|
|
|
|
{
|
|
|
|
|
let finalCurve: Curve[] = [];
|
|
|
|
|
|
|
|
|
|
//因为临时编辑器会新建一个场景,只需要遍历这个场景内的对象就可以了
|
|
|
|
|
for (let obj of app.Viewer.Scene.children)
|
|
|
|
|
{
|
|
|
|
|
if (obj.visible)
|
|
|
|
|
{
|
|
|
|
|
let cu = GetEntity(obj);
|
|
|
|
|
if (cu && cu.Id?.Object && cu !== brCurve && cu.Visible && !cu.IsErase && (cu instanceof Curve))
|
|
|
|
|
finalCurve.push(cu);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let cuGourp = curveLinkGroup(finalCurve);
|
|
|
|
|
let pathMap = new Map<number, Polyline[]>();
|
|
|
|
|
|
|
|
|
|
if (cuGourp)
|
|
|
|
|
{
|
|
|
|
|
await CommandWrap(async () =>
|
|
|
|
|
{
|
|
|
|
|
const rightStore = RightPanelStore.GetInstance();
|
|
|
|
|
|
|
|
|
|
for (let g of cuGourp)
|
|
|
|
|
{
|
|
|
|
|
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 === ""))
|
|
|
|
|
{
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
message: "部分颜色未设置深度或者刀具!",
|
|
|
|
|
timeout: 5000,
|
|
|
|
|
intent: Intent.WARNING,
|
|
|
|
|
}, "unSetDepthKnife");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let path: Polyline;
|
|
|
|
|
|
|
|
|
|
if (g[0] instanceof Circle)
|
|
|
|
|
path = ConverCircleToPolyline(g[0] as Circle);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
path = new Polyline;
|
|
|
|
|
for (let c of g)
|
|
|
|
|
path.Join(c, true, 1e-3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (path)
|
|
|
|
|
{
|
|
|
|
|
path.ColorIndex = c.ColorIndex;
|
|
|
|
|
if (!pathMap.has(c.ColorIndex))
|
|
|
|
|
pathMap.set(c.ColorIndex, [path]);
|
|
|
|
|
else
|
|
|
|
|
pathMap.get(c.ColorIndex).push(path);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, "分析二维刀路");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppToaster.dismiss(EDITOR_2D_PATH);
|
|
|
|
|
|
|
|
|
|
await CommandWrap(async () =>
|
|
|
|
|
{
|
|
|
|
|
await this.AddModeling2(pathMap);
|
|
|
|
|
}, "修改二维刀路");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
PickUpModelingOutline3 = async () =>
|
|
|
|
|
{
|
|
|
|
|
if (TempEditor.EditorIng)
|
|
|
|
@ -576,93 +688,6 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//应用二维刀路
|
|
|
|
|
private ChangeModeling2 = async () =>
|
|
|
|
|
{
|
|
|
|
|
await app.Editor.ModalManage.EndExecingCmd();
|
|
|
|
|
await CommandWrap(async () =>
|
|
|
|
|
{
|
|
|
|
|
app.Editor.ModalManage.ToggleShow();
|
|
|
|
|
app.Editor.MaskManage.Clear();
|
|
|
|
|
|
|
|
|
|
let exec = async () =>
|
|
|
|
|
{
|
|
|
|
|
let { contour, group: cuGourp, useCurves } = await SelectExtrudeContour(true, true);
|
|
|
|
|
if (!contour) return;
|
|
|
|
|
|
|
|
|
|
let br = this.props.br;
|
|
|
|
|
let applyMatrix = ExtrudeApplyContour(br, contour);
|
|
|
|
|
|
|
|
|
|
//更新高级排钻数据
|
|
|
|
|
this.props.boardProcess.highDrill = br.BoardProcessOption.highDrill;
|
|
|
|
|
|
|
|
|
|
//删除应用的轮廓
|
|
|
|
|
if (useCurves)
|
|
|
|
|
for (let c of useCurves)
|
|
|
|
|
c.Erase();
|
|
|
|
|
|
|
|
|
|
if (cuGourp)
|
|
|
|
|
{
|
|
|
|
|
let box = contour.BoundingBox;
|
|
|
|
|
app.Viewer.WorldToScreen(box.min);
|
|
|
|
|
app.Viewer.WorldToScreen(box.max);
|
|
|
|
|
let selectBox = new SelectBox(app.Viewer, AsVector2(box.min), AsVector2(box.max), SelectType.C);
|
|
|
|
|
|
|
|
|
|
const rightStore = RightPanelStore.GetInstance();
|
|
|
|
|
|
|
|
|
|
let pathMap = new Map<number, Polyline[]>();
|
|
|
|
|
|
|
|
|
|
for (let g of cuGourp)
|
|
|
|
|
{
|
|
|
|
|
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 === ""))
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (selectBox.CheckSelectTraverse(c.GetDrawObjectFromRenderType()))
|
|
|
|
|
{
|
|
|
|
|
let path: Polyline;
|
|
|
|
|
|
|
|
|
|
if (g[0] instanceof Circle)
|
|
|
|
|
path = ConverCircleToPolyline(g[0] as Circle);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// path = Polyline.Combine(g); 弃用的原因是因为直线提供的坐标系不和曲线坐标系一致 可能Z轴反了
|
|
|
|
|
path = new Polyline;
|
|
|
|
|
path.OCS = contour.OCSNoClone;
|
|
|
|
|
for (let c of g)
|
|
|
|
|
path.Join(c, true, 1e-3);
|
|
|
|
|
}
|
|
|
|
|
if (path)
|
|
|
|
|
{
|
|
|
|
|
path.ColorIndex = c.ColorIndex;
|
|
|
|
|
if (!pathMap.has(c.ColorIndex))
|
|
|
|
|
pathMap.set(c.ColorIndex, [path]);
|
|
|
|
|
else
|
|
|
|
|
pathMap.get(c.ColorIndex).push(path);
|
|
|
|
|
|
|
|
|
|
//删除应用的轮廓
|
|
|
|
|
for (let c of g)
|
|
|
|
|
c.Erase();
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await this.AddModeling2(pathMap, applyMatrix);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await exec();
|
|
|
|
|
|
|
|
|
|
app.Editor.ModalManage.ToggleShow();
|
|
|
|
|
app.Editor.MaskManage.OnFocusEvent();
|
|
|
|
|
}, "修改二维刀路");
|
|
|
|
|
};
|
|
|
|
|
private AddModeling = (contourMap: Map<number, Contour[]>, applyMatrix: Matrix4) =>
|
|
|
|
|
{
|
|
|
|
|
if (contourMap.size > 0)
|
|
|
|
@ -715,11 +740,17 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//应用二维刀路
|
|
|
|
|
private AddModeling2 = async (contourMap: Map<number, Polyline[]>, applyMatrix: Matrix4) =>
|
|
|
|
|
private AddModeling2 = async (contourMap: Map<number, Polyline[]>) =>
|
|
|
|
|
{
|
|
|
|
|
if (contourMap.size === 0) return;
|
|
|
|
|
|
|
|
|
|
let br = this.props.br;
|
|
|
|
|
|
|
|
|
|
if (!contourMap.size)
|
|
|
|
|
{
|
|
|
|
|
br.KnifePolylineMap = new Map();
|
|
|
|
|
br.Modeling2D = [];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const rightStore = RightPanelStore.GetInstance();
|
|
|
|
|
br.ClearModeling2DList();
|
|
|
|
|
let modelings: I2DModeling[] = [];
|
|
|
|
@ -729,7 +760,6 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
|
|
|
|
|
let cd = rightStore.modeling2Store.modelingItems[color - 1];
|
|
|
|
|
for (let path of contours)
|
|
|
|
|
{
|
|
|
|
|
path.ApplyMatrix(applyMatrix);
|
|
|
|
|
path.Position = path.Position.setZ(0);
|
|
|
|
|
if (path.IsClose)
|
|
|
|
|
{
|
|
|
|
@ -773,7 +803,6 @@ export class BoardConfigModal extends React.Component<BoardConfigProps, {}>{
|
|
|
|
|
knifeMap.set(knifIds[i], knifPolylines[i]);
|
|
|
|
|
|
|
|
|
|
br.KnifePolylineMap = knifeMap;
|
|
|
|
|
|
|
|
|
|
br.Modeling2D = modelings;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|