From 9de55c834402089a0d135732db23b27809958f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=AF=97=E6=B4=A5?= <2723065175@qq.com> Date: Wed, 8 May 2024 02:15:03 +0000 Subject: [PATCH] =?UTF-8?q?!2721=20=E6=96=B0=E5=A2=9E:=E5=9C=86=E5=BC=A7?= =?UTF-8?q?=E6=9D=BF=E5=9C=86=E5=BC=A7=E6=A7=BD=E9=80=9A=E7=94=A8=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Add-on/ArcBoard/ArcBoardFeeding.ts | 6 +- .../ArcBoardGeooveConfig/ArcBoardGroove.tsx | 107 ++++++++++ .../ArcBoardGrooveStore.ts | 28 +++ src/Add-on/ArcBoard/DrawArcBoard.ts | 195 ++++++++++++------ src/DatabaseServices/Entity/Board.ts | 28 ++- .../Template/Action/TemplateFilletAction.ts | 1 + src/Editor/DefaultConfig.ts | 13 +- src/UI/Components/Board/ArcBoardOption.tsx | 3 +- src/UI/Components/Board/BoardModalType.ts | 1 + .../Store/OptionInterface/IOptionInterface.ts | 10 + 10 files changed, 310 insertions(+), 82 deletions(-) create mode 100644 src/Add-on/ArcBoard/ArcBoardGeooveConfig/ArcBoardGroove.tsx create mode 100644 src/Add-on/ArcBoard/ArcBoardGeooveConfig/ArcBoardGrooveStore.ts diff --git a/src/Add-on/ArcBoard/ArcBoardFeeding.ts b/src/Add-on/ArcBoard/ArcBoardFeeding.ts index 4a0cf501a..3d6889008 100644 --- a/src/Add-on/ArcBoard/ArcBoardFeeding.ts +++ b/src/Add-on/ArcBoard/ArcBoardFeeding.ts @@ -17,7 +17,7 @@ export interface ArcBoardOptions grooveWidth: number; retainedThickness: number; knifeRadius: number; - grooveAddLengt: number; + grooveAddLength: number; grooveAddWidth: number; grooveAddDepth: number; arcExtension: number; @@ -30,7 +30,7 @@ export const defultArcBoardOption: ArcBoardOptions = { grooveWidth: 6, retainedThickness: 2, knifeRadius: 3, - grooveAddLengt: 0, + grooveAddLength: 0, grooveAddWidth: 0, grooveAddDepth: 0, arcExtension: 0, @@ -122,7 +122,7 @@ export function ParseBoardArcFeed(br: Board, path: Polyline, angle: number, dir: thickness: br.Thickness - arcBoardOption.retainedThickness, dir: dir === 0 ? FaceDirection.Back : FaceDirection.Front, knifeRadius: arcBoardOption.knifeRadius, - addLen: arcBoardOption.grooveAddLengt, + addLen: arcBoardOption.grooveAddLength, addWidth: arcBoardOption.grooveAddWidth, addDepth: arcBoardOption.grooveAddDepth, }); diff --git a/src/Add-on/ArcBoard/ArcBoardGeooveConfig/ArcBoardGroove.tsx b/src/Add-on/ArcBoard/ArcBoardGeooveConfig/ArcBoardGroove.tsx new file mode 100644 index 000000000..a0af49818 --- /dev/null +++ b/src/Add-on/ArcBoard/ArcBoardGeooveConfig/ArcBoardGroove.tsx @@ -0,0 +1,107 @@ +import { Button, Checkbox, Classes } from "@blueprintjs/core"; +import { observer } from "mobx-react"; +import React from "react"; +import { CheckObjectType } from "../../../Common/CheckoutVaildValue"; +import { SetBoardDataItem } from "../../../UI/Components/Board/BoardCommon"; +import { BoardModalType } from "../../../UI/Components/Board/BoardModalType"; +import { Config_ModalType } from "../../../UI/Components/Board/UserConfigComponent"; +import { CommonModal } from "../../../UI/Components/Modal/ModalContainer"; +import { ModalState } from "../../../UI/Components/Modal/ModalInterface"; +import { ArcBoardGrooveStore } from "./ArcBoardGrooveStore"; + +@observer +export class ArcBoardGroove extends React.Component<{ store: ArcBoardGrooveStore, type: BoardModalType; }, {}> +{ + curveBoardPars = [ + ["retainedThickness", "留底厚度"], + ["knifeRadius", "刀半径"], + ["grooveAddLength", "槽加长"], + ["grooveAddWidth", "槽加宽"], + ["grooveAddDepth", "槽加深"], + ]; + + render() + { + const { store, type } = this.props; + return ( + store.OnOk(ModalState.Cancel)} + configType={Config_ModalType.ConfigListModal} + store={store} + type={type} + footerChildren={ + <> + + { + store.OnOk(ModalState.Ok, true, { isOk: true }); + }} /> + + { + store.OnOk(ModalState.Cancel); + }} /> + > + } + > + + + + { + store.m_Option.isDrawArcGroove = !store.m_Option.isDrawArcGroove; + }} + /> + + + { + + {"通用转角槽配置"} + + { + this.curveBoardPars.map(([optKey, title], index) => + { + return ( + ); + }) + } + + + } + + + + ); + } +} diff --git a/src/Add-on/ArcBoard/ArcBoardGeooveConfig/ArcBoardGrooveStore.ts b/src/Add-on/ArcBoard/ArcBoardGeooveConfig/ArcBoardGrooveStore.ts new file mode 100644 index 000000000..522b848c9 --- /dev/null +++ b/src/Add-on/ArcBoard/ArcBoardGeooveConfig/ArcBoardGrooveStore.ts @@ -0,0 +1,28 @@ +import { observable, toJS } from "mobx"; +import { DefaultArcBoardGrooveOption } from "../../../Editor/DefaultConfig"; +import { IConfigOption } from "../../../UI/Components/Board/UserConfigComponent"; +import { BoardStore } from "../../../UI/Store/BoardStore"; +import { IArcBoardGrooveOption } from "../../../UI/Store/OptionInterface/IOptionInterface"; + +export class ArcBoardGrooveStore extends BoardStore +{ + title = "圆弧板通用配置"; + @observable m_Option: IArcBoardGrooveOption = { ...DefaultArcBoardGrooveOption, }; + + InitOption() + { + Object.assign(this.m_Option, DefaultArcBoardGrooveOption); + } + + UpdateOption(cof: IConfigOption): void + { + Object.assign(this.m_Option, cof.option); + } + + SaveConfig() + { + let newConfig: IConfigOption = {}; + newConfig.option = toJS(this.m_Option); + return newConfig; + } +} diff --git a/src/Add-on/ArcBoard/DrawArcBoard.ts b/src/Add-on/ArcBoard/DrawArcBoard.ts index a06e2c888..46f259744 100644 --- a/src/Add-on/ArcBoard/DrawArcBoard.ts +++ b/src/Add-on/ArcBoard/DrawArcBoard.ts @@ -3,10 +3,12 @@ import { app } from "../../ApplicationServices/Application"; import { GetPointAtCurveDir } from "../../Common/CurveUtils"; import { Draw } from "../../Common/Draw"; import { FixedNotZero } from "../../Common/Utils"; +import { safeEval } from "../../Common/eval"; import { Board } from "../../DatabaseServices/Entity/Board"; import { Line } from "../../DatabaseServices/Entity/Line"; import { Polyline } from "../../DatabaseServices/Entity/Polyline"; import { Command } from "../../Editor/CommandMachine"; +import { DefaultArcBoardGrooveOption } from "../../Editor/DefaultConfig"; import { JigUtils } from "../../Editor/JigUtils"; import { PromptStatus } from "../../Editor/PromptResult"; import { UCSUtils } from "../../Editor/UCSRAII"; @@ -14,16 +16,38 @@ import { ZAxis, ZeroVec, equaln, equalv3, isPerpendicularityTo } from "../../Geo import { HotCMD } from "../../Hot/HotCommand"; import { BoardModal } from "../../UI/Components/Board/BoardModal"; import { BoardModalType } from "../../UI/Components/Board/BoardModalType"; +import { IConfigOption } from "../../UI/Components/Board/UserConfigComponent"; import { ModalState } from "../../UI/Components/Modal/ModalInterface"; +import { IArcBoardGrooveOption } from "../../UI/Store/OptionInterface/IOptionInterface"; +import { userConfigStore } from "../../UI/Store/UserConfigStore"; import { FaceDirection } from "../DrawDrilling/DrillType"; import { ArcBoardBuild } from "./ArcBoardBuild"; +import { ArcBoardGroove } from "./ArcBoardGeooveConfig/ArcBoardGroove"; +import { ArcBoardGrooveStore } from "./ArcBoardGeooveConfig/ArcBoardGrooveStore"; import { arcBoardStore } from "./ArcBoardStore"; +let arcBoardGrooveOption: IArcBoardGrooveOption = { ...DefaultArcBoardGrooveOption }; @HotCMD export class Command_DrawArcBoard implements Command { + arcBoardGrooveStore: ArcBoardGrooveStore = ArcBoardGrooveStore.GetInstance(); + + constructor() + { + this.InitGrooveOption(); + } + async InitGrooveOption() + { + let config = await userConfigStore.GetConfig(BoardModalType.ArcBoardGrooves) as IConfigOption; + if (config) + { + this.arcBoardGrooveStore.UpdateOption(config); + arcBoardGrooveOption = config.option; + } + } async exec() { + arcBoardGrooveOption = { ...this.arcBoardGrooveStore.m_Option }; // 1.选择要放样的路径 const pathRes = await app.Editor.GetEntity({ Msg: "选择要放样的路径:", Filter: { filterTypes: [Polyline] } }); if (pathRes.Status !== PromptStatus.OK) return; @@ -108,87 +132,111 @@ export async function DrawArcBoard(params: { odir: number; fdir: number; }, path { const { odir, fdir } = params; - //4.选择要弯曲的板 或者创建个板 - const brRes = await app.Editor.GetSelection({ - Msg: "选择要弯曲的板:", - Filter: { - filterTypes: [Board], - }, - KeyWordList: [ - { - key: "C", - msg: "创建板" - } - ] - }); + while (true) + { + //4.选择要弯曲的板 或者创建个板 + const brRes = await app.Editor.GetSelection({ + Msg: "选择要弯曲的板:", + Filter: { + filterTypes: [Board], + }, + KeyWordList: [ + { + key: "C", + msg: "创建板" + }, + { + key: "S", + msg: "配置" + } + ] + }); - if (!(brRes.Status === PromptStatus.OK || brRes.Status === PromptStatus.Keyword)) return; + if (!(brRes.Status === PromptStatus.OK || brRes.Status === PromptStatus.Keyword)) return; - if (brRes.Status === PromptStatus.Keyword) - { - const store = arcBoardStore; - store.m_Option.width = path1.Length; - store.UpdateUIOption(); - app.Editor.ModalManage.RenderModal(BoardModal, { store, type: BoardModalType.ArcBr }); - const res = await app.Editor.ModalManage.Wait(); - if (res.Status === ModalState.Cancel) return; + if (brRes.Status === PromptStatus.Keyword) + { + if (brRes.StringResult === "C") + { + const store = arcBoardStore; + store.m_Option.width = path1.Length; + store.UpdateUIOption(); + app.Editor.ModalManage.RenderModal(BoardModal, { store, type: BoardModalType.ArcBr }); + const res = await app.Editor.ModalManage.Wait(); + if (res.Status === ModalState.Cancel) continue; - const { name, type, height, thickness } = store.m_Option; + const { name, type, height, thickness } = store.m_Option; - let path2 = path1.GetOffsetCurves(thickness * odir)[0]; - let backPath: Polyline;//背面路径 - let brWidth: number; + let path2 = path1.GetOffsetCurves(thickness * odir)[0]; + let backPath: Polyline;//背面路径 + let brWidth: number; - //如果见光面方向等于偏移方向 则使用path1 作为背面路径 - if (fdir === odir) - { - backPath = path1; - if (odir < 0) - backPath.Reverse(); + //如果见光面方向等于偏移方向 则使用path1 作为背面路径 + if (fdir === odir) + { + backPath = path1; + if (odir < 0) + backPath.Reverse(); - brWidth = Number.parseFloat(FixedNotZero(path2.Length, 5)); - } - else//反之 - { - backPath = path2; - if (odir > 0) - backPath.Reverse(); + brWidth = Number.parseFloat(FixedNotZero(path2.Length, 5)); + } + else//反之 + { + backPath = path2; + if (odir > 0) + backPath.Reverse(); - brWidth = Number.parseFloat(FixedNotZero(path1.Length, 5)); - } + brWidth = Number.parseFloat(FixedNotZero(path1.Length, 5)); + } - //针对此path构件一个板 - let br = new Board().InitBoard(height, brWidth, thickness, type); - br.Name = name; - br.BoardProcessOption = store.BoardProcessOption; + //针对此path构件一个板 + let br = new Board().InitBoard(height, brWidth, thickness, type); + br.Name = name; + br.BoardProcessOption = store.BoardProcessOption; - if (brWidth != store.m_Option.width) - { - br.FixArcSweepPathLength(); - } + if (brWidth != store.m_Option.width) + { + br.FixArcSweepPathLength(); + } - let x = backPath.EndPoint.sub(backPath.StartPoint).normalize(); - if (equalv3(x, ZeroVec)) - x = new Vector3(1, 0, 0); - let y = backPath.Normal; - let z = new Vector3().crossVectors(x, y); + let x = backPath.EndPoint.sub(backPath.StartPoint).normalize(); + if (equalv3(x, ZeroVec)) + x = new Vector3(1, 0, 0); + let y = backPath.Normal; + let z = new Vector3().crossVectors(x, y); - br.ApplyMatrix(new Matrix4().makeBasis(x, y, z).setPosition(backPath.StartPoint)); - br.SweepVisibleFace = FaceDirection.Front; + br.ApplyMatrix(new Matrix4().makeBasis(x, y, z).setPosition(backPath.StartPoint)); + br.SweepVisibleFace = FaceDirection.Front; - let path = backPath.Clone(); - let [angle, isRev] = Path2BoardPath(br, path); - if (isRev) + let path = backPath.Clone(); + let [angle, isRev] = Path2BoardPath(br, path); + if (isRev) + { + console.error("未预料到的错误 我们已经根据起点和终点构建了 没想到还是出错了!!!!"); + } + br.SetSweepPath(path, angle); + UpdataDefultArcBoardOption(br, arcBoardGrooveOption); + + Draw(br); + break; + } + else if (brRes.StringResult === "S") + { + let arcBoardGrooveStore = ArcBoardGrooveStore.GetInstance(); + app.Editor.ModalManage.RenderModal(ArcBoardGroove, { store: arcBoardGrooveStore, type: BoardModalType.ArcBoardGrooves }); + let res = await app.Editor.ModalManage.Wait(); + if (res.Status === ModalState.Ok) + { + arcBoardGrooveOption = arcBoardGrooveStore.m_Option; + } + } + } + else { - console.error("未预料到的错误 我们已经根据起点和终点构建了 没想到还是出错了!!!!"); + const brs = brRes.SelectSet.SelectEntityList as Board[]; + await ApplyArcBoardByPathInfo(brs, odir, fdir, path1); + break; } - br.SetSweepPath(path, angle); - Draw(br); - } - else - { - const brs = brRes.SelectSet.SelectEntityList as Board[]; - await ApplyArcBoardByPathInfo(brs, odir, fdir, path1); } } @@ -277,6 +325,7 @@ export async function ApplyArcBoardByPathInfo(brs: Board[], odir: number, fdir: } br.SetSweepPath(path, angle); + UpdataDefultArcBoardOption(br, arcBoardGrooveOption); let length = br.ArcBuild.SweepLength; let brLength = br.ParseBoardLengthInArcSweep(); @@ -285,6 +334,7 @@ export async function ApplyArcBoardByPathInfo(brs: Board[], odir: number, fdir: br.FixContourByArcSweepPath(); else br.FixArcSweepPathLength(); + br.UpdateArcBoardOptions(true); } } @@ -390,3 +440,14 @@ export function Path2BoardPath(br: Board, path: Polyline): [number, boolean] return [0, isReverse]; } } + +async function UpdataDefultArcBoardOption(br: Board, option: IArcBoardGrooveOption) +{ + let defaultOption = br.ArcBoardOptions.get(-1); + defaultOption.retainedThickness = safeEval(option.retainedThickness); + defaultOption.knifeRadius = safeEval(option.knifeRadius); + defaultOption.grooveAddLength = safeEval(option.grooveAddLength); + defaultOption.grooveAddWidth = safeEval(option.grooveAddWidth); + defaultOption.grooveAddDepth = safeEval(option.grooveAddDepth); + br.IsDrawArcGroove = option.isDrawArcGroove; +} diff --git a/src/DatabaseServices/Entity/Board.ts b/src/DatabaseServices/Entity/Board.ts index ac98e992c..91d3e18cb 100644 --- a/src/DatabaseServices/Entity/Board.ts +++ b/src/DatabaseServices/Entity/Board.ts @@ -201,26 +201,36 @@ export class Board extends ExtrudeSolid { this.WriteAllObjectRecord(); this._ArcBoardOptions = opt; - this.UpdateArcBoardOptions(); + this.UpdateArcBoardOptions(false); this.Update(); } - UpdateArcBoardOptions(): void + UpdateArcBoardOptions(isNewPath: boolean): void { //更新ArcBuild曲线数据 this._SweepArcBoardBuild = new ArcBoardBuild(this).ParseSweepCurves(); let cus = this.GetSweepPathInWCS().Explode(); - if (cus.filter(cu => cu instanceof Arc).length <= this._ArcBoardOptions.size - 1) + + let newOpts = new Map(); + newOpts.set(-1, this._ArcBoardOptions.get(-1)); + //如果是新的多段线信息,就更新全部数据 + if (isNewPath) + { + cus.forEach((cu, i) => + { + if (cu instanceof Arc) + newOpts.set(i, { ...defultArcBoardOption, arcLength: parseFloat(FixedNotZero(cu.Length, 5)) }); + }); + } + else if (cus.filter(cu => cu instanceof Arc).length <= this._ArcBoardOptions.size - 1) { - let newOpts = new Map(); - newOpts.set(-1, this._ArcBoardOptions.get(-1)); cus.forEach((cu, i) => { if (cu instanceof Arc && this._ArcBoardOptions.has(i)) newOpts.set(i, { ...this._ArcBoardOptions.get(i), arcLength: parseFloat(FixedNotZero(cu.Length, 5)) }); }); - this._ArcBoardOptions = newOpts; } + this._ArcBoardOptions = newOpts; } get IsArcBoard() @@ -237,7 +247,6 @@ export class Board extends ExtrudeSolid SetSweepPath(path: Polyline, sweepAngle: number) { this.WriteAllObjectRecord(); - this._ArcBoardOptions.clear(); this._SweepPath = path; this._SweepAngle = sweepAngle; this.Update(); @@ -325,7 +334,6 @@ export class Board extends ExtrudeSolid this._SweepPath = ArcBoardBuild.OffsetPolyline(path, this.thickness); } } - this.UpdateArcBoardOptions(); } ParseBoardLengthInArcSweep(): number @@ -2950,7 +2958,7 @@ export class Board extends ExtrudeSolid grooveWidth: file.Read(), retainedThickness: file.Read(), grooveAddDepth: file.Read(), - grooveAddLengt: file.Read(), + grooveAddLength: file.Read(), grooveAddWidth: file.Read(), knifeRadius: file.Read(), arcExtension: 0, @@ -3054,7 +3062,7 @@ export class Board extends ExtrudeSolid file.Write(v.grooveWidth); file.Write(v.retainedThickness); file.Write(v.grooveAddDepth); - file.Write(v.grooveAddLengt); + file.Write(v.grooveAddLength); file.Write(v.grooveAddWidth); file.Write(v.knifeRadius); file.Write(v.arcExtension); diff --git a/src/DatabaseServices/Template/Action/TemplateFilletAction.ts b/src/DatabaseServices/Template/Action/TemplateFilletAction.ts index b11e26b90..f564cff7a 100644 --- a/src/DatabaseServices/Template/Action/TemplateFilletAction.ts +++ b/src/DatabaseServices/Template/Action/TemplateFilletAction.ts @@ -108,6 +108,7 @@ export class TemplateFilletAction extends TemplateAction { br.SetSweepPath(faker.path, br.SweepAngle); br.FixContourByArcSweepPath(); + br.UpdateArcBoardOptions(false); } } diff --git a/src/Editor/DefaultConfig.ts b/src/Editor/DefaultConfig.ts index 4d8c8a270..3668ae926 100644 --- a/src/Editor/DefaultConfig.ts +++ b/src/Editor/DefaultConfig.ts @@ -16,7 +16,7 @@ import { CurtailType, IBoardBatchCurtailOption } from "../UI/Store/OptionInterfa import { BoardProcessOption } from "../UI/Store/OptionInterface/BoardProcessOption"; import { BulkheadCeilingOption } from "../UI/Store/OptionInterface/BulkheadCeilingOption"; import { ClosingStripOption, StripType } from "../UI/Store/OptionInterface/ClosingStripOption"; -import { BehindBoardOption, BoardConfigOption, ChangeColorByBoardMaterialOption, ChangeColorByRoomOrCabinetOption, CommonPanelConfigOption, DatalistConfigOption, DoorRelatesInfoOption, IBatchModifyPanelOption, IDimStyleOption, LayerBoardOption, LayerNailOption, ModifyTextsConfigOption, OneClickInspectionOption, RightPlaneLightOption, ShareBoardInfConfigurationOption, SideBoardOption, SingleBoardOption, TBBoardOption, VerticalBoardOption, WindowPanelConfigOption } from "../UI/Store/OptionInterface/IOptionInterface"; +import { BehindBoardOption, BoardConfigOption, ChangeColorByBoardMaterialOption, ChangeColorByRoomOrCabinetOption, CommonPanelConfigOption, DatalistConfigOption, DoorRelatesInfoOption, IArcBoardGrooveOption, IBatchModifyPanelOption, IDimStyleOption, LayerBoardOption, LayerNailOption, ModifyTextsConfigOption, OneClickInspectionOption, RightPlaneLightOption, ShareBoardInfConfigurationOption, SideBoardOption, SingleBoardOption, TBBoardOption, VerticalBoardOption, WindowPanelConfigOption } from "../UI/Store/OptionInterface/IOptionInterface"; import { PointLightOption, RectAreaLightOption, SpotLightOption } from "../UI/Store/OptionInterface/LightConfigOption"; import { BehindHeightPositon, RadioType, ViewDirection, ViewportPosition } from "../UI/Store/OptionInterface/OptionEnum"; import { Viewport2ConfigOption, Viewport3ConfigOption, Viewport4ConfigOption, ViewportConfigOption } from "../UI/Store/OptionInterface/ViewportConfigOption"; @@ -1076,3 +1076,14 @@ export const DefaultOneClickInspectionOption: OneClickInspectionOption = { } }; Object.freeze(DefaultOneClickInspectionOption); + +export const DefaultArcBoardGrooveOption: IArcBoardGrooveOption = { + version: 1, + isDrawArcGroove: true, + retainedThickness: "2", + knifeRadius: "3", + grooveAddLength: "0", + grooveAddWidth: "0", + grooveAddDepth: "0", +}; +Object.freeze(DefaultArcBoardGrooveOption); diff --git a/src/UI/Components/Board/ArcBoardOption.tsx b/src/UI/Components/Board/ArcBoardOption.tsx index c9f57e874..45c0121dd 100644 --- a/src/UI/Components/Board/ArcBoardOption.tsx +++ b/src/UI/Components/Board/ArcBoardOption.tsx @@ -27,7 +27,7 @@ export const ArcBoardOption = (observer(({ showCurveBoardOpt, arcBoardOptions, a ["arcExtension", "圆弧头尾延长"], ["retainedThickness", "留底厚度"], ["knifeRadius", "刀半径"], - ["grooveAddLengt", "槽加长"], + ["grooveAddLength", "槽加长"], ["grooveAddWidth", "槽加宽"], ["grooveAddDepth", "槽加深"], ]; @@ -112,6 +112,7 @@ export const ArcBoardOption = (observer(({ showCurveBoardOpt, arcBoardOptions, a let display = (i === 0 && index <= 2); return (