2 Attachment(s)
Issue of overlapping segments on a QwtPlotCurve with a thick transparent QPen
Hello,
I'm trying to draw a QwtPlotCurve with a thick transparent QPen that has some alpha transparency. The issue is that when the straight line segments of the plotted curve overlap, the colors are added (blended?), changing the color of the overlapping region. Here is a minimal example with a single curve, plotted with a red pen, with a thickness of 16, and an alpha of 128:
https://i.imgur.com/Qxv7XOu.jpg
Attachment 13778
Code:
#include "qwt_plot.h"
#include "qwt_plot_curve.h"
#include <QApplication>
int main( int argc, char* argv[] )
{
for (float t = 0.0; t < 10.0; t+=0.1f)
curve->setPen(color, 16);
curve->setSamples(points);
curve->attach(&plot);
plot.show();
return app.exec();
}
My reason for plotting with a thick pen with alpha is try and achieve a "glowing" effect by plotting the same line on top of itself a few times with different widths and alpha values. I've done this in other languages/plotting APIs such as matplotlib and it looks great, and I was hoping to do the same effect with Qwt. Here is a minimal working example of the effect, and a screenshot:
Code:
#include "qwt_plot.h"
#include "qwt_plot_curve.h"
#include <QApplication>
{
color.setAlphaF(alpha);
curve->setPen(color,width);
curve->setSamples(points);
curve->attach(plot);
}
int main( int argc, char* argv[] )
{
for (float t = 0.0; t < 10.0; t+=0.1f)
addCurve(&plot, points, Qt::green, 16, 0.05);
addCurve(&plot, points, Qt::green, 10, 0.1);
addCurve(&plot, points, Qt::green, 6, 0.15);
addCurve(&plot, points, Qt::white, 2, 0.25);
plot.show();
return app.exec();
}
And the result looks like this:
https://i.imgur.com/P55cAdj.jpg
Attachment 13779
If you have any suggestions on how to plot the thick transparent curves without the overlapping segments showing, or other ideas about achieving this effect that would be great! Thank you very much,
Kind regards,
Bob
Re: Issue of overlapping segments on a QwtPlotCurve with a thick transparent QPen
Using a pen with Qt::FlatCap and/or QwtPainter::setPolylineSplitting( false );
HTH,
Uwe
Re: Issue of overlapping segments on a QwtPlotCurve with a thick transparent QPen
Excellent! Thank you very much Uwe, cheers.
Bob