Static Public Member Functions | Static Private Attributes | List of all members
QwtPainter Class Reference

A collection of QPainter workarounds. More...

#include <qwt_painter.h>

Static Public Member Functions

static QPixmap backingStore (QWidget *, const QSize &)
 
static qreal devicePixelRatio (const QPaintDevice *)
 
static void drawBackgound (QPainter *, const QRectF &, const QWidget *)
 
static void drawColorBar (QPainter *, const QwtColorMap &, const QwtInterval &, const QwtScaleMap &, Qt::Orientation, const QRectF &)
 
static void drawEllipse (QPainter *, const QRectF &)
 Wrapper for QPainter::drawEllipse() More...
 
static void drawFocusRect (QPainter *, const QWidget *)
 Draw a focus rectangle on a widget using its style. More...
 
static void drawFocusRect (QPainter *, const QWidget *, const QRect &)
 Draw a focus rectangle on a widget using its style. More...
 
static void drawFrame (QPainter *, const QRectF &rect, const QPalette &palette, QPalette::ColorRole foregroundRole, int lineWidth, int midLineWidth, int frameStyle)
 
static void drawImage (QPainter *, const QRectF &, const QImage &)
 Wrapper for QPainter::drawImage() More...
 
static void drawLine (QPainter *, const QLineF &)
 Wrapper for QPainter::drawLine() More...
 
static void drawLine (QPainter *, const QPointF &p1, const QPointF &p2)
 Wrapper for QPainter::drawLine() More...
 
static void drawLine (QPainter *, qreal x1, qreal y1, qreal x2, qreal y2)
 Wrapper for QPainter::drawLine() More...
 
static void drawPath (QPainter *, const QPainterPath &)
 Wrapper for QPainter::drawPath() More...
 
static void drawPie (QPainter *, const QRectF &r, int a, int alen)
 Wrapper for QPainter::drawPie() More...
 
static void drawPixmap (QPainter *, const QRectF &, const QPixmap &)
 Wrapper for QPainter::drawPixmap() More...
 
static void drawPoint (QPainter *, const QPoint &)
 Wrapper for QPainter::drawPoint() More...
 
static void drawPoint (QPainter *, const QPointF &)
 Wrapper for QPainter::drawPoint() More...
 
static void drawPoint (QPainter *, qreal x, qreal y)
 Wrapper for QPainter::drawPoint() More...
 
static void drawPoints (QPainter *, const QPoint *, int pointCount)
 Wrapper for QPainter::drawPoints() More...
 
static void drawPoints (QPainter *, const QPointF *, int pointCount)
 Wrapper for QPainter::drawPoints() More...
 
static void drawPoints (QPainter *, const QPolygon &)
 Wrapper for QPainter::drawPoints() More...
 
static void drawPoints (QPainter *, const QPolygonF &)
 Wrapper for QPainter::drawPoints() More...
 
static void drawPolygon (QPainter *, const QPolygon &)
 Wrapper for QPainter::drawPolygon() More...
 
static void drawPolygon (QPainter *, const QPolygonF &)
 Wrapper for QPainter::drawPolygon() More...
 
static void drawPolyline (QPainter *, const QPoint *, int pointCount)
 Wrapper for QPainter::drawPolyline() More...
 
static void drawPolyline (QPainter *, const QPointF *, int pointCount)
 Wrapper for QPainter::drawPolyline() More...
 
static void drawPolyline (QPainter *, const QPolygon &)
 Wrapper for QPainter::drawPolyline() More...
 
static void drawPolyline (QPainter *, const QPolygonF &)
 Wrapper for QPainter::drawPolyline() More...
 
static void drawRect (QPainter *, const QRectF &rect)
 Wrapper for QPainter::drawRect() More...
 
static void drawRect (QPainter *, qreal x, qreal y, qreal w, qreal h)
 Wrapper for QPainter::drawRect() More...
 
static void drawRoundedFrame (QPainter *, const QRectF &, qreal xRadius, qreal yRadius, const QPalette &, int lineWidth, int frameStyle)
 
static void drawRoundFrame (QPainter *, const QRectF &, const QPalette &, int lineWidth, int frameStyle)
 
static void drawSimpleRichText (QPainter *, const QRectF &, int flags, const QTextDocument &)
 
static void drawText (QPainter *, const QPointF &, const QString &)
 Wrapper for QPainter::drawText() More...
 
static void drawText (QPainter *, const QRectF &, int flags, const QString &)
 Wrapper for QPainter::drawText() More...
 
static void drawText (QPainter *, qreal x, qreal y, const QString &)
 Wrapper for QPainter::drawText() More...
 
static void drawText (QPainter *, qreal x, qreal y, qreal w, qreal h, int flags, const QString &)
 Wrapper for QPainter::drawText() More...
 
static qreal effectivePenWidth (const QPen &)
 
static void fillPixmap (const QWidget *, QPixmap &, const QPoint &offset=QPoint())
 
static void fillRect (QPainter *, const QRectF &, const QBrush &)
 Wrapper for QPainter::fillRect() More...
 
static int horizontalAdvance (const QFontMetrics &, const QString &)
 
static int horizontalAdvance (const QFontMetrics &, QChar)
 
static qreal horizontalAdvance (const QFontMetricsF &, const QString &)
 
static qreal horizontalAdvance (const QFontMetricsF &, QChar)
 
static bool isAligning (const QPainter *)
 
static bool isX11GraphicsSystem ()
 
static bool polylineSplitting ()
 
static bool roundingAlignment ()
 
static bool roundingAlignment (const QPainter *)
 
static QFont scaledFont (const QFont &, const QPaintDevice *=nullptr)
 
static void setPolylineSplitting (bool)
 En/Disable line splitting for the raster paint engine. More...
 
static void setRoundingAlignment (bool)
 

Static Private Attributes

static bool m_polylineSplitting = true
 
static bool m_roundingAlignment = true
 

Detailed Description

A collection of QPainter workarounds.

Definition at line 36 of file qwt_painter.h.

Member Function Documentation

◆ backingStore()

QPixmap QwtPainter::backingStore ( QWidget *  widget,
const QSize &  size 
)
static
Returns
A pixmap that can be used as backing store
Parameters
widgetWidget, for which the backingstore is intended
sizeSize of the pixmap

Definition at line 1525 of file qwt_painter.cpp.

◆ devicePixelRatio()

qreal QwtPainter::devicePixelRatio ( const QPaintDevice *  paintDevice)
static
Returns
Pixel ratio for a paint device
Parameters
paintDevicePaint device

Definition at line 1491 of file qwt_painter.cpp.

◆ drawBackgound()

void QwtPainter::drawBackgound ( QPainter *  painter,
const QRectF &  rect,
const QWidget *  widget 
)
static

Fill rect with the background of a widget

Parameters
painterPainter
rectRectangle to be filled
widgetWidget
See also
QStyle::PE_Widget, QWidget::backgroundRole()

Definition at line 1351 of file qwt_painter.cpp.

◆ drawColorBar()

void QwtPainter::drawColorBar ( QPainter *  painter,
const QwtColorMap colorMap,
const QwtInterval interval,
const QwtScaleMap scaleMap,
Qt::Orientation  orientation,
const QRectF &  rect 
)
static

Draw a color bar into a rectangle

Parameters
painterPainter
colorMapColor map
intervalValue range
scaleMapScale map
orientationOrientation
rectTarget rectangle

Definition at line 1205 of file qwt_painter.cpp.

◆ drawEllipse()

void QwtPainter::drawEllipse ( QPainter *  painter,
const QRectF &  rect 
)
static

Wrapper for QPainter::drawEllipse()

Definition at line 426 of file qwt_painter.cpp.

◆ drawFocusRect() [1/2]

void QwtPainter::drawFocusRect ( QPainter *  painter,
const QWidget *  widget 
)
static

Draw a focus rectangle on a widget using its style.

Definition at line 815 of file qwt_painter.cpp.

◆ drawFocusRect() [2/2]

void QwtPainter::drawFocusRect ( QPainter *  painter,
const QWidget *  widget,
const QRect &  rect 
)
static

Draw a focus rectangle on a widget using its style.

Definition at line 821 of file qwt_painter.cpp.

◆ drawFrame()

void QwtPainter::drawFrame ( QPainter *  painter,
const QRectF &  rect,
const QPalette &  palette,
QPalette::ColorRole  foregroundRole,
int  frameWidth,
int  midLineWidth,
int  frameStyle 
)
static

Draw a rectangular frame

Parameters
painterPainter
rectFrame rectangle
palettePalette
foregroundRoleForeground role used for QFrame::Plain
frameWidthFrame width
midLineWidthUsed for QFrame::Box
frameStylebitwise OR´ed value of QFrame::Shape and QFrame::Shadow

Definition at line 911 of file qwt_painter.cpp.

◆ drawImage()

void QwtPainter::drawImage ( QPainter *  painter,
const QRectF &  rect,
const QImage &  image 
)
static

Wrapper for QPainter::drawImage()

Definition at line 773 of file qwt_painter.cpp.

◆ drawLine() [1/3]

void QwtPainter::drawLine ( QPainter *  painter,
const QLineF &  line 
)
inlinestatic

Wrapper for QPainter::drawLine()

Definition at line 161 of file qwt_painter.h.

◆ drawLine() [2/3]

void QwtPainter::drawLine ( QPainter *  painter,
const QPointF &  p1,
const QPointF &  p2 
)
static

Wrapper for QPainter::drawLine()

Definition at line 541 of file qwt_painter.cpp.

◆ drawLine() [3/3]

void QwtPainter::drawLine ( QPainter *  painter,
qreal  x1,
qreal  y1,
qreal  x2,
qreal  y2 
)
inlinestatic

Wrapper for QPainter::drawLine()

Definition at line 154 of file qwt_painter.h.

◆ drawPath()

void QwtPainter::drawPath ( QPainter *  painter,
const QPainterPath &  path 
)
static

Wrapper for QPainter::drawPath()

Definition at line 341 of file qwt_painter.cpp.

◆ drawPie()

void QwtPainter::drawPie ( QPainter *  painter,
const QRectF &  r,
int  a,
int  alen 
)
static

Wrapper for QPainter::drawPie()

Definition at line 414 of file qwt_painter.cpp.

◆ drawPixmap()

void QwtPainter::drawPixmap ( QPainter *  painter,
const QRectF &  rect,
const QPixmap &  pixmap 
)
static

Wrapper for QPainter::drawPixmap()

Definition at line 794 of file qwt_painter.cpp.

◆ drawPoint() [1/3]

void QwtPainter::drawPoint ( QPainter *  painter,
const QPoint &  pos 
)
static

Wrapper for QPainter::drawPoint()

Definition at line 691 of file qwt_painter.cpp.

◆ drawPoint() [2/3]

void QwtPainter::drawPoint ( QPainter *  painter,
const QPointF &  pos 
)
static

Wrapper for QPainter::drawPoint()

Definition at line 679 of file qwt_painter.cpp.

◆ drawPoint() [3/3]

void QwtPainter::drawPoint ( QPainter *  painter,
qreal  x,
qreal  y 
)
inlinestatic

Wrapper for QPainter::drawPoint()

Definition at line 136 of file qwt_painter.h.

◆ drawPoints() [1/4]

void QwtPainter::drawPoints ( QPainter *  painter,
const QPoint *  points,
int  pointCount 
)
static

Wrapper for QPainter::drawPoints()

Definition at line 714 of file qwt_painter.cpp.

◆ drawPoints() [2/4]

void QwtPainter::drawPoints ( QPainter *  painter,
const QPointF *  points,
int  pointCount 
)
static

Wrapper for QPainter::drawPoints()

Definition at line 747 of file qwt_painter.cpp.

◆ drawPoints() [3/4]

void QwtPainter::drawPoints ( QPainter *  painter,
const QPolygon &  polygon 
)
inlinestatic

Wrapper for QPainter::drawPoints()

Definition at line 142 of file qwt_painter.h.

◆ drawPoints() [4/4]

void QwtPainter::drawPoints ( QPainter *  painter,
const QPolygonF &  polygon 
)
inlinestatic

Wrapper for QPainter::drawPoints()

Definition at line 148 of file qwt_painter.h.

◆ drawPolygon() [1/2]

void QwtPainter::drawPolygon ( QPainter *  painter,
const QPolygon &  polygon 
)
static

Wrapper for QPainter::drawPolygon()

Definition at line 620 of file qwt_painter.cpp.

◆ drawPolygon() [2/2]

void QwtPainter::drawPolygon ( QPainter *  painter,
const QPolygonF &  polygon 
)
static

Wrapper for QPainter::drawPolygon()

Definition at line 561 of file qwt_painter.cpp.

◆ drawPolyline() [1/4]

void QwtPainter::drawPolyline ( QPainter *  painter,
const QPoint *  points,
int  pointCount 
)
static

Wrapper for QPainter::drawPolyline()

Definition at line 657 of file qwt_painter.cpp.

◆ drawPolyline() [2/4]

void QwtPainter::drawPolyline ( QPainter *  painter,
const QPointF *  points,
int  pointCount 
)
static

Wrapper for QPainter::drawPolyline()

Definition at line 598 of file qwt_painter.cpp.

◆ drawPolyline() [3/4]

void QwtPainter::drawPolyline ( QPainter *  painter,
const QPolygon &  polygon 
)
static

Wrapper for QPainter::drawPolyline()

Definition at line 637 of file qwt_painter.cpp.

◆ drawPolyline() [4/4]

void QwtPainter::drawPolyline ( QPainter *  painter,
const QPolygonF &  polygon 
)
static

Wrapper for QPainter::drawPolyline()

Definition at line 578 of file qwt_painter.cpp.

◆ drawRect() [1/2]

void QwtPainter::drawRect ( QPainter *  painter,
const QRectF &  rect 
)
static

Wrapper for QPainter::drawRect()

Definition at line 353 of file qwt_painter.cpp.

◆ drawRect() [2/2]

void QwtPainter::drawRect ( QPainter *  painter,
qreal  x,
qreal  y,
qreal  w,
qreal  h 
)
static

Wrapper for QPainter::drawRect()

Definition at line 347 of file qwt_painter.cpp.

◆ drawRoundedFrame()

void QwtPainter::drawRoundedFrame ( QPainter *  painter,
const QRectF &  rect,
qreal  xRadius,
qreal  yRadius,
const QPalette &  palette,
int  lineWidth,
int  frameStyle 
)
static

Draw a rectangular frame with rounded borders

Parameters
painterPainter
rectFrame rectangle
xRadiusx-radius of the ellipses defining the corners
yRadiusy-radius of the ellipses defining the corners
paletteQPalette::WindowText is used for plain borders QPalette::Dark and QPalette::Light for raised or sunken borders
lineWidthLine width
frameStylebitwise OR´ed value of QFrame::Shape and QFrame::Shadow

Definition at line 1065 of file qwt_painter.cpp.

◆ drawRoundFrame()

void QwtPainter::drawRoundFrame ( QPainter *  painter,
const QRectF &  rect,
const QPalette &  palette,
int  lineWidth,
int  frameStyle 
)
static

Draw a round frame

Parameters
painterPainter
rectFrame rectangle
paletteQPalette::WindowText is used for plain borders QPalette::Dark and QPalette::Light for raised or sunken borders
lineWidthLine width
frameStylebitwise OR´ed value of QFrame::Shape and QFrame::Shadow

Definition at line 845 of file qwt_painter.cpp.

◆ drawSimpleRichText()

void QwtPainter::drawSimpleRichText ( QPainter *  painter,
const QRectF &  rect,
int  flags,
const QTextDocument &  text 
)
static

Draw a text document into a rectangle

Parameters
painterPainter
rectTarget rectangle
flagsAlignments/Text flags, see QPainter::drawText()
textText document

Definition at line 489 of file qwt_painter.cpp.

◆ drawText() [1/4]

void QwtPainter::drawText ( QPainter *  painter,
const QPointF &  pos,
const QString &  text 
)
static

Wrapper for QPainter::drawText()

Definition at line 445 of file qwt_painter.cpp.

◆ drawText() [2/4]

void QwtPainter::drawText ( QPainter *  painter,
const QRectF &  rect,
int  flags,
const QString &  text 
)
static

Wrapper for QPainter::drawText()

Definition at line 470 of file qwt_painter.cpp.

◆ drawText() [3/4]

void QwtPainter::drawText ( QPainter *  painter,
qreal  x,
qreal  y,
const QString &  text 
)
static

Wrapper for QPainter::drawText()

Definition at line 438 of file qwt_painter.cpp.

◆ drawText() [4/4]

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

Wrapper for QPainter::drawText()

Definition at line 462 of file qwt_painter.cpp.

◆ effectivePenWidth()

qreal QwtPainter::effectivePenWidth ( const QPen &  pen)
inlinestatic
Returns
pen.widthF() expanded to at least 1.0
Parameters
penPen

Definition at line 201 of file qwt_painter.h.

◆ fillPixmap()

void QwtPainter::fillPixmap ( const QWidget *  widget,
QPixmap &  pixmap,
const QPoint &  offset = QPoint() 
)
static

Fill a pixmap with the content of a widget

In Qt >= 5.0 QPixmap::fill() is a nop, in Qt 4.x it is buggy for backgrounds with gradients. Thus fillPixmap() offers an alternative implementation.

Parameters
widgetWidget
pixmapPixmap to be filled
offsetOffset
See also
QPixmap::fill()

Definition at line 1311 of file qwt_painter.cpp.

◆ fillRect()

void QwtPainter::fillRect ( QPainter *  painter,
const QRectF &  rect,
const QBrush &  brush 
)
static

Wrapper for QPainter::fillRect()

Definition at line 382 of file qwt_painter.cpp.

◆ horizontalAdvance() [1/4]

int QwtPainter::horizontalAdvance ( const QFontMetrics &  fontMetrics,
const QString &  text 
)
static

Distance appropriate for drawing a subsequent character after text.

Parameters
fontMetricsFont metrics
textText
Returns
horizontal advance in pixels

Definition at line 1379 of file qwt_painter.cpp.

◆ horizontalAdvance() [2/4]

int QwtPainter::horizontalAdvance ( const QFontMetrics &  fontMetrics,
QChar  ch 
)
static

Distance appropriate for drawing a subsequent character after ch.

Parameters
fontMetricsFont metrics
chCharacter
Returns
horizontal advance in pixels

Definition at line 1414 of file qwt_painter.cpp.

◆ horizontalAdvance() [3/4]

qreal QwtPainter::horizontalAdvance ( const QFontMetricsF &  fontMetrics,
const QString &  text 
)
static

Distance appropriate for drawing a subsequent character after text.

Parameters
fontMetricsFont metrics
textText
Returns
horizontal advance in pixels

Definition at line 1397 of file qwt_painter.cpp.

◆ horizontalAdvance() [4/4]

qreal QwtPainter::horizontalAdvance ( const QFontMetricsF &  fontMetrics,
QChar  ch 
)
static

Distance appropriate for drawing a subsequent character after ch.

Parameters
fontMetricsFont metrics
chCharacter
Returns
horizontal advance in pixels

Definition at line 1431 of file qwt_painter.cpp.

◆ isAligning()

bool QwtPainter::isAligning ( const QPainter *  painter)
static

Check if the painter is using a paint engine, that aligns coordinates to integers. Today these are all paint engines beside QPaintEngine::Pdf and QPaintEngine::SVG.

If we have an integer based paint engine it is also checked if the painter has a transformation matrix, that rotates or scales.

Parameters
painterPainter
Returns
true, when the painter is aligning
See also
setRoundingAlignment()

Definition at line 267 of file qwt_painter.cpp.

◆ isX11GraphicsSystem()

bool QwtPainter::isX11GraphicsSystem ( )
static

Check is the application is running with the X11 graphics system that has some special capabilities that can be used for incremental painting to a widget.

Returns
True, when the graphics system is X11

Definition at line 233 of file qwt_painter.cpp.

◆ polylineSplitting()

bool QwtPainter::polylineSplitting ( )
inlinestatic
Returns
True, when line splitting for the raster paint engine is enabled.
See also
setPolylineSplitting()

Definition at line 170 of file qwt_painter.h.

◆ roundingAlignment() [1/2]

bool QwtPainter::roundingAlignment ( )
inlinestatic

Check whether coordinates should be rounded, before they are painted to a paint engine that rounds to integer values. For other paint engines ( PDF, SVG ), this flag has no effect.

Returns
True, when rounding is enabled
See also
setRoundingAlignment(), isAligning()

Definition at line 183 of file qwt_painter.h.

◆ roundingAlignment() [2/2]

bool QwtPainter::roundingAlignment ( const QPainter *  painter)
inlinestatic
Returns
roundingAlignment() && isAligning(painter);
Parameters
painterPainter

Definition at line 192 of file qwt_painter.h.

◆ scaledFont()

QFont QwtPainter::scaledFont ( const QFont &  font,
const QPaintDevice *  paintDevice = nullptr 
)
static

Adjust the DPI value of font according to the DPI value of the paint device

Parameters
fontUnscaled font
paintDevicePaint device providing a DPI value. If paintDevice == null the DPI value of the primary screen will be used
Returns
Font being adjusted to the DPI value of the paint device

Definition at line 1450 of file qwt_painter.cpp.

◆ setPolylineSplitting()

void QwtPainter::setPolylineSplitting ( bool  enable)
static

En/Disable line splitting for the raster paint engine.

In some Qt versions the raster paint engine paints polylines of many points much faster when they are split in smaller chunks: f.e all supported Qt versions >= Qt 5.0 when drawing an antialiased polyline with a pen width >=2.

Also the raster paint engine has a nasty bug in many versions ( Qt 4.8 - ... ) for short lines ( https://codereview.qt-project.org/#/c/99456 ), that is worked around in this mode.

The default setting is true.

See also
polylineSplitting()

Definition at line 335 of file qwt_painter.cpp.

◆ setRoundingAlignment()

void QwtPainter::setRoundingAlignment ( bool  enable)
static

Enable whether coordinates should be rounded, before they are painted to a paint engine that floors to integer values. For other paint engines ( PDF, SVG ) this flag has no effect. QwtPainter stores this flag only, the rounding itself is done in the painting code ( f.e the plot items ).

The default setting is true.

See also
roundingAlignment(), isAligning()

Definition at line 315 of file qwt_painter.cpp.

Member Data Documentation

◆ m_polylineSplitting

bool QwtPainter::m_polylineSplitting = true
staticprivate

Definition at line 131 of file qwt_painter.h.

◆ m_roundingAlignment

bool QwtPainter::m_roundingAlignment = true
staticprivate

Definition at line 132 of file qwt_painter.h.


The documentation for this class was generated from the following files:


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:50