A Widget which contains a scale. More...
#include <qwt_scale_widget.h>
Classes | |
class | PrivateData |
Signals | |
void | scaleDivChanged () |
Signal emitted, whenever the scale divison changes. | |
Public Member Functions | |
QwtScaleWidget (QWidget *parent=NULL) | |
Create a scale with the position QwtScaleWidget::Left. | |
QwtScaleWidget (QWidget *parent, const char *name) | |
Create a scale with the position QwtScaleWidget::Left. | |
QwtScaleWidget (QwtScaleDraw::Alignment, QWidget *parent=NULL) | |
Constructor. | |
virtual | ~QwtScaleWidget () |
Destructor. | |
void | setTitle (const QString &title) |
void | setTitle (const QwtText &title) |
QwtText | title () const |
void | setBorderDist (int start, int end) |
int | startBorderDist () const |
int | endBorderDist () const |
void | getBorderDistHint (int &start, int &end) const |
Calculate a hint for the border distances. | |
void | getMinBorderDist (int &start, int &end) const |
void | setMinBorderDist (int start, int end) |
void | setMargin (int) |
Specify the margin to the colorBar/base line. | |
int | margin () const |
void | setSpacing (int td) |
Specify the distance between color bar, scale and title. | |
int | spacing () const |
void | setPenWidth (int) |
Specify the width of the scale pen. | |
int | penWidth () const |
void | setScaleDiv (QwtScaleTransformation *, const QwtScaleDiv &sd) |
Assign a scale division. | |
void | setScaleDraw (QwtScaleDraw *) |
const QwtScaleDraw * | scaleDraw () const |
QwtScaleDraw * | scaleDraw () |
void | setLabelAlignment (int) |
Change the alignment for the labels. | |
void | setLabelRotation (double rotation) |
Change the rotation for the labels. See QwtScaleDraw::setLabelRotation(). | |
void | setColorBarEnabled (bool) |
bool | isColorBarEnabled () const |
void | setColorBarWidth (int) |
int | colorBarWidth () const |
void | setColorMap (const QwtDoubleInterval &, const QwtColorMap &) |
QwtDoubleInterval | colorBarInterval () const |
const QwtColorMap & | colorMap () const |
virtual QSize | sizeHint () const |
virtual QSize | minimumSizeHint () const |
int | titleHeightForWidth (int width) const |
Find the height of the title for a given width. | |
int | dimForLength (int length, const QFont &scaleFont) const |
Find the minimum dimension for a given length. dim is the height, length the width seen in direction of the title. | |
void | drawColorBar (QPainter *painter, const QRect &rect) const |
void | drawTitle (QPainter *painter, QwtScaleDraw::Alignment, const QRect &rect) const |
void | setAlignment (QwtScaleDraw::Alignment) |
QwtScaleDraw::Alignment | alignment () const |
QRect | colorBarRect (const QRect &) const |
Protected Member Functions | |
virtual void | paintEvent (QPaintEvent *e) |
paintEvent | |
virtual void | resizeEvent (QResizeEvent *e) |
resizeEvent | |
virtual void | fontChange (const QFont &oldfont) |
Notify a change of the font. | |
void | draw (QPainter *p) const |
draw the scale | |
void | scaleChange () |
Notify a change of the scale. | |
void | layoutScale (bool update=true) |
Recalculate the scale's geometry and layout based on. |
A Widget which contains a scale.
This Widget can be used to decorate composite widgets with a scale.
Definition at line 34 of file qwt_scale_widget.h.
QwtScaleWidget::QwtScaleWidget | ( | QWidget * | parent = NULL ) |
[explicit] |
Create a scale with the position QwtScaleWidget::Left.
parent | Parent widget |
Definition at line 63 of file qwt_scale_widget.cpp.
References QwtScaleDraw::LeftScale.
: QWidget(parent) { initScale(QwtScaleDraw::LeftScale); }
QwtScaleWidget::QwtScaleWidget | ( | QWidget * | parent, |
const char * | name | ||
) | [explicit] |
Create a scale with the position QwtScaleWidget::Left.
parent | Parent widget |
name | Object name |
Definition at line 75 of file qwt_scale_widget.cpp.
References QwtScaleDraw::LeftScale.
: QWidget(parent, name) { initScale(QwtScaleDraw::LeftScale); }
QwtScaleWidget::QwtScaleWidget | ( | QwtScaleDraw::Alignment | align, |
QWidget * | parent = NULL |
||
) | [explicit] |
Constructor.
align | Alignment. |
parent | Parent widget |
Definition at line 87 of file qwt_scale_widget.cpp.
: QWidget(parent) { initScale(align); }
QwtScaleWidget::~QwtScaleWidget | ( | ) | [virtual] |
QwtScaleDraw::Alignment QwtScaleWidget::alignment | ( | ) | const |
Definition at line 224 of file qwt_scale_widget.cpp.
References QwtScaleDraw::alignment(), QwtScaleDraw::LeftScale, and scaleDraw().
{ if (!scaleDraw()) return QwtScaleDraw::LeftScale; return scaleDraw()->alignment(); }
QwtDoubleInterval QwtScaleWidget::colorBarInterval | ( | ) | const |
Definition at line 908 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::colorBar, and QwtScaleWidget::PrivateData::t_colorBar::interval.
QRect QwtScaleWidget::colorBarRect | ( | const QRect & | rect ) | const |
Definition at line 499 of file qwt_scale_widget.cpp.
References QwtScaleDraw::alignment(), QwtScaleWidget::PrivateData::borderDist, QwtScaleDraw::BottomScale, QwtScaleWidget::PrivateData::colorBar, QwtScaleDraw::LeftScale, QwtScaleDraw::orientation(), QwtScaleDraw::RightScale, QwtScaleWidget::PrivateData::scaleDraw, QwtScaleWidget::PrivateData::spacing, QwtScaleDraw::TopScale, and QwtScaleWidget::PrivateData::t_colorBar::width.
Referenced by draw(), and QwtPlot::printScale().
{ QRect cr = rect; if ( d_data->scaleDraw->orientation() == Qt::Horizontal ) { cr.setLeft(cr.left() + d_data->borderDist[0]); cr.setWidth(cr.width() - d_data->borderDist[1] + 1); } else { cr.setTop(cr.top() + d_data->borderDist[0]); cr.setHeight(cr.height() - d_data->borderDist[1] + 1); } switch(d_data->scaleDraw->alignment()) { case QwtScaleDraw::LeftScale: { cr.setLeft( cr.right() - d_data->spacing - d_data->colorBar.width + 1 ); cr.setWidth(d_data->colorBar.width); break; } case QwtScaleDraw::RightScale: { cr.setLeft( cr.left() + d_data->spacing ); cr.setWidth(d_data->colorBar.width); break; } case QwtScaleDraw::BottomScale: { cr.setTop( cr.top() + d_data->spacing ); cr.setHeight(d_data->colorBar.width); break; } case QwtScaleDraw::TopScale: { cr.setTop( cr.bottom() - d_data->spacing - d_data->colorBar.width + 1 ); cr.setHeight(d_data->colorBar.width); break; } } return cr; }
int QwtScaleWidget::colorBarWidth | ( | ) | const |
Definition at line 903 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::colorBar, and QwtScaleWidget::PrivateData::t_colorBar::width.
Referenced by layoutScale(), and QwtPlot::printScale().
const QwtColorMap & QwtScaleWidget::colorMap | ( | ) | const |
Definition at line 925 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::colorBar, and QwtScaleWidget::PrivateData::t_colorBar::colorMap.
int QwtScaleWidget::dimForLength | ( | int | length, |
const QFont & | scaleFont | ||
) | const |
Find the minimum dimension for a given length. dim is the height, length the width seen in direction of the title.
length | width for horizontal, height for vertical scales |
scaleFont | Font of the scale |
Definition at line 765 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::colorBar, QwtScaleDraw::extent(), QwtScaleWidget::PrivateData::t_colorBar::interval, QwtText::isEmpty(), QwtScaleWidget::PrivateData::t_colorBar::isEnabled, QwtDoubleInterval::isValid(), QwtScaleWidget::PrivateData::margin, QwtScaleWidget::PrivateData::penWidth, QwtScaleWidget::PrivateData::scaleDraw, QwtScaleWidget::PrivateData::spacing, QwtScaleWidget::PrivateData::title, titleHeightForWidth(), and QwtScaleWidget::PrivateData::t_colorBar::width.
Referenced by QwtPlotLayout::LayoutData::init(), and minimumSizeHint().
{ int dim = d_data->margin; dim += d_data->scaleDraw->extent( QPen(Qt::black, d_data->penWidth), scaleFont); if ( !d_data->title.isEmpty() ) dim += titleHeightForWidth(length) + d_data->spacing; if ( d_data->colorBar.isEnabled && d_data->colorBar.interval.isValid() ) dim += d_data->colorBar.width + d_data->spacing; return dim; }
void QwtScaleWidget::draw | ( | QPainter * | p ) | const [protected] |
draw the scale
Definition at line 439 of file qwt_scale_widget.cpp.
References QwtScaleDraw::alignment(), QwtScaleWidget::PrivateData::borderDist, QwtScaleDraw::BottomScale, QwtScaleWidget::PrivateData::colorBar, colorBarRect(), QwtAbstractScaleDraw::draw(), drawColorBar(), drawTitle(), QwtScaleWidget::PrivateData::t_colorBar::interval, QwtText::isEmpty(), QwtScaleWidget::PrivateData::t_colorBar::isEnabled, QwtDoubleInterval::isValid(), QwtScaleDraw::LeftScale, QwtScaleDraw::orientation(), QwtScaleWidget::PrivateData::penWidth, QwtScaleDraw::RightScale, QwtScaleWidget::PrivateData::scaleDraw, QwtScaleWidget::PrivateData::title, QwtScaleWidget::PrivateData::titleOffset, QwtScaleDraw::TopScale, and QwtScaleWidget::PrivateData::t_colorBar::width.
Referenced by paintEvent().
{ painter->save(); QPen scalePen = painter->pen(); scalePen.setWidth(d_data->penWidth); painter->setPen(scalePen); #if QT_VERSION < 0x040000 d_data->scaleDraw->draw(painter, colorGroup()); #else d_data->scaleDraw->draw(painter, palette()); #endif painter->restore(); if ( d_data->colorBar.isEnabled && d_data->colorBar.width > 0 && d_data->colorBar.interval.isValid() ) { drawColorBar(painter, colorBarRect(rect())); } QRect r = rect(); if ( d_data->scaleDraw->orientation() == Qt::Horizontal ) { r.setLeft(r.left() + d_data->borderDist[0]); r.setWidth(r.width() - d_data->borderDist[1]); } else { r.setTop(r.top() + d_data->borderDist[0]); r.setHeight(r.height() - d_data->borderDist[1]); } if ( !d_data->title.isEmpty() ) { QRect tr = r; switch(d_data->scaleDraw->alignment()) { case QwtScaleDraw::LeftScale: tr.setRight( r.right() - d_data->titleOffset ); break; case QwtScaleDraw::RightScale: tr.setLeft( r.left() + d_data->titleOffset ); break; case QwtScaleDraw::BottomScale: tr.setTop( r.top() + d_data->titleOffset ); break; case QwtScaleDraw::TopScale: default: tr.setBottom( r.bottom() - d_data->titleOffset ); break; } drawTitle(painter, d_data->scaleDraw->alignment(), tr); } }
void QwtScaleWidget::drawColorBar | ( | QPainter * | painter, |
const QRect & | rect | ||
) | const |
Definition at line 614 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::colorBar, QwtScaleWidget::PrivateData::t_colorBar::colorMap, QwtScaleWidget::PrivateData::t_colorBar::interval, QwtDoubleInterval::isValid(), QwtAbstractScaleDraw::map(), QwtDoubleInterval::normalized(), QwtScaleDraw::orientation(), and QwtScaleWidget::PrivateData::scaleDraw.
Referenced by draw(), and QwtPlot::printScale().
{ if ( !d_data->colorBar.interval.isValid() ) return; const QwtScaleDraw* sd = d_data->scaleDraw; QwtPainter::drawColorBar(painter, *d_data->colorBar.colorMap, d_data->colorBar.interval.normalized(), sd->map(), sd->orientation(), rect); }
void QwtScaleWidget::drawTitle | ( | QPainter * | painter, |
QwtScaleDraw::Alignment | align, | ||
const QRect & | rect | ||
) | const |
Rotate and paint a title according to its position into a given rectangle.
painter | Painter |
align | Alignment |
rect | Bounding rectangle |
Definition at line 633 of file qwt_scale_widget.cpp.
References QwtScaleDraw::BottomScale, QwtText::draw(), QwtMetricsMap::layoutToDevice(), QwtScaleDraw::LeftScale, QwtPainter::metricsMap(), QwtText::renderFlags(), QwtPainter::resetMetricsMap(), QwtScaleDraw::RightScale, QwtPainter::setMetricsMap(), QwtText::setRenderFlags(), title(), QwtScaleWidget::PrivateData::title, and QwtScaleDraw::TopScale.
Referenced by draw(), and QwtPlot::printScale().
{ QRect r; double angle; int flags = d_data->title.renderFlags() & ~(Qt::AlignTop | Qt::AlignBottom | Qt::AlignVCenter); switch(align) { case QwtScaleDraw::LeftScale: flags |= Qt::AlignTop; angle = -90.0; r.setRect(rect.left(), rect.bottom(), rect.height(), rect.width()); break; case QwtScaleDraw::RightScale: flags |= Qt::AlignTop; angle = 90.0; r.setRect(rect.right(), rect.top(), rect.height(), rect.width()); break; case QwtScaleDraw::TopScale: flags |= Qt::AlignTop; angle = 0.0; r = rect; break; case QwtScaleDraw::BottomScale: default: flags |= Qt::AlignBottom; angle = 0.0; r = rect; break; } painter->save(); painter->setFont(font()); #if QT_VERSION < 0x040000 painter->setPen(colorGroup().color(QColorGroup::Text)); #else painter->setPen(palette().color(QPalette::Text)); #endif const QwtMetricsMap metricsMap = QwtPainter::metricsMap(); QwtPainter::resetMetricsMap(); r = metricsMap.layoutToDevice(r); painter->translate(r.x(), r.y()); if (angle != 0.0) painter->rotate(angle); QwtText title = d_data->title; title.setRenderFlags(flags); title.draw(painter, QRect(0, 0, r.width(), r.height())); QwtPainter::setMetricsMap(metricsMap); // restore metrics map painter->restore(); }
int QwtScaleWidget::endBorderDist | ( | ) | const |
Definition at line 387 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::borderDist.
Referenced by QwtPlot::canvasMap(), QwtPlotLayout::LayoutData::init(), and QwtPlot::print().
{ return d_data->borderDist[1]; }
void QwtScaleWidget::fontChange | ( | const QFont & | oldFont ) | [protected, virtual] |
Notify a change of the font.
This virtual function may be overloaded by derived widgets. The default implementation resizes the scale and repaints the widget.
oldFont | Previous font |
Definition at line 842 of file qwt_scale_widget.cpp.
References layoutScale().
{ QWidget::fontChange( oldFont ); layoutScale(); }
void QwtScaleWidget::getBorderDistHint | ( | int & | start, |
int & | end | ||
) | const |
Calculate a hint for the border distances.
This member function calculates the distance of the scale's endpoints from the widget borders which is required for the mark labels to fit into the widget. The maximum of this distance an the minimum border distance is returned.
Definition at line 793 of file qwt_scale_widget.cpp.
References QwtScaleDraw::getBorderDistHint(), QwtScaleWidget::PrivateData::minBorderDist, and QwtScaleWidget::PrivateData::scaleDraw.
Referenced by QwtPlotPrintFilter::apply(), layoutScale(), minimumSizeHint(), QwtPlotLayout::minimumSizeHint(), QwtPlot::print(), QwtPlotPrintFilter::reset(), and QwtPlot::updateAxes().
{ d_data->scaleDraw->getBorderDistHint(font(), start, end); if ( start < d_data->minBorderDist[0] ) start = d_data->minBorderDist[0]; if ( end < d_data->minBorderDist[1] ) end = d_data->minBorderDist[1]; }
void QwtScaleWidget::getMinBorderDist | ( | int & | start, |
int & | end | ||
) | const |
Get the minimum value for the distances of the scale's endpoints from the widget borders.
Definition at line 826 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::minBorderDist.
{ start = d_data->minBorderDist[0]; end = d_data->minBorderDist[1]; }
bool QwtScaleWidget::isColorBarEnabled | ( | ) | const |
Definition at line 887 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::colorBar, and QwtScaleWidget::PrivateData::t_colorBar::isEnabled.
Referenced by QwtPlot::printScale(), setColorBarWidth(), and setColorMap().
void QwtScaleWidget::layoutScale | ( | bool | update = true ) |
[protected] |
Recalculate the scale's geometry and layout based on.
Definition at line 563 of file qwt_scale_widget.cpp.
References QwtScaleDraw::alignment(), QwtScaleWidget::PrivateData::borderDist, QwtScaleDraw::BottomScale, QwtScaleWidget::PrivateData::colorBar, colorBarWidth(), QwtScaleDraw::extent(), getBorderDistHint(), QwtScaleWidget::PrivateData::t_colorBar::interval, QwtScaleWidget::PrivateData::t_colorBar::isEnabled, QwtDoubleInterval::isValid(), QwtScaleDraw::LeftScale, QwtScaleWidget::PrivateData::margin, QwtScaleDraw::move(), QwtScaleDraw::orientation(), QwtScaleWidget::PrivateData::penWidth, QwtScaleWidget::PrivateData::scaleDraw, QwtScaleDraw::setLength(), QwtScaleWidget::PrivateData::spacing, QwtScaleWidget::PrivateData::titleOffset, and QwtScaleWidget::PrivateData::t_colorBar::width.
Referenced by fontChange(), resizeEvent(), scaleChange(), setAlignment(), setBorderDist(), setColorBarEnabled(), setColorBarWidth(), setColorMap(), setLabelRotation(), setMargin(), setPenWidth(), setScaleDiv(), setScaleDraw(), setSpacing(), and setTitle().
{ int bd0, bd1; getBorderDistHint(bd0, bd1); if ( d_data->borderDist[0] > bd0 ) bd0 = d_data->borderDist[0]; if ( d_data->borderDist[1] > bd1 ) bd1 = d_data->borderDist[1]; int colorBarWidth = 0; if ( d_data->colorBar.isEnabled && d_data->colorBar.interval.isValid() ) colorBarWidth = d_data->colorBar.width + d_data->spacing; const QRect r = rect(); int x, y, length; if ( d_data->scaleDraw->orientation() == Qt::Vertical ) { y = r.top() + bd0; length = r.height() - (bd0 + bd1); if ( d_data->scaleDraw->alignment() == QwtScaleDraw::LeftScale ) x = r.right() - d_data->margin - colorBarWidth; else x = r.left() + d_data->margin + colorBarWidth; } else { x = r.left() + bd0; length = r.width() - (bd0 + bd1); if ( d_data->scaleDraw->alignment() == QwtScaleDraw::BottomScale ) y = r.top() + d_data->margin + colorBarWidth; else y = r.bottom() - d_data->margin - colorBarWidth; } d_data->scaleDraw->move(x, y); d_data->scaleDraw->setLength(length); d_data->titleOffset = d_data->margin + d_data->spacing + colorBarWidth + d_data->scaleDraw->extent(QPen(Qt::black, d_data->penWidth), font()); if ( update_geometry ) { updateGeometry(); update(); } }
int QwtScaleWidget::margin | ( | ) | const |
Definition at line 396 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::margin.
Referenced by QwtPlotLayout::LayoutData::init(), QwtPlotLayout::minimumSizeHint(), QwtPlot::print(), and setMargin().
{ return d_data->margin; }
QSize QwtScaleWidget::minimumSizeHint | ( | ) | const [virtual] |
Definition at line 716 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::borderDist, dimForLength(), getBorderDistHint(), QwtScaleDraw::minLength(), QwtScaleDraw::orientation(), QwtScaleWidget::PrivateData::penWidth, qwtMax, and QwtScaleWidget::PrivateData::scaleDraw.
Referenced by QwtPlotLayout::minimumSizeHint(), sizeHint(), and QwtPlot::sizeHint().
{ const Qt::Orientation o = d_data->scaleDraw->orientation(); // Border Distance cannot be less than the scale borderDistHint // Note, the borderDistHint is already included in minHeight/minWidth int length = 0; int mbd1, mbd2; getBorderDistHint(mbd1, mbd2); length += qwtMax( 0, d_data->borderDist[0] - mbd1 ); length += qwtMax( 0, d_data->borderDist[1] - mbd2 ); length += d_data->scaleDraw->minLength( QPen(Qt::black, d_data->penWidth), font()); int dim = dimForLength(length, font()); if ( length < dim ) { // compensate for long titles length = dim; dim = dimForLength(length, font()); } QSize size(length + 2, dim); if ( o == Qt::Vertical ) size.transpose(); return size; }
void QwtScaleWidget::paintEvent | ( | QPaintEvent * | e ) | [protected, virtual] |
paintEvent
Definition at line 421 of file qwt_scale_widget.cpp.
References draw(), and QwtPaintBuffer::painter().
{ const QRect &ur = e->rect(); if ( ur.isValid() ) { #if QT_VERSION < 0x040000 QwtPaintBuffer paintBuffer(this, ur); draw(paintBuffer.painter()); #else QPainter painter(this); draw(&painter); #endif } }
int QwtScaleWidget::penWidth | ( | ) | const |
Definition at line 414 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::penWidth.
Referenced by QwtPlot::printScale().
{ return d_data->penWidth; }
void QwtScaleWidget::resizeEvent | ( | QResizeEvent * | e ) | [protected, virtual] |
resizeEvent
Definition at line 553 of file qwt_scale_widget.cpp.
References layoutScale().
{ layoutScale(false); }
void QwtScaleWidget::scaleChange | ( | ) | [protected] |
Notify a change of the scale.
This virtual function can be overloaded by derived classes. The default implementation updates the geometry and repaints the widget.
Definition at line 700 of file qwt_scale_widget.cpp.
References layoutScale().
{ layoutScale(); }
void QwtScaleWidget::scaleDivChanged | ( | ) | [signal] |
Signal emitted, whenever the scale divison changes.
Referenced by setScaleDiv().
const QwtScaleDraw * QwtScaleWidget::scaleDraw | ( | ) | const |
scaleDraw of this scale
Definition at line 351 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::scaleDraw.
Referenced by alignment(), QwtPlot::axisScaleDraw(), QwtPlotLayout::LayoutData::init(), QwtPlotLayout::minimumSizeHint(), QwtPlot::printScale(), and QwtPlot::sizeHint().
{ return d_data->scaleDraw; }
QwtScaleDraw * QwtScaleWidget::scaleDraw | ( | ) |
scaleDraw of this scale
Definition at line 360 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::scaleDraw.
{ return d_data->scaleDraw; }
void QwtScaleWidget::setAlignment | ( | QwtScaleDraw::Alignment | alignment ) |
Change the alignment
alignment | New alignment |
Definition at line 193 of file qwt_scale_widget.cpp.
References layoutScale(), QwtScaleDraw::orientation(), QwtScaleWidget::PrivateData::scaleDraw, and QwtScaleDraw::setAlignment().
{ #if QT_VERSION >= 0x040000 if ( !testAttribute(Qt::WA_WState_OwnSizePolicy) ) #else if ( !testWState( WState_OwnSizePolicy ) ) #endif { QSizePolicy policy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); if ( d_data->scaleDraw->orientation() == Qt::Vertical ) policy.transpose(); setSizePolicy(policy); #if QT_VERSION >= 0x040000 setAttribute(Qt::WA_WState_OwnSizePolicy, false); #else clearWState( WState_OwnSizePolicy ); #endif } if (d_data->scaleDraw) d_data->scaleDraw->setAlignment(alignment); layoutScale(); }
void QwtScaleWidget::setBorderDist | ( | int | dist1, |
int | dist2 | ||
) |
Specify distances of the scale's endpoints from the widget's borders. The actual borders will never be less than minimum border distance.
dist1 | Left or top Distance |
dist2 | Right or bottom distance |
Definition at line 240 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::borderDist, and layoutScale().
Referenced by QwtPlotPrintFilter::apply(), QwtPlotPrintFilter::reset(), and QwtPlot::updateAxes().
{ if ( dist1 != d_data->borderDist[0] || dist2 != d_data->borderDist[1] ) { d_data->borderDist[0] = dist1; d_data->borderDist[1] = dist2; layoutScale(); } }
void QwtScaleWidget::setColorBarEnabled | ( | bool | on ) |
Definition at line 878 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::colorBar, QwtScaleWidget::PrivateData::t_colorBar::isEnabled, and layoutScale().
{ if ( on != d_data->colorBar.isEnabled ) { d_data->colorBar.isEnabled = on; layoutScale(); } }
void QwtScaleWidget::setColorBarWidth | ( | int | width ) |
Definition at line 893 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::colorBar, isColorBarEnabled(), layoutScale(), and QwtScaleWidget::PrivateData::t_colorBar::width.
{ if ( width != d_data->colorBar.width ) { d_data->colorBar.width = width; if ( isColorBarEnabled() ) layoutScale(); } }
void QwtScaleWidget::setColorMap | ( | const QwtDoubleInterval & | interval, |
const QwtColorMap & | colorMap | ||
) |
Definition at line 913 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::colorBar, QwtScaleWidget::PrivateData::t_colorBar::colorMap, QwtColorMap::copy(), QwtScaleWidget::PrivateData::t_colorBar::interval, isColorBarEnabled(), and layoutScale().
{ d_data->colorBar.interval = interval; delete d_data->colorBar.colorMap; d_data->colorBar.colorMap = colorMap.copy(); if ( isColorBarEnabled() ) layoutScale(); }
void QwtScaleWidget::setLabelAlignment | ( | int | alignment ) |
Change the alignment for the labels.
Definition at line 303 of file qwt_scale_widget.cpp.
{ d_data->scaleDraw->setLabelAlignment(alignment); layoutScale(); }
void QwtScaleWidget::setLabelRotation | ( | double | rotation ) |
Change the rotation for the labels. See QwtScaleDraw::setLabelRotation().
, rotation Rotation
Definition at line 319 of file qwt_scale_widget.cpp.
References layoutScale(), QwtScaleWidget::PrivateData::scaleDraw, and QwtScaleDraw::setLabelRotation().
Referenced by QwtPlot::setAxisLabelRotation().
{ d_data->scaleDraw->setLabelRotation(rotation); layoutScale(); }
void QwtScaleWidget::setMargin | ( | int | margin ) |
Specify the margin to the colorBar/base line.
margin | Margin |
Definition at line 255 of file qwt_scale_widget.cpp.
References layoutScale(), margin(), QwtScaleWidget::PrivateData::margin, and qwtMax.
Referenced by QwtPlot::print().
void QwtScaleWidget::setMinBorderDist | ( | int | start, |
int | end | ||
) |
Set a minimum value for the distances of the scale's endpoints from the widget borders. This is useful to avoid that the scales are "jumping", when the tick labels or their positions change often.
start | Minimum for the start border |
end | Minimum for the end border |
Definition at line 814 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::minBorderDist.
{ d_data->minBorderDist[0] = start; d_data->minBorderDist[1] = end; }
void QwtScaleWidget::setPenWidth | ( | int | width ) |
Specify the width of the scale pen.
width | Pen width |
Definition at line 285 of file qwt_scale_widget.cpp.
References layoutScale(), and QwtScaleWidget::PrivateData::penWidth.
void QwtScaleWidget::setScaleDiv | ( | QwtScaleTransformation * | transformation, |
const QwtScaleDiv & | scaleDiv | ||
) |
Assign a scale division.
The scale division determines where to set the tick marks.
transformation | Transformation, needed to translate between scale and pixal values |
scaleDiv | Scale Division |
Definition at line 860 of file qwt_scale_widget.cpp.
References layoutScale(), QwtAbstractScaleDraw::map(), QwtAbstractScaleDraw::scaleDiv(), scaleDivChanged(), QwtScaleWidget::PrivateData::scaleDraw, QwtAbstractScaleDraw::setScaleDiv(), QwtAbstractScaleDraw::setTransformation(), QwtScaleMap::transformation(), and QwtScaleTransformation::type().
Referenced by QwtPlot::updateAxes().
{ QwtScaleDraw *sd = d_data->scaleDraw; if (sd->scaleDiv() != scaleDiv || sd->map().transformation()->type() != transformation->type() ) { sd->setTransformation(transformation); sd->setScaleDiv(scaleDiv); layoutScale(); emit scaleDivChanged(); } else delete transformation; }
void QwtScaleWidget::setScaleDraw | ( | QwtScaleDraw * | sd ) |
Set a scale draw sd has to be created with new and will be deleted in ~QwtScaleWidget() or the next call of setScaleDraw().
sd | ScaleDraw object |
Definition at line 333 of file qwt_scale_widget.cpp.
References QwtScaleDraw::alignment(), layoutScale(), QwtScaleWidget::PrivateData::scaleDraw, and QwtScaleDraw::setAlignment().
Referenced by QwtPlot::setAxisScaleDraw().
{ if ( sd == NULL || sd == d_data->scaleDraw ) return; if ( d_data->scaleDraw ) sd->setAlignment(d_data->scaleDraw->alignment()); delete d_data->scaleDraw; d_data->scaleDraw = sd; layoutScale(); }
void QwtScaleWidget::setSpacing | ( | int | spacing ) |
Specify the distance between color bar, scale and title.
spacing | Spacing |
Definition at line 270 of file qwt_scale_widget.cpp.
References layoutScale(), qwtMax, spacing(), and QwtScaleWidget::PrivateData::spacing.
void QwtScaleWidget::setTitle | ( | const QString & | title ) |
Give title new text contents
title | New title |
Definition at line 156 of file qwt_scale_widget.cpp.
References layoutScale(), QwtText::setText(), QwtText::text(), title(), and QwtScaleWidget::PrivateData::title.
Referenced by QwtPlotPrintFilter::apply(), QwtPlotPrintFilter::reset(), and QwtPlot::setAxisTitle().
void QwtScaleWidget::setTitle | ( | const QwtText & | title ) |
Give title new text contents
title | New title |
Definition at line 174 of file qwt_scale_widget.cpp.
References layoutScale(), QwtText::renderFlags(), QwtText::setRenderFlags(), QuadProgPP::t(), QwtScaleWidget::PrivateData::title, and title().
{ QwtText t = title; const int flags = title.renderFlags() & ~(Qt::AlignTop | Qt::AlignBottom); t.setRenderFlags(flags); if (t != d_data->title) { d_data->title = t; layoutScale(); } }
QSize QwtScaleWidget::sizeHint | ( | ) | const [virtual] |
Definition at line 708 of file qwt_scale_widget.cpp.
References minimumSizeHint().
{ return minimumSizeHint(); }
int QwtScaleWidget::spacing | ( | ) | const |
Definition at line 405 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::spacing.
Referenced by QwtPlot::printScale(), and setSpacing().
{ return d_data->spacing; }
int QwtScaleWidget::startBorderDist | ( | ) | const |
Definition at line 378 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::borderDist.
Referenced by QwtPlot::canvasMap(), QwtPlotLayout::LayoutData::init(), and QwtPlot::print().
{ return d_data->borderDist[0]; }
QwtText QwtScaleWidget::title | ( | ) | const |
Definition at line 369 of file qwt_scale_widget.cpp.
References QwtScaleWidget::PrivateData::title.
Referenced by QwtPlotPrintFilter::apply(), QwtPlot::axisTitle(), drawTitle(), QwtPlotLayout::expandLineBreaks(), QwtPlotLayout::LayoutData::init(), and setTitle().
{ return d_data->title; }
int QwtScaleWidget::titleHeightForWidth | ( | int | width ) | const |
Find the height of the title for a given width.
width | Width |
Definition at line 751 of file qwt_scale_widget.cpp.
References QwtText::heightForWidth(), and QwtScaleWidget::PrivateData::title.
Referenced by dimForLength(), QwtPlotLayout::expandLineBreaks(), and QwtPlotLayout::LayoutData::init().
{ return d_data->title.heightForWidth(width, font()); }