A Real-Time Data Plotting Program
This article describes the implementation of rtp (real-time plotter), a live x,y data plotting utility based on the Qt windowing library. rtp combines live updates with zoom in, auto-scaling, and auto-tracking modes. It is meant to be used where gnuplot is limited, such as the termination of a live data pipeline. However, rtp is small and does not attempt to cover gnuplot's large feature set for producing publishable data plots.
The rtp source code is released under the GPL and is available at metalab.unc.edu/pub/linux/science/visualization/rtp-1.0.0.tar.gz. I developed and tested it under Red Hat 6.0, with Qt 1.44. A README file is included in the package to help you build and use rtp. A screenshot of rtp is shown in Figure 1.
rtp provides real-time updates and basic mouse-driven resolution selection. However, it lacks gnuplot's ability to send formatted, titled plots to a printer. rtp is still a simple piece of software (1200 lines of code) that needs many features added. By describing its principles here, I hope to provide a useful, gentle example of an application based on the Qt library and the X Window System. I also hope to motivate some interested people to do more work on a Linux-based real-time, interactive data visualization system. This could be done either by extending rtp or as a completely new project.
Because all of rtp's data comes from STDIN (standard input), interaction with the user through the X Window System is limited to setting the viewing mode. It allows the user to change the viewing mode even as new data points are being processed. The viewing modes are as follows:
Auto scale: the scaling is adjusted when necessary to include all received data points. This is the default mode and can be selected by pressing a button on the toolbar.
Auto tracking: maintains a fixed scaling, but varies the viewport offset to track the latest points. This mode is selected by pressing a button on the toolbar. The scaling will be fixed at what it was before the toolbar button was pressed.
User-defined fixed: maintains a fixed viewport (both scale and offset), as defined by the user. This mode is selected when the user drags out a viewport in the plot window with the mouse.
I based rtp on the Qt library, because many others in the Linux community are using it (e.g., KDE) and because of its high-quality documentation. An HTML tree (guaranteed to be synchronized with the Qt source because it is automatically generated from the source code and comments) describes all of Qt's classes and functions. Dalheimer also wrote a book on Qt programming that is a very helpful introduction (see Resources).
The Qt library provides a GUI programming environment that is quite complete. When programming in the Qt environment, no reference to the underlying XLib library is necessary. Qt's functionality extends beyond the GUI domain to include container classes that implement several standard data structures.
Each of Qt's functional components is packaged as a C++ class, giving C++ wizards much to ponder and tinker with and those of us who like to write operational code a good tool set. For myself, having about a year of experience writing production C code with only a college course in C++, it was fairly easy to learn the Qt C++ framework.
The Qt library makes integration of independently developed classes easier through its C++ extensions: “signals” and “slots”. A signal is a class member function that is undefined at compile time. A slot is a member function that is specially designated for connection to a signal at runtime. For example, a GUI button class could have a Push signal. At runtime, a plot window's slot Render could be connected to the button's Push. From then on, code that calls the button's Push method effectively calls the plot window's Render method.
Code based on the signals and slots mechanism is easier to read and maintain than that dealing with runtime function-pointer tables. (I'd bet the implementation uses a function pointer or two.) Qt also takes care of annoyances such as stubbing non-connected signals to an empty function, so you don't get a segmentation fault from a null pointer.
The drawback of signals and slots is that they are non-standard C++ extensions using new syntax, so Qt code with signals and slots must be passed through a preprocessor provided with the Qt library before it can be compiled. Dalheimer's book explains signals and slots in sufficient detail for you to start using them.
Trending Topics
| You Need A Budget | Feb 10, 2012 |
| The Linux powered LAN Gaming House | Feb 08, 2012 |
| Creating a vDSO: the Colonel's Other Chicken | Feb 06, 2012 |
| Your CMS Is Not Your Web Site | Feb 01, 2012 |
| Casper, the Friendly (and Persistent) Ghost | Jan 31, 2012 |
| Razor-qt 0.4 - Qt based Desktop Environment | Jan 30, 2012 |
- Fun with ethtool
- Parallel Programming with NVIDIA CUDA
- Readers' Choice Awards 2011
- 100% disappointed with the decision to go all digital.
- Linux-Based X Terminals with XDMCP
- Validate an E-Mail Address with PHP, the Right Way
- You Need A Budget
- Build Your Own Arcade Game Player and Relive the '80s!
- Why Python?
- Python for Android
- I use Wireshark on a daily
1 hour 45 min ago - buena información
6 hours 52 min ago - One important "bucket" that I didn't note (désolé si qqun deja d
7 hours 53 min ago - Gnome3 is such a POS. No one
17 hours 20 min ago - Gnome 3 is the biggest POS
17 hours 31 min ago - I didn't knew this thing by
23 hours 35 min ago - Author's reply
1 day 2 hours ago - Link to modlys
1 day 4 hours ago - I use YNAB because of the
1 day 4 hours ago - Search
1 day 9 hours ago







Comments
bad link
http://www.linuxjournal.com/article/3921
refers to rtp 1.0.0. Link is broken, version is 1.0.1
ftp://metalab.unc.edu/pub/linux/science/visualization/rtp-1.0.1.tar.gz