QWT API (中文) 7.0.1
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_plot_layout_engine.h
1#ifndef QWTPLOTLAYOUTENGINE_H
2#define QWTPLOTLAYOUTENGINE_H
3#include <QRectF>
4#include <QFont>
5class QWidget;
6// qwt
7#include "qwt_global.h"
8#include "qwt_axis.h"
9#include "qwt_axis_id.h"
10#include "qwt_text.h"
11#include "qwt_plot.h"
13class QwtTextLabel;
14class QwtScaleWidget;
28class QWT_EXPORT QwtPlotLayoutEngine
29{
30public:
43 {
44 // Constructor
45 Dimensions();
46
47 // Get the dimension for a specific axis
48 int dimAxis(QwtAxisId axisId) const;
49
50 // Set the dimension for a specific axis
51 void setDimAxis(QwtAxisId axisId, int dim);
52
53 // Get the dimension for an axis position (YLeft, YRight, XTop, XBottom)
54 int dimAxes(int axisPos) const;
55
56 // Get the total width of left and right Y axes
57 int dimYAxes() const;
58
59 // Get the total height of top and bottom X axes
60 int dimXAxes() const;
61
62 // Center a label rectangle within available space after accounting for Y axes
63 QRectF centered(const QRectF& rect, const QRectF& labelRect) const;
64
65 // Calculate inner rectangle after reserving space for all axes
66 QRectF innerRect(const QRectF& rect) const;
67
68 int dimTitle;
69 int dimFooter;
70
71 private:
72 int m_dimAxes[ QwtAxis::AxisPositions ];
73 };
74
87 {
88 public:
101 {
102 // Initialize legend data from a QwtAbstractLegend
103 void init(const QwtAbstractLegend* legend);
104
105 // Calculate optimal legend size for the given rectangle
106 QSize legendHint(const QwtAbstractLegend* legend, const QRectF& rect) const;
107
108 int frameWidth;
109 int hScrollExtent;
110 int vScrollExtent;
111 QSize hint;
112 };
113
126 {
127 // Initialize label data from a QwtTextLabel
128 void init(const QwtTextLabel* label);
129
130 QwtText text;
131 int frameWidth;
132 };
133
146 {
147 // Initialize scale data from a QwtScaleWidget
148 void init(const QwtScaleWidget* axisWidget);
149
150 // Reset scale data to default values
151 void reset();
152
153 bool isVisible;
154 const QwtScaleWidget* scaleWidget;
155 QFont scaleFont;
156 int start;
157 int end;
158 int baseLineOffset;
159 double tickOffset;
160 int dimWithoutTitle;
161 int edgeMargin;
162 };
163
176 {
177 // Initialize canvas data from a QWidget
178 void init(const QWidget* canvas);
179
180 int contentsMargins[ QwtAxis::AxisPositions ];
181 };
182
194 enum Label
195 {
198
199 NumLabels
200 };
201
202 // Construct LayoutData from a QwtPlot
203 LayoutData(const QwtPlot* plot);
204
205 // Check if left and right Y axes have the same visibility state
206 bool hasSymmetricYAxes() const;
207
208 // Get mutable scale data for a specific axis
209 ScaleData& axisData(QwtAxisId axisId);
210
211 // Get const scale data for a specific axis
212 const ScaleData& axisData(QwtAxisId axisId) const;
213
214 // Get tick offset for a specific axis position
215 double tickOffset(int axisPos) const;
216
217 LegendData legendData;
218 LabelData labelData[ NumLabels ];
219 CanvasData canvasData;
220
221 private:
222 ScaleData m_scaleData[ QwtAxis::AxisPositions ];
223 };
224
225public:
226 // Constructor
228
229 // Calculate and return the legend rectangle within the available space
230 QRectF layoutLegend(int plotLayoutOptions,
231 const LayoutData::LegendData& legendData,
232 const QRectF& rect,
233 const QSize& legendHint) const;
234
235 // Align the legend rectangle relative to the canvas
236 QRectF alignLegend(const QSize& legendHint, const QRectF& canvasRect, const QRectF& legendRect) const;
237
238 // Align scale rectangles with the canvas, adjusting positions for proper layout
239 void alignScales(int plotLayoutOptions,
240 const LayoutData& layoutData,
241 QRectF& canvasRect,
242 QRectF scaleRect[ QwtAxis::AxisPositions ]) const;
243
244 // Align scale rectangles to canvas boundaries
245 void alignScalesToCanvas(int plotLayoutOptions,
246 const LayoutData& layoutData,
247 const QRectF& canvasRect,
248 QRectF scaleRect[ QwtAxis::AxisPositions ]) const;
249
250 // Calculate layout dimensions for title, footer, and all axes
251 Dimensions layoutDimensions(int plotLayoutOptions, const LayoutData& layoutData, const QRectF& rect) const;
252
253 // Set the spacing between plot components
254 void setSpacing(unsigned int spacing);
255
256 // Get the spacing between plot components
257 unsigned int spacing() const;
258
259 // Set whether the canvas should align to the scale at a given axis position
260 void setAlignCanvas(int axisPos, bool on);
261
262 // Check if the canvas is aligned to the scale at a given axis position
263 bool alignCanvas(int axisPos) const;
264
265 // Set the margin between canvas and scale at a given axis position
266 void setCanvasMargin(int axisPos, int margin);
267
268 // Get the margin between canvas and scale at a given axis position
269 int canvasMargin(int axisPos) const;
270
271 // Set the legend position
272 void setLegendPos(QwtPlot::LegendPosition pos);
273
274 // Get the legend position
275 QwtPlot::LegendPosition legendPos() const;
276
277 // Set the legend ratio for size calculation
278 void setLegendRatio(double ratio);
279
280 // Get the legend ratio for size calculation
281 double legendRatio() const;
282
283private:
289 int heightForWidth(LayoutData::Label labelType,
290 const LayoutData& layoutData,
291 int plotLayoutOptions,
292 double width,
293 int axesWidth) const;
294
295 QwtPlot::LegendPosition m_legendPos;
296 double m_legendRatio;
297
298 unsigned int m_canvasMargin[ QwtAxis::AxisPositions ] = { 0, 0, 0, 0 };
299 bool m_alignCanvas[ QwtAxis::AxisPositions ];
300
301 unsigned int m_spacing;
302};
303
304#endif // QWTPLOTLAYOUTENGINE_H
图例控件的抽象基类
Definition qwt_abstract_legend.h:57
布局计算数据结构
Definition qwt_plot_layout_engine.h:87
Label
标签类型枚举
Definition qwt_plot_layout_engine.h:195
@ Title
标题标签
Definition qwt_plot_layout_engine.h:196
@ Footer
页脚标签
Definition qwt_plot_layout_engine.h:197
QwtPlot组件的布局引擎
Definition qwt_plot_layout_engine.h:29
二维绘图部件
Definition qwt_plot.h:138
LegendPosition
图例相对于画布的位置
Definition qwt_plot.h:162
包含刻度的控件
Definition qwt_scale_widget.h:95
显示 QwtText 的控件
Definition qwt_text_label.h:55
表示文本的类
Definition qwt_text.h:93
保存布局计算尺寸值的结构体
Definition qwt_plot_layout_engine.h:43
画布布局计算数据
Definition qwt_plot_layout_engine.h:176
标题/页脚标签布局计算数据
Definition qwt_plot_layout_engine.h:126
图例布局计算数据
Definition qwt_plot_layout_engine.h:101
坐标轴刻度部件布局计算数据
Definition qwt_plot_layout_engine.h:146