|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
import { Vector3 } from 'three';
|
|
|
|
|
import { app } from '../ApplicationServices/Application';
|
|
|
|
|
import { GetPointAtCurveDir } from '../Common/CurveUtils';
|
|
|
|
|
import { Log } from '../Common/Log';
|
|
|
|
|
import { Curve } from '../DatabaseServices/Entity/Curve';
|
|
|
|
|
import { Polyline } from '../DatabaseServices/Entity/Polyline';
|
|
|
|
|
import { Command } from '../Editor/CommandMachine';
|
|
|
|
@ -12,11 +13,18 @@ const OffsetKey = "offset";
|
|
|
|
|
//获取偏移距离的返回状态.
|
|
|
|
|
type GetOffsetStatus = { Status: PromptStatus, offsetDist?: number; };
|
|
|
|
|
|
|
|
|
|
enum OffsetType
|
|
|
|
|
{
|
|
|
|
|
Direction = 0,
|
|
|
|
|
Dynamic = 1,
|
|
|
|
|
Continuous = 2,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//曲线偏移
|
|
|
|
|
export class Command_Offset implements Command
|
|
|
|
|
{
|
|
|
|
|
offsetDis: number = 1;
|
|
|
|
|
isDyn = false;
|
|
|
|
|
type = OffsetType.Direction;
|
|
|
|
|
constructor()
|
|
|
|
|
{
|
|
|
|
|
let o = window.localStorage.getItem(OffsetKey);
|
|
|
|
@ -25,17 +33,22 @@ export class Command_Offset implements Command
|
|
|
|
|
}
|
|
|
|
|
async exec()
|
|
|
|
|
{
|
|
|
|
|
this.isDyn = false;
|
|
|
|
|
this.type = OffsetType.Direction;
|
|
|
|
|
let disRes = await app.Editor.GetDistance({
|
|
|
|
|
Msg: "指定偏移距离:",
|
|
|
|
|
KeyWordList: [{ msg: "通过:", key: "T" }],
|
|
|
|
|
KeyWordList: [{ msg: "通过(动态选点):", key: "T" }, { msg: "连续", key: "C" }],
|
|
|
|
|
Default: this.offsetDis
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (disRes.StringResult === "T")
|
|
|
|
|
this.isDyn = true;
|
|
|
|
|
this.type = OffsetType.Dynamic;
|
|
|
|
|
else if (disRes.StringResult === "C")
|
|
|
|
|
this.type = OffsetType.Continuous;
|
|
|
|
|
else if (disRes.Status === PromptStatus.OK)
|
|
|
|
|
{
|
|
|
|
|
this.type = OffsetType.Direction;
|
|
|
|
|
this.UpdateDistance(disRes.Distance);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
@ -65,10 +78,12 @@ export class Command_Offset implements Command
|
|
|
|
|
{
|
|
|
|
|
app.Viewer.OutlinePass.selectedObjects = [cu.DrawObject];
|
|
|
|
|
let state: GetOffsetStatus;
|
|
|
|
|
if (this.isDyn)
|
|
|
|
|
if (this.type === OffsetType.Dynamic)
|
|
|
|
|
state = await this.GetDynOffsetDist(cu);
|
|
|
|
|
else
|
|
|
|
|
else if (this.type === OffsetType.Direction)
|
|
|
|
|
state = await this.GetOffsetDir(cu);
|
|
|
|
|
else
|
|
|
|
|
state = await this.GetOffsetContinuous(cu);
|
|
|
|
|
|
|
|
|
|
JigUtils.End();
|
|
|
|
|
if (state.Status === PromptStatus.OK)
|
|
|
|
@ -83,6 +98,32 @@ export class Command_Offset implements Command
|
|
|
|
|
app.Editor.UCSMatrix = oldUCS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async GetOffsetContinuous(cu: Curve): Promise<GetOffsetStatus>
|
|
|
|
|
{
|
|
|
|
|
let numberSet: Set<number> = new Set();
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
let disRes = await app.Editor.GetDistance({
|
|
|
|
|
Msg: "指定偏移距离:",
|
|
|
|
|
Default: this.offsetDis
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (disRes.Status !== PromptStatus.OK)
|
|
|
|
|
return { Status: disRes.Status };
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (numberSet.has(disRes.Distance))
|
|
|
|
|
{
|
|
|
|
|
Log("你已经偏移过这个距离!");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
numberSet.add(disRes.Distance);
|
|
|
|
|
this.DrawOffset(cu, disRes.Distance);
|
|
|
|
|
this.offsetDis = disRes.Distance;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateDistance(offsetDist: number)
|
|
|
|
|
{
|
|
|
|
|
this.offsetDis = offsetDist || this.offsetDis;
|
|
|
|
@ -184,7 +225,7 @@ export class Command_DynOffset extends Command_Offset
|
|
|
|
|
{
|
|
|
|
|
async exec()
|
|
|
|
|
{
|
|
|
|
|
this.isDyn = true;
|
|
|
|
|
this.type = OffsetType.Dynamic;
|
|
|
|
|
await this.Run();
|
|
|
|
|
app.Viewer.OutlinePass.selectedObjects = [];
|
|
|
|
|
}
|
|
|
|
|