mirror of https://gitee.com/cf-fz/WebCAD.git
parent
cb471879bd
commit
4176b4021f
@ -0,0 +1,42 @@
|
|||||||
|
import { app } from "../../ApplicationServices/Application";
|
||||||
|
import { LineAngularDimension } from "../../DatabaseServices/Dimension/2LineAngularDimension";
|
||||||
|
import { AlignedDimension } from "../../DatabaseServices/Dimension/AlignedDimension";
|
||||||
|
import { LinearDimension } from "../../DatabaseServices/Dimension/LinearDimension";
|
||||||
|
import { Command } from "../../Editor/CommandMachine";
|
||||||
|
import { PromptStatus } from "../../Editor/PromptResult";
|
||||||
|
import { DimContinueLineAngular } from "./DimContinueLineAngular";
|
||||||
|
import { DimContinueAligen } from "./DimContinueAligen";
|
||||||
|
|
||||||
|
export type Dimension = AlignedDimension | LineAngularDimension;
|
||||||
|
|
||||||
|
let aligenContinue = new DimContinueAligen();
|
||||||
|
let angularContinue = new DimContinueLineAngular();
|
||||||
|
|
||||||
|
export async function ContinueDrawDimension(lastDim: Dimension)
|
||||||
|
{
|
||||||
|
if (lastDim instanceof AlignedDimension)
|
||||||
|
{
|
||||||
|
await aligenContinue.StartDraw(lastDim);
|
||||||
|
}
|
||||||
|
else if (lastDim instanceof LineAngularDimension)
|
||||||
|
{
|
||||||
|
await angularContinue.StartDraw(lastDim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Command_DimContinue implements Command
|
||||||
|
{
|
||||||
|
async exec()
|
||||||
|
{
|
||||||
|
let dimRes = await app.m_Editor.GetEntity({
|
||||||
|
Msg: "选择连续标注",
|
||||||
|
Filter: { filterTypes: [AlignedDimension, LineAngularDimension, LinearDimension] }
|
||||||
|
});
|
||||||
|
|
||||||
|
if (dimRes.Status !== PromptStatus.OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
let lastDim = dimRes.Entity as Dimension;
|
||||||
|
await ContinueDrawDimension(lastDim);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
import { Vector3 } from "three";
|
||||||
|
import { app } from "../../ApplicationServices/Application";
|
||||||
|
import { JigUtils } from "../../Editor/JigUtils";
|
||||||
|
import { PromptStatus } from "../../Editor/PromptResult";
|
||||||
|
import { Dimension } from "./Command_DimContinue";
|
||||||
|
export class DimContinue
|
||||||
|
{
|
||||||
|
protected m_LastDim: Dimension;
|
||||||
|
protected m_BasePoint: Vector3;
|
||||||
|
//开始绘制.
|
||||||
|
async StartDraw(lastDim: Dimension)
|
||||||
|
{
|
||||||
|
this.m_LastDim = lastDim.Clone();
|
||||||
|
let oldUcs = app.m_Editor.UCSMatrix;
|
||||||
|
app.m_Editor.UCSMatrix = this.m_LastDim.OCS;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
let newDim = this.CloneDimension(this.m_LastDim);
|
||||||
|
JigUtils.Draw(newDim);
|
||||||
|
let ptRes = await app.m_Editor.GetPoint({
|
||||||
|
BasePoint: this.m_BasePoint,
|
||||||
|
Msg: "指定第二个尺寸原点",
|
||||||
|
Callback: p => this.UpdateNextPoint(p, newDim)
|
||||||
|
});
|
||||||
|
if (ptRes.Status === PromptStatus.OK)
|
||||||
|
{
|
||||||
|
let p = ptRes.Value;
|
||||||
|
this.UpdateNextPoint(p, newDim);
|
||||||
|
app.m_Database.ModelSpace.Append(newDim);
|
||||||
|
this.Drawed(newDim, p);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.EndDraw();
|
||||||
|
app.m_Editor.UCSMatrix = oldUcs;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 重载: 当绘制开始时,会拷贝标注,此时你可以进行一些操作
|
||||||
|
* @param dim
|
||||||
|
* @returns and jig draw
|
||||||
|
*/
|
||||||
|
protected CloneDimension(dim: Dimension): Dimension
|
||||||
|
{
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 重载:当用户点击的位置改变时,调用这个函数
|
||||||
|
* @param p
|
||||||
|
* @param dim
|
||||||
|
*/
|
||||||
|
protected UpdateNextPoint(p: Vector3, dim: Dimension)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 重载,当绘制时发生
|
||||||
|
* @param dim
|
||||||
|
*/
|
||||||
|
protected Drawed(dim: Dimension, p: Vector3)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 重载:绘制结束后,将调用这个函数
|
||||||
|
*/
|
||||||
|
protected EndDraw()
|
||||||
|
{
|
||||||
|
this.m_LastDim.GoodBye();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
import { Vector3 } from "three";
|
||||||
|
import { AlignedDimension } from "../../DatabaseServices/Dimension/AlignedDimension";
|
||||||
|
import { Line } from "../../DatabaseServices/Line";
|
||||||
|
import { DimContinue } from "./DimContinue";
|
||||||
|
//对齐标注的连续标注
|
||||||
|
export class DimContinueAligen extends DimContinue
|
||||||
|
{
|
||||||
|
private m_line: Line;
|
||||||
|
/**
|
||||||
|
* 重载: 当绘制开始时,会拷贝标注,此时你可以进行一些操作
|
||||||
|
* @param dim
|
||||||
|
* @returns and jig draw
|
||||||
|
*/
|
||||||
|
protected CloneDimension(dim: AlignedDimension): AlignedDimension
|
||||||
|
{
|
||||||
|
let ndim = dim.Clone();
|
||||||
|
ndim.FootP1 = dim.FootP2;
|
||||||
|
ndim.ArmP1 = dim.ArmP2;
|
||||||
|
this.m_BasePoint = dim.FootP2;
|
||||||
|
if (!this.m_line)
|
||||||
|
this.m_line = new Line(dim.ArmP1, dim.ArmP2);
|
||||||
|
return ndim;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 重载:当用户点击的位置改变时,调用这个函数
|
||||||
|
* @param p
|
||||||
|
* @param dim
|
||||||
|
*/
|
||||||
|
protected UpdateNextPoint(p: Vector3, dim: AlignedDimension)
|
||||||
|
{
|
||||||
|
let last = this.m_LastDim as AlignedDimension;
|
||||||
|
let { closestPt, param } = this.m_line.GetClosestAtPoint(p, true);
|
||||||
|
if (param > 1)
|
||||||
|
{
|
||||||
|
dim.FootP1 = last.FootP2;
|
||||||
|
dim.FootP2 = p;
|
||||||
|
dim.ArmP1 = last.ArmP2;
|
||||||
|
dim.ArmP2 = closestPt;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dim.FootP1 = p;
|
||||||
|
dim.FootP2 = last.FootP1;
|
||||||
|
dim.ArmP1 = closestPt;
|
||||||
|
dim.ArmP2 = last.ArmP1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 重载,当绘制时发生
|
||||||
|
* @param dim
|
||||||
|
*/
|
||||||
|
protected Drawed(dim: AlignedDimension, p: Vector3)
|
||||||
|
{
|
||||||
|
let last = this.m_LastDim as AlignedDimension;
|
||||||
|
let { param } = this.m_line.GetClosestAtPoint(p, true);
|
||||||
|
if (param > 1)
|
||||||
|
{
|
||||||
|
last.FootP2 = p;
|
||||||
|
last.ArmP2 = dim.ArmP2;
|
||||||
|
}
|
||||||
|
else if (param < 0)
|
||||||
|
{
|
||||||
|
last.FootP1 = p;
|
||||||
|
last.ArmP1 = dim.ArmP1;
|
||||||
|
}
|
||||||
|
this.m_line.Join(new Line(dim.ArmP1, dim.ArmP2));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 重载:绘制结束后,将调用这个函数
|
||||||
|
*/
|
||||||
|
protected EndDraw()
|
||||||
|
{
|
||||||
|
super.EndDraw();
|
||||||
|
this.m_line.GoodBye();
|
||||||
|
this.m_line = undefined;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,96 @@
|
|||||||
|
import { Vector3 } from "three";
|
||||||
|
import { Arc } from "../../DatabaseServices/Arc";
|
||||||
|
import { LineAngularDimension } from "../../DatabaseServices/Dimension/2LineAngularDimension";
|
||||||
|
import { Line } from "../../DatabaseServices/Line";
|
||||||
|
import { equalv3 } from "../../Geometry/GeUtils";
|
||||||
|
import { DimContinue } from "./DimContinue";
|
||||||
|
//2直线角度标注的连续标注
|
||||||
|
export class DimContinueLineAngular extends DimContinue
|
||||||
|
{
|
||||||
|
private _l1Sp: Vector3;
|
||||||
|
private _l1Ep: Vector3;
|
||||||
|
private _l2Ep: Vector3;
|
||||||
|
private _arc: Arc;
|
||||||
|
private _narc: Arc;
|
||||||
|
/**
|
||||||
|
* 重载: 当绘制开始时,会拷贝标注,此时你可以进行一些操作
|
||||||
|
* @param dim
|
||||||
|
* @returns and jig draw
|
||||||
|
*/
|
||||||
|
protected CloneDimension(dim: LineAngularDimension): LineAngularDimension
|
||||||
|
{
|
||||||
|
let ndim = dim.Clone();
|
||||||
|
[this._l1Sp, this._l1Ep, this._l2Ep] =
|
||||||
|
[dim.L1StartPoint, dim.L1EndPoint, dim.L2EndPoint];
|
||||||
|
this._arc = dim.Arc;
|
||||||
|
this._narc = dim.Arc;
|
||||||
|
return ndim;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 重载,当绘制时发生
|
||||||
|
* @param dim
|
||||||
|
*/
|
||||||
|
protected Drawed(dim: LineAngularDimension, p: Vector3)
|
||||||
|
{
|
||||||
|
this.m_LastDim.GoodBye();
|
||||||
|
this.m_LastDim = dim.Clone();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 重载:当用户点击的位置改变时,调用这个函数
|
||||||
|
* @param p
|
||||||
|
* @param dim
|
||||||
|
*/
|
||||||
|
protected UpdateNextPoint(p: Vector3, dim: LineAngularDimension)
|
||||||
|
{
|
||||||
|
let cp = this._arc.GetClosestPointTo(p, true);
|
||||||
|
let newL1Ep: Vector3;
|
||||||
|
let param = this._arc.GetParamAtPoint(cp);
|
||||||
|
let arcSpOnL1 = !isNaN(new Line(this._l1Sp, this._l1Ep).GetParamAtPoint(this._arc.StartPoint));
|
||||||
|
if (param > 0.5)
|
||||||
|
{
|
||||||
|
newL1Ep = arcSpOnL1 ? this._l2Ep : this._l1Ep;
|
||||||
|
if (equalv3(newL1Ep, this._arc.Center))
|
||||||
|
newL1Ep = this._arc.EndPoint;
|
||||||
|
if (param > 1)
|
||||||
|
{
|
||||||
|
this._narc.StartAngle = this._arc.GetAngleAtParam(1);
|
||||||
|
this._narc.EndAngle = this._arc.GetAngleAtParam(param);
|
||||||
|
}
|
||||||
|
else if (param === 1)
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this._narc.StartAngle = this._arc.GetAngleAtParam(param);
|
||||||
|
this._narc.EndAngle = this._arc.GetAngleAtParam(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newL1Ep = arcSpOnL1 ? this._l1Ep : this._l2Ep;
|
||||||
|
if (equalv3(newL1Ep, this._arc.Center))
|
||||||
|
newL1Ep = this._arc.StartPoint;
|
||||||
|
if (param < 0)
|
||||||
|
{
|
||||||
|
this._narc.StartAngle = this._arc.GetAngleAtParam(param);
|
||||||
|
this._narc.EndAngle = this._arc.GetAngleAtParam(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this._narc.StartAngle = this._arc.GetAngleAtParam(0);
|
||||||
|
this._narc.EndAngle = this._arc.GetAngleAtParam(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (equalv3(p, this._arc.Center))
|
||||||
|
return;
|
||||||
|
dim.UpdateDimData(this._arc.Center, newL1Ep, this._arc.Center, p, this._narc.GetPointAtParam(0.5));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 重载:绘制结束后,将调用这个函数
|
||||||
|
*/
|
||||||
|
protected EndDraw()
|
||||||
|
{
|
||||||
|
super.EndDraw();
|
||||||
|
this._arc.GoodBye();
|
||||||
|
this._narc.GoodBye();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue