1 Attachment(s)
curve with QLinearGradient
Hello,
I have a curve filled with a linear gradient which the colors depends on certain values.
The problem is : if the curve have a concave shape or local minimum, there is a shift in the position of the colors at the same Y position of the minimum and after its X position, please see the image.
Anyone could help me to find out why this happens :confused:
cheers,
Attachment 12021
Re: curve with QLinearGradient
Assuming, that you fill the curve using QwtPlotCurve::setBrush(), the problem should be somewhere in the paint engine of your system. What type of graphic system is your backend ?
Uwe
Re: curve with QLinearGradient
Hi Uwe and thank you for your reply.
Yes I used QwtPlotCurve::setBrush(). The problem persists on both OS ubuntu 16.04 and Windows 10.
Re: curve with QLinearGradient
Then we are talking about the raster paint engine and you should be able to reproduce the problem with a small standalone application drawing a QPolygon to a QImage.
Uwe
1 Attachment(s)
Re: curve with QLinearGradient
Indeed I was able to reproduce this in a simple polygon draw with qlineargradient :
Code:
p.begin(this) ;
g.setColorAt(0, Qt::red);
g.setColorAt(0.2, Qt::yellow);
g.setColorAt(0.4, Qt::green);
g.setColorAt(0.401, Qt::yellow);
g.setColorAt(0.6, Qt::cyan);
g.setColorAt(0.602, Qt::black) ;
g.setColorAt(0.8, Qt::blue);
g.setColorAt(0.801, Qt::yellow);
g.setColorAt(1, Qt::white);
p.setBrush(g);
p.drawPolygon(poly);
p.end() ;
And this what it gave me Attachment 12023
Does this mean that this is a bug in the raster paint engine ? could it be changed to other paint engine ?
Re: curve with QLinearGradient
Quote:
Does this mean that this is a bug in the raster paint engine ?
Yes.
Quote:
could it be changed to other paint engine ?
First of all you could try a different version of Qt.
With Qt4/X11 you could use the X11 paint engine, what is IMHO superior to all other options, when using Qwt: hardware accelerated + no bugs.
There are also 2 different types of OpenGL paint engines. When using Qwt from SVN trunk you could play with the QwtPlotCanvas::OpenGLBuffer mode.
But if I were in your shoes I would try:
- fill a temporary QImage with your gradient
- setting a clip path with the polygon
- draw the image
Uwe
Re: curve with QLinearGradient
Quote:
- fill a temporary QImage with your gradient
- setting a clip path with the polygon
- draw the image
That worked out.
I overloaded the method QwtPlotCurve::fillCurve so it would do the same and it is acceptable.
Thank you very much :D