233 const QRectF& canvasRect,
const QPointF& pos )
const
238 Qt::Alignment align = m_data->labelAlignment;
239 QPointF alignPos = pos;
241 QSizeF symbolOff( 0, 0 );
243 switch ( m_data->style )
250 if ( m_data->labelAlignment & Qt::AlignTop )
252 alignPos.setY( canvasRect.top() );
253 align &= ~Qt::AlignTop;
254 align |= Qt::AlignBottom;
256 else if ( m_data->labelAlignment & Qt::AlignBottom )
261 alignPos.setY( canvasRect.bottom() - 1 );
262 align &= ~Qt::AlignBottom;
263 align |= Qt::AlignTop;
267 alignPos.setY( canvasRect.center().y() );
273 if ( m_data->labelAlignment & Qt::AlignLeft )
275 alignPos.setX( canvasRect.left() );
276 align &= ~Qt::AlignLeft;
277 align |= Qt::AlignRight;
279 else if ( m_data->labelAlignment & Qt::AlignRight )
281 alignPos.setX( canvasRect.right() - 1 );
282 align &= ~Qt::AlignRight;
283 align |= Qt::AlignLeft;
287 alignPos.setX( canvasRect.center().x() );
293 if ( m_data->symbol &&
296 symbolOff = m_data->symbol->
size() + QSizeF( 1, 1 );
302 qreal pw2 = m_data->pen.widthF() / 2.0;
306 const int spacing = m_data->spacing;
308 const qreal xOff = qwtMaxF( pw2, symbolOff.width() );
309 const qreal yOff = qwtMaxF( pw2, symbolOff.height() );
311 const QSizeF textSize = m_data->label.
textSize( painter->font() );
313 if ( align & Qt::AlignLeft )
315 alignPos.rx() -= xOff +
spacing;
316 if ( m_data->labelOrientation == Qt::Vertical )
317 alignPos.rx() -= textSize.height();
319 alignPos.rx() -= textSize.width();
321 else if ( align & Qt::AlignRight )
323 alignPos.rx() += xOff +
spacing;
327 if ( m_data->labelOrientation == Qt::Vertical )
328 alignPos.rx() -= textSize.height() / 2;
330 alignPos.rx() -= textSize.width() / 2;
333 if ( align & Qt::AlignTop )
335 alignPos.ry() -= yOff +
spacing;
336 if ( m_data->labelOrientation != Qt::Vertical )
337 alignPos.ry() -= textSize.height();
339 else if ( align & Qt::AlignBottom )
341 alignPos.ry() += yOff +
spacing;
342 if ( m_data->labelOrientation == Qt::Vertical )
343 alignPos.ry() += textSize.width();
347 if ( m_data->labelOrientation == Qt::Vertical )
348 alignPos.ry() += textSize.width() / 2;
350 alignPos.ry() -= textSize.height() / 2;
353 painter->translate( alignPos.x(), alignPos.y() );
354 if ( m_data->labelOrientation == Qt::Vertical )
355 painter->rotate( -90.0 );
357 const QRectF textRect( 0, 0, textSize.width(), textSize.height() );
358 m_data->label.
draw( painter, textRect );
576 switch (m_data->style)
579 return QRectF( m_data->xValue, m_data->yValue, -1.0, 0.0 );
582 return QRectF( m_data->xValue, m_data->yValue, 0.0, -1.0 );
585 return QRectF( m_data->xValue, m_data->yValue, 0.0, 0.0 );
602 if ( size.isEmpty() )
609 QPainter painter( &icon );
610 painter.setRenderHint( QPainter::Antialiasing,
615 painter.setPen( m_data->pen );
620 const double y = 0.5 * size.height();
623 0.0, y, size.width(), y );
629 const double x = 0.5 * size.width();
632 x, 0.0, x, size.height() );
636 if ( m_data->symbol )
638 const QRect r( 0.0, 0.0, size.width(), size.height() );
A class representing a text.
void draw(QPainter *painter, const QRectF &rect) const