增加ed.GetAngle方法

pull/106/MERGE
ChenX 6 years ago
parent 4490916dfc
commit 433da0c6b9

@ -28,7 +28,7 @@ export class DrawText implements Command
if (equaln(height, 0) || !height) return;
hRes = await app.m_Editor.GetDistance({
hRes = await app.m_Editor.GetAngle({
Msg: "指定文字旋转角度",
BasePoint: startPoint,
Default: 0

@ -116,7 +116,7 @@ export class Command_Offset implements Command
Msg: "指定通过点或输入偏移距离:",
KeyWordList: [{ key: "D", msg: isMulti ? "单个" : "多个" }],
BasePoint: basePoint,
CalcDistance: (p: Vector3) =>
CalcDistance: (baseP, p: Vector3) =>
{
basePoint.copy(cu.GetClosestPointTo(p, false));
dir = GetPointAtCurveDir(cu, p) ? 1 : -1;

@ -39,7 +39,7 @@ export class Command_Scale implements Command
en.ApplyMatrix(scMat);
}
},
CalcDistance: (p) => p.distanceTo(ptRes.Value) / maxSize
CalcDistance: (pBase, p) => p.distanceTo(pBase) / maxSize
});
Jig.End();

@ -58,7 +58,7 @@ export interface GetDistendPrompt extends GetAnyPrompt
{
BasePoint?: Vector3;
Callback?: (dist: number, pt?: Vector3) => void;
CalcDistance?: (pt: Vector3) => number;
CalcDistance?: (ptBase: Vector3, pt: Vector3) => number;
Default?: number;
}

@ -17,6 +17,8 @@ import { SelectControls } from './SelectControls';
import { SnapDragServices } from './SnapDragServices';
import { TransformServicess } from './TranstrolControl/TransformServices';
import { UCSServices } from './UCSServices';
import { angle } from '../Geometry/GeUtils';
import { Vector3, Math } from 'three';
//用户交互编辑工具
@ -100,6 +102,18 @@ export class Editor
{
return this.m_GetDistanceServices.Start(prompt);
}
GetAngle(prompt?: GetDistendPrompt): Promise<PromptDistendResult>
{
if (prompt.Msg === undefined)
prompt.Msg = "请点取角度";
if (prompt.CalcDistance === undefined)
prompt.CalcDistance = (pbase: Vector3, p: Vector3) =>
{
let v = p.clone().sub(pbase);
return Math.radToDeg(angle(v));
}
return this.m_GetDistanceServices.Start(prompt);
}
GetKeyWords(prompt: GetKeyWordPrommpt): Promise<PromptResult>
{
return this.m_KeywordsServices.Start(prompt);

@ -67,7 +67,7 @@ export class GetDistanceServices
dynInput.ValuePostion = midp;
if (prompt.CalcDistance)
dynInput.Value = prompt.CalcDistance(p);
dynInput.Value = prompt.CalcDistance(p1, p);
else
dynInput.Value = p1.distanceTo(p);
@ -77,7 +77,7 @@ export class GetDistanceServices
});
if (ptRes.Status === PromptStatus.OK)
if (prompt.CalcDistance)
this._return(prompt.CalcDistance(ptRes.Value))
this._return(prompt.CalcDistance(p1, ptRes.Value))
else
this._return(p1.distanceTo(ptRes.Value));
else if (ptRes.Status === PromptStatus.Keyword)

Loading…
Cancel
Save