fast canvas with many graphic objects

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
qwer
In need of some credit
In need of some credit
Posts: 1
Joined: Mon Mar 16, 2009 11:11 am

fast canvas with many graphic objects

Post by qwer »

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) ?
Romas
I live to help wx-kind
I live to help wx-kind
Posts: 176
Joined: Mon Jun 16, 2008 11:07 am
Location: Kaunas

Post by Romas »

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 :)
leiradella
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Sun Sep 07, 2008 9:49 pm
Location: Rio de Janeiro, Brazil

Post by leiradella »

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
Romas
I live to help wx-kind
I live to help wx-kind
Posts: 176
Joined: Mon Jun 16, 2008 11:07 am
Location: Kaunas

Post by Romas »

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 :)
leiradella
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Sun Sep 07, 2008 9:49 pm
Location: Rio de Janeiro, Brazil

Post by leiradella »

@Romas

Hum, I don't have any problems with wxScrolledWindow. But it's a long time I've written this class so I don't remember if I took special measures to avoid the problems you mention.

Cheers,

Andre
Romas
I live to help wx-kind
I live to help wx-kind
Posts: 176
Joined: Mon Jun 16, 2008 11:07 am
Location: Kaunas

Post by Romas »

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 :)
phlox81
wxWorld Domination!
wxWorld Domination!
Posts: 1387
Joined: Thu Aug 18, 2005 7:49 pm
Location: Germany
Contact:

Post by phlox81 »

Take a look at wxShapeFramework:
http://sourceforge.net/projects/wxsf/
Post Reply