Qwt User's Guide: QwtDialScaleDraw Class Reference

Qwt User's Guide 6.0.1

- Main Page
- Related Pages
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected Member Functions

# QwtDialScaleDraw Class Reference

A special scale draw made for QwtDial. More...

`#include <qwt_dial.h>`

Inheritance diagram for QwtDialScaleDraw:
[legend]

List of all members.

## Public Types
enum | ScaleComponent { Backbone = 0x01, Ticks = 0x02, Labels = 0x04 }
typedef QFlags< ScaleComponent > | ScaleComponents
## Public Member Functions
QPointF | center () const
virtual void | draw (QPainter *, const QPalette &) const
void | enableComponent (ScaleComponent, bool enable=true)
virtual double | extent (const QFont &) const
bool | hasComponent (ScaleComponent) const
virtual QwtText | label (double value) const
double | maxTickLength () const
double | minimumExtent () const
void | moveCenter (const QPointF &)
void | moveCenter (double x, double y)
double | penWidth () const
| QwtDialScaleDraw (QwtDial *)
int | radius () const
const QwtScaleDiv & | scaleDiv () const
QwtScaleMap & | scaleMap ()
const QwtScaleMap & | scaleMap () const
void | setAngleRange (double angle1, double angle2)
void | setMinimumExtent (double)
void | setPenWidth (int width)
void | setPenWidth (double)
void | setRadius (int radius)
void | setScaleDiv (const QwtScaleDiv &s)
void | setSpacing (double margin)
void | setTickLength (QwtScaleDiv::TickType, double length)
void | setTransformation (QwtScaleTransformation *)
double | spacing () const
double | tickLength (QwtScaleDiv::TickType) const
## Protected Member Functions
virtual void | drawBackbone (QPainter *p) const
virtual void | drawLabel (QPainter *p, double val) const
virtual void | drawTick (QPainter *p, double val, double len) const
void | invalidateCache ()
const QwtText & | tickLabel (const QFont &, double value) const

## Detailed Description

A special scale draw made for QwtDial.

See also:
  QwtDial, QwtCompass

## Member Typedef Documentation

typedef QFlags<ScaleComponent> QwtAbstractScaleDraw::ScaleComponents`[inherited]`

Scale components.

## Member Enumeration Documentation

enum QwtAbstractScaleDraw::ScaleComponent`[inherited]`

Components of a scale

See also:
  enableComponent(), hasComponent

Enumerator:

  Backbone | Backbone = the line where the ticks are located.
  Ticks | Ticks.
  Labels | Labels.

## Constructor & Destructor Documentation

QwtDialScaleDraw::QwtDialScaleDraw | ( | QwtDial * | parent | ) | `[explicit]`

Constructor

Parameters:

  parent | Parent dial widget

## Member Function Documentation

QPointF QwtRoundScaleDraw::center | ( |  | ) | const`[inherited]`

Get the center of the scale.

void QwtAbstractScaleDraw::draw | ( | QPainter * | painter,
|  | const QPalette & | palette
| ) |  | const`[virtual, inherited]`

Draw the scale.

Parameters:

  painter | The painter
  palette | Palette, text color is used for the labels, foreground color for ticks and backbone

void QwtRoundScaleDraw::drawBackbone | ( | QPainter * | painter | ) | const`[protected, virtual, inherited]`

Draws the baseline of the scale

Parameters:

  painter | Painter

See also:
  drawTick(), drawLabel()

Implements QwtAbstractScaleDraw.

void QwtRoundScaleDraw::drawLabel | ( | QPainter * | painter,
|  | double | value
| ) |  | const`[protected, virtual, inherited]`

Draws the label for a major scale tick

Parameters:

  painter | Painter
  value | Value

See also:
  drawTick(), drawBackbone()

Implements QwtAbstractScaleDraw.

void QwtRoundScaleDraw::drawTick | ( | QPainter * | painter,
|  | double | value,
|  | double | len
| ) |  | const`[protected, virtual, inherited]`

Draw a tick

Parameters:

  painter | Painter
  value | Value of the tick
  len | Lenght of the tick

See also:
  drawBackbone(), drawLabel()

Implements QwtAbstractScaleDraw.

void QwtAbstractScaleDraw::enableComponent | ( | ScaleComponent | component,
|  | bool | enable = `true`
| ) |  | `[inherited]`

En/Disable a component of the scale

Parameters:

  component | Scale component
  enable | On/Off

See also:
  hasComponent()

double QwtRoundScaleDraw::extent | ( | const QFont & | font | ) | const`[virtual, inherited]`

Calculate the extent of the scale

The extent is the distance between the baseline to the outermost pixel of the scale draw. radius() + extent() is an upper limit for the radius of the bounding circle.

Parameters:

  font | Font used for painting the labels

See also:
  setMinimumExtent(), minimumExtent()

Warning:
  The implemented algo is not too smart and calculates only an upper limit, that might be a few pixels too large

Implements QwtAbstractScaleDraw.

bool QwtAbstractScaleDraw::hasComponent | ( | ScaleComponent | component | ) | const`[inherited]`

Check if a component is enabled

See also:
  enableComponent()

void QwtAbstractScaleDraw::invalidateCache | ( |  | ) | `[protected, inherited]`

Invalidate the cache used by QwtAbstractScaleDraw::tickLabel

The cache is invalidated, when a new QwtScaleDiv is set. If the labels need to be changed. while the same QwtScaleDiv is set, invalidateCache() needs to be called manually.

QwtText QwtDialScaleDraw::label | ( | double | value | ) | const`[virtual]`

Call QwtDial::scaleLabel of the parent dial widget.

Parameters:

  value | Value to display

See also:
  QwtDial::scaleLabel()

Reimplemented from QwtAbstractScaleDraw.

double QwtAbstractScaleDraw::maxTickLength | ( |  | ) | const`[inherited]`

Returns:
  Length of the longest tick

Useful for layout calculations

See also:
  tickLength(), setTickLength()

double QwtAbstractScaleDraw::minimumExtent | ( |  | ) | const`[inherited]`

Get the minimum extent

See also:
  extent(), setMinimumExtent()

void QwtRoundScaleDraw::moveCenter | ( | double | x,
|  | double | y
| ) |  | `[inline, inherited]`

Move the center of the scale draw, leaving the radius unchanged.

void QwtRoundScaleDraw::moveCenter | ( | const QPointF & | center | ) | `[inherited]`

Move the center of the scale draw, leaving the radius unchanged

Parameters:

  center | New center

See also:
  setRadius()

double QwtDialScaleDraw::penWidth | ( |  | ) | const

Returns:
  Pen width used for painting the scale

See also:
  setPenWidth, QwtDial::drawScale()

Reimplemented from QwtAbstractScaleDraw.

int QwtRoundScaleDraw::radius | ( |  | ) | const`[inherited]`

Get the radius

Radius is the radius of the backbone without ticks and labels.

See also:
  setRadius(), extent()

const QwtScaleDiv & QwtAbstractScaleDraw::scaleDiv | ( |  | ) | const`[inherited]`

Returns:
  scale division

const QwtScaleMap & QwtAbstractScaleDraw::scaleMap | ( |  | ) | const`[inherited]`

Returns:
  Map how to translate between scale and pixel values

QwtScaleMap & QwtAbstractScaleDraw::scaleMap | ( |  | ) | `[inherited]`

Returns:
  Map how to translate between scale and pixel values

void QwtRoundScaleDraw::setAngleRange | ( | double | angle1,
|  | double | angle2
| ) |  | `[inherited]`

Adjust the baseline circle segment for round scales.

The baseline will be drawn from min(angle1,angle2) to max(angle1, angle2). The default setting is [ -135, 135 ]. An angle of 0 degrees corresponds to the 12 o'clock position, and positive angles count in a clockwise direction.

Parameters:

  angle1 |
  angle2 | boundaries of the angle interval in degrees.

Warning:
  - The angle range is limited to [-360, 360] degrees. Angles exceeding this range will be clipped.
  - For angles more than 359 degrees above or below min(angle1, angle2), scale marks will not be drawn.
  - If you need a counterclockwise scale, use QwtScaleDiv::setRange

void QwtAbstractScaleDraw::setMinimumExtent | ( | double | minExtent | ) | `[inherited]`

Set a minimum for the extent.

The extent is calculated from the coomponents of the scale draw. In situations, where the labels are changing and the layout depends on the extent (f.e scrolling a scale), setting an upper limit as minimum extent will avoid jumps of the layout.

Parameters:

  minExtent | Minimum extent

See also:
  extent(), minimumExtent()

void QwtDialScaleDraw::setPenWidth | ( | double | penWidth | ) |

Set the pen width used for painting the scale

Parameters:

  penWidth | Pen width

See also:
  penWidth(), QwtDial::drawScale()

void QwtAbstractScaleDraw::setPenWidth | ( | int | width | ) | `[inherited]`

Specify the width of the scale pen.

Parameters:

  width | Pen width

See also:
  penWidth()

void QwtRoundScaleDraw::setRadius | ( | int | radius | ) | `[inherited]`

Change of radius the scale

Radius is the radius of the backbone without ticks and labels.

Parameters:

  radius | New Radius

See also:
  moveCenter()

void QwtAbstractScaleDraw::setScaleDiv | ( | const QwtScaleDiv & | sd | ) | `[inherited]`

Change the scale division

Parameters:

  sd | New scale division

void QwtAbstractScaleDraw::setSpacing | ( | double | spacing | ) | `[inherited]`

Set the spacing between tick and labels.

The spacing is the distance between ticks and labels. The default spacing is 4 pixels.

Parameters:

  spacing | Spacing

See also:
  spacing()

void QwtAbstractScaleDraw::setTickLength | ( | QwtScaleDiv::TickType | tickType,
|  | double | length
| ) |  | `[inherited]`

Set the length of the ticks

Parameters:

  tickType | Tick type
  length | New length

Warning:
  the length is limited to [0..1000]

void QwtAbstractScaleDraw::setTransformation | ( | QwtScaleTransformation * | transformation | ) | `[inherited]`

Change the transformation of the scale

Parameters:

  transformation | New scale transformation

double QwtAbstractScaleDraw::spacing | ( |  | ) | const`[inherited]`

Get the spacing.

The spacing is the distance between ticks and labels. The default spacing is 4 pixels.

See also:
  setSpacing()

const QwtText & QwtAbstractScaleDraw::tickLabel | ( | const QFont & | font,
|  | double | value
| ) |  | const`[protected, inherited]`

Convert a value into its representing label and cache it.

The conversion between value and label is called very often in the layout and painting code. Unfortunately the calculation of the label sizes might be slow (really slow for rich text in Qt4), so it's necessary to cache the labels.

Parameters:

  font | Font
  value | Value

Returns:
  Tick label

double QwtAbstractScaleDraw::tickLength | ( | QwtScaleDiv::TickType | tickType | ) | const`[inherited]`

Return the length of the ticks

See also:
  setTickLength(), maxTickLength()