# QwtPainter Class Reference

Collaboration diagram for QwtPainter:

[legend]
List of all members.

## Detailed Description

A collection of QPainter workarounds.

1) Clipping to coordinate system limits (Qt3 only)

On X11 pixel coordinates are stored in shorts. Qt produces overruns when mapping QCOORDS to shorts.

2) Scaling to device metrics

QPainter scales fonts, line and fill patterns to the metrics of the paint device. Other values like the geometries of rects, points remain device independend. To enable a device independent widget implementation, QwtPainter adds scaling of these geometries. (Unfortunately QPainter::scale scales both types of paintings, so the objects of the first type would be scaled twice).

Definition at line 62 of file qwt_painter.h.

## Static Public Member Functions

static void | setMetricsMap (const QPaintDevice *layout, const QPaintDevice *device)
static void | setMetricsMap (const QwtMetricsMap &)
static void | resetMetricsMap ()
static const QwtMetricsMap & | metricsMap ()
static void | setDeviceClipping (bool)
static bool | deviceClipping ()
static void | setClipRect (QPainter *, const QRect &)
static void | drawText (QPainter *, int x, int y, const QString &)
static void | drawText (QPainter *, const QPoint &, const QString &)
static void | drawText (QPainter *, int x, int y, int w, int h, int flags, const QString &)
static void | drawText (QPainter *, const QRect &, int flags, const QString &)
static void | drawSimpleRichText (QPainter *, const QRect &, int flags, QTextDocument &)
static void | drawRect (QPainter *, int x, int y, int w, int h)
static void | drawRect (QPainter *, const QRect &rect)
static void | fillRect (QPainter *, const QRect &, const QBrush &)
static void | drawEllipse (QPainter *, const QRect &)
static void | drawPie (QPainter *, const QRect &r, int a, int alen)
static void | drawLine (QPainter *, int x1, int y1, int x2, int y2)
static void | drawLine (QPainter *, const QPoint &p1, const QPoint &p2)
static void | drawPolygon (QPainter *, const QwtPolygon &pa)
static void | drawPolyline (QPainter *, const QwtPolygon &pa)
static void | drawPoint (QPainter *, int x, int y)
static void | drawRoundFrame (QPainter *, const QRect &, int width, const QPalette &, bool sunken)
static void | drawFocusRect (QPainter *, QWidget *)
static void | drawFocusRect (QPainter *, QWidget *, const QRect &)
static QwtPolygon | clip (const QwtPolygon &)
static void | drawColorBar (QPainter *painter, const QwtColorMap &, const QwtDoubleInterval &, const QwtScaleMap &, Qt::Orientation, const QRect &)

## Member Function Documentation

void QwtPainter::setMetricsMap | ( | const QPaintDevice * | layout,
|  | const QPaintDevice * | device |
| ) |  |  | `[static]`

Scale all QwtPainter drawing operations using the ratio QwtPaintMetrics(from).logicalDpiX() / QwtPaintMetrics(to).logicalDpiX() and QwtPaintMetrics(from).logicalDpiY() / QwtPaintMetrics(to).logicalDpiY()

See also:
  QwtPainter::resetScaleMetrics(), QwtPainter::scaleMetricsX, QwtPainter::scaleMetricsY()

Definition at line 133 of file qwt_painter.cpp.

References QwtMetricsMap::setMetrics().

Referenced by QwtScaleDraw::drawTick(), and QwtPlot::print().

void QwtPainter::setMetricsMap | ( | const QwtMetricsMap & | map | ) | `[static]`

Change the metrics map

See also:
  QwtPainter::resetMetricsMap, QwtPainter::metricsMap

Definition at line 143 of file qwt_painter.cpp.

void QwtPainter::resetMetricsMap | ( |  | ) | `[static]`

Reset the metrics map to the ratio 1:1

See also:
  QwtPainter::setMetricsMap, QwtPainter::resetMetricsMap

Definition at line 152 of file qwt_painter.cpp.

Referenced by QwtScaleDraw::drawTick(), and QwtPlot::print().

const QwtMetricsMap & QwtPainter::metricsMap | ( |  | ) | `[static]`

Returns:
  Metrics map

Definition at line 160 of file qwt_painter.cpp.

Referenced by QwtText::draw(), QwtSymbol::draw(), QwtPlotMarker::draw(), QwtLegendItem::drawIdentifier(), QwtLegendItem::drawItem(), QwtPlotCurve::drawSymbols(), QwtScaleDraw::drawTick(), QwtText::heightForWidth(), QwtPlot::print(), QwtPlot::printScale(), and QwtText::textSize().

void QwtPainter::setDeviceClipping | ( | bool | enable | ) | `[static]`

En/Disable device clipping.

On X11 the default for device clipping is enabled, otherwise it is disabled.

See also:
  QwtPainter::deviceClipping()

Definition at line 62 of file qwt_painter.cpp.

bool QwtPainter::deviceClipping | ( |  | ) | `[static]`

Returns whether device clipping is enabled. On X11 the default is enabled, otherwise it is disabled.

See also:
  QwtPainter::setDeviceClipping()

Definition at line 73 of file qwt_painter.cpp.

void QwtPainter::setClipRect | ( | QPainter * | painter,
|  | const QRect & | rect |
| ) |  |  | `[static]`

Wrapper for QPainter::setClipRect()

Definition at line 168 of file qwt_painter.cpp.

References QwtMetricsMap::layoutToDevice().

Referenced by QwtPlot::printCanvas(), and QwtPlot::printLegend().

void QwtPainter::drawText | ( | QPainter * | painter,
|  | int | x,
|  | int | y,
|  | const QString & | text |
| ) |  |  | `[static]`

Wrapper for QPainter::drawText()

Definition at line 310 of file qwt_painter.cpp.

Referenced by QwtPlainTextEngine::draw(), and drawText().

void QwtPainter::drawText | ( | QPainter * | painter,
|  | const QPoint & | pos,
|  | const QString & | text |
| ) |  |  | `[static]`

Wrapper for QPainter::drawText()

Definition at line 319 of file qwt_painter.cpp.

References QwtMetricsMap::layoutToDevice().

void QwtPainter::drawText | ( | QPainter * | painter,
|  | int | x,
|  | int | y,
|  | int | w,
|  | int | h,
|  | int | flags,
|  | const QString & | text |
| ) |  |  | `[static]`

Wrapper for QPainter::drawText()

Definition at line 335 of file qwt_painter.cpp.

References drawText().

void QwtPainter::drawText | ( | QPainter * | painter,
|  | const QRect & | rect,
|  | int | flags,
|  | const QString & | text |
| ) |  |  | `[static]`

Wrapper for QPainter::drawText()

Definition at line 344 of file qwt_painter.cpp.

References QwtMetricsMap::layoutToDevice().

void QwtPainter::drawSimpleRichText | ( | QPainter * | painter,
|  | const QRect & | rect,
|  | int | flags,
|  | QTextDocument & | text |
| ) |  |  | `[static]`

Wrapper for QSimpleRichText::draw()

Definition at line 391 of file qwt_painter.cpp.

References QwtMetricsMap::layoutToDevice().

Referenced by QwtRichTextEngine::draw().

void QwtPainter::drawRect | ( | QPainter * | painter,
|  | int | x,
|  | int | y,
|  | int | w,
|  | int | h |
| ) |  |  | `[static]`

Wrapper for QPainter::drawRect()

Definition at line 176 of file qwt_painter.cpp.

Referenced by QwtText::draw(), QwtSymbol::draw(), QwtPicker::drawRubberBand(), and QwtPlot::printCanvas().

void QwtPainter::drawRect | ( | QPainter * | painter,
|  | const QRect & | rect |
| ) |  |  | `[static]`

Wrapper for QPainter::drawRect()

Definition at line 184 of file qwt_painter.cpp.

References drawPolyline(), fillRect(), and QwtMetricsMap::layoutToDevice().

void QwtPainter::fillRect | ( | QPainter * | painter,
|  | const QRect & | rect,
|  | const QBrush & | brush |
| ) |  |  | `[static]`

Wrapper for QPainter::fillRect()

Definition at line 228 of file qwt_painter.cpp.

References QwtMetricsMap::layoutToDevice().

Referenced by drawRect(), and QwtPlot::printCanvas().

void QwtPainter::drawEllipse | ( | QPainter * | painter,
|  | const QRect & | rect |
| ) |  |  | `[static]`

Wrapper for QPainter::drawEllipse()

Definition at line 281 of file qwt_painter.cpp.

References QwtMetricsMap::layoutToDevice().

Referenced by QwtSymbol::draw(), and QwtPicker::drawRubberBand().

void QwtPainter::drawPie | ( | QPainter * | painter,
|  | const QRect & | rect,
|  | int | a,
|  | int | alen |
| ) |  |  | `[static]`

Wrapper for QPainter::drawPie()

Definition at line 266 of file qwt_painter.cpp.

References QwtMetricsMap::layoutToDevice().

void QwtPainter::drawLine | ( | QPainter * | painter,
|  | int | x1,
|  | int | y1,
|  | int | x2,
|  | int | y2 |
| ) |  |  | `[static]`

Wrapper for QPainter::drawLine()

Definition at line 424 of file qwt_painter.cpp.

References drawPolyline(), QwtMetricsMap::isIdentity(), and QwtMetricsMap::layoutToDevice().

Referenced by QwtSymbol::draw(), QwtPlotMarker::draw(), QwtScaleDraw::drawBackbone(), QwtPlotSpectrogram::drawContourLines(), QwtLegendItem::drawIdentifier(), drawLine(), QwtPicker::drawRubberBand(), QwtPlotCurve::drawSticks(), QwtScaleDraw::drawTick(), and QwtRoundScaleDraw::drawTick().

void QwtPainter::drawLine | ( | QPainter * | ,
|  | const QPoint & | p1,
|  | const QPoint & | p2 |
| ) |  |  | `[inline, static]`

Wrapper for QPainter::drawLine().

Definition at line 143 of file qwt_painter.h.

References drawLine().

void QwtPainter::drawPolygon | ( | QPainter * | painter,
|  | const QwtPolygon & | pa |
| ) |  |  | `[static]`

Wrapper for QPainter::drawPolygon()

Definition at line 474 of file qwt_painter.cpp.

References clip(), and QwtMetricsMap::layoutToDevice().

Referenced by QwtSymbol::draw(), and QwtPlotCurve::fillCurve().

void QwtPainter::drawPolyline | ( | QPainter * | painter,
|  | const QwtPolygon & | pa |
| ) |  |  | `[static]`

Wrapper for QPainter::drawPolyline()

Definition at line 491 of file qwt_painter.cpp.

References clip(), and QwtMetricsMap::layoutToDevice().

Referenced by drawLine(), QwtPlotCurve::drawLines(), drawRect(), and QwtPlotCurve::drawSteps().

void QwtPainter::drawPoint | ( | QPainter * | painter,
|  | int | x,
|  | int | y |
| ) |  |  | `[static]`

Wrapper for QPainter::drawPoint()

Definition at line 534 of file qwt_painter.cpp.

References QwtMetricsMap::layoutToDevice().

Referenced by QwtPlotCurve::drawDots().

void QwtPainter::drawRoundFrame | ( | QPainter * | ,
|  | const QRect & | ,
|  | int | width,
|  | const QPalette & | ,
|  | bool | sunken |
| ) |  |  | `[static]`

Draw a round frame.

Definition at line 608 of file qwt_painter.cpp.

Referenced by QwtDial::drawFrame().

QwtPolygon QwtPainter::clip | ( | const QwtPolygon & |  | ) | `[static]`

Clip a point array.

Definition at line 95 of file qwt_painter.cpp.

References QwtClipper::clipPolygon().

Referenced by drawPolygon(), and drawPolyline().