Public Types | Public Member Functions | Static Public Member Functions

QwtCompassWindArrow Class Reference

An indicator for the wind direction. More...

#include <qwt_dial_needle.h>

Inheritance diagram for QwtCompassWindArrow:
Inheritance graph
[legend]
Collaboration diagram for QwtCompassWindArrow:
Collaboration graph
[legend]

List of all members.

Public Types

enum  Style { Style1, Style2 }
 

Style of the arrow.

More...

Public Member Functions

 QwtCompassWindArrow (Style, const QColor &light=Qt::white, const QColor &dark=Qt::gray)
virtual void draw (QPainter *, const QPoint &, int length, double direction, QPalette::ColorGroup=QPalette::Active) const

Static Public Member Functions

static void drawStyle1Needle (QPainter *, const QPalette &, QPalette::ColorGroup, const QPoint &, int length, double direction)
static void drawStyle2Needle (QPainter *, const QPalette &, QPalette::ColorGroup, const QPoint &, int length, double direction)

Detailed Description

An indicator for the wind direction.

QwtCompassWindArrow shows the direction where the wind comes from.

See also:
QwtDial, QwtCompass

Definition at line 170 of file qwt_dial_needle.h.


Member Enumeration Documentation

Style of the arrow.

Enumerator:
Style1 
Style2 

Definition at line 174 of file qwt_dial_needle.h.

    {
        Style1,
        Style2
    };

Constructor & Destructor Documentation

QwtCompassWindArrow::QwtCompassWindArrow ( Style  style,
const QColor &  light = Qt::white,
const QColor &  dark = Qt::gray 
)

Constructor

Parameters:
styleArrow style
lightLight color
darkDark color

Definition at line 495 of file qwt_dial_needle.cpp.

References QwtDialNeedle::palette(), and QwtDialNeedle::setPalette().

                                                :
    d_style(style)
{
    QPalette palette;
    for ( int i = 0; i < QPalette::NColorGroups; i++ )
    {
        palette.setColor((QPalette::ColorGroup)i,
            QwtPalette::Light, light);
        palette.setColor((QPalette::ColorGroup)i,
            QwtPalette::Dark, dark);
    }

    setPalette(palette);
}

Member Function Documentation

void QwtCompassWindArrow::draw ( QPainter *  painter,
const QPoint &  center,
int  length,
double  direction,
QPalette::ColorGroup  colorGroup = QPalette::Active 
) const [virtual]

Draw the needle

Parameters:
painterPainter
centerCenter of the dial, start position for the needle
lengthLength of the needle
directionDirection of the needle, in degrees counter clockwise
colorGroupColor group, used for painting

Implements QwtDialNeedle.

Definition at line 520 of file qwt_dial_needle.cpp.

References drawStyle1Needle(), drawStyle2Needle(), QwtDialNeedle::palette(), and Style1.

{
    if ( d_style == Style1 )
    {
        drawStyle1Needle(painter, palette(), colorGroup,
            center, length, direction);
    }
    else
    {
        drawStyle2Needle(painter, palette(), colorGroup,
            center, length, direction); 
    }
}
void QwtCompassWindArrow::drawStyle1Needle ( QPainter *  painter,
const QPalette &  palette,
QPalette::ColorGroup  colorGroup,
const QPoint &  center,
int  length,
double  direction 
) [static]

Draw a compass needle

Parameters:
painterPainter
palettePalette
colorGroupcolorGroup
centerCenter of the dial, start position for the needle
lengthLength of the needle
directionDirection of the needle, in degrees counter clockwise

Definition at line 545 of file qwt_dial_needle.cpp.

References qwtDegree2Pos().

Referenced by draw().

{
    const QBrush lightBrush = palette.brush(colorGroup, QwtPalette::Light);

    const double AR1[] = {0, 0.4, 0.3, 1, 0.8, 1, 0.3, 0.4};
    const double AW1[] = {0, -45, -20, -15, 0, 15, 20, 45};

    const QPoint arrowCenter(center.x() + 1, center.y() + 1);

    QwtPolygon pa(8);
    pa.setPoint(0, arrowCenter);
    for (int i=1; i<8; i++) 
    {
        const QPoint p = qwtDegree2Pos(center, 
            AR1[i] * length, direction + AW1[i]);
        pa.setPoint(i, p);
    }

    painter->save();
    painter->setPen(Qt::NoPen);
    painter->setBrush(lightBrush);
    painter->drawPolygon(pa);
    painter->restore();
}
void QwtCompassWindArrow::drawStyle2Needle ( QPainter *  painter,
const QPalette &  palette,
QPalette::ColorGroup  colorGroup,
const QPoint &  center,
int  length,
double  direction 
) [static]

Draw a compass needle

Parameters:
painterPainter
palettePalette
colorGroupcolorGroup
centerCenter of the dial, start position for the needle
lengthLength of the needle
directionDirection of the needle, in degrees counter clockwise

Definition at line 582 of file qwt_dial_needle.cpp.

References qwtDegree2Pos().

Referenced by draw().

{
    const QBrush lightBrush = palette.brush(colorGroup, QwtPalette::Light);
    const QBrush darkBrush = palette.brush(colorGroup, QwtPalette::Dark);

    painter->save();
    painter->setPen(Qt::NoPen);

    const double angle = 12.0;
    const double ratio = 0.7;

    const QPoint arrowCenter(center.x() + 1, center.y() + 1);

    QwtPolygon pa(3);

    pa.setPoint(0, center);
    pa.setPoint(2, qwtDegree2Pos(arrowCenter, ratio * length, direction));

    pa.setPoint(1, qwtDegree2Pos(arrowCenter, length, direction + angle));
    painter->setBrush(darkBrush);
    painter->drawPolygon(pa);

    pa.setPoint(1, qwtDegree2Pos(arrowCenter, length, direction - angle));
    painter->setBrush(lightBrush);
    painter->drawPolygon(pa);

    painter->restore();
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines