优化GetRectPoint在任意视图下动态提示的显示.

pull/232/MERGE
ChenX 6 years ago
parent 030f424038
commit 66e7a8f1a0

@ -61,6 +61,15 @@ export class GetRectPointServices
let signX = 1;
let signY = 1;
let p2UCS: Vector3;
this.destroyCalls.push(
end(app.m_Viewer.m_CameraCtrl, app.m_Viewer.m_CameraCtrl.Update, () =>
{
if (p2UCS)
this.UpdateDynPrompt(basePointUCS, p2UCS);
})
);
//#region 动态输入框响应
let mng = DynamicInputManage.GetManage();
@ -96,7 +105,7 @@ export class GetRectPointServices
let pScreen = app.m_Viewer.WorldToScreen(p2.clone());
this.dynPrompt.SetPostion(pScreen);
let p2UCS = p2.clone().applyMatrix4(ucsInv);
p2UCS = p2.clone().applyMatrix4(ucsInv);
let x = p2UCS.x - basePointUCS.x;
let y = p2UCS.y - basePointUCS.y;
@ -108,22 +117,7 @@ export class GetRectPointServices
p2UCS.x = basePointUCS.x + this.dynPrompt.Width * signX;
p2UCS.y = basePointUCS.y + this.dynPrompt.Height * signY;
let b = new Box3().setFromPoints([basePointUCS, p2UCS]);
let pts = [
b.min,
new Vector3(b.max.x, b.min.y),
b.max,
new Vector3(b.min.x, b.max.y),
b.min
];
BufferGeometryUtils.UpdatePts(this.rubberBandLine.geometry as BufferGeometry, pts);
this.rubberBandLine.geometry.computeBoundingSphere();
this.dynPrompt.UpdatePosition(
app.m_Viewer.WorldToScreen(midPoint(pts[0], pts[1])),
app.m_Viewer.WorldToScreen(midPoint(pts[0], pts[3])),
);
this.UpdateDynPrompt(basePointUCS, p2UCS);
}
});
if (ptRes.Status === PromptStatus.OK)
@ -158,6 +152,33 @@ export class GetRectPointServices
});
}
/**
* 线
*/
private UpdateDynPrompt(basePointUCS: Vector3, p2UCS: Vector3)
{
let b = new Box3().setFromPoints([basePointUCS, p2UCS]);
let pts = [
b.min,
new Vector3(b.max.x, b.min.y),
b.max,
new Vector3(b.min.x, b.max.y),
b.min.clone()
];
for (let p of pts)
{
p.applyMatrix4(app.m_Editor.UCSMatrix);
app.m_Viewer.m_PreViewer.WorldToViewPoint(p);
}
BufferGeometryUtils.UpdatePts(this.rubberBandLine.geometry as BufferGeometry, pts);
this.rubberBandLine.geometry.computeBoundingSphere();
this.dynPrompt.UpdatePosition(
app.m_Viewer.m_PreViewer.ViewerPointToScreenPoint(midPoint(pts[0], pts[1])),
app.m_Viewer.m_PreViewer.ViewerPointToScreenPoint(midPoint(pts[0], pts[3]))
);
}
DrawRubberBand()
{
if (!this.rubberBandLine)
@ -166,10 +187,14 @@ export class GetRectPointServices
BufferGeometryUtils.CreateFromPts(PointShapeUtils.SquarePts(0)),
ColorMaterial.GetLineMaterial(7)
);
app.m_Viewer.Scene.add(this.rubberBandLine);
app.m_Viewer.m_PreViewer.Scene.add(this.rubberBandLine);
}
else
else
{
this.rubberBandLine.visible = true;
let geo = this.rubberBandLine.geometry as BufferGeometry;
geo.drawRange.count = 0;
}
}
private InitState()

@ -21,7 +21,7 @@ export class GetRectPointPromptBlock extends PromptBlock
this.xDynIpt.Fixed = true;
this.yDynIpt.Fixed = true;
this.UpdatePrompt("请点击或者输入距离:");
this.UpdatePrompt("指定另一个角点:");
dynamicInputManage.FocusIndex = 0;
}

Loading…
Cancel
Save