将 WPF PathGeometry 拆分为“图块”

发布于 2024-09-15 10:32:48 字数 373 浏览 8 评论 0原文

我有一个相当大的 PathGeometry(超过 100,000 个点,有描边但未填充)要向用户显示,但在任何时候都只有一小部分路径可见。需要澄清的是,路径本身不是预先确定的,而是根据数据创建的。

问题:我想提供非常平滑的平移,以便用户可以探索较大路径的区域。

我有一个可能的解决方案,但我不知道如何实现它。我想使用平铺技术——将几何体分割成图块并仅加载可见的图块。

那么,如何将仅笔画路径几何图形分割成图块。更具体地说,如何确定给定矩形图块中存在的路径部分?

我知道我可以使用 CombinedGeometry 来确定路径几何图形和矩形之间的相交,但这将包括矩形的“墙”(将被描边)。有没有更好的方法来平铺仅笔划的 PathGeometry?

谢谢!

I have a rather large PathGeometry (over 100,000 points and stroked but not filled) to display for the user, but only a small portion of the path will be visible at any one time. To clarify, the path itself is not predetermined but will be created from data.

The problem: I want to provide very smooth panning so the user can explore areas of the larger path.

I have a possible solution but I'm not sure how to pull it off. I'd like to use a tiling technique--split the geometry into tiles and only load the visible tiles.

So, how do split a stroke-only path geometry into tiles. More specifically, how do I determine the portion of the path that exists in a given rectangular tile?

I know I can use a CombinedGeometry to determine the intersect between the path geometry and a rectangle, but that will include the "walls" of the rectangle (which will be stroked). Is there a better way to tile a stroke-only PathGeometry?

Thanks!

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

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

发布评论

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

评论(3

不即不离 2024-09-22 10:32:48

也许不需要平铺,只需使用一个路径几何图形,并使用数据绑定或其他方式以编程方式更改路径数据来表示您放大的路径段。有点像 DeepZoom 但有路径。这意味着您不必搞乱合并路径。

我正在做与你类似的事情,但我在路径中使用的数字略少,所以我没有考虑使用任何虚拟化方法。但是,我没有注意到大规模的性能问题。我在滚动查看器中有一条代表大约 1000 - 10000 个点的路径,只有在点相距很远的情况下放大时才会出现滞后。如果路径中的点相对靠近它们的邻居(例如,良好的扫描正弦波),则 WPF 会对它们执行某种优化,以防止任何可察觉的滞后。

例如:这条路径...

multiple sines

...将比这条路径花费更长的时间来绘制:

simple sine

即使它们包含相同数量的描述它的点。尽管实际上,在您注意到性能上的任何差异之前,路径需要开始如下图所示。

the Troublemaker

因为该路径代表音频波,所以我打算通过执行某种操作来消除未来的任何此类问题检查这些点是否正在创建一个巨大的深蓝色块,并将其替换为耗电量较小的块,但这对您来说可能不是一个足够的解决方案。

(很抱歉图像的大小差异,计算正弦波的位目前不起作用,所以我不得不使用旧的 jpeg)

Perhaps instead of tiling just have the one pathgeometry and change the pathdata programatically using databinding or whatever to represent the segment of path you are zoomed in on. A bit like DeepZoom but with paths. This will mean you won't have to mess around merging paths.

I am doing something similar to you but the numbers I am using In my paths are slightly less so I havn't considered using any virtualisation methods. However, I have not noticed massive performance problems. I have a path in a scrollviewer representing about 1000 - 10000 points and it only gets laggy when I zoom in only if the points are very far apart. If the points in the path are relativly close to their neighbours (e.g. a nice sweeping sine wave) then WPF performs some kind of optimisation on them to prevent any percievable lagging.

Eg: this path...

multiple sines

...will take longer to draw than this path:

simple sine

even though they contain the same amount of points describing it. Although in reality the path needs to start looking like the image below before you notice any difference in performance.

the troublemaker

Because the path is representing an audio wave I intend to get rid of any future problems like this by performing some kind of check to see if the points are creating a massive dark blue block and replacing it with something less power hungry but this may not be a sufficient solution for you.

(sorry about the size difference in the images, the bit that calculates the sine wave is out of action at the moment so i've had to use old jpegs)

舟遥客 2024-09-22 10:32:48

我最近也在思考这个问题,也许我的经历对你有帮助。首先,如果您能够使用 StreamGeometry 而不是 PathGeometry,您可以获得更好的性能。我建议创建一个 StreamGeometry 作为路径的 Data 属性,将其放置在画布上,然后应用“缩放”和“平移”变换来导航形状。我使用 5 或 6 个系列几何体获得了不错的性能,每个系列几何体都有 1000 个点(显然比您提到的数字少得多),但我相信只要屏幕上没有所有点,WPF 图形引擎就能很好地扩展同时。如果您需要支持“完全缩小”,即所有点都可见,那么我建议创建几何图形的低分辨率版本(即一组更简单的点或位图)并交换高低-res 当缩放达到一定程度时的版本。

这有道理吗?

祝你好运!

I was thinking about this myself recently, so perhaps my experiences may help you. Firstly, you can get better performance if you're able to use a StreamGeometry rather than a PathGeometry. I would recommend creating a single StreamGeometry as the Data property of a Path, placing it on a canvas, and then applying Scale and Translate transforms to navigate the shape. I was getting decent performance with 5 or 6 SeriesGeometries each with 1000 points (obviously much fewer than the number you mentioned), though I believe the WPF graphics engine will scale quite well as long as you don't have all the points on the screen at the same time. If you need to support being "fully zoomed out", i.e. all the points would be visible, then I would recommend creating low-res versions of the geometry (i.e. either a simpler set of points or a bitmap) and swapping the high and low-res versions when the zoom reaches some level.

Does that make sense?

Good luck!

幽蝶幻影 2024-09-22 10:32:48

一种方法是,将整个几何图形加载到画布中。然后对画布应用缩放。您可以使用第三方控件,例如 ab2d。

我创建了这样一个画布,就像在 Photoshop 中的画布一样,里面有很多几何形状的绘图(由用户创建)。我已经使用 ab2d 通过它的菜单控件进行放大,效果很好。您还可以为其一部分设置预定义缩放。

谢谢/subho100

One way would be, you load the whole geometry in a canvas. Then apply a zoom to the canvas. You may use third party controls like ab2d.

I have created such a canvas like one in photoshop with lot of drawings(created by user) in form of geometries lying in there. I have used ab2d to zoom in out with its menucontrol and it works fine. You can also set a predefined zoom to a part of it.

Thanks / subho100

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