|
QWT 7.0.1
|
The QwtPlotLayoutEngine class. More...
#include <qwt_plot_layout_engine.h>
Classes | |
| struct | Dimensions |
| class | LayoutData |
Public Member Functions | |
| QwtPlotLayoutEngine () | |
| Default constructor for QwtPlotLayoutEngine / QwtPlotLayoutEngine的默认构造函数 | |
| QRectF | layoutLegend (int plotLayoutOptions, const LayoutData::LegendData &legendData, const QRectF &rect, const QSize &legendHint) const |
| Calculate legend rectangle within available space / 在可用空间内计算图例矩形 | |
| QRectF | alignLegend (const QSize &legendHint, const QRectF &canvasRect, const QRectF &legendRect) const |
| Align legend rectangle relative to canvas / 相对于画布对齐图例矩形 | |
| void | alignScales (int plotLayoutOptions, const LayoutData &layoutData, QRectF &canvasRect, QRectF scaleRect[QwtAxis::AxisPositions]) const |
| Align scale rectangles with canvas / 将刻度矩形与画布对齐 | |
| void | alignScalesToCanvas (int plotLayoutOptions, const LayoutData &layoutData, const QRectF &canvasRect, QRectF scaleRect[QwtAxis::AxisPositions]) const |
| Dimensions | layoutDimensions (int plotLayoutOptions, const LayoutData &layoutData, const QRectF &rect) const |
| Iteratively calculate the layout dimensions for a QwtPlot / 迭代计算QwtPlot的布局尺寸 | |
| void | setSpacing (unsigned int spacing) |
| Set spacing value / 设置间距值 | |
| unsigned int | spacing () const |
| Get spacing value / 获取间距值 | |
| void | setAlignCanvas (int axisPos, bool on) |
| Set canvas alignment to scale for a specific axis / 设置画布对齐到特定轴的刻度 | |
| bool | alignCanvas (int axisPos) const |
| Check if canvas is aligned to scale for a specific axis / 检查画布是否对齐到特定轴的刻度 | |
| void | setCanvasMargin (int axisPos, int margin) |
| Set canvas margin for a specific axis / 设置特定轴的画布边距 | |
| int | canvasMargin (int axisPos) const |
| Get canvas margin for a specific axis / 获取特定轴的画布边距 | |
| void | setLegendPos (QwtPlot::LegendPosition pos) |
| Set the legend position / 设置图例位置 | |
| QwtPlot::LegendPosition | legendPos () const |
| Get the legend position / 获取图例位置 | |
| void | setLegendRatio (double ratio) |
| Set the legend ratio / 设置图例比例 | |
| double | legendRatio () const |
| Get the legend ratio / 获取图例比例 | |
The QwtPlotLayoutEngine class.
原来的QwtPlotLayout里的私有类,原来此类写在qwt_plot_layout.cpp中,class LayoutEngine,由于其它布局会用到,把它提取为公共类
| QwtPlotLayoutEngine::QwtPlotLayoutEngine | ( | ) |
Default constructor for QwtPlotLayoutEngine / QwtPlotLayoutEngine的默认构造函数
Initializes the layout engine with default values:
使用默认值初始化布局引擎:
| bool QwtPlotLayoutEngine::alignCanvas | ( | int | axisPos | ) | const |
Check if canvas is aligned to scale for a specific axis / 检查画布是否对齐到特定轴的刻度
| axisPos | Axis position (0-3) / 轴位置(0-3) |
| QRectF QwtPlotLayoutEngine::alignLegend | ( | const QSize & | legendHint, |
| const QRectF & | canvasRect, | ||
| const QRectF & | legendRect | ||
| ) | const |
Align legend rectangle relative to canvas / 相对于画布对齐图例矩形
Adjusts the legend rectangle to be properly aligned with the canvas, ensuring it doesn't extend beyond the canvas boundaries when possible.
调整图例矩形以与画布正确对齐,确保在可能的情况下不超出画布边界。
| legendHint | Preferred size hint for the legend / 图例的首选尺寸提示 |
| canvasRect | Canvas rectangle / 画布矩形 |
| legendRect | Initial legend rectangle / 初始图例矩形 |
| void QwtPlotLayoutEngine::alignScales | ( | int | plotLayoutOptions, |
| const LayoutData & | layoutData, | ||
| QRectF & | canvasRect, | ||
| QRectF | scaleRect[QwtAxis::AxisPositions] | ||
| ) | const |
Align scale rectangles with canvas / 将刻度矩形与画布对齐
Adjusts the positions of scale rectangles to ensure proper alignment with the canvas, taking into account border distances and tick offsets.
调整刻度矩形的位置以确保与画布正确对齐,考虑边框距离和刻度偏移量。
这个函数的主要职责是调整坐标轴刻度矩形的位置,确保它们与画布正确对齐。 这是一个复杂的布局计算过程,涉及到多个坐标轴和画布之间的空间协调。 具体计算过程可见代码里的注释
| plotLayoutOptions | Layout options bitmask / 布局选项位掩码 |
| layoutData | Precalculated layout data / 预计算的布局数据 |
| canvasRect | Canvas rectangle (may be modified) / 画布矩形(可能被修改) |
| scaleRect | Array of scale rectangles (will be modified) / 刻度矩形数组(将被修改) |
对于X轴(水平轴): 检查左侧Y轴和右侧Y轴的影响 计算左右偏移量,考虑轴起始/结束距离和骨干偏移 调整X轴矩形位置,必要时调整画布矩形
对于Y轴(垂直轴): 检查底部X轴和顶部X轴的影响 计算上下偏移量,考虑轴起始/结束距离和骨干偏移 调整Y轴矩形位置,必要时调整画布矩形
当轴需要比可用空间更多的空间时,函数会调整画布矩形
在所有轴相互调整后,函数进行最终的对齐调整,确保轴与画布边缘正确对齐
| void QwtPlotLayoutEngine::alignScalesToCanvas | ( | int | plotLayoutOptions, |
| const LayoutData & | layoutData, | ||
| const QRectF & | canvasRect, | ||
| QRectF | scaleRect[QwtAxis::AxisPositions] | ||
| ) | const |
对于X轴(水平轴): 检查左侧Y轴和右侧Y轴的影响 计算左右偏移量,考虑轴起始/结束距离和骨干偏移 调整X轴矩形位置,必要时调整画布矩形
对于Y轴(垂直轴): 检查底部X轴和顶部X轴的影响 计算上下偏移量,考虑轴起始/结束距离和骨干偏移 调整Y轴矩形位置,必要时调整画布矩形
在所有轴相互调整后,函数进行最终的对齐调整,确保轴与画布边缘正确对齐
| int QwtPlotLayoutEngine::canvasMargin | ( | int | axisPos | ) | const |
Get canvas margin for a specific axis / 获取特定轴的画布边距
| axisPos | Axis position (0-3) / 轴位置(0-3) |
| QwtPlotLayoutEngine::Dimensions QwtPlotLayoutEngine::layoutDimensions | ( | int | plotLayoutOptions, |
| const LayoutData & | layoutData, | ||
| const QRectF & | rect | ||
| ) | const |
Iteratively calculate the layout dimensions for a QwtPlot / 迭代计算QwtPlot的布局尺寸
This routine determines the exact space (in pixels) that every visual component of a QwtPlot—title, footer, and the four axes (X-top, X-bottom, Y-left, Y-right)—needs inside a given rectangle. Because the required size of one component affects the available space for all others (e.g. a taller horizontal axis shrinks the vertical axes, which may then wrap their labels and expand horizontally, and so on), the algorithm loops until the dimensions stabilize.
本函数在给定矩形区域内,精确地计算QwtPlot中每一个可视部件 (标题、页脚以及四个坐标轴:上、下、左、右)所占用的像素尺寸。 由于各部件相互影响(例如水平轴变高会压缩垂直轴,垂直轴标签换行 又可能使水平轴再次换行),因此采用迭代方式,直到所有尺寸不再变化。
| plotLayoutOptions | Layout options bitmask / 布局选项位掩码 |
| layoutData | Precalculated layout data / 预计算的布局数据 |
| rect | Available rectangle for layout / 布局的可用矩形区域 |
| QRectF QwtPlotLayoutEngine::layoutLegend | ( | int | plotLayoutOptions, |
| const LayoutData::LegendData & | legendData, | ||
| const QRectF & | rect, | ||
| const QSize & | legendHint | ||
| ) | const |
Calculate legend rectangle within available space / 在可用空间内计算图例矩形
Determines the optimal position and size for the legend based on the specified legend position and ratio constraints.
根据指定的图例位置和比例约束,确定图例的最佳位置和大小。
| plotLayoutOptions | Layout options bitmask / 布局选项位掩码 |
| legendData | Precalculated legend data / 预计算的图例数据 |
| rect | Available rectangle for layout / 布局的可用矩形区域 |
| legendHint | Preferred size hint for the legend / 图例的首选尺寸提示 |
| QwtPlot::LegendPosition QwtPlotLayoutEngine::legendPos | ( | ) | const |
Get the legend position / 获取图例位置
| double QwtPlotLayoutEngine::legendRatio | ( | ) | const |
Get the legend ratio / 获取图例比例
| void QwtPlotLayoutEngine::setAlignCanvas | ( | int | axisPos, |
| bool | on | ||
| ) |
Set canvas alignment to scale for a specific axis / 设置画布对齐到特定轴的刻度
| axisPos | Axis position (0-3) / 轴位置(0-3) |
| on | True to align canvas to scale / 为true时对齐画布到刻度 |
| void QwtPlotLayoutEngine::setCanvasMargin | ( | int | axisPos, |
| int | margin | ||
| ) |
Set canvas margin for a specific axis / 设置特定轴的画布边距
| axisPos | Axis position (0-3) / 轴位置(0-3) |
| margin | New canvas margin value / 新的画布边距值 |
| void QwtPlotLayoutEngine::setLegendPos | ( | QwtPlot::LegendPosition | pos | ) |
Set the legend position / 设置图例位置
| pos | New legend position / 新的图例位置 |
| void QwtPlotLayoutEngine::setLegendRatio | ( | double | ratio | ) |
Set the legend ratio / 设置图例比例
| ratio | New legend ratio value / 新的图例比例值 |
| void QwtPlotLayoutEngine::setSpacing | ( | unsigned int | spacing | ) |
Set spacing value / 设置间距值
| spacing | New spacing value in pixels / 新的间距值(像素) |
| unsigned int QwtPlotLayoutEngine::spacing | ( | ) | const |
Get spacing value / 获取间距值