From e603d4d253bb930273a243d92a61c6e5920ac346 Mon Sep 17 00:00:00 2001 From: ChenX Date: Wed, 10 Jan 2018 13:47:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BD=93=E5=89=8D=E7=82=B9?= =?UTF-8?q?=E7=9A=84=E6=9B=B4=E6=96=B0=E6=B3=A8=E5=85=A5=E5=87=BD=E6=95=B0?= =?UTF-8?q?,=E7=8E=B0=E5=9C=A8=E5=8F=AA=E4=BC=9A=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=E5=BD=93=E5=89=8D=E7=82=B9=E7=9A=84=E6=8D=95?= =?UTF-8?q?=E6=8D=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Editor/GetPointServices.ts | 37 ++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/Editor/GetPointServices.ts b/src/Editor/GetPointServices.ts index c99b788c5..7be62b2e7 100644 --- a/src/Editor/GetPointServices.ts +++ b/src/Editor/GetPointServices.ts @@ -1,13 +1,14 @@ import * as THREE from 'three'; +import { Vector3 } from 'three'; import * as xaop from 'xaop'; import { app } from '../ApplicationServices/Application'; import { GetPointPrompt, InputState } from '../Common/InputState'; -import { MouseKey, KeyBoard } from '../Common/KeyEnum'; -import { polar, equaln, fixAngle, Intersect } from '../Geometry/GeUtils'; -import { PromptPointResult, PromptStatus } from './PromptResult'; -import { GetPointPromptBlock } from '../UI/DynamicPrompt/GetPointPromptBlock'; +import { KeyBoard, MouseKey } from '../Common/KeyEnum'; +import { equaln, fixAngle, Intersect, polar } from '../Geometry/GeUtils'; import { DynamicInputManage } from '../UI/DynamicPrompt/DynamicInputManage'; +import { GetPointPromptBlock } from '../UI/DynamicPrompt/GetPointPromptBlock'; +import { PromptPointResult, PromptStatus } from './PromptResult'; /** * 为拾取点提供服务,提供一个类以供Editor引用. @@ -27,6 +28,7 @@ export class GetPointServices this.initAppState(); //点捕捉 this.initPtSnap(); + this.initUpdateCurPoint(); //消息显示. this.initPrompt(prompt); //动态输入框. @@ -49,6 +51,20 @@ export class GetPointServices }); } + //更新当前点事件,统一使用该方法注入其他服务的更新(aop在此方法中注入) + UpdateCurPointEvent(pt: Vector3) + { + } + + //初始化更新当前点的事件 + private initUpdateCurPoint() + { + xaop.end(app.m_Editor.m_MouseCtrl, + app.m_Editor.m_MouseCtrl.onMouseMove, + () => this.UpdateCurPointEvent(this.GetNowPoint()) + ) + } + private initHandleKeyDown() { this.removeCalls.push(xaop.begin(app.m_Editor.m_KeyCtrl, app.m_Editor.m_KeyCtrl.OnKeyDown, (e: KeyboardEvent) => @@ -73,9 +89,8 @@ export class GetPointServices { if (prompt.Callback) { - this.removeCalls.push(xaop.end(app.m_Editor.m_MouseCtrl, app.m_Editor.m_MouseCtrl.onMouseMove, () => + this.removeCalls.push(xaop.end(this, this.UpdateCurPointEvent, (p: Vector3) => { - let p = this.GetNowPoint(); prompt.Callback(p); app.m_Editor.UpdateScreen(); })); @@ -99,9 +114,9 @@ export class GetPointServices this.removeCalls.push(() => { preView.Scene.remove(line); - }, xaop.end(app.m_Editor.m_MouseCtrl, app.m_Editor.m_MouseCtrl.onMouseMove, () => + }, xaop.end(this, this.UpdateCurPointEvent, (p: Vector3) => { - let endP = this.GetNowPoint(); + let endP = p.clone(); app.m_Viewer.WorldToScreen(endP); preView.ScreenPointToViewerPoint(endP); let startP = prompt.BasePoint.clone(); @@ -193,10 +208,10 @@ export class GetPointServices { dynPrompt.Destroy(); }); - this.removeCalls.push(xaop.end(app.m_Editor.m_MouseCtrl, app.m_Editor.m_MouseCtrl.onMouseMove, () => + this.removeCalls.push(xaop.end(this, this.UpdateCurPointEvent, (p) => { dynPrompt.SetPostion(app.m_Editor.m_MouseCtrl.m_CurMousePointVCS); - dynPrompt.Value = this.GetNowPoint(); + dynPrompt.Value = p; })); //处理动态输入 let dynManage = DynamicInputManage.GetManage(); @@ -502,7 +517,7 @@ export class GetPointServices } } testSnap(); - let removeCall = xaop.end(app.m_Editor.m_MouseCtrl, app.m_Editor.m_MouseCtrl.onMouseMove, testSnap); + let removeCall = xaop.end(this, this.UpdateCurPointEvent, testSnap); this.removeCalls.push(() => { removeCall();