Ingo Maindorfer | 23 Sep 11:38

Different colors in one curve

Dear list,

I'd like to draw some data in a simple curve, but every data point 
should have a different color depending on a third data value.
The type of data is cartesian data with x and y values and a third one 
which should influence the color.

Any suggestions?

Best regards,

Ingo

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Uwe Rathmann | 25 Sep 08:24

Re: Different colors in one curve

On Tuesday 23 September 2008 11:38, Ingo Maindorfer wrote:

> I'd like to draw some data in a simple curve, but every data point
> should have a different color depending on a third data value.
> The type of data is cartesian data with x and y values and a third one
> which should influence the color.

This is a new type of plot item ( planned for Qwt 5.2.x ). It will represent 
3D Data using a QwtColorMap.

For the moment I recommend to derive from QwtPlotCurve:

void YourCurve::drawCurve(QPainter *painter, int style,
    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    int from, int to) const
{
    for (int i = from; i <= to; i++)
    {
        const int xi = xMap.transform(x(i));
        const int yi = yMap.transform(y(i));

        const QColor color = _colorMap(...);

        painter->setPen(color);
        painter->drawPoint(xi, yi);
}

Uwe

-------------------------------------------------------------------------
(Continue reading)


Gmane