예제 #1
0
/*!
  Draw a compass needle

 \param painter Painter
 \param palette Palette
 \param colorGroup colorGroup
 \param center Center of the dial, start position for the needle
 \param length Length of the needle
 \param direction Direction of the needle, in degrees counter clockwise
*/
void QwtCompassWindArrow::drawStyle2Needle( QPainter *painter,
    const QPalette &palette, QPalette::ColorGroup colorGroup,
    const QPoint &center, int length, double direction )
{
    const QBrush lightBrush = palette.brush( colorGroup, QPalette::Light );
    const QBrush darkBrush = palette.brush( colorGroup, QPalette::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 );

    QPolygon 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();
}
예제 #2
0
/*!
  Draw a compass needle 
*/
void QwtCompassWindArrow::drawStyle2Needle(
    QPainter *painter, const QColorGroup &cg,
    const QPoint &center, int length, double direction) 
{
    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);

    QPointArray pa(3);

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

    pa.setPoint(1, qwtDegree2Pos(arrowCenter, length, direction + angle));
    painter->setBrush(cg.brush(QColorGroup::Dark));
    painter->drawPolygon(pa);

    pa.setPoint(1, qwtDegree2Pos(arrowCenter, length, direction - angle));
    painter->setBrush(cg.brush(QColorGroup::Light));
    painter->drawPolygon(pa);

    painter->restore();
}
예제 #3
0
/*!
  Draw a compass needle

 \param painter Painter
 \param palette Palette
 \param colorGroup colorGroup
 \param center Center of the dial, start position for the needle
 \param length Length of the needle
 \param direction Direction of the needle, in degrees counter clockwise
*/
void QwtCompassWindArrow::drawStyle1Needle( QPainter *painter,
    const QPalette &palette, QPalette::ColorGroup colorGroup,
    const QPoint &center, int length, double direction )
{
    const QBrush lightBrush = palette.brush( colorGroup, QPalette::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 );

    QPolygon 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();
}
예제 #4
0
/*!
  Draw a compass needle

  \param painter Painter
  \param palette Palette
  \param colorGroup Color group
  \param center Center, where the needle starts
  \param length Length of the needle
  \param direction Direction
*/
void QwtCompassMagnetNeedle::drawTriangleNeedle( QPainter *painter,
    const QPalette &palette, QPalette::ColorGroup colorGroup,
    const QPoint &center, int length, double direction )
{
    const QBrush darkBrush = palette.brush( colorGroup, QPalette::Dark );
    const QBrush lightBrush = palette.brush( colorGroup, QPalette::Light );

    QBrush brush;

    const int width = qRound( length / 3.0 );
    const int colorOffset =  10;

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

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

    QPolygon pa( 3 );
    pa.setPoint( 0, arrowCenter );
    pa.setPoint( 1, qwtDegree2Pos( arrowCenter, length, direction ) );

    pa.setPoint( 2, qwtDegree2Pos( arrowCenter, width / 2, direction + 90.0 ) );

    brush = darkBrush;
    brush.setColor( brush.color().dark( 100 + colorOffset ) );
    painter->setBrush( brush );
    painter->drawPolygon( pa );

    pa.setPoint( 2, qwtDegree2Pos( arrowCenter, width / 2, direction - 90.0 ) );

    brush = darkBrush;
    brush.setColor( brush.color().dark( 100 - colorOffset ) );
    painter->setBrush( brush );
    painter->drawPolygon( pa );

    // --

    pa.setPoint( 1, qwtDegree2Pos( arrowCenter, length, direction + 180.0 ) );

    pa.setPoint( 2, qwtDegree2Pos( arrowCenter, width / 2, direction + 90.0 ) );

    brush = lightBrush;
    brush.setColor( brush.color().dark( 100 + colorOffset ) );
    painter->setBrush( brush );
    painter->drawPolygon( pa );

    pa.setPoint( 2, qwtDegree2Pos( arrowCenter, width / 2, direction - 90.0 ) );

    brush = lightBrush;
    brush.setColor( brush.color().dark( 100 - colorOffset ) );
    painter->setBrush( brush );
    painter->drawPolygon( pa );

    painter->restore();
}
예제 #5
0
/*!
  Draw a compass needle

  \param painter Painter
  \param brush Brush
  \param colorOffset Color offset
  \param center Center, where the needle starts
  \param length Length of the needle
  \param width Width of the needle
  \param direction Direction
*/
void QwtCompassMagnetNeedle::drawPointer(
    QPainter *painter, const QBrush &brush,
    int colorOffset, const QPoint &center, int length,
    int width, double direction )
{
    painter->save();

    const int peak = qMax( qRound( length / 10.0 ), 5 );

    const int knobWidth = width + 8;
    QRect knobRect( 0, 0, knobWidth, knobWidth );
    knobRect.moveCenter( center );

    QPolygon pa( 5 );

    pa.setPoint( 0, qwtDegree2Pos( center, width / 2, direction + 90.0 ) );
    pa.setPoint( 1, center );
    pa.setPoint( 2, qwtDegree2Pos( pa.point( 1 ), length - peak, direction ) );
    pa.setPoint( 3, qwtDegree2Pos( center, length, direction ) );
    pa.setPoint( 4, qwtDegree2Pos( pa.point( 0 ), length - peak, direction ) );

    painter->setPen( Qt::NoPen );

    QBrush darkBrush = brush;
    darkBrush.setColor( darkBrush.color().dark( 100 + colorOffset ) );
    painter->setBrush( darkBrush );
    painter->drawPolygon( pa );
    painter->drawPie( knobRect, qRound( direction * 16 ), 90 * 16 );

    pa.setPoint( 0, qwtDegree2Pos( center, width / 2, direction - 90.0 ) );
    pa.setPoint( 4, qwtDegree2Pos( pa.point( 0 ), length - peak, direction ) );

    QBrush lightBrush = brush;
    lightBrush.setColor( lightBrush.color().dark( 100 - colorOffset ) );
    painter->setBrush( lightBrush );
    painter->drawPolygon( pa );
    painter->drawPie( knobRect, qRound( direction * 16 ), -90 * 16 );

    painter->restore();
}