!1543 功能:弧长标注 命令: DimArc

pull/1543/MERGE
林三 3 years ago committed by ChenX
parent 723d580903
commit 60de2ceb6b

@ -0,0 +1,98 @@
import { app } from "../../ApplicationServices/Application";
import { Draw } from "../../Common/Append2CurSpace";
import { ArcDimension } from "../../DatabaseServices/Dimension/ArcDimension";
import { Arc } from "../../DatabaseServices/Entity/Arc";
import { Board } from "../../DatabaseServices/Entity/Board";
import { Polyline } from "../../DatabaseServices/Entity/Polyline";
import { Command } from "../../Editor/CommandMachine";
import { JigUtils } from "../../Editor/JigUtils";
import { PromptStatus } from "../../Editor/PromptResult";
import { HotCMD } from "../../Hot/HotCommand";
function GetBoardCurve(ent: Board): Arc | undefined
{
return GetPolylineArc(ent.ContourCurve.Clone().ApplyMatrix(ent.OCSNoClone) as Polyline);
}
function GetPolylineArc(cu: Polyline)
{
let ucsB = app.Editor.UCSMatrix;
app.Editor.UCSMatrix = cu.OCSNoClone;
let p = app.Editor.MouseCtrl._CurMousePointWCS;
p = cu.GetClosestPointTo(p, false);
app.Editor.UCSMatrix = ucsB;
if (!p) return undefined;
let param = cu.GetParamAtPoint(p);
let ccu = cu.GetCurveAtParam(param);
if (ccu instanceof Arc)
return ccu;
}
@HotCMD
export class Command_DimArc implements Command
{
async exec()
{
let arc: Arc;
while (true)
{
let enRes = await app.Editor.GetEntity({
Msg: "选择圆或者圆弧",
Filter: {
filterFunction: (obj, ent) =>
{
if (ent instanceof Arc) return true;
if (ent instanceof Board)
{
let ccu = GetBoardCurve(ent);
return ccu !== undefined;
}
else if (ent instanceof Polyline)
{
let ccu = GetPolylineArc(ent);
return ccu !== undefined;
}
}
}
});
if (enRes.Status === PromptStatus.Cancel)
return;
else if (enRes.Entity)
{
if (enRes.Entity instanceof Board)
arc = GetBoardCurve(enRes.Entity);
else if (enRes.Entity instanceof Polyline)
arc = GetPolylineArc(enRes.Entity);
else
arc = enRes.Entity as Arc;
break;
}
}
if (!arc) return;
let ucsBak = app.Editor.UCSMatrix;
app.Editor.UCSMatrix = arc.OCSNoClone;
let dim = new ArcDimension(arc.Center.applyMatrix4(arc.OCSInv), arc.StartAngle, arc.EndAngle, arc.IsClockWise, arc.Radius, 30);
dim.OCS = arc.OCSNoClone;
JigUtils.Draw(dim);
let pRes = await app.Editor.GetPoint({
Msg: "请点击标注文字的位置:", Callback: p =>
{
let dist = p.distanceTo(arc.Center);
dim.TextRadiusAdd = dist - arc.Radius;
}
});
app.Editor.UCSMatrix = ucsBak;
if (pRes.Status !== PromptStatus.OK) return;
Draw(dim);
}
}

@ -68,6 +68,7 @@ export enum CommandNames
AngleDim = "ANGLEDIM", AngleDim = "ANGLEDIM",
DimContinue = "CONTINUEDIM", DimContinue = "CONTINUEDIM",
RadiusDim = "RADIUSDIM", RadiusDim = "RADIUSDIM",
DimArc = "DIMARC",
DiaDim = "DIAMETERDIMEN", DiaDim = "DIAMETERDIMEN",
Text = "TEXT", Text = "TEXT",
Intersect = "INTERSECT", Intersect = "INTERSECT",

@ -15,7 +15,7 @@ import { Factory } from "../CADFactory";
import { CADFiler } from "../CADFiler"; import { CADFiler } from "../CADFiler";
import { Arc } from "../Entity/Arc"; import { Arc } from "../Entity/Arc";
import { Line } from "../Entity/Line"; import { Line } from "../Entity/Line";
import { Text, TextAligen } from "../Text/Text"; import { TextAligen } from "../Text/Text";
import { Dimension } from "./Dimension"; import { Dimension } from "./Dimension";
import { GetDimLineMaterial } from "./GetDimLineMaterial"; import { GetDimLineMaterial } from "./GetDimLineMaterial";
@ -25,7 +25,6 @@ import { GetDimLineMaterial } from "./GetDimLineMaterial";
@Factory @Factory
export class LineAngularDimension extends Dimension export class LineAngularDimension extends Dimension
{ {
private _Text = new Text();
private _Arc = new Arc(); private _Arc = new Arc();
constructor( constructor(
protected _L1StartPoint = new Vector3(), //第一条直线的起点 protected _L1StartPoint = new Vector3(), //第一条直线的起点
@ -319,7 +318,8 @@ export class LineAngularDimension extends Dimension
this._Text.AutoUpdate = false;//更新标记 this._Text.AutoUpdate = false;//更新标记
this._Text.TextString = this._TextString ? this._TextString.replace("<>", this.GetString()) : this.GetString(); this._Text.Height = this._TextSize;
this._Text.TextString = this.TextString;
this._Text.Position = this._Arc.GetPointAtParam(0.5); this._Text.Position = this._Arc.GetPointAtParam(0.5);
this._Text.TextRotation = this._Arc.GetAngleAtParam(0.5) % (Math.PI) - Math.PI / 2; this._Text.TextRotation = this._Arc.GetAngleAtParam(0.5) % (Math.PI) - Math.PI / 2;
@ -378,18 +378,20 @@ export class LineAngularDimension extends Dimension
this._L2EndPoint.fromArray(file.Read()); this._L2EndPoint.fromArray(file.Read());
this._DimPoint.fromArray(file.Read()); this._DimPoint.fromArray(file.Read());
if (ver > 1) this._TextString = file.Read(); if (ver > 1) this._TextString = file.Read();
if (ver > 2) this._TextSize = file.Read();
} }
//对象将自身数据写入到文件. //对象将自身数据写入到文件.
WriteFile(file: CADFiler) WriteFile(file: CADFiler)
{ {
super.WriteFile(file); super.WriteFile(file);
file.Write(2); file.Write(3);
file.Write(this._L1StartPoint.toArray()); file.Write(this._L1StartPoint.toArray());
file.Write(this._L1EndPoint.toArray()); file.Write(this._L1EndPoint.toArray());
file.Write(this._L2StartPoint.toArray()); file.Write(this._L2StartPoint.toArray());
file.Write(this._L2EndPoint.toArray()); file.Write(this._L2EndPoint.toArray());
file.Write(this._DimPoint.toArray()); file.Write(this._DimPoint.toArray());
file.Write(this._TextString); file.Write(this._TextString);
file.Write(this._TextSize);
} }
//#endregion //#endregion

@ -17,7 +17,7 @@ import { CADFiler } from "../CADFiler";
import { Line } from "../Entity/Line"; import { Line } from "../Entity/Line";
import { Polyline } from "../Entity/Polyline"; import { Polyline } from "../Entity/Polyline";
import { ObjectId } from "../ObjectId"; import { ObjectId } from "../ObjectId";
import { Text, TextAligen } from "../Text/Text"; import { TextAligen } from "../Text/Text";
import { Dimension } from "./Dimension"; import { Dimension } from "./Dimension";
import { GetDimLineMaterial } from "./GetDimLineMaterial"; import { GetDimLineMaterial } from "./GetDimLineMaterial";
@ -40,7 +40,6 @@ interface DefaultValue
@Factory @Factory
export class AlignedDimension extends Dimension export class AlignedDimension extends Dimension
{ {
private _Text = new Text(undefined, undefined, "yahei");
//引线 //引线
private _LeadOutLine = new Polyline(); private _LeadOutLine = new Polyline();
private _LeadOutOffsetY = 72; private _LeadOutOffsetY = 72;
@ -274,21 +273,6 @@ export class AlignedDimension extends Dimension
return this._DefaultVal; return this._DefaultVal;
} }
set TextSize(size: number)
{
if (this._Text.Height !== size)
{
this.WriteAllObjectRecord();
this._Text.Height = size;
this.Update();
}
}
get TextSize()
{
return this._Text.Height;
}
Explode() Explode()
{ {
this.UpdateText(this._Text.Position); this.UpdateText(this._Text.Position);
@ -479,10 +463,11 @@ export class AlignedDimension extends Dimension
this._Text.AutoUpdate = false; this._Text.AutoUpdate = false;
let textRo = this._TextRotation ?? angleAndX(this._ArmP1.clone().sub(this._ArmP2)); let textRo = this._TextRotation ?? angleAndX(this._ArmP1.clone().sub(this._ArmP2));
this._Text.TextString = this._TextString ? this._TextString.replace("<>", this.GetString()) : this.GetString(); this._Text.TextString = this.TextString;
this._Text.Position = pos ?? midPoint(this._ArmP1, this._ArmP2); this._Text.Position = pos ?? midPoint(this._ArmP1, this._ArmP2);
this._Text.TextRotation = textRo; this._Text.TextRotation = textRo;
this._Text.ColorIndex = this._Color; this._Text.ColorIndex = this._Color;
this._Text.Height = this._TextSize;
this._Text.DeferUpdate(); this._Text.DeferUpdate();
this._Text.AutoUpdate = true; this._Text.AutoUpdate = true;
@ -631,7 +616,7 @@ export class AlignedDimension extends Dimension
this._LeadOutOffsetX = file.Read(); this._LeadOutOffsetX = file.Read();
} }
if (ver > 4) if (ver > 4)
this.TextSize = file.Read(); this._TextSize = file.Read();
} }
//对象将自身数据写入到文件. //对象将自身数据写入到文件.
WriteFile(file: CADFiler) WriteFile(file: CADFiler)
@ -651,7 +636,7 @@ export class AlignedDimension extends Dimension
file.Write(this._LeadOutOffsetY); file.Write(this._LeadOutOffsetY);
file.Write(this._LeadOutOffsetX); file.Write(this._LeadOutOffsetX);
file.Write(this.TextSize); file.Write(this._TextSize);
} }
//#endregion //#endregion
} }

@ -0,0 +1,248 @@
import { BufferGeometry, Line, Material, Matrix4, Mesh, Object3D, Vector3 } from "three";
import { AddEntityDrawObject } from "../../Common/AddEntityDrawObject";
import { FixedNotZero } from "../../Common/Utils";
import { BufferGeometryUtils } from "../../Geometry/BufferGeometryUtils";
import { AsVector3 } from "../../Geometry/GeUtils";
import { RenderType } from "../../GraphicsSystem/RenderType";
import { equaln } from "../../Nest/Common/Util";
import { Factory } from "../CADFactory";
import { CADFiler } from "../CADFiler";
import { Arc } from "../Entity/Arc";
import { Text, TextAligen } from "../Text/Text";
import { Dimension } from "./Dimension";
import { GetDimLineMaterial } from "./GetDimLineMaterial";
@Factory
export class ArcDimension extends Dimension
{
private _Arc = new Arc;
protected _Text = new Text();
constructor(
private _Center: Vector3 = new Vector3,
private _StartAngle: number = 0,
private _EndAngle: number = 1,
private _Clockwise = false,
private _Radius: number = 1,
private _TextRadiusAdd: number = 1,
protected _TextString: string = "⌒<>",
)
{
super();
}
get Text()
{
if (!this._Text.TextString)
{
this.PraseArc();
this.ParseText();
}
return this._Text;
}
set TextRadiusAdd(ra: number)
{
if (equaln(ra, this._TextRadiusAdd)) return;
this.WriteAllObjectRecord();
this._TextRadiusAdd = ra;
this.Update();
}
get TextRadiusAdd() { return this._TextRadiusAdd; }
protected GetString(): string
{
return FixedNotZero(this._Arc.Length, 2);
}
//#region 拉伸相关
GetGripPoints(): Vector3[]
{
this.PraseArc();
let pts = this._Arc.GetGripPoints();
for (let p of pts)
p.applyMatrix4(this.OCSNoClone);
return pts;
}
MoveGripPoints(indexList: number[], vec: Vector3)
{
this.WriteAllObjectRecord();
vec = vec.clone().applyMatrix4(this.OCSInv.setPosition(0, 0, 0));
this.PraseArc();
this._Arc.MoveGripPoints(indexList, vec);
this.UpdateArcFromThisArc();
this.Update();
}
GetStretchPoints(): Vector3[]
{
this.PraseArc();
let pts = this._Arc.GetStretchPoints();
for (let p of pts)
p.applyMatrix4(this.OCSNoClone);
return pts;
}
MoveStretchPoints(indexList: number[], vec: Vector3)
{
this.WriteAllObjectRecord();
vec = vec.clone().applyMatrix4(this.OCSInv.setPosition(0, 0, 0));
this.PraseArc();
this._Arc.MoveStretchPoints(indexList, vec);
this.UpdateArcFromThisArc();
this.Update();
}
private UpdateArcFromThisArc()
{
this._Center.copy(this._Arc.Center);
this._StartAngle = this._Arc.StartAngle;
this._EndAngle = this._Arc.EndAngle;
this._Radius = this._Arc.Radius;
this._Clockwise = this._Arc.IsClockWise;
}
//#endregion
//#region Draw
InitDrawObject(renderType: RenderType = RenderType.Wireframe)
{
let colorMaterial = GetDimLineMaterial(this, renderType);
let obj = new Object3D();
let line = new Line(new BufferGeometry, colorMaterial);
obj.add(line);
let arrow1 = new Mesh(BufferGeometryUtils.ArrowGeometry(), colorMaterial);
let arrow2 = new Mesh(BufferGeometryUtils.ArrowGeometry(), colorMaterial);
let arrowSize = 10;
arrow1.scale.set(arrowSize, arrowSize, arrowSize);
arrow2.scale.set(arrowSize, arrowSize, arrowSize);
obj.add(arrow1, arrow2);
this.UpdateDrawObject(renderType, obj);
return obj;
}
UpdateDrawObject(renderType: RenderType, obj: Object3D)
{
obj.remove(...obj.children.slice(3));
let [line, arrow1, arrow2] = obj.children as [Line, Mesh, Mesh];
let colorMaterial = GetDimLineMaterial(this, renderType);
line.material = colorMaterial;
arrow1.material = colorMaterial;
arrow2.material = colorMaterial;
this.PraseArc();//半径设置到实际尺寸的位置,获得正确的标注尺寸
let startFootPoint = this._Arc.StartPoint;//一定要在这个位置求脚点
let endFootPoint = this._Arc.EndPoint;
this._Text.AutoUpdate = false;
this._Text.ColorIndex = this.ColorIndex;
this.ParseText();
this._Arc.DeferUpdate();
this._Text.DeferUpdate();
let linePoints: Vector3[] = [startFootPoint];
for (let p of this._Arc.Shape.getPoints(8))
linePoints.push(AsVector3(p).add(this._Center));
linePoints.push(endFootPoint);
let geo = line.geometry as BufferGeometry;
if (!BufferGeometryUtils.UpdatePts(geo, linePoints))
{
line.geometry.dispose();
line.geometry = BufferGeometryUtils.CreateFromPts(linePoints);
}
AddEntityDrawObject(obj, this._Text, renderType);
//更新箭头的位置和旋转角度
arrow1.position.copy(this._Arc.StartPoint);
arrow1.rotation.z = this._Arc.GetFistDerivAngle(0) + Math.PI / 2;
arrow1.updateMatrix();
arrow2.position.copy(this._Arc.EndPoint);
arrow2.rotation.z = this._Arc.GetFistDerivAngle(1) - Math.PI / 2;
arrow2.updateMatrix();
}
private ParseText()
{
this._Text.TextString = this.TextString;
this._Arc.Radius = this._Radius + this._TextRadiusAdd; //半径设置到文字的位置,获得文字的位置
let textP = this._Arc.GetPointAtParam(0.5);
let ang = this._Arc.GetAngleAtParam(0.5);
let textOCS = new Matrix4().makeRotationZ(ang + Math.PI * 3 / 2).setPosition(textP);
this._Text.TextAligen = TextAligen.Down;
this._Text.OCS = textOCS;
this._Text.Height = this._TextSize;
}
UpdateDrawObjectMaterial(type: RenderType, obj: Object3D, material?: Material)
{
let colorMaterial = GetDimLineMaterial(this, type);
let count = Math.min(3, obj.children.length);
for (let i = 0; i < count; i++)
{
let l = obj.children[i] as Line;
l.material = colorMaterial;
}
this._Text.ColorIndex = this.ColorIndex;
this.Text.DeferUpdate();
}
private PraseArc()
{
this._Arc.AutoUpdate = false;
this._Arc.Center = this._Center;
this._Arc.StartAngle = this._StartAngle;
this._Arc.EndAngle = this._EndAngle;
this._Arc.IsClockWise = this._Clockwise;
this._Arc.Radius = this._Radius;
}
//#endregion
//#region -------------------------File-------------------------
//对象从文件中读取数据,初始化自身
protected _ReadFile(file: CADFiler)
{
let ver = file.Read();
super._ReadFile(file);
this._Center.fromArray(file.Read());
this._Radius = file.Read();
this._TextRadiusAdd = file.Read();
this._Clockwise = file.Read();
this._StartAngle = file.Read();
this._EndAngle = file.Read();
this._TextString = file.Read();
this._TextSize = file.Read();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFiler)
{
file.Write(1);
super.WriteFile(file);
file.Write(this._Center.toArray());
file.Write(this._Radius);
file.Write(this._TextRadiusAdd);
file.Write(this._Clockwise);
file.Write(this._StartAngle);
file.Write(this._EndAngle);
file.Write(this._TextString);
file.Write(this._TextSize);
}
//#endregion
}

@ -1,11 +1,14 @@
import { CADFactory } from "../CADFactory"; import { Factory } from "../CADFactory";
import { Entity } from "../Entity/Entity"; import { Entity } from "../Entity/Entity";
import { Text } from "../Text/Text";
CADFactory; @Factory
export abstract class Dimension extends Entity export abstract class Dimension extends Entity
{ {
OnlyRenderType = true; OnlyRenderType = true;
protected _TextString: string; protected _TextString: string;
protected _TextSize: number = 60;
protected _Text = new Text(undefined, undefined, "yahei");
set TextString(txt: string) set TextString(txt: string)
{ {
@ -21,5 +24,25 @@ export abstract class Dimension extends Entity
} }
} }
get TextString()
{
return this._TextString ? this._TextString.replace("<>", this.GetString()) : this.GetString();
}
set TextSize(size: number)
{
if (this._Text.Height !== size)
{
this.WriteAllObjectRecord();
this._TextSize = size;
this.Update();
}
}
get TextSize()
{
return this._TextSize;
}
protected abstract GetString(): string; protected abstract GetString(): string;
} }

@ -15,7 +15,6 @@ import { CADFiler } from "../CADFiler";
import { Circle } from "../Entity/Circle"; import { Circle } from "../Entity/Circle";
import { Line } from "../Entity/Line"; import { Line } from "../Entity/Line";
import { ObjectId } from "../ObjectId"; import { ObjectId } from "../ObjectId";
import { Text } from "../Text/Text";
import { Dimension } from "./Dimension"; import { Dimension } from "./Dimension";
import { GetDimLineMaterial } from "./GetDimLineMaterial"; import { GetDimLineMaterial } from "./GetDimLineMaterial";
@ -24,7 +23,6 @@ export class RadiusDimension extends Dimension
{ {
OnlyRenderType = true; OnlyRenderType = true;
protected _Text = new Text();
protected _TextString: string = "R<>"; protected _TextString: string = "R<>";
constructor( constructor(
@ -188,9 +186,10 @@ export class RadiusDimension extends Dimension
this._Text.AutoUpdate = false; this._Text.AutoUpdate = false;
let armV = this.endPt.clone().sub(this.center); let armV = this.endPt.clone().sub(this.center);
this._Text.TextString = this._TextString ? this._TextString.replace("<>", this.GetString()) : this.GetString(); this._Text.TextString = this.TextString;
this._Text.Position = this.endPt; this._Text.Position = this.endPt;
this._Text.TextRotation = angleAndX(armV); this._Text.TextRotation = angleAndX(armV);
this._Text.Height = this._TextSize;
this._Text.DeferUpdate(); this._Text.DeferUpdate();
this._Text.AutoUpdate = true; this._Text.AutoUpdate = true;
@ -281,14 +280,16 @@ export class RadiusDimension extends Dimension
this.center.fromArray(file.Read()); this.center.fromArray(file.Read());
this.endPt.fromArray(file.Read()); this.endPt.fromArray(file.Read());
if (ver > 1) this._TextString = file.Read(); if (ver > 1) this._TextString = file.Read();
if (ver > 2) this._TextSize = file.Read();
} }
WriteFile(file: CADFiler) WriteFile(file: CADFiler)
{ {
super.WriteFile(file); super.WriteFile(file);
file.Write(2); file.Write(3);
file.Write(this.startPt.toArray()); file.Write(this.startPt.toArray());
file.Write(this.center.toArray()); file.Write(this.center.toArray());
file.Write(this.endPt.toArray()); file.Write(this.endPt.toArray());
file.Write(this._TextString); file.Write(this._TextString);
file.Write(this._TextSize);
} }
} }

@ -4,6 +4,7 @@ import { setRotationOnAxis } from '../../Common/Matrix4Utils';
import { UpdateDraw } from '../../Common/Status'; import { UpdateDraw } from '../../Common/Status';
import { GetBox, MoveMatrix } from '../../Geometry/GeUtils'; import { GetBox, MoveMatrix } from '../../Geometry/GeUtils';
import { RenderType } from '../../GraphicsSystem/RenderType'; import { RenderType } from '../../GraphicsSystem/RenderType';
import { equaln } from '../../Nest/Common/Util';
import { Factory } from '../CADFactory'; import { Factory } from '../CADFactory';
import { CADFiler } from '../CADFiler'; import { CADFiler } from '../CADFiler';
import { Entity } from '../Entity/Entity'; import { Entity } from '../Entity/Entity';
@ -72,6 +73,8 @@ export class Text extends Entity
set TextAligen(al: TextAligen) set TextAligen(al: TextAligen)
{ {
if (al === this._Align) return;
this.WriteAllObjectRecord();
this._Align = al; this._Align = al;
this.UpdateTranslate(); this.UpdateTranslate();
} }
@ -82,6 +85,8 @@ export class Text extends Entity
} }
set Height(v: number) set Height(v: number)
{ {
if (equaln(v, this._Height)) return;
this.WriteAllObjectRecord(); this.WriteAllObjectRecord();
this._Height = v; this._Height = v;
this.Update(UpdateDraw.Geometry); this.Update(UpdateDraw.Geometry);

@ -234,6 +234,7 @@ import { ShowKinfeManageModal } from './../Add-on/showModal/ShowKnifeManageModal
import { commandMachine } from './CommandMachine'; import { commandMachine } from './CommandMachine';
import hotkeys from "hotkeys-js"; import hotkeys from "hotkeys-js";
import { Command_ChangeLayout, Command_ModuleBar, Command_PropertiesBar, Command_RightPanel } from "../UI/Components/CommandPanel/SystemCommand/UICpmmand"; import { Command_ChangeLayout, Command_ModuleBar, Command_PropertiesBar, Command_RightPanel } from "../UI/Components/CommandPanel/SystemCommand/UICpmmand";
import { Command_DimArc } from "../Add-on/DrawDim/DimArc";
import { ToggleDrillingReactor } from "../Add-on/DrawDrilling/ToggleDrillingReactor"; import { ToggleDrillingReactor } from "../Add-on/DrawDrilling/ToggleDrillingReactor";
export function registerCommand() export function registerCommand()
{ {
@ -386,6 +387,7 @@ export function registerCommand()
commandMachine.RegisterCommand(CommandNames.DimContinue, new Command_DimContinue()); commandMachine.RegisterCommand(CommandNames.DimContinue, new Command_DimContinue());
commandMachine.RegisterCommand(CommandNames.RadiusDim, new DrawRadiusDim()); commandMachine.RegisterCommand(CommandNames.RadiusDim, new DrawRadiusDim());
commandMachine.RegisterCommand(CommandNames.DiaDim, new DrawDiameterDim()); commandMachine.RegisterCommand(CommandNames.DiaDim, new DrawDiameterDim());
commandMachine.RegisterCommand(CommandNames.DimArc, new Command_DimArc());
commandMachine.RegisterCommand(CommandNames.Text, new DrawText()); commandMachine.RegisterCommand(CommandNames.Text, new DrawText());
commandMachine.RegisterCommand(CommandNames.Intersect, new IntersectionOperation()); commandMachine.RegisterCommand(CommandNames.Intersect, new IntersectionOperation());

@ -6,6 +6,7 @@ import { FixedNotZero, GetEntity } from "../../Common/Utils";
import { ExtrudeHole } from "../../DatabaseServices/3DSolid/ExtrudeHole"; import { ExtrudeHole } from "../../DatabaseServices/3DSolid/ExtrudeHole";
import { LineAngularDimension } from "../../DatabaseServices/Dimension/2LineAngularDimension"; import { LineAngularDimension } from "../../DatabaseServices/Dimension/2LineAngularDimension";
import { AlignedDimension } from "../../DatabaseServices/Dimension/AlignedDimension"; import { AlignedDimension } from "../../DatabaseServices/Dimension/AlignedDimension";
import { ArcDimension } from "../../DatabaseServices/Dimension/ArcDimension";
import { RadiusDimension } from "../../DatabaseServices/Dimension/RadiusDimension"; import { RadiusDimension } from "../../DatabaseServices/Dimension/RadiusDimension";
import { Board } from "../../DatabaseServices/Entity/Board"; import { Board } from "../../DatabaseServices/Entity/Board";
import { Line } from "../../DatabaseServices/Entity/Line"; import { Line } from "../../DatabaseServices/Entity/Line";
@ -102,7 +103,7 @@ export class DbClickManager extends Singleton
await DBClickPolyline.GetInstance().HandlePolyline(pickEnt); await DBClickPolyline.GetInstance().HandlePolyline(pickEnt);
}, "_pedit"); }, "_pedit");
} }
else if (pickEnt instanceof AlignedDimension || pickEnt instanceof LineAngularDimension || pickEnt instanceof RadiusDimension) else if (pickEnt instanceof AlignedDimension || pickEnt instanceof LineAngularDimension || pickEnt instanceof RadiusDimension || pickEnt instanceof ArcDimension)
{ {
let textarea = TextArea.GetInstance() as TextArea; let textarea = TextArea.GetInstance() as TextArea;
if (pickObj.children.length > 0) if (pickObj.children.length > 0)

@ -1142,6 +1142,15 @@ export const CommandList: ICommand[] = [
// enName: "Continue Dimension", // enName: "Continue Dimension",
chDes: "标注直径", chDes: "标注直径",
}, },
{
typeId: "dim",
defaultCustom: CommandNames.DimArc,
command: CommandNames.DimArc,
type: "标注",
chName: "标注弧长",
// enName: "Continue Dimension",
chDes: "标注弧长",
},
{ {
icon: IconEnum.AutoDim, icon: IconEnum.AutoDim,
typeId: "dim", typeId: "dim",

@ -2,16 +2,17 @@ import { Button, Card, Classes, HTMLSelect } from "@blueprintjs/core";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import React from "react"; import React from "react";
import { AlignedDimension } from "../../../DatabaseServices/Dimension/AlignedDimension"; import { AlignedDimension } from "../../../DatabaseServices/Dimension/AlignedDimension";
import { RadiusDimension } from "../../../DatabaseServices/Dimension/RadiusDimension";
import { LineAngularDimension } from "../../../DatabaseServices/Dimension/2LineAngularDimension";
import { Curve } from "../../../DatabaseServices/Entity/Curve"; import { Curve } from "../../../DatabaseServices/Entity/Curve";
import { Entity } from "../../../DatabaseServices/Entity/Entity"; import { Entity } from "../../../DatabaseServices/Entity/Entity";
import { Text } from "../../../DatabaseServices/Text/Text"; import { Text } from "../../../DatabaseServices/Text/Text";
import { DownPanelStore } from "../../Store/DownPanelStore"; import { DownPanelStore } from "../../Store/DownPanelStore";
import { ColorModal } from "../EntityModal/EntityColorList"; import { ColorModal } from "../EntityModal/EntityColorList";
import { PropertiesStore } from "./PropertiesStore"; import { PropertiesStore } from "./PropertiesStore";
import { Properties_DimPanel } from "./Properties_Dim";
import { Properties_Text } from "./Properties_Text"; import { Properties_Text } from "./Properties_Text";
import { ArcDimension } from "../../../DatabaseServices/Dimension/ArcDimension";
import { Dimension } from "../../../DatabaseServices/Dimension/Dimension";
import { Properties_DimPanel } from "./Properties_Dim";
import { Properties_AlignedDimPanel } from "./Properties_AlignedDim";
enum EntType enum EntType
{ {
@ -27,6 +28,8 @@ enum EntType
DiameterDimension = "DiameterDimension", DiameterDimension = "DiameterDimension",
RadiusDimension = "RadiusDimension", RadiusDimension = "RadiusDimension",
LinearDimension = "LinearDimension", LinearDimension = "LinearDimension",
ArcDimension = "ArcDimension",
Dimension = "Dimension",
Board = "Board", Board = "Board",
} }
@ -51,6 +54,9 @@ export class PropertiesPanel extends React.Component<{}, {}>
case EntType.Text: case EntType.Text:
res = ents.filter((e) => { return e instanceof Text; }); res = ents.filter((e) => { return e instanceof Text; });
break; break;
case EntType.Dimension:
res = ents.filter((e) => { return e instanceof Dimension; });
break;
//todo: more //todo: more
} }
return res; return res;
@ -124,11 +130,24 @@ export class PropertiesPanel extends React.Component<{}, {}>
</> </>
} }
{ {
ents[0] instanceof AlignedDimension && ents[0] instanceof Dimension &&
<> <>
<span className="li-title"></span> <span className="li-title"></span>
</>
}
{
ents[0] instanceof AlignedDimension &&
<>
<li>
<Properties_AlignedDimPanel ents={this.GetEntsByType(ents, EntType.AlignDim) as AlignedDimension[]} />
</li>
</>
}
{
ents[0] instanceof Dimension &&
<>
<li> <li>
<Properties_DimPanel ents={this.GetEntsByType(ents, EntType.AlignDim) as AlignedDimension[]} /> <Properties_DimPanel ents={this.GetEntsByType(ents, EntType.Dimension) as Dimension[]} />
</li> </li>
</> </>
} }

@ -0,0 +1,61 @@
import React from "react";
import { observer } from "mobx-react";
import { observable } from "mobx";
import { CommandWrap } from "../../../Editor/CommandMachine";
import { Button, Card, Classes } from "@blueprintjs/core";
import { AlignedDimension } from "../../../DatabaseServices/Dimension/AlignedDimension";
export interface Properties_AlignedDimPanelProps
{
ents: AlignedDimension[];
}
@observer
export class Properties_AlignedDimPanel extends React.Component<Properties_AlignedDimPanelProps, {}>
{
@observable private dim_TextSize: number = 60;
constructor(p)
{
super(p);
if (this.props.ents.length > 0)
{
let numval = this.props.ents[0].TextSize;
this.dim_TextSize = numval;
}
}
render()
{
let ents = this.props.ents;
return (
<Card className={"dal-editor"}>
<ul className={Classes.LIST_UNSTYLED}>
<li className="leadout-editor">
<span>线: </span>
<div>
<Button icon="swap-horizontal" text="切换方向" minimal small onClick={() =>
{
CommandWrap(() =>
{
for (let al of ents)
{
al.toggleLeadOutFlipped();
}
}, "切换标注引线方向");
}} />
<Button icon="eye-open" text="切换显示" minimal small onClick={() =>
{
CommandWrap(() =>
{
for (let al of ents)
{
al.toggleLeadOutVisible();
}
}, "切换标注引线显示");
}} />
</div>
</li>
</ul>
</Card>
);
}
}

@ -1,21 +1,22 @@
import { Button, Card, Classes, Intent, Position, Slider, Tooltip } from "@blueprintjs/core"; import React from "react";
import hotkeys from "hotkeys-js"; import hotkeys from "hotkeys-js";
import { observable } from "mobx"; import { safeEval } from "../../../Common/eval";
import { PropertiesStore } from "./PropertiesStore";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import React from "react"; import { observable } from "mobx";
import { Object3D } from "three"; import { Object3D } from "three";
import { end } from "xaop";
import { app } from "../../../ApplicationServices/Application";
import { safeEval } from "../../../Common/eval";
import { KeyBoard, KeyCode } from "../../../Common/KeyEnum"; import { KeyBoard, KeyCode } from "../../../Common/KeyEnum";
import { AlignedDimension } from "../../../DatabaseServices/Dimension/AlignedDimension"; import { end } from "xaop";
import { commandMachine, CommandWrap } from "../../../Editor/CommandMachine"; import { Dimension } from "../../../DatabaseServices/Dimension/Dimension";
import { CommandState } from "../../../Editor/CommandState"; import { CommandState } from "../../../Editor/CommandState";
import { commandMachine, CommandWrap } from "../../../Editor/CommandMachine";
import { Button, Card, Classes, Intent, Position, Slider, Tooltip } from "@blueprintjs/core";
import { AppToaster } from "../Toaster"; import { AppToaster } from "../Toaster";
import { PropertiesStore } from "./PropertiesStore"; import { app } from "../../../ApplicationServices/Application";
export interface Properties_DimPanelProps export interface Properties_DimPanelProps
{ {
ents: AlignedDimension[]; ents: Dimension[];
} }
@observer @observer
@ -74,7 +75,7 @@ export class Properties_DimPanel extends React.Component<Properties_DimPanelProp
f(); f();
this.removeFuncs.length = 0; this.removeFuncs.length = 0;
} }
private Dim_UseDefault(als: AlignedDimension[]) private Dim_UseDefault(als: Dimension[])
{ {
let propsStore = PropertiesStore.GetInstance() as PropertiesStore; let propsStore = PropertiesStore.GetInstance() as PropertiesStore;
CommandWrap(() => CommandWrap(() =>
@ -83,10 +84,6 @@ export class Properties_DimPanel extends React.Component<Properties_DimPanelProp
for (let al of als) for (let al of als)
{ {
al.TextSize = 60; al.TextSize = 60;
al.LeadOutOffsetY = al.DefaultValue.offset.y;
al.LeadOutOffsetX = al.DefaultValue.offset.x;
al.LeadOutFlipped = al.DefaultValue.isFlipped;
al.LeadOutVisible = true;
al.ColorIndex = 7; al.ColorIndex = 7;
propsStore.colorIndex = 7;//todo 撤销的时候UI颜色没有同步更改 propsStore.colorIndex = 7;//todo 撤销的时候UI颜色没有同步更改
this.dim_InputEl.current.value = "60"; this.dim_InputEl.current.value = "60";
@ -232,31 +229,6 @@ export class Properties_DimPanel extends React.Component<Properties_DimPanelProp
vertical={false} vertical={false}
/> />
</li> </li>
<li className="leadout-editor">
<span>线: </span>
<div>
<Button icon="swap-horizontal" text="切换方向" minimal small onClick={() =>
{
CommandWrap(() =>
{
for (let al of ents)
{
al.toggleLeadOutFlipped();
}
}, "切换标注引线方向");
}} />
<Button icon="eye-open" text="切换显示" minimal small onClick={() =>
{
CommandWrap(() =>
{
for (let al of ents)
{
al.toggleLeadOutVisible();
}
}, "切换标注引线显示");
}} />
</div>
</li>
<li> <li>
<Button className={Classes.INTENT_WARNING} text="重置标注为默认" minimal small onClick={() => this.Dim_UseDefault(ents)} /> <Button className={Classes.INTENT_WARNING} text="重置标注为默认" minimal small onClick={() => this.Dim_UseDefault(ents)} />
</li> </li>

@ -103,6 +103,7 @@ export class TopToolBar extends React.Component<{}, {}>
{ svg: IconEnum.DimContinued, title: "线性标注", command: CommandNames.LinearDim }, { svg: IconEnum.DimContinued, title: "线性标注", command: CommandNames.LinearDim },
{ svg: IconEnum.DimAngle, title: "角度标注", command: CommandNames.AngleDim }, { svg: IconEnum.DimAngle, title: "角度标注", command: CommandNames.AngleDim },
{ svg: IconEnum.DimLinear, title: "连续标注", command: CommandNames.DimContinue }, { svg: IconEnum.DimLinear, title: "连续标注", command: CommandNames.DimContinue },
{ svg: IconEnum.Arc, title: "弧长标注", command: CommandNames.DimArc },
{ svg: IconEnum.Circle, title: "半径标注", command: CommandNames.RadiusDim }, { svg: IconEnum.Circle, title: "半径标注", command: CommandNames.RadiusDim },
{ svg: IconEnum.Diameter, title: "直径标注", command: CommandNames.DiaDim }, { svg: IconEnum.Diameter, title: "直径标注", command: CommandNames.DiaDim },
{ svg: IconEnum.AutoDim, title: "柜体标注", command: CommandNames.AutoDimBrs }, { svg: IconEnum.AutoDim, title: "柜体标注", command: CommandNames.AutoDimBrs },

@ -1,7 +1,8 @@
import { action, observable } from "mobx"; import { action, observable } from "mobx";
import { Singleton } from "../../Common/Singleton"; import { Singleton } from "../../Common/Singleton";
import { AlignedDimension } from "../../DatabaseServices/Dimension/AlignedDimension"; import { Dimension } from "../../DatabaseServices/Dimension/Dimension";
import { Arc } from "../../DatabaseServices/Entity/Arc"; import { Arc } from "../../DatabaseServices/Entity/Arc";
import { Board } from "../../DatabaseServices/Entity/Board";
import { Circle } from "../../DatabaseServices/Entity/Circle"; import { Circle } from "../../DatabaseServices/Entity/Circle";
import { Ellipse } from "../../DatabaseServices/Entity/Ellipse"; import { Ellipse } from "../../DatabaseServices/Entity/Ellipse";
import { Entity } from "../../DatabaseServices/Entity/Entity"; import { Entity } from "../../DatabaseServices/Entity/Entity";
@ -9,11 +10,6 @@ import { Line } from "../../DatabaseServices/Entity/Line";
import { Polyline } from "../../DatabaseServices/Entity/Polyline"; import { Polyline } from "../../DatabaseServices/Entity/Polyline";
import { Region } from "../../DatabaseServices/Entity/Region"; import { Region } from "../../DatabaseServices/Entity/Region";
import { Text } from "../../DatabaseServices/Text/Text"; import { Text } from "../../DatabaseServices/Text/Text";
import { LineAngularDimension } from "../../DatabaseServices/Dimension/2LineAngularDimension";
import { RadiusDimension } from "../../DatabaseServices/Dimension/RadiusDimension";
import { LinearDimension } from "../../DatabaseServices/Dimension/LinearDimension";
import { DiameterDimension } from "../../DatabaseServices/Dimension/DiameterDimension";
import { Board } from "../../DatabaseServices/Entity/Board";
import { DownPanelStore, ToolBarType } from "./DownPanelStore"; import { DownPanelStore, ToolBarType } from "./DownPanelStore";
export class EntityStore extends Singleton export class EntityStore extends Singleton
@ -31,8 +27,6 @@ export class EntityStore extends Singleton
@action @action
AddEntitysToMap(ens: Entity[]) AddEntitysToMap(ens: Entity[])
{ {
console.log(ens);
for (let en of ens) for (let en of ens)
{ {
let type: string = ""; let type: string = "";
@ -48,16 +42,8 @@ export class EntityStore extends Singleton
type = "圆弧"; type = "圆弧";
else if (en instanceof Ellipse) else if (en instanceof Ellipse)
type = "椭圆"; type = "椭圆";
else if (en instanceof LinearDimension) else if (en instanceof Dimension)
type = "线性标注"; type = "标注";
else if (en instanceof AlignedDimension)
type = "对齐标注";
else if (en instanceof DiameterDimension)
type = "直径标注";
else if (en instanceof RadiusDimension)
type = "半径标注";
else if (en instanceof LineAngularDimension)
type = "角度标注";
else if (en instanceof Board) else if (en instanceof Board)
type = "板"; type = "板";
else if (en instanceof Text) else if (en instanceof Text)

Loading…
Cancel
Save