From 61a9e078058159e67681888ec7529ba3e406b731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E8=AF=97=E9=9B=85?= Date: Wed, 27 Nov 2019 15:01:50 +0800 Subject: [PATCH] =?UTF-8?q?!515=20=E8=87=AA=E5=8A=A8=E6=A0=87=E6=B3=A8?= =?UTF-8?q?=E5=AD=97=E4=BD=93=E5=B0=BA=E5=AF=B8=E8=B0=83=E6=95=B4=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BC=95=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Add-on/DrawDim/AutoDimBrs.ts | 113 +++++--- src/Common/Utils.ts | 2 + .../Dimension/AlignedDimension.ts | 231 +++++++++++++++-- src/DatabaseServices/Text/Text.ts | 2 + src/Editor/BoardMoveTool.ts | 2 +- .../CameraControlButton/CameraControlBtn.tsx | 11 +- src/UI/Components/ColorPanel.tsx | 2 +- .../EntityModal/EntityColorList.tsx | 23 +- src/UI/Components/Modal/LightModal.tsx | 2 + .../RightPanel/RightPanelButton.tsx | 44 ++++ .../Components/ToolBar/PropertiesPanel.less | 146 +++++++++++ src/UI/Components/ToolBar/PropertiesPanel.tsx | 128 +++++++++ src/UI/Components/ToolBar/PropertiesStore.ts | 25 ++ src/UI/Components/ToolBar/Properties_Dim.tsx | 243 ++++++++++++++++++ src/UI/Components/ToolBar/ToolBar.tsx | 1 + .../Components/ToolBar/ToolbarContainer.tsx | 22 +- src/UI/Layout/ApplicationLayout.tsx | 13 +- src/UI/Store/DownPanelStore.ts | 10 +- src/UI/Store/EntityStore.ts | 9 +- 19 files changed, 954 insertions(+), 75 deletions(-) create mode 100644 src/UI/Components/ToolBar/PropertiesPanel.less create mode 100644 src/UI/Components/ToolBar/PropertiesPanel.tsx create mode 100644 src/UI/Components/ToolBar/PropertiesStore.ts create mode 100644 src/UI/Components/ToolBar/Properties_Dim.tsx diff --git a/src/Add-on/DrawDim/AutoDimBrs.ts b/src/Add-on/DrawDim/AutoDimBrs.ts index 4799488c6..505cd1bd8 100644 --- a/src/Add-on/DrawDim/AutoDimBrs.ts +++ b/src/Add-on/DrawDim/AutoDimBrs.ts @@ -16,6 +16,10 @@ import { BoardType } from "../Erp/Models/CadBlock"; import { Entity } from "../../DatabaseServices/Entity/Entity"; import { OBB } from "../../Geometry/OBB/obb"; import { Math as TMath } from "three"; +import { Region } from "../../DatabaseServices/Entity/Region"; +import { BoolOpeartionType } from "../../GraphicsSystem/BoolOperateUtils"; +import { DownPanelStore, ToolBarType } from "../../UI/Store/DownPanelStore"; +import { PropertiesStore } from "../../UI/Components/ToolBar/PropertiesStore"; interface DirPls { @@ -76,6 +80,7 @@ export class Command_AutoDimBrs implements Command } } + let als: AlignedDimension[] = []; for (let brs of brGroups) { let spaceOcs = brs[0].SpaceOCS; @@ -99,10 +104,19 @@ export class Command_AutoDimBrs implements Command .copyPosition(spaceOcs); //绘制右侧标注(俯视图) - this.DrawDim(brs, right, -Math.PI); + let alss = this.DrawDim(brs, right, -Math.PI); //绘制前视图的标注 - await this.DrawFrontDim(brs, -Math.PI); + let alsfront = await this.DrawFrontDim(brs, -Math.PI); + als.push(...(alss ?? []), ...(alsfront ?? [])); + } + //打开特性面板 + let propsStore = PropertiesStore.GetInstance() as PropertiesStore; + for (let a of als) + { + propsStore.AddEnToMap(a); } + let downStore = DownPanelStore.GetInstance() as DownPanelStore; + downStore.showToolBar = ToolBarType.both; } /** @@ -138,16 +152,15 @@ export class Command_AutoDimBrs implements Command await spaceParse.Parse(); app.Editor.UCSMatrix = oldUCS; - let pl = new Polyline(); - for (let cu of spaceParse.Outlines) + let pls = this.GetOutLineByBoolUnion(spaceParse.Polylines); + pls.forEach((pl) => { - pl.Join(cu); - cu.Erase(); - } - pl.CloseMark = true; + pl.CloseMark = true; + pl.OCS = spaceParse.Outlines[0].OCS; + }); //分析外轮廓上下左右并得到上下左右的板件 - let dirPls = this.JudgeOutlineDirection(pl, cs); + let dirPls = this.JudgeOutlineDirection(pls, cs); let dirBrs: DirBrs = { right: [], left: [], top: [], bottom: [] }; for (let key in dirPls) @@ -165,11 +178,15 @@ export class Command_AutoDimBrs implements Command dirBrs[key].push(...brs.filter(b => cuObb.intersectsOBB(b.OBB))); } } + + let als: AlignedDimension[] = []; //绘制标注 - if (dirBrs.top.length > 0) this.DrawDim(dirBrs.top, drawCS_top, textRo); - if (dirBrs.right.length > 0) this.DrawDim(dirBrs.right, drawCS_right, textRo); - if (dirBrs.left.length > 0) this.DrawDim(dirBrs.left, drawCS_left, textRo); - if (dirBrs.bottom.length > 0) this.DrawDim(dirBrs.bottom, drawCS_bottom); + if (dirBrs.top.length > 0) als.push(...this.DrawDim(dirBrs.top, drawCS_top, textRo)); + if (dirBrs.right.length > 0) als.push(...this.DrawDim(dirBrs.right, drawCS_right, textRo, false, false, true)); + if (dirBrs.left.length > 0) als.push(...this.DrawDim(dirBrs.left, drawCS_left, textRo)); + if (dirBrs.bottom.length > 0) als.push(...this.DrawDim(dirBrs.bottom, drawCS_bottom, undefined, false, false, true)); + + return als; } /** @@ -177,7 +194,7 @@ export class Command_AutoDimBrs implements Command * @param brs * @param drawCS 绘制标注的坐标系 */ - DrawDim(brs: Board[], drawCS: Matrix4, textRotation?: number, needJig?: boolean, useMaxZ?: boolean) + DrawDim(brs: Board[], drawCS: Matrix4, textRotation?: number, needJig: boolean = false, useMaxZ: boolean = false, isLeadOutFlipped: boolean = false) { let als: AlignedDimension[] = []; let foots: number[] = []; @@ -199,14 +216,14 @@ export class Command_AutoDimBrs implements Command arrayRemoveDuplicateBySort(foots, equalnn(1)); let drawY = minY - 20; - let armY = drawY - 100; + let armY = drawY - 90; let z = useMaxZ ? maxZ : minZ; - let drawYTotal = minY - 120; - let armYTotal = drawYTotal - 100; + let drawYTotal = minY - 230; + let armYTotal = drawYTotal - 80; - if (!needJig) + //draw总长标注 需要拖拽的FastDim不需要总长 仅有一块板时不需要总长 + if (!needJig && brs.length > 1) { - //draw总长 let alDimTotal = new AlignedDimension( new Vector3(foots[0], drawYTotal, z), new Vector3(foots[foots.length - 1], drawYTotal, z), @@ -215,8 +232,11 @@ export class Command_AutoDimBrs implements Command ); if (textRotation) alDimTotal.TextRotation = textRotation; + alDimTotal.LeadOutFlipped = isLeadOutFlipped; + alDimTotal.LeadOutVisible = true; alDimTotal.ApplyMatrix(drawCS); + als.push(alDimTotal); app.Database.ModelSpace.Append(alDimTotal); } @@ -234,16 +254,20 @@ export class Command_AutoDimBrs implements Command ); if (!equaln(textRotation, 0) && textRotation) alDim.TextRotation = textRotation; + alDim.LeadOutFlipped = isLeadOutFlipped; + alDim.LeadOutVisible = true; alDim.ApplyMatrix(drawCS); if (needJig) { - als.push(alDim); + alDim.LeadOutVisible = false; JigUtils.Draw(alDim); } else app.Database.ModelSpace.Append(alDim); + + als.push(alDim); } return als; } @@ -254,29 +278,46 @@ export class Command_AutoDimBrs implements Command * @param cs 参照坐标系 * @memberof Command_AutoDimBrs */ - JudgeOutlineDirection(pl: Polyline, cs: CoordinateSystem): DirPls + JudgeOutlineDirection(pls: Polyline[], cs: CoordinateSystem): DirPls { - let clockWise = pl.Area2 < 0;//true为顺时针 false为逆时针 let res: DirPls = { right: [], left: [], top: [], bottom: [] }; - for (let i = 0; i < pl.EndParam; i++) + for (let pl of pls) { - let cu = pl.GetCurveAtParam(i); - let derv = cu.GetFistDeriv(0).normalize(); - if (isParallelTo(derv, cs.XAxis)) + let clockWise = pl.Area2 < 0;//true为顺时针 false为逆时针 + for (let i = 0; i < pl.EndParam; i++) { - if (derv.dot(cs.XAxis) > 0) - clockWise ? res.top.push(cu) : res.bottom.push(cu); - else - clockWise ? res.bottom.push(cu) : res.top.push(cu); - } - else - { - if (derv.dot(cs.ZAxis) < 0) - clockWise ? res.right.push(cu) : res.left.push(cu); + let cu = pl.GetCurveAtParam(i); + let derv = cu.GetFistDeriv(0).normalize(); + if (isParallelTo(derv, cs.XAxis)) + { + if (derv.dot(cs.XAxis) > 0) + clockWise ? res.top.push(cu) : res.bottom.push(cu); + else + clockWise ? res.bottom.push(cu) : res.top.push(cu); + } else - clockWise ? res.left.push(cu) : res.right.push(cu); + { + if (derv.dot(cs.ZAxis) < 0) + clockWise ? res.right.push(cu) : res.left.push(cu); + else + clockWise ? res.left.push(cu) : res.right.push(cu); + } } } return res; } + + /** + * 通过轮廓并集得到最大外轮廓 + * @memberof Command_AutoDimBrs + */ + private GetOutLineByBoolUnion(pls: Polyline[]) + { + let reg = Region.CreateFromCurves([pls.shift()]); + for (let pl of pls) + reg.BooleanOper(Region.CreateFromCurves([pl]), BoolOpeartionType.Union); + + let plsRes = reg.ShapeManager.ShapeList.map(s => s.Outline.Curve) as Polyline[]; + return plsRes; + } } diff --git a/src/Common/Utils.ts b/src/Common/Utils.ts index 1ccd55cb6..f10fc8f42 100644 --- a/src/Common/Utils.ts +++ b/src/Common/Utils.ts @@ -3,6 +3,8 @@ import { Entity } from "../DatabaseServices/Entity/Entity"; import { equaln } from "../Geometry/GeUtils"; import { safeEval } from "./eval"; +//仅数字构成的3位字符串(不以0开头) +export const digitStrReg = /^[^0\D]\d{0,2}$/; export const commandReg = /[^A-Za-z0-9]/g; //仅可输入英文 export const onlyEnExpReg = /[^A-Za-z]/g; diff --git a/src/DatabaseServices/Dimension/AlignedDimension.ts b/src/DatabaseServices/Dimension/AlignedDimension.ts index 849906cbc..627bc7efc 100644 --- a/src/DatabaseServices/Dimension/AlignedDimension.ts +++ b/src/DatabaseServices/Dimension/AlignedDimension.ts @@ -1,4 +1,4 @@ -import { BufferGeometry, Line as TLine, Matrix3, Mesh, Object3D, Vector3, Vector2 } from "three"; +import { BufferGeometry, Line as TLine, Matrix3, Mesh, Object3D, Vector3, Vector2, Material } from "three"; import { ColorMaterial } from "../../Common/ColorPalette"; import { FixedNotZero } from "../../Common/Utils"; import { ObjectSnapMode } from "../../Editor/ObjectSnapMode"; @@ -11,10 +11,15 @@ import { Entity } from "../Entity/Entity"; import { Line } from "../Entity/Line"; import { Polyline } from "../Entity/Polyline"; import { Text, TextAligen } from "../Text/Text"; +import { safeEval } from "../../Common/eval"; let snapPolyline = new Polyline(); -snapPolyline.LineData = [{ pt: new Vector2, bul: 0 }, { pt: new Vector2, bul: 0 }, { pt: new Vector2, bul: 0 }, { pt: new Vector2, bul: 0 },]; - +snapPolyline.LineData = [{ pt: new Vector2, bul: 0 }, { pt: new Vector2, bul: 0 }, { pt: new Vector2, bul: 0 }, { pt: new Vector2, bul: 0 }, { pt: new Vector2, bul: 0 }, { pt: new Vector2, bul: 0 },]; +interface LeadOutLinePts +{ + dragPt: Vector3; + endPt: Vector3; +} /** * 对齐标注 * 存在子类重载(线性标注 LinearDimension) @@ -25,7 +30,18 @@ export class AlignedDimension extends Entity { private _Text = new Text(undefined, undefined, "yahei"); private _TextString: string; - + //引线 + private _LeadOutLine = new TLine(); + private _LeadOutOffsetY = 72; + private _LeadOutOffsetX = 30; + //引线是否反向(往左伸/往右伸) + private _LeadOutIsFlipped: boolean = false; + //引线的拖拽点和终点 + private _LeadOutPts: LeadOutLinePts = { dragPt: midPoint(this.m_ArmP1, this.m_ArmP2), endPt: new Vector3() }; + //文字是否比footer间距更宽 + private needLeadOut: boolean = true; + //是否由拖拽更新_LeadOutPts.dragPt. 关系到引线的update + private isDragLeadOutPt: boolean = false; constructor( //针脚 protected m_FootP1: Vector3 = new Vector3(), @@ -34,6 +50,8 @@ export class AlignedDimension extends Entity protected m_ArmP1: Vector3 = new Vector3(), protected m_ArmP2: Vector3 = new Vector3(), protected m_TextRotation: number = undefined, + //是否默认显示引线 + protected m_LeadOutVisible: boolean = false, ) { super(); @@ -121,6 +139,66 @@ export class AlignedDimension extends Entity this.Update(); } } + + set LeadOutVisible(visible: boolean) + { + this.m_LeadOutVisible = visible; + this.Update(); + } + + set LeadOutFlipped(isFlipped: boolean) + { + this._LeadOutIsFlipped = isFlipped; + this.Update(); + } + + toggleLeadOutVisible() + { + this.WriteAllObjectRecord(); + this.m_LeadOutVisible = !this.m_LeadOutVisible; + this.Update(); + } + + toggleLeadOutFlipped() + { + this.WriteAllObjectRecord(); + this._LeadOutIsFlipped = !this._LeadOutIsFlipped; + this.Update(); + } + + set LeadOutOffsetY(size: number) + { + this._LeadOutOffsetY = size; + this.Update(); + } + + set LeadOutOffsetX(size: number) + { + this._LeadOutOffsetX = size; + this.Update(); + } + + set TextSize(size: number) + { + this.WriteAllObjectRecord(); + this._Text.Height = size; + this.UpdateNeedLeadOut(size); + this.Update(); + } + + get TextSize() + { + return this._Text.Height; + } + UpdateNeedLeadOut(eachTextSize?: number) + { + let eachTextWidth = eachTextSize ? ~~(Math.abs(eachTextSize) / 2) : ~~(Math.abs(this.TextSize) / 2); + let distanceStr = FixedNotZero(this.m_ArmP1.distanceTo(this.m_ArmP2), 2); + let textWidth = new Vector3(distanceStr.length * (eachTextWidth)); + this.needLeadOut = safeEval(distanceStr) < distanceStr.length * (eachTextWidth); + return textWidth; + } + Explode() { this.UpdateText(); @@ -128,6 +206,8 @@ export class AlignedDimension extends Entity new Line(this.m_FootP1.clone(), this.m_ArmP1.clone()), new Line(this.m_ArmP2.clone(), this.m_ArmP1.clone()), new Line(this.m_ArmP2.clone(), this.m_FootP2.clone()), + new Line(midPoint(this.m_ArmP1, this.m_ArmP2), this._LeadOutPts.dragPt.clone()), + new Line(this._LeadOutPts.dragPt.clone(), this._LeadOutPts.endPt.clone()), this._Text.Clone() ].map(en => en.ApplyMatrix(this.OCS)); } @@ -145,6 +225,10 @@ export class AlignedDimension extends Entity return ent; } + CloneDrawObject(from: this) + { + } + //重载 protected OnlyRenderType = true; InitDrawObject(renderType: RenderType = RenderType.Wireframe): Object3D @@ -162,7 +246,7 @@ export class AlignedDimension extends Entity this.RepairText(); - obj.add(line, arrow1, arrow2, this._Text.DrawObject); + obj.add(line, arrow1, arrow2); this.UpdateDrawObject(renderType, obj); @@ -185,7 +269,8 @@ export class AlignedDimension extends Entity UpdateDrawObject(type: RenderType, obj: Object3D) { - let [line, arrow1, arrow2, textObj] = obj.children; + obj.remove(...obj.children.splice(3)); + let [line, arrow1, arrow2] = obj.children; BufferGeometryUtils.UpdatePts((line).geometry as BufferGeometry, [this.m_FootP1, this.m_ArmP1, this.m_ArmP2, this.m_FootP2]); let arrowSize = 10; @@ -202,18 +287,94 @@ export class AlignedDimension extends Entity arrow2.rotation.z = armAn + Math.PI / 2; arrow2.updateMatrix(); - this.UpdateText(); + //更新引线this._LeadOutLine 并返回新的字体位置 + let textPos = this.UpdateLeadOutLine(); + + this.UpdateText(textPos as Vector3); + obj.add(this._LeadOutLine, this._Text.DrawObject); + this.AsyncUpdated(); + this.isDragLeadOutPt = false; + } + + UpdateLeadOutLine(): Vector3 + { + let textPosition: Vector3 = midPoint(this.m_ArmP1, this.m_ArmP2); + if (this.m_LeadOutVisible) //引线可见 + { + let textWidth = this.UpdateNeedLeadOut(); + + if (this.needLeadOut) //需要引线 + { + //确定引线方向(确定引线所有点的位置) + if (this._LeadOutIsFlipped) //引线已翻转(朝左) + { + if (this.isDragLeadOutPt) //是否由拖拽更新dragPt + if (this._LeadOutPts.dragPt.x < textPosition.x)//已经拖过中线 改变endPt 改变朝向值 + { + this._LeadOutPts.endPt = this._LeadOutPts.dragPt.clone().sub(textWidth); + this._LeadOutIsFlipped = false; + } + else + { + this._LeadOutPts.endPt = this._LeadOutPts.dragPt.clone().add(textWidth); + this._LeadOutIsFlipped = true; + } + else //非拖拽 + { + this._LeadOutPts.dragPt = textPosition.clone().add(new Vector3(this._LeadOutOffsetX, -this._LeadOutOffsetY)); + this._LeadOutPts.endPt = this._LeadOutPts.dragPt.clone().add(textWidth); + } + } + else //引线未翻转(朝右) + { + if (this.isDragLeadOutPt)//是否由拖拽更新dragPt + if (this._LeadOutPts.dragPt.x > textPosition.x)//已经拖过中线 改变endPt 改变朝向值 + { + this._LeadOutPts.endPt = this._LeadOutPts.dragPt.clone().add(textWidth); + this._LeadOutIsFlipped = true; + } + else + { + this._LeadOutPts.endPt = this._LeadOutPts.dragPt.clone().sub(textWidth); + this._LeadOutIsFlipped = false; + } + else //非拖拽 + { + this._LeadOutPts.dragPt = textPosition.clone().sub(new Vector3(this._LeadOutOffsetX, this._LeadOutOffsetY)); + this._LeadOutPts.endPt = this._LeadOutPts.dragPt.clone().sub(textWidth); + } + } - obj.remove(obj.children[3]); - obj.add(this._Text.DrawObject); + this._LeadOutLine.geometry = BufferGeometryUtils.CreateFromPts([textPosition, this._LeadOutPts.dragPt, this._LeadOutPts.endPt]); + this._LeadOutLine.material = ColorMaterial.GetLineMaterial(this.ColorIndex); + this._LeadOutLine.visible = true; + textPosition = midPoint(this._LeadOutPts.dragPt, this._LeadOutPts.endPt); + } + else //不需要引线 + { + //使引线不可见 并将dragPt隐藏于托盘中点 + this._LeadOutPts.dragPt = midPoint(this.m_ArmP1, this.m_ArmP2); + this._LeadOutLine.geometry = BufferGeometryUtils.CreateFromPts([]); + this._LeadOutLine.visible = false; + } + } + else //引线不可见 + { + //使引线不可见 并将dragPt隐藏于托盘中点 + this._LeadOutPts.dragPt = midPoint(this.m_ArmP1, this.m_ArmP2); + this._LeadOutLine.geometry = BufferGeometryUtils.CreateFromPts([]); + this._LeadOutLine.visible = false; + } + return textPosition; } - UpdateText() + UpdateText(pos?: Vector3) { let textRo = this.m_TextRotation ?? angleAndX(this.m_ArmP1.clone().sub(this.m_ArmP2)); this._Text.TextString = this._TextString ? this._TextString : FixedNotZero(this.m_ArmP1.distanceTo(this.m_ArmP2), 2); - this._Text.Position = midPoint(this.m_ArmP1, this.m_ArmP2); + this._Text.Position = pos ? pos : midPoint(this.m_ArmP1, this.m_ArmP2); this._Text.TextRotation = textRo; + this._Text.ColorIndex = this._Color; this.RepairText(); } @@ -229,12 +390,26 @@ export class AlignedDimension extends Entity snapPolyline.LineData[1].pt.set(this.m_ArmP1.x, this.m_ArmP1.y); snapPolyline.LineData[2].pt.set(this.m_ArmP2.x, this.m_ArmP2.y); snapPolyline.LineData[3].pt.set(this.m_FootP2.x, this.m_FootP2.y); + snapPolyline.LineData[4].pt.set(this._LeadOutPts.dragPt.x, this._LeadOutPts.dragPt.y);//引线拖拽点 + snapPolyline.LineData[5].pt.set(this._LeadOutPts.endPt.x, this._LeadOutPts.endPt.y); return snapPolyline.GetObjectSnapPoints(snapMode, pickPoint, lastPoint, viewXform); } + UpdateDrawObjectMaterial(type: RenderType, obj: Object3D, material?: Material) + { + this.WriteAllObjectRecord(); + let colorMat = ColorMaterial.GetLineMaterial(this.ColorIndex); + this._LeadOutLine.material = colorMat; + let [line, arrow1, arrow2] = obj.children; + (line).material = colorMat; + (arrow1).material = colorMat; + (arrow2).material = colorMat; + this._Text.ColorIndex = this._Color; + } + GetGripPoints(): Array { - return [this.m_FootP1, this.m_FootP2, this.m_ArmP1, this.m_ArmP2, midPoint(this.m_ArmP1, this.m_ArmP2)].map(p => + return [this.m_FootP1, this.m_FootP2, this.m_ArmP1, this.m_ArmP2, midPoint(this.m_ArmP1, this.m_ArmP2), this._LeadOutPts.dragPt].map(p => { return p.clone().applyMatrix4(this.OCS); }); @@ -244,7 +419,17 @@ export class AlignedDimension extends Entity this.WriteAllObjectRecord(); for (let i of indexList) { - if (i >= 2) + if (i === 5) + { + //开始拖拽引线夹点(_LeadOutPts.dragPt) + this.isDragLeadOutPt = true; + vec = vec.clone().applyMatrix4(this.OCSInv.clone().setPosition(ZeroVec)); + this._LeadOutPts.dragPt.add(vec); + let calcV = this._LeadOutPts.dragPt.clone().sub(midPoint(this.m_ArmP1, this.m_ArmP2)); + this._LeadOutOffsetY = calcV.y * -1; + this._LeadOutOffsetX = Math.abs(calcV.x); + } + else if (i >= 2) { let p = this.TextPosition.add(vec).applyMatrix4(this.OCSInv); let l = new Line(this.m_ArmP1, this.m_ArmP2); @@ -253,6 +438,7 @@ export class AlignedDimension extends Entity this.m_ArmP1.add(v); this.m_ArmP2.add(v); + this._LeadOutPts.dragPt.add(v); } else { @@ -312,20 +498,33 @@ export class AlignedDimension extends Entity this.m_FootP1.fromArray(file.Read()); this.m_FootP2.fromArray(file.Read()); this.m_TextRotation = file.Read(); - if (ver > 2) - this._TextString = file.Read(); + this._TextString = file.Read(); + if (ver > 3) + { + this.m_LeadOutVisible = file.Read(); + this._LeadOutIsFlipped = file.Read(); + this._LeadOutPts.dragPt.fromArray(file.Read()); + this._LeadOutOffsetY = file.Read(); + this._LeadOutOffsetX = file.Read(); + } } //对象将自身数据写入到文件. WriteFile(file: CADFiler) { super.WriteFile(file); - file.Write(3); + file.Write(4); file.Write(this.m_ArmP1.toArray()); file.Write(this.m_ArmP2.toArray()); file.Write(this.m_FootP1.toArray()); file.Write(this.m_FootP2.toArray()); file.Write(this.m_TextRotation); file.Write(this._TextString); + + file.Write(this.m_LeadOutVisible); + file.Write(this._LeadOutIsFlipped); + file.Write(this._LeadOutPts.dragPt.toArray()); + file.Write(this._LeadOutOffsetY); + file.Write(this._LeadOutOffsetX); } //#endregion } diff --git a/src/DatabaseServices/Text/Text.ts b/src/DatabaseServices/Text/Text.ts index cfc8a6ca5..39c24a805 100644 --- a/src/DatabaseServices/Text/Text.ts +++ b/src/DatabaseServices/Text/Text.ts @@ -151,6 +151,8 @@ export class Text extends Entity } UpdateDrawObjectMaterial(type: RenderType, en: Object3D) { + if (en) + this.AsyncUpdateDrawObject(en); } GetGripPoints(): Array { diff --git a/src/Editor/BoardMoveTool.ts b/src/Editor/BoardMoveTool.ts index 3ebe21093..8d8e0f7d6 100644 --- a/src/Editor/BoardMoveTool.ts +++ b/src/Editor/BoardMoveTool.ts @@ -202,7 +202,7 @@ export class BoardMoveTool private UpdateDimensionDraw() { - if (!this._DrawDimPoints) + if (!this._DrawDimPoints || CommandState.CommandIng) { for (let dim of this._DrawDims) dim.Visible = false; diff --git a/src/UI/Components/CameraControlButton/CameraControlBtn.tsx b/src/UI/Components/CameraControlButton/CameraControlBtn.tsx index 0bea92345..1ec8e9ec9 100644 --- a/src/UI/Components/CameraControlButton/CameraControlBtn.tsx +++ b/src/UI/Components/CameraControlButton/CameraControlBtn.tsx @@ -8,7 +8,7 @@ import { app } from "../../../ApplicationServices/Application"; import { KeyBoard } from "../../../Common/KeyEnum"; import { commandMachine } from "../../../Editor/CommandMachine"; import { userConfig } from "../../../Editor/UserConfig"; -import { DownPanelStore } from "../../Store/DownPanelStore"; +import { DownPanelStore, ToolBarType } from "../../Store/DownPanelStore"; import { VisualStyleData } from "./IVisualType"; import { equalv3 } from "../../../Geometry/GeUtils"; @@ -173,6 +173,8 @@ export class CameraControlBtn extends React.Component<{}, {}> RenderControlsMenu = () => { + let downStore = DownPanelStore.GetInstance() as DownPanelStore; + let toolbarIsShow = (downStore.showToolBar === ToolBarType.toolbar) || (downStore.showToolBar === ToolBarType.both); return ( { { - (DownPanelStore.GetInstance() as DownPanelStore).showToolBar = !(DownPanelStore.GetInstance() as DownPanelStore).showToolBar; + downStore.showToolBar = toolbarIsShow ? + (downStore.showToolBar === ToolBarType.both ? ToolBarType.properties : ToolBarType.none) + : (downStore.showToolBar === ToolBarType.properties ? ToolBarType.both : ToolBarType.toolbar); + toolbarIsShow = !toolbarIsShow; this.HideMenu(); }} /> diff --git a/src/UI/Components/ColorPanel.tsx b/src/UI/Components/ColorPanel.tsx index d584e4414..eb150e93f 100644 --- a/src/UI/Components/ColorPanel.tsx +++ b/src/UI/Components/ColorPanel.tsx @@ -16,7 +16,7 @@ interface IColorProps } export class ColorPanel extends React.Component { - constructor(props) + constructor(props: Readonly) { super(props); this.state = { diff --git a/src/UI/Components/EntityModal/EntityColorList.tsx b/src/UI/Components/EntityModal/EntityColorList.tsx index c7f571560..7fef14cf3 100644 --- a/src/UI/Components/EntityModal/EntityColorList.tsx +++ b/src/UI/Components/EntityModal/EntityColorList.tsx @@ -4,7 +4,7 @@ import { observable } from 'mobx'; import { observer } from 'mobx-react'; import * as React from 'react'; import { ColorMaterial } from '../../../Common/ColorPalette'; -import { app } from '../../../ApplicationServices/Application'; +import { CommandWrap } from '../../../Editor/CommandMachine'; import { EntityStore } from '../../Store/EntityStore'; export const ColorItem = (props: { className: string, text: string, style?: React.CSSProperties, value?: number; }) => @@ -46,18 +46,21 @@ export class ColorModal extends React.Component<{ store?: EntityStore; }, {}> private changeEntityColor = (color: number[]) => { const store = this.props.store; - let ens = store.GetEntitys(); - if (color.length === 1) - ens.forEach(en => en.ColorIndex = color[0]); - else - ens.forEach((en, i) => en.ColorIndex = color[i]); - app.Editor.UpdateScreen(); + CommandWrap(() => + { + let ens = store.GetEntitys(); + if (color.length === 1) + ens.forEach(en => en.ColorIndex = color[0]); + else + ens.forEach((en, i) => { if (i < color.length) en.ColorIndex = color[i]; }); + }, "快捷特性修改颜色"); }; private handleMouseMove = (e: React.MouseEvent) => { let el = e.target as HTMLLIElement; - if (el.value !== undefined) - this.changeEntityColor([el.value]); + //!不能频繁的修改实体 + // if (el.value !== undefined) + // this.changeEntityColor([el.value]); }; private handleClick = (e: React.MouseEvent) => { @@ -107,7 +110,7 @@ export class ColorModal extends React.Component<{ store?: EntityStore; }, {}> className={Classes.LIST_UNSTYLED + " props-color-list"} onMouseDown={this.handleClick} onMouseMove={this.handleMouseMove} - onMouseLeave={() => this.changeEntityColor(Array.from(store.colorSet.keys()))} + //! onMouseLeave={() => this.changeEntityColor(Array.from(store.colorSet.keys()))} 不能频繁的修改实体 style={{ width: "128px", overflow: "hidden", diff --git a/src/UI/Components/Modal/LightModal.tsx b/src/UI/Components/Modal/LightModal.tsx index eebb24017..0b9b4f0a4 100644 --- a/src/UI/Components/Modal/LightModal.tsx +++ b/src/UI/Components/Modal/LightModal.tsx @@ -152,6 +152,7 @@ export class LightDataCom extends React.Component { color={"#" + light.Color.getHexString()} onChange={(color: string) => { + //FIXME: 频繁的修改实体又没有命令包装 light.Color = new Color(color); app.Editor.UpdateScreen(); }} @@ -166,6 +167,7 @@ export class LightDataCom extends React.Component { color={"#" + (light as HemisphereLight).GroundColor.getHexString()} onChange={(color: string) => { + //FIXME: 频繁的修改实体又没有命令包装 (light as HemisphereLight).GroundColor = new Color(color); app.Editor.UpdateScreen(); }} diff --git a/src/UI/Components/RightPanel/RightPanelButton.tsx b/src/UI/Components/RightPanel/RightPanelButton.tsx index 39b361419..f2c27cd5b 100644 --- a/src/UI/Components/RightPanel/RightPanelButton.tsx +++ b/src/UI/Components/RightPanel/RightPanelButton.tsx @@ -1,6 +1,7 @@ import React from "react"; import { Button } from "@blueprintjs/core"; import { RightPanelStore } from "../../Store/RightPanelStore/RightPanelStore"; +import { DownPanelStore, ToolBarType } from "../../Store/DownPanelStore"; export class RightPanelButton extends React.Component<{ store: RightPanelStore; }, { classname: string; }> { @@ -39,3 +40,46 @@ export class RightPanelButton extends React.Component<{ store: RightPanelStore; ); } } + +export class PropertiesPanelButton extends React.Component<{ store: DownPanelStore; }, { classname: string; }> +{ + btnEl: Button; + constructor(props) + { + super(props); + this.state = { + classname: "", + }; + this.handleClick = this.handleClick.bind(this); + } + + handleClick() + { + const store = this.props.store; + if (store.showToolBar === ToolBarType.both || store.showToolBar === ToolBarType.properties) + { + this.setState({ classname: "" }); + store.showToolBar = store.showToolBar === ToolBarType.both ? ToolBarType.toolbar : ToolBarType.none; + } + else + { + this.setState({ classname: "iconTransBtn" }); + store.showToolBar = store.showToolBar === ToolBarType.toolbar ? ToolBarType.both : ToolBarType.properties; + } + } + + render() + { + return ( +
+
+ ); + } +} diff --git a/src/UI/Components/ToolBar/PropertiesPanel.less b/src/UI/Components/ToolBar/PropertiesPanel.less new file mode 100644 index 000000000..bb89a2711 --- /dev/null +++ b/src/UI/Components/ToolBar/PropertiesPanel.less @@ -0,0 +1,146 @@ +.properties{ + width: 170px; + .bp3-card{ + padding: 5px; + height: 100%; + .header{ + span{ + font-size: 12px; + font-weight: 600; + } + margin: 10px 0; + display: flex; + justify-content: space-between; + background: #ced9e0; + padding: 0 5px; + align-items: center; + } + .select{ + .bp3-html-select{ + width: 100%; + select{ + height: 2.0rem; + line-height: 2.0rem; + min-height: 2.0rem; + } + >span{ + top: 2px; + } + } + } + >ul>li{ + margin: 5px 0 0 0 !important; + } + ul{//.props + width: 100% !important; + .li-title{ + background: #BFCCD6; + padding: 5px; + margin: 5px 0 0 0; + width: 100%; + } + >li{ + width: 100% !important; + } + .color{ + margin: 5px 0 0 0 !important; + width: 100% !important; + display: flex; + >label{ + width: 20%; + display: flex; + align-items: center; + justify-content: space-around; + flex-direction: column; + justify-content: end; + } + >ul{ + width: 100% !important; + .props-color{ + display: flex; + justify-content: space-between; + border: 1px ridge transparent; + &:hover{ + border: 1px ridge #394b59; + } + } + >li{ + >label{ + width: 100%; + } + >ul{//.props-color-list + >li{ + padding: 5px 0 0 0 !important; + } + } + } + } + } + .dal-editor{ + >ul>li{ + padding: 5px 0 0 0; + } + .outline{ + div{ + width: 100%; + display: flex; + justify-content: space-between; + align-items: center; + } + } + .text-editor{ + >div{ + >span{ + margin: auto 0; + } + >.numeric_input{ + width: 60%; + .bp3-input-group{ + width: 60%; + } + } + display: flex; + justify-content: space-between; + } + } + .leadout-editor{ + display: flex; + >span{ + width: 70%; + margin: auto 0; + align-items: center; + } + } + } + } + } +} +#PropertiesBtn{ + >div{ + background: #fff; + transform: perspective(3em) rotateY(40deg); + border-radius: 0 10px 10px 0; + } + .bp3-button.bp3-small + { + &.iconTransBtn{ + >span{ + transform: rotate(-90deg); + -webkit-transition: transform .25s linear; + -moz-transition: transform .25s linear; + -o-transition: transform .25s linear; + transition: transform .25s linear; + } + } + border-radius: 0 3px 3px 0; + min-height: 30px; + padding: 5px 5px 5px 0; + >span{ + transform: rotate(90deg); + -webkit-transition: transform .25s linear; + -moz-transition: transform .25s linear; + -o-transition: transform .25s linear; + transition: transform .25s linear; + } + } +} diff --git a/src/UI/Components/ToolBar/PropertiesPanel.tsx b/src/UI/Components/ToolBar/PropertiesPanel.tsx new file mode 100644 index 000000000..613a3acd6 --- /dev/null +++ b/src/UI/Components/ToolBar/PropertiesPanel.tsx @@ -0,0 +1,128 @@ +import React from "react"; +import { HTMLSelect, Button, Classes, Card } from "@blueprintjs/core"; +import { DownPanelStore, ToolBarType } from "../../Store/DownPanelStore"; +import { observer } from "mobx-react"; +import { PropertiesStore } from "./PropertiesStore"; +import { ColorModal } from "../EntityModal/EntityColorList"; +import { AlignedDimension } from "../../../DatabaseServices/Dimension/AlignedDimension"; +import { Properties_DimPanel } from "./Properties_Dim"; +import { Entity } from "../../../DatabaseServices/Entity/Entity"; +enum EntType +{ + AlignDim = "AlignedDimension", + Line = "Line", + PolyLine = "Polyline", + Circle = "Circle", + Arc = "Arc", + Curve = "Curve", + Extrude = "Extrude", +} +export interface PropertiesPanelProps +{ + store?: PropertiesStore; +} +@observer +export class PropertiesPanel extends React.Component +{ + componentWillUnmount() + { + this.props.store.Exit(); + } + Exit() + { + let downStore = DownPanelStore.GetInstance() as DownPanelStore; + downStore.showToolBar = ToolBarType.toolbar; + } + HandleSelectOnChange(e: React.ChangeEvent) + { + let store = this.props.store; + store.currentEnType = e.target.value; + store.GetCurrentColor(); + } + GetEntsByType(ents: Entity[], type: string) + { + let res: Entity[] = []; + switch (type) + { + case EntType.AlignDim: + res = ents.filter((e) => { return e instanceof AlignedDimension; }); + //todo: more + } + return res; + } + render() + { + let store = this.props.store; + let options = []; + let count = 0; + for (let [k, v] of store.enMap) + { + let label = k; + if (v.length > 1) + label += ` (${v.length.toString()})`; + count += v.length; + let value = k; + options.push({ label, value }); + } + if (count > 1) + { + options.unshift({ + label: `全部 (${count.toString()})`, value: "all" + }); + } + else if (count === 0) + options.unshift({ label: "无选择", value: "none" }); + let ents = store.GetEntitys(); + return ( +
+ +
+ 特性 +
+
+ this.HandleSelectOnChange(e)} + /> +
+
    + 常规 +
  • + +
  • + + { + ents.length > 0 && this.props.store.GetEntitys()[0]['Length'] !== undefined && + <> + 其他 +
  • + 长度: {store.GetEntitys()[0]['Length'].toFixed(2)} +
  • +
  • + 面积: {store.GetEntitys()[0]['Area'].toFixed(2)} +
  • + + } + { + ents.length > 0 && store.GetEntitys()[0] instanceof AlignedDimension && + <> + 其他 +
  • + +
  • + + } +
+ +
+
+ ); + } +} diff --git a/src/UI/Components/ToolBar/PropertiesStore.ts b/src/UI/Components/ToolBar/PropertiesStore.ts new file mode 100644 index 000000000..d0ef91a18 --- /dev/null +++ b/src/UI/Components/ToolBar/PropertiesStore.ts @@ -0,0 +1,25 @@ +import { Entity } from "../../../DatabaseServices/Entity/Entity"; +import { begin, end } from "xaop"; +import { app } from "../../../ApplicationServices/Application"; +import { EntityStore } from "../../Store/EntityStore"; + +export class PropertiesStore extends EntityStore +{ + constructor() + { + super(); + let selectCtrl = app.Editor.SelectCtrl; + begin(selectCtrl, selectCtrl.UpdateSelectEvent, () => + { + selectCtrl.SelectSet.SelectEntityList.forEach(ent => + { + if (ent instanceof Entity) + this.AddEnToMap(ent); + }); + }); + end(selectCtrl, selectCtrl.CanenEvent, () => + { + this.enMap.clear(); + }); + } +} diff --git a/src/UI/Components/ToolBar/Properties_Dim.tsx b/src/UI/Components/ToolBar/Properties_Dim.tsx new file mode 100644 index 000000000..7c7a8ab78 --- /dev/null +++ b/src/UI/Components/ToolBar/Properties_Dim.tsx @@ -0,0 +1,243 @@ +import React from "react"; +import { Card, Classes, Button, Slider, NumericInput, Position, Intent, Tooltip } from "@blueprintjs/core"; +import { app } from "../../../ApplicationServices/Application"; +import { KeyBoard } from "../../../Common/KeyEnum"; +import { safeEval } from "../../../Common/eval"; +import { AlignedDimension } from "../../../DatabaseServices/Dimension/AlignedDimension"; +import { observable } from "mobx"; +import { observer } from "mobx-react"; +import { PropertiesStore } from "./PropertiesStore"; +import { end, begin } from "xaop"; +import { Object3D } from "three"; +import { digitStrReg } from "../../../Common/Utils"; +import { CommandWrap } from "../../../Editor/CommandMachine"; +export interface Properties_DimPanelProps +{ + ents: AlignedDimension[]; +} + +@observer +export class Properties_DimPanel extends React.Component +{ + private removeFuncs: Function[] = []; + @observable outlineCheckDims: boolean = true; + @observable private dim_TextSize: number = 60; + private dim_InputEl: HTMLInputElement; + @observable private numericInputVal: string = ""; + @observable private isPopoverOpen: boolean = false; + componentDidMount() + { + this.outlineCheckDims = !(app.Viewer.OutlinePass.selectedObjects.length > 0); + let propsStore = PropertiesStore.GetInstance() as PropertiesStore; + let selectCtrl = app.Editor.SelectCtrl; + propsStore.isWorking = true; + this.removeFuncs.push( + end(selectCtrl, selectCtrl.UpdateSelectEvent, () => + { + this.outlineCheckDims = false; + }), + end(selectCtrl, selectCtrl.CanenEvent, () => + { + this.outlineCheckDims = true; + }), + begin((new AlignedDimension()).AsyncUpdated, () => + { + for (let al of this.props.ents) + { + app.Viewer.GripScene.Update(al.DrawObject); + } + }), + ); + } + componentWillUnmount() + { + for (let f of this.removeFuncs) + f(); + this.removeFuncs.length = 0; + } + private Dim_UseDefault(als: AlignedDimension[]) + { + CommandWrap(() => + { + this.dim_TextSize = 60; + for (let al of als) + { + al.TextSize = 60; + al.LeadOutOffsetY = 72; + al.LeadOutOffsetX = 30; + al.LeadOutVisible = true; + al.LeadOutFlipped = false; + this.numericInputVal = "60"; + // this.dim_InputEl.setState({ value: "60" }); + } + }, "重置标注形态"); + } + render() + { + let ents = this.props.ents; + return ( + +
    +
  • +
    + 亮显: +
    +
  • +
  • +
    + 文字尺寸: +
    + + { this.dim_InputEl = el; }} + selectAllOnFocus + onValueChange={(vn, vs) => + { + let isOK = digitStrReg.test(vs); + if (isOK || vs === "") + { + this.dim_InputEl.classList.remove("bp3-intent-danger"); + this.isPopoverOpen = false; + } + else + { + this.dim_InputEl.classList.add("bp3-intent-danger"); + this.isPopoverOpen = true; + } + }} + value={this.numericInputVal} + onFocus={(e) => + { + e.target.onkeydown = (e) => + { + if (e.keyCode === KeyBoard.Escape) + { + //@ts-ignore + e.target.blur(); + } + else if (e.keyCode === KeyBoard.Enter || e.keyCode === KeyBoard.Space) + { + if (!this.isPopoverOpen) + //@ts-ignore + e.target.blur(); + else + //@ts-ignore + e.target.focus(); + e.preventDefault(); + } + e.stopPropagation(); + }; + }} + onBlur={(e) => + { + let val = safeEval(e.target.value); + if (!isNaN(val)) + { + if (val <= 0 || val > 999) + app.Editor.Prompt('文字尺寸仅限1-999间的数字!'); + else + { + this.dim_TextSize = val; + CommandWrap(() => + { + for (let al of this.props.ents) + { + al.TextSize = val; + } + }, "修改标注字体大小"); + } + } + else + app.Editor.Prompt('文字尺寸仅限1-999间的数字!'); + }} + /> + +
    +
    + + { + this.numericInputVal = value.toString(); + this.dim_TextSize = value; + for (let al of ents) + { + al.TextSize = this.dim_TextSize; + } + }} + value={this.dim_TextSize} + vertical={false} + /> +
  • +
  • + 引线调整: +
    +
    +
  • +
  • +
  • +
+
+ ); + } +} diff --git a/src/UI/Components/ToolBar/ToolBar.tsx b/src/UI/Components/ToolBar/ToolBar.tsx index a65efedd9..661332152 100644 --- a/src/UI/Components/ToolBar/ToolBar.tsx +++ b/src/UI/Components/ToolBar/ToolBar.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import { commandMachine } from '../../../Editor/CommandMachine'; import { ICON_CDN } from '../../IconEnum'; import { ICommandIconInfo } from '../TopToolBar/TopToolBarInterface'; +import './PropertiesPanel.less'; export interface ToolBarProps { diff --git a/src/UI/Components/ToolBar/ToolbarContainer.tsx b/src/UI/Components/ToolBar/ToolbarContainer.tsx index 0b8fada1f..942134b22 100644 --- a/src/UI/Components/ToolBar/ToolbarContainer.tsx +++ b/src/UI/Components/ToolBar/ToolbarContainer.tsx @@ -1,9 +1,11 @@ import * as React from 'react'; import { IconEnum } from '../../IconEnum'; -import { DownPanelStore } from '../../Store/DownPanelStore'; +import { DownPanelStore, ToolBarType } from '../../Store/DownPanelStore'; import { ICommandIconInfo } from '../TopToolBar/TopToolBarInterface'; import { ToolBar } from './ToolBar'; import { observer } from 'mobx-react'; +import { PropertiesPanel } from './PropertiesPanel'; +import { PropertiesStore } from './PropertiesStore'; @observer export class ToolbarContainer extends React.Component<{}, {}> { @@ -29,13 +31,23 @@ export class ToolbarContainer extends React.Component<{}, {}> { { svg: IconEnum.EditPolyLine, title: "编辑多段线", command: "PE" }, { svg: IconEnum.Explode, title: "分解", command: "X" }, ]; + let downStore = DownPanelStore.GetInstance() as DownPanelStore; + let pStore = PropertiesStore.GetInstance() as PropertiesStore; return (
- + { + downStore.showToolBar === ToolBarType.properties ? + + : downStore.showToolBar === ToolBarType.toolbar ? + : + <> + + + + + }
); } diff --git a/src/UI/Layout/ApplicationLayout.tsx b/src/UI/Layout/ApplicationLayout.tsx index e8d017351..69836c701 100644 --- a/src/UI/Layout/ApplicationLayout.tsx +++ b/src/UI/Layout/ApplicationLayout.tsx @@ -17,7 +17,7 @@ import { TopToolBar } from '../Components/TopToolBar/TopToolBar'; import { DownPanelStore } from '../Store/DownPanelStore'; import { RightPanelStore } from '../Store/RightPanelStore/RightPanelStore'; import { TopPanelStore } from '../Store/TopPanelStore'; -import { RightPanelButton } from '../Components/RightPanel/RightPanelButton'; +import { RightPanelButton, PropertiesPanelButton } from '../Components/RightPanel/RightPanelButton'; export let appUi: WebCAD; @@ -169,6 +169,17 @@ export class WebCAD } renderToolBar() { + let downStore = DownPanelStore.GetInstance(); + let propertiesBtn = document.createElement('div'); + propertiesBtn.id = "PropertiesBtn"; + propertiesBtn.style.cssText = ` + position: absolute; + top:calc(100%/2.2); + left:0; + z-index:${ZINDEX.Common}; `; + document.getElementById("Webgl").appendChild(propertiesBtn); + ReactDOM.render(, propertiesBtn); + let toolbarEl = document.createElement("div"); toolbarEl.id = "toolbar"; toolbarEl.style.display = "flex"; diff --git a/src/UI/Store/DownPanelStore.ts b/src/UI/Store/DownPanelStore.ts index 3b2d7cfae..786c45793 100644 --- a/src/UI/Store/DownPanelStore.ts +++ b/src/UI/Store/DownPanelStore.ts @@ -14,13 +14,21 @@ function PointToString(pt: Vector3): string }).join(","); } +export enum ToolBarType +{ + both = 3,//同时显示工具和特性 + toolbar = 1,//显示工具 + properties = 2,//显示特性 + none = 0,//不显示 +} + /** * 底部状态栏. */ export class DownPanelStore extends Singleton { @observable useDynInput: boolean = true; - @observable showToolBar: boolean = true; + @observable showToolBar: ToolBarType = 1; @observable useDynSnap: boolean = true; @observable usePass: boolean = true; @observable useOrtho: boolean = false; diff --git a/src/UI/Store/EntityStore.ts b/src/UI/Store/EntityStore.ts index bba945f26..c059327de 100644 --- a/src/UI/Store/EntityStore.ts +++ b/src/UI/Store/EntityStore.ts @@ -7,6 +7,8 @@ import { Line } from "../../DatabaseServices/Entity/Line"; import { Polyline } from "../../DatabaseServices/Entity/Polyline"; import { Region } from "../../DatabaseServices/Entity/Region"; import { Ellipse } from "../../DatabaseServices/Entity/Ellipse"; +import { AlignedDimension } from "../../DatabaseServices/Dimension/AlignedDimension"; +import { Text } from "../../DatabaseServices/Text/Text"; export class EntityStore extends Singleton { @@ -46,6 +48,10 @@ export class EntityStore extends Singleton addEnToMap("圆弧", en); else if (en instanceof Ellipse) addEnToMap("椭圆", en); + else if (en instanceof AlignedDimension) + addEnToMap("对齐标注", en); + else if (en instanceof Text) + addEnToMap("文字", en); else addEnToMap("三维实体", en); @@ -60,7 +66,8 @@ export class EntityStore extends Singleton ens.push(...v); } else - ens = this.enMap.get(this.currentEnType); + if (this.enMap.has(this.currentEnType)) + ens = this.enMap.get(this.currentEnType); return ens; } GetCurrentColor()