An indicator for the wind direction. More...
#include <qwt_dial_needle.h>
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) |
An indicator for the wind direction.
QwtCompassWindArrow shows the direction where the wind comes from.
Definition at line 170 of file qwt_dial_needle.h.
Style of the arrow.
Definition at line 174 of file qwt_dial_needle.h.
QwtCompassWindArrow::QwtCompassWindArrow | ( | Style | style, |
const QColor & | light = Qt::white , |
||
const QColor & | dark = Qt::gray |
||
) |
Constructor
style | Arrow style |
light | Light color |
dark | Dark 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); }
void QwtCompassWindArrow::draw | ( | QPainter * | painter, |
const QPoint & | center, | ||
int | length, | ||
double | direction, | ||
QPalette::ColorGroup | colorGroup = QPalette::Active |
||
) | const [virtual] |
Draw the needle
painter | Painter |
center | Center of the dial, start position for the needle |
length | Length of the needle |
direction | Direction of the needle, in degrees counter clockwise |
colorGroup | Color 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
painter | Painter |
palette | Palette |
colorGroup | colorGroup |
center | Center of the dial, start position for the needle |
length | Length of the needle |
direction | Direction 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
painter | Painter |
palette | Palette |
colorGroup | colorGroup |
center | Center of the dial, start position for the needle |
length | Length of the needle |
direction | Direction 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(); }