diff --git a/__test__/EdgeSealing/EdgeSealing.test.ts b/__test__/EdgeSealing/EdgeSealing.test.ts index ec76d12de..e1ad241bc 100644 --- a/__test__/EdgeSealing/EdgeSealing.test.ts +++ b/__test__/EdgeSealing/EdgeSealing.test.ts @@ -90,3 +90,21 @@ test("异型板件,非相切圆弧", () => sealingSize = [3, 5, 3, 3, 3]; testBrSealing(br, sealingSize); }) + +test("丢失线段板件", () => +{ + let data = + [1, "Board", 3, 2, 101, false, 1, 1, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 817.4143763202346, -26.547581507291397, -408.40778761079696, 1], 2, 1200.0000000000002, 600, 18, false, "Polyline", 3, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1025.70079227525, -1279.6056228760524, 0, 1], 2, 54, [1025.70079227525, 2058.576017106141], 0, [1325.865855638082, 2058.576017106141], 0.41421356237309503, [1345.865855638082, 2078.576017106141], 0, [1345.865855638082, 2097.321917106141], 0.41421356237309503, [1325.865855638082, 2117.321917106141], 0, [1025.70079227525, 2137.2691008583533], 0, [1025.70079227525, 2137.2691008583533], -0.41421356237309503, [1045.70079227525, 2157.2691008583533], 0, [1325.865855638082, 2157.2691008583533], 0.41421356237309503, [1345.865855638082, 2177.2691008583533], 0, [1345.865855638082, 2196.0150008583532], 0.41421356237309503, [1325.865855638082, 2216.0150008583532], 0, [1025.70079227525, 2216.0150008583532], 0, [1025.70079227525, 2248.912678628265], 0, [1325.865855638082, 2248.912678628265], 0.41421356237309503, [1345.865855638082, 2268.912678628265], 0, [1345.865855638082, 2287.658578628265], 0.41421356237309503, [1325.865855638082, 2307.658578628265], 0, [1045.70079227525, 2307.658578628265], -0.41421356237309503, [1025.70079227525, 2327.658578628265], 0, [1025.70079227525, 2479.6056228760526], 0, [1625.70079227525, 2479.6056228760526], 0, [1625.70079227525, 1279.6056228760524], 0, [1025.70079227525, 1279.6056228760524], 0, [1025.70079227525, 1375.9224547698577], -0.41421356237309503, [1045.70079227525, 1395.9224547698577], 0, [1345.865855638082, 1395.9224547698577], 0, [1345.865855638082, 1404.6683547698576], 0.41421356237309503, [1295.865855638082, 1454.6683547698576], 0, [1025.70079227525, 1454.6683547698576], 0, [1025.70079227525, 1522.813562451274], 0, [1325.865855638082, 1522.813562451274], 0.41421356237309503, [1345.865855638082, 1542.813562451274], 0, [1345.865855638082, 1561.559462451274], 0.41421356237309503, [1325.865855638082, 1581.559462451274], 0, [1045.70079227525, 1581.559462451274], -0.41421356237309503, [1025.70079227525, 1601.559462451274], 0, [1025.70079227525, 1652.6155645751674], -0.41421356237309503, [1045.70079227525, 1672.6155645751674], 0, [1345.865855638082, 1672.6155645751674], 0, [1345.865855638082, 1701.988514575167], 0, [1045.70079227525, 1731.3614645751672], -0.41421356237309503, [1025.70079227525, 1751.3614645751672], 0, [1025.70079227525, 1761.8829073008312], -0.41421356237309503, [1045.70079227525, 1781.8829073008312], 0, [1363.4896205938342, 1781.8829073008312], 0, [1363.4896205938342, 1840.628807300831], 0, [1025.70079227525, 1881.684909424725], 0, [1025.70079227525, 1881.684909424725], -0.41421356237309503, [1075.70079227525, 1931.684909424725], 0, [1345.865855638082, 1931.684909424725], 0, [1345.865855638082, 1990.4308094247249], 0, [1075.70079227525, 1990.4308094247249], -0.41421356237309503, [1025.70079227525, 2040.4308094247249], 0, true, 0, 3, 0, 0, 0, 2, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -401.8444990614662, -7520.408091226085, -408.40778761079696, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\",\"highDrill\":[]}", 0, 0] + //第3段为圆弧 + let br = LoadBoardsFromFileData(data)[0]; + let sealingSize = []; + for (let i = 0; i < 20; i++) + sealingSize.push(1); + testBrSealing(br, sealingSize); + data = [1, "Board", 3, 2, 103, false, 1, 1, 0, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 475.1861812309362, -119.62672264222056, 591, 1], 2, 799.9999999999999, 600, 18, false, "Polyline", 3, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -102.47516991969519, 1419.0110848098525, 0, 1], 2, 39, [122.47516991969519, -814.6847031918554], 0, [340.6340264789152, -814.6847031918554], 0.41421356237309503, [360.6340264789152, -794.6847031918554], 0, [360.63402647891513, -756.0122031918554], 0, [102.47516991969522, -756.0122031918554], 0, [102.47516991969522, -639.0110848098526], -0.41421356237309503, [122.47516991969522, -619.0110848098526], 0, [682.4751699196952, -619.0110848098526], -0.41421356237309503, [702.4751699196952, -639.0110848098526], 0, [702.4751699196952, -1399.0110848098525], -0.41421356237309503, [682.4751699196952, -1419.0110848098525], 0, [102.47516991969522, -1419.0110848098525], 0, [102.47516991969519, -1251.259221730597], -0.41421356237309503, [122.47516991969519, -1231.259221730597], 0, [360.63402647891513, -1231.259221730597], 0, [360.63402647891513, -1172.5867217305968], 0, [122.47516991969522, -1172.5867217305968], -0.41421356237309503, [102.47516991969522, -1152.5867217305968], 0, [102.4751699196952, -1137.3832738908804], 0, [340.63402647891513, -1137.3832738908804], 0.41421356237309503, [360.63402647891513, -1117.3832738908804], 0, [360.63402647891513, -1078.7107738908805], 0, [102.47516991969522, -1078.7107738908805], 0, [102.4751699196952, -1031.7728325711996], 0, [340.63402647891513, -1031.7728325711996], 0.41421356237309503, [360.63402647891513, -1011.7728325711997], 0, [360.63402647891513, -993.1003325711996], 0.41421356237309503, [340.63402647891513, -973.1003325711996], 0, [122.47516991969519, -973.1003325711996], -0.41421356237309503, [102.47516991969519, -953.1003325711996], 0, [102.47516991969519, -948.1181401648461], -0.41421356237309503, [122.47516991969519, -928.1181401648461], 0, [340.6340264789152, -928.1181401648461], 0.41421356237309503, [360.6340264789152, -908.1181401648461], 0, [360.6340264789152, -889.4456401648459], 0.41421356237309503, [340.6340264789152, -869.4456401648459], 0, [122.47516991969522, -869.4456401648459], -0.41421356237309503, [102.47516991969522, -849.4456401648459], 0, [102.47516991969519, -834.6847031918554], -0.41421356237309503, true, 0, 3, 0, 0, 0, 2, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 475.1861812309362, -119.62672264222056, 591, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[{\"size\":2,\"color\":2},{\"size\":2,\"color\":2},{\"size\":2,\"color\":2},{\"size\":1,\"color\":1},{\"size\":1,\"color\":1},{\"size\":1,\"color\":1},{\"size\":2,\"color\":2},{\"size\":3,\"color\":3},{\"size\":4,\"color\":4},{\"size\":5,\"color\":5},{\"size\":6,\"color\":6},{\"size\":8,\"color\":7},{\"size\":7,\"color\":8},{\"size\":9,\"color\":9},{\"size\":10,\"color\":10},{\"size\":11,\"color\":11},{\"size\":12,\"color\":12},{\"size\":13,\"color\":13},{\"size\":14,\"color\":14},{\"size\":15,\"color\":15},{\"size\":2,\"color\":2},{\"size\":2,\"color\":2},{\"size\":2,\"color\":2},{\"size\":1,\"color\":1}],\"sealedUp\":\"1\",\"sealedDown\":\"1\",\"sealedLeft\":\"1\",\"sealedRight\":\"1\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\",\"highDrill\":[]}", 0, 0]; + br = LoadBoardsFromFileData(data)[0]; + sealingSize = []; + for (let i = 0; i < 9; i++) + sealingSize.push(1); + testBrSealing(br, sealingSize); +}) diff --git a/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap b/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap index 3eb9986f5..938c30940 100644 --- a/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap +++ b/__test__/EdgeSealing/__snapshots__/EdgeSealing.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`丢失线段板件 1`] = `538651.2759963807`; + +exports[`丢失线段板件 2`] = `398758.87896958226`; + exports[`常规板件,常规坐标系 1`] = `716404`; exports[`常规板件,常规坐标系 2`] = `711624`; diff --git a/src/Add-on/BoardFindModify.ts b/src/Add-on/BoardFindModify.ts index db5fa2698..d42d9eae8 100644 --- a/src/Add-on/BoardFindModify.ts +++ b/src/Add-on/BoardFindModify.ts @@ -264,7 +264,9 @@ export class BoardFindModify implements Command case EBoardKeyList.DownSealed: case EBoardKeyList.LeftSealed: case EBoardKeyList.RightSealed: - br.BoardProcessOption[i] = option[i]; + if (option[i]) + br.BoardProcessOption[i] = option[i]; + br.BoardProcessOption.highDrill = option.highDrill; break; default: break; diff --git a/src/Add-on/DrawBoard/DrawBoardTool.ts b/src/Add-on/DrawBoard/DrawBoardTool.ts index ad3e0584f..a016a4de8 100644 --- a/src/Add-on/DrawBoard/DrawBoardTool.ts +++ b/src/Add-on/DrawBoard/DrawBoardTool.ts @@ -7,6 +7,7 @@ import { BoardModal, BoardModalType } from '../../UI/Components/Board/BoardModal import { ModalPosition } from '../../UI/Components/Modal/ModalsManage'; import { BehindBoardStore, LayerBoardStore, VerticalBoardStore } from '../../UI/Store/BoardStore'; import { ISpaceParse } from '../../Geometry/SpaceParse/ISpaceParse'; +import { userConfig } from '../../Editor/UserConfig'; export abstract class DrawBoardTool implements Command { @@ -71,6 +72,9 @@ export abstract class DrawBoardTool implements Command this.buildBoard(); app.m_Editor.UpdateScreen(); + + if (!userConfig.isContinuousDraw) + break; } //恢复原先状态 app.m_Editor.m_GetpointServices.snapServices.Disabled = oldSnapState; diff --git a/src/Add-on/DrawBoard/DrawLayerBoard.ts b/src/Add-on/DrawBoard/DrawLayerBoard.ts index 8fa0b205c..c77196844 100644 --- a/src/Add-on/DrawBoard/DrawLayerBoard.ts +++ b/src/Add-on/DrawBoard/DrawLayerBoard.ts @@ -8,6 +8,7 @@ import { LayerBoardStore } from '../../UI/Store/BoardStore'; import { DrawBoardTool } from './DrawBoardTool'; import { ObjectId } from '../../DatabaseServices/ObjectId'; import { arrayLast } from '../../Common/ArrayExt'; +import { toJS } from 'mobx'; enum NailPos { @@ -60,6 +61,7 @@ export class DrawLayerBoard extends DrawBoardTool let board = Board.CreateBoard(len, width, thickness, BoardType.Layer); opt.height = len; opt.width = width; + board.BoardProcessOption = toJS(this.store.m_BoardProcessOption); //等分单层空间大小 let singleSize = (size.z - (thickness * count)) / (count + 1); diff --git a/src/Add-on/DrawBoard/DrawLeftRightBoard.ts b/src/Add-on/DrawBoard/DrawLeftRightBoard.ts index 74a07f1a2..34544bb2e 100644 --- a/src/Add-on/DrawBoard/DrawLeftRightBoard.ts +++ b/src/Add-on/DrawBoard/DrawLeftRightBoard.ts @@ -9,6 +9,7 @@ import { BoardModal, BoardModalType } from '../../UI/Components/Board/BoardModal import { ModalPosition } from '../../UI/Components/Modal/ModalsManage'; import { SideBoardStore } from '../../UI/Store/BoardStore'; import { JigUtils } from '../../Editor/JigUtils'; +import { toJS } from 'mobx'; export class DrawLeftRight implements Command { @@ -47,10 +48,10 @@ export class DrawLeftRight implements Command rightBoard.ApplyMatrix(MoveMatrix(vec)); leftBoard.Name = "左侧板" - leftBoard.BoardProcessOption = store.m_BoardProcessOption; + leftBoard.BoardProcessOption = toJS(store.m_BoardProcessOption); rightBoard.Name = "右侧板" - rightBoard.BoardProcessOption = store.m_BoardProcessOption; + rightBoard.BoardProcessOption = toJS(store.m_BoardProcessOption); app.m_Database.ModelSpace.Append(leftBoard); app.m_Database.ModelSpace.Append(rightBoard); diff --git a/src/Add-on/DrawBoard/DrawTopBottomBoard.ts b/src/Add-on/DrawBoard/DrawTopBottomBoard.ts index 21c37abe1..b031cc000 100644 --- a/src/Add-on/DrawBoard/DrawTopBottomBoard.ts +++ b/src/Add-on/DrawBoard/DrawTopBottomBoard.ts @@ -16,14 +16,6 @@ export class DrawTopBottomBoard implements Command private store: TopBottomBoardStore; async exec() { - let selectSpace = new PointSelectSpaceSurround(); - await selectSpace.Select(); - if (!selectSpace.ParseOK) - { - log("请选择有效板件"); - return; - } - this.store = TopBottomBoardStore.GetInstance(); app.m_Editor.m_ModalManage.RenderModal(BoardModal, ModalPosition.Center, { store: this.store, type: BoardModalType.TB }); @@ -31,6 +23,14 @@ export class DrawTopBottomBoard implements Command if (res.Status === ModalState.Ok) { + let selectSpace = new PointSelectSpaceSurround(); + await selectSpace.Select(); + if (!selectSpace.ParseOK) + { + log("请选择有效板件"); + return; + } + let topOpt = this.store.topBoardOption; let bottomOpt = this.store.bottomBoardOption; let space = selectSpace.m_SpaceParse; diff --git a/src/Add-on/DrawDrilling/DrawDrilling.ts b/src/Add-on/DrawDrilling/DrawDrilling.ts index 602c43eb6..62f931cec 100644 --- a/src/Add-on/DrawDrilling/DrawDrilling.ts +++ b/src/Add-on/DrawDrilling/DrawDrilling.ts @@ -18,7 +18,7 @@ export class DrawDrilling implements Command let brs = brsRes.SelectSet.SelectEntityList.filter(e => e instanceof Board) as Board[]; if (brs.length >= 2) { - DrawDrillingTool.GetInstance().StartGangDrill(brs); + (DrawDrillingTool.GetInstance() as DrawDrillingTool).StartGangDrill(brs); } else { diff --git a/src/Add-on/DrawDrilling/DrawDrillingTool.ts b/src/Add-on/DrawDrilling/DrawDrillingTool.ts index 532172541..c8b9b5a12 100644 --- a/src/Add-on/DrawDrilling/DrawDrillingTool.ts +++ b/src/Add-on/DrawDrilling/DrawDrillingTool.ts @@ -7,12 +7,15 @@ import { GangDrill } from "../../DatabaseServices/3DSolid/GangDrill"; import { Board } from "../../DatabaseServices/Board"; import { Circle } from "../../DatabaseServices/Circle"; import { ObjectId } from "../../DatabaseServices/ObjectId"; +import { userConfig } from "../../Editor/UserConfig"; import { CollisionDetection } from "../../Geometry/DrillParse/CollisionDetection"; import { Face } from "../../Geometry/DrillParse/Face"; import { cZAxis, equaln, MoveMatrix } from "../../Geometry/GeUtils"; import { FaceDirection } from "../../UI/Store/BoardInterface"; import { DrillingOption, SpacingType } from "../../UI/Store/drillInterface"; import { DrillStore } from "../../UI/Store/DrillStore"; +import { toJS } from "mobx"; + export class DrawDrillingTool extends Singleton { @@ -20,14 +23,24 @@ export class DrawDrillingTool extends Singleton private m_Face: Face; private m_Option: DrillingOption; private drillEnts: GangDrill[] = []; - private GetDrillingConfig() + /**获取用户正在使用的配置 */ + private GetDrillingConfig(type: string) { - //TODO:完善用户配置类,暂用store得数据进行测试 - return DrillStore.GetInstance().rules; + const store = DrillStore.GetInstance() as DrillStore; + let configs = toJS(userConfig.drillConfigs, { exportMapsAsObjects: false }); + if (configs && configs.size > 0) + { + if (configs.has(type)) + return configs.get(type); + else + return configs.get(store.type); + } + else + return store.rules; } - private GetRuleByFace(f: Face): DrillingOption + private GetRuleByFace(f: Face) { - const rules = this.GetDrillingConfig(); + const rules = this.GetDrillingConfig(f.drillType); let length = f.m_Length; for (let rule of rules) { @@ -270,7 +283,7 @@ export class DrawDrillingTool extends Singleton //加入本地的板件排钻测试通孔 for (let [id, v] of locaBoard.DrillList) { - if (id) + if (id && id.Object) refDrillList.push(...v); } @@ -391,7 +404,6 @@ export class DrawDrillingTool extends Singleton //清理掉已经存在的排钻 this.ClearExitDrillList(checkRes.m_CollisonFaces); - for (let f of checkRes.m_CollisonFaces) { let suitableOption = this.GetRuleByFace(f); @@ -433,4 +445,17 @@ export class DrawDrillingTool extends Singleton } } + ResetGangDrill(br: Board) + { + let brs = [br]; + for (let [k,] of br.DrillList) + { + if (k.Object) + { + brs.push(k.Object as Board); + br.ClearDrillList(k); + } + } + this.StartGangDrill(brs); + } } diff --git a/src/Add-on/DrawWineRack/DrawWinRackTool.ts b/src/Add-on/DrawWineRack/DrawWinRackTool.ts index da13d54c5..b56326bc5 100644 --- a/src/Add-on/DrawWineRack/DrawWinRackTool.ts +++ b/src/Add-on/DrawWineRack/DrawWinRackTool.ts @@ -54,29 +54,32 @@ export class DrawWineRackTool extends Singleton br.BoardProcessOption.sealedUp = topSealed.toString(); br.BoardProcessOption.sealedDown = downSealed.toString(); - let highSeals: IHighSealedItem[] = [{ size: downSealed }]; + let sizes = [...new Set([downSealed, rightSealed, topSealed, leftSealed])]; + let downSeal = { + size: downSealed, color: sizes.indexOf(downSealed) + 1 + }; + let rigthSeal = { + size: rightSealed, color: sizes.indexOf(rightSealed) + 1 + }; + let topSeal = { size: topSealed, color: sizes.indexOf(topSealed) + 1 }; + let leftSeal = { size: leftSealed, color: sizes.indexOf(leftSealed) + 1 }; + + let highSeals: IHighSealedItem[] = [downSeal]; if (isLeft) { - highSeals.push( - { - size: rightSealed - }, - { - size: topSealed - } - ) - for (let i = 3; i <= cu.EndParam; i++) + highSeals.push(rigthSeal, topSeal); + for (let i = 3; i <= cu.EndParam - 1; i++) { - highSeals.push({ size: leftSealed }); + highSeals.push(leftSeal); } } else { for (let i = 1; i <= cu.EndParam - 3; i++) { - highSeals.push({ size: rightSealed }); + highSeals.push(rigthSeal); } - highSeals.push({ size: topSealed }, { size: leftSealed }); + highSeals.push(topSeal, leftSeal); } br.BoardProcessOption.highSealed = highSeals; } diff --git a/src/Add-on/HideSelected.ts b/src/Add-on/HideSelected.ts index c84e4da7c..318de12c0 100644 --- a/src/Add-on/HideSelected.ts +++ b/src/Add-on/HideSelected.ts @@ -8,7 +8,7 @@ export class Command_HideSelected implements Command { let selects = app.m_Editor.m_SelectCtrl.SelectSet.SelectEntityList; if (selects.length !== 0) - selects.forEach(e => { e.Erase(true) }); + selects.forEach(e => { e.Visible = false }); else app.m_Editor.Prompt("没有选中实体,隐藏失败!"); } @@ -20,7 +20,7 @@ export class Command_ShowAll implements Command { app.m_Database.ModelSpace.Entitys.forEach(o => { - o.Erase(false); + o.Visible = true; }); } } @@ -35,7 +35,7 @@ export class Command_HideUnselected implements Command { if (!selects.includes(o) && !(o instanceof Light)) { - o.Erase(true); + o.Visible = false; count++; } }); diff --git a/src/Add-on/LatticeDrawer/LatticeDrawerTool.ts b/src/Add-on/LatticeDrawer/LatticeDrawerTool.ts index 1ef79ce33..781ae04e1 100644 --- a/src/Add-on/LatticeDrawer/LatticeDrawerTool.ts +++ b/src/Add-on/LatticeDrawer/LatticeDrawerTool.ts @@ -10,6 +10,7 @@ import { Vec3DTo2D } from "../../Common/CurveUtils"; import { arrayLast } from "../../Common/ArrayExt"; import { log } from "../../Common/Utils"; import { IHighSealedItem } from "../../UI/Store/BoardInterface"; +import { equaln } from "../../Geometry/GeUtils"; export class DrawLatticeDrawerTool extends Singleton { @@ -55,7 +56,10 @@ export class DrawLatticeDrawerTool extends Singleton let verBr = Board.CreateBoard(size.z, size.y, config.thickness, BoardType.Vertical); this.WriteBoardProcessOption(verBr); - this.ParseArcLenOrObliuqeAng(verBr); + //分析切角圆弧的结果 + let res = this.ParseArcLenOrObliuqeAng(verBr); + if (!res) return; + this.ParseBrTooth(verBr); this.ParseHighSealing(verBr, config.leftSealed, config.rightSealed, config.upSealed, config.downSealed, false); @@ -228,12 +232,12 @@ export class DrawLatticeDrawerTool extends Singleton if (config.upCut > size.z || config.downCut > size.z) { log("切角过大"); - return; + return false; } if (config.upCut < 1 || config.downCut < 1) { log("切角过小"); - return; + return false; } let cu = br.ContourCurve as Polyline; cu.AddVertexAt(3, new Vector2(config.upCut, br.Height)); @@ -244,15 +248,16 @@ export class DrawLatticeDrawerTool extends Singleton if (config.arcLen > size.z) { log("圆弧角过大"); - return; + return false; } let cu = br.ContourCurve as Polyline; cu.AddVertexAt(3, new Vector2(config.arcLen, br.Height)); - cu.SetBulgeAt(3, Math.PI / 8); + cu.SetBulgeAt(3, Math.tan(Math.PI / 8)); cu.SetPointAt(4, new Vector2(0, br.Height - config.arcLen)); } this.ChangeLeftRightBr(br); + return true; } private WriteBoardProcessOption(br: Board) { @@ -265,36 +270,46 @@ export class DrawLatticeDrawerTool extends Singleton } protected ParseHighSealing(br: Board, leftSealed: number, rightSealed: number, topSealed: number, downSealed: number, isHor: boolean) { - let cu = br.ContourCurve; + let cu = br.ContourCurve as Polyline; br.BoardProcessOption.sealedLeft = leftSealed.toString(); br.BoardProcessOption.sealedRight = rightSealed.toString(); br.BoardProcessOption.sealedUp = topSealed.toString(); br.BoardProcessOption.sealedDown = downSealed.toString(); let highSeals: IHighSealedItem[] = []; + + let sizes = [...new Set([downSealed, rightSealed, topSealed, leftSealed])]; + let downSeal = { + size: downSealed, color: sizes.indexOf(downSealed) + 1 + }; + let rigthSeal = { + size: rightSealed, color: sizes.indexOf(rightSealed) + 1 + }; + let topSeal = { size: topSealed, color: sizes.indexOf(topSealed) + 1 }; + let leftSeal = { size: leftSealed, color: sizes.indexOf(leftSealed) + 1 }; + if (isHor) { - highSeals.push( - { - size: downSealed - }, - { - size: rightSealed - } - ) + highSeals.push(downSeal, rigthSeal); + for (let i = 1; i <= cu.EndParam - 3; i++) { - highSeals.push({ size: topSealed }); + highSeals.push(topSeal); } - highSeals.push({ size: leftSealed }); + highSeals.push(leftSeal); } else { for (let i = 0; i <= cu.EndParam - 5; i++) { - highSeals.push({ size: downSealed }); + highSeals.push(downSeal); + } + highSeals.push(rigthSeal, topSeal); + + if (cu.PtsBuls.buls.every(b => equaln(b, 0))) + { + highSeals.push(topSeal, leftSeal); } - highSeals.push({ size: rightSealed }, { size: topSealed }, { size: topSealed }, { size: topSealed }); } br.BoardProcessOption.highSealed = highSeals; } diff --git a/src/Add-on/TestFb.ts b/src/Add-on/TestFb.ts index 4f0d3e512..08ef2b7b8 100644 --- a/src/Add-on/TestFb.ts +++ b/src/Add-on/TestFb.ts @@ -1,11 +1,12 @@ -import { Command } from "../Editor/CommandMachine"; +import { Vector3 } from "three"; import { app } from "../ApplicationServices/Application"; +import { EBoardKeyList } from "../Common/BoardKeyList"; import { Board } from "../DatabaseServices/Board"; -import { PromptStatus } from "../Editor/PromptResult"; import { Curve } from "../DatabaseServices/Curve"; -import { calcEdgeSealing } from "../GraphicsSystem/CalcEdgeSealing"; import { Polyline } from "../DatabaseServices/Polyline"; -import { Vector3 } from "three"; +import { Command } from "../Editor/CommandMachine"; +import { PromptStatus } from "../Editor/PromptResult"; +import { calcEdgeSealing, paragraphCulist } from "../GraphicsSystem/CalcEdgeSealing"; export class TestFb implements Command { @@ -29,12 +30,31 @@ export class TestFb implements Command let offsetCus: Curve[] = []; let highSeals = br.BoardProcessOption.highSealed; let cus = br.ContourCurve.Explode() as Curve[]; - //TODO:先能测试封边,未完善 + if (!br.IsSpecialShape) + { + highSeals.length = 0; + let sealDown = parseFloat(br.BoardProcessOption[EBoardKeyList.DownSealed]); + let sealUp = parseFloat(br.BoardProcessOption[EBoardKeyList.UpSealed]); + let sealLeft = parseFloat(br.BoardProcessOption[EBoardKeyList.LeftSealed]); + let sealRight = parseFloat(br.BoardProcessOption[EBoardKeyList.RightSealed]); + let seals = [...new Set([sealDown, sealRight, sealUp, sealLeft])]; + [sealDown, sealRight, sealUp, sealLeft].forEach(size => highSeals.push({ size, color: seals.indexOf(size) + 1 })); + } + else + paragraphCulist(cus); + if (highSeals.length > 0 && cus.length === highSeals.length) { for (let i = 0; i < cus.length; i++) { - offsetCus.push(...cus[i].GetOffsetCurves(-highSeals[i].size)); + let cs = cus[i].GetOffsetCurves(-highSeals[i].size); + for (let c of cs) + { + if (c instanceof Polyline) + offsetCus.push(...c.Explode()); + else + offsetCus.push(c); + } } calcEdgeSealing(offsetCus); let pl = new Polyline(); @@ -54,18 +74,24 @@ export class TestFb implements Command if (ptRes.Status === PromptStatus.OK) { - let oldPosition = 0; + let moveDist = 0; + let vec = new Vector3(); for (let i = 0; i < showCus.length; i++) { let c = showCus[i]; - c.Position = ptRes.Point.add(new Vector3(oldPosition)); - if (i % 2 === 1) + if (i % 2 === 0) { - oldPosition += c.BoundingBox.getSize(new Vector3).x + 20; + let min = c.BoundingBox.min; + vec = ptRes.Point.clone().sub(min).add(new Vector3(moveDist)); + c.Position = c.Position.add(vec); + moveDist += c.BoundingBox.getSize(new Vector3).x + 20; + } + else + { + c.Position = c.Position.add(vec); } app.m_Database.ModelSpace.Append(c); } } - } } diff --git a/src/Common/CheckoutVaildValue.ts b/src/Common/CheckoutVaildValue.ts index 7516dc237..4a5c0b15b 100644 --- a/src/Common/CheckoutVaildValue.ts +++ b/src/Common/CheckoutVaildValue.ts @@ -90,15 +90,18 @@ export namespace CheckoutValid case "spliteWidth": case "spliteThickness": return ""; + case "sealedUp": + case "sealedDown": + case "sealedLeft": + case "sealedRight": + if (!isNaN(parseFloat(v)) && parseFloat(v) < 0) + return "数值必须大于0"; + return ""; case "height": case "width": case "count": case "thickness": case "footThickness": - case "sealedUp": - case "sealedDown": - case "sealedLeft": - case "sealedRight": if (!isNaN(parseFloat(v)) && parseFloat(v) <= 0) return "数值必须大于0"; default: @@ -181,17 +184,13 @@ export namespace CheckoutValid case "arrayAngle": if (Math.abs(parseFloat(v)) > 360) return "角度不可大于360"; - // case "": - // case "": - // case "": - // case "": default: if (v === "" || isNaN(Number(v))) { return "数值不能为空且必须为数字"; } + return ""; } - return ""; } export function CheckoutDoorOption(k: string, v: string): string { diff --git a/src/DatabaseServices/Board.ts b/src/DatabaseServices/Board.ts index b9dbdce3c..abd0607ea 100644 --- a/src/DatabaseServices/Board.ts +++ b/src/DatabaseServices/Board.ts @@ -1,17 +1,16 @@ -import { Matrix4, Mesh, Object3D, Vector3 } from 'three'; +import { Matrix4, Vector3 } from 'three'; import { UpdateDraw } from '../Common/Status'; +import { userConfig } from '../Editor/UserConfig'; import { boardUVGenerator, boardUVGenerator2 } from '../Geometry/BoardUVGenerator'; import { Box3Ext } from '../Geometry/Box'; import { equaln, MoveMatrix } from '../Geometry/GeUtils'; -import { RenderType } from '../GraphicsSystem/RenderType'; -import { BoardProcessOption, ComposingType, DrillType, FaceDirection, LinesType } from '../UI/Store/BoardInterface'; +import { BoardProcessOption, ComposingType, FaceDirection, LinesType } from '../UI/Store/BoardInterface'; import { Factory } from './CADFactory'; import { CADFiler } from './CADFiler'; import { Circle } from './Circle'; import { Contour } from './Contour'; import { ExtureSolid } from './Extrude'; import { ObjectId } from './ObjectId'; -import { PhysicalMaterialRecord } from './PhysicalMaterialRecord'; import { Shape } from './Shape'; export enum BoardType @@ -81,7 +80,7 @@ export class Board extends ExtureSolid color: "", lines: LinesType.Positive, bigHoleDir: FaceDirection.Front, - drillType: DrillType.Three, + drillType: [...userConfig.drillConfigs.keys()][0], composingFace: ComposingType.Arbitrary, highSealed: [], sealedUp: "1", @@ -90,7 +89,8 @@ export class Board extends ExtureSolid sealedRight: "1", spliteHeight: "", spliteWidth: "", - spliteThickness: "" + spliteThickness: "", + highDrill: [], }; } @@ -98,7 +98,12 @@ export class Board extends ExtureSolid InitBoard(length: number, width: number, thickness: number, boardType: BoardType = BoardType.Layer) { this.m_BoardType = boardType; - this.ColorIndex = boardType + 1; + if (boardType === BoardType.Layer) + this.ColorIndex = 2; + else if (boardType === BoardType.Vertical) + this.ColorIndex = 11; + else + this.ColorIndex = 3; this.ConverToRectSolid(width, length, thickness); this.Update(UpdateDraw.Geometry); } @@ -108,12 +113,6 @@ export class Board extends ExtureSolid board.InitBoard(length, width, thickness, boardType); board.ApplyMatrix(board.RotateMat); board.m_SpecOCS.identity(); - if (boardType === BoardType.Layer) - board.ColorIndex = 2; - else if (boardType === BoardType.Vertical) - board.ColorIndex = 11; - else - board.ColorIndex = 3; return board; } get DrillList() @@ -480,9 +479,10 @@ export class Board extends ExtureSolid } ApplyMatrix(m: Matrix4): this { + super.ApplyMatrix(m); if (equaln(m.getMaxScaleOnAxis(), 1)) this.m_SpecOCS.multiplyMatrices(m, this.m_SpecOCS); - return super.ApplyMatrix(m); + return this; } protected ApplyScaleMatrix(m: Matrix4): this { @@ -516,6 +516,10 @@ export class Board extends ExtureSolid this.m_BoardType = file.Read(); this.m_Name = file.Read(); this.m_BoardProcessOption = JSON.parse(file.Read()); + //兼容旧版本 + if (!this.m_BoardProcessOption.highDrill) + this.m_BoardProcessOption.highDrill = []; + //读取排钻列表 this.m_DrillList.clear(); let size = file.Read(); @@ -560,8 +564,14 @@ export class Board extends ExtureSolid file.Write(this.m_Name); file.Write(JSON.stringify(this.m_BoardProcessOption)); - //写入排钻列表 - file.Write(this.m_DrillList.size); + // 写入排钻列表 + let size = 0; + for (let [id,] of this.m_DrillList) + { + if (id && id.Object && !id.Object.IsErase) + size++; + } + file.Write(size); for (let [id, idList] of this.m_DrillList) { if (id && id.Object && !id.Object.IsErase) diff --git a/src/DatabaseServices/Entity.ts b/src/DatabaseServices/Entity.ts index 8a247f64c..168bc6ce6 100644 --- a/src/DatabaseServices/Entity.ts +++ b/src/DatabaseServices/Entity.ts @@ -254,7 +254,15 @@ export class Entity extends CADObject for (let [type, en] of this._CacheDrawObject) this.UpdateDrawObjectMaterial(type, en); } - + get Visible() + { + return this._Visible; + } + set Visible(v: boolean) + { + this._Visible = v; + this.UpdateVisible(); + } UpdateVisible() { if (this._drawObject) diff --git a/src/Editor/UserConfig.ts b/src/Editor/UserConfig.ts index 8f20bec31..53abf7079 100644 --- a/src/Editor/UserConfig.ts +++ b/src/Editor/UserConfig.ts @@ -1,4 +1,6 @@ import { RenderType } from "../GraphicsSystem/RenderType"; +import { DrillingOption } from "../UI/Store/drillInterface"; +import { observable } from "mobx"; /** * //TODO:保存用户的配置,先保存在sessionStroage @@ -8,18 +10,18 @@ class UserConfig private _renderType: RenderType = RenderType.Wireframe; maxHeight = 2440; maxWidth = 1220; + isContinuousDraw = false; //是否连续绘制层板立板背板... + @observable drillConfigs: Map = new Map(); constructor() { - this.InitConfig(); + this.Init(); } - - InitConfig() + Init() { let type = sessionStorage.getItem("renderType"); if (type) this._renderType = parseFloat(type); } - set RenderType(t: RenderType) { if (t !== this._renderType) diff --git a/src/Geometry/DrillParse/BoardGetFace.ts b/src/Geometry/DrillParse/BoardGetFace.ts index 64957d727..6843b6cd1 100644 --- a/src/Geometry/DrillParse/BoardGetFace.ts +++ b/src/Geometry/DrillParse/BoardGetFace.ts @@ -6,6 +6,7 @@ import { Curve } from "../../DatabaseServices/Curve"; import { Region } from "../../DatabaseServices/Region"; import { cZAxis, equaln, equalv3, rotatePoint } from "../GeUtils"; import { Face } from "./Face"; +import { DrillType } from "../../UI/Store/BoardInterface"; export enum BoardFaceType { @@ -42,40 +43,50 @@ export class BoardGetFace let thickness = this.m_Board.Thickness; let ocs = this.m_Board.OCS; + const highDrill = this.m_Board.BoardProcessOption.highDrill; //正反面 - this.m_Faces.push(new Face({ - type: BoardFaceType.NoSide, - region: reg, - isRect, - localBoard: this.m_Board, - isPositiveFace: true, - matrix4: ocs.clone().multiply( - new Matrix4().setPosition(new Vector3(0, 0, thickness))), - length: size.x, - width: size.y - })); + if (highDrill.length === 0 || highDrill[0] !== DrillType.None) + this.m_Faces.push(new Face({ + type: BoardFaceType.NoSide, + region: reg, + isRect, + localBoard: this.m_Board, + isPositiveFace: true, + matrix4: ocs.clone().multiply( + new Matrix4().setPosition(new Vector3(0, 0, thickness))), + length: size.x, + width: size.y + })); - let mat = GetMirrorMat(cZAxis).setPosition(new Vector3()); - this.m_Faces.push(new Face({ - type: BoardFaceType.NoSide, - localBoard: this.m_Board, - isRect, - region: reg ? reg.Clone() : undefined, - isPositiveFace: false, - matrix4: new Matrix4().multiplyMatrices(ocs.clone(), mat), - length: size.x, - width: size.y - })); + if (highDrill.length === 0 || highDrill[1] !== DrillType.None) + { + let mat = GetMirrorMat(cZAxis).setPosition(new Vector3()); + this.m_Faces.push(new Face({ + type: BoardFaceType.NoSide, + localBoard: this.m_Board, + isRect, + region: reg ? reg.Clone() : undefined, + isPositiveFace: false, + matrix4: new Matrix4().multiplyMatrices(ocs.clone(), mat), + length: size.x, + width: size.y + })); + } } GetSideFaces() { // 判断板件构建曲线方向 let cus = this.m_Board.ContourCurve.Explode() as Curve[]; //板构建曲线方向 - let dir = Math.sign(this.m_Board.ContourCurve.Area2) + let dir = Math.sign(this.m_Board.ContourCurve.Area2); + + const highDrill = this.m_Board.BoardProcessOption.highDrill; - cus.forEach(cu => + for (let i = 0; i < cus.length; i++) { + if (highDrill.length > 0 && highDrill[i + 2] === DrillType.None) + continue; + let cu = cus[i]; let derv = cu.GetFistDeriv(0).normalize(); let len = cu.Length; @@ -93,15 +104,16 @@ export class BoardGetFace isPositiveFace: derv.x + derv.y + derv.z > 0, matrix4: new Matrix4().multiplyMatrices(this.m_Board.OCS.clone(), mat), length: len, - width: this.m_Board.Thickness + width: this.m_Board.Thickness, + drillType: highDrill.length >= 2 && highDrill[i + 2] })); - }) + } } IntersectFace(br: BoardGetFace, bInsEqual: boolean = false): Face[] { //板件包围盒不相交 let localBox = this.m_Board.GetBoardBoxInMat(this.m_Board.SpaceOCSInv); - let interBox = br.m_Board.GetBoardBoxInMat(br.m_Board.SpaceOCSInv); + let interBox = br.m_Board.GetBoardBoxInMat(this.m_Board.SpaceOCSInv); if (!localBox.intersectsBox(interBox)) return []; let collisionFaces: Face[] = []; @@ -110,10 +122,11 @@ export class BoardGetFace { for (let f2 of br.m_Faces) { - //都是正面,或者不允许侧面同侧面 - if (f1.type === f2.type) - if (f1.type === BoardFaceType.NoSide || !bInsEqual) - continue; + //都是正面,或者不允许侧面同侧面并且2板件类型不一样就跳过 + if (f1.type === f2.type + && (f1.type !== BoardFaceType.NoSide || !bInsEqual) + && br.m_Board.BoardType !== this.m_Board.BoardType) + continue; //不共面 if (!matrixIsCoplane(f1.OCS, f2.OCS, 1e-4)) continue; diff --git a/src/Geometry/DrillParse/CollisionDetection.ts b/src/Geometry/DrillParse/CollisionDetection.ts index 14ce328d6..4b969ea91 100644 --- a/src/Geometry/DrillParse/CollisionDetection.ts +++ b/src/Geometry/DrillParse/CollisionDetection.ts @@ -1,6 +1,7 @@ import { Board } from "../../DatabaseServices/Board"; import { BoardGetFace } from "./BoardGetFace"; import { Face } from "./Face"; +import { DrillType } from "../../UI/Store/BoardInterface"; export class CollisionDetection { @@ -16,7 +17,8 @@ export class CollisionDetection { for (let b of this.m_Boards) { - this.m_BoardGeList.push(new BoardGetFace(b)); + if (b.BoardProcessOption.drillType !== DrillType.None) + this.m_BoardGeList.push(new BoardGetFace(b)); } for (let i = 0; i < this.m_BoardGeList.length; i++) { diff --git a/src/Geometry/DrillParse/Face.ts b/src/Geometry/DrillParse/Face.ts index c6ff77f19..36fe2669d 100644 --- a/src/Geometry/DrillParse/Face.ts +++ b/src/Geometry/DrillParse/Face.ts @@ -17,6 +17,7 @@ export interface BoardFaceParams matrix4: Matrix4; region?: Region; isRect?: boolean; + drillType?: string; } export class Face { @@ -30,6 +31,7 @@ export class Face isEqualType: boolean = false; OCS: Matrix4 = new Matrix4(); m_IsRect: boolean = true; + drillType: string; constructor(parameters?: BoardFaceParams) { if (parameters) @@ -43,6 +45,10 @@ export class Face this.m_Width = parameters.width; if (parameters.isRect !== undefined) this.m_IsRect = parameters.isRect; + if (parameters.drillType) + this.drillType = parameters.drillType; + else + this.drillType = this.m_LocalBoard.BoardProcessOption.drillType; } } get IsRect() @@ -143,7 +149,7 @@ export class Face newFace.OCS = sideOcs.clone().setPosition(min); newFace.IsPositiveFace = sideFace.IsPositiveFace; - + newFace.drillType = sideFace.drillType; //都是侧面 if (this.type === f.type) newFace.isEqualType = true; diff --git a/src/Geometry/GeUtils.ts b/src/Geometry/GeUtils.ts index 533fd769f..cc9ad87c8 100644 --- a/src/Geometry/GeUtils.ts +++ b/src/Geometry/GeUtils.ts @@ -1,7 +1,6 @@ -import { Box3, BufferGeometry, Geometry, Line, Matrix4, Mesh, Object3D, Vector, Vector2, Vector3 } from 'three'; +import { Box3, BufferGeometry, Geometry, Line, Matrix4, Mesh, Object3D, Vector, Vector2, Vector3, Scene } from 'three'; import { ToFixed } from '../Common/Utils'; import { Matrix2 } from './Matrix2'; - export const cZeroVec = new Vector3(); export const cXAxis = new Vector3(1, 0, 0); export const cYAxis = new Vector3(0, 1, 0); @@ -170,12 +169,8 @@ export function GetBox(obj: Object3D, updateMatrix?: boolean): Box3 if (updateMatrix) obj.updateMatrixWorld(false); if (!obj.visible) return box; - obj.traverse(o => + obj.traverseVisible(o => { - //因为实体Erase时,实体仍然保存在Scene中. - if (o.visible === false) - return; - //@ts-ignore let geo = o.geometry as BufferGeometry; if (geo) @@ -185,7 +180,6 @@ export function GetBox(obj: Object3D, updateMatrix?: boolean): Box3 box.union(geo.boundingBox.clone().applyMatrix4(o.matrixWorld)); } }); - return box; } diff --git a/src/GraphicsSystem/CalcEdgeSealing.ts b/src/GraphicsSystem/CalcEdgeSealing.ts index 449edfa48..1a4c5e91d 100644 --- a/src/GraphicsSystem/CalcEdgeSealing.ts +++ b/src/GraphicsSystem/CalcEdgeSealing.ts @@ -1,10 +1,10 @@ import { FixIndex } from "../Common/Utils"; import { Curve } from "../DatabaseServices/Curve"; +import { Line } from "../DatabaseServices/Line"; import { Polyline } from "../DatabaseServices/Polyline"; +import { equaln, equalv3, isParallelTo } from "../Geometry/GeUtils"; import { IntersectOption } from "./IntersectWith"; import { PolyOffsetUtil } from "./OffsetPolyline"; -import { Line } from "../DatabaseServices/Line"; -import { isParallelTo } from "../Geometry/GeUtils"; /** *曲线列表分段 @@ -16,7 +16,7 @@ export function paragraphCulist(cus: Curve[]) let usedCu: WeakSet = new WeakSet(); //归类曲线,返回归类是否成功 - const paragraph = (cu: Curve, originCu: Curve, cus: Curve[]) => + const paragraph = (cu: Curve, originCu: Curve, cuList: Curve[], isBack: boolean) => { const cuIsLine = cu instanceof Line; const originCuIsLine = originCu instanceof Line; @@ -26,44 +26,62 @@ export function paragraphCulist(cus: Curve[]) if (originCuIsLine !== cuIsLine) { - if (originCuIsLine && !isParallelTo(originCu.GetFistDeriv(0), cu.GetFistDeriv(0))) + + if (originCuIsLine && + !isParallelTo(originCu.GetFistDeriv(0), cu.GetFistDeriv(0)) + && !isParallelTo(originCu.GetFistDeriv(0), cu.GetFistDeriv(1)) + ) + { return false; - if (cuIsLine && !isParallelTo(originCu.GetFistDeriv(1), cu.GetFistDeriv(0))) + } + + if (cuIsLine + && !isParallelTo(originCu.GetFistDeriv(1), cu.GetFistDeriv(0)) + && !isParallelTo(originCu.GetFistDeriv(0), cu.GetFistDeriv(0) + )) + { return false; + } } - - cus.push(cu); + if (isBack) + cuList.push(cu); + else + cuList.unshift(cu); usedCu.add(cu); return true; } + let caclCus = cus.slice().filter(c => !equaln(c.Length, 0)); - while (cus.length > 0) + while (caclCus.length > 0) { - let originCu = cus.shift(); + let originCu = caclCus.shift(); if (usedCu.has(originCu)) continue; let originCus = [originCu]; usedCu.add(originCu); //往后搜索 - for (let i = 0; i < cus.length; i++) + for (let i = 0; i < caclCus.length; i++) { - if (!paragraph(cus[i], originCu, originCus)) + if (!paragraph(caclCus[i], originCu, originCus, true)) break; - originCu = cus[i]; + originCu = caclCus[i]; } - - originCu = originCus[0]; - //往前搜索 - for (let i = cus.length - 1; i >= 0; i--) + //只有第一条才需要往前搜索 + if (caclCus.length === cus.length - 1) { - if (!paragraph(cus[i], originCu, originCus)) - break; - originCu = cus[i]; + originCu = originCus[0]; + //往前搜索 + for (let i = caclCus.length - 1; i >= 0; i--) + { + if (!paragraph(caclCus[i], originCu, originCus, false)) + break; + originCu = caclCus[i]; + } } newCulist.push(originCus); } - + cus.length = 0; //同组多条曲线连接为多段线 for (let g of newCulist) { @@ -92,6 +110,8 @@ export function calcEdgeSealing(cus: Curve[]) { let frontLine = cus[i]; let laterLine = cus[FixIndex(i + 1, cus)]; + if (equalv3(frontLine.EndPoint, laterLine.StartPoint)) + continue; let iPts = frontLine.IntersectWith(laterLine, IntersectOption.ExtendBoth); let tPts = iPts.filter(p => frontLine.PtOnCurve(p) diff --git a/src/UI/Components/Board/BoardCommon.tsx b/src/UI/Components/Board/BoardCommon.tsx index f3494c043..a779d9aa7 100644 --- a/src/UI/Components/Board/BoardCommon.tsx +++ b/src/UI/Components/Board/BoardCommon.tsx @@ -1,11 +1,14 @@ -import { Checkbox, Classes, HTMLSelect, Radio, RadioGroup } from '@blueprintjs/core'; +import { Button, Checkbox, Classes, HTMLSelect, Radio, RadioGroup } from '@blueprintjs/core'; import { observer } from 'mobx-react'; import * as React from 'react'; +import { app } from '../../../ApplicationServices/Application'; import { CheckObjectType } from '../../../Common/CheckoutVaildValue'; -import { BoardType } from '../../../DatabaseServices/Board'; -import { BoardConfigOption, BoardOption, BrRelativePos, TBBoardOption } from '../../Store/BoardInterface'; -import { ToasterInput } from '../Toaster'; +import { Board, BoardType } from '../../../DatabaseServices/Board'; +import { BoardConfigOption, BoardOption, BoardProcessOption, BrRelativePos, TBBoardOption } from '../../Store/BoardInterface'; import { DrillingOption } from '../../Store/drillInterface'; +import { RightPanelStore } from '../../Store/RightPanelStore'; +import { RightTabId } from '../RightPanel/RightPanel'; +import { AppToaster, ToasterInput } from '../Toaster'; type OptionType = BoardOption | DrillingOption; @@ -273,6 +276,8 @@ interface I5InputComponent extends ISetItemOption leftKey: string; rightKey: string; centerKey?: string; + isShowEditor?: boolean; + drillConfigs?: Map; } /** @@ -283,23 +288,62 @@ export class Input5Or4Component extends React.Component { render() { + const options = this.props.drillConfigs ? [ + ...this.props.drillConfigs.keys(), "不排" + ] : []; + const hightDrill = (this.props.option as BoardProcessOption).highDrill; + + const isShow = this.props.isShowEditor && hightDrill.length >= 6; + return (
-
+ { + isShow && + { + hightDrill[4] = e.currentTarget.value; + }} + /> + } +
+
+
+ + { + isShow && + { + hightDrill[5] = e.currentTarget.value; + }} + /> + } +
{ this.props.showDirectionIcon && } @@ -312,22 +356,121 @@ export class Input5Or4Component extends React.Component onChange={this.props.onChange} /> } +
+ + { + isShow && + { + hightDrill[3] = e.currentTarget.value; + }} + /> + } +
+
+
+ { + isShow && + { + hightDrill[2] = e.currentTarget.value; + }} + /> + }
- +
) } -} +} + +interface IDrillTypeSelect +{ + drillConfigs?: Map; + opt: BoardProcessOption; + br: Board; + isShowHigh?: boolean; +} + +@observer +export class DrillTypeSelectCom extends React.Component{ + private editorDrilling(br: Board) + { + app.m_Editor.m_ModalManage.Clear(); + let store = RightPanelStore.GetInstance() as RightPanelStore; + store.m_IsShow = true; + store.m_TabId = RightTabId.Drill; + store.EditorDrilling(br); + AppToaster.show({ + message:
正在编辑排钻,
点击<确定>写入排钻数据到板件,
点击<保存>保存当前排钻设置,
点击<退出>退出编辑状态
, + timeout: 0 + }); + } + private handleChange = (e) => + { + this.props.opt.drillType = e.target.value; + if (this.props.br && !this.props.br.IsSpecialShape) + { + this.props.opt.highDrill.fill(e.target.value, 2); + } + } + render() + { + const options = this.props.drillConfigs ? [ + ...this.props.drillConfigs.keys(), "不排" + ] : []; + const select = + + if (this.props.br && this.props.isShowHigh) + { + return
+ {select} +
+ } + else + { + return select; + } + } +} diff --git a/src/UI/Components/Board/BoardConfigModal.tsx b/src/UI/Components/Board/BoardConfigModal.tsx index c470a9548..5975e6de8 100644 --- a/src/UI/Components/Board/BoardConfigModal.tsx +++ b/src/UI/Components/Board/BoardConfigModal.tsx @@ -19,6 +19,7 @@ import { MoveMatrix } from "../../../Geometry/GeUtils"; import { BoardConfigOption, BoardProcessOption, FaceDirection, IGrooveOption } from '../../Store/BoardInterface'; import { RightPanelStore } from "../../Store/RightPanelStore"; import { BoardTypeComponent, ItemName, SetBoardDataBlock } from "./BoardCommon"; +import { RightTabId } from "../RightPanel/RightPanel"; interface BoardConfigProps { @@ -172,6 +173,9 @@ export class BoardConfigModal extends React.Component{ */ private PickUpModelingOutline = async () => { + await app.m_Editor.m_ModalManage.EndExecingCmd(); + if (!commandMachine.CommandStart("_pick")) + return; app.m_Editor.m_ModalManage.ToggleShow(); let br = this.props.br; @@ -219,8 +223,9 @@ export class BoardConfigModal extends React.Component{ //显示右侧状态栏 store.m_IsShow = true; - store.m_TabId = "modeling"; + store.m_TabId = RightTabId.Model; app.m_Editor.m_ModalManage.ToggleShow(); + commandMachine.CommandEnd(); } render() { diff --git a/src/UI/Components/Board/BoardFindModify.tsx b/src/UI/Components/Board/BoardFindModify.tsx index 3cd6668c2..396870b8f 100644 --- a/src/UI/Components/Board/BoardFindModify.tsx +++ b/src/UI/Components/Board/BoardFindModify.tsx @@ -11,8 +11,8 @@ import { EFindType, ECompareType } from '../../Store/BoardFindInterface'; import { EBoardKeyList } from '../../../Common/BoardKeyList'; import { app } from '../../../ApplicationServices/Application'; import { observable } from 'mobx'; -import { LinesType, FaceDirection, ComposingType } from '../../Store/BoardInterface'; -import { DrillType } from '../../Store/drillInterface'; +import { LinesType, FaceDirection, ComposingType, DrillType } from '../../Store/BoardInterface'; +import { userConfig } from '../../../Editor/UserConfig'; interface IBoardFindState @@ -114,6 +114,7 @@ export default class BoardFindModifyModal extends React.Component<{ store?: Boar const matPars1 = [ ["房名", EBoardKeyList.RoomName], ["柜名", EBoardKeyList.CabinetName], ] + const selectOptions = userConfig.drillConfigs ? [...userConfig.drillConfigs.keys(), "不排"] : []; return (
option[EBoardKeyList.UpSealed] = e.target.value} /> + option.highDrill[4] = e.currentTarget.value} + />
@@ -221,6 +229,13 @@ export default class BoardFindModifyModal extends React.Component<{ store?: Boar value={option[EBoardKeyList.LeftSealed]} onChange={e => option[EBoardKeyList.LeftSealed] = e.target.value} /> + option.highDrill[5] = e.currentTarget.value} + />
option[EBoardKeyList.RightSealed] = e.target.value} /> + option.highDrill[3] = e.currentTarget.value} + />
@@ -252,6 +274,13 @@ export default class BoardFindModifyModal extends React.Component<{ store?: Boar value={option[EBoardKeyList.DownSealed]} onChange={e => option[EBoardKeyList.DownSealed] = e.target.value} /> + option.highDrill[2] = e.currentTarget.value} + />
+
+ 正反面是否排钻 + +
@@ -428,8 +480,7 @@ export default class BoardFindModifyModal extends React.Component<{ store?: Boar { @@ -32,10 +31,9 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}> super(props); this.m_CurrentBoard = this.props.board; this.m_IsSpecialBoard.set(this.props.board.IsSpecialShape); - this.SetBrConfig(); - this.m_ProcessOption = Object.assign({}, this.m_CurrentBoard.BoardProcessOption); + this.setBrConfig(); } - SetBrConfig = () => + private setBrConfig = () => { let ro = this.m_CurrentBoard.Rotation; @@ -70,6 +68,25 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}> else this.m_GrooveOption = newGrooveOpt; + const boardProcessOption = this.m_CurrentBoard.BoardProcessOption; + + if (!this.m_IsSpecialBoard.get() && boardProcessOption.highDrill.length === 0) + { + boardProcessOption.highDrill.push(...Array(6).fill(boardProcessOption.drillType)); + } + if (!this.m_ProcessOption) + { + this.m_ProcessOption = boardProcessOption; + } + else + Object.assign(this.m_ProcessOption, boardProcessOption); + + } + private handleChangeCurrentBoard = (e) => + { + let br = this.m_BoardMap.get(e.target.value); + this.m_CurrentBoard = br; + this.setBrConfig(); } handleComfirmOption = () => { @@ -83,9 +100,15 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}> app.m_Database.hm.StartCmd("changeSize"); let board = this.m_CurrentBoard; - board.BoardProcessOption = this.m_ProcessOption; - board.Name = this.m_ConfigOption.name; + let oldDrillType = board.BoardProcessOption.drillType; + board.BoardProcessOption = toJS(this.m_ProcessOption); + if (oldDrillType !== this.m_ProcessOption.drillType) + { + (DrawDrillingTool.GetInstance() as DrawDrillingTool).ResetGangDrill(board); + } + + board.Name = this.m_ConfigOption.name; board.Height = this.m_ConfigOption.height; board.Width = this.m_ConfigOption.width; board.Thickness = this.m_ConfigOption.thickness; @@ -172,12 +195,7 @@ export class BoardOptionModal extends React.Component<{ board: Board }, {}> } }) } - onChange={e => - { - let br = this.m_BoardMap.get(e.target.value); - this.SetBrConfig(); - Object.assign(this.m_ProcessOption, br.BoardProcessOption); - }} + onChange={this.handleChangeCurrentBoard} />
diff --git a/src/UI/Components/Board/BoardProcessModal.tsx b/src/UI/Components/Board/BoardProcessModal.tsx index cd17e90b5..751800739 100644 --- a/src/UI/Components/Board/BoardProcessModal.tsx +++ b/src/UI/Components/Board/BoardProcessModal.tsx @@ -1,13 +1,18 @@ -import { Classes, HTMLSelect } from '@blueprintjs/core'; -import { IObservableValue } from 'mobx'; +import { Button, Classes, HTMLSelect, Checkbox } from '@blueprintjs/core'; +import { IObservableValue, observable } from 'mobx'; import { observer } from 'mobx-react'; import * as React from 'react'; +import { app } from '../../../ApplicationServices/Application'; import { CheckObjectType } from '../../../Common/CheckoutVaildValue'; import { Board } from '../../../DatabaseServices/Board'; import { Circle } from '../../../DatabaseServices/Circle'; -import { BoardProcessOption, ComposingType, DrillType, LinesType, FaceDirection } from '../../Store/BoardInterface'; -import { Input5Or4Component, SetBoardDataBlock, SetBoardDataItem } from './BoardCommon'; -import { EdgeSealingComponent } from './EdgeSealingComponent'; +import { userConfig } from '../../../Editor/UserConfig'; +import { BoardProcessOption, ComposingType, FaceDirection, LinesType, DrillType } from '../../Store/BoardInterface'; +import { DrillingOption } from '../../Store/drillInterface'; +import { RightPanelStore } from '../../Store/RightPanelStore'; +import { RightTabId } from '../RightPanel/RightPanel'; +import { AppToaster } from '../Toaster'; +import { DrillTypeSelectCom, Input5Or4Component, SetBoardDataBlock, SetBoardDataItem } from './BoardCommon'; interface BoardProcessProps { @@ -20,6 +25,23 @@ export class BoardProcessModal extends React.Component{ private matPars = [ ["boardName", "板材名"], ["material", "材料"], ["color", "颜色"] ]; + @observable private drillConfigs: Map; + private editorEdgeSealing(br: Board) + { + app.m_Editor.m_ModalManage.Clear(); + let store = RightPanelStore.GetInstance() as RightPanelStore; + store.m_IsShow = true; + store.m_TabId = RightTabId.Seal; + store.EditorEdgeSealing(br); + AppToaster.show({ + message:
正在编辑封边,
点击<写入>写入封边数据到板件,
点击<保存>保存当前封边数据,
点击<退出>退出编辑状态
, + timeout: 0 + }); + } + async componentWillMount() + { + this.drillConfigs = userConfig.drillConfigs; + } render() { let isShowHighEditor = this.props.br @@ -102,28 +124,11 @@ export class BoardProcessModal extends React.Component{ + { + Boolean(this.props.br) && this.props.opt.highDrill.length > 0 && + } +
封边 { - isShowHighEditor && + isShowHighEditor && +
{ @@ -170,6 +216,8 @@ export class BoardProcessModal extends React.Component{ leftKey="sealedLeft" rightKey="sealedRight" option={this.props.opt} + drillConfigs={this.drillConfigs} + isShowEditor={Boolean(this.props.br)} /> } diff --git a/src/UI/Components/Board/DrillCommon.tsx b/src/UI/Components/Board/DrillCommon.tsx new file mode 100644 index 000000000..02e96a01e --- /dev/null +++ b/src/UI/Components/Board/DrillCommon.tsx @@ -0,0 +1,95 @@ +import { Button, Card, Classes, Popover, Position, Radio, RadioGroup, Intent } from '@blueprintjs/core'; +import { observable } from 'mobx'; +import { observer } from 'mobx-react'; +import * as React from 'react'; +import { DrillStore } from '../../Store/DrillStore'; + +@observer +export class DrillTypeCom extends React.Component<{ store: DrillStore }, { typeName: string }> +{ + constructor(props) + { + super(props); + this.state = { + typeName: "" + } + } + private addDrillType = () => + { + this.props.store.AddNewDrillType(this.state.typeName); + this.props.store.type = this.state.typeName; + this.handleUpdate(); + } + private handleOnChange = (e) => + { + const store = this.props.store; + store.type = e.currentTarget.value; + this.handleUpdate(); + } + private handleDelete = () => + { + const store = this.props.store; + store.drillConfig.delete(store.type); + let types = [...store.drillConfig.keys()]; + if (types.length > 0) + { + store.type = types[0]; + this.handleUpdate(); + } + } + private handleUpdate = () => + { + const store = this.props.store; + observable(store.rules).replace(store.drillConfig.get(store.type)); + store.ChangeRules(0); + } + render() + { + const store = this.props.store; + + return ( +
+ + { + [...store.drillConfig.keys()].map(type => ) + } + +
+ this.setState({ typeName: "" })} + content={ + + this.setState({ typeName: e.target.value })} + /> +
+
+ ) + } +} + diff --git a/src/UI/Components/Board/EdgeSealingComponent.tsx b/src/UI/Components/Board/EdgeSealingComponent.tsx deleted file mode 100644 index e05460cfa..000000000 --- a/src/UI/Components/Board/EdgeSealingComponent.tsx +++ /dev/null @@ -1,161 +0,0 @@ -import { Button, Classes, Intent, Popover } from '@blueprintjs/core'; -import { observable } from 'mobx'; -import { observer } from 'mobx-react'; -import * as React from 'react'; -import { Matrix4, Vector3 } from 'three'; -import { app } from '../../../ApplicationServices/Application'; -import { Board } from '../../../DatabaseServices/Board'; -import { Curve } from '../../../DatabaseServices/Curve'; -import { Text } from '../../../DatabaseServices/Text/Text'; -import { JigUtils } from '../../../Editor/JigUtils'; -import { calcEdgeSealing, paragraphCulist } from '../../../GraphicsSystem/CalcEdgeSealing'; -import { MoveMatrix } from '../../../Geometry/GeUtils'; - -@observer -export class EdgeSealingComponent extends React.Component<{ br: Board }, {}> -{ - private ulList: HTMLUListElement; - @observable private cuList: Curve[] = []; - constructor(props) - { - super(props); - } - private EditorEdgeSealing = () => - { - let br = this.props.br; - let cus = br.ContourCurve.Explode() as Curve[]; - - //曲线分段 - paragraphCulist(cus); - //替换曲线列表 - observable(this.cuList).replace(cus); - - app.m_Viewer.m_CameraCtrl.LookAt(br.Normal.negate()); - app.m_Editor.UCSMatrix = new Matrix4().extractRotation(br.OCS); - app.m_Editor.UpdateScreen(); - - JigUtils.Destroy(); - for (let i = 0; i < this.cuList.length; i++) - { - let cu = this.cuList[i]; - let p = cu.GetPointAtParam(cu.EndParam / 2); - JigUtils.Draw(new Text(p, (i + 1).toString()) - .ApplyMatrix(MoveMatrix(new Vector3(0, 0, br.Thickness))) - .ApplyMatrix(br.OCS)); - //显示对应设置的边 - let refCu = cu.Clone(); - refCu.ColorIndex = i + 1 - JigUtils.Draw(refCu.ApplyMatrix(br.OCS)); - } - } - - private CalcEdgeSealing = () => - { - let originCurve = this.props.br.ContourCurve; - let dir = Math.sign(originCurve.Area2) * -1; - let infoEls = this.ulList.querySelectorAll('li input'); - let edgeSealingNum: number[] = []; - let highSeal = this.props.br.BoardProcessOption.highSealed; - highSeal.length = 0; - infoEls.forEach(el => - { - let size = parseFloat((el as HTMLInputElement).value); - highSeal.push({ - size - }) - edgeSealingNum.push(size * dir); - }); - - let calcCus = this.cuList; - let offsetCus: Curve[] = []; - - for (let i = 0; i < calcCus.length; i++) - { - let cu = calcCus[i]; - offsetCus.push(...cu.GetOffsetCurves(edgeSealingNum[i])); - } - calcEdgeSealing(offsetCus); - this.ShowSealingResult(offsetCus); - } - private ShowSealingResult = (offsetCus: Curve[]) => - { - offsetCus.forEach((cu, i) => - { - cu.ApplyMatrix(MoveMatrix(new Vector3(0, 0, this.props.br.Thickness))) - .ApplyMatrix(this.props.br.OCS); - JigUtils.Draw(cu); - }) - app.m_Editor.UpdateScreen(); - } - render() - { - let highSeal = this.props.br.BoardProcessOption.highSealed; - //兼容以前没有这个属性的版本 - if (!highSeal) - { - this.props.br.BoardProcessOption.highSealed = []; - highSeal = []; - } - return ( - -
封边编辑
-
    this.ulList = el} - > - { - this.cuList.map((cu, i) => - { - let defaultValue = "1.0"; - if (highSeal.length > 0) - defaultValue = highSeal[i] ? highSeal[i].size.toString() : "1"; - return ( -
  • - -
  • - ) - }) - } -
-
-
- - } - target={ -