- 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?
- 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.
Instead of using Line objects, you could draw your lines by Path objects. Here is an answer https://stackoverflow.com/a/15323221/1305119
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With