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

Brad Howes howes at ll.mit.edu
Tue Sep 22 15:44:59 CEST 2009


On Mon, Sep 21, 2009 at 1:07 PM, Svenn Are Bjerkem
<svenn.bjerkem at googlemail.com> 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



-------------- next part --------------
A non-text attachment was scrubbed...
Name: ascope.jpeg
Type: image/jpg
Size: 248552 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090922/4e7edf54/attachment.jpg 
-------------- next part --------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Snapz Pro XScreenSnapz001.jpg
Type: image/jpg
Size: 74745 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090922/4e7edf54/attachment-0001.jpg 


More information about the Qt-interest-old mailing list