QWT API (中文) 7.0.1
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
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
76class QWT_EXPORT QwtFigure : public QFrame
77{
78 Q_OBJECT
79 QWT_DECLARE_PRIVATE(QwtFigure)
80public:
81 QwtFigure(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
82 virtual ~QwtFigure();
83
84 // Add a widget with normalized coordinates
85 void addWidget(QWidget* widget, qreal left, qreal top, qreal width, qreal height);
86 void addWidget(QWidget* widget,
87 int rowCnt,
88 int colCnt,
89 int row,
90 int col,
91 int rowSpan = 1,
92 int colSpan = 1,
93 qreal wspace = 0.0,
94 qreal hspace = 0.0);
95
96 // Add a plot with normalized coordinates
97 void addAxes(QwtPlot* plot, const QRectF& rect);
98
99 // Add a plot with normalized coordinates using separate parameters
100 void addAxes(QwtPlot* plot, qreal left, qreal top, qreal width, qreal height);
101
102 // Add a plot by grid layout
103 void addGridAxes(QwtPlot* plot,
104 int rowCnt,
105 int colCnt,
106 int row,
107 int col,
108 int rowSpan = 1,
109 int colSpan = 1,
110 qreal wspace = 0.0,
111 qreal hspace = 0.0);
112
113 // Change the normalized position of an added widget
114 void setWidgetNormPos(QWidget* widget, const QRectF& rect);
115
116 // Get all axes (plots) in the figure (not including parasite axes)
117 QList< QwtPlot* > allAxes(bool byZOrder = false) const;
118
119 // Check if the figure has any axes
120 bool hasAxes() const;
121
122 // Check if the figure has a specific plot
123 bool hasAxes(QwtPlot* plot) const;
124
125 // Remove a specific axes (plot) from the figure
126 void removeAxes(QwtPlot* plot);
127
128 // Take a specific axes (plot) from the figure without deleting it
129 bool takeAxes(QwtPlot* plot);
130
131 // Clear all axes from the figure
132 void clear();
133
134 // Get the size of the figure in inches
135 QSize getSizeInches() const;
136
137 // Set the size of the figure in inches
138 void setSizeInches(float width, float height);
139 void setSizeInches(const QSizeF& size);
140
141 // Set the face color of the figure
142 void setFaceColor(const QColor& color);
143 QColor faceColor() const;
144
145 // Set the face brush of the figure
146 void setFaceBrush(const QBrush& brush);
147 QBrush faceBrush() const;
148
149 // Set the edge color of the figure
150 void setEdgeColor(const QColor& color);
151 QColor edgeColor() const;
152
153 // Set the edge line width of the figure
154 void setEdgeLineWidth(int width);
155 int edgeLineWidth() const;
156
157 // Create parasite axes for a host plot
158 QwtPlot* createParasiteAxes(QwtPlot* hostPlot, QwtAxis::Position enableAxis);
159
160 // Get all parasite axes for a host plot
161 QList< QwtPlot* > getParasiteAxes(QwtPlot* hostPlot) const;
162
163 // Save the figure to a QPixmap with specified DPI
164 QPixmap saveFig(int dpi = -1) const;
165
166 // Save the figure to a QPixmap with specified size in inches
167 QPixmap saveFig(QSizeF& inchesSize) const;
168
169 // Save the figure to a file with specified DPI
170 bool saveFig(const QString& filename, int dpi = -1) const;
171
172 // Set the current axes (plot)
173 void setCurrentAxes(QwtPlot* plot);
174 void sca(QwtPlot* plot);
175
176 // Get the current axes (plot)
177 QwtPlot* currentAxes() const;
178 QwtPlot* gca() const;
179
180 // Get the normalized rectangle for an axes
181 QRectF axesNormRect(QwtPlot* plot) const;
182
183 // Get the normalized rectangle for a child widget
184 QRectF widgetNormRect(QWidget* w) const;
185
186 // Get the plot at a given position (returns host plot if parasite exists)
187 QwtPlot* plotUnderPos(const QPoint& pos) const;
188
189 // Calculate normalized coordinates from actual geometry
190 QRectF calcNormRect(const QRect& geoRect) const;
191
192 // Calculate actual rectangle from normalized coordinates
193 QRect calcActualRect(const QRectF& normRect);
194
195 // Update all plots
196 void replotAll();
197
198 // Add axis alignment configuration
199 void addAxisAlignment(const QList< QwtPlot* >& plots, int axisId);
200
201 // Remove specified axis alignment configuration
202 bool removeAxisAlignment(const QList< QwtPlot* >& plots, int axisId);
203
204 // Clear all axis alignment configurations
205 void clearAxisAlignment();
206
207 // Apply all axis alignment configurations
208 void applyAllAxisAlignments(bool replot = true);
209
210 // Apply all alignment configurations for a specific axis ID
211 void applyAlignmentsForAxis(int axisId);
212
213 // Get the count of axis alignment configurations
214 int axisAligmentCount() const;
215
216 // Get axis alignment information at specified index
217 QPair<QList< QwtPlot* >,int> axisAligmentInfo(int index) const;
218
219public:
220 // Align axes of multiple QwtPlot objects
221 static void alignAxes(QList< QwtPlot* > plots, int axisId, bool update = true);
222Q_SIGNALS:
236 void axesAdded(QwtPlot* newAxes);
237
251 void axesRemoved(QwtPlot* removedAxes);
252
263
278
279
280protected:
281 void paintEvent(QPaintEvent* event) override;
282 void resizeEvent(QResizeEvent* event) override;
283};
284
285#endif // QWT_FIGURE_H
Definition qwt_dyngrid_layout.h:33
用于组织Qwt绘图的图形容器,提供灵活的布局选项
Definition qwt_figure.h:77
void figureCleared()
当图形被清除时发出的信号
void axesAdded(QwtPlot *newAxes)
当坐标轴添加到图形时发出的信号
void currentAxesChanged(QwtPlot *current)
当前激活的坐标系发生了改变的信号
void axesRemoved(QwtPlot *removedAxes)
当坐标轴从图形中移除时发出的信号
二维绘图部件
Definition qwt_plot.h:138
Position
坐标轴位置
Definition qwt_axis.h:53