Hi all,

for our post-processing needs we want to improve print quality (incl. PDF export) by generating vector-based plots from QwtPlotSpectrogram data. While we can implement this in a custom way, I think there may be a generic way to go about this, that would work for many cases. The idea is to add optional virtual functions that you may implement in your spectrogram implementation and the rendering process would run along these lines:


  1. First request a list/vector of points and triangles that approximate the color maps shape. A convenience function may be provided to automatically generate triangulated data from a rectangular grid. What needs to be generated is a list of points (index and optionally coordinates) and a list of triangles defined via point references. The implementer of this function can effectively control the granularity of the generated triangulation and thus the smoothness of approximating the actual data.
  2. Implement an API that generates values for each point (or alternatively a function that generates x,y coordinates for a point-by-index and then using the value() function from plot spectrogram to get the value). The idea for generating a list of values matching the list of points is just for those implementations of spectrogram plot that render the image themselves and do not bother to implement the value() function.


With those functions in place, the generic routine could generate vector-based plots using the following algorithm:

  • for each triangle get the corner values
  • compute the projection onto the z-plane with linear gradient vectors
  • compose a Qt-linear gradient using the colors associated to the values
  • paint a filled triangle with this gradient brush


I tested that with a small example and the generated SVG and PDF files are indeed free of raster-image data.

Questions:

a) is there actually a wider interest in such a feature (after all, a generic implementation is quite a bit more work than a hard-coded single-app variant)
b) @Uwe: what are your thoughts on adding API functions for this purpose to the QwtRasterData or QwtPlotSpectrogram classes?

Bye,
Andreas