Classes | Signals | Public Member Functions | Protected Member Functions

QwtScaleWidget Class Reference

A Widget which contains a scale. More...

#include <qwt_scale_widget.h>

Collaboration diagram for QwtScaleWidget:
Collaboration graph
[legend]

List of all members.

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 QwtScaleDrawscaleDraw () const
QwtScaleDrawscaleDraw ()
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 QwtColorMapcolorMap () 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.

Detailed Description

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.


Constructor & Destructor Documentation

QwtScaleWidget::QwtScaleWidget ( QWidget *  parent = NULL ) [explicit]

Create a scale with the position QwtScaleWidget::Left.

Parameters:
parentParent 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.

Parameters:
parentParent widget
nameObject 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.

Parameters:
alignAlignment.
parentParent widget

Definition at line 87 of file qwt_scale_widget.cpp.

                                                     :
    QWidget(parent)
{
    initScale(align);
}
QwtScaleWidget::~QwtScaleWidget (  ) [virtual]

Destructor.

Definition at line 95 of file qwt_scale_widget.cpp.

{
    delete d_data;
}

Member Function Documentation

QwtScaleDraw::Alignment QwtScaleWidget::alignment (  ) const
Returns:
position
See also:
setPosition()

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
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
const QwtColorMap & QwtScaleWidget::colorMap (  ) const
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.

Parameters:
lengthwidth for horizontal, height for vertical scales
scaleFontFont of the scale
Returns:
height for horizontal, width for vertical scales

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
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.

Parameters:
painterPainter
alignAlignment
rectBounding 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
Returns:
end border distance
See also:
setBorderDist()

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.

Parameters:
oldFontPrevious 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.

Warning:
  • The minimum border distance depends on the font.
See also:
setMinBorderDist(), getMinBorderDist(), setBorderDist()

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.

See also:
setMinBorderDist(), getBorderDistHint()

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
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
Returns:
margin
See also:
setMargin()

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]
Returns:
a minimum size hint

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
Returns:
Scale pen width
See also:
setPenWidth()

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

See also:
setScaleDraw(), QwtScaleDraw::setScaleDraw()

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

See also:
QwtScaleDraw::setScaleDraw()

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

Parameters:
alignmentNew alignment
See also:
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.

Parameters:
dist1Left or top Distance
dist2Right or bottom distance
See also:
borderDist()

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 )
void QwtScaleWidget::setColorBarWidth ( int  width )
void QwtScaleWidget::setColorMap ( const QwtDoubleInterval interval,
const QwtColorMap colorMap 
)
void QwtScaleWidget::setLabelAlignment ( int  alignment )

Change the alignment for the labels.

See also:
QwtScaleDraw::setLabelAlignment(), setLabelRotation()

Definition at line 303 of file qwt_scale_widget.cpp.

void QwtScaleWidget::setLabelRotation ( double  rotation )

Change the rotation for the labels. See QwtScaleDraw::setLabelRotation().

, rotation Rotation

See also:
QwtScaleDraw::setLabelRotation(), setLabelFlags()

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.

Parameters:
marginMargin
See also:
margin()

Definition at line 255 of file qwt_scale_widget.cpp.

References layoutScale(), margin(), QwtScaleWidget::PrivateData::margin, and qwtMax.

Referenced by QwtPlot::print().

{
    margin = qwtMax( 0, margin );
    if ( margin != d_data->margin )
    {
        d_data->margin = margin;
        layoutScale();
    }
}
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.

Parameters:
startMinimum for the start border
endMinimum for the end border
See also:
getMinBorderDist(), getBorderDistHint()

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.

Parameters:
widthPen width
See also:
penWidth()

Definition at line 285 of file qwt_scale_widget.cpp.

References layoutScale(), and QwtScaleWidget::PrivateData::penWidth.

{
    if ( width < 0 )
        width = 0;

    if ( width != d_data->penWidth )
    {
        d_data->penWidth = width;
        layoutScale();
    }
}
void QwtScaleWidget::setScaleDiv ( QwtScaleTransformation transformation,
const QwtScaleDiv scaleDiv 
)

Assign a scale division.

The scale division determines where to set the tick marks.

Parameters:
transformationTransformation, needed to translate between scale and pixal values
scaleDivScale Division
See also:
For more information about scale divisions, see QwtScaleDiv.

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().

Parameters:
sdScaleDraw object
See also:
scaleDraw()

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.

Parameters:
spacingSpacing
See also:
spacing()

Definition at line 270 of file qwt_scale_widget.cpp.

References layoutScale(), qwtMax, spacing(), and QwtScaleWidget::PrivateData::spacing.

{
    spacing = qwtMax( 0, spacing );
    if ( spacing != d_data->spacing )
    {
        d_data->spacing = spacing;
        layoutScale();
    }
}
void QwtScaleWidget::setTitle ( const QString &  title )

Give title new text contents

Parameters:
titleNew title
See also:
title(), setTitle(const QwtText &);

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().

{
    if ( d_data->title.text() != title )
    {
        d_data->title.setText(title);
        layoutScale();
    }
}
void QwtScaleWidget::setTitle ( const QwtText title )

Give title new text contents

Parameters:
titleNew title
See also:
title()
Warning:
The title flags are interpreted in direction of the label, AlignTop, AlignBottom can't be set as the title will always be aligned to the scale.

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]
Returns:
a size hint

Definition at line 708 of file qwt_scale_widget.cpp.

References minimumSizeHint().

{
    return minimumSizeHint();
}
int QwtScaleWidget::spacing (  ) const
Returns:
distance between scale and title
See also:
setMargin()

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
Returns:
start border distance
See also:
setBorderDist()

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
int QwtScaleWidget::titleHeightForWidth ( int  width ) const

Find the height of the title for a given width.

Parameters:
widthWidth
Returns:
height Height

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());
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines