PDA

View Full Version : Should I use SVG or something else?



cboles
10th December 2008, 18:23
I need to create some dynamically-defined virtual gauges similar to the ones show in this Trolltech demo :

http://trolltech.com/images/products/widgets-dials-and-gauges
http://trolltech.com/files/embedded-widgets-catalog-demo

Unlike this demo, I need to make my gauges have different numbers of tick marks, different units, text, sweep ranges, etc. depending on what parameters are being displayed. I can do this by having my program generate the SVG XML on the fly and then send this in-memory file to the SVG renderer, but I wonder if at that point it just makes more sense to just do direct GUI drawing via Qt or OpenGL.

I guess my question is - is the SVG renderer better in terms of scaling, anti-aliasing, graphics primitives, gradients, etc. to justify the extra step of generating the XML for SVG versus drawing everything via a graphics API?

Thanks,

Colby

spraff
10th December 2008, 19:31
I'd say you're better off using SVG for perhaps the layer of gloss or background, but as far as tick intervals and the like goes, if you're going to have to specify them programmatically anyway I can't image there's any advantage of generating SVG to issuing drawing commands directly.

In short, break your widget up into independent pieces. Some can be SVG.

cboles
10th December 2008, 21:03
I'd say you're better off using SVG for perhaps the layer of gloss or background, but as far as tick intervals and the like goes, if you're going to have to specify them programmatically anyway I can't image there's any advantage of generating SVG to issuing drawing commands directly.

In short, break your widget up into independent pieces. Some can be SVG.

The one thing that I like about SVG is that is seems to do a very good scaling / anti-aliasing. If you look at the gauges in the demo EXE and shrink down the window, it does a very good job. Most other drawing APIs I have seem tend to have more aliasing, or maybe don't composite the image before scaling to get the anti-aliasing right. I don't know this is true of Qt until I try it both ways and compare of course, but that is the impression I get looking at a lot of other Qt demos.