QWT 7.0.1
Loading...
Searching...
No Matches
Classes | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
QwtFigure Class Reference

A figure container for organizing Qwt plots with flexible layout options. More...

#include <qwt_figure.h>

Inheritance diagram for QwtFigure:

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/获取图形的边缘线宽
 
QwtPlotcreateParasiteAxes (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)/设置当前坐标轴(绘图)
 
QwtPlotcurrentAxes () const
 Get the current axes (plot)/获取当前坐标轴(绘图)
 
QwtPlotgca () 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/获取窗口的归一化矩形
 
QwtPlotplotUnderPos (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
 

Detailed Description

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的标准左上角坐标系,使定位更加直观。

// Example usage:
// 使用示例:
QwtFigure figure;
// Add a plot using normalized coordinates (Qt top-left coordinate system)
// 使用归一化坐标添加绘图(Qt左上角坐标系)
QwtPlot* plot1 = new QwtPlot;
figure.addAxes(plot1, QRectF(0.1, 0.1, 0.8, 0.4)); // Left: 10%, Top: 10%, Width: 80%, Height: 40%
// Add plots using grid layout
// 使用网格布局添加绘图
// Create a 2x2 grid:
// 创建2x2网格:
// +-------------------+-------------------+
// | | |
// | (0,0) | (0,1) |
// | | |
// +-------------------+-------------------+
// | | |
// | (1,0) | (1,1) |
// | | |
// +-------------------+-------------------+
QwtPlot* plot2 = new QwtPlot;
figure.addAxes(plot2, 2, 2, 0, 1); // 2x2 grid, row 0, column 1
// Result:
// 结果:
// +-------------------+-------------------+
// | | |
// | | plot2 |
// | | |
// +-------------------+-------------------+
// | | |
// | | |
// | | |
// +-------------------+-------------------+
QwtPlot* plot3 = new QwtPlot;
figure.addAxes(plot3, 2, 2, 1, 0, 1, 2); // 2x2 grid, row 1, columns 0-1 (span 2 columns)
// Result:
// 结果:
// +-------------------+-------------------+
// | | |
// | | plot2 |
// | | |
// +---------------------------------------+
// | |
// | plot3 (span 2 cols) |
// | |
// +---------------------------------------+
// Adjust layout parameters
// 调整布局参数
figure.adjustLayout(0.1, 0.1, 0.9, 0.9, 0.2, 0.2);
// Save the figure
// 保存图形
figure.saveFig("output.png", 300);
A figure container for organizing Qwt plots with flexible layout options.
Definition qwt_figure.h:90
QPixmap saveFig(int dpi=-1) const
Save the figure to a QPixmap with specified DPI/使用指定DPI将图形保存为QPixmap.
Definition qwt_figure.cpp:880
void addAxes(QwtPlot *plot, const QRectF &rect)
Add a plot with normalized coordinates/使用归一化坐标添加绘图
Definition qwt_figure.cpp:162
A 2-D plotting widget.
Definition qwt_plot.h:99

Constructor & Destructor Documentation

◆ QwtFigure()

QwtFigure::QwtFigure ( QWidget *  parent = nullptr,
Qt::WindowFlags  f = Qt::WindowFlags() 
)

Constructor.

构造函数

Parameters
parentParent widget / 父窗口部件
fWindow flags / 窗口标志

Member Function Documentation

◆ addAxes() [1/2]

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添加到图形中。 坐标指定为[左, 下, 宽, 高]。

Parameters
plotQwtPlot to add / 要添加的QwtPlot
rectNormalized coordinates [left, bottom, width, height] in range [0,1] 归一化坐标 [左, 下, 宽, 高],范围 [0,1]
// Add a plot that occupies the top-left quarter of the figure
// 添加一个占据图形左上角四分之一的绘图
QwtPlot* plot = new QwtPlot;
figure.addAxes(plot, QRectF(0.0, 0.5, 0.5, 0.5));
Note
此函数会发射axesAdded 信号,此信号发射后发射currentAxesChanged 信号

◆ addAxes() [2/2]

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].

Parameters
plotQwtPlot to add / 要添加的QwtPlot
leftNormalized coordinates left in range [0,1]
topNormalized coordinates top in range [0,1]
widthNormalized coordinates width in range [0,1]
heightNormalized coordinates height in range [0,1]
Note
此函数会发射axesAdded 信号,此信号发射后发射currentAxesChanged 信号

◆ addAxisAlignment()

void QwtFigure::addAxisAlignment ( const QList< QwtPlot * > &  plots,
int  axisId 
)

添加轴对齐配置

Parameters
plots需要对齐的plot列表
axisId要对齐的轴ID(QwtAxis::XTop/XBottom/YLeft/YRight)

◆ addGridAxes()

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添加到网格布局中的指定位置,可选择跨行和跨列。

Parameters
plotQwtPlot to add / 要添加的QwtPlot
rowCntNumber of rows in the grid / 网格行数
colCntNumber of columns in the grid / 网格列数
rowGrid row position (0-based) / 网格行位置(从0开始)
colGrid column position (0-based) / 网格列位置(从0开始)
rowSpanNumber of rows to span (default: 1) / 跨行数(默认:1)
colSpanNumber of columns to span (default: 1) / 跨列数(默认:1)
wspaceHorizontal space between subplots [0,1] / 子图之间的水平间距 [0,1]
hspaceVertical space between subplots [0,1] / 子图之间的垂直间距 [0,1]
// Create a 2x2 grid and add plots
// 创建一个2x2网格并添加绘图
// Add a plot that spans the entire top row (row 0, columns 0-1)
// 添加一个占据整个顶行(第0行,第0-1列)的绘图
QwtPlot* topPlot = new QwtPlot;
figure.addAxes(topPlot, 2, 2, 0, 0, 1, 2);
// Add a plot to the bottom-left cell (row 1, column 0)
// 添加一个到底部左侧单元格(第1行,第0列)的绘图
QwtPlot* bottomLeftPlot = new QwtPlot;
figure.addAxes(bottomLeftPlot, 2, 2, 1, 0);
Note
此函数会发射axesAdded 信号,此信号发射后发射currentAxesChanged 信号

◆ addWidget() [1/2]

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添加到网格布局中的指定位置,可选择跨行和跨列。

Parameters
plotwidget to add / 要添加的widget
rowCntNumber of rows in the grid / 网格行数
colCntNumber of columns in the grid / 网格列数
rowGrid row position (0-based) / 网格行位置(从0开始)
colGrid column position (0-based) / 网格列位置(从0开始)
rowSpanNumber of rows to span (default: 1) / 跨行数(默认:1)
colSpanNumber of columns to span (default: 1) / 跨列数(默认:1)
wspaceHorizontal space between subplots [0,1] / 子图之间的水平间距 [0,1]
hspaceVertical space between subplots [0,1] / 子图之间的垂直间距 [0,1]
Note
即使添加的窗口是qwtplot,此函数也不会发射axesAdded 信号,因此,如果你需要添加QwtPlot窗口, 你应该使用addAxes 函数,此函数是为了在figure窗口添加除QwtPlot以外的窗口使用的
See also
addAxes

◆ addWidget() [2/2]

void QwtFigure::addWidget ( QWidget *  widget,
qreal  left,
qreal  top,
qreal  width,
qreal  height 
)

Add a widget with normalized coordinates/使用归一化坐标添加窗口

Parameters
widgetQWidget to add / 要添加的QWidget
leftNormalized coordinates left in range [0,1]
topNormalized coordinates top in range [0,1]
widthNormalized coordinates width in range [0,1]
heightNormalized coordinates height in range [0,1]
Note
即使添加的窗口是qwtplot,此函数也不会发射axesAdded 信号,因此,如果你需要添加QwtPlot窗口, 你应该使用addAxes 函数,此函数是为了在figure窗口添加除QwtPlot以外的窗口使用的
See also
addAxes

◆ alignAxes()

void QwtFigure::alignAxes ( QList< QwtPlot * >  plots,
int  axisId,
bool  update = true 
)
static

QwtPlot轴对齐函数

Parameters
plots待对齐的QwtPlot列表(非空)
axisId要对齐的轴ID(QwtAxis::XTop/XBottom/YLeft/YRight)
Note
1. 函数会统一指定轴的minimumExtent和minBorderDist,确保轴视觉对齐;
  1. 需在控件初始化完成后调用(如showEvent/resizeEvent中);
  2. 支持任意数量Plot、任意合法轴类型,适配水平/垂直布局。
  3. 不要传入寄生轴,目前仅支持宿主轴

◆ allAxes()

QList< QwtPlot * > QwtFigure::allAxes ( bool  byZOrder = false) const

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对象的列表。(不包含寄生轴)

Parameters
byZOrder是否按zorder排序,如果按zorder排序,按按 z 序从高到低排序
Returns
List of all QwtPlot objects / 所有QwtPlot对象的列表(不包含寄生轴)
Note
此方法获取的绘图不包含寄生轴
// Get all plots and update their titles
// 获取所有绘图并更新它们的标题
QList<QwtPlot*> plots = figure.allAxes();
for (int i = 0; i < plots.size(); ++i) {
plots[i]->setTitle(QString("Plot %1").arg(i + 1));
}
Definition qwt_dyngrid_layout.h:33

◆ applyAlignmentsForAxis()

void QwtFigure::applyAlignmentsForAxis ( int  axisId)

应用指定轴ID的所有对齐配置

Parameters
axisId轴ID

◆ axesAdded

void QwtFigure::axesAdded ( QwtPlot newAxes)
signal

Signal emitted when axes are added to the figure/当坐标轴添加到图形时发出的信号

Parameters
newAxesPointer to the newly added QwtPlot / 指向新添加的QwtPlot的指针
Note
寄生轴的添加也会触发此信号

◆ axesNormRect()

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。

Parameters
widgetWidget to query / 要查询的坐标系
Returns
Normalized coordinates [left, top, width, height] in range [0,1], or invalid QRectF if not found 归一化坐标 [左, 上, 宽, 高],范围 [0,1],如果未找到则返回无效QRectF
// Get the normalized position of a widget
// 获取窗口部件的归一化位置
QRectF normRect = figure->axesNormRect(plot);
if (normRect.isValid()) {
qDebug() << "axes position:" << normRect;
} else {
qDebug() << "axes not found in figure";
}

◆ axesRemoved

void QwtFigure::axesRemoved ( QwtPlot removedAxes)
signal

Signal emitted when axes are removed from the figure/当坐标轴从图形中移除时发出的信号

Parameters
removedAxesPointer to the removed QwtPlot / 指向被移除的QwtPlot的指针
Note
寄生轴的移除也会触发此信号

◆ calcActualRect()

QRect QwtFigure::calcActualRect ( const QRectF &  normRect)

通过正则矩形计算真实矩形

Parameters
normRect
Returns

◆ calcNormRect()

QRectF QwtFigure::calcNormRect ( const QRect &  geoRect) const

通过真实的窗口坐标计算归一化坐标

Parameters
geoRect真实窗口坐标,就是子窗口的geometry()
Returns

◆ clear()

void QwtFigure::clear ( )

Clear all axes from the figure/清除图形中的所有坐标轴

This method removes all QwtPlot objects from the figure and deletes them.

此方法从图形中移除所有QwtPlot对象并删除它们。

Note
此方法在移除过程中会发射axesRemoved 信号, axesRemoved携带的绘图指针不应该被保存
此方法还会发射2个信号,先发射currentAxesChanged 信号,此信号参数会携带nullptr, 最后发射figureCleared 信号
此方法会删除已经持有的所有plot窗口
// Clear all plots from the figure
// 清除图形中的所有绘图
figure.clear();

◆ createParasiteAxes()

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.

此方法创建一个寄生轴,它与宿主绘图共享相同的绘图区域,但具有独立的轴缩放和标签。 寄生轴将精确定位在宿主绘图之上,并自动同步其几何形状。

Parameters
hostPlotPointer to the host QwtPlot/指向宿主QwtPlot的指针
enableAxisThe axis position to enable on the parasite axes/在寄生轴上启用的轴位置
shareXIf true, share X-axis scale with host plot/如果为true,与宿主绘图共享X轴刻度
shareYIf true, share Y-axis scale with host plot/如果为true,与宿主绘图共享Y轴刻度
Returns
Pointer to the created parasite QwtPlot/指向创建的寄生QwtPlot的指针
Return values
nullptrif hostPlot is invalid or not in the figure/如果hostPlot无效或不在图形中则返回nullptr
Note
The parasite axes will have a transparent background and only the specified axis will be visible. /寄生轴将具有透明背景,只有指定的轴可见。
The parasite axes will automatically be deleted when the host plot is removed from the figure. /当宿主绘图从图形中移除时,寄生轴将自动被删除。
Parasitic axes are not stored in QwtFigureLayout, but are separately controlled by QwtFigure for layout management /寄生轴不会存入QwtFigureLayout中,单独由QwtFigure进行布局控制
// Create a host plot
// 创建宿主绘图
QwtPlot* hostPlot = new QwtPlot(figure);
figure->addAxes(hostPlot, 0.1, 0.1, 0.8, 0.8);
// Create parasite axes with YRight axis enabled and sharing Y-axis scale
// 创建寄生轴,启用YRight轴并共享X轴刻度
QwtPlot* parasiteYRight = figure->createParasiteAxes(hostPlot, QwtAxis::YRight, true, false);
// Add curves to both plots
// 向两个绘图添加曲线
QwtPlotCurve* curve1 = new QwtPlotCurve("Host Curve");
curve1->setSamples(xData, yData1);
curve1->attach(hostPlot);
QwtPlotCurve* curve2 = new QwtPlotCurve("Parasite Curve");
curve2->setSamples(xData, yData2);
curve2->attach(parasiteYRight);
// Set different axis titles
// 设置不同的轴标题
hostPlot->setAxisTitle(QwtAxis::YLeft, "Primary Y");
parasiteYRight->setAxisTitle(QwtAxis::YRight, "Secondary Y");
A plot item, that represents a series of points.
Definition qwt_plot_curve.h:75
void setSamples(const double *xData, const double *yData, int size)
Set data by copying x- and y-values from specified memory blocks.
Definition qwt_plot_curve.cpp:1226
void attach(QwtPlot *plot)
Attach the item to a plot.
Definition qwt_plot_item.cpp:115
void setAxisTitle(QwtAxisId, const QString &)
Change the title of a specified axis/修改指定轴的标题
Definition qwt_plot_axis.cpp:754
@ YRight
Y axis right of the canvas.
Definition qwt_axis.h:44
@ YLeft
Y axis left of the canvas.
Definition qwt_axis.h:41
See also
getParasiteAxes()
Note
寄生轴必须有figure来管理,这是因为寄生轴仅仅是绘图区域和宿主重叠,坐标窗口的位置都和宿主不一样

◆ currentAxes()

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。 当前坐标轴通常是最后添加、修改或绘图的坐标轴。

Returns
Pointer to the current QwtPlot, or nullptr if no axes exist / 指向当前QwtPlot的指针,如果没有坐标轴则返回nullptr
// Get the current axes and plot some data
// 获取当前坐标轴并绘制一些数据
QwtPlot* currentPlot = figure.currentAxes();
if (currentPlot) {
// Add curve to the current plot
// 在当前绘图中添加曲线
QwtPlotCurve* curve = new QwtPlotCurve;
curve->attach(currentPlot);
}
See also
gca

◆ currentAxesChanged

void QwtFigure::currentAxesChanged ( QwtPlot current)
signal

当前激活的坐标系发生了改变的信号

Parameters
current
Note
寄生轴不能作为当前axes
此信号会携带空指针,说明没有设置任何有效的激活坐标系

◆ edgeColor()

QColor QwtFigure::edgeColor ( ) const

Get the edge color of the figure/获取图形的边缘颜色

This method returns the border color of the figure.

此方法返回图形的边框颜色。

Returns
Border color / 边框颜色
// Get the current border color
// 获取当前边框颜色
QColor borderColor = figure.edgeColor();

◆ edgeLineWidth()

int QwtFigure::edgeLineWidth ( ) const

Get the edge line width of the figure/获取图形的边缘线宽

This method returns the border line width of the figure.

此方法返回图形的边框线宽。

Returns
Border line width in pixels / 边框线宽(像素)
// Get the current border width
// 获取当前边框宽度
int borderWidth = figure.edgeLineWidth();

◆ faceBrush()

QBrush QwtFigure::faceBrush ( ) const

Get the face brush of the figure/获取图形的表面画刷

This method returns the background brush of the figure.

此方法返回图形的背景画刷。

Returns
Background brush / 背景画刷
// Get the current background brush
// 获取当前背景画刷
QBrush bgBrush = figure.faceBrush();

◆ faceColor()

QColor QwtFigure::faceColor ( ) const

Get the face color of the figure/获取图形的表面颜色

This method returns the background color of the figure.

此方法返回图形的背景颜色。

Returns
Background color / 背景颜色
// Get the current background color
// 获取当前背景颜色
QColor bgColor = figure.faceColor();

◆ gca()

QwtPlot * QwtFigure::gca ( ) const

Get the current axes (plot)/获取当前坐标轴(绘图)

Returns
Pointer to the current QwtPlot, or nullptr if no axes exist / 指向当前QwtPlot的指针,如果没有坐标轴则返回nullptr
See also
currentAxes

◆ getParasiteAxes()

QList< QwtPlot * > QwtFigure::getParasiteAxes ( QwtPlot hostPlot) const

Get all parasite axes for a host plot/获取宿主绘图的所有寄生轴

This method returns a list of all parasite axes associated with the specified host plot.

此方法返回与指定宿主绘图关联的所有寄生轴的列表。

Parameters
hostPlotPointer to the host QwtPlot/指向宿主QwtPlot的指针
Returns
List of parasite QwtPlot pointers/寄生QwtPlot指针列表
Return values
Emptylist if hostPlot is invalid or has no parasite axes/如果hostPlot无效或没有寄生轴则返回空列表
See also
createParasiteAxes()

◆ getSizeInches()

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计算图形的物理尺寸(英寸)。

Returns
Size of the figure in inches / 图形的英寸尺寸
// Get the size of the figure in inches
// 获取图形的英寸尺寸
QSize sizeInInches = figure.getSizeInches();
qDebug() << "Figure size:" << sizeInInches.width() << "x" << sizeInInches.height() << "inches";

◆ hasAxes() [1/2]

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。

Returns
true if the figure has axes, false otherwise / 如果图形有坐标轴返回true,否则返回false
// Check if figure has axes before performing operations
// 在执行操作前检查图形是否有坐标轴
if (figure.hasAxes()) {
// Do something with the plots
// 对绘图进行操作
}

◆ hasAxes() [2/2]

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。

Parameters
plotQwtPlot to check / 要检测的QwtPlot
Returns
true if the figure has axes, false otherwise / 如果图形有坐标轴返回true,否则返回false
// Check if figure has axes before performing operations
// 在执行操作前检查图形是否有坐标轴
QwtPlot* plot;
...
if (figure.hasAxes(plot)) {
// Do something with the plots
// 对绘图进行操作
}

◆ plotUnderPos()

QwtPlot * QwtFigure::plotUnderPos ( const QPoint &  pos) const

获取在此坐标下的绘图,如果此坐标下没有,则返回nullptr,存在寄生轴情况只返回宿主轴

Note
隐藏的窗口不会获取到
Parameters
pos坐标
Returns
如果此坐标下没有,则返回nullptr

◆ removeAxes()

void QwtFigure::removeAxes ( QwtPlot plot)

Remove a specific axes (plot) from the figure/从图形中移除特定的坐标轴(绘图)

This method removes the specified QwtPlot from the figure.

此方法从图形中移除指定的QwtPlot。

Parameters
plotQwtPlot to remove / 要移除的QwtPlot
Note
This function will destroy the QwtPlot object 此函数会销毁QwtPlot对象
// Remove a specific plot from the figure
// 从图形中移除特定的绘图
QwtPlot* plotToRemove = figure.getAllAxes().first();
figure.removeAxes(plotToRemove);
// 你需要手动删除它
plotToRemove->deletelater();

◆ removeAxisAlignment()

bool QwtFigure::removeAxisAlignment ( const QList< QwtPlot * > &  plots,
int  axisId 
)

移除指定的轴对齐配置

Parameters
plots需要移除的对齐配置中的plot列表
axisId要移除的对齐配置中的轴ID
Returns
是否成功移除

◆ saveFig() [1/3]

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的图像文件。

Parameters
filenameName of the file to save / 要保存的文件名
dpiDots per inch for the saved image (-1 to use screen DPI) / 保存图像的DPI(-1表示使用屏幕DPI)
Returns
true if saved successfully, false otherwise / 成功保存返回true,否则返回false
// Save the figure with screen DPI
// 使用屏幕DPI保存图形
figure.saveFig("figure.png");
// Save the figure with 300 DPI
// 使用300 DPI保存图形
figure.saveFig("high_res_figure.png", 300);

◆ saveFig() [2/3]

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。

Parameters
dpiDots per inch for the saved image (-1 to use screen DPI) / 保存图像的DPI(-1表示使用屏幕DPI)
Returns
QPixmap containing the rendered figure / 包含渲染图形的QPixmap
// Save the figure with screen DPI
// 使用屏幕DPI保存图形
QPixmap pixmap1 = figure.saveFig();
// Save the figure with 300 DPI
// 使用300 DPI保存图形
QPixmap pixmap2 = figure.saveFig(300);

◆ saveFig() [3/3]

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设置来计算像素尺寸。

Parameters
inchesSizePhysical size in inches / 物理尺寸(英寸)
Returns
QPixmap containing the rendered figure / 包含渲染图形的QPixmap
// Save the figure as a 6x4 inch image
// 将图形保存为6x4英寸的图像
QPixmap pixmap = figure.saveFig(QSizeF(6.0, 4.0));

◆ sca()

void QwtFigure::sca ( QwtPlot plot)

Set the current axes (plot)/设置当前坐标轴(绘图)

Parameters
plotQwtPlot to set as current / 要设置为当前的QwtPlot
See also
setCurrentAxes

◆ setCurrentAxes()

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设置为图形中当前活动的坐标轴。

Parameters
plotQwtPlot to set as current / 要设置为当前的QwtPlot
// Set a specific plot as current axes
// 将特定绘图设置为当前坐标轴
QList<QwtPlot*> plots = figure.getAllAxes();
if (!plots.isEmpty()) {
figure.setCurrentAxes(plots.first()); // Set first plot as current
}

◆ setEdgeColor()

void QwtFigure::setEdgeColor ( const QColor &  color)

Set the edge color of the figure/设置图形的边缘颜色

This method sets the border color of the figure.

此方法设置图形的边框颜色。

Parameters
colorBorder color / 边框颜色
// Set the figure border to black
// 将图形边框设置为黑色
figure.setEdgeColor(Qt::black);

◆ setEdgeLineWidth()

void QwtFigure::setEdgeLineWidth ( int  width)

Set the edge line width of the figure/设置图形的边缘线宽

This method sets the border line width of the figure.

此方法设置图形的边框线宽。

Parameters
widthBorder line width in pixels / 边框线宽(像素)
// Set the figure border width to 2 pixels
// 将图形边框宽度设置为2像素
figure.setEdgeLineWidth(2);

◆ setFaceBrush()

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.).

此方法设置图形的背景画刷,允许更复杂的背景(渐变、纹理等)。

Parameters
brushBackground brush / 背景画刷
// Set a gradient background
// 设置渐变背景
QLinearGradient gradient(0, 0, 0, 1);
gradient.setColorAt(0, Qt::white);
gradient.setColorAt(1, Qt::lightGray);
figure.setFaceBrush(QBrush(gradient));

◆ setFaceColor()

void QwtFigure::setFaceColor ( const QColor &  color)

Set the face color of the figure/设置图形的背景颜色

This method sets the background color of the figure.

此方法设置图形的背景颜色。

Parameters
colorBackground color / 背景颜色
// Set the figure background to light gray
// 将图形背景设置为浅灰色
figure.setFaceColor(Qt::lightGray);

◆ setSizeInches() [1/2]

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转换为像素。

Parameters
sizeSize in inches / 英寸尺寸
// Set the figure size to 6x4 inches
// 将图形尺寸设置为6x4英寸
figure.setSizeInches(QSizeF(6.0, 4.0));

◆ setSizeInches() [2/2]

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转换为像素。

Parameters
widthWidth in inches / 宽度(英寸)
heightHeight in inches / 高度(英寸)
// Set the figure size to 6x4 inches
// 将图形尺寸设置为6x4英寸
figure.setSizeInches(6.0, 4.0);

◆ setWidgetNormPos()

void QwtFigure::setWidgetNormPos ( QWidget *  widget,
const QRectF &  rect 
)

改变已经添加的窗口的位置占比,如果窗口还没添加,此函数无效

Parameters
widget
rect

◆ takeAxes()

bool QwtFigure::takeAxes ( QwtPlot plot)

Take a specific axes (plot) from the figure without deleting it/从图形中取出特定的坐标轴(绘图)但不删除它

Parameters
plotPointer to the QwtPlot to take / 要取出的QwtPlot指针
Returns
Pointer to the taken QwtPlot, or nullptr if not found / 取出的QwtPlot指针,如果未找到则返回nullptr
Note
如果当前的绘图是选择的激活坐标系,在移除时,会先发射currentAxesChanged 信号,再发射axesRemoved 信号
如果只有一个绘图,在移除后,整个figure没有绘图的情况下,也会发射currentAxesChanged 信号,信号携带的内容为nullptr
如果一个绘图有寄生轴,再takeAxes后,它的寄生轴会设置为隐藏,并把parent widget设置为nullptr

◆ widgetNormRect()

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。

Parameters
widgetWidget to query / 要查询的窗口
Returns
Normalized coordinates [left, top, width, height] in range [0,1], or invalid QRectF if not found 归一化坐标 [左, 上, 宽, 高],范围 [0,1],如果未找到则返回无效QRectF

The documentation for this class was generated from the following files: