Qwt User's Guide
QwtScaleWidget Class Reference

A Widget which contains a scale. More...

#include <qwt_scale_widget.h>

Public Types

enum  LayoutFlag { TitleInverted = 1 }
 Layout flags of the title. More...
typedef QFlags< LayoutFlagLayoutFlags
 Layout flags of the title.

Signals

void scaleDivChanged ()
 Signal emitted, whenever the scale division changes.

Public Member Functions

 QwtScaleWidget (QWidget *parent=NULL)
 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 setLayoutFlag (LayoutFlag, bool on)
bool testLayoutFlag (LayoutFlag) 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 setScaleDiv (const QwtScaleDiv &sd)
 Assign a scale division.
void setTransformation (QwtTransform *)
void setScaleDraw (QwtScaleDraw *)
const QwtScaleDrawscaleDraw () const
QwtScaleDrawscaleDraw ()
void setLabelAlignment (Qt::Alignment)
 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 QwtInterval &, QwtColorMap *)
QwtInterval 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 QRectF &) const
void drawTitle (QPainter *painter, QwtScaleDraw::Alignment, const QRectF &rect) const
void setAlignment (QwtScaleDraw::Alignment)
QwtScaleDraw::Alignment alignment () const
QRectF colorBarRect (const QRectF &) const

Protected Member Functions

virtual void paintEvent (QPaintEvent *)
 paintEvent
virtual void resizeEvent (QResizeEvent *)
void draw (QPainter *p) const
 draw the scale
void scaleChange ()
 Notify a change of the scale.
void layoutScale (bool update=true)

Detailed Description

A Widget which contains a scale.

This Widget can be used to decorate composite widgets with a scale.


Member Enumeration Documentation

Layout flags of the title.

Enumerator:
TitleInverted 

The title of vertical scales is painted from top to bottom. Otherwise it is painted from bottom to top.


Constructor & Destructor Documentation

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

Create a scale with the position QwtScaleWidget::Left.

Parameters:
parentParent widget
QwtScaleWidget::QwtScaleWidget ( QwtScaleDraw::Alignment  align,
QWidget *  parent = NULL 
) [explicit]

Constructor.

Parameters:
alignAlignment.
parentParent widget

Member Function Documentation

Returns:
position
See also:
setPosition()
Returns:
Value interval for the color bar
See also:
setColorMap(), colorMap()
QRectF QwtScaleWidget::colorBarRect ( const QRectF &  rect) const

Calculate the the rectangle for the color bar

Parameters:
rectBounding rectangle for all components of the scale
Returns:
Rectangle for the color bar
Returns:
Width of the color bar
See also:
setColorBarEnabled(), setColorBarEnabled()
Returns:
Color map
See also:
setColorMap(), colorBarInterval()
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
void QwtScaleWidget::drawColorBar ( QPainter *  painter,
const QRectF &  rect 
) const

Draw the color bar of the scale widget

Parameters:
painterPainter
rectBounding rectangle for the color bar
See also:
setColorBarEnabled()
void QwtScaleWidget::drawTitle ( QPainter *  painter,
QwtScaleDraw::Alignment  align,
const QRectF &  rect 
) const

Rotate and paint a title according to its position into a given rectangle.

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

Parameters:
startReturn parameter for the border width at the beginning of the scale
endReturn parameter for the border width at the end of the scale
Warning:
  • The minimum border distance depends on the font.
See also:
setMinBorderDist(), getMinBorderDist(), setBorderDist()
void QwtScaleWidget::getMinBorderDist ( int &  start,
int &  end 
) const

Get the minimum value for the distances of the scale's endpoints from the widget borders.

Parameters:
startReturn parameter for the border width at the beginning of the scale
endReturn parameter for the border width at the end of the scale
See also:
setMinBorderDist(), getBorderDistHint()
Returns:
true, when the color bar is enabled
See also:
setColorBarEnabled(), setColorBarWidth()
void QwtScaleWidget::layoutScale ( bool  update_geometry = true) [protected]

Recalculate the scale's geometry and layout based on the current geometry and fonts.

Parameters:
update_geometryNotify the layout system and call update to redraw the scale
int QwtScaleWidget::margin ( ) const
Returns:
margin
See also:
setMargin()
QSize QwtScaleWidget::minimumSizeHint ( ) const [virtual]
Returns:
a minimum size hint
void QwtScaleWidget::resizeEvent ( QResizeEvent *  event) [protected, virtual]

Event handler for resize events

Parameters:
eventResize event
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.

Returns:
scaleDraw of this scale
See also:
setScaleDraw(), QwtScaleDraw::setScaleDraw()
Returns:
scaleDraw of this scale
See also:
QwtScaleDraw::setScaleDraw()

Change the alignment

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

En/disable a color bar associated to the scale

See also:
isColorBarEnabled(), setColorBarWidth()
void QwtScaleWidget::setColorBarWidth ( int  width)

Set the width of the color bar

Parameters:
widthWidth
See also:
colorBarWidth(), setColorBarEnabled()
void QwtScaleWidget::setColorMap ( const QwtInterval interval,
QwtColorMap colorMap 
)

Set the color map and value interval, that are used for displaying the color bar.

Parameters:
intervalValue interval
colorMapColor map
See also:
colorMap(), colorBarInterval()
void QwtScaleWidget::setLabelAlignment ( Qt::Alignment  alignment)

Change the alignment for the labels.

See also:
QwtScaleDraw::setLabelAlignment(), setLabelRotation()
void QwtScaleWidget::setLabelRotation ( double  rotation)

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

Parameters:
rotationRotation
See also:
QwtScaleDraw::setLabelRotation(), setLabelFlags()
void QwtScaleWidget::setLayoutFlag ( LayoutFlag  flag,
bool  on 
)

Toggle an layout flag

Parameters:
flagLayout flag
ontrue/false
See also:
testLayoutFlag(), LayoutFlag
void QwtScaleWidget::setMargin ( int  margin)

Specify the margin to the colorBar/base line.

Parameters:
marginMargin
See also:
margin()
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()
void QwtScaleWidget::setScaleDiv ( const QwtScaleDiv scaleDiv)

Assign a scale division.

The scale division determines where to set the tick marks.

Parameters:
scaleDivScale Division
See also:
For more information about scale divisions, see QwtScaleDiv.

Set a scale draw

scaleDraw has to be created with new and will be deleted in ~QwtScaleWidget() or the next call of setScaleDraw(). scaleDraw will be initialized with the attributes of the previous scaleDraw object.

Parameters:
scaleDrawScaleDraw object
See also:
scaleDraw()
void QwtScaleWidget::setSpacing ( int  spacing)

Specify the distance between color bar, scale and title.

Parameters:
spacingSpacing
See also:
spacing()
void QwtScaleWidget::setTitle ( const QString &  title)

Give title new text contents

Parameters:
titleNew title
See also:
title(), setTitle(const QwtText &);
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.
void QwtScaleWidget::setTransformation ( QwtTransform transformation)

Set the transformation

Parameters:
transformationTransformation
See also:
QwtAbstractScaleDraw::scaleDraw(), QwtScaleMap
QSize QwtScaleWidget::sizeHint ( ) const [virtual]
Returns:
a size hint
int QwtScaleWidget::spacing ( ) const
Returns:
distance between scale and title
See also:
setMargin()
Returns:
start border distance
See also:
setBorderDist()

Test a layout flag

Parameters:
flagLayout flag
Returns:
true/false
See also:
setLayoutFlag(), LayoutFlag
Returns:
title
See also:
setTitle()
int QwtScaleWidget::titleHeightForWidth ( int  width) const

Find the height of the title for a given width.

Parameters:
widthWidth
Returns:
height Height

List of all members.

 All Classes Functions Variables Typedefs Enumerations Enumerator