Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building a CAD program in WPF

- Building a CAD program in WPF:

I want to build a CAD program that will have 10000 LINE objects at a time. I'm using LineGeomery class for drawing lines that are added to a Canvas. I have implemented Zoom and Pan and the performance is great so far.

Only one major disappointment:

The Thickness of the lines gets scaled while zooming. I have tried to Bind the Thickness property of the lines to a factor to keep them unchanged, This works but reduces the performance dramatically while zooming. Clearing and drawing new lines with new thickness on MouseWheel is out of the question as well. This one too reduces performance and is not practical in the current method.

- Now what solutions I have?

  • Stick with the current method and ignore the change in Thickness
  • Do the whole job in GDI+
  • Host GDI in WPF
  • Use WPF Viewport3D (Will the LineThickness be invariant there?)

- Other solutions?

What other paths you would take. I'm new to WPF and programming and I'm eager to learn.

UPDATE:

This is the way I'm doing it right now. I draw 3000 Lines on the Visual Layer using Pen an Brushes. Then on MouseWheel event I redraw all the Lines with the updated Thickness. Also I don't show the rest of the Lines to the user until he zooms so I only create 3000 out of 10000 Lines in each MouseWheel event.

like image 586
Vahid Avatar asked Mar 21 '14 06:03

Vahid


2 Answers

Instead of using Line objects, you could draw your lines by Path objects. Here is an answer https://stackoverflow.com/a/15323221/1305119

like image 125
Suresh Kumar Veluswamy Avatar answered Oct 27 '22 23:10

Suresh Kumar Veluswamy


Next to hosting a winforms element inside WPF, I would also implement partial rendering on the zooming feature, e.g. when you zoom in everything that is not visible should not be calculated as well!

like image 45
woutervs Avatar answered Oct 27 '22 23:10

woutervs