What's the best way to implement big canvas with 1000s of objects (lines, filled ellipses, polygons, text, images), and scrolling, scaling, and mouse dragging ?
Is it possible to add opacity, shadows, and antialiacing for objects with Wx drawing methods ?
Or better to use other tools (Cairo/OpenGL) ?
fast canvas with many graphic objects
Hello,
It depends on what you want to do. If those objects are not frequently redrawed you can use buffer and put everything on it it will not each much of computer resources. But if those objects are redrawed very often, I think, you should consider of using more powerfull graphic engines than gdi can support
It depends on what you want to do. If those objects are not frequently redrawed you can use buffer and put everything on it it will not each much of computer resources. But if those objects are redrawed very often, I think, you should consider of using more powerfull graphic engines than gdi can support
-
- I live to help wx-kind
- Posts: 172
- Joined: Sun Sep 07, 2008 9:49 pm
- Location: Rio de Janeiro, Brazil
I was needing such a canvas for an application I'm writing, though it won't have to handle thousands of objects. After evaluating wxSF and wxArt2D, I decided to write my own.
Basically, you should subclass wxScrolledWindow and overrite the OnDraw method. Then draw the objects in this canvas.
Of course you'll have to manage (draw, dragging, selecting etc.) the shapes yourself. I think there is no problem in having thousands of them, you can just check every shape to see if they lay inside the visible are and draw only the ones that does.
Cheers,
Andre
Basically, you should subclass wxScrolledWindow and overrite the OnDraw method. Then draw the objects in this canvas.
Of course you'll have to manage (draw, dragging, selecting etc.) the shapes yourself. I think there is no problem in having thousands of them, you can just check every shape to see if they lay inside the visible are and draw only the ones that does.
Cheers,
Andre
Long time since last post. I can only agree with leiradella of writing your own canvas window, that will work as you want with less code. However, while searching for info, I've found that scrolled window might sometimes paint graphic glitches or similar unwanted things. So, I have moved from wxScrolledWindow to wxWindow with to scrollbars and my logics
-
- I live to help wx-kind
- Posts: 172
- Joined: Sun Sep 07, 2008 9:49 pm
- Location: Rio de Janeiro, Brazil
wxScrolledWindow worked fine for me, but one day, I wanted to draw object, that stays on top of everything, no matter if scroll is in action or not That brought me very interesting result - graphics glitches. I guess this is part of windows, not wxWidgets itself. As I didn't have much time to find the solution, I've just written my own scrolling window, which is working very good for me
Take a look at wxShapeFramework:
http://sourceforge.net/projects/wxsf/
http://sourceforge.net/projects/wxsf/