From 07920fca40368ddd847c2f7557a55eee58249c38 Mon Sep 17 00:00:00 2001 From: ZoeLeeFZ Date: Thu, 30 Apr 2020 14:35:27 +0800 Subject: [PATCH] =?UTF-8?q?!985=20=E4=BC=98=E5=8C=96:=E6=A8=A1=E6=80=81?= =?UTF-8?q?=E6=A1=86=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Add-on/DrawBoard/DrawBoardTool.ts | 57 +++++++++++++------------ src/Editor/UserConfig.ts | 1 - src/UI/Components/Modal/CadModal.tsx | 11 +++-- src/UI/Components/Modal/ModalsManage.ts | 23 +++++++++- src/UI/Store/BoardStore.ts | 2 +- 5 files changed, 59 insertions(+), 35 deletions(-) diff --git a/src/Add-on/DrawBoard/DrawBoardTool.ts b/src/Add-on/DrawBoard/DrawBoardTool.ts index e063b3f6b..a007aa3a2 100644 --- a/src/Add-on/DrawBoard/DrawBoardTool.ts +++ b/src/Add-on/DrawBoard/DrawBoardTool.ts @@ -37,52 +37,53 @@ export abstract class DrawBoardTool implements Command BoardModal, { store: this.store, type: this.modalType }); - app.Editor.ModalManage.SetCallback(async () => - { - await this.SelectAndBuildBoard(); - if (this.store.autoCutOption.isAutoCut) - AutoCutting(this.store.autoCutOption.isRelevance); - }); + app.Editor.ModalManage.SetCallback(this.Callback); } + private Callback = async () => + { + await this.SelectAndBuildBoard(); + if (this.store.autoCutOption.isAutoCut) + AutoCutting(this.store.autoCutOption.isRelevance); + }; private async SelectAndBuildBoard() { //原来禁用捕捉开启状态 let oldSnapState = app.Editor.GetPointServices.snapServices.Disabled; app.Editor.GetPointServices.snapServices.Disabled = true; - while (true) + let selectSpace = new PointSelectSpaceClamp(); + await selectSpace.Select(() => { - let selectSpace = new PointSelectSpaceClamp(); - await selectSpace.Select(() => - { - this.space = selectSpace.SpaceParse; - if (selectSpace.ParseOK) - this.buildBoard(false); - }); - if (selectSpace.GetPointRes.Status === PromptStatus.None) + this.space = selectSpace.SpaceParse; + if (selectSpace.ParseOK) + this.buildBoard(false); + }); + if (selectSpace.GetPointRes.Status === PromptStatus.None) + { + //命令执行完在弹出 + setTimeout(() => { app.Editor.ModalManage.RenderModeless( BoardModal, { store: this.store, type: this.modalType }, { position: ModalPosition.Old }); - break; - } + app.Editor.ModalManage.SetCallback(this.Callback); + }, 0); + return; + } - if (!selectSpace.ParseOK) - break; - this.space = selectSpace.SpaceParse; - //用周围板件加工数据 - if (this.store.UseBoardProcessOption && this.space.Boards.length > 0) - this.store.GetBoardProcessOption(this.space.Boards[0]); + if (!selectSpace.ParseOK) + return; + this.space = selectSpace.SpaceParse; + //用周围板件加工数据 + if (this.store.UseBoardProcessOption && this.space.Boards.length > 0) + this.store.GetBoardProcessOption(this.space.Boards[0]); - await this.buildBoard(); + await this.buildBoard(); - app.Editor.UpdateScreen(); + app.Editor.UpdateScreen(); - if (!userConfig.isContinuousDraw) - break; - } //恢复原先状态 app.Editor.GetPointServices.snapServices.Disabled = oldSnapState; } diff --git a/src/Editor/UserConfig.ts b/src/Editor/UserConfig.ts index dfe4f9e18..d694bd7f0 100644 --- a/src/Editor/UserConfig.ts +++ b/src/Editor/UserConfig.ts @@ -31,7 +31,6 @@ export class UserConfig implements IConfigStore height: 2440, width: 1220, }; - isContinuousDraw = false; //是否连续绘制层板立板背板... @observable private _drillConfigs: Map = new Map(); @observable openDrillingReactor = true; @observable openAutoCuttingReactor = true; diff --git a/src/UI/Components/Modal/CadModal.tsx b/src/UI/Components/Modal/CadModal.tsx index 35d7c1458..a3cfe7fe3 100644 --- a/src/UI/Components/Modal/CadModal.tsx +++ b/src/UI/Components/Modal/CadModal.tsx @@ -8,6 +8,7 @@ import { CommandState } from './../../../Editor/CommandState'; import { ModalPosition } from "./ModalInterface"; import { IModalProps } from "./ModalsManage"; import { equaln } from '../../../Geometry/GeUtils'; +import { AnyObject } from '../../Store/BoardInterface'; export const DATA_KEY = "data-modalkey"; @@ -29,6 +30,8 @@ export class CADModal private minimizeEl: HTMLElement = null; private _mask: HTMLDivElement; private _canForceMax = false; + /**锁定后不能关闭和最大化 */ + IsLock = false; constructor(_rootContainer: HTMLElement, private _rootModal?: CADModal) { this.container = document.createElement("div"); @@ -44,7 +47,7 @@ export class CADModal } private onFocus = (e: FocusEvent) => { - if ((!this.IsModal && !CommandState.CommandIng) || this._canForceMax) + if ((!this.IsLock && !this.IsModal && !CommandState.CommandIng) || this._canForceMax) { let dialog = this.container.getElementsByClassName('bp3-dialog')[0] as HTMLElement; if (dialog && this.minimizeEl) @@ -71,7 +74,7 @@ export class CADModal } } }; - static Create(rootContainer: HTMLElement, Component: any, props: { [key: string]: any; }, option: IModalProps = {}) + static Create(rootContainer: HTMLElement, Component: React.ComponentType, props: T, option: IModalProps = {}) { let modal = new CADModal(option.root ? option.root.container : rootContainer, option.root); modal.Render(Component, props, option); @@ -79,7 +82,7 @@ export class CADModal option.root.ShowMasking(); return modal; } - Render(Component: any, props: { [key: string]: any; }, option: IModalProps = {}) + Render(Component: React.ComponentType, props: T, option: IModalProps = {}) { const { canMinimize = true, resizable = false, position = ModalPosition.Center, isModal = false, isMax = false, canForceMax = false } = option; let key = (props?.type) ? props.type : (Component.name || Component.displayName); @@ -174,7 +177,7 @@ export class CADModal this.dragHandleEl.style.top = this.dhTopEnd + delta.height + "px"; } } - Update(Component: any, props: { [key: string]: any; }, option: IModalProps = {}) + Update(Component: React.ComponentType, props: T, option: IModalProps = {}) { ReactDOM.unmountComponentAtNode(this.container); this.minimizeEl = null; diff --git a/src/UI/Components/Modal/ModalsManage.ts b/src/UI/Components/Modal/ModalsManage.ts index 44af4dfd2..a88f9cd74 100644 --- a/src/UI/Components/Modal/ModalsManage.ts +++ b/src/UI/Components/Modal/ModalsManage.ts @@ -77,6 +77,17 @@ export class ModalManage { if (this.IsModal) this.CurrentModal?.Focus(); + else if (this.CurrentModal.IsLock) + { + for (let [, modal] of this._List) + { + if (modal.IsModal) + { + modal.Focus(); + break; + } + } + } else this.MinAll(); }); @@ -140,6 +151,8 @@ export class ModalManage } RenderModal(Component: React.ComponentType, props?: T, option: IModalProps = {}) { + for (let [k, modal] of this._List) + modal.IsLock = true; this.RenderModeless(Component, props, { ...option, isModal: true }); } async EndExecingCmd() @@ -190,7 +203,8 @@ export class ModalManage { for (let [, modal] of this._List) { - modal.Minimize(); + if (!modal.IsModal) + modal.Minimize(); } } ChangeFoucus() @@ -210,6 +224,9 @@ export class ModalManage { this.CurrentModal?.Destory(); app.Editor.MaskManage.Clear(); + if (this.IsModal) + for (let [, modal] of this._List) + modal.IsLock = false; } private Clear() { @@ -223,11 +240,15 @@ export class ModalManage } Destory() { + if (this.CurrentModal.IsLock) + return; this.Close(); this.Clear(); } async DestoryAndExec(data: IModalResult = { Status: ModalState.Ok }, isClose = true) { + if (this.CurrentModal.IsLock) + return; if (isClose) this.Close(); if (this.m_PromisRes) diff --git a/src/UI/Store/BoardStore.ts b/src/UI/Store/BoardStore.ts index fcf70fe89..51f4f4af0 100644 --- a/src/UI/Store/BoardStore.ts +++ b/src/UI/Store/BoardStore.ts @@ -36,7 +36,7 @@ export class BoardStore extends Singleton implements IConfigStore EditorTemplate: TemplateRecord; m_Option: IBaseOption; protected m_UiOption; - title: string; + readonly title: string; @observable UseBoardProcessOption = true; @observable m_BoardProcessOption: BoardProcessOption = { ...DefaultBoardProcessOption }; @observable remarks: [string, string][] = Array.from({ length: 12 }, () => ["", ""]);