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; double x[100], y1[100], y2[100]; // x and y values myPlot = new QwtPlot("Two Curves", parent); // add curves QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1"); QwtPlotCurve *curve2 = new QwtPlotCurve("Curve 2"); getSomeValues(x, y1, y2); // copy the data into the curves curve1->setData(x, y1, 100); curve2->setData(x, y2, 100); curve1->attach(myPlot); curve2->attach(myPlot); // finally, refresh the plot myPlot->replot();
Definition at line 77 of file qwt_plot.h.
Public Types | |
enum | Axis { yLeft, yRight, xBottom, xTop, axisCnt } |
enum | LegendPosition { LeftLegend, RightLegend, BottomLegend, TopLegend, ExternalLegend } |
Public Slots | |
void | clear () |
virtual void | replot () |
void | autoRefresh () |
Signals | |
void | legendClicked (QwtPlotItem *plotItem) |
void | legendChecked (QwtPlotItem *plotItem, bool on) |
Public Member Functions | |
QwtPlot (QWidget *=NULL) | |
QwtPlot (const QwtText &title, QWidget *p=NULL) | |
virtual | ~QwtPlot () |
void | applyProperties (const QString &) |
QString | grabProperties () const |
void | setAutoReplot (bool tf=true) |
bool | autoReplot () const |
void | print (QPaintDevice &p, const QwtPlotPrintFilter &=QwtPlotPrintFilter()) const |
virtual void | print (QPainter *, const QRect &rect, const QwtPlotPrintFilter &=QwtPlotPrintFilter()) const |
QwtPlotLayout * | plotLayout () |
const QwtPlotLayout * | plotLayout () const |
void | setMargin (int margin) |
int | margin () const |
void | setTitle (const QString &) |
void | setTitle (const QwtText &t) |
QwtText | title () const |
QwtTextLabel * | titleLabel () |
const QwtTextLabel * | titleLabel () const |
QwtPlotCanvas * | canvas () |
const QwtPlotCanvas * | canvas () const |
void | setCanvasBackground (const QColor &c) |
const QColor & | canvasBackground () const |
void | setCanvasLineWidth (int w) |
int | canvasLineWidth () const |
virtual QwtScaleMap | canvasMap (int axisId) const |
double | invTransform (int axisId, int pos) const |
int | transform (int axisId, double value) const |
QwtScaleEngine * | axisScaleEngine (int axisId) |
const QwtScaleEngine * | axisScaleEngine (int axisId) const |
void | setAxisScaleEngine (int axisId, QwtScaleEngine *) |
void | setAxisAutoScale (int axisId) |
bool | axisAutoScale (int axisId) const |
void | enableAxis (int axisId, bool tf=true) |
bool | axisEnabled (int axisId) const |
void | setAxisFont (int axisId, const QFont &f) |
QFont | axisFont (int axisId) const |
void | setAxisScale (int axisId, double min, double max, double step=0) |
void | setAxisScaleDiv (int axisId, const QwtScaleDiv &) |
void | setAxisScaleDraw (int axisId, QwtScaleDraw *) |
const QwtScaleDiv * | axisScaleDiv (int axisId) const |
QwtScaleDiv * | axisScaleDiv (int axisId) |
const QwtScaleDraw * | axisScaleDraw (int axisId) const |
QwtScaleDraw * | axisScaleDraw (int axisId) |
const QwtScaleWidget * | axisWidget (int axisId) const |
QwtScaleWidget * | axisWidget (int axisId) |
void | setAxisLabelAlignment (int axisId, Qt::Alignment) |
void | setAxisLabelRotation (int axisId, double rotation) |
void | setAxisTitle (int axisId, const QString &) |
void | setAxisTitle (int axisId, const QwtText &) |
QwtText | axisTitle (int axisId) const |
void | setAxisMaxMinor (int axisId, int maxMinor) |
int | axisMaxMajor (int axisId) const |
void | setAxisMaxMajor (int axisId, int maxMajor) |
int | axisMaxMinor (int axisId) const |
void | insertLegend (QwtLegend *, LegendPosition=QwtPlot::RightLegend, double ratio=-1.0) |
QwtLegend * | legend () |
const QwtLegend * | legend () const |
virtual void | polish () |
virtual QSize | sizeHint () const |
virtual QSize | minimumSizeHint () const |
virtual void | updateLayout () |
virtual bool | event (QEvent *) |
Protected Slots | |
virtual void | legendItemClicked () |
virtual void | legendItemChecked (bool) |
Protected Member Functions | |
virtual void | drawCanvas (QPainter *) |
virtual void | drawItems (QPainter *, const QRect &, const QwtScaleMap maps[axisCnt], const QwtPlotPrintFilter &) const |
virtual void | updateTabOrder () |
void | updateAxes () |
virtual void | resizeEvent (QResizeEvent *e) |
virtual void | printLegendItem (QPainter *, const QWidget *, const QRect &) const |
virtual void | printTitle (QPainter *, const QRect &) const |
virtual void | printScale (QPainter *, int axisId, int startDist, int endDist, int baseDist, const QRect &) const |
virtual void | printCanvas (QPainter *, const QRect &, const QwtScaleMap maps[axisCnt], const QwtPlotPrintFilter &) const |
virtual void | printLegend (QPainter *, const QRect &) const |
Static Protected Member Functions | |
static bool | axisValid (int axisId) |
Friends | |
class | QwtPlotCanvas |
|
Axis index.
Definition at line 87 of file qwt_plot.h. |
|
Position of the legend, relative to the canvas. ExternalLegend means that only the content of the legend will be handled by QwtPlot, but not its geometry. This might be interesting if an application wants to have a legend in an external window. Definition at line 105 of file qwt_plot.h. |
|
Constructor.
Definition at line 53 of file qwt_plot.cpp. |
|
Constructor.
Definition at line 64 of file qwt_plot.cpp. References title(). |
|
Destructor.
Definition at line 85 of file qwt_plot.cpp. References QwtPlotDict::autoDelete(), and QwtPlotDict::detachItems(). |
|
Replots the plot if QwtPlot::autoReplot() is
Definition at line 167 of file qwt_plot.cpp. References replot(). Referenced by setAxisAutoScale(), setAxisMaxMajor(), setAxisMaxMinor(), setAxisScale(), setAxisScaleDiv(), setAxisScaleDraw(), and setAxisScaleEngine(). |
|
Definition at line 195 of file qwt_plot.cpp. Referenced by QwtPlotPrintFilter::apply(), QwtPlotPanner::moveCanvas(), replot(), QwtPlotZoomer::rescale(), QwtPlotMagnifier::rescale(), and QwtPlotPrintFilter::reset(). |
|
Definition at line 154 of file qwt_plot_axis.cpp. References axisValid(). Referenced by updateAxes(). |
|
Definition at line 167 of file qwt_plot_axis.cpp. References axisValid(). Referenced by canvasMap(), QwtPlotLayout::minimumSizeHint(), printScale(), QwtPlotPicker::QwtPlotPicker(), and sizeHint(). |
|
Definition at line 179 of file qwt_plot_axis.cpp. References axisValid(), and axisWidget(). |
|
Definition at line 192 of file qwt_plot_axis.cpp. References axisValid(). |
|
Definition at line 204 of file qwt_plot_axis.cpp. References axisValid(). |
|
Return the scale division of a specified axis. axisScaleDiv(axisId)->lBound(), axisScaleDiv(axisId)->hBound() are the current limits of the axis scale.
Definition at line 242 of file qwt_plot_axis.cpp. References axisValid(). |
|
Return the scale division of a specified axis. axisScaleDiv(axisId)->lBound(), axisScaleDiv(axisId)->hBound() are the current limits of the axis scale.
Definition at line 223 of file qwt_plot_axis.cpp. References axisValid(). Referenced by canvasMap(), QwtPlotPanner::moveCanvas(), QwtPlotZoomer::rescale(), QwtPlotMagnifier::rescale(), and QwtPlotPicker::scaleRect(). |
|
Definition at line 270 of file qwt_plot_axis.cpp. References axisValid(), axisWidget(), and QwtScaleWidget::scaleDraw(). |
|
Definition at line 256 of file qwt_plot_axis.cpp. References axisValid(), axisWidget(), and QwtScaleWidget::scaleDraw(). |
|
Definition at line 282 of file qwt_plot_axis.cpp. References axisValid(), axisWidget(), and QwtScaleWidget::title(). |
|
Definition at line 767 of file qwt_plot.cpp. Referenced by axisAutoScale(), axisEnabled(), axisFont(), axisMaxMajor(), axisMaxMinor(), axisScaleDiv(), axisScaleDraw(), axisScaleEngine(), axisTitle(), axisWidget(), enableAxis(), invTransform(), setAxisAutoScale(), setAxisFont(), setAxisLabelRotation(), setAxisMaxMajor(), setAxisMaxMinor(), setAxisScale(), setAxisScaleDiv(), setAxisScaleDraw(), setAxisScaleEngine(), setAxisTitle(), and transform(). |
|
Definition at line 112 of file qwt_plot_axis.cpp. References axisValid(). |
|
Definition at line 100 of file qwt_plot_axis.cpp. References axisValid(). Referenced by axisFont(), axisScaleDraw(), axisTitle(), canvasMap(), QwtPlotLayout::minimumSizeHint(), print(), printScale(), setAxisFont(), setAxisLabelRotation(), setAxisScaleDraw(), setAxisTitle(), and sizeHint(). |
|
Definition at line 297 of file qwt_plot.cpp. |
|
Definition at line 289 of file qwt_plot.cpp. Referenced by canvasBackground(), canvasLineWidth(), QwtPlotCurve::draw(), printCanvas(), replot(), and setCanvasLineWidth(). |
|
Nothing else than: canvas()->palette().color( QPalette::Normal, QColorGroup::Background);
Definition at line 730 of file qwt_plot.cpp. References canvas(). |
|
Nothing else than: canvas()->lineWidth(), left for compatibility only.
Definition at line 758 of file qwt_plot.cpp. References canvas(). |
|
Definition at line 626 of file qwt_plot.cpp. References axisEnabled(), axisScaleDiv(), axisScaleEngine(), axisWidget(), QwtPlotLayout::canvasMargin(), QwtScaleWidget::endBorderDist(), QwtScaleDiv::hBound(), QwtScaleDiv::lBound(), margin(), plotLayout(), QwtScaleMap::setPaintInterval(), QwtScaleMap::setScaleInterval(), QwtScaleMap::setTransformation(), and QwtScaleWidget::startBorderDist(). Referenced by QwtPlotCurve::closestPoint(), drawCanvas(), QwtPlotPicker::invTransform(), invTransform(), QwtPlotPanner::moveCanvas(), QwtPlotPicker::transform(), and transform(). |
|
Remove all curves and markers.
Definition at line 798 of file qwt_plot.cpp. References QwtPlotDict::detachItems(). |
|
Redraw the canvas.
Definition at line 568 of file qwt_plot.cpp. References canvasMap(), and drawItems(). |
|
Redraw the canvas items.
Definition at line 586 of file qwt_plot.cpp. References QwtPlotDict::itemList(), and QwtPlotPrintFilter::options(). Referenced by drawCanvas(). |
|
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.
Definition at line 302 of file qwt_plot_axis.cpp. References axisValid(), and updateLayout(). |
|
Adds handling of layout requests.
Definition at line 141 of file qwt_plot.cpp. References polish(), and updateLayout(). |
|
Insert a legend.
If the position legend is 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().
Definition at line 830 of file qwt_plot.cpp. References QwtPlotDict::itemList(), and legend(). |
|
Transform the x or y coordinate of a position in the drawing region into a value.
Definition at line 319 of file qwt_plot_axis.cpp. References axisValid(), and canvasMap(). |
|
Definition at line 280 of file qwt_plot.cpp. |
|
Definition at line 271 of file qwt_plot.cpp. Referenced by QwtPlotLayout::activate(), insertLegend(), and printLegend(). |
|
A signal which is emitted when the user has clicked on a legend item, which is in QwtLegend::CheckableItem mode
Referenced by legendItemChecked(). |
|
A signal which is emitted when the user has clicked on a legend item, which is in QwtLegend::ClickableItem mode.
Referenced by legendItemClicked(). |
|
Called internally when the legend has been clicked on. Emits a legendClicked() signal. Definition at line 777 of file qwt_plot.cpp. References legendClicked(). |
|
Definition at line 695 of file qwt_plot.cpp. Referenced by canvasMap(). |
|
Return a minimum size hint.
Definition at line 351 of file qwt_plot.cpp. |
|
Definition at line 246 of file qwt_plot.cpp. |
|
Definition at line 238 of file qwt_plot.cpp. Referenced by canvasMap(). |
|
Paint the plot into a given rectangle. Paint the contents of a QwtPlot instance into a given rectangle.
Definition at line 74 of file qwt_plot_print.cpp. References QwtPlotPrintFilter::apply(), axisWidget(), QwtPainter::metricsMap(), QwtPlotPrintFilter::options(), and QwtPainter::setMetricsMap(). |
|
Print the plot to a
Definition at line 44 of file qwt_plot_print.cpp. |
|
Print the canvas into a given rectangle.
Definition at line 450 of file qwt_plot_print.cpp. References canvas(), and QwtPlotPrintFilter::options(). |
|
Print the legend into a given rectangle.
Definition at line 267 of file qwt_plot_print.cpp. References QwtDynGridLayout::columnsForWidth(), QwtLegend::contentsWidget(), QwtDynGridLayout::count(), QwtDynGridLayout::itemAt(), QwtDynGridLayout::layoutItems(), legend(), printLegendItem(), and QwtPainter::setClipRect(). |
|
Print the legend item into a given rectangle.
Definition at line 322 of file qwt_plot_print.cpp. Referenced by printLegend(). |
|
Paint a scale into a given rectangle. Paint the scale into a given rectangle.
Definition at line 346 of file qwt_plot_print.cpp. References axisEnabled(), axisWidget(), QwtScaleWidget::colorBarRect(), QwtScaleWidget::colorBarWidth(), QwtScaleWidget::drawColorBar(), QwtScaleWidget::isColorBarEnabled(), QwtPainter::metricsMap(), QwtScaleDraw::orientation(), QwtScaleWidget::scaleDraw(), and QwtScaleWidget::spacing(). |
|
Print the title into a given rectangle.
Definition at line 243 of file qwt_plot_print.cpp. References QwtText::draw(), QwtTextLabel::text(), and titleLabel(). |
|
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.
Definition at line 376 of file qwt_plot.cpp. References autoReplot(), canvas(), QwtPlotCanvas::invalidatePaintCache(), setAutoReplot(), QwtPlotCanvas::testPaintAttribute(), and updateAxes(). Referenced by applyProperties(), autoRefresh(), and polish(). |
|
Resize and update internal layout.
Definition at line 360 of file qwt_plot.cpp. References updateLayout(). |
|
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.
Definition at line 187 of file qwt_plot.cpp. Referenced by QwtPlotPrintFilter::apply(), QwtPlotPanner::moveCanvas(), replot(), QwtPlotZoomer::rescale(), QwtPlotMagnifier::rescale(), and QwtPlotPrintFilter::reset(). |
|
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.
Definition at line 366 of file qwt_plot_axis.cpp. References autoRefresh(), and axisValid(). |
|
Change the font of an axis.
Definition at line 351 of file qwt_plot_axis.cpp. References axisValid(), and axisWidget(). |
|
Change the alignment of the tick labels
Definition at line 453 of file qwt_plot_axis.cpp. |
|
Rotate all tick labels
Definition at line 467 of file qwt_plot_axis.cpp. References axisValid(), axisWidget(), and QwtScaleWidget::setLabelRotation(). |
|
Set the maximum number of major scale intervals for a specified axis.
Definition at line 505 of file qwt_plot_axis.cpp. References autoRefresh(), and axisValid(). |
|
Set the maximum number of minor scale intervals for a specified axis.
Definition at line 479 of file qwt_plot_axis.cpp. References autoRefresh(), and axisValid(). |
|
Disable autoscaling and specify a fixed scale for a selected axis.
Definition at line 384 of file qwt_plot_axis.cpp. References autoRefresh(), and axisValid(). Referenced by QwtPlotPanner::moveCanvas(), QwtPlotZoomer::rescale(), and QwtPlotMagnifier::rescale(). |
|
Disable autoscaling and specify a fixed scale for a selected axis.
Definition at line 407 of file qwt_plot_axis.cpp. References autoRefresh(), and axisValid(). |
|
Set a scale draw.
Definition at line 435 of file qwt_plot_axis.cpp. References autoRefresh(), axisValid(), axisWidget(), and QwtScaleWidget::setScaleDraw(). |
|
Change the title of a specified axis.
Definition at line 540 of file qwt_plot_axis.cpp. References axisValid(), axisWidget(), QwtScaleWidget::setTitle(), and title(). |
|
Change the title of a specified axis.
Definition at line 529 of file qwt_plot_axis.cpp. References axisValid(), axisWidget(), and QwtScaleWidget::setTitle(). |
|
Change the background of the plotting area. Sets c to QColorGroup::Background of all colorgroups of the palette of the canvas. Using canvas()->setPalette() is a more powerful way to set these colors.
Definition at line 708 of file qwt_plot.cpp. |
|
Change the border width of the plotting area Nothing else than canvas()->setLineWidth(w), left for compatibility only.
Definition at line 747 of file qwt_plot.cpp. References canvas(), and updateLayout(). |
|
Change the margin of the plot. The margin is the space around all components.
Definition at line 679 of file qwt_plot.cpp. References updateLayout(). |
|
Change the plot's title.
Definition at line 217 of file qwt_plot.cpp. References updateLayout(). |
|
Change the plot's title.
Definition at line 204 of file qwt_plot.cpp. References updateLayout(). Referenced by applyProperties(). |
|
Return sizeHint
Definition at line 316 of file qwt_plot.cpp. References axisEnabled(), axisWidget(), QwtScaleWidget::minimumSizeHint(), QwtAbstractScaleDraw::scaleDiv(), QwtScaleWidget::scaleDraw(), and QwtScaleDiv::ticks(). |
|
Definition at line 230 of file qwt_plot.cpp. Referenced by grabProperties(), QwtPlot(), and setAxisTitle(). |
|
Definition at line 262 of file qwt_plot.cpp. |
|
Definition at line 254 of file qwt_plot.cpp. Referenced by QwtPlotPrintFilter::apply(), printTitle(), and QwtPlotPrintFilter::reset(). |
|
Transform a value into a coordinate in the plotting region.
Definition at line 335 of file qwt_plot_axis.cpp. References axisValid(), and canvasMap(). |
|
Rebuild the scales and maps.
Definition at line 547 of file qwt_plot_axis.cpp. References axisAutoScale(), and QwtPlotDict::itemList(). Referenced by replot(). |
|
Adjust plot content to its current size.
Definition at line 426 of file qwt_plot.cpp. Referenced by enableAxis(), event(), resizeEvent(), setCanvasLineWidth(), setMargin(), and setTitle(). |
|
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. Definition at line 490 of file qwt_plot.cpp. |