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 "../include/qwt_plot.h> #include "../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 75 of file qwt_plot.h.
Public Types | |
enum | Axis { yLeft, yRight, xBottom, xTop, axisCnt } |
enum | LegendPosition { LeftLegend, RightLegend, BottomLegend, TopLegend } |
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 *p=0) | |
QwtPlot (const QwtText &title, QWidget *p=NULL) | |
virtual | ~QwtPlot () |
void | enableXBottomAxis (bool b) |
bool | xBottomAxisEnabled () const |
void | enableXTopAxis (bool b) |
bool | xTopAxisEnabled () const |
void | enableYRightAxis (bool b) |
bool | yRightAxisEnabled () const |
void | enableYLeftAxis (bool b) |
bool | yLeftAxisEnabled () 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, int) |
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 |
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 QwtArray< QwtScaleMap > &, 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 QwtArray< QwtScaleMap > &, 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 101 of file qwt_plot.h. |
|
Position.
Definition at line 111 of file qwt_plot.h. |
|
Constructor.
Definition at line 46 of file qwt_plot.cpp. |
|
Constructor.
Definition at line 58 of file qwt_plot.cpp. |
|
Destructor.
Definition at line 65 of file qwt_plot.cpp. |
|
Replots the plot if QwtPlot::autoReplot() is
Definition at line 147 of file qwt_plot.cpp. References replot(). Referenced by setAxisAutoScale(), setAxisMaxMajor(), setAxisMaxMinor(), setAxisScale(), setAxisScaleDiv(), setAxisScaleDraw(), and setAxisScaleEngine(). |
|
Definition at line 175 of file qwt_plot.cpp. Referenced by QwtPlotPrintFilter::apply(), replot(), QwtPlotZoomer::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(), print(), printScale(), QwtPlotPicker::QwtPlotPicker(), sizeHint(), and updateLayout(). |
|
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(). |
|
Definition at line 230 of file qwt_plot_axis.cpp. References axisValid(). |
|
Definition at line 217 of file qwt_plot_axis.cpp. References axisValid(). Referenced by canvasMap(), print(), QwtPlotZoomer::rescale(), QwtPlotPicker::scaleRect(), and updateAxes(). |
|
Definition at line 258 of file qwt_plot_axis.cpp. References axisValid(), axisWidget(), and QwtScaleWidget::scaleDraw(). |
|
Definition at line 244 of file qwt_plot_axis.cpp. References axisValid(), axisWidget(), and QwtScaleWidget::scaleDraw(). |
|
Definition at line 270 of file qwt_plot_axis.cpp. References axisValid(), axisWidget(), and QwtScaleWidget::title(). |
|
Definition at line 731 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 QwtPlotPrintFilter::apply(), axisFont(), axisScaleDraw(), axisTitle(), canvasMap(), QwtPlotLayout::minimumSizeHint(), print(), printScale(), QwtPlotPrintFilter::reset(), setAxisFont(), setAxisLabelRotation(), setAxisScaleDraw(), setAxisTitle(), sizeHint(), updateAxes(), and updateLayout(). |
|
Definition at line 269 of file qwt_plot.cpp. |
|
Definition at line 261 of file qwt_plot.cpp. Referenced by canvasBackground(), canvasLineWidth(), QwtPlotCurve::draw(), QwtPlotLayout::minimumSizeHint(), printCanvas(), replot(), setCanvasBackground(), and setCanvasLineWidth(). |
|
Nothing else than: canvas()->palette().color( QPalette::Normal, QColorGroup::Background);
Definition at line 695 of file qwt_plot.cpp. References canvas(). Referenced by QwtPlotPrintFilter::apply(). |
|
Nothing else than: canvas()->lineWidth(), left for compatibility only.
Definition at line 722 of file qwt_plot.cpp. References canvas(). |
|
Definition at line 591 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(), QwtPlotCurve::draw(), drawCanvas(), QwtPlotPicker::invTransform(), invTransform(), QwtPlotPicker::transform(), and transform(). |
|
Remove all curves and markers.
Definition at line 762 of file qwt_plot.cpp. |
|
Redraw the canvas.
Definition at line 529 of file qwt_plot.cpp. References canvasMap(), and drawItems(). |
|
Redraw the canvas items.
Definition at line 547 of file qwt_plot.cpp. References QwtPlotItem::draw(), QwtPlotItem::isVisible(), QwtPlotPrintFilter::options(), QwtPlotItem::rtti(), QwtPlotItem::xAxis(), and QwtPlotItem::yAxis(). Referenced by drawCanvas(), and printCanvas(). |
|
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 290 of file qwt_plot_axis.cpp. References axisValid(), and updateLayout(). |
|
Designer API for enableAxis.
Definition at line 124 of file qwt_plot.h. |
|
Designer API for enableAxis.
Definition at line 128 of file qwt_plot.h. |
|
Designer API for enableAxis.
Definition at line 136 of file qwt_plot.h. |
|
Designer API for enableAxis.
Definition at line 132 of file qwt_plot.h. |
|
Adds handling of layout requests.
Definition at line 121 of file qwt_plot.cpp. References polish(), and updateLayout(). |
|
Insert a legend.
If the position legend is 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 794 of file qwt_plot.cpp. References QwtDynGridLayout::setMaxCols(), updateLayout(), and updateTabOrder(). |
|
Transform the x or y coordinate of a position in the drawing region into a value.
Definition at line 307 of file qwt_plot_axis.cpp. References axisValid(), canvasMap(), and QwtScaleMap::invTransform(). |
|
Definition at line 252 of file qwt_plot.cpp. |
|
Definition at line 243 of file qwt_plot.cpp. Referenced by QwtPlotLayout::activate(), QwtPlotPrintFilter::apply(), QwtPlotLayout::minimumSizeHint(), print(), printLegend(), QwtPlotPrintFilter::reset(), and updateTabOrder(). |
|
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 741 of file qwt_plot.cpp. References legendClicked(). |
|
Definition at line 660 of file qwt_plot.cpp. Referenced by canvasMap(), and print(). |
|
Return a minimum size hint.
Definition at line 323 of file qwt_plot.cpp. Referenced by sizeHint(). |
|
Definition at line 218 of file qwt_plot.cpp. |
|
Definition at line 210 of file qwt_plot.cpp. Referenced by canvasMap(), and print(). |
|
|
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 431 of file qwt_plot_print.cpp. References canvas(), drawItems(), QwtPainter::drawRect(), QwtPainter::metricsMap(), QwtPlotPrintFilter::options(), QwtMetricsMap::screenToLayoutX(), QwtMetricsMap::screenToLayoutY(), and QwtPainter::setClipRect(). Referenced by print(). |
|
Print the legend into a given rectangle.
Definition at line 267 of file qwt_plot_print.cpp. References QwtDynGridLayout::columnsForWidth(), QwtLegend::contentsWidget(), QwtDynGridLayout::iterator(), QwtDynGridLayout::layoutItems(), legend(), printLegendItem(), and QwtPainter::setClipRect(). Referenced by print(). |
|
Print the legend item into a given rectangle.
Definition at line 322 of file qwt_plot_print.cpp. References QwtLegendItem::drawItem(). 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(), QwtAbstractScaleDraw::draw(), QwtScaleWidget::drawTitle(), QwtScaleDraw::length(), QwtScaleDraw::move(), QwtScaleDraw::pos(), QwtScaleWidget::scaleDraw(), and QwtScaleDraw::setLength(). Referenced by print(). |
|
Print the title into a given rectangle.
Definition at line 243 of file qwt_plot_print.cpp. References QwtText::draw(), QwtTextLabel::text(), and titleLabel(). Referenced by print(). |
|
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 348 of file qwt_plot.cpp. References autoReplot(), canvas(), QwtPlotCanvas::invalidatePaintCache(), setAutoReplot(), QwtPlotCanvas::testPaintAttribute(), and updateAxes(). Referenced by autoRefresh(), polish(), and QwtPlotZoomer::rescale(). |
|
Resize and update internal layout.
Definition at line 332 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 167 of file qwt_plot.cpp. Referenced by QwtPlotPrintFilter::apply(), replot(), QwtPlotZoomer::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 354 of file qwt_plot_axis.cpp. References autoRefresh(), and axisValid(). |
|
Change the font of an axis.
Definition at line 339 of file qwt_plot_axis.cpp. References axisValid(), and axisWidget(). |
|
Change the alignment of the tick labels
Definition at line 439 of file qwt_plot_axis.cpp. |
|
Rotate all tick labels
Definition at line 455 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 493 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 467 of file qwt_plot_axis.cpp. References autoRefresh(), and axisValid(). |
|
Disable autoscaling and specify a fixed scale for a selected axis.
Definition at line 372 of file qwt_plot_axis.cpp. References autoRefresh(), and axisValid(). Referenced by QwtPlotZoomer::rescale(). |
|
Disable autoscaling and specify a fixed scale for a selected axis.
Definition at line 395 of file qwt_plot_axis.cpp. References autoRefresh(), and axisValid(). |
|
Set a scale draw.
Definition at line 423 of file qwt_plot_axis.cpp. References autoRefresh(), axisValid(), axisWidget(), and QwtScaleWidget::setScaleDraw(). |
|
Change the title of a specified axis.
Definition at line 528 of file qwt_plot_axis.cpp. References axisValid(), axisWidget(), and QwtScaleWidget::setTitle(). |
|
Change the title of a specified axis.
Definition at line 517 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 673 of file qwt_plot.cpp. References canvas(). Referenced by QwtPlotPrintFilter::apply(), and QwtPlotPrintFilter::reset(). |
|
Change the border width of the plotting area Nothing else than canvas()->setLineWidth(w), left for compatibility only.
Definition at line 712 of file qwt_plot.cpp. References canvas(). |
|
Change the margin of the plot. The margin is the space around all components.
Definition at line 644 of file qwt_plot.cpp. References updateLayout(). |
|
Change the plot's title.
Definition at line 193 of file qwt_plot.cpp. |
|
Change the plot's title.
Definition at line 184 of file qwt_plot.cpp. |
|
Return sizeHint
Definition at line 288 of file qwt_plot.cpp. References axisEnabled(), axisWidget(), minimumSizeHint(), QwtScaleWidget::minimumSizeHint(), QwtAbstractScaleDraw::scaleDiv(), QwtScaleWidget::scaleDraw(), and QwtScaleDiv::ticks(). |
|
Definition at line 202 of file qwt_plot.cpp. |
|
Definition at line 234 of file qwt_plot.cpp. |
|
Definition at line 226 of file qwt_plot.cpp. Referenced by QwtPlotPrintFilter::apply(), QwtPlotLayout::minimumSizeHint(), print(), printTitle(), and QwtPlotPrintFilter::reset(). |
|
Transform a value into a coordinate in the plotting region.
Definition at line 323 of file qwt_plot_axis.cpp. References axisValid(), canvasMap(), and QwtScaleMap::transform(). |
|
Rebuild the scales and maps.
Definition at line 535 of file qwt_plot_axis.cpp. References axisAutoScale(), axisScaleDiv(), axisWidget(), QwtDoubleRect::bottom(), QwtPlotItem::boundingRect(), QwtScaleWidget::getBorderDistHint(), QwtDoubleInterval::isValid(), QwtDoubleRect::left(), QwtDoubleInterval::maxValue(), QwtDoubleInterval::minValue(), QwtDoubleRect::right(), QwtScaleWidget::setBorderDist(), QwtScaleWidget::setScaleDiv(), QwtPlotItem::testItemAttribute(), QwtDoubleRect::top(), QwtPlotItem::updateScaleDiv(), QwtPlotItem::xAxis(), and QwtPlotItem::yAxis(). Referenced by replot(). |
|
Adjust plot content to its current size.
Definition at line 398 of file qwt_plot.cpp. References axisEnabled(), and axisWidget(). Referenced by enableAxis(), event(), insertLegend(), resizeEvent(), and setMargin(). |
|
Update the focus tab order.
Definition at line 455 of file qwt_plot.cpp. References legend(). Referenced by insertLegend(). |
|
Designer API for axisEnabled.
Definition at line 126 of file qwt_plot.h. |
|
Designer API for axisEnabled.
Definition at line 130 of file qwt_plot.h. |
|
Designer API for axisEnabled.
Definition at line 138 of file qwt_plot.h. |
|
Designer API for axisEnabled.
Definition at line 134 of file qwt_plot.h. |