/*! Calculate the width/height that is needed for a vertical/horizontal scale. The extent is calculated from the pen width of the backbone, the major tick length, the spacing and the maximum width/height of the labels. \param pen Pen that is used for painting backbone and ticks \param font Font used for painting the labels \sa minLength() */ int QwtScaleDraw::extent(const QPen &pen, const QFont &font) const { int d = 0; if ( hasComponent(QwtAbstractScaleDraw::Labels) ) { if ( orientation() == Qt::Vertical ) d = maxLabelWidth(font); else d = maxLabelHeight(font); if ( d > 0 ) d += spacing(); } if ( hasComponent(QwtAbstractScaleDraw::Ticks) ) { d += majTickLength(); } if ( hasComponent(QwtAbstractScaleDraw::Backbone) ) { const int pw = qwtMax( 1, pen.width() ); // penwidth can be zero d += pw; } d = qwtMax(d, minimumExtent()); return d; }
// The rect of a scale without the title QRect ScalePicker::scaleRect(const QwtScale *scale) const { const int bld = scale->baseLineDist(); const int mjt = scale->scaleDraw()->majTickLength(); const int sbd = scale->startBorderDist(); const int ebd = scale->endBorderDist(); int mlw, mlh; QRect rect; switch(scale->position()) { case QwtScale::Left: { mlw=maxLabelWidth(scale); rect.setRect(scale->width() - bld - mjt-mlw, sbd, mjt+mlw, scale->height() - sbd - ebd); break; } case QwtScale::Right: { mlw=maxLabelWidth(scale); rect.setRect(bld, sbd, mjt+mlw, scale->height() - sbd - ebd); break; } case QwtScale::Bottom: { mlh=maxLabelHeight(scale); rect.setRect(sbd, bld, scale->width() - sbd - ebd, mjt+mlh); break; } case QwtScale::Top: { mlh=maxLabelHeight(scale); rect.setRect(sbd, scale->height() - bld - mjt-mlh, scale->width() - sbd - ebd, mjt+mlh); break; } } return rect; }
void PlacemarkLayout::styleReset() { m_paintOrder.clear(); m_labelArea = 0; qDeleteAll( m_visiblePlacemarks ); m_visiblePlacemarks.clear(); m_maxLabelHeight = maxLabelHeight(); m_styleResetRequested = false; }