隐藏多边形时,标签保留
我正在使用Edit2D扩展程序和标签上使用Autodesk Viewer。奇怪的是,当多边形隐藏时,标签似乎留下了“残留”。
我的层上有几个多边形,并且用户可以隐藏它们。当他们这样做时,此代码会隐藏着:
export function setRegionVisibility(
editor: Autodesk.Extensions.Edit2D,
region: RegionData,
geometry: SpaceGeometry,
visible: boolean
): void {
const shape = editor.defaultContext.layer.shapes.find(
(s) => s.id === region.itemIds[0]
);
if (shape == null) {
return;
}
// @ts-ignore
shape.visible = visible;
editor.defaultContext.layer.update();
return;
}
但是,当隐藏多边形时,它的标签仍在视图上。当我重新展示形状时,它会有一个新的标签,它可以随它移动,但是无论视图的缩放或平移如何,旧的标签都保留在静态位置。
我试图手动将其隐藏或删除它,但似乎无效。这就是我尝试这样做的方式:
export function setRegionVisibility(
editor: Autodesk.Extensions.Edit2D,
region: RegionData,
geometry: SpaceGeometry,
// @ts-ignore
tagRule: Autodesk.Edit2D.ShapeLabelRule | undefined,
visible: boolean
): void {
const shape = editor.defaultContext.layer.shapes.find(
(s) => s.id === region.itemIds[0]
);
if (shape == null) {
return;
}
// @ts-ignore
shape.visible = visible;
let label: any;
for (let labelsKey in tagRule.labels) {
if (labelsKey === shape.id.toString()) {
label = tagRule.labels[labelsKey];
}
console.log(tagRule.labels);
}
if (label != null) {
label.visible = visible;
console.log(label);
label.dtor();
label.update();
label.layer.update();
}
editor.defaultContext.layer.update();
return;
}
任何想法如何使鬼魂消失?
I am using the Autodesk Viewer with the Edit2D extension and working on labels. The strange thing is that labels seem to leave a 'residue' when the polygon is hidden.
I have several polygons on the layer and the ability for the user to hide them. When they do that, this code does the hiding:
export function setRegionVisibility(
editor: Autodesk.Extensions.Edit2D,
region: RegionData,
geometry: SpaceGeometry,
visible: boolean
): void {
const shape = editor.defaultContext.layer.shapes.find(
(s) => s.id === region.itemIds[0]
);
if (shape == null) {
return;
}
// @ts-ignore
shape.visible = visible;
editor.defaultContext.layer.update();
return;
}
However, when a polygon is hidden, the label that was for it remains on the view. When I re-show the shape it gets a NEW label which moves with it, but the old one remains on the view and just stays in a static location regardless of the zooming or panning of the view.
I tried to manually hide it or remove it but nothing seems to work. This is how I tried to do that:
export function setRegionVisibility(
editor: Autodesk.Extensions.Edit2D,
region: RegionData,
geometry: SpaceGeometry,
// @ts-ignore
tagRule: Autodesk.Edit2D.ShapeLabelRule | undefined,
visible: boolean
): void {
const shape = editor.defaultContext.layer.shapes.find(
(s) => s.id === region.itemIds[0]
);
if (shape == null) {
return;
}
// @ts-ignore
shape.visible = visible;
let label: any;
for (let labelsKey in tagRule.labels) {
if (labelsKey === shape.id.toString()) {
label = tagRule.labels[labelsKey];
}
console.log(tagRule.labels);
}
if (label != null) {
label.visible = visible;
console.log(label);
label.dtor();
label.update();
label.layer.update();
}
editor.defaultContext.layer.update();
return;
}
Any idea how to make that ghost go away?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论