From eb1e32d9469d7d6ad0a9f350d916d519845bd42e Mon Sep 17 00:00:00 2001 From: ChenX Date: Sat, 24 Feb 2018 17:30:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E5=85=B3=E9=94=AE=E5=AD=97=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/InputState.ts | 2 +- src/Editor/GetEntityServices.ts | 6 +++++- src/Editor/GetPointServices.ts | 20 ++++---------------- src/Editor/InitKeyword.ts | 17 +++++++++++++++++ 4 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 src/Editor/InitKeyword.ts diff --git a/src/Common/InputState.ts b/src/Common/InputState.ts index 1ece9fb19..8de596171 100644 --- a/src/Common/InputState.ts +++ b/src/Common/InputState.ts @@ -28,7 +28,7 @@ export interface KeyWord msg: string; key: string; } -interface GetAnyPrompt +export interface GetAnyPrompt { Msg?: string KeyWordList?: KeyWord[] diff --git a/src/Editor/GetEntityServices.ts b/src/Editor/GetEntityServices.ts index cc510dbed..4299fdb25 100644 --- a/src/Editor/GetEntityServices.ts +++ b/src/Editor/GetEntityServices.ts @@ -3,13 +3,14 @@ import { end } from 'xaop'; import { GetEntityPrompt, InputState } from '../Common/InputState'; import { KeyBoard, MouseKey } from '../Common/KeyEnum'; import { Entity } from '../DatabaseServices/Entity'; +import { Viewer } from '../GraphicsSystem/Viewer'; import { DynamicInputManage } from '../UI/DynamicPrompt/DynamicInputManage'; import { PromptBlock } from '../UI/DynamicPrompt/PromptBlock'; import { Editor, EditorService } from './Editor'; +import { InitKeyWord } from './InitKeyword'; import { MouseControls } from './MouseControls'; import { PointPick } from './PointPick'; import { PromptEntityResult, PromptStatus } from './PromptResult'; -import { Viewer } from '../GraphicsSystem/Viewer'; /** * @@ -59,6 +60,9 @@ export class GetEntityServices implements EditorService ) ) } + + this.removeCalls.push(InitKeyWord(prompt)); + this.removeCalls.push( end(this.m_Editor.m_KeyCtrl, this.m_Editor.m_KeyCtrl.OnKeyDown, (e: KeyboardEvent) => { diff --git a/src/Editor/GetPointServices.ts b/src/Editor/GetPointServices.ts index da6b3de3f..7abd2a1d2 100644 --- a/src/Editor/GetPointServices.ts +++ b/src/Editor/GetPointServices.ts @@ -1,5 +1,5 @@ -import { Vector3 } from 'three'; import * as THREE from 'three'; +import { Vector3 } from 'three'; import * as xaop from 'xaop'; import { app } from '../ApplicationServices/Application'; @@ -9,9 +9,10 @@ import { midPoint } from '../Geometry/GeUtils'; import { DynamicInputManage } from '../UI/DynamicPrompt/DynamicInputManage'; import { GetDistancePromptBlock } from '../UI/DynamicPrompt/GetDistancePromptBlock'; import { GetPoint2PromptBlock, GetPointPromptBlock } from '../UI/DynamicPrompt/GetPointPromptBlock'; +import { EditorService } from './Editor'; +import { InitKeyWord } from './InitKeyword'; import { PromptDistendResult, PromptPointResult, PromptStatus } from './PromptResult'; import { SnapServices } from './SnapServices'; -import { EditorService } from './Editor'; /** * 为拾取点提供服务,提供一个类以供Editor引用. @@ -48,7 +49,7 @@ export class GetPointServices implements EditorService //动态输入框. this.initDynInput(prompt); //设置关键字 - this.initKeyword(prompt); + this.removeCalls.push(InitKeyWord(prompt)); //处理用户输入 this.initHandleInput(prompt); //如果有基点,绘制橡皮筋 @@ -217,19 +218,6 @@ export class GetPointServices implements EditorService } } - private initKeyword(prompt: GetPointPrompt) - { - if (prompt.KeyWordList) - { - app.m_Editor.m_CommandStore.keyWordList.length = 0; - app.m_Editor.m_CommandStore.keyWordList.push(...prompt.KeyWordList); - this.removeCalls.push(() => - { - app.m_Editor.m_CommandStore.keyWordList.length = 0; - }); - } - } - //初始化动态输入框,包括处理事件 protected initDynInput(prompt: GetPointPrompt) { diff --git a/src/Editor/InitKeyword.ts b/src/Editor/InitKeyword.ts new file mode 100644 index 000000000..626a1f04e --- /dev/null +++ b/src/Editor/InitKeyword.ts @@ -0,0 +1,17 @@ +import { app } from '../ApplicationServices/Application'; +import { GetAnyPrompt } from '../Common/InputState'; + +function ClearKeyWord() +{ + app.m_Editor.m_CommandStore.keyWordList.length = 0; +} + +export function InitKeyWord(prompt: GetAnyPrompt) +{ + if (prompt.KeyWordList) + { + app.m_Editor.m_CommandStore.keyWordList.length = 0; + app.m_Editor.m_CommandStore.keyWordList.push(...prompt.KeyWordList); + } + return ClearKeyWord; +}