|
|
@ -9,7 +9,9 @@ import { arrayRemove } from "../../Common/ArrayExt";
|
|
|
|
import { EBoardKeyList } from "../../Common/BoardKeyList";
|
|
|
|
import { EBoardKeyList } from "../../Common/BoardKeyList";
|
|
|
|
import { CommandNames } from "../../Common/CommandNames";
|
|
|
|
import { CommandNames } from "../../Common/CommandNames";
|
|
|
|
import { GroupEntitysByBox } from "../../Common/GroupEntitysByBox";
|
|
|
|
import { GroupEntitysByBox } from "../../Common/GroupEntitysByBox";
|
|
|
|
|
|
|
|
import { CheckInterfereTool } from "../../Common/InterfereUtil";
|
|
|
|
import { KeyBoard } from "../../Common/KeyEnum";
|
|
|
|
import { KeyBoard } from "../../Common/KeyEnum";
|
|
|
|
|
|
|
|
import { LogType } from "../../Common/Log";
|
|
|
|
import { AlignLineGroupRecord } from "../../DatabaseServices/AlignLine/AlignLineGroupRecord";
|
|
|
|
import { AlignLineGroupRecord } from "../../DatabaseServices/AlignLine/AlignLineGroupRecord";
|
|
|
|
import { Board } from "../../DatabaseServices/Entity/Board";
|
|
|
|
import { Board } from "../../DatabaseServices/Entity/Board";
|
|
|
|
import { LinesType } from "../../DatabaseServices/Entity/BoardInterface";
|
|
|
|
import { LinesType } from "../../DatabaseServices/Entity/BoardInterface";
|
|
|
@ -430,79 +432,149 @@ export class AlignLineGroupPanel extends React.Component<{ store: AlignLineGroup
|
|
|
|
|
|
|
|
|
|
|
|
await CommandWrap(async () =>
|
|
|
|
await CommandWrap(async () =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let ssRes = await app.Editor.GetSelection({
|
|
|
|
while (true)
|
|
|
|
Msg: `请选择需要加入对纹组的实体`,
|
|
|
|
|
|
|
|
Filter: { filterTypes: [Board] }
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ssRes.Status === PromptStatus.OK)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let brs = ssRes.SelectSet.SelectEntityList as Board[];
|
|
|
|
let alignLineGroupSpacing = this.props.store.m_Option.alignLineGroupSpacing ?? 20;
|
|
|
|
if (!brs.every(br => isParallelTo(br.Normal, brs[0].Normal)))
|
|
|
|
let ssRes = await app.Editor.GetSelection({
|
|
|
|
|
|
|
|
Msg: `选择加入对纹组的板件(当前规定对纹组板件间距小于等于:${alignLineGroupSpacing})`,
|
|
|
|
|
|
|
|
KeyWordList: [{ key: "D", msg: "板件间距" }],
|
|
|
|
|
|
|
|
Filter: { filterTypes: [Board] }
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (ssRes.Status === PromptStatus.Keyword)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AppToaster.show({
|
|
|
|
if (ssRes.StringResult === "D")
|
|
|
|
message: "所选的板件不在同一平面上",
|
|
|
|
{
|
|
|
|
timeout: 5000,
|
|
|
|
let ret = await app.Editor.GetDistance({ Msg: "当前规定板件间距小于等于:", Default: alignLineGroupSpacing });
|
|
|
|
intent: Intent.WARNING,
|
|
|
|
if (ret.Status === PromptStatus.OK)
|
|
|
|
});
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
if (ret.Distance < 0 || isNaN(ret.Distance))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
app.Editor.Prompt("请输入为正数的间距!", LogType.Error);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.props.store.m_Option.alignLineGroupSpacing = Math.abs(ret.Distance);
|
|
|
|
|
|
|
|
userConfigStore.SaveConfig(BoardModalType.AlignLineGroupStore, this.props.store, { toaster: false });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ret.Status === PromptStatus.Cancel)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ssRes.Status === PromptStatus.OK)
|
|
|
|
let invalidBoard = brs.filter(br => br.AlignLineObject);
|
|
|
|
|
|
|
|
if (invalidBoard.length)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AppToaster.show({
|
|
|
|
let brs = ssRes.SelectSet.SelectEntityList as Board[];
|
|
|
|
message: "存在已经组合的板!",
|
|
|
|
|
|
|
|
timeout: 5000,
|
|
|
|
|
|
|
|
intent: Intent.WARNING,
|
|
|
|
|
|
|
|
}, "hasInvalidBoard");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.Editor.SetSelection(invalidBoard);
|
|
|
|
let tool = new CheckInterfereTool();
|
|
|
|
return;
|
|
|
|
let p = await tool.Check(brs);
|
|
|
|
}
|
|
|
|
if (p.length)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
|
|
|
message: "所选的板件存在干涉!",
|
|
|
|
|
|
|
|
timeout: 7000,
|
|
|
|
|
|
|
|
intent: Intent.WARNING,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let brBoxMap = GroupEntitysByBox(brs);
|
|
|
|
let spliteSizeBrs = brs.filter((b) => b.BoardProcessOption.spliteHeight || b.BoardProcessOption.spliteThickness || b.BoardProcessOption.spliteWidth);
|
|
|
|
let name = this.props.store.selectedLeftNode;
|
|
|
|
|
|
|
|
for (let [box, brs] of brBoxMap)
|
|
|
|
if (spliteSizeBrs.length)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (brs.length < 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
app.Editor.SetSelection(spliteSizeBrs);
|
|
|
|
AppToaster.show({
|
|
|
|
AppToaster.show({
|
|
|
|
message: "存在无效的对纹组合!",
|
|
|
|
message: "所选的板件存在有拆单尺寸(已选中)!",
|
|
|
|
timeout: 5000,
|
|
|
|
timeout: 7000,
|
|
|
|
intent: Intent.WARNING,
|
|
|
|
intent: Intent.WARNING,
|
|
|
|
}, "notGroupAlignLine");
|
|
|
|
});
|
|
|
|
continue;
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let invalidBoard = brs.filter(br => br.AlignLineObject);
|
|
|
|
|
|
|
|
if (invalidBoard.length)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
app.Editor.SetSelection(invalidBoard);
|
|
|
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
|
|
|
message: "存在已经组合的板(已选中)!",
|
|
|
|
|
|
|
|
timeout: 7000,
|
|
|
|
|
|
|
|
intent: Intent.WARNING,
|
|
|
|
|
|
|
|
}, "hasInvalidBoard");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const FirstBr = brs[0];
|
|
|
|
if (!brs.every(br => isParallelTo(br.Normal, brs[0].Normal)))
|
|
|
|
const ComposingFace = FirstBr.BoardProcessOption.composingFace;
|
|
|
|
|
|
|
|
const LineType = FirstBr.BoardProcessOption.lines;
|
|
|
|
|
|
|
|
const Material = FirstBr.BoardProcessOption.material;
|
|
|
|
|
|
|
|
const Color = FirstBr.BoardProcessOption.color;
|
|
|
|
|
|
|
|
const MatName = FirstBr.BoardProcessOption.boardName;
|
|
|
|
|
|
|
|
const Thickness = FirstBr.Thickness;
|
|
|
|
|
|
|
|
let canAdd = brs.every(
|
|
|
|
|
|
|
|
br => br.BoardProcessOption.material === Material &&
|
|
|
|
|
|
|
|
br.BoardProcessOption.color === Color &&
|
|
|
|
|
|
|
|
br.BoardProcessOption.boardName === MatName &&
|
|
|
|
|
|
|
|
br.BoardProcessOption.lines === LineType &&
|
|
|
|
|
|
|
|
br.BoardProcessOption.composingFace === ComposingFace &&
|
|
|
|
|
|
|
|
equaln(br.Thickness, Thickness)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!canAdd)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AppToaster.show({
|
|
|
|
AppToaster.show({
|
|
|
|
message: "所选板块中,板材料、板材颜色、板材名、板厚、排版面或者板纹路不一致,无法组成对纹组!",
|
|
|
|
message: "所选的板件不在同一平面上",
|
|
|
|
timeout: 5000,
|
|
|
|
timeout: 7000,
|
|
|
|
intent: Intent.WARNING,
|
|
|
|
intent: Intent.WARNING,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
continue;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let brBoxMap = GroupEntitysByBox(brs, alignLineGroupSpacing);
|
|
|
|
|
|
|
|
let name = this.props.store.selectedLeftNode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (let [box, brs] of brBoxMap)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//超长板件
|
|
|
|
//---独立板件检查 begin---
|
|
|
|
|
|
|
|
if (brs.length < 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
app.Editor.SetSelection(brs);
|
|
|
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
|
|
|
message: "存在独立的单板(已选中),未组成对纹组合!",
|
|
|
|
|
|
|
|
timeout: 7000,
|
|
|
|
|
|
|
|
intent: Intent.WARNING,
|
|
|
|
|
|
|
|
}, "notGroupAlignLine");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//---材料检查 begin---
|
|
|
|
|
|
|
|
const firstBr = brs[0];
|
|
|
|
|
|
|
|
const composingFace = firstBr.BoardProcessOption.composingFace;
|
|
|
|
|
|
|
|
const lineType = firstBr.BoardProcessOption.lines;
|
|
|
|
|
|
|
|
const material = firstBr.BoardProcessOption.material;
|
|
|
|
|
|
|
|
const color = firstBr.BoardProcessOption.color;
|
|
|
|
|
|
|
|
const matName = firstBr.BoardProcessOption.boardName;
|
|
|
|
|
|
|
|
const thickness = firstBr.Thickness;
|
|
|
|
|
|
|
|
let hasDifferentMtl = brs.every(
|
|
|
|
|
|
|
|
br => br.BoardProcessOption.material === material &&
|
|
|
|
|
|
|
|
br.BoardProcessOption.color === color &&
|
|
|
|
|
|
|
|
br.BoardProcessOption.boardName === matName &&
|
|
|
|
|
|
|
|
br.BoardProcessOption.lines === lineType &&
|
|
|
|
|
|
|
|
br.BoardProcessOption.composingFace === composingFace &&
|
|
|
|
|
|
|
|
equaln(br.Thickness, thickness)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!hasDifferentMtl)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
app.Editor.SetSelection(brs);
|
|
|
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
|
|
|
message: "所选板块中,板材料、板材颜色、板材名、板厚、排版面或者板纹路不一致,无法组成对纹组!",
|
|
|
|
|
|
|
|
timeout: 7000,
|
|
|
|
|
|
|
|
intent: Intent.WARNING,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//---材料检查 end---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//---对纹方向检查 begin---
|
|
|
|
|
|
|
|
const yNormal = new Vector3().setFromMatrixColumn(firstBr.OCS, 1);
|
|
|
|
|
|
|
|
let hasDifferentYNormal = brs.every(
|
|
|
|
|
|
|
|
br => isParallelTo(yNormal, new Vector3().setFromMatrixColumn(br.OCS, 1))
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!hasDifferentYNormal)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
app.Editor.SetSelection(brs);
|
|
|
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
|
|
|
message: "所选板块中,存在实际纹路方向不一致(已选中),无法组成对纹组!",
|
|
|
|
|
|
|
|
timeout: 7000,
|
|
|
|
|
|
|
|
intent: Intent.WARNING,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//---对纹方向检查 end---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//---超长板件检查 begin---
|
|
|
|
let ocsInv = brs[0].OCSInv;
|
|
|
|
let ocsInv = brs[0].OCSInv;
|
|
|
|
let spliteSize = box.applyMatrix4(ocsInv).getSize(new Vector3);
|
|
|
|
let spliteSize = box.applyMatrix4(ocsInv).getSize(new Vector3);
|
|
|
|
let width = spliteSize.x;
|
|
|
|
let width = spliteSize.x;
|
|
|
@ -516,24 +588,29 @@ export class AlignLineGroupPanel extends React.Component<{ store: AlignLineGroup
|
|
|
|
|
|
|
|
|
|
|
|
if (height > userConfig.maxSize.height + 1e-5 || width > userConfig.maxSize.width + 1e-5)
|
|
|
|
if (height > userConfig.maxSize.height + 1e-5 || width > userConfig.maxSize.width + 1e-5)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
app.Editor.SetSelection(brs);
|
|
|
|
AppToaster.show({
|
|
|
|
AppToaster.show({
|
|
|
|
message: "组合的对纹组尺寸超长!",
|
|
|
|
message: "组合的对纹组尺寸超长!",
|
|
|
|
timeout: 5000,
|
|
|
|
timeout: 7000,
|
|
|
|
intent: Intent.DANGER,
|
|
|
|
intent: Intent.DANGER,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
continue;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//---超长板件检查 end---
|
|
|
|
|
|
|
|
|
|
|
|
let al = new AlignLineGroupRecord;
|
|
|
|
let al = new AlignLineGroupRecord;
|
|
|
|
al.Name = name || "未命名";
|
|
|
|
al.Name = name || "未命名";
|
|
|
|
app.Database.AlignLineGroupTable.Add(al);
|
|
|
|
app.Database.AlignLineGroupTable.Add(al);
|
|
|
|
for (let br of brs)
|
|
|
|
for (let br of brs)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
br.AlignLineObject = al.Id;
|
|
|
|
br.AlignLineObject = al.Id;
|
|
|
|
al.Objects.push(br.Id);
|
|
|
|
al.Objects.push(br.Id);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, CommandNames.AddAlignLineGroup);
|
|
|
|
}, CommandNames.AddAlignLineGroup);
|
|
|
|
|
|
|
|
|
|
|
|