QwtAbstractScaleDraw Class Reference

Inheritance diagram for QwtAbstractScaleDraw:

Inheritance graph
[legend]
List of all members.

Detailed Description

A abstract base class for drawing scales.

QwtAbstractScaleDraw can be used to draw linear or logarithmic scales.

After a scale division has been specified as a QwtScaleDiv object using QwtAbstractScaleDraw::setScaleDiv(const QwtScaleDiv &s), the scale can be drawn with the QwtAbstractScaleDraw::draw() member.

Definition at line 37 of file qwt_abstract_scale_draw.h.

Public Types

enum  ScaleComponent {
  Backbone = 1,
  Ticks = 2,
  Labels = 4
}

Public Member Functions

 QwtAbstractScaleDraw ()
 QwtAbstractScaleDraw (const QwtAbstractScaleDraw &)
virtual ~QwtAbstractScaleDraw ()
QwtAbstractScaleDrawoperator= (const QwtAbstractScaleDraw &)
void setScaleDiv (const QwtScaleDiv &s)
const QwtScaleDivscaleDiv () const
void setTransformation (QwtScaleTransformation *)
const QwtScaleMapmap () const
void enableComponent (ScaleComponent, bool enable=true)
bool hasComponent (ScaleComponent) const
void setTickLength (QwtScaleDiv::TickType, int length)
int tickLength (QwtScaleDiv::TickType) const
int majTickLength () const
void setSpacing (int margin)
int spacing () const
virtual void draw (QPainter *, const QPalette &) const
virtual QwtText label (double) const
virtual int extent (const QPen &, const QFont &) const =0
void setMinimumExtent (int)
int minimumExtent () const
QwtScaleMapscaleMap ()

Protected Member Functions

virtual void drawTick (QPainter *painter, double value, int len) const =0
virtual void drawBackbone (QPainter *painter) const =0
virtual void drawLabel (QPainter *painter, double value) const =0
void invalidateCache ()
const QwtTexttickLabel (const QFont &, double value) const


Member Enumeration Documentation

enum QwtAbstractScaleDraw::ScaleComponent
 

Components of a scale

  • Backbone
  • Ticks
  • Label

See also:
QwtAbstractScaleDraw::enableComponent, QwtAbstractScaleDraw::hasComponent

Definition at line 52 of file qwt_abstract_scale_draw.h.


Constructor & Destructor Documentation

QwtAbstractScaleDraw::QwtAbstractScaleDraw  ) 
 

Constructor.

The range of the scale is initialized to [0, 100], The spacing (distance between ticks and labels) is set to 4, the tick lengths are set to 4,6 and 8 pixels

Definition at line 54 of file qwt_abstract_scale_draw.cpp.

QwtAbstractScaleDraw::QwtAbstractScaleDraw const QwtAbstractScaleDraw  ) 
 

Copy constructor.

Definition at line 60 of file qwt_abstract_scale_draw.cpp.

References d_data.

QwtAbstractScaleDraw::~QwtAbstractScaleDraw  )  [virtual]
 

Destructor.

Definition at line 66 of file qwt_abstract_scale_draw.cpp.


Member Function Documentation

void QwtAbstractScaleDraw::draw QPainter *  painter,
const QPalette &  palette
const [virtual]
 

Draw the scale.

Parameters:
painter The painter
palette Palette, text color is used for the labels, foreground color for ticks and backbone

Definition at line 164 of file qwt_abstract_scale_draw.cpp.

Referenced by QwtThermo::draw(), QwtSlider::draw(), and QwtKnob::draw().

virtual void QwtAbstractScaleDraw::drawBackbone QPainter *  painter  )  const [protected, pure virtual]
 

Draws the baseline of the scale

Parameters:
painter Painter
See also:
drawTick(), drawLabel()

Implemented in QwtRoundScaleDraw, and QwtScaleDraw.

virtual void QwtAbstractScaleDraw::drawLabel QPainter *  painter,
double  value
const [protected, pure virtual]
 

Draws the label for a major scale tick

Parameters:
painter Painter
value Value
See also:
drawTick, drawBackbone

Implemented in QwtRoundScaleDraw, and QwtScaleDraw.

virtual void QwtAbstractScaleDraw::drawTick QPainter *  painter,
double  value,
int  len
const [protected, pure virtual]
 

Draw a tick

Parameters:
painter Painter
value Value of the tick
len Lenght of the tick
See also:
drawBackbone(), drawLabel()

Implemented in QwtRoundScaleDraw, and QwtScaleDraw.

void QwtAbstractScaleDraw::enableComponent ScaleComponent  component,
bool  enable = true
 

En/Disable a component of the scale

Parameters:
component Scale component
enable On/Off
See also:
QwtAbstractScaleDraw::hasComponent

Definition at line 85 of file qwt_abstract_scale_draw.cpp.

Referenced by QwtDial::setScaleOptions().

virtual int QwtAbstractScaleDraw::extent const QPen &  ,
const QFont & 
const [pure virtual]
 

Calculate the extent

The extent is the distcance from the baseline to the outermost pixel of the scale draw in opposite to its orientation. It is at least minimumExtent() pixels.

See also:
setMinimumExtent(), minimumExtent()

Implemented in QwtRoundScaleDraw, and QwtScaleDraw.

bool QwtAbstractScaleDraw::hasComponent ScaleComponent  component  )  const
 

Check if a component is enabled

See also:
QwtAbstractScaleDraw::enableComponent

Definition at line 98 of file qwt_abstract_scale_draw.cpp.

Referenced by QwtRoundScaleDraw::drawLabel(), QwtScaleDraw::extent(), QwtRoundScaleDraw::extent(), QwtScaleDraw::getBorderDistHint(), QwtScaleDraw::labelPosition(), QwtScaleDraw::minLabelDist(), and QwtScaleDraw::minLength().

void QwtAbstractScaleDraw::invalidateCache  )  [protected]
 

Invalidate the cache used by QwtAbstractScaleDraw::tickLabel

The cache is invalidated, when a new QwtScaleDiv is set. If the labels need to be changed. while the same QwtScaleDiv is set, QwtAbstractScaleDraw::invalidateCache needs to be called manually.

Definition at line 402 of file qwt_abstract_scale_draw.cpp.

QwtText QwtAbstractScaleDraw::label double  value  )  const [virtual]
 

Convert a value into its representing label.

The value is converted to a plain text using QString::number(value). This method is often overloaded by applications to have individual labels.

Parameters:
value Value
Returns:
Label string.

Reimplemented in QwtDialScaleDraw.

Definition at line 359 of file qwt_abstract_scale_draw.cpp.

Referenced by QwtRoundScaleDraw::drawLabel(), QwtRoundScaleDraw::extent(), QwtDialScaleDraw::label(), and tickLabel().

int QwtAbstractScaleDraw::majTickLength  )  const
 

The same as QwtAbstractScaleDraw::tickLength(QwtScaleDiv::MajorTick).

Definition at line 344 of file qwt_abstract_scale_draw.cpp.

Referenced by QwtRoundScaleDraw::drawLabel(), QwtScaleDraw::extent(), and QwtScaleDraw::labelPosition().

const QwtScaleMap & QwtAbstractScaleDraw::map  )  const
 

Returns:
Map how to translate between scale and pixel values

Definition at line 125 of file qwt_abstract_scale_draw.cpp.

Referenced by QwtRoundScaleDraw::drawBackbone(), QwtScaleWidget::drawColorBar(), QwtRoundScaleDraw::drawLabel(), QwtScaleDraw::drawTick(), QwtRoundScaleDraw::drawTick(), QwtRoundScaleDraw::extent(), QwtScaleDraw::getBorderDistHint(), QwtScaleDraw::labelPosition(), and QwtScaleWidget::setScaleDiv().

int QwtAbstractScaleDraw::minimumExtent  )  const
 

Get the minimum extent

See also:
extent(), setMinimumExtent()

Definition at line 292 of file qwt_abstract_scale_draw.cpp.

Referenced by QwtScaleDraw::extent().

QwtAbstractScaleDraw & QwtAbstractScaleDraw::operator= const QwtAbstractScaleDraw  ) 
 

Assignment operator.

Definition at line 71 of file qwt_abstract_scale_draw.cpp.

References d_data.

const QwtScaleDiv & QwtAbstractScaleDraw::scaleDiv  )  const
 

Returns:
scale division

Definition at line 137 of file qwt_abstract_scale_draw.cpp.

Referenced by QwtRoundScaleDraw::extent(), QwtScaleDraw::getBorderDistHint(), QwtScaleDraw::maxLabelHeight(), QwtScaleDraw::maxLabelWidth(), QwtScaleDraw::minLabelDist(), QwtScaleDraw::minLength(), QwtScaleWidget::setScaleDiv(), and QwtPlot::sizeHint().

QwtScaleMap & QwtAbstractScaleDraw::scaleMap  ) 
 

Returns:
Map how to translate between scale and pixel values

Definition at line 131 of file qwt_abstract_scale_draw.cpp.

Referenced by QwtScaleDraw::drawTick(), QwtRoundScaleDraw::QwtRoundScaleDraw(), and QwtRoundScaleDraw::setAngleRange().

void QwtAbstractScaleDraw::setMinimumExtent int  minExtent  ) 
 

Set a minimum for the extent.

The extent is calculated from the coomponents of the scale draw. In situations, where the labels are changing and the layout depends on the extent (f.e scrolling a scale), setting an upper limit as minimum extent will avoid jumps of the layout.

Parameters:
minExtent Minimum extent
See also:
extent(), minimumExtent()

Definition at line 280 of file qwt_abstract_scale_draw.cpp.

void QwtAbstractScaleDraw::setScaleDiv const QwtScaleDiv sd  ) 
 

Change the scale division

Parameters:
sd New scale division

Definition at line 107 of file qwt_abstract_scale_draw.cpp.

References QwtScaleDiv::hBound(), and QwtScaleDiv::lBound().

Referenced by QwtScaleWidget::setScaleDiv().

void QwtAbstractScaleDraw::setSpacing int  spacing  ) 
 

Set the spacing between tick and labels.

The spacing is the distance between ticks and labels. The default spacing is 4 pixels.

Parameters:
spacing Spacing
See also:
QwtAbstractScaleDraw::spacing

Definition at line 246 of file qwt_abstract_scale_draw.cpp.

void QwtAbstractScaleDraw::setTickLength QwtScaleDiv::TickType  tickType,
int  length
 

Set the length of the ticks

Parameters:
tickType Tick type
length New length
Warning:
the length is limited to [0..1000]

Definition at line 305 of file qwt_abstract_scale_draw.cpp.

Referenced by QwtDial::setScaleTicks().

void QwtAbstractScaleDraw::setTransformation QwtScaleTransformation transformation  ) 
 

Change the transformation of the scale

Parameters:
transformation New scale transformation

Definition at line 118 of file qwt_abstract_scale_draw.cpp.

Referenced by QwtScaleWidget::setScaleDiv().

int QwtAbstractScaleDraw::spacing  )  const
 

Get the spacing.

The spacing is the distance between ticks and labels. The default spacing is 4 pixels.

See also:
QwtAbstractScaleDraw::setSpacing

Definition at line 262 of file qwt_abstract_scale_draw.cpp.

Referenced by QwtRoundScaleDraw::drawLabel(), QwtScaleDraw::extent(), and QwtScaleDraw::labelPosition().

const QwtText & QwtAbstractScaleDraw::tickLabel const QFont &  font,
double  value
const [protected]
 

Convert a value into its representing label and cache it.

The conversion between value and label is called very often in the layout and painting code. Unfortunately the calculation of the label sizes might be slow (really slow for rich text in Qt4), so it's necessary to cache the labels.

Parameters:
font Font
value Value
Returns:
Tick label

Definition at line 377 of file qwt_abstract_scale_draw.cpp.

References label(), and QwtText::setRenderFlags().

Referenced by QwtScaleDraw::drawLabel(), QwtRoundScaleDraw::drawLabel(), QwtRoundScaleDraw::extent(), and QwtScaleDraw::labelRect().

int QwtAbstractScaleDraw::tickLength QwtScaleDiv::TickType  tickType  )  const
 

Return the length of the ticks

See also:
QwtAbstractScaleDraw::setTickLength, QwtAbstractScaleDraw::majTickLength

Definition at line 330 of file qwt_abstract_scale_draw.cpp.


Generated on Mon Feb 26 21:22:46 2007 for Qwt User's Guide by  doxygen 1.4.6