16 #include <qpaintengine.h> 20 const QRectF &rect,
const QSizeF &itemSize )
23 if ( renderFlags & Qt::AlignLeft )
27 else if ( renderFlags & Qt::AlignRight )
29 x = rect.right() - itemSize.width();
33 x = rect.center().x() - 0.5 * itemSize.width();
37 if ( renderFlags & Qt::AlignTop )
41 else if ( renderFlags & Qt::AlignBottom )
43 y = rect.bottom() - itemSize.height();
47 y = rect.center().y() - 0.5 * itemSize.height();
50 return QRect( x, y, itemSize.width(), itemSize.height() );
148 margin = qMax( margin, 0 );
178 const QRectF &canvasRect )
const 185 const QRectF rect =
textRect( canvasRect.adjusted( m, m, -m, -m ),
191 switch( painter->paintEngine()->type() )
193 case QPaintEngine::Picture:
194 case QPaintEngine::User:
216 pixmapRect.setLeft(
qwtFloor( rect.left() ) - pw );
217 pixmapRect.setTop(
qwtFloor( rect.top() ) - pw );
218 pixmapRect.setRight(
qwtCeil( rect.right() ) + pw );
219 pixmapRect.setBottom(
qwtCeil( rect.bottom() ) + pw );
221 #if QT_VERSION >= 0x050000 223 const QSize scaledSize = pixmapRect.size() * pixelRatio;
225 const QSize scaledSize = pixmapRect.size();
232 #if QT_VERSION >= 0x050000 237 const QRect r( pw, pw,
238 pixmapRect.width() - 2 * pw, pixmapRect.height() - 2 * pw );
264 const QRectF &rect,
const QSizeF &textSize )
const static QRect qwtItemRect(int renderFlags, const QRectF &rect, const QSizeF &itemSize)
QwtPlotTextLabel()
Constructor.
void setMargin(int margin)
void draw(QPainter *painter, const QRectF &rect) const
virtual int rtti() const QWT_OVERRIDE
int qwtFloor(qreal value)
The item is represented on the legend.
virtual QRectF textRect(const QRectF &, const QSizeF &) const
Align the text label.
static qreal devicePixelRatio(const QPaintDevice *)
A class representing a text.
void setZ(double z)
Set the z value.
void setText(const QwtText &)
virtual void draw(QPainter *, const QwtScaleMap &, const QwtScaleMap &, const QRectF &) const QWT_OVERRIDE
virtual void itemChanged()
void invalidateCache()
Invalidate all internal cache.
Base class for items on the plot canvas.
void setItemAttribute(ItemAttribute, bool on=true)
virtual ~QwtPlotTextLabel()
Destructor.
static bool roundingAlignment()