diff --git a/__test__/EdgeSealing/EdgeSealing.test.ts b/__test__/EdgeSealing/EdgeSealing.test.ts index ccded6f5f..da76c3a96 100644 --- a/__test__/EdgeSealing/EdgeSealing.test.ts +++ b/__test__/EdgeSealing/EdgeSealing.test.ts @@ -10,7 +10,7 @@ function testBrSealing(br: Board, sealingSize: number[]) { br.BoardProcessOption.highSealed = sealingSize.map(s => { - return { size: s }; + return { size: s, sealColor: "" }; }); SetBoardTopDownLeftRightSealData(br, br.BoardProcessOption.highSealed); diff --git a/src/Add-on/Batch/BatchModifySealOrDrill.ts b/src/Add-on/Batch/BatchModifySealOrDrill.ts index a4a1e0649..b93faa27b 100644 --- a/src/Add-on/Batch/BatchModifySealOrDrill.ts +++ b/src/Add-on/Batch/BatchModifySealOrDrill.ts @@ -42,7 +42,7 @@ export class BatchModify implements Command let keyRes = await app.Editor.GetKeyWords({ Msg: "编辑项目", - KeyWordList: [{ msg: "封边", key: "S" }, { msg: "排钻", key: "D" }, { msg: "板边备注", key: "R" }] + KeyWordList: [{ msg: "封边", key: "S" }, { msg: "排钻", key: "D" }, { msg: "板边备注", key: "R" }, { msg: "预留边", key: "Y" }] }); if (keyRes.Status !== PromptStatus.Keyword) return; @@ -105,6 +105,22 @@ export class BatchModify implements Command boardEdgeRemarksStore.isNotUpdateStore = false; }, 0); } + else if (keyRes.StringResult === "Y") + { + const reservedEdgeStore = store.reservedEdgeStore; + + reservedEdgeStore.isNotUpdateStore = true; + let config = new DialogUserConfig(reservedEdgeStore, BoardModalType.ReservedEdge); + await config.LoadAndInitConfig(); + + store.m_IsShow = true; + store.m_TabId = RightTabId.ReservedEdge; + setTimeout(async () =>//当前命令结束后在进入编辑 + { + await reservedEdgeStore.StartEditor(brs); + reservedEdgeStore.isNotUpdateStore = false; + }, 0); + } } } diff --git a/src/Add-on/BoardEditor/SerializeBoardData.ts b/src/Add-on/BoardEditor/SerializeBoardData.ts index 070907cae..7901ef45e 100644 --- a/src/Add-on/BoardEditor/SerializeBoardData.ts +++ b/src/Add-on/BoardEditor/SerializeBoardData.ts @@ -22,6 +22,7 @@ export function serializeBoardData(file: CADFiler, processData: BoardProcessOpti for (let n of processData[EBoardKeyList.HighSealed]) { file.Write(n.size); + file.Write(n.sealColor); } file.Write(processData[EBoardKeyList.UpSealed]); file.Write(processData[EBoardKeyList.DownSealed]); @@ -63,11 +64,18 @@ export function deserializationBoardData(file: CADFiler, processData: BoardProce for (let i = 0; i < count; i++) { let size = file.Read(); + let sealColor = ""; + if (ver > 22) + { + sealColor = file.Read(); + } + if (ver < 4) { file.Read(); } - processData[EBoardKeyList.HighSealed].push({ size }); + + processData[EBoardKeyList.HighSealed].push({ size, sealColor }); } processData[EBoardKeyList.UpSealed] = file.Read(); diff --git a/src/Add-on/CF/Import/CFInterface.ts b/src/Add-on/CF/Import/CFInterface.ts index 7409cdff4..f7b01349e 100644 --- a/src/Add-on/CF/Import/CFInterface.ts +++ b/src/Add-on/CF/Import/CFInterface.ts @@ -89,10 +89,15 @@ export interface ICFBoard extends ICFExtrudeSolid LeftSealed?: string; RightSealed?: string; + sealColorUp?: string; //封边颜色 + sealColorDown?: string; + sealColorLeft?: string; + sealColorRight?: string; + // 封边信息 // 普通板时使用 UpSealed,DownSealed,LeftSealed,RightSealed 表示上下左右封边的值 - // 异形板时使用 EachSealeds 数组表示每个边的封边数据,size表示封边的厚度 - EachSealeds?: { size: number; }[]; //每个边的封边数据 + // 异形板时使用 EachSealeds 数组表示每个边的封边数据,size表示封边的厚度,sealColor表示封边颜色 + EachSealeds?: { size: number; sealColor: string; }[]; //每个边的封边数据 EachEdgeDrills?: string[]; //每个边的排钻数据 diff --git a/src/Add-on/CF/Parse/ParseBoard.ts b/src/Add-on/CF/Parse/ParseBoard.ts index de7226163..71a5d50ea 100644 --- a/src/Add-on/CF/Parse/ParseBoard.ts +++ b/src/Add-on/CF/Parse/ParseBoard.ts @@ -188,6 +188,10 @@ export function ParseCFBoard(el: ICFBoard, boardMaterialMap?: Map 1) @@ -125,6 +137,14 @@ export class DrawLeftRightOpenDoor extends DrawDoorTool en.BoardProcessOption.edgeRemarkDown = verticalEdgeRemarkDown.toString(); en.BoardProcessOption.edgeRemarkLeft = verticalEdgeRemarkLeft.toString(); en.BoardProcessOption.edgeRemarkRight = verticalEdgeRemarkRight.toString(); + en.BoardProcessOption.sealColorUp = verticalSealColorUp; + en.BoardProcessOption.sealColorDown = verticalSealColorDown; + en.BoardProcessOption.sealColorLeft = verticalSealColorLeft; + en.BoardProcessOption.sealColorRight = verticalSealColorRight; + en.BoardProcessOption.reservedEdgeUp = verticalReservedEdgeUp; + en.BoardProcessOption.reservedEdgeDown = verticalReservedEdgeDown; + en.BoardProcessOption.reservedEdgeLeft = verticalReservedEdgeLeft; + en.BoardProcessOption.reservedEdgeRight = verticalReservedEdgeRight; en.BoardProcessOption.highDrill = [lbDrillDown, lbDrillRight, lbDrillUp, lbDrillLeft]; let drillSet = new Set(en.BoardProcessOption.highDrill); if (drillSet.size > 1) diff --git a/src/Add-on/DrawBoard/DrawDoorDrawer/DrawUpDownOpenDoor.ts b/src/Add-on/DrawBoard/DrawDoorDrawer/DrawUpDownOpenDoor.ts index 59afe0495..593ffba37 100644 --- a/src/Add-on/DrawBoard/DrawDoorDrawer/DrawUpDownOpenDoor.ts +++ b/src/Add-on/DrawBoard/DrawDoorDrawer/DrawUpDownOpenDoor.ts @@ -35,6 +35,10 @@ export class DrawUpDownOpenDoor extends DrawDoorTool topBrSeal, bottomBrSeal, leftBrSeal, rightBrSeal, layerEdgeRemarkUp, layerEdgeRemarkDown, layerEdgeRemarkLeft, layerEdgeRemarkRight, verticalEdgeRemarkUp, verticalEdgeRemarkDown, verticalEdgeRemarkLeft, verticalEdgeRemarkRight, + layerSealColorUp, layerSealColorDown, layerSealColorLeft, layerSealColorRight, + layerReservedEdgeUp, layerReservedEdgeDown, layerReservedEdgeLeft, layerReservedEdgeRight, + verticalSealColorUp, verticalSealColorDown, verticalSealColorLeft, verticalSealColorRight, + verticalReservedEdgeUp, verticalReservedEdgeDown, verticalReservedEdgeLeft, verticalReservedEdgeRight, verticalBoardName, layerBoardName, thickness, isAuto, useBoardProcessOption, lbHightDrillOption: { down: lbDrillDown, up: lbDrillUp, left: lbDrillLeft, right: lbDrillRight }, @@ -77,6 +81,14 @@ export class DrawUpDownOpenDoor extends DrawDoorTool en.BoardProcessOption.edgeRemarkDown = verticalEdgeRemarkDown.toString(); en.BoardProcessOption.edgeRemarkLeft = verticalEdgeRemarkLeft.toString(); en.BoardProcessOption.edgeRemarkRight = verticalEdgeRemarkRight.toString(); + en.BoardProcessOption.sealColorUp = verticalSealColorUp; + en.BoardProcessOption.sealColorDown = verticalSealColorDown; + en.BoardProcessOption.sealColorLeft = verticalSealColorLeft; + en.BoardProcessOption.sealColorRight = verticalSealColorRight; + en.BoardProcessOption.reservedEdgeUp = verticalReservedEdgeUp; + en.BoardProcessOption.reservedEdgeDown = verticalReservedEdgeDown; + en.BoardProcessOption.reservedEdgeLeft = verticalReservedEdgeLeft; + en.BoardProcessOption.reservedEdgeRight = verticalReservedEdgeRight; let drillSet = new Set(en.BoardProcessOption.highDrill); if (drillSet.size > 1) en.BoardProcessOption.drillType = DrillType.More; @@ -127,6 +139,14 @@ export class DrawUpDownOpenDoor extends DrawDoorTool en.BoardProcessOption.edgeRemarkDown = layerEdgeRemarkDown.toString(); en.BoardProcessOption.edgeRemarkLeft = layerEdgeRemarkLeft.toString(); en.BoardProcessOption.edgeRemarkRight = layerEdgeRemarkRight.toString(); + en.BoardProcessOption.sealColorUp = layerSealColorUp; + en.BoardProcessOption.sealColorDown = layerSealColorDown; + en.BoardProcessOption.sealColorLeft = layerSealColorLeft; + en.BoardProcessOption.sealColorRight = layerSealColorRight; + en.BoardProcessOption.reservedEdgeUp = layerReservedEdgeUp; + en.BoardProcessOption.reservedEdgeDown = layerReservedEdgeDown; + en.BoardProcessOption.reservedEdgeLeft = layerReservedEdgeLeft; + en.BoardProcessOption.reservedEdgeRight = layerReservedEdgeRight; let drillSet = new Set(en.BoardProcessOption.highDrill); if (drillSet.size > 1) en.BoardProcessOption.drillType = DrillType.More; diff --git a/src/Add-on/DrawBoard/DrawDrawer.ts b/src/Add-on/DrawBoard/DrawDrawer.ts index 3b717637a..13918c4a9 100644 --- a/src/Add-on/DrawBoard/DrawDrawer.ts +++ b/src/Add-on/DrawBoard/DrawDrawer.ts @@ -573,6 +573,8 @@ export class DrawDrawrer implements Command const { verticalBoardName, thickness, lbSealedUp, lbSealedDown, lbSealedLeft, lbSealedRight, + sealColorUp, sealColorDown, sealColorLeft, sealColorRight, + reservedEdgeUp, reservedEdgeDown, reservedEdgeLeft, reservedEdgeRight, lbHightDrillOption: { down: lbDrillDown, up: lbDrillUp, left: lbDrillLeft, right: lbDrillRight }, } = option; let verTemp = new TemplateSizeBoard().InitBaseParams(); @@ -584,6 +586,14 @@ export class DrawDrawrer implements Command br.BoardProcessOption[EBoardKeyList.DownSealed] = lbSealedDown.toString(); br.BoardProcessOption[EBoardKeyList.LeftSealed] = lbSealedLeft.toString(); br.BoardProcessOption[EBoardKeyList.RightSealed] = lbSealedRight.toString(); + br.BoardProcessOption.sealColorUp = sealColorUp; + br.BoardProcessOption.sealColorDown = sealColorDown; + br.BoardProcessOption.sealColorLeft = sealColorLeft; + br.BoardProcessOption.sealColorRight = sealColorRight; + br.BoardProcessOption.reservedEdgeUp = reservedEdgeUp; + br.BoardProcessOption.reservedEdgeDown = reservedEdgeDown; + br.BoardProcessOption.reservedEdgeLeft = reservedEdgeLeft; + br.BoardProcessOption.reservedEdgeRight = reservedEdgeRight; br.BoardProcessOption.highDrill = [lbDrillDown, lbDrillRight, lbDrillUp, lbDrillLeft]; let drillSet = new Set(br.BoardProcessOption.highDrill); if (drillSet.size > 1) diff --git a/src/Add-on/DrawDrilling/DrillingReactor.ts b/src/Add-on/DrawDrilling/DrillingReactor.ts index 2bb3f77a8..4254dc7ad 100644 --- a/src/Add-on/DrawDrilling/DrillingReactor.ts +++ b/src/Add-on/DrawDrilling/DrillingReactor.ts @@ -46,6 +46,9 @@ const ForbidReactorCmd = new Set([ // 板件取消孔槽加工 CommandNames.ClearCDBrHoleModeling, + CommandNames.板边备注编辑, + CommandNames.预留边属性编辑, + //对纹组 CommandNames.AlignLineGroup, CommandNames.AddAlignLineGroup, diff --git a/src/Add-on/DrawWineRack/DrawWinRackTool.ts b/src/Add-on/DrawWineRack/DrawWinRackTool.ts index 556c1619e..439a1a597 100644 --- a/src/Add-on/DrawWineRack/DrawWinRackTool.ts +++ b/src/Add-on/DrawWineRack/DrawWinRackTool.ts @@ -78,18 +78,18 @@ export class DrawWineRackTool extends Singleton let sizes = [...new Set([downSealed, rightSealed, topSealed, leftSealed])]; let downSeal = { - size: downSealed, color: sizes.indexOf(downSealed) + 1 + size: downSealed, color: sizes.indexOf(downSealed) + 1, sealColor: "" }; let rigthSeal = { - size: rightSealed, color: sizes.indexOf(rightSealed) + 1 + size: rightSealed, color: sizes.indexOf(rightSealed) + 1, sealColor: "" }; - let topSeal = { size: topSealed, color: sizes.indexOf(topSealed) + 1 }; - let leftSeal = { size: leftSealed, color: sizes.indexOf(leftSealed) + 1 }; + let topSeal = { size: topSealed, color: sizes.indexOf(topSealed) + 1, sealColor: "" }; + let leftSeal = { size: leftSealed, color: sizes.indexOf(leftSealed) + 1, sealColor: "" }; let highSeals: IHighSealedItem[] = [downSeal]; if (isLeft) { - let leftSealNoSize = { size: 0, color: sizes.indexOf(leftSealed) + 1 }; + let leftSealNoSize = { size: 0, color: sizes.indexOf(leftSealed) + 1, sealColor: "" }; highSeals.push(rigthSeal, topSeal); for (let i = 3; i <= cu.EndParam - 1; i++) { @@ -101,7 +101,7 @@ export class DrawWineRackTool extends Singleton } else { - let rightSealNoSize = { size: 0, color: sizes.indexOf(rightSealed) + 1 }; + let rightSealNoSize = { size: 0, color: sizes.indexOf(rightSealed) + 1, sealColor: "" }; for (let i = 1; i <= cu.EndParam - 3; i++) { if ((i - 1) % 4 === 0) diff --git a/src/Add-on/Erp/ErpCommands.ts b/src/Add-on/Erp/ErpCommands.ts index bfa0fccf8..bf7592551 100644 --- a/src/Add-on/Erp/ErpCommands.ts +++ b/src/Add-on/Erp/ErpCommands.ts @@ -186,6 +186,18 @@ async function ExecChaiDan(chaiDanRoute: ErpRoutes) } } + if (userConfig.chaidanOption.reservedEdgeCheckTip) + { + if (boardList.some(br => br.IsSpecialShape ? br.BoardProcessOption.highReservedEdge.some(r => r.size != 0) : ["reservedEdgeUp", "reservedEdgeDown", "reservedEdgeLeft", "reservedEdgeRight"].some(k => br.BoardProcessOption[k] != "0"))) + { + AppToaster.show({ + message: `注意:拆单板件有预留边处理,会影响CNC(五面钻、六面钻、PTP等设备)加工程序的孔槽及异形轮廓切割的位置,如果有对接CNC加工设备进行加工的,请确认已对原有CNC程序进行升级对接(否则可能出现生产错误问题)!`, + timeout: 8000, + intent: Intent.WARNING, + }); + } + } + for (let br of boardList) { let b = br.__OriginalEnt__ ?? br; diff --git a/src/Add-on/Erp/Models/ArrayHelper.ts b/src/Add-on/Erp/Models/ArrayHelper.ts index 4b98836d6..af0719172 100644 --- a/src/Add-on/Erp/Models/ArrayHelper.ts +++ b/src/Add-on/Erp/Models/ArrayHelper.ts @@ -47,7 +47,7 @@ export function GetPointInfoArray(info: CadBlockInfo): [object, object, object, let orgPoints = GetArray(CadBlockPoint, info.OrgPointDetail); if (orgPoints.length > 0) { - orgPoints[0][5] = 1; + orgPoints[0][7] = 1; } return [ GetArray(CadBlockPoint, info.PointDetail), diff --git a/src/Add-on/Erp/Models/CadBlockInfo.ts b/src/Add-on/Erp/Models/CadBlockInfo.ts index c08f450bc..18fbb109e 100644 --- a/src/Add-on/Erp/Models/CadBlockInfo.ts +++ b/src/Add-on/Erp/Models/CadBlockInfo.ts @@ -23,10 +23,12 @@ export class CadBlockPoint extends BaseModel PointX: number; PointY: number; Curve: number; - SealSize: number; + SealSize: number;//封边厚度 + SealColor: string;//封边颜色 + ReservedEdge: number;//预留边 protected get props() { - return ['PointID', 'PointX', 'PointY', 'Curve', 'SealSize']; + return ['PointID', 'PointX', 'PointY', 'Curve', 'SealSize', 'SealColor', 'ReservedEdge']; } ToArray() { @@ -134,3 +136,10 @@ export class CadBlockInfo SideModelDetail: CadBlockModel[]; SideHoleDetail: CadBlockHoles[]; } +export class CadSealInfoPoint +{ + PointID: number; + SealSize: number;//封边厚度 + SealColor: string;//封边颜色 + ReservedEdge: number;//预留边 +} diff --git a/src/Add-on/Erp/ParseData.ts b/src/Add-on/Erp/ParseData.ts index d1e40e73f..cc275bc01 100644 --- a/src/Add-on/Erp/ParseData.ts +++ b/src/Add-on/Erp/ParseData.ts @@ -15,7 +15,7 @@ import { GetBoxArr, IdentityMtx4, equalv2 } from "../../Geometry/GeUtils"; import { IContourData } from "../../Production/Convert2PtsBul"; import { I2DModeling, I3DContourData, I3DModeling, IDrillingOption, IHardwareType, IModelingData, IOriginSideModelingData, ISpliteHardwareData, ISpliteOrderData, ModelType, Production } from '../../Production/Product'; import { EMetalsType } from "../../UI/Components/RightPanel/RightPanelInterface"; -import { ISealingData } from "../../UI/Store/OptionInterface/IHighSealedItem"; +import { IHighReservedEdgeItem, ISealingData } from "../../UI/Store/OptionInterface/IHighSealedItem"; import { FaceDirection } from "../DrawDrilling/DrillType"; // import { DownPanelStore } from "../../UI/Store/DownPanelStore"; import { HostApplicationServices } from "../../ApplicationServices/HostApplicationServices"; @@ -31,7 +31,7 @@ import { TemplateWineRackRecord } from './../../DatabaseServices/Template/Progra import { ErpGroupBy } from "./ErpGroupBy"; import { GetArray, GetPointInfoArray } from "./Models/ArrayHelper"; import { CadType, OrderDataBlock, WaveType } from "./Models/CadBlock"; -import { BasePosition, CadBlockHoles, CadBlockInfo, CadBlockModel, CadBlockModelPoint, CadBlockPoint, FaceType, HoleType, ModelOffSetData } from "./Models/CadBlockInfo"; +import { BasePosition, CadBlockHoles, CadBlockInfo, CadBlockModel, CadBlockModelPoint, CadBlockPoint, CadSealInfoPoint, FaceType, HoleType, ModelOffSetData } from "./Models/CadBlockInfo"; import { CADDbBoard } from "./Models/CadModel"; import { AlignLineGroupObject, OrderDataObject, ProcessGroupObject, ProcessGroupProjObject } from "./Models/CadObject"; import { DealAlignLineGroup, ParseAlignLine } from "./ParseDataFunction"; @@ -361,7 +361,7 @@ export class ErpParseData return w; } //获取异形数据 - GetPointDetail(points: IContourData, seals: ISealingData[]): CadBlockPoint[] + GetPointDetail(points: IContourData, seals: ISealingData[], reservedEdge: IHighReservedEdgeItem[]): CadBlockPoint[] { if (points == null || points.pts == null) return []; @@ -374,7 +374,6 @@ export class ErpParseData // intent: Intent.DANGER, // }); // } - let pointList: CadBlockPoint[] = []; for (let i = 0; i < points.pts.length; i++) { @@ -383,7 +382,9 @@ export class ErpParseData newPoint.PointX = points.pts[i].x; newPoint.PointY = points.pts[i].y; newPoint.Curve = points.buls[i]; - newPoint.SealSize = seals[i] ? seals[i].size : 0; + newPoint.SealSize = seals[i]?.size ?? 0; + newPoint.SealColor = seals[i]?.sealColor ?? ''; + newPoint.ReservedEdge = reservedEdge[i]?.size ?? 0; pointList.push(newPoint); } return pointList; @@ -673,8 +674,8 @@ export class ErpParseData let orgPointDetail: CadBlockPoint[] = []; if (board.info.isRect === false) { - pointDetail = this.GetPointDetail(board.outline, board.sealing);//TODO: 现在这个不应该在写入封边信息了 - orgPointDetail = this.GetPointDetail(board.originOutlin, board.sealing);//保留这个 + pointDetail = this.GetPointDetail(board.outline, board.sealing, board.reservedEdge);//TODO: 现在这个不应该在写入封边信息了 + orgPointDetail = this.GetPointDetail(board.originOutlin, board.sealing, board.reservedEdge);//保留这个 } else { @@ -843,14 +844,18 @@ export class ErpParseData ds.push(hole); } }, - sealGruopKey: (key: string, b: Board, size: number) => + sealGruopKey: (key: string, b: Board, thickness: string, data: ISealingData) => { + let material = b.BoardProcessOption[EBoardKeyList.Mat]; + let color = b.BoardProcessOption[EBoardKeyList.Color]; + if (data.sealColor) + color = data.sealColor; sealMap.set(key, { - size, - [EBoardKeyList.Mat]: b.BoardProcessOption[EBoardKeyList.Mat], + size: data.size, + [EBoardKeyList.Mat]: material, [EBoardKeyList.BrMat]: b.BoardProcessOption[EBoardKeyList.BrMat], - [EBoardKeyList.Thick]: b.Thickness, - [EBoardKeyList.Color]: b.BoardProcessOption[EBoardKeyList.Color] + [EBoardKeyList.Thick]: Number(thickness), + [EBoardKeyList.Color]: color }); } }; @@ -996,6 +1001,12 @@ export class ErpParseData const edgeRemarks = spliteData.boardEdgeRemark.length > 0 ? // 没有高级封边按顺序出 下 左 上 右出 spliteData.boardEdgeRemark.map(i => i ? i.description : '') : [board.BoardProcessOption.edgeRemarkDown ?? "", board.BoardProcessOption.edgeRemarkRight ?? "", board.BoardProcessOption.edgeRemarkUp ?? "", board.BoardProcessOption.edgeRemarkLeft ?? "",]; + //矩形封边信息 + let rectSealDetail = []; + if (spliteData.info.isRect) + { + rectSealDetail = this.GetRectSealDetail(spliteData.originOutlin, spliteData.sealing, spliteData.reservedEdge); + } const info = { boardType: { 0: '层板', 1: '立板', 2: '背板' }[board.BoardType], throughHoleCount, @@ -1005,7 +1016,8 @@ export class ErpParseData has3DModel, composingFace: { 0: '正面', 1: '反面', 2: '任意面' }[board.BoardProcessOption.composingFace], processList, - edgeRemarks + edgeRemarks, + rectSealDetail }; let remarks = spliteData.info.remarks.slice(); let boardRemark = remarks.find(t => t[0] == '#extra'); @@ -1026,6 +1038,22 @@ export class ErpParseData return cadObj.Name === "层板" || cadObj.Name === "立板"; return false; }; + //获取矩形封边数据 + GetRectSealDetail(points: IContourData, seals: ISealingData[], reservedEdge: IHighReservedEdgeItem[]): CadSealInfoPoint[] + { + if (points == null || points.pts == null) return []; + let pointList: CadSealInfoPoint[] = []; + for (let i = 0; i < points.pts.length; i++) + { + let newPoint = new CadSealInfoPoint(); + newPoint.PointID = i + 1; + newPoint.SealSize = seals[i]?.size ?? 0; + newPoint.SealColor = seals[i]?.sealColor ?? ''; + newPoint.ReservedEdge = reservedEdge[i]?.size ?? 0; + pointList.push(newPoint); + } + return pointList; + } groupBy(data: any[], fileds: string[]) { let groupList = {}; diff --git a/src/Add-on/KJL/Import/KJLImport.ts b/src/Add-on/KJL/Import/KJLImport.ts index 004c83c71..5e18ad699 100644 --- a/src/Add-on/KJL/Import/KJLImport.ts +++ b/src/Add-on/KJL/Import/KJLImport.ts @@ -358,7 +358,7 @@ async function ParseModel(model: KJL_ParamModel, { let sealeds: IHighSealedItem[] = edgesBandings[0].map(v => { - return { size: v }; + return { size: v, sealColor: "" }; }); let cus = pls[0].Explode(); let last = arrayLast(sealeds); diff --git a/src/Add-on/LatticeDrawer/LatticeDrawerTool.ts b/src/Add-on/LatticeDrawer/LatticeDrawerTool.ts index b28a49fea..990729cdf 100644 --- a/src/Add-on/LatticeDrawer/LatticeDrawerTool.ts +++ b/src/Add-on/LatticeDrawer/LatticeDrawerTool.ts @@ -297,17 +297,17 @@ export class DrawLatticeDrawerTool extends Singleton let sizes = [...new Set([downSealed, rightSealed, topSealed, leftSealed])]; let downSeal = { - size: downSealed, color: sizes.indexOf(downSealed) + 1 + size: downSealed, color: sizes.indexOf(downSealed) + 1, sealColor: "" }; let rigthSeal = { - size: rightSealed, color: sizes.indexOf(rightSealed) + 1 + size: rightSealed, color: sizes.indexOf(rightSealed) + 1, sealColor: "" }; - let topSeal = { size: topSealed, color: sizes.indexOf(topSealed) + 1 }; - let leftSeal = { size: leftSealed, color: sizes.indexOf(leftSealed) + 1 }; + let topSeal = { size: topSealed, color: sizes.indexOf(topSealed) + 1, sealColor: "" }; + let leftSeal = { size: leftSealed, color: sizes.indexOf(leftSealed) + 1, sealColor: "" }; if (isHor) { - let topSealNoSize = { size: 0, color: sizes.indexOf(topSealed) + 1 }; + let topSealNoSize = { size: 0, color: sizes.indexOf(topSealed) + 1, sealColor: "" }; highSeals.push(downSeal, rigthSeal); for (let i = 1; i <= cu.EndParam - 3; i++) @@ -323,7 +323,7 @@ export class DrawLatticeDrawerTool extends Singleton { let count = (this._config.depthCount - 1) * 3 + this._config.depthCount; - let downSealNoSize = { size: 0, color: sizes.indexOf(downSealed) + 1 }; + let downSealNoSize = { size: 0, color: sizes.indexOf(downSealed) + 1, sealColor: "" }; for (let i = 0; i < count; i++) { if (i % 4 === 0) diff --git a/src/Add-on/LookOverBoardInfos/LookOverBoardInfosTool.ts b/src/Add-on/LookOverBoardInfos/LookOverBoardInfosTool.ts index fe63b502c..d963f3ed0 100644 --- a/src/Add-on/LookOverBoardInfos/LookOverBoardInfosTool.ts +++ b/src/Add-on/LookOverBoardInfos/LookOverBoardInfosTool.ts @@ -31,7 +31,7 @@ export interface ICountType goodsId?: string; goodsSn?: string; } -export type GetCountOption = { sealGruopKey: (key: string, block: Board, size: number) => void; getHoles?: (name: string, hole: CylinderHole) => void; }; +export type GetCountOption = { sealGruopKey: (key: string, block: Board, thickness: string, data: ISealingData) => void; getHoles?: (name: string, hole: CylinderHole) => void; }; class LookOverBoardInfosTool { private drillTypeMap: Map = new Map(); @@ -268,9 +268,7 @@ class LookOverBoardInfosTool throw "错误:板扣除封边失败!"; } - let sealData: ISealingData[] = Production.ParseSealData(sealdData); - let color = br.BoardProcessOption[EBoardKeyList.Color]; - + let { seals: sealData, reservedEdges } = Production.ParseSealData(sealdData, br.BoardProcessOption.color); //封边留头量 let sealReserve = HostApplicationServices.sealReserve * 2; @@ -280,11 +278,11 @@ class LookOverBoardInfosTool { if (equaln(0, data.size)) continue; data.length += sealReserve; - + let color = data.sealColor; let k = `${data.size}-${FixedNotZero(thickness, 2)}-${color}`; if (options && options.sealGruopKey) { - options.sealGruopKey(k, br, data.size); + options.sealGruopKey(k, br, thickness, data); } let len = this.sealMap.get(k); if (!len) diff --git a/src/Common/CheckoutVaildValue.ts b/src/Common/CheckoutVaildValue.ts index 19d5acfbd..8a17a5aa4 100644 --- a/src/Common/CheckoutVaildValue.ts +++ b/src/Common/CheckoutVaildValue.ts @@ -285,6 +285,10 @@ export namespace CheckoutValid case "grooveAddDepth2": case "grooveAddWidth2": case "back": + case "reservedEdgeUp": + case "reservedEdgeDown": + case "reservedEdgeLeft": + case "reservedEdgeRight": { let val = safeEval(v); if (isNaN(val)) diff --git a/src/Common/CommandNames.ts b/src/Common/CommandNames.ts index 63d8ac0f4..e71c667b5 100644 --- a/src/Common/CommandNames.ts +++ b/src/Common/CommandNames.ts @@ -353,6 +353,7 @@ export enum CommandNames 封边属性编辑 = "封边属性编辑", 板边备注编辑 = "板边备注编辑", 排钻属性编辑 = "排钻属性编辑", + 预留边属性编辑 = "预留边属性编辑", SwitchServers = "SWITCHSERVERS", Replace = "重新放置模型", diff --git a/src/Common/InterfereUtil.ts b/src/Common/InterfereUtil.ts index f4300bab1..114d34db0 100644 --- a/src/Common/InterfereUtil.ts +++ b/src/Common/InterfereUtil.ts @@ -16,7 +16,7 @@ import { TemplateWineRackRecord } from "../DatabaseServices/Template/ProgramTemp import { OBB } from "../Geometry/OBB/obb"; import { FuzzyFactory } from "../csg/core/FuzzyFactory"; import { CSG2Geometry2, Geometry2CSG2 } from "../csg/core/Geometry2CSG"; -import { CSGIntersect } from "./CSGIntersect"; +import { CSGIntersect, Geom3Res } from "./CSGIntersect"; import { ColorMaterial } from "./ColorPalette"; import { Log, LogType } from "./Log"; import { Sleep } from "./Sleep"; @@ -170,7 +170,7 @@ export class CheckInterfereTool continue; } - let interCsg = CSGIntersect(csg1, csg2, e1.OCSInv.multiply(e2.OCSNoClone)); + let interCsg = CSGIntersect(csg1, csg2, e1.OCSInv.multiply(e2.OCSNoClone)) as unknown as Geom3Res; // 先判断交集是否围城一个实体,再判断该实体是否造成干涉 let planeSet = new Set(); let f = new FuzzyFactory; diff --git a/src/DatabaseServices/Entity/Board.ts b/src/DatabaseServices/Entity/Board.ts index 18bf4fbd1..3775d882b 100644 --- a/src/DatabaseServices/Entity/Board.ts +++ b/src/DatabaseServices/Entity/Board.ts @@ -31,7 +31,7 @@ import { AddCSGSubtractTask, CSGTask, TerminateCSGTask } from '../../Geometry/CS import { EdgesGeometry } from '../../Geometry/EdgeGeometry'; import { AsVector2, AsVector3, IdentityMtx4, UpdateBoundingSphere, XAxis, XAxisN, YAxis, YAxisN, ZAxis, ZeroVec, equaln, equalv2, equalv3 } from '../../Geometry/GeUtils'; import { PointShapeUtils } from '../../Geometry/PointShapeUtils'; -import { GetBoardContour, GetBoardHighSeal, GetBoardSealingCurves, GetHighBoardEdgeRemark, SetBoardEdgeRemarkData, SetBoardTopDownLeftRightSealData } from '../../GraphicsSystem/CalcEdgeSealing'; +import { GetBoardContour, GetBoardHighReservedEdge, GetBoardHighSeal, GetBoardSealingCurves, GetHighBoardEdgeRemark, SetBoardEdgeRemarkData, SetBoardReservedEdgeData, SetBoardTopDownLeftRightSealData } from '../../GraphicsSystem/CalcEdgeSealing'; import { RenderType } from '../../GraphicsSystem/RenderType'; import { BoardProcessOption } from "../../UI/Store/OptionInterface/BoardProcessOption"; import { CSG2Geometry2, Geometry2CSG2 } from '../../csg/core/Geometry2CSG'; @@ -582,6 +582,16 @@ export class Board extends ExtrudeSolid edgeRemarkLeft: "", edgeRemarkRight: "", highBoardEdgeRemark: this.CreateArray(), + reservedEdgeUp: "0", + reservedEdgeDown: "0", + reservedEdgeRight: "0", + reservedEdgeLeft: "0", + highReservedEdge: this.CreateArray(), + sealColorUp: "", + sealColorDown: "", + sealColorLeft: "", + sealColorRight: "", + sealColorType: "", }; this._BoardProcessOption = new Proxy(defaultData, { @@ -594,7 +604,7 @@ export class Board extends ExtrudeSolid if (Reflect.get(target, key, receiver) !== value) { this.WriteAllObjectRecord(); - if (key === "highDrill" || key === EBoardKeyList.HighSealed || key === "highBoardEdgeRemark") + if (key === "highDrill" || key === EBoardKeyList.HighSealed || key === "highBoardEdgeRemark" || key === "highReservedEdge") { let arr = this.CreateArray() as any[]; arr.push(...value); @@ -796,8 +806,9 @@ export class Board extends ExtrudeSolid { Object.assign(this._BoardProcessOption, obj, { - [EBoardKeyList.HighSealed]: obj[EBoardKeyList.HighSealed].slice(), - highBoardEdgeRemark: obj.highBoardEdgeRemark.slice(), + [EBoardKeyList.HighSealed]: structuredClone(obj[EBoardKeyList.HighSealed]), + highBoardEdgeRemark: structuredClone(obj.highBoardEdgeRemark), + highReservedEdge: structuredClone(obj.highReservedEdge) }); } get NeedUpdateRelevanceGroove() @@ -1470,7 +1481,8 @@ export class Board extends ExtrudeSolid let oldHightSealCurves = GetBoardSealingCurves(this);//旧的封边轮廓 let oldHightSealDatas = GetBoardHighSeal(this, oldHightSealCurves);//旧的封边数据 - let oldHighBoardEdgeRemarkDatas = GetHighBoardEdgeRemark(this, oldHightSealCurves);//旧的封边数据 + let oldHighBoardEdgeRemarkDatas = GetHighBoardEdgeRemark(this, oldHightSealCurves);//旧的板边备注数据 + let oldHighReservedEdgeDatas = GetBoardHighReservedEdge(this, oldHightSealCurves);//旧的预留边数据 let splitSideModel = false; @@ -1524,11 +1536,13 @@ export class Board extends ExtrudeSolid this._BoardProcessOption.highSealed.length = 0; this._BoardProcessOption.highBoardEdgeRemark.length = 0; + this._BoardProcessOption.highReservedEdge.length = 0; //保持封边属性 if (this.isRect) { SetBoardTopDownLeftRightSealData(this, oldHightSealDatas, oldHightSealCurves, oldContour); SetBoardEdgeRemarkData(this, oldHighBoardEdgeRemarkDatas, oldHightSealCurves, oldContour); + SetBoardReservedEdgeData(this, oldHighReservedEdgeDatas, oldHightSealCurves, oldContour); } else//变成了异形 { @@ -1555,6 +1569,7 @@ export class Board extends ExtrudeSolid this._BoardProcessOption.highSealed.push(oldHightSealDatas[closesIndex]); this._BoardProcessOption.highBoardEdgeRemark.push(oldHighBoardEdgeRemarkDatas[closesIndex]); + this._BoardProcessOption.highReservedEdge.push(oldHighReservedEdgeDatas[closesIndex]); } } @@ -3365,6 +3380,7 @@ export class Board extends ExtrudeSolid processData.edgeRemarkLeft = file.Read(); processData.edgeRemarkRight = file.Read(); let count = file.Read(); + processData.highBoardEdgeRemark.length = 0; processData.highBoardEdgeRemark = file.ReadArray(count); } @@ -3427,12 +3443,34 @@ export class Board extends ExtrudeSolid this._LockMaterial = file.ReadBool(); else this._LockMaterial = false; + + if (ver > 23) + { + processData.reservedEdgeUp = file.Read(); + processData.reservedEdgeDown = file.Read(); + processData.reservedEdgeLeft = file.Read(); + processData.reservedEdgeRight = file.Read(); + let count = file.Read(); + processData.highReservedEdge.length = 0; + for (let i = 0; i < count; i++) + { + let size = file.Read(); + processData.highReservedEdge.push({ size }); + } + + processData.sealColorUp = file.Read(); + processData.sealColorDown = file.Read(); + processData.sealColorLeft = file.Read(); + processData.sealColorRight = file.Read(); + + processData.sealColorType = file.Read(); + } } WriteFile(file: CADFiler) { super.WriteFile(file); - file.Write(23); + file.Write(24); // file.Write(this._SpaceOCS.toArray()); ver < 6 file.Write(this._BoardType); file.Write(this._Name); @@ -3537,6 +3575,23 @@ export class Board extends ExtrudeSolid // ver 23 file.WriteBool(this._LockMaterial); + + //ver 24 + file.Write(processData.reservedEdgeUp); + file.Write(processData.reservedEdgeDown); + file.Write(processData.reservedEdgeLeft); + file.Write(processData.reservedEdgeRight); + file.Write(processData.highReservedEdge.length); + for (let r of processData.highReservedEdge) + { + file.Write(r.size); + } + file.Write(processData.sealColorUp); + file.Write(processData.sealColorDown); + file.Write(processData.sealColorLeft); + file.Write(processData.sealColorRight); + + file.Write(processData.sealColorType); } } diff --git a/src/Editor/DefaultConfig.ts b/src/Editor/DefaultConfig.ts index 30f7e2a1f..d24412e3f 100644 --- a/src/Editor/DefaultConfig.ts +++ b/src/Editor/DefaultConfig.ts @@ -491,7 +491,7 @@ export const DefaultLatticOption: ILatticeOption = { Object.freeze(DefaultLatticOption); export const DefaultDoorOption: IDoorConfigOption = { - version: 12, + version: 13, col: 2, row: 1, isAllSelect: true, @@ -559,6 +559,30 @@ export const DefaultDoorOption: IDoorConfigOption = { verticalEdgeRemarkLeft: '', verticalEdgeRemarkRight: '', parseHinge: false, + sealColorUp: "", //门板封边颜色 + sealColorDown: "", + sealColorLeft: "", + sealColorRight: "", + reservedEdgeUp: "0", //门板预留边 + reservedEdgeDown: "0", + reservedEdgeLeft: "0", + reservedEdgeRight: "0", + layerSealColorUp: "", //层板封边颜色 + layerSealColorDown: "", + layerSealColorLeft: "", + layerSealColorRight: "", + layerReservedEdgeUp: "0", //层板预留边 + layerReservedEdgeDown: "0", + layerReservedEdgeLeft: "0", + layerReservedEdgeRight: "0", + verticalSealColorUp: "", //立板封边颜色 + verticalSealColorDown: "", + verticalSealColorLeft: "", + verticalSealColorRight: "", + verticalReservedEdgeUp: "0", //层板预留边 + verticalReservedEdgeDown: "0", + verticalReservedEdgeLeft: "0", + verticalReservedEdgeRight: "0", }; Object.freeze(DefaultDoorOption); export const DefaultHingeOption: IHingeConfigOption = { @@ -572,7 +596,7 @@ export const DefaultHingeOption: IHingeConfigOption = { }; Object.freeze(DefaultHingeOption); export const DefaultDrawerOption: IDrawerConfigOption = { - version: 9, + version: 10, col: 1, row: 1, isAllSelect: true, @@ -619,6 +643,14 @@ export const DefaultDrawerOption: IDrawerConfigOption = { color: "",//颜色 roomName: "",//房名 cabinetName: "",//柜名 + sealColorUp: "", //抽屉立板封边颜色 + sealColorDown: "", + sealColorLeft: "", + sealColorRight: "", + reservedEdgeUp: "0", //抽屉立板预留边 + reservedEdgeDown: "0", + reservedEdgeLeft: "0", + reservedEdgeRight: "0", }; Object.freeze(DefaultDrawerOption); @@ -774,7 +806,7 @@ export const DefaultToplineMetalsOption: IToplineOption = { Object.freeze(DefaultToplineMetalsOption); export const DefaultBoardProcessOption: BoardProcessOption = { - version: 4, + version: 5, roomName: "", cabinetName: "", boardName: "", @@ -802,6 +834,16 @@ export const DefaultBoardProcessOption: BoardProcessOption = { edgeRemarkLeft: "", edgeRemarkRight: "", highBoardEdgeRemark: [], + reservedEdgeUp: "0", + reservedEdgeDown: "0", + reservedEdgeLeft: "0", + reservedEdgeRight: "0", + highReservedEdge: [], + sealColorUp: "", + sealColorDown: "", + sealColorLeft: "", + sealColorRight: "", + sealColorType: "", }; Object.freeze(DefaultBoardProcessOption); diff --git a/src/Editor/UserConfig.ts b/src/Editor/UserConfig.ts index 1686c25dc..98c80a8f5 100644 --- a/src/Editor/UserConfig.ts +++ b/src/Editor/UserConfig.ts @@ -53,7 +53,7 @@ export interface IChat export class UserConfig implements IConfigStore { - private readonly _version = 47; //🌟🌟每次更新必须向上添加一次版本号🌟🌟 + private readonly _version = 48; //🌟🌟每次更新必须向上添加一次版本号🌟🌟 @observable designer = ""; //一键布局的设计师 _renderType: RenderType = RenderType.Wireframe; @observable maxSize: IMaxSizeProps = { @@ -139,6 +139,7 @@ export class UserConfig implements IConfigStore xlineLength: 20000, //构造线长度默认使用20000 cancelHoleProcessing: false,//填写拆单尺寸板件取消孔槽加工 isCheckCustomBoardNumber: false,//是否开启自动板件编号校验 + reservedEdgeCheckTip: true,//是否显示预留边检查提示 }; @observable viewSize = { minViewHeight: 1e-3, @@ -201,6 +202,7 @@ export class UserConfig implements IConfigStore @observable autoDeviation: boolean = false;//排钻自动偏移 @observable autoDeviationMinDist: number = 200; //排钻自动偏移的最小排钻面 @observable drillShortPrior: boolean = false;//排钻的碰撞面短的优先排钻 + @observable reservedEdgeCheckTip: boolean = true;//是否显示预留边检查提示 constructor() { @@ -267,6 +269,7 @@ export class UserConfig implements IConfigStore xlineLength: 20000, cancelHoleProcessing: false, isCheckCustomBoardNumber: false, + reservedEdgeCheckTip: true, }); Object.assign(this.textStyleOption, { appointTextHight: false, @@ -322,6 +325,7 @@ export class UserConfig implements IConfigStore this.drillShortPrior = false; this.autoDeviationMinDist = 200; this.isShowAxesMatrix = true; + this.reservedEdgeCheckTip = true; } SaveConfig() { @@ -387,6 +391,7 @@ export class UserConfig implements IConfigStore drillShortPrior: this.drillShortPrior, autoDeviationMinDist: this.autoDeviationMinDist, isShowAxesMatrix: this.isShowAxesMatrix, + reservedEdgeCheckTip: this.reservedEdgeCheckTip, } }; } @@ -603,6 +608,10 @@ export class UserConfig implements IConfigStore { this.isShowAxesMatrix = config.option.isShowAxesMatrix; } + if (config.option.version > 47) + { + this.reservedEdgeCheckTip = config.option.reservedEdgeCheckTip; + } } } diff --git a/src/Geometry/DrillParse/BoardGetFace.ts b/src/Geometry/DrillParse/BoardGetFace.ts index ab233a287..16b8909be 100644 --- a/src/Geometry/DrillParse/BoardGetFace.ts +++ b/src/Geometry/DrillParse/BoardGetFace.ts @@ -149,7 +149,7 @@ export class BoardGetFace if (highSealingData) { let cus = (br.ContourCurve.Clone() as Polyline).Explode(); - highSealingData.push(...GetBoardHighSeal(br, cus)); + highSealingData.push(...structuredClone(GetBoardHighSeal(br, cus))); sealCu.push(...cus); } diff --git a/src/GraphicsSystem/CalcEdgeSealing.ts b/src/GraphicsSystem/CalcEdgeSealing.ts index 8b1affefa..f52d6aa49 100644 --- a/src/GraphicsSystem/CalcEdgeSealing.ts +++ b/src/GraphicsSystem/CalcEdgeSealing.ts @@ -16,7 +16,7 @@ import { CreateContour2 } from "../Geometry/CreateContour2"; import { IdentityMtx4, XAxis, equaln, equalv3, isParallelTo } from "../Geometry/GeUtils"; import { Max } from "../Nest/Common/Util"; import { Production } from "../Production/Product"; -import { IHighEdgeRemarkItem, IHighSealedItem } from "../UI/Store/OptionInterface/IHighSealedItem"; +import { IHighEdgeRemarkItem, IHighReservedEdgeItem, IHighSealedItem } from "../UI/Store/OptionInterface/IHighSealedItem"; import { OffsetPolyline } from "./OffsetPolyline"; import { ParseEdgeSealDir } from "./ParseEdgeSealDir"; @@ -148,16 +148,17 @@ export function SubsectionCurvesOfHightSeal(in_out_curves: Curve[]): CurveGroups //与GetBoardSealingCurves相关 export function GetBoardHighSeal(br: Board, sealcus: Curve[]): IHighSealedItem[] { - if (br.BoardProcessOption[EBoardKeyList.SpliteHeight] - && br.BoardProcessOption[EBoardKeyList.SpliteWidth] - && br.BoardProcessOption[EBoardKeyList.SpliteThickness] + const option = br.BoardProcessOption; + if (option[EBoardKeyList.SpliteHeight] + && option[EBoardKeyList.SpliteWidth] + && option[EBoardKeyList.SpliteThickness] ) { return [ - { size: parseFloat(br.BoardProcessOption.sealedDown) }, - { size: parseFloat(br.BoardProcessOption.sealedRight) }, - { size: parseFloat(br.BoardProcessOption.sealedUp) }, - { size: parseFloat(br.BoardProcessOption.sealedLeft) }, + { size: parseFloat(option.sealedDown), sealColor: option.sealColorDown }, + { size: parseFloat(option.sealedRight), sealColor: option.sealColorRight }, + { size: parseFloat(option.sealedUp), sealColor: option.sealColorUp }, + { size: parseFloat(option.sealedLeft), sealColor: option.sealColorLeft }, ]; } @@ -183,16 +184,16 @@ export function GetBoardHighSeal(br: Board, sealcus: Curve[]): IHighSealedItem[] if (Math.abs(derv.x) > Math.abs(derv.y)) { if (derv.x > 0) - highSeals.push({ size: sealDown }); + highSeals.push({ size: sealDown, sealColor: option.sealColorDown }); else - highSeals.push({ size: sealUp }); + highSeals.push({ size: sealUp, sealColor: option.sealColorUp }); } else { if (derv.y > 0) - highSeals.push({ size: sealRight }); + highSeals.push({ size: sealRight, sealColor: option.sealColorRight }); else - highSeals.push({ size: sealLeft }); + highSeals.push({ size: sealLeft, sealColor: option.sealColorLeft }); } } } @@ -200,6 +201,60 @@ export function GetBoardHighSeal(br: Board, sealcus: Curve[]): IHighSealedItem[] return highSeals; } +export function GetBoardHighReservedEdge(br: Board, sealcus: Curve[]): IHighReservedEdgeItem[] +{ + if (br.BoardProcessOption[EBoardKeyList.SpliteHeight] + && br.BoardProcessOption[EBoardKeyList.SpliteWidth] + && br.BoardProcessOption[EBoardKeyList.SpliteThickness] + ) + { + return [ + { size: parseFloat(br.BoardProcessOption.reservedEdgeDown) }, + { size: parseFloat(br.BoardProcessOption.reservedEdgeRight) }, + { size: parseFloat(br.BoardProcessOption.reservedEdgeUp) }, + { size: parseFloat(br.BoardProcessOption.reservedEdgeLeft) }, + ]; + } + + let highReservedEdge: IHighReservedEdgeItem[] = []; + for (let d of br.BoardProcessOption.highReservedEdge) + if (d.size != null) + highReservedEdge.push({ ...d }); + + //若未设置高级封边,把上下左右封边存入高级封边 + if (sealcus.length !== highReservedEdge.length || !br.IsSpecialShape) + { + let reservedEdgeDown = parseFloat(br.BoardProcessOption.reservedEdgeDown); + let reservedEdgeUp = parseFloat(br.BoardProcessOption.reservedEdgeUp); + let reservedEdgeLeft = parseFloat(br.BoardProcessOption.reservedEdgeLeft); + let reservedEdgeRight = parseFloat(br.BoardProcessOption.reservedEdgeRight); + + highReservedEdge.length = 0; + let dir = Math.sign(br.ContourCurve.Area2); + for (let c of sealcus) + { + let derv = c.GetFirstDeriv(0).multiplyScalar(dir); + + if (Math.abs(derv.x) > Math.abs(derv.y)) + { + if (derv.x > 0) + highReservedEdge.push({ size: reservedEdgeDown }); + else + highReservedEdge.push({ size: reservedEdgeUp }); + } + else + { + if (derv.y > 0) + highReservedEdge.push({ size: reservedEdgeRight }); + else + highReservedEdge.push({ size: reservedEdgeLeft }); + } + } + } + + return highReservedEdge; +} + export function GetHighBoardEdgeRemark(br: Board, sealcus: Curve[]): IHighEdgeRemarkItem[] { const opt = br.BoardProcessOption; @@ -313,6 +368,7 @@ export interface BrSealedData brCurves: Curve[];//封边轮廓(高级封边 已经成组) highSeals: IHighSealedItem[];//高级封边(一一对应) + highReservedEdges: IHighReservedEdgeItem[];//高级预留边 hasSealedErr?: boolean;//调用 GetSealedBoardContour 方法时判断是否有出现封边异常 } @@ -378,6 +434,7 @@ export function GetSealedBoardContour(br: Board): BrSealedData | undefined let curves = GetBoardSealingCurves(br); let highSeals = GetBoardHighSeal(br, curves); + let highReservedEdges = GetBoardHighReservedEdge(br, curves); if (curves.length === 1 && curves[0] instanceof Circle) { @@ -386,6 +443,7 @@ export function GetSealedBoardContour(br: Board): BrSealedData | undefined sealedContour: curves[0].GetOffsetCurves(-highSeals[0].size)[0] as Circle, brCurves: curves, highSeals, + highReservedEdges, }; return res; } @@ -407,56 +465,72 @@ export function GetSealedBoardContour(br: Board): BrSealedData | undefined } else { - //局部偏移 - let polylineOffset = new OffsetPolyline2(brContour, dir * -Math.max(...highSeals.map(s => s.size))); - let subIndex = 0; - polylineOffset._TrimCircleContours = []; - polylineOffset._TrimArcContours = []; - polylineOffset._SubOffsetedCurves = []; - polylineOffset._SubCurves = []; - polylineOffset._Circles = []; - polylineOffset._CacheOCS = IdentityMtx4; - polylineOffset._IsClose = true; - + let positiveOffset: number; //正偏移 + let negativeOffset: number; //负偏移 for (let i = 0; i < curves.length; i++) { - let curve = curves[i];//曲线组 let seal = highSeals[i];//封边 + let reservedEdge = highReservedEdges[i]; + let offDist = -seal.size + reservedEdge.size; + if (offDist > 0) + positiveOffset = positiveOffset === undefined ? offDist : (positiveOffset > offDist ? positiveOffset : offDist); + else + negativeOffset = negativeOffset === undefined ? offDist : (negativeOffset < offDist ? negativeOffset : offDist); + } - let preSeal = highSeals[FixIndex(i - 1, curves)]; + //先分解多段线生成对应线段和封边值,防止两次偏移得到的线段数不一致 + const newSeal: IHighSealedItem[] = []; + const newReservedEdge: IHighReservedEdgeItem[] = []; + const newCurves: Curve[] = []; + for (let i = 0; i < curves.length; i++) + { + let seal = highSeals[i]; + let reservedEdge = highReservedEdges[i]; + let curve = curves[i]; if (curve instanceof Polyline) { let curveExpds = curve.Explode().filter(c => c.Length >= 1e-4); - - for (let j = 0; j < curveExpds.length; j++) + for (const c of curveExpds) { - let c = curveExpds[j]; - - polylineOffset._SubCurves.push(c);//sub - - //trim Circle - if (seal.size && (j || seal.size === preSeal.size)) - polylineOffset._Circles.push(new Circle(c.StartPoint, seal.size)); - else - polylineOffset._Circles.push(undefined); - - //offset - let offsetC = c.GetOffsetCurves(dir * -seal.size)[0]; - if (offsetC) - polylineOffset._SubOffsetedCurves.push({ - index: subIndex, - curve: offsetC, - dist: seal.size, - }); - else - polylineOffset._TrimArcContours.push(Contour.CreateContour([c, new Line(c.StartPoint, c.EndPoint)], false)); - - subIndex++; + newSeal.push(seal); + newReservedEdge.push(reservedEdge); + newCurves.push(c); } } else { + newSeal.push(seal); + newReservedEdge.push(reservedEdge); + newCurves.push(curve); + } + } + + const SealedContours = (curves: Curve[], highSeals: IHighSealedItem[], highReservedEdges: IHighReservedEdgeItem[], dist: number) => + { + //局部偏移 + let polylineOffset = new OffsetPolyline2(brContour, dir * dist); + let subIndex = 0; + polylineOffset._TrimCircleContours = []; + polylineOffset._TrimArcContours = []; + polylineOffset._SubOffsetedCurves = []; + polylineOffset._SubCurves = []; + polylineOffset._Circles = []; + polylineOffset._CacheOCS = IdentityMtx4; + polylineOffset._IsClose = true; + + for (let i = 0; i < curves.length; i++) + { + let curve = curves[i];//曲线组 + let seal = highSeals[i];//封边 + let reservedEdge = highReservedEdges[i]; + + let offDist = -seal.size + reservedEdge.size; + if (Math.sign(offDist) != Math.sign(dist)) + offDist = 0; + + let preSeal = highSeals[FixIndex(i - 1, curves)]; + if (curve.Length < 1e-4) continue; polylineOffset._SubCurves.push(curve);//sub @@ -468,23 +542,41 @@ export function GetSealedBoardContour(br: Board): BrSealedData | undefined polylineOffset._Circles.push(undefined); //offset - let offsetC = curve.GetOffsetCurves(dir * -seal.size)[0]; + let offsetC = curve.GetOffsetCurves(dir * offDist)[0]; if (offsetC) polylineOffset._SubOffsetedCurves.push({ index: subIndex, curve: offsetC, - dist: seal.size, + dist: -offDist, }); else polylineOffset._TrimArcContours.push(Contour.CreateContour([curve, new Line(curve.StartPoint, curve.EndPoint)], false)); subIndex++; } - } - polylineOffset._Vertexs = polylineOffset._SubCurves.map(c => c.StartPoint); + polylineOffset._Vertexs = polylineOffset._SubCurves.map(c => c.StartPoint); - sealedContours = polylineOffset.Do(); + polylineOffset.Do(); + return polylineOffset; + }; + + let polylineOffset1: OffsetPolyline2; + let offCurves = newCurves; + //先判断负偏移 + if (negativeOffset != undefined) + { + polylineOffset1 = SealedContours(newCurves, newSeal, newReservedEdge, negativeOffset); + offCurves = polylineOffset1._SubOffsetedCurves.map((s) => s.curve); + } + //如果存在正偏移,再偏移一次 + if (positiveOffset != undefined) + { + let polylineOffset2 = SealedContours(offCurves, newSeal, newReservedEdge, positiveOffset); + sealedContours = polylineOffset2._RetCurves; + } + else + sealedContours = polylineOffset1._RetCurves; } let hasSealedErr = false; @@ -528,6 +620,7 @@ export function GetSealedBoardContour(br: Board): BrSealedData | undefined sealedContour, brCurves: curves, highSeals, + highReservedEdges, hasSealedErr }; @@ -544,7 +637,7 @@ export function GetSealedBoardContour(br: Board): BrSealedData | undefined export function ConverEachSeal2HightSealData(seals: IHighSealedItem[], curves: Curve[]): IHighSealedItem[] { curves = curves.concat(); - seals = seals.concat(); + seals = structuredClone(seals); let lastSeal = seals[seals.length - 1]; for (let i = seals.length; i < curves.length; i++) @@ -583,20 +676,34 @@ export function SetBoardTopDownLeftRightSealData(br: Board, sealDatas: IHighSeal { for (let i = 0; i < 4; i++) { + const size = sealDatas[i].size.toString(); + const { sealColor: color = "" } = sealDatas[i]; let derv = sealCurves[i].GetFirstDeriv(0).normalize(); if (isParallelTo(derv, XAxis, 1e-4)) { if (derv.x * dir > 0) - br.BoardProcessOption[EBoardKeyList.DownSealed] = sealDatas[i].size.toString(); + { + br.BoardProcessOption[EBoardKeyList.DownSealed] = size; + br.BoardProcessOption.sealColorDown = color; + } else - br.BoardProcessOption[EBoardKeyList.UpSealed] = sealDatas[i].size.toString(); + { + br.BoardProcessOption[EBoardKeyList.UpSealed] = size; + br.BoardProcessOption.sealColorUp = color; + } } else { if (derv.y * dir > 0) - br.BoardProcessOption[EBoardKeyList.RightSealed] = sealDatas[i].size.toString(); + { + br.BoardProcessOption[EBoardKeyList.RightSealed] = size; + br.BoardProcessOption.sealColorRight = color; + } else - br.BoardProcessOption[EBoardKeyList.LeftSealed] = sealDatas[i].size.toString(); + { + br.BoardProcessOption[EBoardKeyList.LeftSealed] = size; + br.BoardProcessOption.sealColorLeft = color; + } } } } @@ -609,6 +716,49 @@ export function SetBoardTopDownLeftRightSealData(br: Board, sealDatas: IHighSeal br.BoardProcessOption[EBoardKeyList.RightSealed] = sealDatas[right].size.toString(); br.BoardProcessOption[EBoardKeyList.UpSealed] = sealDatas[top].size.toString(); br.BoardProcessOption[EBoardKeyList.DownSealed] = sealDatas[bottom].size.toString(); + + br.BoardProcessOption.sealColorLeft = sealDatas[left].sealColor ?? ""; + br.BoardProcessOption.sealColorRight = sealDatas[right].sealColor ?? ""; + br.BoardProcessOption.sealColorUp = sealDatas[top].sealColor ?? ""; + br.BoardProcessOption.sealColorDown = sealDatas[bottom].sealColor ?? ""; + } +} + +export function SetBoardReservedEdgeData(br: Board, sealDatas: IHighReservedEdgeItem[], sealCurves?: Curve[], brContourCurve?: ExtrudeContourCurve) +{ + let dir = Math.sign((brContourCurve ?? br.ContourCurve).Area2); + sealCurves = sealCurves ?? GetBoardSealingCurves(br); + + if (br.IsRect && sealCurves.length === 4) + { + for (let i = 0; i < 4; i++) + { + let derv = sealCurves[i].GetFirstDeriv(0).normalize(); + if (isParallelTo(derv, XAxis, 1e-4)) + { + if (derv.x * dir > 0) + br.BoardProcessOption.reservedEdgeDown = sealDatas[i].size.toString(); + else + br.BoardProcessOption.reservedEdgeUp = sealDatas[i].size.toString(); + } + else + { + if (derv.y * dir > 0) + br.BoardProcessOption.reservedEdgeRight = sealDatas[i].size.toString(); + else + br.BoardProcessOption.reservedEdgeLeft = sealDatas[i].size.toString(); + } + } + } + else + { + if (sealCurves.length === 0) + return; + let [left, right, top, bottom] = ParseEdgeSealDir(sealCurves); + br.BoardProcessOption.reservedEdgeLeft = sealDatas[left].size.toString(); + br.BoardProcessOption.reservedEdgeRight = sealDatas[right].size.toString(); + br.BoardProcessOption.reservedEdgeUp = sealDatas[top].size.toString(); + br.BoardProcessOption.reservedEdgeDown = sealDatas[bottom].size.toString(); } } diff --git a/src/Production/Product.ts b/src/Production/Product.ts index b016ddaa3..6eaafe1d3 100644 --- a/src/Production/Product.ts +++ b/src/Production/Product.ts @@ -30,7 +30,7 @@ import { AsVector2, IsBetweenA2B, MoveMatrix, XAxis, angle, angleTo, equaln, equ import { BrSealedData, GetSealedBoardContour } from "../GraphicsSystem/CalcEdgeSealing"; import { FeedingToolPath, GetModelingFromCustomDrill } from "../GraphicsSystem/ToolPath/FeedingToolPath"; import { EMetalsType, IHardwareOption, IToplineOption } from "../UI/Components/RightPanel/RightPanelInterface"; -import { IHighEdgeRemarkItem, ISealingData } from "../UI/Store/OptionInterface/IHighSealedItem"; +import { IHighEdgeRemarkItem, IHighReservedEdgeItem, ISealingData } from "../UI/Store/OptionInterface/IHighSealedItem"; import { Entity } from './../DatabaseServices/Entity/Entity'; import { ICompHardwareOption } from './../UI/Components/RightPanel/RightPanelInterface'; import { ConverArcToPtsBul, ConverToPtsBul, IContourData } from "./Convert2PtsBul"; @@ -114,6 +114,7 @@ export interface ISpliteOrderData outline: IContourData; //拆单轮廓信息 sealing: ISealingData[]; //封边信息 boardEdgeRemark: IHighEdgeRemarkItem[]; //板边备注信息 + reservedEdge: IHighReservedEdgeItem[]; //预留边信息 modeling: IModelingData[]; //造型信息 curveBoardModeling: IModeling[]; holes: IBoardHoleInfo; //孔信息 @@ -217,13 +218,15 @@ export namespace Production boardContour = ConverToPtsBul(br.ContourCurve);//不分裂圆弧转点表 //每段封边信息 - let perSealData = ParseSealData(sealedData); + let { seals: perSealData, reservedEdges: perReservedEdgeData } = ParseSealData(sealedData, br.BoardProcessOption.color); let perBoardEdgeRemarkData = br.IsSpecialShape ? ParseBoardEdgeRemarkData(sealedData, br.BoardProcessOption.highBoardEdgeRemark) : []; //因为传递给拆单软件的数据是逆时针,所以我们翻转它 if (orgContour.Area2 < 0) { perSealData.reverse(); + perBoardEdgeRemarkData.reverse(); + perReservedEdgeData.reverse(); //对应sealedOutlinePtsBul顺序 解析孔时翻转orgContour orgContour.Reverse(); @@ -238,6 +241,7 @@ export namespace Production outline: sealedOutlinePtsBul, //扣完封边的点表 sealing: perSealData,//每段曲线的封边信息 boardEdgeRemark: perBoardEdgeRemarkData, //每段曲线的板边备注信息 + reservedEdge: perReservedEdgeData, //每段曲线的预留边信息 modeling, curveBoardModeling, holes, @@ -252,24 +256,31 @@ export namespace Production //生产那边需要一一对应的数据 - export function ParseSealData(sealData: BrSealedData): ISealingData[] + export function ParseSealData(sealData: BrSealedData, defaultSealColor: string = ""): { seals: ISealingData[], reservedEdges: IHighReservedEdgeItem[]; } { let seals: ISealingData[] = []; + let reservedEdges: IHighReservedEdgeItem[] = []; for (let i = 0; i < sealData.brCurves.length; i++) { let curve = sealData.brCurves[i]; let sealD = sealData.highSeals[i]; + let reservedEdgeD = sealData.highReservedEdges[i]; if (curve instanceof Circle) { let seal2: ISealingData = { length: curve.Length * 0.5, - ...sealD + ...sealD, + sealColor: sealD.sealColor ? sealD.sealColor : defaultSealColor }; + //圆型板拆单时是分成两段圆弧处理 seals.push(seal2); seals.push({ ...seal2 }); - return seals; + + reservedEdges.push(reservedEdgeD); + reservedEdges.push({ ...reservedEdgeD }); + return { seals, reservedEdges }; } else { @@ -279,22 +290,28 @@ export namespace Production { let seal2: ISealingData = { length: subC.Length, - ...sealD + ...sealD, + sealColor: sealD.sealColor ? sealD.sealColor : defaultSealColor }; seals.push(seal2); + + reservedEdges.push(reservedEdgeD); } } else//直线 圆弧直接加 { let seal2: ISealingData = { length: curve.Length, - ...sealD + ...sealD, + sealColor: sealD.sealColor ? sealD.sealColor : defaultSealColor }; seals.push(seal2); + + reservedEdges.push(reservedEdgeD); } } } - return seals; + return { seals, reservedEdges }; } export function ParseBoardEdgeRemarkData(sealData: BrSealedData, highBoardEdgeRemark: IHighEdgeRemarkItem[]): IHighEdgeRemarkItem[] @@ -307,6 +324,7 @@ export namespace Production if (curve instanceof Circle) { + //圆型板拆单时是分成两段圆弧处理 remarks.push(remarkData); remarks.push({ ...remarkData }); return remarks; diff --git a/src/UI/Components/BBS/BBSCommon.tsx b/src/UI/Components/BBS/BBSCommon.tsx index 07e454c55..3e3acb28f 100644 --- a/src/UI/Components/BBS/BBSCommon.tsx +++ b/src/UI/Components/BBS/BBSCommon.tsx @@ -164,9 +164,10 @@ export class TitleBanner extends React.Component sealing: ["上封边", "下封边", "左封边", "右封边"], highDrill: ["上排钻", "下排钻", "左排钻", "右排钻"], boardEdgeRemark: ["上边备注信息", "下边备注信息", "左边备注信息", "右边备注信息"], + reservedEdge: ["上预留边", "下预留边", "左预留边", "右预留边"], }; - if (["sealing", "highDrill", "boardEdgeRemark"].includes(key)) + if (["sealing", "highDrill", "boardEdgeRemark", "reservedEdge"].includes(key)) { return boardEdgeEditor(index, boardEdgeMap[key], key); } @@ -442,6 +443,13 @@ export class BBSSealingComponent extends React.Component return this.option.hasOwnProperty("edgeRemarkUp"); } + if (key === "reservedEdge") + { + return this.option.hasOwnProperty("reservedEdgeUp"); + } + return this.option.hasOwnProperty(key); } public render() @@ -165,6 +170,7 @@ export class BoardInfoList extends React.Component ); case "sealing": case "boardEdgeRemark": + case "reservedEdge": return opt.edgeRemarkLeft = br.BoardProcessOption.edgeRemarkLeft; opt.edgeRemarkRight = br.BoardProcessOption.edgeRemarkRight; break; + case "reservedEdge": + opt.reservedEdgeUp = br.BoardProcessOption.reservedEdgeUp; + opt.reservedEdgeDown = br.BoardProcessOption.reservedEdgeDown; + opt.reservedEdgeLeft = br.BoardProcessOption.reservedEdgeLeft; + opt.reservedEdgeRight = br.BoardProcessOption.reservedEdgeRight; + break; default: opt[key] = br.BoardProcessOption[key]; } diff --git a/src/UI/Components/BBS/LookOverBoardInfos.tsx b/src/UI/Components/BBS/LookOverBoardInfos.tsx index 901097e0c..bbaf57d64 100644 --- a/src/UI/Components/BBS/LookOverBoardInfos.tsx +++ b/src/UI/Components/BBS/LookOverBoardInfos.tsx @@ -493,6 +493,20 @@ export class LookOverBoardInfosModal extends React.Component; } /** @@ -520,7 +521,7 @@ export class Input5Or4Component extends React.Component const options = [...userConfig.DrillConfigs.keys(), "不排"]; const { isRemarks, highDrillOption, isShowEditor, type, upKey, leftKey, downKey, rightKey, centerKey, - option, uiOption, showDirectionIcon, hasCenter, + option, uiOption, showDirectionIcon, hasCenter, showHighEdgeProcessing, onChange } = this.props; const isShow = isShowEditor && highDrillOption; @@ -533,6 +534,7 @@ export class Input5Or4Component extends React.Component option={option} uiOption={uiOption} onChange={onChange} + isHideErrorMsg={showHighEdgeProcessing ? showHighEdgeProcessing.get() : false} /> { isShow && option={option} uiOption={uiOption} onChange={onChange} + isHideErrorMsg={showHighEdgeProcessing ? showHighEdgeProcessing.get() : false} /> { isShow && option={option} uiOption={uiOption} onChange={onChange} + isHideErrorMsg={showHighEdgeProcessing ? showHighEdgeProcessing.get() : false} /> { isShow && option={option} uiOption={uiOption} onChange={onChange} + isHideErrorMsg={showHighEdgeProcessing ? showHighEdgeProcessing.get() : false} /> { isShow && {select}