QWT 7.0.1
Loading...
Searching...
No Matches
qwt_figure.h
1#ifndef QWT_FIGURE_H
2#define QWT_FIGURE_H
3// stl
4#include <memory>
5
6// Qt
7#include <QFrame>
8class QResizeEvent;
9class QPaintEvent;
10
11// qwt
12#include "qwt_global.h"
13#include "qwt_axis.h"
14class QwtPlot;
15
89class QWT_EXPORT QwtFigure : public QFrame
90{
91 Q_OBJECT
92 QWT_DECLARE_PRIVATE(QwtFigure)
93public:
94 QwtFigure(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
95 virtual ~QwtFigure();
96 // Add a widget with normalized coordinates/使用归一化坐标添加widget
97 void addWidget(QWidget* widget, qreal left, qreal top, qreal width, qreal height);
98 void addWidget(QWidget* widget,
99 int rowCnt,
100 int colCnt,
101 int row,
102 int col,
103 int rowSpan = 1,
104 int colSpan = 1,
105 qreal wspace = 0.0,
106 qreal hspace = 0.0);
107 // Add a plot with normalized coordinates/使用归一化坐标添加绘图
108 void addAxes(QwtPlot* plot, const QRectF& rect);
109
110 // Add a plot with normalized coordinates using separate parameters/使用分离参数和归一化坐标添加窗口部件
111 void addAxes(QwtPlot* plot, qreal left, qreal top, qreal width, qreal height);
112
113 // Add a plot by grid layout/添加窗口部件到网格布局
114 void addGridAxes(QwtPlot* plot,
115 int rowCnt,
116 int colCnt,
117 int row,
118 int col,
119 int rowSpan = 1,
120 int colSpan = 1,
121 qreal wspace = 0.0,
122 qreal hspace = 0.0);
123
124 // 改变已经添加的窗口的位置占比,如果窗口还没添加,此函数无效
125 void setWidgetNormPos(QWidget* widget, const QRectF& rect);
126
127 // Get all axes (plots) in the figure(not contain parasite axes)/获取图形中的所有坐标轴(绘图)(不包含寄生轴)
128 QList< QwtPlot* > allAxes(bool byZOrder = false) const;
129
130 // Check if the figure has any axes/检查图形是否有任意绘图
131 bool hasAxes() const;
132
133 // Check if the figure has plot/检查图形是否存在plot
134 bool hasAxes(QwtPlot* plot) const;
135
136 // Remove a specific axes (plot) from the figure/从图形中移除特定的坐标轴(绘图)/This function does not destroy the QwtPlot object
137 void removeAxes(QwtPlot* plot);
138
139 // Take a specific axes (plot) from the figure without deleting it/从图形中取出特定的坐标轴(绘图)但不删除它
140 bool takeAxes(QwtPlot* plot);
141
142 // Clear all axes from the figure/清除图形中的所有坐标轴
143 void clear();
144
145 // Get the size of the figure in inches/获取图形的英寸尺寸
146 QSize getSizeInches() const;
147
148 // Set the size of the figure in inches/设置图形的英寸尺寸
149 void setSizeInches(float width, float height);
150 void setSizeInches(const QSizeF& size);
151
152 // Set/Get the face color of the figure/设置图形的背景颜色
153 void setFaceColor(const QColor& color);
154 QColor faceColor() const;
155
156 // Set/Get the face brush of the figure/设置图形的背景画刷
157 void setFaceBrush(const QBrush& brush);
158 QBrush faceBrush() const;
159
160 // Set/Get the edge color of the figure/设置图形的边缘颜色
161 void setEdgeColor(const QColor& color);
162 QColor edgeColor() const;
163
164 // Set/Get the edge line width of the figure/设置图形的边缘线宽
165 void setEdgeLineWidth(int width);
166 int edgeLineWidth() const;
167
168 // Parasite Axes
169 // Create parasite axes for a host plot/为宿主绘图创建寄生轴
170 QwtPlot* createParasiteAxes(QwtPlot* hostPlot, QwtAxis::Position enableAxis);
171 // Get all parasite axes for a host plot/获取宿主绘图的所有寄生轴
172 QList< QwtPlot* > getParasiteAxes(QwtPlot* hostPlot) const;
173
174 // Save methods / 保存方法
175 // Save the figure to a QPixmap with specified DPI/使用指定DPI将图形保存为QPixmap
176 QPixmap saveFig(int dpi = -1) const;
177
178 // Save the figure to a QPixmap with specified size in inches/使用指定英寸尺寸将图形保存为QPixmap
179 QPixmap saveFig(QSizeF& inchesSize) const;
180
181 // Save the figure to a file with specified DPI/使用指定DPI将图形保存到文件
182 bool saveFig(const QString& filename, int dpi = -1) const;
183
184 // Set the current axes (plot)/设置当前坐标轴(绘图)
185 void setCurrentAxes(QwtPlot* plot);
186 void sca(QwtPlot* plot);
187
188 // Get the current axes (plot)/获取当前坐标轴(绘图)
189 QwtPlot* currentAxes() const;
190 QwtPlot* gca() const;
191
192 // Get the normalized rectangle for a axes/获取绘图的归一化矩形
193 QRectF axesNormRect(QwtPlot* plot) const;
194 // Get the normalized rectangle for a child widget/获取子窗口的的归一化矩形
195 QRectF widgetNormRect(QWidget* w) const;
196 // 获取在此坐标下的绘图,如果此坐标下没有,则返回nullptr,存在寄生轴情况只返回宿主轴
197 QwtPlot* plotUnderPos(const QPoint& pos) const;
198 // 通过真实位置计算归一化坐标
199 QRectF calcNormRect(const QRect& geoRect) const;
200 // 计算正规矩形
201 QRect calcActualRect(const QRectF& normRect);
202 // 更新所有的绘图
203 void replotAll();
204 //=============AxisAlignment==================
205 // 添加轴对齐配置
206 void addAxisAlignment(const QList< QwtPlot* >& plots, int axisId);
207 // 移除指定的轴对齐配置
208 bool removeAxisAlignment(const QList< QwtPlot* >& plots, int axisId);
209 // 清除所有轴对齐配置
210 void clearAxisAlignment();
211 // 应用所有轴对齐配置,对记录的plot和轴进行对齐
212 void applyAllAxisAlignments(bool replot = true);
213 // 应用指定轴ID的所有对齐配置
214 void applyAlignmentsForAxis(int axisId);
215Q_SIGNALS:
221 void axesAdded(QwtPlot* newAxes);
222
228 void axesRemoved(QwtPlot* removedAxes);
229
234
242
243public:
244 // QwtPlot轴对齐函数
245 static void alignAxes(QList< QwtPlot* > plots, int axisId, bool update = true);
246
247protected:
248 void paintEvent(QPaintEvent* event) override;
249 void resizeEvent(QResizeEvent* event) override;
250};
251
252#endif // QWT_FIGURE_H
Definition qwt_dyngrid_layout.h:33
A figure container for organizing Qwt plots with flexible layout options.
Definition qwt_figure.h:90
void figureCleared()
Signal emitted when the figure is cleared/当图形被清除时发出的信号
void axesAdded(QwtPlot *newAxes)
Signal emitted when axes are added to the figure/当坐标轴添加到图形时发出的信号
void currentAxesChanged(QwtPlot *current)
当前激活的坐标系发生了改变的信号
void axesRemoved(QwtPlot *removedAxes)
Signal emitted when axes are removed from the figure/当坐标轴从图形中移除时发出的信号
A 2-D plotting widget.
Definition qwt_plot.h:99
Position
Axis position.
Definition qwt_axis.h:39