显示2D示意图WPF中与绘图视觉效果 [英] Displaying 2D Schematics in WPF with Drawing Visuals

查看:563
本文介绍了显示2D示意图WPF中与绘图视觉效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个WPF应用程序,将显示一个城市规模的水资源管理制度的2D矢量图形。我已经从阀门,泵,处理设施等的简图和互连这些管路的数百页捕获的数据。与个人住宅和商业属性和数据集具有沿带有互连管信息约100,000节点实例的映射信息结合起来。我有概念验证的应用程序,为每个管段或节点(节点是pretty的简单,矩形,圆形等)创建了一个DrawingVisual,创建的DrawingContext,绘制线段的管道或节点的图形重新presentation。所述DrawingVisuals加入到画布。每一个视觉的命中测试的(我需要能够对其中的任何点击来获得更详细的信息)。问题是,作为视觉的遍数一数千年,性能(平移,缩放)降级(真的很酷,直到那时,虽然!)。我曾尝试与抗锯齿和放大器摆弄;位图缓存,但它没有太大的帮助。

I am creating a WPF application that will display 2D vector graphics of a city-scale water management system. I have captured data from hundreds pages of schematic drawings of valves, pumps, treatment facilities, etc and the piping that interconnects them. Combine this with mapping information of individual residences and commercial properties and the data set has about 100,000 node instances along with the interconnecting pipe information. I have a proof-of-concept application that creates a DrawingVisual for each pipe segment or node (nodes are pretty simple; a rectangle, circle, etc), creates a DrawingContext, rendering the line segments for the pipe or the node's graphic representation. The DrawingVisuals are added to a canvas. Each visual is hit-testable (I need to be able to click on any of them to get more detailed information). The problem is that as the number of visuals passes a several thousand, performance (pan, zoom) degrade (really cool until then, though!). I have tried fiddling with anti-aliasing & bitmap caching, but it's not much help.

时这种事情可能在WPF?有没有更好的方法吗?我来自一个MFC背景,才开始与WPF 6-8个月前,虽然我有C#经验相当数量。从这里阅读文章中,我看到Direct3D是经常被提及,但它doent似乎真的符合这个要求的平面的2D,线路图,还是我错了?该XNF教程我只看到处理精灵,这很难说是合适的?我已阅读相关业务图的帖子;下采样的数据似乎有必要在这种情况下,但我不知道我能做到这一点,因为每个节点放;互连管是相关的。用户需要相当快的缩放和放大器;平移在原理图的任何一点。我的想法是OpenGL的可能是一个很好的东西去探索,但我真的很喜欢所有的WPF的功能(命中测试,极大的几何类等)

Is this kind of thing possible in WPF? Is there a better approach? I come from an MFC background and only started with WPF 6-8 months ago, though I have a fair amount of C# experience. From reading posts here, I see Direct3D is often mentioned, but it doent' really seem to fit the bill for flat, 2D, line-drawings, or am I wrong? The XNF tutorials I've seen only deal with sprites, and that hardly seems appropriate? I have read the posts related to business graphs; down-sampling data seems appropriate in those cases, but I am not sure I can do that, as every node & interconnecting pipe is relevant. Users require reasonably fast zooming & panning to any point in the schematic. I was thinking that OpenGL might be a good thing to explore, but I REALLY like all of the features of WPF (hit testing, great geometry classes, etc)

有什么建议?

谢谢!

推荐答案

如果您还没有准备好,你应该看一下WPF的性能工具:的 http://msdn.microsoft.com/en-us/library/aa969767.aspx 。你应该能够得到一些想法,其中真正的瓶颈是,什么是重新渲染每次和更多。

If you haven't already, you should have a look at the WPF performance tools : http://msdn.microsoft.com/en-us/library/aa969767.aspx. You should be able to get some idea of where the real bottlenecks are, what's re-rendered every time and a lot more.

我不得不处理这个问题扩展为WPF一些3D模型。虽然我不是太肯定的2D当量计算,该建议可能仍然适用。

I've had to deal with this issue of scaling WPF for some 3D models. Though I'm not too sure about the 2D equivalent terms, the advice might still be applicable.

WPF有足够的优势去尝试pretty的努力优化它为您的使用情况,而不是考虑一些替代架构。我觉得对我来说是较少的工作,了解和解决性能问题不是处理一些其他的框架。

WPF has enough advantages to try pretty hard to optimise it for your use case, rather than considering some alternative architecture. I think for me it was less work to understand and work around the performance issues than dealing with some other framework.

在年底的大招对我来说是巩固模型和视觉效果。而不是有许多小模型,其中每个命中测试的,用自己的颜色等等,我这些聚合成重present许多组件的大型模型。然后我处理的大模型的点击测试以进一步缩小选择和决定哪些小部件实际上应该重灾区。而不是改变整个聚合体模型的颜色从那里,我覆盖小模型重新present选择。我觉得你的想法......

In the end the big trick for me was to consolidate models and visuals. Instead of having lots of little models, each of which is hit-testable, with their own colour etc., I aggregate these into large models which represent many components. Then I handle the hit testing of the big models to further refine the selection and decide which little component should actually be 'hit'. From there, instead of changing the colour of the whole aggregate model, I overlay a smaller model to represent the selection. I think you get the idea...

所以,你需要找出哪些部分的抽象图形中的不结垢好 - DrawingVisuals的可能数量,或者你使用其他的UIElement,然后试图巩固这些

So you need to figure out which abstract part in your drawing is not scaling well - maybe the number of DrawingVisuals, or maybe some other UIElement you use, then try to consolidate these.

这篇关于显示2D示意图WPF中与绘图视觉效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆