Qwt User's Guide
svn
|
#include <qwt_plot.h>
Inherits QwtPlotDict.
Public Types | |
enum | Axis { yLeft, yRight, xBottom, xTop, axisCnt } |
enum | LegendPosition { LeftLegend, RightLegend, BottomLegend, TopLegend, ExternalLegend } |
Public Slots | |
void | autoRefresh () |
virtual void | replot () |
Signals | |
void | legendChecked (QwtPlotItem *plotItem, bool on) |
void | legendClicked (QwtPlotItem *plotItem) |
Public Member Functions | |
void | applyProperties (const QString &) |
bool | autoDelete () const |
bool | autoReplot () const |
bool | axisAutoScale (int axisId) const |
bool | axisEnabled (int axisId) const |
QFont | axisFont (int axisId) const |
QwtInterval | axisInterval (int axisId) const |
int | axisMaxMajor (int axisId) const |
int | axisMaxMinor (int axisId) const |
const QwtScaleDiv * | axisScaleDiv (int axisId) const |
QwtScaleDiv * | axisScaleDiv (int axisId) |
const QwtScaleDraw * | axisScaleDraw (int axisId) const |
QwtScaleDraw * | axisScaleDraw (int axisId) |
QwtScaleEngine * | axisScaleEngine (int axisId) |
const QwtScaleEngine * | axisScaleEngine (int axisId) const |
double | axisStepSize (int axisId) const |
QwtText | axisTitle (int axisId) const |
const QwtScaleWidget * | axisWidget (int axisId) const |
QwtScaleWidget * | axisWidget (int axisId) |
QwtPlotCanvas * | canvas () |
const QwtPlotCanvas * | canvas () const |
QBrush | canvasBackground () const |
int | canvasLineWidth () const |
virtual QwtScaleMap | canvasMap (int axisId) const |
void | detachItems (int rtti=QwtPlotItem::Rtti_PlotItem, bool autoDelete=true) |
virtual void | drawCanvas (QPainter *) |
virtual void | drawItems (QPainter *, const QRectF &, const QwtScaleMap maps[axisCnt]) const |
void | enableAxis (int axisId, bool tf=true) |
virtual bool | event (QEvent *) |
QString | grabProperties () const |
void | insertLegend (QwtLegend *, LegendPosition=QwtPlot::RightLegend, double ratio=-1.0) |
double | invTransform (int axisId, int pos) const |
const QwtPlotItemList & | itemList () const |
QwtPlotItemList | itemList (int rtti) const |
QwtLegend * | legend () |
const QwtLegend * | legend () const |
virtual QSize | minimumSizeHint () const |
QwtPlotLayout * | plotLayout () |
const QwtPlotLayout * | plotLayout () const |
QwtPlot (QWidget *=NULL) | |
QwtPlot (const QwtText &title, QWidget *p=NULL) | |
void | setAutoDelete (bool) |
void | setAutoReplot (bool tf=true) |
void | setAxisAutoScale (int axisId, bool on=true) |
void | setAxisFont (int axisId, const QFont &f) |
void | setAxisLabelAlignment (int axisId, Qt::Alignment) |
void | setAxisLabelRotation (int axisId, double rotation) |
void | setAxisMaxMajor (int axisId, int maxMajor) |
void | setAxisMaxMinor (int axisId, int maxMinor) |
void | setAxisScale (int axisId, double min, double max, double step=0) |
void | setAxisScaleDiv (int axisId, const QwtScaleDiv &) |
void | setAxisScaleDraw (int axisId, QwtScaleDraw *) |
void | setAxisScaleEngine (int axisId, QwtScaleEngine *) |
void | setAxisTitle (int axisId, const QString &) |
void | setAxisTitle (int axisId, const QwtText &) |
void | setCanvasBackground (const QBrush &) |
void | setCanvasLineWidth (int w) |
void | setTitle (const QString &) |
void | setTitle (const QwtText &t) |
virtual QSize | sizeHint () const |
QwtText | title () const |
QwtTextLabel * | titleLabel () |
const QwtTextLabel * | titleLabel () const |
double | transform (int axisId, double value) const |
void | updateAxes () |
virtual void | updateLayout () |
virtual | ~QwtPlot () |
Protected Slots | |
virtual void | legendItemChecked (bool) |
virtual void | legendItemClicked () |
Protected Member Functions | |
virtual void | resizeEvent (QResizeEvent *e) |
virtual void | updateTabOrder () |
Static Protected Member Functions | |
static bool | axisValid (int axisId) |
A 2-D plotting widget.
QwtPlot is a widget for plotting two-dimensional graphs. An unlimited number of plot items can be displayed on its canvas. Plot items might be curves (QwtPlotCurve), markers (QwtPlotMarker), the grid (QwtPlotGrid), or anything else derived from QwtPlotItem. A plot can have up to four axes, with each plot item attached to an x- and a y axis. The scales at the axes can be explicitely set (QwtScaleDiv), or are calculated from the plot items, using algorithms (QwtScaleEngine) which can be configured separately for each axis.
#include <qwt_plot.h> #include <qwt_plot_curve.h> QwtPlot *myPlot = new QwtPlot("Two Curves", parent); // add curves QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1"); QwtPlotCurve *curve2 = new QwtPlotCurve("Curve 2"); // connect or copy the data to the curves curve1->setData(...); curve2->setData(...); curve1->attach(myPlot); curve2->attach(myPlot); // finally, refresh the plot myPlot->replot();
enum QwtPlot::Axis |
Position of the legend, relative to the canvas.
LeftLegend |
The legend will be left from the QwtPlot::yLeft axis. |
RightLegend |
The legend will be right from the QwtPlot::yRight axis. |
BottomLegend |
The legend will be below QwtPlot::xBottom axis. |
TopLegend |
The legend will be between QwtPlot::xTop axis and the title. |
ExternalLegend |
External means that only the content of the legend will be handled by QwtPlot, but not its geometry. This type can be used to have a legend in an external window ( or on the canvas ). |
QwtPlot::QwtPlot | ( | QWidget * | parent = NULL | ) | [explicit] |
Constructor.
parent | Parent widget |
QwtPlot::QwtPlot | ( | const QwtText & | title, |
QWidget * | parent = NULL |
||
) | [explicit] |
Constructor.
title | Title text |
parent | Parent widget |
QwtPlot::~QwtPlot | ( | ) | [virtual] |
Destructor.
void QwtPlot::applyProperties | ( | const QString & | ) |
This method is intended for manipulating the plot widget from a specific editor in the Qwt designer plugin.
bool QwtPlotDict::autoDelete | ( | ) | const [inherited] |
void QwtPlot::autoRefresh | ( | ) | [slot] |
Replots the plot if autoReplot() is true
.
bool QwtPlot::autoReplot | ( | ) | const |
bool QwtPlot::axisAutoScale | ( | int | axisId | ) | const |
true
if autoscaling is enabled axisId | axis index |
bool QwtPlot::axisEnabled | ( | int | axisId | ) | const |
true
if a specified axis is enabled axisId | axis index |
QFont QwtPlot::axisFont | ( | int | axisId | ) | const |
axisId | axis index |
QwtInterval QwtPlot::axisInterval | ( | int | axisId | ) | const |
Return the current interval of the specified axis.
This is only a convenience function for axisScaleDiv( axisId )->interval();
axisId | axis index |
int QwtPlot::axisMaxMajor | ( | int | axisId | ) | const |
axisId | axis index |
int QwtPlot::axisMaxMinor | ( | int | axisId | ) | const |
axisId | axis index |
const QwtScaleDiv * QwtPlot::axisScaleDiv | ( | int | axisId | ) | const |
Return the scale division of a specified axis.
axisScaleDiv(axisId)->lowerBound(), axisScaleDiv(axisId)->upperBound() are the current limits of the axis scale.
axisId | axis index |
QwtScaleDiv * QwtPlot::axisScaleDiv | ( | int | axisId | ) |
Return the scale division of a specified axis.
axisScaleDiv(axisId)->lowerBound(), axisScaleDiv(axisId)->upperBound() are the current limits of the axis scale.
axisId | axis index |
const QwtScaleDraw * QwtPlot::axisScaleDraw | ( | int | axisId | ) | const |
axisId | axis index |
QwtScaleDraw * QwtPlot::axisScaleDraw | ( | int | axisId | ) |
axisId | axis index |
QwtScaleEngine * QwtPlot::axisScaleEngine | ( | int | axisId | ) |
axisId | axis index |
const QwtScaleEngine * QwtPlot::axisScaleEngine | ( | int | axisId | ) | const |
axisId | axis index |
double QwtPlot::axisStepSize | ( | int | axisId | ) | const |
Return the step size parameter, that has been set in setAxisScale. This doesn't need to be the step size of the current scale.
axisId | axis index |
QwtText QwtPlot::axisTitle | ( | int | axisId | ) | const |
axisId | axis index |
bool QwtPlot::axisValid | ( | int | axisId | ) | [static, protected] |
true
if the specified axis exists, otherwise false
axisId | axis index |
const QwtScaleWidget * QwtPlot::axisWidget | ( | int | axisId | ) | const |
axisId | axis index |
QwtScaleWidget * QwtPlot::axisWidget | ( | int | axisId | ) |
axisId | axis index |
QwtPlotCanvas * QwtPlot::canvas | ( | ) |
const QwtPlotCanvas * QwtPlot::canvas | ( | ) | const |
QBrush QwtPlot::canvasBackground | ( | ) | const |
Nothing else than: canvas()->palette().brush( QPalette::Normal, QPalette::Window);
int QwtPlot::canvasLineWidth | ( | ) | const |
Nothing else than: canvas()->lineWidth(), left for compatibility only.
QwtScaleMap QwtPlot::canvasMap | ( | int | axisId | ) | const [virtual] |
axisId | Axis |
void QwtPlotDict::detachItems | ( | int | rtti = QwtPlotItem::Rtti_PlotItem , |
bool | autoDelete = true |
||
) | [inherited] |
Detach items from the dictionary
rtti | In case of QwtPlotItem::Rtti_PlotItem detach all items otherwise only those items of the type rtti. |
autoDelete | If true, delete all detached items |
void QwtPlot::drawCanvas | ( | QPainter * | painter | ) | [virtual] |
Redraw the canvas.
painter | Painter used for drawing |
void QwtPlot::drawItems | ( | QPainter * | painter, |
const QRectF & | canvasRect, | ||
const QwtScaleMap | map[axisCnt] | ||
) | const [virtual] |
Redraw the canvas items.
painter | Painter used for drawing |
canvasRect | Bounding rectangle where to paint |
map | QwtPlot::axisCnt maps, mapping between plot and paint device coordinates |
void QwtPlot::enableAxis | ( | int | axisId, |
bool | tf = true |
||
) |
Enable or disable a specified axis.
When an axis is disabled, this only means that it is not visible on the screen. Curves, markers and can be attached to disabled axes, and transformation of screen coordinates into values works as normal.
Only xBottom and yLeft are enabled by default.
axisId | axis index |
tf | true (enabled) or false (disabled) |
bool QwtPlot::event | ( | QEvent * | event | ) | [virtual] |
Adds handling of layout requests.
event | Event |
QString QwtPlot::grabProperties | ( | ) | const |
This method is intended for manipulating the plot widget from a specific editor in the Qwt designer plugin.
void QwtPlot::insertLegend | ( | QwtLegend * | legend, |
QwtPlot::LegendPosition | pos = QwtPlot::RightLegend , |
||
double | ratio = -1.0 |
||
) |
Insert a legend.
If the position legend is QwtPlot::LeftLegend
or QwtPlot::RightLegend
the legend will be organized in one column from top to down. Otherwise the legend items will be placed in a table with a best fit number of columns from left to right.
If pos != QwtPlot::ExternalLegend the plot widget will become parent of the legend. It will be deleted when the plot is deleted, or another legend is set with insertLegend().
legend | Legend |
pos | The legend's position. For top/left position the number of colums will be limited to 1, otherwise it will be set to unlimited. |
ratio | Ratio between legend and the bounding rect of title, canvas and axes. The legend will be shrinked if it would need more space than the given ratio. The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0 it will be reset to the default ratio. The default vertical/horizontal ratio is 0.33/0.5. |
double QwtPlot::invTransform | ( | int | axisId, |
int | pos | ||
) | const |
Transform the x or y coordinate of a position in the drawing region into a value.
axisId | axis index |
pos | position |
const QwtPlotItemList & QwtPlotDict::itemList | ( | ) | const [inherited] |
A QwtPlotItemList of all attached plot items.
Use caution when iterating these lists, as removing/detaching an item will invalidate the iterator. Instead you can place pointers to objects to be removed in a removal list, and traverse that list later.
QwtPlotItemList QwtPlotDict::itemList | ( | int | rtti | ) | const [inherited] |
QwtLegend * QwtPlot::legend | ( | ) |
const QwtLegend * QwtPlot::legend | ( | ) | const |
void QwtPlot::legendChecked | ( | QwtPlotItem * | plotItem, |
bool | on | ||
) | [signal] |
A signal which is emitted when the user has clicked on a legend item, which is in QwtLegend::CheckableItem mode
plotItem | Corresponding plot item of the selected legend item |
on | True when the legen item is checked |
void QwtPlot::legendClicked | ( | QwtPlotItem * | plotItem | ) | [signal] |
A signal which is emitted when the user has clicked on a legend item, which is in QwtLegend::ClickableItem mode.
plotItem | Corresponding plot item of the selected legend item |
void QwtPlot::legendItemChecked | ( | bool | on | ) | [protected, virtual, slot] |
Called internally when the legend has been checked Emits a legendClicked() signal.
void QwtPlot::legendItemClicked | ( | ) | [protected, virtual, slot] |
Called internally when the legend has been clicked on. Emits a legendClicked() signal.
QSize QwtPlot::minimumSizeHint | ( | ) | const [virtual] |
Return a minimum size hint.
QwtPlotLayout * QwtPlot::plotLayout | ( | ) |
const QwtPlotLayout * QwtPlot::plotLayout | ( | ) | const |
void QwtPlot::replot | ( | ) | [virtual, slot] |
Redraw the plot.
If the autoReplot option is not set (which is the default) or if any curves are attached to raw data, the plot has to be refreshed explicitly in order to make changes visible.
void QwtPlot::resizeEvent | ( | QResizeEvent * | e | ) | [protected, virtual] |
Resize and update internal layout
e | Resize event |
void QwtPlotDict::setAutoDelete | ( | bool | autoDelete | ) | [inherited] |
En/Disable Auto deletion
If Auto deletion is on all attached plot items will be deleted in the destructor of QwtPlotDict. The default value is on.
void QwtPlot::setAutoReplot | ( | bool | tf = true | ) |
Set or reset the autoReplot option.
If the autoReplot option is set, the plot will be updated implicitly by manipulating member functions. Since this may be time-consuming, it is recommended to leave this option switched off and call replot() explicitly if necessary.
The autoReplot option is set to false by default, which means that the user has to call replot() in order to make changes visible.
tf | true or false . Defaults to true . |
void QwtPlot::setAxisAutoScale | ( | int | axisId, |
bool | on = true |
||
) |
Enable autoscaling for a specified axis.
This member function is used to switch back to autoscaling mode after a fixed scale has been set. Autoscaling is enabled by default.
axisId | axis index |
on | On/Off |
void QwtPlot::setAxisFont | ( | int | axisId, |
const QFont & | f | ||
) |
Change the font of an axis.
axisId | axis index |
f | font |
void QwtPlot::setAxisLabelAlignment | ( | int | axisId, |
Qt::Alignment | alignment | ||
) |
Change the alignment of the tick labels
axisId | axis index |
alignment | Or'd Qt::AlignmentFlags see <qnamespace.h> |
void QwtPlot::setAxisLabelRotation | ( | int | axisId, |
double | rotation | ||
) |
Rotate all tick labels
axisId | axis index |
rotation | Angle in degrees. When changing the label rotation, the label alignment might be adjusted too. |
void QwtPlot::setAxisMaxMajor | ( | int | axisId, |
int | maxMajor | ||
) |
Set the maximum number of major scale intervals for a specified axis
axisId | axis index |
maxMajor | maximum number of major steps |
void QwtPlot::setAxisMaxMinor | ( | int | axisId, |
int | maxMinor | ||
) |
Set the maximum number of minor scale intervals for a specified axis
axisId | axis index |
maxMinor | maximum number of minor steps |
void QwtPlot::setAxisScale | ( | int | axisId, |
double | min, | ||
double | max, | ||
double | stepSize = 0 |
||
) |
Disable autoscaling and specify a fixed scale for a selected axis.
axisId | axis index |
min | |
max | minimum and maximum of the scale |
stepSize | Major step size. If step == 0 , the step size is calculated automatically using the maxMajor setting. |
void QwtPlot::setAxisScaleDiv | ( | int | axisId, |
const QwtScaleDiv & | scaleDiv | ||
) |
Disable autoscaling and specify a fixed scale for a selected axis.
axisId | axis index |
scaleDiv | Scale division |
void QwtPlot::setAxisScaleDraw | ( | int | axisId, |
QwtScaleDraw * | scaleDraw | ||
) |
Set a scale draw.
axisId | axis index |
scaleDraw | object responsible for drawing scales. |
By passing scaleDraw it is possible to extend QwtScaleDraw functionality and let it take place in QwtPlot. Please note that scaleDraw has to be created with new and will be deleted by the corresponding QwtScale member ( like a child object ).
void QwtPlot::setAxisScaleEngine | ( | int | axisId, |
QwtScaleEngine * | scaleEngine | ||
) |
Change the scale engine for an axis
axisId | axis index |
scaleEngine | Scale engine |
void QwtPlot::setAxisTitle | ( | int | axisId, |
const QString & | title | ||
) |
Change the title of a specified axis.
axisId | axis index |
title | axis title |
void QwtPlot::setAxisTitle | ( | int | axisId, |
const QwtText & | title | ||
) |
Change the title of a specified axis.
axisId | axis index |
title | axis title |
void QwtPlot::setCanvasBackground | ( | const QBrush & | brush | ) |
Change the background of the plotting area.
Sets brush to QPalette::Window of all colorgroups of the palette of the canvas. Using canvas()->setPalette() is a more powerful way to set these colors.
brush | New background brush |
void QwtPlot::setCanvasLineWidth | ( | int | width | ) |
Change the border width of the plotting area.
Nothing else than canvas()->setLineWidth(w), left for compatibility only.
width | New border width |
void QwtPlot::setTitle | ( | const QString & | title | ) |
Change the plot's title
title | New title |
void QwtPlot::setTitle | ( | const QwtText & | title | ) |
Change the plot's title
title | New title |
QSize QwtPlot::sizeHint | ( | ) | const [virtual] |
Return sizeHint
QwtText QwtPlot::title | ( | ) | const |
QwtTextLabel * QwtPlot::titleLabel | ( | ) |
const QwtTextLabel * QwtPlot::titleLabel | ( | ) | const |
double QwtPlot::transform | ( | int | axisId, |
double | value | ||
) | const |
Transform a value into a coordinate in the plotting region.
axisId | axis index |
value | value |
void QwtPlot::updateAxes | ( | ) |
Rebuild the scales.
void QwtPlot::updateLayout | ( | ) | [virtual] |
Adjust plot content to its current size.
void QwtPlot::updateTabOrder | ( | ) | [protected, virtual] |
Update the focus tab order
The order is changed so that the canvas will be in front of the first legend item, or behind the last legend item - depending on the position of the legend.