|
QWT 7.0.1
|
A figure container for organizing Qwt plots with flexible layout options. More...
#include <qwt_figure.h>
Classes | |
| class | PrivateData |
Signals | |
| void | axesAdded (QwtPlot *newAxes) |
| Signal emitted when axes are added to the figure/当坐标轴添加到图形时发出的信号 | |
| void | axesRemoved (QwtPlot *removedAxes) |
| Signal emitted when axes are removed from the figure/当坐标轴从图形中移除时发出的信号 | |
| void | figureCleared () |
| Signal emitted when the figure is cleared/当图形被清除时发出的信号 | |
| void | currentAxesChanged (QwtPlot *current) |
| 当前激活的坐标系发生了改变的信号 | |
Public Member Functions | |
| QwtFigure (QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags()) | |
| Constructor. | |
| void | addWidget (QWidget *widget, qreal left, qreal top, qreal width, qreal height) |
| Add a widget with normalized coordinates/使用归一化坐标添加窗口 | |
| void | addWidget (QWidget *widget, int rowCnt, int colCnt, int row, int col, int rowSpan=1, int colSpan=1, qreal wspace=0.0, qreal hspace=0.0) |
| Add a widget by grid layout/添加窗口部件到网格布局 | |
| void | addAxes (QwtPlot *plot, const QRectF &rect) |
| Add a plot with normalized coordinates/使用归一化坐标添加绘图 | |
| void | addAxes (QwtPlot *plot, qreal left, qreal top, qreal width, qreal height) |
| Add a plot with normalized coordinates/使用归一化坐标添加绘图 | |
| void | addGridAxes (QwtPlot *plot, int rowCnt, int colCnt, int row, int col, int rowSpan=1, int colSpan=1, qreal wspace=0.0, qreal hspace=0.0) |
| Add a plot by grid layout/添加窗口部件到网格布局 | |
| void | setWidgetNormPos (QWidget *widget, const QRectF &rect) |
| 改变已经添加的窗口的位置占比,如果窗口还没添加,此函数无效 | |
| QList< QwtPlot * > | allAxes (bool byZOrder=false) const |
| Get all axes (plots) in the figure(not contain parasite axes)/获取图形中的所有坐标轴(绘图)(不包含寄生轴) | |
| bool | hasAxes () const |
| Check if the figure has any axes/检查图形是否有坐标轴 | |
| bool | hasAxes (QwtPlot *plot) const |
| Check if the figure has any axes/检查图形是否有坐标轴 | |
| void | removeAxes (QwtPlot *plot) |
| Remove a specific axes (plot) from the figure/从图形中移除特定的坐标轴(绘图) | |
| bool | takeAxes (QwtPlot *plot) |
| Take a specific axes (plot) from the figure without deleting it/从图形中取出特定的坐标轴(绘图)但不删除它 | |
| void | clear () |
| Clear all axes from the figure/清除图形中的所有坐标轴 | |
| QSize | getSizeInches () const |
| Get the size of the figure in inches/获取图形的英寸尺寸 | |
| void | setSizeInches (float width, float height) |
| Set the size of the figure in inches/设置图形的英寸尺寸 | |
| void | setSizeInches (const QSizeF &size) |
| Set the size of the figure in inches/设置图形的英寸尺寸 | |
| void | setFaceColor (const QColor &color) |
| Set the face color of the figure/设置图形的背景颜色 | |
| QColor | faceColor () const |
| Get the face color of the figure/获取图形的表面颜色 | |
| void | setFaceBrush (const QBrush &brush) |
| Set the face brush of the figure/设置图形的背景画刷 | |
| QBrush | faceBrush () const |
| Get the face brush of the figure/获取图形的表面画刷 | |
| void | setEdgeColor (const QColor &color) |
| Set the edge color of the figure/设置图形的边缘颜色 | |
| QColor | edgeColor () const |
| Get the edge color of the figure/获取图形的边缘颜色 | |
| void | setEdgeLineWidth (int width) |
| Set the edge line width of the figure/设置图形的边缘线宽 | |
| int | edgeLineWidth () const |
| Get the edge line width of the figure/获取图形的边缘线宽 | |
| QwtPlot * | createParasiteAxes (QwtPlot *hostPlot, QwtAxis::Position enableAxis) |
| Create parasite axes for a host plot/为宿主绘图创建寄生轴 | |
| QList< QwtPlot * > | getParasiteAxes (QwtPlot *hostPlot) const |
| Get all parasite axes for a host plot/获取宿主绘图的所有寄生轴 | |
| QPixmap | saveFig (int dpi=-1) const |
| Save the figure to a QPixmap with specified DPI/使用指定DPI将图形保存为QPixmap. | |
| QPixmap | saveFig (QSizeF &inchesSize) const |
| Save the figure to a QPixmap with specified size in inches/使用指定英寸尺寸将图形保存为QPixmap. | |
| bool | saveFig (const QString &filename, int dpi=-1) const |
| Save the figure to a file with specified DPI/使用指定DPI将图形保存到文件 | |
| void | setCurrentAxes (QwtPlot *plot) |
| Set the current axes (plot)/设置当前坐标轴(绘图) | |
| void | sca (QwtPlot *plot) |
| Set the current axes (plot)/设置当前坐标轴(绘图) | |
| QwtPlot * | currentAxes () const |
| Get the current axes (plot)/获取当前坐标轴(绘图) | |
| QwtPlot * | gca () const |
| Get the current axes (plot)/获取当前坐标轴(绘图) | |
| QRectF | axesNormRect (QwtPlot *plot) const |
| Get the normalized rectangle for a axes/获取坐标系的归一化矩形 | |
| QRectF | widgetNormRect (QWidget *w) const |
| Get the normalized rectangle for a widget/获取窗口的归一化矩形 | |
| QwtPlot * | plotUnderPos (const QPoint &pos) const |
| 获取在此坐标下的绘图,如果此坐标下没有,则返回nullptr,存在寄生轴情况只返回宿主轴 | |
| QRectF | calcNormRect (const QRect &geoRect) const |
| 通过真实的窗口坐标计算归一化坐标 | |
| QRect | calcActualRect (const QRectF &normRect) |
| 通过正则矩形计算真实矩形 | |
| void | replotAll () |
| 更新所有的绘图 | |
| void | addAxisAlignment (const QList< QwtPlot * > &plots, int axisId) |
| 添加轴对齐配置 | |
| bool | removeAxisAlignment (const QList< QwtPlot * > &plots, int axisId) |
| 移除指定的轴对齐配置 | |
| void | clearAxisAlignment () |
| 清除所有轴对齐配置 | |
| void | applyAllAxisAlignments (bool replot=true) |
| 应用所有轴对齐配置,对记录的plot和轴进行对齐 | |
| void | applyAlignmentsForAxis (int axisId) |
| 应用指定轴ID的所有对齐配置 | |
Static Public Member Functions | |
| static void | alignAxes (QList< QwtPlot * > plots, int axisId, bool update=true) |
| QwtPlot轴对齐函数 | |
Protected Member Functions | |
| void | paintEvent (QPaintEvent *event) override |
| void | resizeEvent (QResizeEvent *event) override |
A figure container for organizing Qwt plots with flexible layout options.
用于组织Qwt绘图的图形容器,提供灵活的布局选项
This class provides a figure-like container similar to matplotlib's Figure class, supporting both normalized coordinate positioning and grid layouts for Qwt plots. It uses Qt's standard top-left coordinate system for intuitive positioning.
此类提供类似于matplotlib的Figure类的图形容器,支持Qwt绘图的归一化坐标定位和网格布局。 它使用Qt的标准左上角坐标系,使定位更加直观。
| QwtFigure::QwtFigure | ( | QWidget * | parent = nullptr, |
| Qt::WindowFlags | f = Qt::WindowFlags() |
||
| ) |
Constructor.
构造函数
| parent | Parent widget / 父窗口部件 |
| f | Window flags / 窗口标志 |
| void QwtFigure::addAxes | ( | QwtPlot * | plot, |
| const QRectF & | rect | ||
| ) |
Add a plot with normalized coordinates/使用归一化坐标添加绘图
This method adds a QwtPlot to the figure using normalized coordinates in the range [0,1]. The coordinates are specified as [left, bottom, width, height].
此方法使用[0,1]范围内的归一化坐标将QwtPlot添加到图形中。 坐标指定为[左, 下, 宽, 高]。
| plot | QwtPlot to add / 要添加的QwtPlot |
| rect | Normalized coordinates [left, bottom, width, height] in range [0,1] 归一化坐标 [左, 下, 宽, 高],范围 [0,1] |
| void QwtFigure::addAxes | ( | QwtPlot * | plot, |
| qreal | left, | ||
| qreal | top, | ||
| qreal | width, | ||
| qreal | height | ||
| ) |
Add a plot with normalized coordinates/使用归一化坐标添加绘图
This method adds a QwtPlot to the figure using normalized coordinates in the range [0,1]. The coordinates are specified as [left, bottom, width, height].
| plot | QwtPlot to add / 要添加的QwtPlot |
| left | Normalized coordinates left in range [0,1] |
| top | Normalized coordinates top in range [0,1] |
| width | Normalized coordinates width in range [0,1] |
| height | Normalized coordinates height in range [0,1] |
添加轴对齐配置
| plots | 需要对齐的plot列表 |
| axisId | 要对齐的轴ID(QwtAxis::XTop/XBottom/YLeft/YRight) |
| void QwtFigure::addGridAxes | ( | QwtPlot * | plot, |
| int | rowCnt, | ||
| int | colCnt, | ||
| int | row, | ||
| int | col, | ||
| int | rowSpan = 1, |
||
| int | colSpan = 1, |
||
| qreal | wspace = 0.0, |
||
| qreal | hspace = 0.0 |
||
| ) |
Add a plot by grid layout/添加窗口部件到网格布局
This method adds a QwtPlot to the grid layout at the specified position with optional row and column spans.
此方法将QwtPlot添加到网格布局中的指定位置,可选择跨行和跨列。
| plot | QwtPlot to add / 要添加的QwtPlot |
| rowCnt | Number of rows in the grid / 网格行数 |
| colCnt | Number of columns in the grid / 网格列数 |
| row | Grid row position (0-based) / 网格行位置(从0开始) |
| col | Grid column position (0-based) / 网格列位置(从0开始) |
| rowSpan | Number of rows to span (default: 1) / 跨行数(默认:1) |
| colSpan | Number of columns to span (default: 1) / 跨列数(默认:1) |
| wspace | Horizontal space between subplots [0,1] / 子图之间的水平间距 [0,1] |
| hspace | Vertical space between subplots [0,1] / 子图之间的垂直间距 [0,1] |
| void QwtFigure::addWidget | ( | QWidget * | widget, |
| int | rowCnt, | ||
| int | colCnt, | ||
| int | row, | ||
| int | col, | ||
| int | rowSpan = 1, |
||
| int | colSpan = 1, |
||
| qreal | wspace = 0.0, |
||
| qreal | hspace = 0.0 |
||
| ) |
Add a widget by grid layout/添加窗口部件到网格布局
This method adds a widget to the grid layout at the specified position with optional row and column spans.
此方法将widget添加到网格布局中的指定位置,可选择跨行和跨列。
| plot | widget to add / 要添加的widget |
| rowCnt | Number of rows in the grid / 网格行数 |
| colCnt | Number of columns in the grid / 网格列数 |
| row | Grid row position (0-based) / 网格行位置(从0开始) |
| col | Grid column position (0-based) / 网格列位置(从0开始) |
| rowSpan | Number of rows to span (default: 1) / 跨行数(默认:1) |
| colSpan | Number of columns to span (default: 1) / 跨列数(默认:1) |
| wspace | Horizontal space between subplots [0,1] / 子图之间的水平间距 [0,1] |
| hspace | Vertical space between subplots [0,1] / 子图之间的垂直间距 [0,1] |
| void QwtFigure::addWidget | ( | QWidget * | widget, |
| qreal | left, | ||
| qreal | top, | ||
| qreal | width, | ||
| qreal | height | ||
| ) |
Add a widget with normalized coordinates/使用归一化坐标添加窗口
| widget | QWidget to add / 要添加的QWidget |
| left | Normalized coordinates left in range [0,1] |
| top | Normalized coordinates top in range [0,1] |
| width | Normalized coordinates width in range [0,1] |
| height | Normalized coordinates height in range [0,1] |
QwtPlot轴对齐函数
| plots | 待对齐的QwtPlot列表(非空) |
| axisId | 要对齐的轴ID(QwtAxis::XTop/XBottom/YLeft/YRight) |
Get all axes (plots) in the figure(not contain parasite axes)/获取图形中的所有坐标轴(绘图)(不包含寄生轴)
This method returns a list of all QwtPlot objects added to the figure.(not contain parasite axes)
此方法返回添加到图形中的所有QwtPlot对象的列表。(不包含寄生轴)
| byZOrder | 是否按zorder排序,如果按zorder排序,按按 z 序从高到低排序 |
| void QwtFigure::applyAlignmentsForAxis | ( | int | axisId | ) |
应用指定轴ID的所有对齐配置
| axisId | 轴ID |
|
signal |
Signal emitted when axes are added to the figure/当坐标轴添加到图形时发出的信号
| newAxes | Pointer to the newly added QwtPlot / 指向新添加的QwtPlot的指针 |
| QRectF QwtFigure::axesNormRect | ( | QwtPlot * | plot | ) | const |
Get the normalized rectangle for a axes/获取坐标系的归一化矩形
This method returns the normalized coordinates [0,1] for the specified axes in the figure. If the axes is not found in the figure, an invalid QRectF is returned.
此方法返回布局中指定坐标系的归一化坐标[0,1]。如果在绘图中未找到该坐标系,则返回无效的QRectF。
| widget | Widget to query / 要查询的坐标系 |
|
signal |
Signal emitted when axes are removed from the figure/当坐标轴从图形中移除时发出的信号
| removedAxes | Pointer to the removed QwtPlot / 指向被移除的QwtPlot的指针 |
| QRect QwtFigure::calcActualRect | ( | const QRectF & | normRect | ) |
通过正则矩形计算真实矩形
| normRect |
| QRectF QwtFigure::calcNormRect | ( | const QRect & | geoRect | ) | const |
通过真实的窗口坐标计算归一化坐标
| geoRect | 真实窗口坐标,就是子窗口的geometry() |
| void QwtFigure::clear | ( | ) |
Clear all axes from the figure/清除图形中的所有坐标轴
This method removes all QwtPlot objects from the figure and deletes them.
此方法从图形中移除所有QwtPlot对象并删除它们。
| QwtPlot * QwtFigure::createParasiteAxes | ( | QwtPlot * | hostPlot, |
| QwtAxis::Position | enableAxis | ||
| ) |
Create parasite axes for a host 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.
此方法创建一个寄生轴,它与宿主绘图共享相同的绘图区域,但具有独立的轴缩放和标签。 寄生轴将精确定位在宿主绘图之上,并自动同步其几何形状。
| hostPlot | Pointer to the host QwtPlot/指向宿主QwtPlot的指针 |
| enableAxis | The axis position to enable on the parasite axes/在寄生轴上启用的轴位置 |
| shareX | If true, share X-axis scale with host plot/如果为true,与宿主绘图共享X轴刻度 |
| shareY | If true, share Y-axis scale with host plot/如果为true,与宿主绘图共享Y轴刻度 |
| nullptr | if hostPlot is invalid or not in the figure/如果hostPlot无效或不在图形中则返回nullptr |
| QwtPlot * QwtFigure::currentAxes | ( | ) | const |
Get the current axes (plot)/获取当前坐标轴(绘图)
This method returns the current active QwtPlot in the figure. The current axes is typically the last axes that was added, modified, or plotted on.
此方法返回图形中当前活动的QwtPlot。 当前坐标轴通常是最后添加、修改或绘图的坐标轴。
|
signal |
当前激活的坐标系发生了改变的信号
| current |
| QColor QwtFigure::edgeColor | ( | ) | const |
Get the edge color of the figure/获取图形的边缘颜色
This method returns the border color of the figure.
此方法返回图形的边框颜色。
| int QwtFigure::edgeLineWidth | ( | ) | const |
Get the edge line width of the figure/获取图形的边缘线宽
This method returns the border line width of the figure.
此方法返回图形的边框线宽。
| QBrush QwtFigure::faceBrush | ( | ) | const |
Get the face brush of the figure/获取图形的表面画刷
This method returns the background brush of the figure.
此方法返回图形的背景画刷。
| QColor QwtFigure::faceColor | ( | ) | const |
Get the face color of the figure/获取图形的表面颜色
This method returns the background color of the figure.
此方法返回图形的背景颜色。
| QwtPlot * QwtFigure::gca | ( | ) | const |
Get the current axes (plot)/获取当前坐标轴(绘图)
Get all parasite axes for a host plot/获取宿主绘图的所有寄生轴
This method returns a list of all parasite axes associated with the specified host plot.
此方法返回与指定宿主绘图关联的所有寄生轴的列表。
| hostPlot | Pointer to the host QwtPlot/指向宿主QwtPlot的指针 |
| Empty | list if hostPlot is invalid or has no parasite axes/如果hostPlot无效或没有寄生轴则返回空列表 |
| QSize QwtFigure::getSizeInches | ( | ) | const |
Get the size of the figure in inches/获取图形的英寸尺寸
This method calculates the physical size of the figure in inches based on the current pixel size and screen DPI.
此方法基于当前像素尺寸和屏幕DPI计算图形的物理尺寸(英寸)。
| bool QwtFigure::hasAxes | ( | ) | const |
Check if the figure has any axes/检查图形是否有坐标轴
This method returns true if the figure contains at least one QwtPlot.
如果图形包含至少一个QwtPlot,则此方法返回true。
| bool QwtFigure::hasAxes | ( | QwtPlot * | plot | ) | const |
Check if the figure has any axes/检查图形是否有坐标轴
This method returns true if the figure contains at least one QwtPlot.
如果图形包含至少一个QwtPlot,则此方法返回true。
| plot | QwtPlot to check / 要检测的QwtPlot |
| QwtPlot * QwtFigure::plotUnderPos | ( | const QPoint & | pos | ) | const |
获取在此坐标下的绘图,如果此坐标下没有,则返回nullptr,存在寄生轴情况只返回宿主轴
| pos | 坐标 |
| void QwtFigure::removeAxes | ( | QwtPlot * | plot | ) |
Remove a specific axes (plot) from the figure/从图形中移除特定的坐标轴(绘图)
This method removes the specified QwtPlot from the figure.
此方法从图形中移除指定的QwtPlot。
| plot | QwtPlot to remove / 要移除的QwtPlot |
移除指定的轴对齐配置
| plots | 需要移除的对齐配置中的plot列表 |
| axisId | 要移除的对齐配置中的轴ID |
| bool QwtFigure::saveFig | ( | const QString & | filename, |
| int | dpi = -1 |
||
| ) | const |
Save the figure to a file with specified DPI/使用指定DPI将图形保存到文件
This method saves the figure to an image file with the specified DPI.
此方法将图形保存为具有指定DPI的图像文件。
| filename | Name of the file to save / 要保存的文件名 |
| dpi | Dots per inch for the saved image (-1 to use screen DPI) / 保存图像的DPI(-1表示使用屏幕DPI) |
| QPixmap QwtFigure::saveFig | ( | int | dpi = -1 | ) | const |
Save the figure to a QPixmap with specified DPI/使用指定DPI将图形保存为QPixmap.
This method renders the figure to a QPixmap with the specified DPI. If DPI is -1, the current screen DPI is used.
此方法将图形渲染为具有指定DPI的QPixmap。 如果DPI为-1,则使用当前屏幕DPI。
| dpi | Dots per inch for the saved image (-1 to use screen DPI) / 保存图像的DPI(-1表示使用屏幕DPI) |
| QPixmap QwtFigure::saveFig | ( | QSizeF & | inchesSize | ) | const |
Save the figure to a QPixmap with specified size in inches/使用指定英寸尺寸将图形保存为QPixmap.
This method renders the figure to a QPixmap with the specified physical size in inches. The current DPI setting of the figure is used to calculate the pixel size.
此方法将图形渲染为具有指定物理尺寸(英寸)的QPixmap。 使用图形当前的DPI设置来计算像素尺寸。
| inchesSize | Physical size in inches / 物理尺寸(英寸) |
| void QwtFigure::sca | ( | QwtPlot * | plot | ) |
Set the current axes (plot)/设置当前坐标轴(绘图)
| plot | QwtPlot to set as current / 要设置为当前的QwtPlot |
| void QwtFigure::setCurrentAxes | ( | QwtPlot * | plot | ) |
Set the current axes (plot)/设置当前坐标轴(绘图)
This method sets the specified QwtPlot as the current active axes in the figure.
此方法将指定的QwtPlot设置为图形中当前活动的坐标轴。
| plot | QwtPlot to set as current / 要设置为当前的QwtPlot |
| void QwtFigure::setEdgeColor | ( | const QColor & | color | ) |
Set the edge color of the figure/设置图形的边缘颜色
This method sets the border color of the figure.
此方法设置图形的边框颜色。
| color | Border color / 边框颜色 |
| void QwtFigure::setEdgeLineWidth | ( | int | width | ) |
Set the edge line width of the figure/设置图形的边缘线宽
This method sets the border line width of the figure.
此方法设置图形的边框线宽。
| width | Border line width in pixels / 边框线宽(像素) |
| void QwtFigure::setFaceBrush | ( | const QBrush & | brush | ) |
Set the face brush of the figure/设置图形的背景画刷
This method sets the background brush of the figure, allowing for more complex backgrounds (gradients, textures, etc.).
此方法设置图形的背景画刷,允许更复杂的背景(渐变、纹理等)。
| brush | Background brush / 背景画刷 |
| void QwtFigure::setFaceColor | ( | const QColor & | color | ) |
Set the face color of the figure/设置图形的背景颜色
This method sets the background color of the figure.
此方法设置图形的背景颜色。
| color | Background color / 背景颜色 |
| void QwtFigure::setSizeInches | ( | const QSizeF & | size | ) |
Set the size of the figure in inches/设置图形的英寸尺寸
This method sets the size of the figure in inches, converting to pixels based on the screen DPI.
此方法设置图形的英寸尺寸,基于屏幕DPI转换为像素。
| size | Size in inches / 英寸尺寸 |
| void QwtFigure::setSizeInches | ( | float | width, |
| float | height | ||
| ) |
Set the size of the figure in inches/设置图形的英寸尺寸
This method sets the size of the figure in inches, converting to pixels based on the screen DPI.
此方法设置图形的英寸尺寸,基于屏幕DPI转换为像素。
| width | Width in inches / 宽度(英寸) |
| height | Height in inches / 高度(英寸) |
| void QwtFigure::setWidgetNormPos | ( | QWidget * | widget, |
| const QRectF & | rect | ||
| ) |
改变已经添加的窗口的位置占比,如果窗口还没添加,此函数无效
| widget | |
| rect |
| bool QwtFigure::takeAxes | ( | QwtPlot * | plot | ) |
Take a specific axes (plot) from the figure without deleting it/从图形中取出特定的坐标轴(绘图)但不删除它
| plot | Pointer to the QwtPlot to take / 要取出的QwtPlot指针 |
| QRectF QwtFigure::widgetNormRect | ( | QWidget * | w | ) | const |
Get the normalized rectangle for a widget/获取窗口的归一化矩形
This method returns the normalized coordinates [0,1] for the specified axes in the figure. If the widget is not found in the figure, an invalid QRectF is returned.
此方法返回布局中指定坐标系的归一化坐标[0,1]。如果在绘图中未找到该窗口,则返回无效的QRectF。
| widget | Widget to query / 要查询的窗口 |