You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
146 lines
0 B
146 lines
0 B
15 years ago
|
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||
|
* Qwt Widget Library
|
||
|
* Copyright (C) 1997 Josef Wilgen
|
||
|
* Copyright (C) 2002 Uwe Rathmann
|
||
14 years ago
|
*
|
||
15 years ago
|
* This library is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the Qwt License, Version 1.0
|
||
|
*****************************************************************************/
|
||
|
|
||
|
#ifndef QWT_ABSTRACT_SCALE_DRAW_H
|
||
|
#define QWT_ABSTRACT_SCALE_DRAW_H
|
||
|
|
||
|
#include "qwt_global.h"
|
||
|
#include "qwt_scale_div.h"
|
||
|
#include "qwt_text.h"
|
||
|
|
||
|
|
||
|
#if QT_VERSION < 0x040000
|
||
|
class QColorGroup;
|
||
|
#else
|
||
|
class QPalette;
|
||
|
#endif
|
||
|
class QPainter;
|
||
|
class QFont;
|
||
|
class QwtScaleTransformation;
|
||
|
class QwtScaleMap;
|
||
|
|
||
|
/*!
|
||
|
\brief 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.
|
||
|
*/
|
||
|
class QWT_EXPORT QwtAbstractScaleDraw
|
||
|
{
|
||
|
public:
|
||
|
|
||
14 years ago
|
/*!
|
||
|
Components of a scale
|
||
15 years ago
|
|
||
14 years ago
|
- Backbone
|
||
|
- Ticks
|
||
|
- Labels
|
||
15 years ago
|
|
||
14 years ago
|
\sa QwtAbstractScaleDraw::enableComponent,
|
||
|
QwtAbstractScaleDraw::hasComponent
|
||
|
*/
|
||
15 years ago
|
|
||
14 years ago
|
enum ScaleComponent {
|
||
15 years ago
|
Backbone = 1,
|
||
|
Ticks = 2,
|
||
|
Labels = 4
|
||
|
};
|
||
14 years ago
|
|
||
15 years ago
|
QwtAbstractScaleDraw();
|
||
|
QwtAbstractScaleDraw( const QwtAbstractScaleDraw & );
|
||
|
virtual ~QwtAbstractScaleDraw();
|
||
|
|
||
|
QwtAbstractScaleDraw &operator=(const QwtAbstractScaleDraw &);
|
||
14 years ago
|
|
||
15 years ago
|
void setScaleDiv(const QwtScaleDiv &s);
|
||
|
const QwtScaleDiv& scaleDiv() const;
|
||
|
|
||
|
void setTransformation(QwtScaleTransformation *);
|
||
|
const QwtScaleMap &map() 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;
|
||
14 years ago
|
|
||
15 years ago
|
#if QT_VERSION < 0x040000
|
||
|
virtual void draw(QPainter *, const QColorGroup &) const;
|
||
|
#else
|
||
|
virtual void draw(QPainter *, const QPalette &) const;
|
||
|
#endif
|
||
|
|
||
|
virtual QwtText label(double) const;
|
||
|
|
||
14 years ago
|
/*!
|
||
|
Calculate the extent
|
||
15 years ago
|
|
||
|
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.
|
||
14 years ago
|
|
||
15 years ago
|
\sa setMinimumExtent(), minimumExtent()
|
||
|
*/
|
||
|
virtual int extent(const QPen &, const QFont &) const = 0;
|
||
|
|
||
|
void setMinimumExtent(int);
|
||
|
int minimumExtent() const;
|
||
|
|
||
|
QwtScaleMap &scaleMap();
|
||
|
|
||
|
protected:
|
||
|
/*!
|
||
|
Draw a tick
|
||
14 years ago
|
|
||
15 years ago
|
\param painter Painter
|
||
|
\param value Value of the tick
|
||
|
\param len Lenght of the tick
|
||
|
|
||
|
\sa drawBackbone(), drawLabel()
|
||
14 years ago
|
*/
|
||
15 years ago
|
virtual void drawTick(QPainter *painter, double value, int len) const = 0;
|
||
|
|
||
|
/*!
|
||
|
Draws the baseline of the scale
|
||
|
\param painter Painter
|
||
|
|
||
|
\sa drawTick(), drawLabel()
|
||
|
*/
|
||
|
virtual void drawBackbone(QPainter *painter) const = 0;
|
||
|
|
||
14 years ago
|
/*!
|
||
15 years ago
|
Draws the label for a major scale tick
|
||
14 years ago
|
|
||
15 years ago
|
\param painter Painter
|
||
|
\param value Value
|
||
|
|
||
|
\sa drawTick, drawBackbone
|
||
14 years ago
|
*/
|
||
15 years ago
|
virtual void drawLabel(QPainter *painter, double value) const = 0;
|
||
|
|
||
|
void invalidateCache();
|
||
|
const QwtText &tickLabel(const QFont &, double value) const;
|
||
|
|
||
|
private:
|
||
|
int operator==(const QwtAbstractScaleDraw &) const;
|
||
|
int operator!=(const QwtAbstractScaleDraw &) const;
|
||
|
|
||
|
class PrivateData;
|
||
|
PrivateData *d_data;
|
||
|
};
|
||
|
|
||
|
#endif
|