!515 自动标注字体尺寸调整 增加引线

pull/515/MERGE
肖诗雅 5 years ago committed by ChenX
parent 507cd45ba6
commit 61a9e07805

@ -16,6 +16,10 @@ import { BoardType } from "../Erp/Models/CadBlock";
import { Entity } from "../../DatabaseServices/Entity/Entity"; import { Entity } from "../../DatabaseServices/Entity/Entity";
import { OBB } from "../../Geometry/OBB/obb"; import { OBB } from "../../Geometry/OBB/obb";
import { Math as TMath } from "three"; 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 interface DirPls
{ {
@ -76,6 +80,7 @@ export class Command_AutoDimBrs implements Command
} }
} }
let als: AlignedDimension[] = [];
for (let brs of brGroups) for (let brs of brGroups)
{ {
let spaceOcs = brs[0].SpaceOCS; let spaceOcs = brs[0].SpaceOCS;
@ -99,10 +104,19 @@ export class Command_AutoDimBrs implements Command
.copyPosition(spaceOcs); .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(); await spaceParse.Parse();
app.Editor.UCSMatrix = oldUCS; app.Editor.UCSMatrix = oldUCS;
let pl = new Polyline(); let pls = this.GetOutLineByBoolUnion(spaceParse.Polylines);
for (let cu of spaceParse.Outlines) 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: [] }; let dirBrs: DirBrs = { right: [], left: [], top: [], bottom: [] };
for (let key in dirPls) 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))); 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.top.length > 0) als.push(...this.DrawDim(dirBrs.top, drawCS_top, textRo));
if (dirBrs.right.length > 0) this.DrawDim(dirBrs.right, drawCS_right, textRo); if (dirBrs.right.length > 0) als.push(...this.DrawDim(dirBrs.right, drawCS_right, textRo, false, false, true));
if (dirBrs.left.length > 0) this.DrawDim(dirBrs.left, drawCS_left, textRo); if (dirBrs.left.length > 0) als.push(...this.DrawDim(dirBrs.left, drawCS_left, textRo));
if (dirBrs.bottom.length > 0) this.DrawDim(dirBrs.bottom, drawCS_bottom); 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 brs
* @param drawCS * @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 als: AlignedDimension[] = [];
let foots: number[] = []; let foots: number[] = [];
@ -199,14 +216,14 @@ export class Command_AutoDimBrs implements Command
arrayRemoveDuplicateBySort(foots, equalnn(1)); arrayRemoveDuplicateBySort(foots, equalnn(1));
let drawY = minY - 20; let drawY = minY - 20;
let armY = drawY - 100; let armY = drawY - 90;
let z = useMaxZ ? maxZ : minZ; let z = useMaxZ ? maxZ : minZ;
let drawYTotal = minY - 120; let drawYTotal = minY - 230;
let armYTotal = drawYTotal - 100; let armYTotal = drawYTotal - 80;
if (!needJig) //draw总长标注 需要拖拽的FastDim不需要总长 仅有一块板时不需要总长
if (!needJig && brs.length > 1)
{ {
//draw总长
let alDimTotal = new AlignedDimension( let alDimTotal = new AlignedDimension(
new Vector3(foots[0], drawYTotal, z), new Vector3(foots[0], drawYTotal, z),
new Vector3(foots[foots.length - 1], drawYTotal, z), new Vector3(foots[foots.length - 1], drawYTotal, z),
@ -215,8 +232,11 @@ export class Command_AutoDimBrs implements Command
); );
if (textRotation) if (textRotation)
alDimTotal.TextRotation = textRotation; alDimTotal.TextRotation = textRotation;
alDimTotal.LeadOutFlipped = isLeadOutFlipped;
alDimTotal.LeadOutVisible = true;
alDimTotal.ApplyMatrix(drawCS); alDimTotal.ApplyMatrix(drawCS);
als.push(alDimTotal);
app.Database.ModelSpace.Append(alDimTotal); app.Database.ModelSpace.Append(alDimTotal);
} }
@ -234,16 +254,20 @@ export class Command_AutoDimBrs implements Command
); );
if (!equaln(textRotation, 0) && textRotation) if (!equaln(textRotation, 0) && textRotation)
alDim.TextRotation = textRotation; alDim.TextRotation = textRotation;
alDim.LeadOutFlipped = isLeadOutFlipped;
alDim.LeadOutVisible = true;
alDim.ApplyMatrix(drawCS); alDim.ApplyMatrix(drawCS);
if (needJig) if (needJig)
{ {
als.push(alDim); alDim.LeadOutVisible = false;
JigUtils.Draw(alDim); JigUtils.Draw(alDim);
} }
else else
app.Database.ModelSpace.Append(alDim); app.Database.ModelSpace.Append(alDim);
als.push(alDim);
} }
return als; return als;
} }
@ -254,10 +278,12 @@ export class Command_AutoDimBrs implements Command
* @param cs * @param cs
* @memberof Command_AutoDimBrs * @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: [] }; let res: DirPls = { right: [], left: [], top: [], bottom: [] };
for (let pl of pls)
{
let clockWise = pl.Area2 < 0;//true为顺时针 false为逆时针
for (let i = 0; i < pl.EndParam; i++) for (let i = 0; i < pl.EndParam; i++)
{ {
let cu = pl.GetCurveAtParam(i); let cu = pl.GetCurveAtParam(i);
@ -277,6 +303,21 @@ export class Command_AutoDimBrs implements Command
clockWise ? res.left.push(cu) : res.right.push(cu); clockWise ? res.left.push(cu) : res.right.push(cu);
} }
} }
}
return res; 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;
}
} }

@ -3,6 +3,8 @@ import { Entity } from "../DatabaseServices/Entity/Entity";
import { equaln } from "../Geometry/GeUtils"; import { equaln } from "../Geometry/GeUtils";
import { safeEval } from "./eval"; import { safeEval } from "./eval";
//仅数字构成的3位字符串(不以0开头)
export const digitStrReg = /^[^0\D]\d{0,2}$/;
export const commandReg = /[^A-Za-z0-9]/g; export const commandReg = /[^A-Za-z0-9]/g;
//仅可输入英文 //仅可输入英文
export const onlyEnExpReg = /[^A-Za-z]/g; export const onlyEnExpReg = /[^A-Za-z]/g;

@ -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 { ColorMaterial } from "../../Common/ColorPalette";
import { FixedNotZero } from "../../Common/Utils"; import { FixedNotZero } from "../../Common/Utils";
import { ObjectSnapMode } from "../../Editor/ObjectSnapMode"; import { ObjectSnapMode } from "../../Editor/ObjectSnapMode";
@ -11,10 +11,15 @@ import { Entity } from "../Entity/Entity";
import { Line } from "../Entity/Line"; import { Line } from "../Entity/Line";
import { Polyline } from "../Entity/Polyline"; import { Polyline } from "../Entity/Polyline";
import { Text, TextAligen } from "../Text/Text"; import { Text, TextAligen } from "../Text/Text";
import { safeEval } from "../../Common/eval";
let snapPolyline = new Polyline(); 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) * (线 LinearDimension)
@ -25,7 +30,18 @@ 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 _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( constructor(
//针脚 //针脚
protected m_FootP1: Vector3 = new Vector3(), protected m_FootP1: Vector3 = new Vector3(),
@ -34,6 +50,8 @@ export class AlignedDimension extends Entity
protected m_ArmP1: Vector3 = new Vector3(), protected m_ArmP1: Vector3 = new Vector3(),
protected m_ArmP2: Vector3 = new Vector3(), protected m_ArmP2: Vector3 = new Vector3(),
protected m_TextRotation: number = undefined, protected m_TextRotation: number = undefined,
//是否默认显示引线
protected m_LeadOutVisible: boolean = false,
) )
{ {
super(); super();
@ -121,6 +139,66 @@ export class AlignedDimension extends Entity
this.Update(); 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() Explode()
{ {
this.UpdateText(); 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_FootP1.clone(), this.m_ArmP1.clone()),
new Line(this.m_ArmP2.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(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() this._Text.Clone()
].map(en => en.ApplyMatrix(this.OCS)); ].map(en => en.ApplyMatrix(this.OCS));
} }
@ -145,6 +225,10 @@ export class AlignedDimension extends Entity
return ent; return ent;
} }
CloneDrawObject(from: this)
{
}
//重载 //重载
protected OnlyRenderType = true; protected OnlyRenderType = true;
InitDrawObject(renderType: RenderType = RenderType.Wireframe): Object3D InitDrawObject(renderType: RenderType = RenderType.Wireframe): Object3D
@ -162,7 +246,7 @@ export class AlignedDimension extends Entity
this.RepairText(); this.RepairText();
obj.add(line, arrow1, arrow2, this._Text.DrawObject); obj.add(line, arrow1, arrow2);
this.UpdateDrawObject(renderType, obj); this.UpdateDrawObject(renderType, obj);
@ -185,7 +269,8 @@ export class AlignedDimension extends Entity
UpdateDrawObject(type: RenderType, obj: Object3D) 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((<TLine>line).geometry as BufferGeometry, [this.m_FootP1, this.m_ArmP1, this.m_ArmP2, this.m_FootP2]); BufferGeometryUtils.UpdatePts((<TLine>line).geometry as BufferGeometry, [this.m_FootP1, this.m_ArmP1, this.m_ArmP2, this.m_FootP2]);
let arrowSize = 10; let arrowSize = 10;
@ -202,18 +287,94 @@ export class AlignedDimension extends Entity
arrow2.rotation.z = armAn + Math.PI / 2; arrow2.rotation.z = armAn + Math.PI / 2;
arrow2.updateMatrix(); arrow2.updateMatrix();
this.UpdateText(); //更新引线this._LeadOutLine 并返回新的字体位置
let textPos = this.UpdateLeadOutLine();
obj.remove(obj.children[3]); this.UpdateText(textPos as Vector3);
obj.add(this._Text.DrawObject); obj.add(this._LeadOutLine, this._Text.DrawObject);
this.AsyncUpdated();
this.isDragLeadOutPt = false;
} }
UpdateText() 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);
}
}
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(pos?: Vector3)
{ {
let textRo = this.m_TextRotation ?? angleAndX(this.m_ArmP1.clone().sub(this.m_ArmP2)); 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.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.TextRotation = textRo;
this._Text.ColorIndex = this._Color;
this.RepairText(); 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[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[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[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); 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;
(<Mesh>line).material = colorMat;
(<Mesh>arrow1).material = colorMat;
(<Mesh>arrow2).material = colorMat;
this._Text.ColorIndex = this._Color;
}
GetGripPoints(): Array<Vector3> GetGripPoints(): Array<Vector3>
{ {
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); return p.clone().applyMatrix4(this.OCS);
}); });
@ -244,7 +419,17 @@ export class AlignedDimension extends Entity
this.WriteAllObjectRecord(); this.WriteAllObjectRecord();
for (let i of indexList) 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 p = this.TextPosition.add(vec).applyMatrix4(this.OCSInv);
let l = new Line(this.m_ArmP1, this.m_ArmP2); 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_ArmP1.add(v);
this.m_ArmP2.add(v); this.m_ArmP2.add(v);
this._LeadOutPts.dragPt.add(v);
} }
else else
{ {
@ -312,20 +498,33 @@ export class AlignedDimension extends Entity
this.m_FootP1.fromArray(file.Read()); this.m_FootP1.fromArray(file.Read());
this.m_FootP2.fromArray(file.Read()); this.m_FootP2.fromArray(file.Read());
this.m_TextRotation = 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) WriteFile(file: CADFiler)
{ {
super.WriteFile(file); super.WriteFile(file);
file.Write(3); file.Write(4);
file.Write(this.m_ArmP1.toArray()); file.Write(this.m_ArmP1.toArray());
file.Write(this.m_ArmP2.toArray()); file.Write(this.m_ArmP2.toArray());
file.Write(this.m_FootP1.toArray()); file.Write(this.m_FootP1.toArray());
file.Write(this.m_FootP2.toArray()); file.Write(this.m_FootP2.toArray());
file.Write(this.m_TextRotation); file.Write(this.m_TextRotation);
file.Write(this._TextString); 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 //#endregion
} }

@ -151,6 +151,8 @@ export class Text extends Entity
} }
UpdateDrawObjectMaterial(type: RenderType, en: Object3D) UpdateDrawObjectMaterial(type: RenderType, en: Object3D)
{ {
if (en)
this.AsyncUpdateDrawObject(en);
} }
GetGripPoints(): Array<Vector3> GetGripPoints(): Array<Vector3>
{ {

@ -202,7 +202,7 @@ export class BoardMoveTool
private UpdateDimensionDraw() private UpdateDimensionDraw()
{ {
if (!this._DrawDimPoints) if (!this._DrawDimPoints || CommandState.CommandIng)
{ {
for (let dim of this._DrawDims) for (let dim of this._DrawDims)
dim.Visible = false; dim.Visible = false;

@ -8,7 +8,7 @@ import { app } from "../../../ApplicationServices/Application";
import { KeyBoard } from "../../../Common/KeyEnum"; import { KeyBoard } from "../../../Common/KeyEnum";
import { commandMachine } from "../../../Editor/CommandMachine"; import { commandMachine } from "../../../Editor/CommandMachine";
import { userConfig } from "../../../Editor/UserConfig"; import { userConfig } from "../../../Editor/UserConfig";
import { DownPanelStore } from "../../Store/DownPanelStore"; import { DownPanelStore, ToolBarType } from "../../Store/DownPanelStore";
import { VisualStyleData } from "./IVisualType"; import { VisualStyleData } from "./IVisualType";
import { equalv3 } from "../../../Geometry/GeUtils"; import { equalv3 } from "../../../Geometry/GeUtils";
@ -173,6 +173,8 @@ export class CameraControlBtn extends React.Component<{}, {}>
RenderControlsMenu = () => RenderControlsMenu = () =>
{ {
let downStore = DownPanelStore.GetInstance() as DownPanelStore;
let toolbarIsShow = (downStore.showToolBar === ToolBarType.toolbar) || (downStore.showToolBar === ToolBarType.both);
return ( return (
<Menu <Menu
className="controlsMenu-fixed" className="controlsMenu-fixed"
@ -191,10 +193,13 @@ export class CameraControlBtn extends React.Component<{}, {}>
{ {
<MenuItem <MenuItem
text="工具条" text="工具条"
icon={(DownPanelStore.GetInstance() as DownPanelStore).showToolBar ? "tick" : "blank"} icon={toolbarIsShow ? "tick" : "blank"}
onClick={() => onClick={() =>
{ {
(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(); this.HideMenu();
}} }}
/> />

@ -16,7 +16,7 @@ interface IColorProps
} }
export class ColorPanel extends React.Component<IColorProps, IColorState> export class ColorPanel extends React.Component<IColorProps, IColorState>
{ {
constructor(props) constructor(props: Readonly<IColorProps>)
{ {
super(props); super(props);
this.state = { this.state = {

@ -4,7 +4,7 @@ import { observable } from 'mobx';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import * as React from 'react'; import * as React from 'react';
import { ColorMaterial } from '../../../Common/ColorPalette'; import { ColorMaterial } from '../../../Common/ColorPalette';
import { app } from '../../../ApplicationServices/Application'; import { CommandWrap } from '../../../Editor/CommandMachine';
import { EntityStore } from '../../Store/EntityStore'; import { EntityStore } from '../../Store/EntityStore';
export const ColorItem = (props: { className: string, text: string, style?: React.CSSProperties, value?: number; }) => 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[]) => private changeEntityColor = (color: number[]) =>
{ {
const store = this.props.store; const store = this.props.store;
CommandWrap(() =>
{
let ens = store.GetEntitys(); let ens = store.GetEntitys();
if (color.length === 1) if (color.length === 1)
ens.forEach(en => en.ColorIndex = color[0]); ens.forEach(en => en.ColorIndex = color[0]);
else else
ens.forEach((en, i) => en.ColorIndex = color[i]); ens.forEach((en, i) => { if (i < color.length) en.ColorIndex = color[i]; });
app.Editor.UpdateScreen(); }, "快捷特性修改颜色");
}; };
private handleMouseMove = (e: React.MouseEvent<HTMLUListElement>) => private handleMouseMove = (e: React.MouseEvent<HTMLUListElement>) =>
{ {
let el = e.target as HTMLLIElement; 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<HTMLUListElement>) => private handleClick = (e: React.MouseEvent<HTMLUListElement>) =>
{ {
@ -107,7 +110,7 @@ export class ColorModal extends React.Component<{ store?: EntityStore; }, {}>
className={Classes.LIST_UNSTYLED + " props-color-list"} className={Classes.LIST_UNSTYLED + " props-color-list"}
onMouseDown={this.handleClick} onMouseDown={this.handleClick}
onMouseMove={this.handleMouseMove} onMouseMove={this.handleMouseMove}
onMouseLeave={() => this.changeEntityColor(Array.from(store.colorSet.keys()))} //! onMouseLeave={() => this.changeEntityColor(Array.from(store.colorSet.keys()))} 不能频繁的修改实体
style={{ style={{
width: "128px", width: "128px",
overflow: "hidden", overflow: "hidden",

@ -152,6 +152,7 @@ export class LightDataCom extends React.Component<ILightComponentProps, {}> {
color={"#" + light.Color.getHexString()} color={"#" + light.Color.getHexString()}
onChange={(color: string) => onChange={(color: string) =>
{ {
//FIXME: 频繁的修改实体又没有命令包装
light.Color = new Color(color); light.Color = new Color(color);
app.Editor.UpdateScreen(); app.Editor.UpdateScreen();
}} }}
@ -166,6 +167,7 @@ export class LightDataCom extends React.Component<ILightComponentProps, {}> {
color={"#" + (light as HemisphereLight).GroundColor.getHexString()} color={"#" + (light as HemisphereLight).GroundColor.getHexString()}
onChange={(color: string) => onChange={(color: string) =>
{ {
//FIXME: 频繁的修改实体又没有命令包装
(light as HemisphereLight).GroundColor = new Color(color); (light as HemisphereLight).GroundColor = new Color(color);
app.Editor.UpdateScreen(); app.Editor.UpdateScreen();
}} }}

@ -1,6 +1,7 @@
import React from "react"; import React from "react";
import { Button } from "@blueprintjs/core"; import { Button } from "@blueprintjs/core";
import { RightPanelStore } from "../../Store/RightPanelStore/RightPanelStore"; import { RightPanelStore } from "../../Store/RightPanelStore/RightPanelStore";
import { DownPanelStore, ToolBarType } from "../../Store/DownPanelStore";
export class RightPanelButton extends React.Component<{ store: RightPanelStore; }, { classname: string; }> 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 (
<div>
<Button
className={this.state.classname}
ref={el => this.btnEl = el}
small={true}
onClick={this.handleClick}
icon="eject"
/>
</div>
);
}
}

@ -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;
}
}
}

@ -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<PropertiesPanelProps, {}>
{
componentWillUnmount()
{
this.props.store.Exit();
}
Exit()
{
let downStore = DownPanelStore.GetInstance() as DownPanelStore;
downStore.showToolBar = ToolBarType.toolbar;
}
HandleSelectOnChange(e: React.ChangeEvent<HTMLSelectElement>)
{
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 (
<div className="properties">
<Card>
<div className="header">
<span></span>
<Button
icon="small-cross"
small
minimal
onClick={() => this.Exit()}
/>
</div>
<div className="select">
<HTMLSelect
value={store.currentEnType}
options={options}
onChange={e => this.HandleSelectOnChange(e)}
/>
</div>
<ul className={"props " + Classes.LIST_UNSTYLED}>
<span className="li-title"></span>
<li className="color">
<ColorModal store={store} />
</li>
{
ents.length > 0 && this.props.store.GetEntitys()[0]['Length'] !== undefined &&
<>
<span className="li-title"></span>
<li>
: {store.GetEntitys()[0]['Length'].toFixed(2)}
</li>
<li>
: {store.GetEntitys()[0]['Area'].toFixed(2)}
</li>
</>
}
{
ents.length > 0 && store.GetEntitys()[0] instanceof AlignedDimension &&
<>
<span className="li-title"></span>
<li>
<Properties_DimPanel ents={this.GetEntsByType(ents, EntType.AlignDim) as AlignedDimension[]} />
</li>
</>
}
</ul>
</Card>
</div>
);
}
}

@ -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();
});
}
}

@ -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<Properties_DimPanelProps, {}>
{
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 (
<Card className={"dal-editor"}>
<ul className={Classes.LIST_UNSTYLED}>
<li className="outline">
<div>
<span>: </span>
<Button
className={Classes.INTENT_PRIMARY}
icon={this.outlineCheckDims ? "eye-open" : "eye-off"}
text={this.outlineCheckDims ? "亮显查看" : "关闭亮显"}
minimal
small
onClick={() =>
{
if (this.outlineCheckDims && app.Viewer.OutlinePass.selectedObjects.length === 0)
{
let alobjs: Object3D[] = [];
for (let al of ents)
{
let obj = al.DrawObject;
alobjs.push(obj);
app.Viewer.GripScene.Append(obj);
}
app.Viewer.OutlinePass.selectedObjects = alobjs;
}
else
{
app.Viewer.OutlinePass.selectedObjects = [];
app.Viewer.GripScene.Clear();
}
app.Viewer.Render();
this.outlineCheckDims = !this.outlineCheckDims;
}}
/>
</div>
</li>
<li className="text-editor">
<div>
<span>: </span>
<div className="numeric_input">
<Tooltip
content={"仅限1-999间的数字!"}
position={Position.TOP}
intent={Intent.WARNING}
isOpen={this.isPopoverOpen}
>
<NumericInput
min={1}
stepSize={1}
minorStepSize={1}
inputRef={el => { 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间的数字!');
}}
/>
</Tooltip>
</div>
</div>
<Slider
min={20}
max={150}
stepSize={5}
labelStepSize={25}
onChange={(value) =>
{
this.numericInputVal = value.toString();
this.dim_TextSize = value;
for (let al of ents)
{
al.TextSize = this.dim_TextSize;
}
}}
value={this.dim_TextSize}
vertical={false}
/>
</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>
<Button className={Classes.INTENT_WARNING} text="重置为默认" minimal small onClick={() => this.Dim_UseDefault(ents)} />
</li>
</ul>
</Card>
);
}
}

@ -2,6 +2,7 @@ import * as React from 'react';
import { commandMachine } from '../../../Editor/CommandMachine'; import { commandMachine } from '../../../Editor/CommandMachine';
import { ICON_CDN } from '../../IconEnum'; import { ICON_CDN } from '../../IconEnum';
import { ICommandIconInfo } from '../TopToolBar/TopToolBarInterface'; import { ICommandIconInfo } from '../TopToolBar/TopToolBarInterface';
import './PropertiesPanel.less';
export interface ToolBarProps export interface ToolBarProps
{ {

@ -1,9 +1,11 @@
import * as React from 'react'; import * as React from 'react';
import { IconEnum } from '../../IconEnum'; import { IconEnum } from '../../IconEnum';
import { DownPanelStore } from '../../Store/DownPanelStore'; import { DownPanelStore, ToolBarType } from '../../Store/DownPanelStore';
import { ICommandIconInfo } from '../TopToolBar/TopToolBarInterface'; import { ICommandIconInfo } from '../TopToolBar/TopToolBarInterface';
import { ToolBar } from './ToolBar'; import { ToolBar } from './ToolBar';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { PropertiesPanel } from './PropertiesPanel';
import { PropertiesStore } from './PropertiesStore';
@observer @observer
export class ToolbarContainer extends React.Component<{}, {}> { export class ToolbarContainer extends React.Component<{}, {}> {
@ -29,13 +31,23 @@ export class ToolbarContainer extends React.Component<{}, {}> {
{ svg: IconEnum.EditPolyLine, title: "编辑多段线", command: "PE" }, { svg: IconEnum.EditPolyLine, title: "编辑多段线", command: "PE" },
{ svg: IconEnum.Explode, title: "分解", command: "X" }, { svg: IconEnum.Explode, title: "分解", command: "X" },
]; ];
let downStore = DownPanelStore.GetInstance() as DownPanelStore;
let pStore = PropertiesStore.GetInstance() as PropertiesStore;
return ( return (
<div className="toolbar" style={{ <div className="toolbar" style={{
display: (DownPanelStore.GetInstance() as DownPanelStore).showToolBar ? "flex" : "none" display: downStore.showToolBar !== ToolBarType.none ? "flex" : "none"
}}> }}>
<ToolBar {
iconList={iconList} downStore.showToolBar === ToolBarType.properties ?
/> <PropertiesPanel store={pStore} />
: downStore.showToolBar === ToolBarType.toolbar ?
<ToolBar iconList={iconList} /> :
<>
<ToolBar iconList={iconList} />
<PropertiesPanel store={pStore} />
</>
}
</div> </div>
); );
} }

@ -17,7 +17,7 @@ import { TopToolBar } from '../Components/TopToolBar/TopToolBar';
import { DownPanelStore } from '../Store/DownPanelStore'; import { DownPanelStore } from '../Store/DownPanelStore';
import { RightPanelStore } from '../Store/RightPanelStore/RightPanelStore'; import { RightPanelStore } from '../Store/RightPanelStore/RightPanelStore';
import { TopPanelStore } from '../Store/TopPanelStore'; import { TopPanelStore } from '../Store/TopPanelStore';
import { RightPanelButton } from '../Components/RightPanel/RightPanelButton'; import { RightPanelButton, PropertiesPanelButton } from '../Components/RightPanel/RightPanelButton';
export let appUi: WebCAD; export let appUi: WebCAD;
@ -169,6 +169,17 @@ export class WebCAD
} }
renderToolBar() 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(<PropertiesPanelButton store={downStore} />, propertiesBtn);
let toolbarEl = document.createElement("div"); let toolbarEl = document.createElement("div");
toolbarEl.id = "toolbar"; toolbarEl.id = "toolbar";
toolbarEl.style.display = "flex"; toolbarEl.style.display = "flex";

@ -14,13 +14,21 @@ function PointToString(pt: Vector3): string
}).join(","); }).join(",");
} }
export enum ToolBarType
{
both = 3,//同时显示工具和特性
toolbar = 1,//显示工具
properties = 2,//显示特性
none = 0,//不显示
}
/** /**
* . * .
*/ */
export class DownPanelStore extends Singleton export class DownPanelStore extends Singleton
{ {
@observable useDynInput: boolean = true; @observable useDynInput: boolean = true;
@observable showToolBar: boolean = true; @observable showToolBar: ToolBarType = 1;
@observable useDynSnap: boolean = true; @observable useDynSnap: boolean = true;
@observable usePass: boolean = true; @observable usePass: boolean = true;
@observable useOrtho: boolean = false; @observable useOrtho: boolean = false;

@ -7,6 +7,8 @@ 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 { Ellipse } from "../../DatabaseServices/Entity/Ellipse"; import { Ellipse } from "../../DatabaseServices/Entity/Ellipse";
import { AlignedDimension } from "../../DatabaseServices/Dimension/AlignedDimension";
import { Text } from "../../DatabaseServices/Text/Text";
export class EntityStore extends Singleton export class EntityStore extends Singleton
{ {
@ -46,6 +48,10 @@ export class EntityStore extends Singleton
addEnToMap("圆弧", en); addEnToMap("圆弧", en);
else if (en instanceof Ellipse) else if (en instanceof Ellipse)
addEnToMap("椭圆", en); addEnToMap("椭圆", en);
else if (en instanceof AlignedDimension)
addEnToMap("对齐标注", en);
else if (en instanceof Text)
addEnToMap("文字", en);
else else
addEnToMap("三维实体", en); addEnToMap("三维实体", en);
@ -60,6 +66,7 @@ export class EntityStore extends Singleton
ens.push(...v); ens.push(...v);
} }
else else
if (this.enMap.has(this.currentEnType))
ens = this.enMap.get(this.currentEnType); ens = this.enMap.get(this.currentEnType);
return ens; return ens;
} }

Loading…
Cancel
Save