Thank you very much. At first it did not work because (for some reason) after the last SVN co only debug libraries of Qwt were built and therefore the bode example was still linked against the "old" release libraries. But after I modified qwtbuild.pri it worked as expected.
The result looks the way I want it and after modification of the QwtPainter::isAligning function the "steps" are indeed gone.
Unfortunately two issues are remaining:
1) The scaling factor needs to be adjusted according to the desired resolution in order to get reasonably sized plot elements. But it hopefully won't be too difficult for me to find a suitable formula...
2) The text lables in the resulting graphic look a little bit odd:
screenshot_text.png
And the thickness of the lines of the axes (and the grid) doesn't seem to get adjusted. The resulting lines seem to be a little too thin for printing.
Update: I found a way for getting rid of the scaling factor. In my project I successfully use the following code to generate pixel images that can be of any resolution and always look the same when displayed in the same "real world" size:
const double toInch = 1.0 / 25.4; //convert mm to inch
//the user is asked for setWidth and setHeight (intended "real world" size in mm)
const QSizeF size
= QSizeF(setWidth, setHeight
) * toInch
* setResolution;
const QRectF documentRect
( 0.0,
0.0, size.
width(), size.
height() );
const qreal toDPM = 1.0 / 0.0254;
const QRect imageRect
= documentRect.
toRect();
//the selected resolution (setResolution) is converted to DotsPerMeter
image.setDotsPerMeterX(setResolution * toDPM);
image.setDotsPerMeterY(setResolution * toDPM);
image.
fill(QColor(Qt
::white).
rgba());
QwtPlotRenderer renderer;
renderer.render(par->spectrum_plot, &painter, image.rect());
painter.end();
image.save(fileName, format.toLatin1(), setQuality);
const double toInch = 1.0 / 25.4; //convert mm to inch
//the user is asked for setWidth and setHeight (intended "real world" size in mm)
const QSizeF size = QSizeF(setWidth, setHeight) * toInch * setResolution;
const QRectF documentRect( 0.0, 0.0, size.width(), size.height() );
const qreal toDPM = 1.0 / 0.0254;
const QRect imageRect = documentRect.toRect();
QImage image( imageRect.size(), QImage::Format_ARGB32 );
//the selected resolution (setResolution) is converted to DotsPerMeter
image.setDotsPerMeterX(setResolution * toDPM);
image.setDotsPerMeterY(setResolution * toDPM);
image.fill(QColor(Qt::white).rgba());
QPainter painter(&image);
QwtPlotRenderer renderer;
renderer.render(par->spectrum_plot, &painter, image.rect());
painter.end();
image.save(fileName, format.toLatin1(), setQuality);
To copy to clipboard, switch view to plain text mode
This works so far as intended. Unfortunately, the problem concerning the too thin lines and odd looking texts are still there.
Bookmarks