地面站终端 App
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
4.0 KiB

15 years ago
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
15 years ago
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#ifndef QWT_DIAL_NEEDLE_H
#define QWT_DIAL_NEEDLE_H 1
#include "qwt_global.h"
#include <qpalette.h>
15 years ago
class QPainter;
class QPoint;
/*!
\brief Base class for needles that can be used in a QwtDial.
QwtDialNeedle is a pointer that indicates a value by pointing
to a specific direction.
15 years ago
\sa QwtDial, QwtCompass
*/
class QWT_EXPORT QwtDialNeedle
{
public:
QwtDialNeedle();
virtual ~QwtDialNeedle();
virtual void setPalette( const QPalette & );
const QPalette &palette() const;
virtual void draw( QPainter *painter, const QPointF &center,
double length, double direction,
QPalette::ColorGroup = QPalette::Active ) const;
protected:
15 years ago
/*!
\brief Draw the needle
15 years ago
The origin of the needle is at position (0.0, 0.0 )
pointing in direction 0.0 ( = east ).
15 years ago
The painter is already initialized with translation and
rotation.
15 years ago
\param painter Painter
\param length Length of the needle
\param colorGroup Color group, used for painting
\sa setPalette(), palette()
*/
virtual void drawNeedle( QPainter *painter,
double length, QPalette::ColorGroup colorGroup ) const = 0;
virtual void drawKnob( QPainter *, double width,
const QBrush &, bool sunken ) const;
15 years ago
private:
QPalette d_palette;
};
/*!
\brief A needle for dial widgets
The following colors are used:
- QPalette::Mid\n
15 years ago
Pointer
- QPalette::Base\n
15 years ago
Knob
\sa QwtDial, QwtCompass
*/
class QWT_EXPORT QwtDialSimpleNeedle: public QwtDialNeedle
{
public:
//! Style of the needle
enum Style
{
//! Arrow
15 years ago
Arrow,
//! A straight line from the center
15 years ago
Ray
};
QwtDialSimpleNeedle( Style, bool hasKnob = true,
const QColor &mid = Qt::gray, const QColor &base = Qt::darkGray );
15 years ago
void setWidth( double width );
double width() const;
15 years ago
protected:
virtual void drawNeedle( QPainter *, double length,
QPalette::ColorGroup ) const;
15 years ago
private:
Style d_style;
bool d_hasKnob;
double d_width;
15 years ago
};
/*!
\brief A magnet needle for compass widgets
A magnet needle points to two opposite directions indicating
north and south.
The following colors are used:
- QPalette::Light\n
15 years ago
Used for pointing south
- QPalette::Dark\n
15 years ago
Used for pointing north
- QPalette::Base\n
15 years ago
Knob (ThinStyle only)
\sa QwtDial, QwtCompass
*/
class QWT_EXPORT QwtCompassMagnetNeedle: public QwtDialNeedle
{
public:
//! Style of the needle
enum Style
{
//! A needle with a triangular shape
15 years ago
TriangleStyle,
//! A thin needle
15 years ago
ThinStyle
};
QwtCompassMagnetNeedle( Style = TriangleStyle,
const QColor &light = Qt::white, const QColor &dark = Qt::red );
15 years ago
protected:
virtual void drawNeedle( QPainter *,
double length, QPalette::ColorGroup ) const;
15 years ago
private:
Style d_style;
};
/*!
\brief An indicator for the wind direction
QwtCompassWindArrow shows the direction where the wind comes from.
- QPalette::Light\n
15 years ago
Used for Style1, or the light half of Style2
- QPalette::Dark\n
15 years ago
Used for the dark half of Style2
\sa QwtDial, QwtCompass
*/
class QWT_EXPORT QwtCompassWindArrow: public QwtDialNeedle
{
public:
//! Style of the arrow
enum Style
{
//! A needle pointing to the center
15 years ago
Style1,
//! A needle pointing to the center
15 years ago
Style2
};
QwtCompassWindArrow( Style, const QColor &light = Qt::white,
const QColor &dark = Qt::gray );
15 years ago
protected:
virtual void drawNeedle( QPainter *,
double length, QPalette::ColorGroup ) const;
15 years ago
private:
Style d_style;
};
#endif