如何进行普通选择

发布于 2025-01-12 17:06:25 字数 232 浏览 0 评论 0原文

我使用 Autodesk Forge Viewer 和 Edit2D 工具来允许用户绘制和修改多边形。我使用多边形工具和polyEditTool 进行此操作。但是,我还有一个用例,用户需要能够选择多边形但不能进行任何修改。据我所知,polyEditTool 和 moveTool 允许用户选择多边形,但也允许它们进行修改。如果我停用所有工具,它们将无法选择,并且标准查看器选择似乎不允许您选择 Edit2D 形状。

如何获得仅选择模式?

I'm using the Autodesk Forge Viewer with the Edit2D tools to allow the user to draw and modify polygons. I have this working with the polygonTool and polyEditTool. However, I also have a use case where the user needs to be able to select polygons but NOT make any modifications. As far as I can tell, the polyEditTool and moveTool allow the user to select polygons but they also allow them to modify. If I deactivate all tools they can't select, and the standard viewer selection doesn't seem to allow you to select the Edit2D shapes.

How can I get a selection only mode?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浊酒尽余欢 2025-01-19 17:06:25

Edit2D 扩展没有任何内置选项,只能选择形状,而不能编辑形状,并且您之前建议的解决方法看起来很合理。

另一个需要考虑的选项是实现 EditToolBase 的自定义子类(您可以使用 官方 Edit2D 工具的实现作为参考)只允许选择,不允许其他任何操作。

The Edit2D extension does not have any built-in option to only enable selection but not editing of shapes, and the workaround you suggested earlier looks reasonable.

Another option to consider would be implementing a custom subclass of EditToolBase (you could use the implementation of the official Edit2D tools as a reference) that would only allow selection, and nothing else.

空城缀染半城烟沙 2025-01-19 17:06:25

好吧,这看起来有点复杂,但我找到了一种似乎有效的方法。移动工具允许您选择和移动,但每个形状都有一个 movable 属性。如果您将形状的 movable 设置为 false,则仍可以选择该形状,但无法移动它。因此,如果您在仅编辑和仅选择模式之间切换,则必须通过迭代图层上的形状并每次设置它来更改该属性。这是我的实现:

for (const shape of state.editor.defaultContext.layer.shapes) {
  // @ts-ignore
  shape.movable = tool !== DrawTools.Select;
}

请注意,TypeScript 定义似乎不包含 movable 属性,因此我必须忽略该错误。

这似乎有效,但如果有更好的解决方案,我很乐意接受更好的答案。

Ok well it seems a little convoluted but I found a way that seems to work. The move tool allows you to select and move, but each shape has a movable property. If you set movable to false on the shape it can still be selected but can't be moved. So if you are switching between the editing and selection only modes you would have to change that property by iterating over the shapes on the layer and set it each time. Here is my implementation:

for (const shape of state.editor.defaultContext.layer.shapes) {
  // @ts-ignore
  shape.movable = tool !== DrawTools.Select;
}

Note that TypeScript definitions don't seem to include the movable property so I have to ignore the error.

This seems to work but if there is a better solution out there I would be happy to accept a better answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文