qt-interest@trolltech.com
[Top] [All Lists]

Re: [Qt-interest] Placing waveforms in stripes, examples needed.

Subject: Re: [Qt-interest] Placing waveforms in stripes, examples needed.
From: Brad Howes
Date: Tue, 22 Sep 2009 09:44:59 -0400
On Mon, Sep 21, 2009 at 1:07 PM, Svenn Are Bjerkem
<svenn.bjerkem@xxxxxxxxxxxxxx> wrote:

Audio sequencers and waveform viewers place visual data in horizontal
stripes and these stripes are attached to a horizontal scrollbar so
that the data viewport can be changed. Example is qtractor or kst. I
downloaded qtractor source to see if I could learn something, but this
is a complete application and not very easy to use as a reference. I
tried to google, but qt seems to mean a lot, and stripes happens on
lcd-panels and waveform is everywhere. If somebody has a URL or two to
simple panelized waveforms in a graphic view I would be happy to learn
from them.

I have a list of x and y data where x is time and y is either logical
0 or 1, basically I want to write a very simple waveform viewer for
digital simulation data. I could present the data in vcd and use
gtkwave, but my needs are a bit different than those offered by
gtkwave.


What I have done is real simple, but handles multiple channels of 400Hz radar data. I have a Visualizer class that is based on QWidget. This class handles the imaging of one or more Channel objects which hold the samples of the last message (~4k samples per message). I support zooming and panning, which rely on QMatrix for performing coordinate transforms, as well as a view stack that lets you zoom in or pan and then back up to previous views. QWidget + QPainter + QMatrix is about all you need for good rendering. I've attached an image of my application (AScope). It also supports view splitting as shown in the image (two Visualizer classes sharing a Channel object with a QSplitter hosting them).

For more advanced imaging, one can dive into OpenGL, but Qt's paint system works fine for our data. Keep in mind that you cannot display everything -- audio has a bandwidth of 40kHz or so which is way faster than your eye's update rate. I read data in in separate threads, saving the raw sample values of the last message, and render on demand, every 15 seconds or so using a QTimer. Not perfect but perfectly adequate for our users. As for rendering, we just use simple lines to draw the radar returns / waveform.

A second application I wrote is just a simple strip-chart view that again supports multiple channels. Again, I'm using QWidget to host the drawing, and in the paintEvent() method, I call QPainter::drawPolyline () for the sample data. We use various filters on the incoming data to get nominal values so we can then detect and highlight off-nominal conditions. The filtered data goes into a std::deque that gives us fast add/delete at the edges of the container. Again, QWidget + QPainter + QMatrix works great.

Brad

--
Brad Howes
Group 42
MIT Lincoln Laboratory • 244 Wood St. • Lexington, MA 02173
Phone: 781.981.5292 • Fax: 781.981.3495 • Secretary: 781.981.7420




_______________________________________________
Qt-interest mailing list
Qt-interest@xxxxxxxxxxxxx
http://lists.trolltech.com/mailman/listinfo/qt-interest
<Prev in Thread] Current Thread [Next in Thread>