|
QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
|
A 2-D plotting widget 更多...
#include <qwt_plot.h>
类 | |
| class | PrivateData |
| class | ScaleData |
Public 类型 | |
| enum | LegendPosition { LeftLegend , RightLegend , BottomLegend , TopLegend } |
| Position of the legend, relative to the canvas 更多... | |
| enum | TickDirection { TickOutside = 0 , TickInside = 1 } |
| Tick direction enum 更多... | |
| enum | Axis { yLeft = QwtAxis::YLeft , yRight = QwtAxis::YRight , xBottom = QwtAxis::XBottom , xTop = QwtAxis::XTop , axisCnt = QwtAxis::AxisPositions } |
Public 槽 | |
| virtual void | replot () |
| Redraw the plot | |
| void | autoRefresh () |
| Replots the plot if autoReplot() is enabled | |
| virtual void | replotAll () |
| Replot all plots | |
| void | autoRefreshAll () |
信号 | |
| void | itemAttached (QwtPlotItem *plotItem, bool on) |
| A signal indicating that an item has been attached/detached | |
| void | legendDataChanged (const QVariant &itemInfo, const QList< QwtLegendData > &data) |
| A signal with the attributes how to update the legend entries for a plot item. | |
| void | parasitePlotAttached (QwtPlot *parasitePlot, bool on) |
| Identify the relationship between the parasitic plot and its host plot | |
Public 成员函数 | |
| QwtPlot (QWidget *=nullptr) | |
| Constructor | |
| QwtPlot (const QwtText &title, QWidget *=nullptr) | |
| void | setAutoReplot (bool=true) |
| Set or reset the autoReplot option | |
| bool | autoReplot () const |
| Check if autoReplot option is enabled | |
| QString | plotId () const |
| Plot ID | |
| void | setPlotId (const QString &id) |
| void | setPlotLayout (QwtPlotLayout *) |
| Assign a new plot layout | |
| QwtPlotLayout * | plotLayout () |
| Get the plot's layout | |
| const QwtPlotLayout * | plotLayout () const |
| Get the plot's layout | |
| void | setTitle (const QString &) |
| Change the plot's title | |
| void | setTitle (const QwtText &) |
| Change the plot's title | |
| QwtText | title () const |
| Get the plot's title | |
| QwtTextLabel * | titleLabel () |
| Get the title label widget | |
| const QwtTextLabel * | titleLabel () const |
| Get the title label widget | |
| void | setFooter (const QString &) |
| Change the footer text | |
| void | setFooter (const QwtText &) |
| Change the footer text | |
| QwtText | footer () const |
| Get the footer text | |
| QwtTextLabel * | footerLabel () |
| Get the footer label widget | |
| const QwtTextLabel * | footerLabel () const |
| Get the footer label widget | |
| void | setCanvas (QWidget *) |
| Set the drawing canvas of the plot widget | |
| QWidget * | canvas () |
| Get the plot's canvas | |
| const QWidget * | canvas () const |
| Get the plot's canvas | |
| void | setCanvasBackground (const QBrush &) |
| Change the background of the plotting area | |
| QBrush | canvasBackground () const |
| Nothing else than: canvas()->palette().brush(
QPalette::Normal, QPalette::Window); | |
| void | setColorCycle (const QwtColorCycle &) |
| Set the color cycle used for automatic item coloring | |
| QwtColorCycle | colorCycle () const |
| Get the current color cycle | |
| QColor | nextColorForItem (int rtti) |
| Get the next auto-assigned color for a plot item type | |
| virtual QwtScaleMap | canvasMap (QwtAxisId) const |
| double | invTransform (QwtAxisId, double pos) const |
| Transform the x or y coordinate of a position in the drawing region into a value. | |
| double | transform (QwtAxisId, double value) const |
| Transform a value into a coordinate in the plotting region | |
| bool | isAxisValid (QwtAxisId) const |
| Checks if an axis is valid | |
| void | setAxisVisible (QwtAxisId, bool on=true) |
| Hide or show a specified axis | |
| bool | isAxisVisible (QwtAxisId) const |
| Return whether the specified axis is visible | |
| QwtScaleEngine * | axisScaleEngine (QwtAxisId) |
| Return the scale engine for a specific axis | |
| const QwtScaleEngine * | axisScaleEngine (QwtAxisId) const |
| Return the scale engine for a specific axis (const overload) | |
| void | setAxisScaleEngine (QwtAxisId, QwtScaleEngine *) |
| Change the scale engine for an axis | |
| void | setAxisAutoScale (QwtAxisId, bool on=true) |
| Enable autoscaling for a specified axis | |
| bool | axisAutoScale (QwtAxisId) const |
| Return whether autoscaling is enabled | |
| void | setAxisFont (QwtAxisId, const QFont &) |
| Change the font of an axis | |
| QFont | axisFont (QwtAxisId) const |
| Return the font of the scale labels for a specified axis | |
| void | setAxisScale (QwtAxisId, double min, double max, double stepSize=0) |
| Disable autoscaling and specify a fixed scale for a selected axis | |
| void | setAxisScaleDiv (QwtAxisId, const QwtScaleDiv &) |
| Disable autoscaling and specify a fixed scale for a selected axis. | |
| void | setAxisScaleDraw (QwtAxisId, QwtScaleDraw *) |
| Set a scale draw | |
| double | axisStepSize (QwtAxisId) const |
| Return the step size parameter that has been set in setAxisScale. | |
| QwtInterval | axisInterval (QwtAxisId) const |
| Return the current interval of the specified axis | |
| const QwtScaleDiv & | axisScaleDiv (QwtAxisId) const |
| Return the scale division of a specified axis | |
| const QwtScaleDraw * | axisScaleDraw (QwtAxisId) const |
| Return the scale draw of a specified axis | |
| QwtScaleDraw * | axisScaleDraw (QwtAxisId) |
| Return the scale draw of a specified axis | |
| const QwtScaleWidget * | axisWidget (QwtAxisId) const |
| Return the scale widget of the specified axis | |
| QwtScaleWidget * | axisWidget (QwtAxisId) |
| Return the scale widget of the specified axis | |
| QwtAxisId | visibleXAxisId () const |
| Return the currently visible X axis | |
| QwtAxisId | visibleYAxisId () const |
| Return the currently usable Y axis | |
| void | setAxisLabelAlignment (QwtAxisId, Qt::Alignment) |
| Change the alignment of the tick labels | |
| void | setAxisLabelRotation (QwtAxisId, double rotation) |
| Rotate all tick labels | |
| void | setAxisTitle (QwtAxisId, const QString &) |
| Change the title of a specified axis | |
| void | setAxisTitle (QwtAxisId, const QwtText &) |
| Change the title of a specified axis | |
| QwtText | axisTitle (QwtAxisId) const |
| Get the title of a specified axis | |
| void | setAxisMaxMinor (QwtAxisId, int maxMinor) |
| Set the maximum number of minor scale intervals for a specified axis | |
| int | axisMaxMinor (QwtAxisId) const |
| Return the maximum number of minor ticks for a specified axis | |
| void | setAxisMaxMajor (QwtAxisId, int maxMajor) |
| Set the maximum number of major scale intervals for a specified axis | |
| int | axisMaxMajor (QwtAxisId) const |
| Return the maximum number of major ticks for a specified axis | |
| void | setAxisTickDirection (QwtAxisId axisId, TickDirection direction) |
| Set the tick direction for an axis | |
| TickDirection | axisTickDirection (QwtAxisId axisId) const |
| Get the tick direction for an axis | |
| void | insertLegend (QwtAbstractLegend *, LegendPosition=QwtPlot::RightLegend, double ratio=-1.0) |
| Insert a legend | |
| QwtAbstractLegend * | legend () |
| Get the plot's legend | |
| const QwtAbstractLegend * | legend () const |
| Get the plot's legend | |
| void | updateLegend () |
| Emit legendDataChanged() for all plot item | |
| void | updateLegend (const QwtPlotItem *) |
| Emit legendDataChanged() for a plot item | |
| virtual QSize | sizeHint () const override |
| virtual QSize | minimumSizeHint () const override |
| Return a minimum size hint | |
| virtual void | updateLayout () |
| Adjust plot content to its current size. | |
| virtual void | drawCanvas (QPainter *) |
| Redraw the canvas. | |
| void | updateAxes () |
| Rebuild the axes scales | |
| void | updateCanvasMargins () |
| Update the canvas margins | |
| virtual void | getCanvasMarginsHint (const QwtScaleMap maps[], const QRectF &canvasRect, double &left, double &top, double &right, double &bottom) const |
| Calculate the canvas margins | |
| virtual bool | event (QEvent *) override |
| Adds handling of layout requests | |
| virtual bool | eventFilter (QObject *, QEvent *) override |
| Event filter | |
| virtual void | drawItems (QPainter *, const QRectF &, const QwtScaleMap maps[QwtAxis::AxisPositions]) const |
| Redraw the canvas items. | |
| virtual QVariant | itemToInfo (QwtPlotItem *) const |
| Build an information, that can be used to identify a plot item on the legend. | |
| virtual QwtPlotItem * | infoToItem (const QVariant &) const |
| Identify the plot item according to an item info object, that has bee generated from itemToInfo(). | |
| QwtPlot * | createParasitePlot (QwtAxis::Position enableAxis) |
| Create parasite axes for this plot | |
| void | setParasiteShareAxis (QwtAxisId axisId, bool isShare=true) |
| Set whether the parasite axis shares the host's specified axis, only valid for parasite axes | |
| bool | isParasiteShareAxis (QwtAxisId axisId) const |
| Query whether the parasite axis shares the host's specified axis | |
| void | removeParasitePlot (QwtPlot *parasite) |
| Remove a parasite plot from this host plot | |
| QList< QwtPlot * > | parasitePlots () const |
| Get all parasite plots associated with this host plot | |
| QList< QwtPlot * > | plotList (bool descending=false) const |
| Return all plots, including the host plot | |
| QwtPlot * | parasitePlotAt (int index) const |
| Get the nth parasite plot | |
| int | parasitePlotIndex (QwtPlot *parasite) const |
| Parasite plot index (level) | |
| QwtPlot * | hostPlot () const |
| Get the host plot for this parasite plot | |
| bool | isParasitePlot () const |
| Check if this plot is a parasite plot | |
| bool | isTopParasitePlot () const |
| Whether this is the topmost parasite plot; the topmost parasite's axes are at the outermost layer and are typically updated last | |
| bool | isHostPlot () const |
| Check if this plot is a host plot | |
| void | setBackgroundColor (const QColor &c) |
| Set background color | |
| QColor | backgroundColor () const |
| Get background color | |
| void | syncAxis (QwtAxisId axis, const QwtPlot *plot) |
| Synchronize the axis ranges from the given plot to this plot | |
| void | rescaleAxes (bool onlyVisibleItems=true, double marginPercent=0.05, QwtAxisId xAxis=QwtPlot::xBottom, QwtAxisId yAxis=QwtPlot::yLeft) |
| Rescale axes to fit all data items | |
| void | setAxisToLogScale (QwtAxisId axisId) |
| Set the specified axis to logarithmic scale | |
| void | setAxisToDateTime (QwtAxisId axisId, Qt::TimeSpec timeSpec=Qt::LocalTime) |
| Set the specified axis to date-time scale | |
| void | setAxisToLinearScale (QwtAxisId axisId) |
| Restore the specified axis to linear scale | |
| void | alignToHost () |
| Align the parasite plot to the host plot | |
| int | parasitePlotCount () const |
| Get the number of parasite plots | |
| void | updateAxisEdgeMargin (QwtAxisId axisId) |
| Recalculate and assign edgeMargin and margin for all layers (host + parasite) axes based on level order | |
| void | updateAllAxisEdgeMargin () |
| Batch update edge offsets for all axis positions | |
| void | updateItemsToScaleDiv () |
| Update the scale range of all plot items to match the current axis scales. | |
| void | setEnableScaleBuildinActions (bool on) |
| Enable or disable built-in axis event actions | |
| bool | isEnableScaleBuildinActions () const |
| Check if built-in axis event actions are enabled | |
| void | setupScaleEventDispatcher (QwtPlotScaleEventDispatcher *dispatcher) |
| Install the axis event dispatcher | |
| void | saveAutoReplotState () |
| Save the current autoReplot state | |
| void | restoreAutoReplotState () |
| Restore the previously saved autoReplot state | |
| void | panAxis (QwtAxisId axisId, int deltaPixels) |
| Pan the specified axis by a given number of pixels | |
| void | panCanvas (const QPoint &offset) |
| Pan the entire canvas by a pixel offset | |
| void | zoomAxis (QwtAxisId axisId, double factor, const QPoint ¢erPosPixels) |
| Zoom the axis centered at the specified pixel position | |
| void | enableAxis (int axisId, bool on=true) |
| bool | axisEnabled (int axisId) const |
Public 成员函数 继承自 QwtPlotDict | |
| QwtPlotDict () | |
| Constructor | |
| void | setAutoDelete (bool) |
| Enable/disable auto deletion | |
| bool | autoDelete () const |
| Check if auto deletion is enabled | |
| const QwtPlotItemList & | itemList () const |
| Get the list of all attached plot items | |
| QwtPlotItemList | itemList (int rtti) const |
| Get the list of all attached plot items of a specific type | |
| void | detachItems (int rtti=QwtPlotItem::Rtti_PlotItem, bool autoDelete=true) |
| Detach items from the dictionary | |
Protected 成员函数 | |
| virtual void | resizeEvent (QResizeEvent *) override |
| Resize and update internal layout | |
| void | addParasitePlot (QwtPlot *parasite) |
| Add a parasite plot to this host plot | |
| void | initParasiteAxes (QwtPlot *parasitePlot) const |
| Initialize basic properties of the parasite axes | |
| void | doLayout () |
| Adjust plot content to its current size. | |
| void | drawInsideTicks (QPainter *, const QRectF &canvasRect, const QwtScaleMap maps[QwtAxis::AxisPositions]) const |
| Draw inside ticks for axes with TickInside direction | |
Protected 成员函数 继承自 QwtPlotDict | |
| void | insertItem (QwtPlotItem *) |
| Insert an item into the dictionary | |
| void | removeItem (QwtPlotItem *) |
| Remove an item from the dictionary | |
属性 | |
| QBrush | canvasBackground |
| bool | autoReplot |
友元 | |
| class | QwtFigure |
| class | QwtPlotItem |
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 explicitly set (QwtScaleDiv), or are calculated from the plot items, using algorithms (QwtScaleEngine) which can be configured separately for each axis.
The simpleplot example is a good starting point to see how to set up a plot widget.
Position of the legend, relative to the canvas
| 枚举值 | |
|---|---|
| LeftLegend | The legend will be left from the QwtAxis::YLeft axis The legend will be right from the QwtAxis::YRight axis |
| RightLegend | The legend will be below the footer |
| BottomLegend | The legend will be above the title |
Tick direction enum
Controls whether ticks are drawn inside or outside the canvas. When ticks are inside, they are drawn from the canvas edge toward the interior, while the backbone and labels remain outside.
| 枚举值 | |
|---|---|
| TickOutside | Ticks are drawn outside the canvas (default behavior) Ticks are drawn inside the canvas |
|
explicit |
|
protected |
Add a parasite plot to this host plot
This method establishes a parasite relationship where the specified plot will be treated as a parasite of this host plot. The parasite plot will automatically synchronize its geometry with the host plot.
| parasite | Pointer to the parasite QwtPlot |
|
slot |
Replots the plot if autoReplot() is enabled
This method is called internally when plot properties change and autoReplot is enabled.
| bool QwtPlot::autoReplot | ( | ) | const |
| bool QwtPlot::axisAutoScale | ( | QwtAxisId | axisId | ) | const |
Return whether autoscaling is enabled
| axisId | Axis ID |
true if autoscaling is enabled | QFont QwtPlot::axisFont | ( | QwtAxisId | axisId | ) | const |
Return the font of the scale labels for a specified axis
| axisId | Axis ID |
| QwtInterval QwtPlot::axisInterval | ( | QwtAxisId | axisId | ) | const |
Return the current interval of the specified axis
This is only a convenience function for axisScaleDiv( axisId )->interval();
| axisId | Axis ID |
| int QwtPlot::axisMaxMajor | ( | QwtAxisId | axisId | ) | const |
Return the maximum number of major ticks for a specified axis
| axisId | Axis ID |
| int QwtPlot::axisMaxMinor | ( | QwtAxisId | axisId | ) | const |
Return the maximum number of minor ticks for a specified axis
| axisId | Axis ID |
| const QwtScaleDiv & QwtPlot::axisScaleDiv | ( | QwtAxisId | 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 ID |
| QwtScaleDraw * QwtPlot::axisScaleDraw | ( | QwtAxisId | axisId | ) |
Return the scale draw of a specified axis
| axisId | Axis ID |
| const QwtScaleDraw * QwtPlot::axisScaleDraw | ( | QwtAxisId | axisId | ) | const |
Return the scale draw of a specified axis
| axisId | Axis ID |
| QwtScaleEngine * QwtPlot::axisScaleEngine | ( | QwtAxisId | axisId | ) |
Return the scale engine for a specific axis
| axisId | Axis ID |
| const QwtScaleEngine * QwtPlot::axisScaleEngine | ( | QwtAxisId | axisId | ) | const |
Return the scale engine for a specific axis (const overload)
| axisId | Axis ID |
| double QwtPlot::axisStepSize | ( | QwtAxisId | 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 ID |
| QwtPlot::TickDirection QwtPlot::axisTickDirection | ( | QwtAxisId | axisId | ) | const |
Get the tick direction for an axis
| axisId | Axis identifier |
| QwtText QwtPlot::axisTitle | ( | QwtAxisId | axisId | ) | const |
Get the title of a specified axis
| axisId | Axis ID |
| QwtScaleWidget * QwtPlot::axisWidget | ( | QwtAxisId | axisId | ) |
Return the scale widget of the specified axis
| axisId | Axis ID |
| const QwtScaleWidget * QwtPlot::axisWidget | ( | QwtAxisId | axisId | ) | const |
Return the scale widget of the specified axis
| axisId | Axis ID |
| QColor QwtPlot::backgroundColor | ( | ) | const |
Get background color
| QWidget * QwtPlot::canvas | ( | ) |
Get the plot's canvas
| const QWidget * QwtPlot::canvas | ( | ) | const |
Get the plot's canvas
| QBrush QwtPlot::canvasBackground | ( | ) | const |
Nothing else than: canvas()->palette().brush( QPalette::Normal, QPalette::Window);
|
virtual |
| axisId | Axis |
| QwtColorCycle QwtPlot::colorCycle | ( | ) | const |
| QwtPlot * QwtPlot::createParasitePlot | ( | QwtAxis::Position | enableAxis | ) |
Create parasite axes for this plot
This method creates a parasite axes that shares the same plotting area as the host plot but with independent axis scaling and labeling. The parasite axes will be positioned exactly on top of the host plot and will automatically synchronize its geometry.
| enableAxis | The axis position to enable on the parasite axes |
| nullptr | if hostPlot is invalid or not in the figure |
|
protected |
Adjust plot content to its current size.
The concrete implementation of updateLayout. Before version 7.0, there were no parasite axes. Since the size information of parasite axes fully references the host axes, during the updateLayout process, parasite axes should not perform any actions. Instead, after the host axis's updateLayout finishes, doLayout is executed for all parasite axes.
Therefore, all implementation of updateLayout is extracted into doLayout.
|
virtual |
Redraw the canvas.
| painter | Painter used for drawing |
|
protected |
Draw inside ticks for axes with TickInside direction
This method is called after drawItems() to draw tick marks that extend from the canvas edge toward the interior.
| painter | Painter |
| canvasRect | Canvas rectangle |
| maps | Scale maps for all axes |
|
virtual |
Redraw the canvas items.
| painter | Painter used for drawing |
| canvasRect | Bounding rectangle where to paint |
| maps | QwtAxis::AxisCount maps, mapping between plot and paint device coordinates |
|
overridevirtual |
Adds handling of layout requests
| event | Event |
|
overridevirtual |
Event filter
The plot handles the following events for the canvas:
| object | Object to be filtered |
| event | Event |
| QwtText QwtPlot::footer | ( | ) | const |
Get the footer text
| QwtTextLabel * QwtPlot::footerLabel | ( | ) |
Get the footer label widget
| const QwtTextLabel * QwtPlot::footerLabel | ( | ) | const |
Get the footer label widget
|
virtual |
Calculate the canvas margins
| maps | QwtAxis::AxisCount maps, mapping between plot and paint device coordinates |
| canvasRect | Bounding rectangle where to paint |
| left | Return parameter for the left margin |
| top | Return parameter for the top margin |
| right | Return parameter for the right margin |
| bottom | Return parameter for the bottom margin |
Plot items might indicate, that they need some extra space at the borders of the canvas by the QwtPlotItem::Margins flag.
| QwtPlot * QwtPlot::hostPlot | ( | ) | const |
Get the host plot for this parasite plot
This method returns the host plot of this parasite plot, or nullptr if this plot is not a parasite.
| nullptr | if this plot is not a parasite plot |
|
virtual |
Identify the plot item according to an item info object, that has bee generated from itemToInfo().
The default implementation simply tries to unwrap a QwtPlotItem pointer:
| itemInfo | Plot item |
|
protected |
Initialize basic properties of the parasite axes
| parasitePlot | The parasite plot to initialize |
| void QwtPlot::insertLegend | ( | QwtAbstractLegend * | 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.
insertLegend() will set the plot widget as parent for the legend. The legend will be deleted in the destructor of the plot or when another legend is inserted.
Legends, that are not inserted into the layout of the plot widget need to connect to the legendDataChanged() signal. Calling updateLegend() initiates this signal for an initial update. When the application code wants to implement its own layout this also needs to be done for rendering plots to a document ( see QwtPlotRenderer ).
| legend | Legend |
| pos | The legend's position. For top/left position the number of columns will be limited to 1, otherwise it will be set to unlimited. |
| ratio | Ratio between legend and the bounding rectangle of title, canvas and axes. The legend will be shrunk 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 | ( | QwtAxisId | axisId, |
| double | pos | ||
| ) | const |
Transform the x or y coordinate of a position in the drawing region into a value.
Transform the x or y coordinate of a position in the drawing region into a value.
| axisId | Axis ID |
| pos | position |
| bool QwtPlot::isAxisValid | ( | QwtAxisId | axisId | ) | const |
Checks if an axis is valid
| axisId | axis ID |
true if the specified axis exists, otherwise false | bool QwtPlot::isAxisVisible | ( | QwtAxisId | axisId | ) | const |
Return whether the specified axis is visible
| axisId | Axis ID |
true if the axis is visible | bool QwtPlot::isEnableScaleBuildinActions | ( | ) | const |
Check if built-in axis event actions are enabled
| bool QwtPlot::isHostPlot | ( | ) | const |
Check if this plot is a host plot
This method returns true if this plot has one or more parasite plots.
A plot is only considered a host if it holds parasite plots.
| bool QwtPlot::isParasitePlot | ( | ) | const |
Check if this plot is a parasite plot
This method returns true if this plot is a parasite of another plot.
| bool QwtPlot::isParasiteShareAxis | ( | QwtAxisId | axisId | ) | const |
Query whether the parasite axis shares the host's specified axis
| axisId | The axis ID to query |
| bool QwtPlot::isTopParasitePlot | ( | ) | const |
Whether this is the topmost parasite plot; the topmost parasite's axes are at the outermost layer and are typically updated last
|
signal |
A signal indicating that an item has been attached/detached
| plotItem | Plot item |
| on | Attached/Detached |
|
virtual |
Build an information, that can be used to identify a plot item on the legend.
The default implementation simply wraps the plot item into a QVariant object. When overloading itemToInfo() usually infoToItem() needs to reimplemeted too.
| plotItem | Plot item |
| QwtAbstractLegend * QwtPlot::legend | ( | ) |
| const QwtAbstractLegend * QwtPlot::legend | ( | ) | const |
|
signal |
A signal with the attributes how to update the legend entries for a plot item.
| itemInfo | Info about a plot item, built from itemToInfo() |
| data | Attributes of the entries (usually <= 1) for the plot item. |
| QColor QwtPlot::nextColorForItem | ( | int | rtti | ) |
Get the next auto-assigned color for a plot item type
Returns the next color from the color cycle for the given rtti type. Each rtti type maintains an independent counter, so curves and bar charts each start from the first palette color.
| rtti | The rtti value of the plot item (e.g. QwtPlotItem::Rtti_PlotCurve) |
| void QwtPlot::panAxis | ( | QwtAxisId | axisId, |
| int | deltaPixels | ||
| ) |
Pan the specified axis by a given number of pixels
| axisId | Axis ID (QwtPlot::xBottom, QwtPlot::yLeft, etc.) |
| deltaPixels | Number of pixels to move |
Positive values move right/down, negative values move left/up. For logarithmic axes, coordinate transformations are handled automatically.
| void QwtPlot::panCanvas | ( | const QPoint & | offset | ) |
Pan the entire canvas by a pixel offset
| offset | Pixel offset |
This method translates all axes (whether enabled or not) by the specified pixel offset, achieving a synchronized panning effect for the entire canvas. Horizontal direction: positive moves right, negative moves left Vertical direction: positive moves down, negative moves up
| QwtPlot * QwtPlot::parasitePlotAt | ( | int | index | ) | const |
Get the nth parasite plot
| index | Index |
|
signal |
Identify the relationship between the parasitic plot and its host plot
| parasitePlot | Parasite plot |
| on | When a parasitic plot is added, on = true. When the parasitic plot is removed, on = false. |
| int QwtPlot::parasitePlotCount | ( | ) | const |
Get the number of parasite plots
| int QwtPlot::parasitePlotIndex | ( | QwtPlot * | parasite | ) | const |
Parasite plot index (level)
The parasite level is determined by the order of addition. The first parasite added is at level 0, the second at level 1, and so on. The higher the level, the closer the axis is to the plot boundary.
| parasite | Parasite plot |
Get all parasite plots associated with this host plot
This method returns a list of all parasite plots that are associated with this host plot.
| QString QwtPlot::plotId | ( | ) | const |
Plot ID
The plot ID is provided to enable a Figure to identify individual plots during persistence.
For example, after saving a Figure in XML format, it is necessary to know which plots have established axis synchronization signals with which other plots, and which plot boundaries have been aligned. These tasks require locating specific plots, which can be achieved using the plot ID.
| QwtPlotLayout * QwtPlot::plotLayout | ( | ) |
Get the plot's layout
| const QwtPlotLayout * QwtPlot::plotLayout | ( | ) | const |
Get the plot's layout
Return all plots, including the host plot
descending=false: ascending order, host plot first, lower levels first. descending=true: descending order, host at the end.
| descending | Sort order |
| void QwtPlot::removeParasitePlot | ( | QwtPlot * | parasite | ) |
Remove a parasite plot from this host plot
This method removes the parasite relationship between this host plot and the specified plot.
| parasite | Pointer to the parasite QwtPlot to remove |
|
virtualslot |
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::rescaleAxes | ( | bool | onlyVisibleItems = true, |
| double | marginPercent = 0.05, |
||
| QwtAxisId | xAxis = QwtPlot::xBottom, |
||
| QwtAxisId | yAxis = QwtPlot::yLeft |
||
| ) |
Rescale axes to fit all data items
This function automatically adjusts the axis ranges to fit all visible data items in the plot. It calculates the bounding rectangle of all plot items and sets appropriate axis scales with optional margins.
| onlyVisibleItems | If true, only visible items are considered |
| marginPercent | Percentage of margin to add around the data range |
| xAxis | The x-axis to rescale (default: QwtPlot::xBottom) |
| yAxis | The y-axis to rescale (default: QwtPlot::yLeft) |
Basic usage:
Custom margin:
|
overrideprotectedvirtual |
Resize and update internal layout
| e | Resize event |
| 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 | ( | QwtAxisId | 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 ID |
| on | On/Off |
| void QwtPlot::setAxisFont | ( | QwtAxisId | axisId, |
| const QFont & | font | ||
| ) |
Change the font of an axis
| axisId | Axis ID |
| font | Font |
| void QwtPlot::setAxisLabelAlignment | ( | QwtAxisId | axisId, |
| Qt::Alignment | alignment | ||
| ) |
Change the alignment of the tick labels
| axisId | Axis ID |
| alignment | Or'd Qt::AlignmentFlags see <qnamespace.h> |
| void QwtPlot::setAxisLabelRotation | ( | QwtAxisId | axisId, |
| double | rotation | ||
| ) |
Rotate all tick labels
| axisId | Axis ID |
| rotation | Angle in degrees. When changing the label rotation, the label alignment might be adjusted too. |
| void QwtPlot::setAxisMaxMajor | ( | QwtAxisId | axisId, |
| int | maxMajor | ||
| ) |
Set the maximum number of major scale intervals for a specified axis
| axisId | Axis ID |
| maxMajor | Maximum number of major steps |
| void QwtPlot::setAxisMaxMinor | ( | QwtAxisId | axisId, |
| int | maxMinor | ||
| ) |
Set the maximum number of minor scale intervals for a specified axis
| axisId | Axis ID |
| maxMinor | Maximum number of minor steps |
| void QwtPlot::setAxisScale | ( | QwtAxisId | axisId, |
| double | min, | ||
| double | max, | ||
| double | stepSize = 0 |
||
| ) |
Disable autoscaling and specify a fixed scale for a selected axis
In updateAxes() the scale engine calculates a scale division from the specified parameters, that will be assigned to the scale widget. So updates of the scale widget usually happen delayed with the next replot.
| axisId | Axis ID |
| min | Minimum of the scale |
| max | Maximum of the scale |
| stepSize | Major step size. If step == 0, the step size is calculated automatically using the maxMajor setting. |
| void QwtPlot::setAxisScaleDiv | ( | QwtAxisId | axisId, |
| const QwtScaleDiv & | scaleDiv | ||
| ) |
Disable autoscaling and specify a fixed scale for a selected axis.
The scale division will be stored locally only until the next call of updateAxes(). So updates of the scale widget usually happen delayed with the next replot.
| axisId | Axis ID |
| scaleDiv | Scale division |
| void QwtPlot::setAxisScaleDraw | ( | QwtAxisId | axisId, |
| QwtScaleDraw * | scaleDraw | ||
| ) |
Set a scale draw
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 ).
| axisId | Axis ID |
| scaleDraw | Object responsible for drawing scales. |
| void QwtPlot::setAxisScaleEngine | ( | QwtAxisId | axisId, |
| QwtScaleEngine * | scaleEngine | ||
| ) |
Change the scale engine for an axis
| axisId | Axis ID |
| scaleEngine | Scale engine |
| void QwtPlot::setAxisTickDirection | ( | QwtAxisId | axisId, |
| TickDirection | direction | ||
| ) |
Set the tick direction for an axis
When set to TickInside, the tick marks are drawn from the canvas edge toward the interior. The outside tick component is disabled on the QwtScaleWidget, and inside ticks are drawn in drawCanvas.
| axisId | Axis identifier |
| direction | Tick direction (TickOutside or TickInside) |
| void QwtPlot::setAxisTitle | ( | QwtAxisId | axisId, |
| const QString & | title | ||
| ) |
Change the title of a specified axis
| axisId | Axis ID |
| title | axis title |
| void QwtPlot::setAxisTitle | ( | QwtAxisId | axisId, |
| const QwtText & | title | ||
| ) |
Change the title of a specified axis
| axisId | Axis ID |
| title | Axis title |
| void QwtPlot::setAxisToDateTime | ( | QwtAxisId | axisId, |
| Qt::TimeSpec | timeSpec = Qt::LocalTime |
||
| ) |
Set the specified axis to date-time scale
This method configures the axis to display date-time formatted labels using QwtDateScaleEngine and QwtDateScaleDraw. Data should be provided as milliseconds since epoch (QDateTime::toMSecsSinceEpoch).
| axisId | Axis identifier, e.g., QwtPlot::xBottom, QwtPlot::yLeft |
| timeSpec | Time zone specification, defaults to Qt::LocalTime |
| void QwtPlot::setAxisToLinearScale | ( | QwtAxisId | axisId | ) |
Restore the specified axis to linear scale
This method replaces the current scale engine and draw with default linear versions. Useful to revert from logarithmic or date-time scales.
| axisId | Axis identifier, e.g., QwtPlot::xBottom, QwtPlot::yLeft |
| void QwtPlot::setAxisToLogScale | ( | QwtAxisId | axisId | ) |
Set the specified axis to logarithmic scale
This method replaces the current scale engine of the axis with QwtLogScaleEngine, enabling logarithmic scaling. All data values must be greater than zero.
| axisId | Axis identifier, e.g., QwtPlot::xBottom, QwtPlot::yLeft |
| void QwtPlot::setAxisVisible | ( | QwtAxisId | axisId, |
| bool | on = true |
||
| ) |
Hide or show a specified axis
Curves, markers and other items can be attached to hidden axes, and transformation of screen coordinates into values works as normal.
Only QwtAxis::XBottom and QwtAxis::YLeft are enabled by default.
| axisId | Axis ID |
| on | true (visible) or false (hidden) |
| void QwtPlot::setBackgroundColor | ( | const QColor & | c | ) |
Set background color
| c | Color |
| void QwtPlot::setCanvas | ( | QWidget * | canvas | ) |
Set the drawing canvas of the plot widget
QwtPlot invokes methods of the canvas as meta methods ( see QMetaObject ). In opposite to using conventional C++ techniques like virtual methods they allow to use canvas implementations that are derived from QWidget or QGLWidget.
The following meta methods could be implemented:
The default canvas is a QwtPlotCanvas
| canvas | Canvas Widget |
| void QwtPlot::setCanvasBackground | ( | const QBrush & | brush | ) |
Change the background of the plotting area
Sets brush to QPalette::Window of all color groups of the palette of the canvas. Using canvas()->setPalette() is a more powerful way to set these colors.
| brush | New background brush |
| void QwtPlot::setColorCycle | ( | const QwtColorCycle & | colorCycle | ) |
Set the color cycle used for automatic item coloring
When plot items (curves, bar charts, etc.) are attached without a user-specified pen or brush, they automatically receive a color from this color cycle.
| colorCycle | Color cycle object |
| void QwtPlot::setEnableScaleBuildinActions | ( | bool | on | ) |
Enable or disable built-in axis event actions
Axis events are built-in event actions for axes, primarily including click-to-move-axis, mouse wheel zoom, etc.
| on | Enable state |
| void QwtPlot::setFooter | ( | const QString & | text | ) |
Change the footer text
| [in] | text | New text of the footer as a string |
| void QwtPlot::setFooter | ( | const QwtText & | text | ) |
Change the footer text
| [in] | text | New text of the footer as a QwtText |
| void QwtPlot::setParasiteShareAxis | ( | QwtAxisId | axisId, |
| bool | isShare = true |
||
| ) |
Set whether the parasite axis shares the host's specified axis, only valid for parasite axes
| axisId | The axis ID to share (e.g., QwtAxis::YLeft) |
| isShare | Whether to enable sharing |
| void QwtPlot::setPlotId | ( | const QString & | id | ) |
set the plot id.
| id |
| void QwtPlot::setPlotLayout | ( | QwtPlotLayout * | layout | ) |
| void QwtPlot::setTitle | ( | const QString & | title | ) |
Change the plot's title
| [in] | title | New title as a string |
| void QwtPlot::setTitle | ( | const QwtText & | title | ) |
Change the plot's title
| [in] | title | New title as a QwtText |
| void QwtPlot::setupScaleEventDispatcher | ( | QwtPlotScaleEventDispatcher * | dispatcher | ) |
Install the axis event dispatcher
| dispatcher | The event dispatcher to install |
|
overridevirtual |
| void QwtPlot::syncAxis | ( | QwtAxisId | axis, |
| const QwtPlot * | plot | ||
| ) |
Synchronize the axis ranges from the given plot to this plot
| axis | Axis ID |
| plot | Source plot to sync from |
| QwtText QwtPlot::title | ( | ) | const |
Get the plot's title
| QwtTextLabel * QwtPlot::titleLabel | ( | ) |
Get the title label widget
| const QwtTextLabel * QwtPlot::titleLabel | ( | ) | const |
Get the title label widget
| double QwtPlot::transform | ( | QwtAxisId | axisId, |
| double | value | ||
| ) | const |
Transform a value into a coordinate in the plotting region
| axisId | Axis ID |
| value | value |
| void QwtPlot::updateAllAxisEdgeMargin | ( | ) |
Batch update edge offsets for all axis positions
Sequentially calls updateAxisEdgeMargin(QwtAxisId) for all axis positions (YLeft, YRight, XBottom, XTop) of the current plot instance, automatically synchronizing edgeMargin and margin between the host and all parasite axes, ensuring no overlap between layers and proper alignment of plot areas in multi-axis scenarios.
Typical invocation timing:
| void QwtPlot::updateAxes | ( | ) |
Rebuild the axes scales
In case of autoscaling the boundaries of a scale are calculated from the bounding rectangles of all plot items, having the QwtPlotItem::AutoScale flag enabled ( QwtScaleEngine::autoScale() ). Then a scale division is calculated ( QwtScaleEngine::divideScale() ) and assigned to scale widget.
When the scale boundaries have been assigned with setAxisScale() a scale division is calculated ( QwtScaleEngine::divideScale() ) for this interval and assigned to the scale widget.
When the scale has been set explicitly by setAxisScaleDiv() the locally stored scale division gets assigned to the scale widget.
The scale widget indicates modifications by emitting a QwtScaleWidget::scaleDivChanged() signal.
updateAxes() is usually called by replot().
| void QwtPlot::updateAxisEdgeMargin | ( | QwtAxisId | axisId | ) |
Recalculate and assign edgeMargin and margin for all layers (host + parasite) axes based on level order
In the Qwt multi-axis system, a host plot can mount any number of parasite plots. Each parasite plot shares the same canvas position as the host but has its own independent axes. To avoid overlap between axis layers, two offsets need to be dynamically calculated for each axis:
Level rules defined here:
Calculation flow:
Notes:
| axisId | The axis ID to process |
| void QwtPlot::updateCanvasMargins | ( | ) |
Update the canvas margins
Plot items might indicate, that they need some extra space at the borders of the canvas by the QwtPlotItem::Margins flag.
| void QwtPlot::updateItemsToScaleDiv | ( | ) |
Update the scale range of all plot items to match the current axis scales.
This is typically called when axes change, forcing all plot items to update their ranges.
|
virtual |
Adjust plot content to its current size.
| void QwtPlot::updateLegend | ( | ) |
Emit legendDataChanged() for all plot item
| void QwtPlot::updateLegend | ( | const QwtPlotItem * | plotItem | ) |
Emit legendDataChanged() for a plot item
| plotItem | Plot item |
| QwtAxisId QwtPlot::visibleXAxisId | ( | ) | const |
Return the currently visible X axis
Selection policy (descending priority):
| QwtAxisId QwtPlot::visibleYAxisId | ( | ) | const |
Return the currently usable Y axis
Selection policy (descending priority):
| void QwtPlot::zoomAxis | ( | QwtAxisId | axisId, |
| double | factor, | ||
| const QPoint & | centerPosPixels | ||
| ) |
Zoom the axis centered at the specified pixel position
| axisId | Axis ID |
| factor | Zoom factor (>1 for zoom in, <1 for zoom out) |
| centerPosPixels | Pixel position of the zoom center (relative to canvas) |
Zoom principle: