|
|
@ -1,9 +1,9 @@
|
|
|
|
import { BufferGeometry, Line as TLine, Matrix3, Mesh, Object3D, Vector3, Vector2, Material, Matrix4 } from "three";
|
|
|
|
import { BufferGeometry, Line as TLine, Matrix3, Mesh, Object3D, Vector3, Vector2, Material, Matrix4, Box3 } from "three";
|
|
|
|
import { ColorMaterial } from "../../Common/ColorPalette";
|
|
|
|
import { ColorMaterial } from "../../Common/ColorPalette";
|
|
|
|
import { FixedNotZero } from "../../Common/Utils";
|
|
|
|
import { FixedNotZero } from "../../Common/Utils";
|
|
|
|
import { ObjectSnapMode } from "../../Editor/ObjectSnapMode";
|
|
|
|
import { ObjectSnapMode } from "../../Editor/ObjectSnapMode";
|
|
|
|
import { BufferGeometryUtils } from "../../Geometry/BufferGeometryUtils";
|
|
|
|
import { BufferGeometryUtils } from "../../Geometry/BufferGeometryUtils";
|
|
|
|
import { angle, angleAndX, midPoint, ZeroVec, ZAxis, equaln, equalv3 } from "../../Geometry/GeUtils";
|
|
|
|
import { angle, angleAndX, midPoint, ZeroVec, ZAxis, equaln, equalv3, GetBox } from "../../Geometry/GeUtils";
|
|
|
|
import { RenderType } from "../../GraphicsSystem/RenderType";
|
|
|
|
import { RenderType } from "../../GraphicsSystem/RenderType";
|
|
|
|
import { Factory } from "../CADFactory";
|
|
|
|
import { Factory } from "../CADFactory";
|
|
|
|
import { CADFiler } from "../CADFiler";
|
|
|
|
import { CADFiler } from "../CADFiler";
|
|
|
@ -35,6 +35,7 @@ export class AlignedDimension extends Entity
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private _Text = new Text(undefined, undefined, "yahei");
|
|
|
|
private _Text = new Text(undefined, undefined, "yahei");
|
|
|
|
private _TextString: string;
|
|
|
|
private _TextString: string;
|
|
|
|
|
|
|
|
private _TextBoundingBox: Box3;
|
|
|
|
//引线
|
|
|
|
//引线
|
|
|
|
private _LeadOutLine = new TLine();
|
|
|
|
private _LeadOutLine = new TLine();
|
|
|
|
private _LeadOutOffsetY = 72;
|
|
|
|
private _LeadOutOffsetY = 72;
|
|
|
@ -123,7 +124,12 @@ export class AlignedDimension extends Entity
|
|
|
|
if (!equaln(this.m_ArmP1.distanceTo(this.m_ArmP2), 0))
|
|
|
|
if (!equaln(this.m_ArmP1.distanceTo(this.m_ArmP2), 0))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let vx = this.m_ArmP2.clone().sub(this.m_ArmP1);
|
|
|
|
let vx = this.m_ArmP2.clone().sub(this.m_ArmP1);
|
|
|
|
if (this.m_ArmP1.x < this.m_ArmP2.x)
|
|
|
|
if (equaln(this.m_ArmP1.x, this.m_ArmP2.x))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (this.m_ArmP1.y < this.m_ArmP2.y)
|
|
|
|
|
|
|
|
vx.negate();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (this.m_ArmP1.x < this.m_ArmP2.x)
|
|
|
|
vx.negate();
|
|
|
|
vx.negate();
|
|
|
|
let vy = vx.clone().cross(ZAxis);
|
|
|
|
let vy = vx.clone().cross(ZAxis);
|
|
|
|
dalUcs = new Matrix4().makeBasis(vx.normalize(), vy.normalize(), ZAxis.clone().normalize());
|
|
|
|
dalUcs = new Matrix4().makeBasis(vx.normalize(), vy.normalize(), ZAxis.clone().normalize());
|
|
|
@ -180,6 +186,17 @@ export class AlignedDimension extends Entity
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get TextBoundingBox()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (this._TextBoundingBox)
|
|
|
|
|
|
|
|
return this._TextBoundingBox;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set TextBoundingBox(box: Box3)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this._TextBoundingBox = box;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
set LeadOutVisible(visible: boolean)
|
|
|
|
set LeadOutVisible(visible: boolean)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.WriteAllObjectRecord();
|
|
|
|
this.WriteAllObjectRecord();
|
|
|
@ -195,6 +212,11 @@ export class AlignedDimension extends Entity
|
|
|
|
this.Update();
|
|
|
|
this.Update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get LeadOutFlipped()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return this._LeadOutIsFlipped;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
toggleLeadOutVisible()
|
|
|
|
toggleLeadOutVisible()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.LeadOutVisible = !this.m_LeadOutVisible;
|
|
|
|
this.LeadOutVisible = !this.m_LeadOutVisible;
|
|
|
@ -211,12 +233,22 @@ export class AlignedDimension extends Entity
|
|
|
|
this.Update();
|
|
|
|
this.Update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get LeadOutOffsetY()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return this._LeadOutOffsetY;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
set LeadOutOffsetX(size: number)
|
|
|
|
set LeadOutOffsetX(size: number)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this._LeadOutOffsetX = size;
|
|
|
|
this._LeadOutOffsetX = size;
|
|
|
|
this.Update();
|
|
|
|
this.Update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get LeadOutOffsetX()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return this._LeadOutOffsetX;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
set DefaultValue(val: DefaultValue)
|
|
|
|
set DefaultValue(val: DefaultValue)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this._DefaultVal = val;
|
|
|
|
this._DefaultVal = val;
|
|
|
@ -417,6 +449,18 @@ export class AlignedDimension extends Entity
|
|
|
|
this._Text.TextRotation = textRo;
|
|
|
|
this._Text.TextRotation = textRo;
|
|
|
|
this._Text.ColorIndex = this._Color;
|
|
|
|
this._Text.ColorIndex = this._Color;
|
|
|
|
this.RepairText();
|
|
|
|
this.RepairText();
|
|
|
|
|
|
|
|
//更新字体包围盒
|
|
|
|
|
|
|
|
let box = this._Text.BoundingBox;
|
|
|
|
|
|
|
|
let roMat = new Matrix4().makeRotationAxis(this._Text.Normal, textRo);
|
|
|
|
|
|
|
|
box.applyMatrix4(roMat);//
|
|
|
|
|
|
|
|
let moveMat = new Matrix4();
|
|
|
|
|
|
|
|
let dalUcs = this.DalUcs;
|
|
|
|
|
|
|
|
let dalUcsInv = new Matrix4().getInverse(dalUcs);
|
|
|
|
|
|
|
|
let cenc = box.getCenter(new Vector3()).applyMatrix4(dalUcs).sub(new Vector3(0, this._Text.Height / 2));//.sub(new Vector3(0, this._Text.Height / 2)); 如果dragpt 的y小于textpos那么sub变为add
|
|
|
|
|
|
|
|
moveMat.setPosition(pos.clone().sub(cenc.applyMatrix4(dalUcsInv)));
|
|
|
|
|
|
|
|
box.applyMatrix4(moveMat);
|
|
|
|
|
|
|
|
box.applyMatrix4(this.OCS);
|
|
|
|
|
|
|
|
this.TextBoundingBox = box;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GetObjectSnapPoints(
|
|
|
|
GetObjectSnapPoints(
|
|
|
|