From d45b952f5dbd6b7d770e1c6edcd43b849ae26e55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=AF=97=E6=B4=A5?= <2723065175@qq.com> Date: Thu, 20 Jan 2022 03:27:04 +0000 Subject: [PATCH] =?UTF-8?q?!1754=20=E4=BF=AE=E5=A4=8D:=E7=81=AF=E5=85=89?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E7=95=8C=E9=9D=A2=E5=93=8D=E5=BA=94=E5=A4=96?= =?UTF-8?q?=E9=83=A8=E5=91=BD=E4=BB=A4=E4=BF=AE=E6=94=B9=E7=9A=84=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/UI/Components/Board/BoardOptionModal.tsx | 62 ++++++++++++------- src/UI/Components/Modal/CadModal.tsx | 8 +++ src/UI/Store/RightPanelStore/LightStore.ts | 4 +- .../Store/RightPanelStore/SpotLightModel.tsx | 2 + 4 files changed, 50 insertions(+), 26 deletions(-) diff --git a/src/UI/Components/Board/BoardOptionModal.tsx b/src/UI/Components/Board/BoardOptionModal.tsx index 176b24dac..e760b3beb 100644 --- a/src/UI/Components/Board/BoardOptionModal.tsx +++ b/src/UI/Components/Board/BoardOptionModal.tsx @@ -1,16 +1,16 @@ import { Button, Classes, HTMLSelect } from '@blueprintjs/core'; import { observer } from 'mobx-react'; import * as React from 'react'; +import { begin } from 'xaop'; import { app } from '../../../ApplicationServices/Application'; +import { EBoardKeyList } from '../../../Common/BoardKeyList'; +import { KeyBoard } from '../../../Common/KeyEnum'; import { Board } from '../../../DatabaseServices/Entity/Board'; import { CommonModal } from '../Modal/ModalContainer'; import { Notes } from './BoardCommon'; import { BoardConfigModal } from './BoardConfigModal'; import { BoardProcessModal } from './BoardProcessModal'; import { AddCommonBoardProps, ICommonOptionProps } from './CommonBoardOption'; -import { EBoardKeyList } from '../../../Common/BoardKeyList'; -import { begin } from 'xaop'; -import { KeyBoard } from '../../../Common/KeyEnum'; @observer class BoardOptionCom extends React.Component @@ -25,7 +25,9 @@ class BoardOptionCom extends React.Component { app.Editor.ModalManage.Destory(); }; - private event: Function; + //移除注入 + private removeFuncs: Function[] = []; + UNSAFE_componentWillMount() { for (let e of app.Database.ModelSpace.Entitys) @@ -37,31 +39,43 @@ class BoardOptionCom extends React.Component } componentDidMount() { - this.event = begin(app.Editor.ModalManage, app.Editor.ModalManage.OnKeyDown, (e: KeyboardEvent) => - { - if ("双击板件" !== app.Editor.ModalManage.CurrentModalKey) return; - let el = e.target as HTMLInputElement; - if (e.keyCode === KeyBoard.Enter || - (e.keyCode === KeyBoard.Space && - (el.nodeName !== "INPUT" || el.type !== "text" || !el.getAttribute('data-isNum')))) + this.removeFuncs.push( + begin(app.Editor.ModalManage, app.Editor.ModalManage.OnKeyDown, (e: KeyboardEvent) => { - this.props.handleComfirmOption(); - e.preventDefault(); - } - else if (e.keyCode === KeyBoard.Escape) + if ("双击板件" !== app.Editor.ModalManage.CurrentModalKey) return; + let el = e.target as HTMLInputElement; + if (e.keyCode === KeyBoard.Enter || + (e.keyCode === KeyBoard.Space && + (el.nodeName !== "INPUT" || el.type !== "text" || !el.getAttribute('data-isNum')))) + { + this.props.handleComfirmOption(); + e.preventDefault(); + } + else if (e.keyCode === KeyBoard.Escape) + { + this.handClose(); + app.Editor.ModalManage.stopKeyDownEvent = true; + } + e.stopPropagation(); + return true; + }), + app.CommandReactor.OnCommandEnd((cmdName, changeObjects, createObjects) => { - this.handClose(); - app.Editor.ModalManage.stopKeyDownEvent = true; - } - e.stopPropagation(); - return true; - }); + for (let o of changeObjects) + { + if (o.Id.Index === this.props._CurrentBoard.get()?.Id?.Index) + { + this.props.setBrConfig(); + break; + } + } + })); } componentWillUnmount() { - if (this.event) - this.event(); - this.event = null; + for (let f of this.removeFuncs) + f(); + this.removeFuncs.length = 0; } render() { diff --git a/src/UI/Components/Modal/CadModal.tsx b/src/UI/Components/Modal/CadModal.tsx index 742b17c69..913556dc3 100644 --- a/src/UI/Components/Modal/CadModal.tsx +++ b/src/UI/Components/Modal/CadModal.tsx @@ -7,6 +7,7 @@ import { ZINDEX } from "../../../Common/ZIndex"; import { CommandWrap } from "../../../Editor/CommandMachine"; import { equaln } from '../../../Geometry/GeUtils'; import { AnyObject } from '../../Store/BoardInterface'; +import { LightStore } from "../../Store/RightPanelStore/LightStore"; import { GetCompoentObjectIdString } from '../ComponentObjectId'; import { CommandState } from './../../../Editor/CommandState'; import { ModalPosition } from "./ModalInterface"; @@ -35,6 +36,7 @@ export class CADModal private _canForceMax = false; /**锁定后不能关闭和最大化 */ IsLock = false; + IsLightModal = false; constructor(_rootContainer: HTMLElement, private _rootModal?: CADModal) { this.container = document.createElement("div"); @@ -74,6 +76,12 @@ export class CADModal this.rndDiv.style.minHeight = "220px"; } } + //灯光面板最小化响应外部修改的数 + if (this.IsLightModal) + { + let lightStore = LightStore.GetInstance(); + lightStore.InitLightData(lightStore.currentSelectEnt); + } } } }; diff --git a/src/UI/Store/RightPanelStore/LightStore.ts b/src/UI/Store/RightPanelStore/LightStore.ts index c79fc045e..1c62f9a70 100644 --- a/src/UI/Store/RightPanelStore/LightStore.ts +++ b/src/UI/Store/RightPanelStore/LightStore.ts @@ -192,8 +192,8 @@ export class LightStore implements IConfigStore this.title = "矩形光"; this.pars.push(["Intensity", "强度"], ["IndirectLightingIntensity", "反弹"], ["SpecularScale", "高光"], ["Width", "宽度"], ["Height", "长度"], ["BarnDoorAngle", "挡板角度"], ["BarnDoorLength", "挡板长度"], ["AttenuationRadius", "衰减半径"]); Object.assign(newState, { - Height: light.Height.toString(), - Width: light.Width.toString(), + Height: FixedNotZero(light.Height, 2), + Width: FixedNotZero(light.Width, 2), BarnDoorAngle: light.BarnDoorAngle.toString(), BarnDoorLength: light.BarnDoorLength.toString(), AttenuationRadius: light.AttenuationRadius.toString(), diff --git a/src/UI/Store/RightPanelStore/SpotLightModel.tsx b/src/UI/Store/RightPanelStore/SpotLightModel.tsx index a24d4b17e..58367937a 100644 --- a/src/UI/Store/RightPanelStore/SpotLightModel.tsx +++ b/src/UI/Store/RightPanelStore/SpotLightModel.tsx @@ -48,9 +48,11 @@ export class SpotLightModel extends React.Component<{ store: LightStore; configS e.stopPropagation(); }) ); + setTimeout(() => { app.Editor.ModalManage.CurrentModal.IsLightModal = true; }, 0); } componentWillUnmount() { + app.Editor.ModalManage.CurrentModal.IsLightModal = false; for (let f of this.removeFuncs) f(); this.removeFuncs.length = 0;