From d622f8633d21a20a73a230553420be7b569c1c88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=B8=89?= <940119273@qq.com> Date: Fri, 8 Sep 2023 03:39:54 +0000 Subject: [PATCH] =?UTF-8?q?!2339=20=E5=BC=80=E5=8F=91:=E5=88=86=E4=BA=AB?= =?UTF-8?q?=E5=9B=BE=E7=BA=B8=E4=B8=AD=E6=8E=92=E9=92=BB=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=88=86=E7=82=B8=E5=9B=BE=E6=95=88=E6=9E=9C,=E5=92=8C?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=9A=90=E8=97=8F=E6=8E=92=E9=92=BB=E5=BC=80?= =?UTF-8?q?=E5=85=B3=20Merge=20pull=20request=20!2339=20from=20=E6=9E=97?= =?UTF-8?q?=E4=B8=89/share=5Fview=5FcylinderHole?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Add-on/ShareView/ShareViewService.ts | 35 +++++++++++++++---- src/Add-on/ShareView/ShareViewStore.ts | 2 ++ src/Add-on/ShareView/ShareViewUtil.ts | 12 ++++++- .../components/HideComponentsMenu/index.tsx | 7 ++++ .../ShareView/components/ShareViewUI.tsx | 34 +++++++++++------- 5 files changed, 70 insertions(+), 20 deletions(-) diff --git a/src/Add-on/ShareView/ShareViewService.ts b/src/Add-on/ShareView/ShareViewService.ts index 87b68956e..aa86f0339 100644 --- a/src/Add-on/ShareView/ShareViewService.ts +++ b/src/Add-on/ShareView/ShareViewService.ts @@ -307,7 +307,7 @@ export interface ICabinetItemData export class ShareService { _CabinetList: CabinetInfo[] = []; - _CabinetDict: { [key: string]: Entity[]; } = {}; + _CabinetDict: { [key: string]: Set; } = {}; _CabinetFormatData: ICabinetFormatData; get CabinetFormatData() { @@ -335,15 +335,38 @@ export class ShareService } let cabinetInfo = this.GetCabinetInfo(entity); let key = this.GetEntityCabinetKey(cabinetInfo); - this._CabinetDict[key] = this._CabinetDict[key] || []; - this._CabinetDict[key].push(entity); + this._CabinetDict[key] = this._CabinetDict[key] || new Set(); + this._CabinetDict[key].add(entity); + if (entity instanceof Board) + { + //层板钉 + for (let layId of entity.LayerNails) + { + if (layId && !layId.IsErase) + this._CabinetDict[key].add(layId.Object as Entity); + } + + // 排钻 + for (let [, drillIds] of entity.DrillList) + { + for (let drillIdGroup of drillIds) + { + for (let drillId of drillIdGroup) + { + let drill = drillId?.Object; + if (drill && !drill.IsErase) + this._CabinetDict[key].add(drill as Entity); + } + } + } + } }); for (const key in this._CabinetDict) { if (Object.prototype.hasOwnProperty.call(this._CabinetDict, key)) { const cabinet = this._CabinetDict[key]; - this._CabinetList.push(this.GetCabinetInfo(cabinet[0])); + this._CabinetList.push(this.GetCabinetInfo([...cabinet][0])); // this.SetBoxVisible(this._BoxList.length - 1, false); } } @@ -402,10 +425,10 @@ export class ShareService // return this._BoxDict[key].filter(predicate); // } - GetCabinetEntities(cabinetIndex: number) + GetCabinetEntities(cabinetIndex: number): Entity[] { let key = this.GetEntityCabinetKey(this.CabinetList[cabinetIndex]); - return this._CabinetDict[key]; + return [...this._CabinetDict[key]]; } //房名+柜名得到key diff --git a/src/Add-on/ShareView/ShareViewStore.ts b/src/Add-on/ShareView/ShareViewStore.ts index 415d281a2..345d88886 100644 --- a/src/Add-on/ShareView/ShareViewStore.ts +++ b/src/Add-on/ShareView/ShareViewStore.ts @@ -21,6 +21,7 @@ interface IOperations showCustomNumber: boolean; showDimension: boolean; isDoorOpen: boolean; + showCylinderHole: boolean; } export class ShareViewStore extends Singleton implements IConfigStore @@ -73,5 +74,6 @@ export class ShareViewStore extends Singleton implements IConfigStore showCustomNumber: false, // 是否显示板编号 showDimension: false, // 是否显示标注 isDoorOpen: false, // 是否门是开着 + showCylinderHole: true //显示/隐藏排钻 }; } diff --git a/src/Add-on/ShareView/ShareViewUtil.ts b/src/Add-on/ShareView/ShareViewUtil.ts index f37299e3b..6ce282b08 100644 --- a/src/Add-on/ShareView/ShareViewUtil.ts +++ b/src/Add-on/ShareView/ShareViewUtil.ts @@ -3,6 +3,7 @@ import { Object3D, Vector3 } from "three"; import { app } from "../../ApplicationServices/Application"; import { CommandNames } from "../../Common/CommandNames"; import { CylinderHole } from "../../DatabaseServices/3DSolid/CylinderHole"; +import { Hole } from "../../DatabaseServices/3DSolid/Hole"; import { AlignedDimension } from "../../DatabaseServices/Dimension/AlignedDimension"; import { Board } from "../../DatabaseServices/Entity/Board"; import { Entity } from "../../DatabaseServices/Entity/Entity"; @@ -41,7 +42,7 @@ export function ForbiddenToaster(action: () => Promise | void) } const explosionDic: { [key: string]: any[]; } = {}; -export async function ExplosionView(index: number, distance: number) +export function ExplosionView(index: number, distance: number) { let key = `${index}_${ShareViewStore.GetInstance().viewUploadProps.VisualStyle}`; let ents = shareViewApp.BoxCtrl.GetCabinetEntities(index); @@ -92,6 +93,15 @@ export async function ExplosionView(index: number, distance: number) shareViewApp.Editor.UpdateScreen(); } +export function ChangeCylinderHoleVisible(index: number, visible: boolean) +{ + for (let ent of shareViewApp.BoxCtrl.GetCabinetEntities(index)) + { + if (ent instanceof Hole && !ent.IsErase) + ent.Visible = !visible; + } +} + // 重置视图 export function resetBoxView() { diff --git a/src/Add-on/ShareView/components/HideComponentsMenu/index.tsx b/src/Add-on/ShareView/components/HideComponentsMenu/index.tsx index c23412f71..7f799ae3c 100644 --- a/src/Add-on/ShareView/components/HideComponentsMenu/index.tsx +++ b/src/Add-on/ShareView/components/HideComponentsMenu/index.tsx @@ -9,6 +9,8 @@ interface IProps doorOrDrawerShowOrHide: (isDoor: boolean) => void; /** 爆炸图 */ changeExplosion: () => void; + /** 显示隐藏 排钻 */ + changeCylinderHoleVisible: () => void; } const HideComponentsMenu: React.FC = (props) => @@ -59,6 +61,11 @@ const HideComponentsMenu: React.FC = (props) => props.changeExplosion(); }} >{shareViewStore.operations.showExplosion ? '聚合图' : '爆炸图'} +
+ { + props.changeCylinderHoleVisible(); + }}>{shareViewStore.operations.showCylinderHole ? '隐藏' : '显示'}排钻
{ diff --git a/src/Add-on/ShareView/components/ShareViewUI.tsx b/src/Add-on/ShareView/components/ShareViewUI.tsx index def34fbe8..b01fb12ae 100644 --- a/src/Add-on/ShareView/components/ShareViewUI.tsx +++ b/src/Add-on/ShareView/components/ShareViewUI.tsx @@ -1,16 +1,15 @@ import { Observer, observer, Provider } from "mobx-react"; import React, { useEffect, useRef, useState } from "react"; import { CommandNames } from "../../../Common/CommandNames"; -import { Hole } from "../../../DatabaseServices/3DSolid/Hole"; import { commandMachine } from "../../../Editor/CommandMachine"; import { userConfig } from "../../../Editor/UserConfig"; import { RenderType } from "../../../GraphicsSystem/RenderType"; -import { IsDoor, IsDrawer, IsHandle } from "../../HideSelect/HideSelectUtils"; +import { IsDoor, IsDrawer } from "../../HideSelect/HideSelectUtils"; import { ViewStyleTypes } from "../ShareViewRules"; import { shareViewApp } from "../ShareViewService"; import { ShareViewStore } from "../ShareViewStore"; import "../ShareViewStyle.less"; -import { ChangeThemeColor, CreateBoxDim, DeleteBoxDim, ExplosionView, ForbiddenToaster, resetBoxView, SwitchDoorOrDrawer } from "../ShareViewUtil"; +import { ChangeCylinderHoleVisible, ChangeThemeColor, CreateBoxDim, DeleteBoxDim, ExplosionView, ForbiddenToaster, resetBoxView, SwitchDoorOrDrawer } from "../ShareViewUtil"; import BoardMessageWidget from "./BoardMessageWidget"; import CabinetBottomSheet from "./CabinetBottomSheet"; import HideComponentsMenu from "./HideComponentsMenu"; @@ -71,9 +70,7 @@ function ShareViewUI() { for (const el of shareViewStore.CurSelectCabinetIndexs) { - let list = shareViewApp.BoxCtrl.GetCabinetEntities(el) - .filter((ent) => IsDrawer(ent) || IsDoor(ent) || IsHandle(ent) || (ent instanceof Hole && ent.ColorIndex !== 4)); - list = list.filter(ent => (IsDoor(ent) && ent.Template) || (IsDrawer(ent)) || (ent instanceof Hole)); + let list = shareViewApp.BoxCtrl.GetCabinetEntities(el).filter(ent => (IsDoor(ent) && ent.Template) || (IsDrawer(ent))); if (list.length) return true; } return false; @@ -273,6 +270,7 @@ function ShareViewUI() async function resetAll() { shareViewStore.SelectedBoard = null; + shareViewStore.operations.showCylinderHole = true; if (shareViewStore.operations.showDimension) { await DeleteBoxDim(); @@ -294,23 +292,23 @@ function ShareViewUI() } /** 爆炸图 距离 */ - const explosionDistance = 600; + const explosionDistance = 800; /** 还原爆炸图 */ - const resetExplosionView = async () => + const resetExplosionView = () => { if (shareViewStore.operations.showExplosion) { - await changeExplosionView(explosionDistance); + changeExplosionView(explosionDistance); shareViewStore.operations.showExplosion = !shareViewStore.operations.showExplosion; } }; /** 打开/关闭 爆炸图 */ - async function changeExplosionView(distance: number) + function changeExplosionView(distance: number) { for (const i of shareViewStore.CurSelectCabinetIndexs) { - await ExplosionView(i, distance); + ExplosionView(i, distance); } } @@ -321,15 +319,24 @@ function ShareViewUI() await closeDoor(); if (shareViewStore.operations.showExplosion) { - await changeExplosionView(explosionDistance); + changeExplosionView(explosionDistance); } else { - await changeExplosionView(-explosionDistance); + changeExplosionView(-explosionDistance); } shareViewStore.operations.showExplosion = !shareViewStore.operations.showExplosion; setLoading(false); }; + /** 显示/隐藏 排钻 */ + function changeCylinderHoleVisible() + { + for (const i of shareViewStore.CurSelectCabinetIndexs) + ChangeCylinderHoleVisible(i, shareViewStore.operations.showCylinderHole); + shareViewApp.Editor.UpdateScreen(); + shareViewStore.operations.showCylinderHole = !shareViewStore.operations.showCylinderHole; + } + return ( @@ -365,6 +372,7 @@ function ShareViewUI()
还原