!2339 开发:分享图纸中排钻增加爆炸图效果,和显示隐藏排钻开关

Merge pull request !2339 from 林三/share_view_cylinderHole
pull/2380/MERGE
林三 1 year ago committed by ChenX
parent 2e45102590
commit d622f8633d

@ -307,7 +307,7 @@ export interface ICabinetItemData
export class ShareService
{
_CabinetList: CabinetInfo[] = [];
_CabinetDict: { [key: string]: Entity[]; } = {};
_CabinetDict: { [key: string]: Set<Entity>; } = {};
_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

@ -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 //显示/隐藏排钻
};
}

@ -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> | 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()
{

@ -9,6 +9,8 @@ interface IProps
doorOrDrawerShowOrHide: (isDoor: boolean) => void;
/** 爆炸图 */
changeExplosion: () => void;
/** 显示隐藏 排钻 */
changeCylinderHoleVisible: () => void;
}
const HideComponentsMenu: React.FC<IProps> = (props) =>
@ -59,6 +61,11 @@ const HideComponentsMenu: React.FC<IProps> = (props) =>
props.changeExplosion();
}}
>{shareViewStore.operations.showExplosion ? '聚合图' : '爆炸图'}</div>
<div
onClick={() =>
{
props.changeCylinderHoleVisible();
}}>{shareViewStore.operations.showCylinderHole ? '隐藏' : '显示'}</div>
<div
onClick={() =>
{

@ -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 (
<React.Fragment>
<Provider store={ShareViewStore}>
@ -365,6 +372,7 @@ function ShareViewUI()
<HideComponentsMenu
doorOrDrawerShowOrHide={doorOrDrawerShowOrHide}
changeExplosion={changeExplosion}
changeCylinderHoleVisible={changeCylinderHoleVisible}
/>
<div onClick={resetAll}></div>
</div>

Loading…
Cancel
Save