|
QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
|
Layout engine for QwtPlot components 更多...
#include <qwt_plot_layout_engine.h>
类 | |
| struct | Dimensions |
| Structure holding dimension values for layout calculation 更多... | |
| class | LayoutData |
| Data structure for layout calculation 更多... | |
Public 成员函数 | |
| QwtPlotLayoutEngine () | |
| Default constructor for 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 |
| Align scale rectangles to canvas boundaries | |
| Dimensions | layoutDimensions (int plotLayoutOptions, const LayoutData &layoutData, const QRectF &rect) const |
| Iteratively calculate the layout dimensions for a 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 position | |
| bool | alignCanvas (int axisPos) const |
| Check if canvas is aligned to scale for a specific axis position | |
| void | setCanvasMargin (int axisPos, int margin) |
| Set canvas margin for a specific axis position | |
| int | canvasMargin (int axisPos) const |
| Get canvas margin for a specific axis position | |
| 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 | |
Layout engine for QwtPlot components
Originally a private class in QwtPlotLayout, previously written as class LayoutEngine in qwt_plot_layout.cpp. It was extracted as a public class because other layouts need to use it.
| QwtPlotLayoutEngine::QwtPlotLayoutEngine | ( | ) |
Default constructor for QwtPlotLayoutEngine
Initializes the layout engine with default values: legend position Bottom, legend ratio 1.0, spacing 5 pixels.
| bool QwtPlotLayoutEngine::alignCanvas | ( | int | axisPos | ) | const |
Check if canvas is aligned to scale for a specific axis position
| [in] | axisPos | Axis position (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.
| [in] | legendHint | Preferred size hint for the legend |
| [in] | canvasRect | Canvas rectangle |
| [in] | 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. This function handles the complex layout calculation involving multiple axes and canvas spatial coordination.
| [in] | plotLayoutOptions | Layout options bitmask |
| [in] | layoutData | Precalculated layout data |
| [out] | canvasRect | Canvas rectangle (may be modified) |
| [out] | scaleRect | Array of scale rectangles (will be modified) |
For X axes (horizontal): Check the influence of left and right Y axes Calculate left/right offsets, considering axis start/end distances and backbone offsets Adjust X axis rectangle position, and canvas rectangle if necessary
For Y axes (vertical): Check the influence of bottom and top X axes Calculate top/bottom offsets, considering axis start/end distances and backbone offsets Adjust Y axis rectangle position, and canvas rectangle if necessary
When the axis needs more space than available, the function adjusts the canvas rectangle
After mutual adjustment of all axes, the function performs final alignment to ensure axes are properly aligned with canvas edges
| void QwtPlotLayoutEngine::alignScalesToCanvas | ( | int | plotLayoutOptions, |
| const LayoutData & | layoutData, | ||
| const QRectF & | canvasRect, | ||
| QRectF | scaleRect[QwtAxis::AxisPositions] | ||
| ) | const |
Align scale rectangles to canvas boundaries
Adjusts the positions of scale rectangles to align with canvas boundaries, taking into account border distances and tick offsets. Unlike alignScales, this function does not modify the canvas rectangle.
| [in] | plotLayoutOptions | Layout options bitmask |
| [in] | layoutData | Precalculated layout data |
| [in] | canvasRect | Canvas rectangle |
| [out] | scaleRect | Array of scale rectangles (will be modified) |
For X axes (horizontal): Check the influence of left and right Y axes Calculate left/right offsets, considering axis start/end distances and backbone offsets Adjust X axis rectangle position, and canvas rectangle if necessary
For Y axes (vertical): Check the influence of bottom and top X axes Calculate top/bottom offsets, considering axis start/end distances and backbone offsets Adjust Y axis rectangle position, and canvas rectangle if necessary
After mutual adjustment of all axes, the function performs final alignment to ensure axes are properly aligned with canvas edges
| int QwtPlotLayoutEngine::canvasMargin | ( | int | axisPos | ) | const |
Get canvas margin for a specific axis position
| [in] | axisPos | Axis position (0-3) |
| QwtPlotLayoutEngine::Dimensions QwtPlotLayoutEngine::layoutDimensions | ( | int | plotLayoutOptions, |
| const LayoutData & | layoutData, | ||
| const QRectF & | rect | ||
| ) | const |
Iteratively calculate the layout dimensions for a QwtPlot
Determines the exact space (in pixels) that every visual component of a QwtPlot—title, footer, and the four axes—needs inside a given rectangle. Because the required size of one component affects the available space for all others, the algorithm loops until the dimensions stabilize.
| [in] | plotLayoutOptions | Layout options bitmask |
| [in] | layoutData | Precalculated layout data |
| [in] | 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.
| [in] | plotLayoutOptions | Layout options bitmask |
| [in] | legendData | Precalculated legend data |
| [in] | rect | Available rectangle for layout |
| [in] | 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 position
| [in] | axisPos | Axis position (0-3) |
| [in] | on | True to align canvas to scale |
| void QwtPlotLayoutEngine::setCanvasMargin | ( | int | axisPos, |
| int | margin | ||
| ) |
Set canvas margin for a specific axis position
| [in] | axisPos | Axis position (0-3) |
| [in] | margin | New canvas margin value |
| void QwtPlotLayoutEngine::setLegendPos | ( | QwtPlot::LegendPosition | pos | ) |
Set the legend position
| [in] | pos | New legend position |
| void QwtPlotLayoutEngine::setLegendRatio | ( | double | ratio | ) |
Set the legend ratio
| [in] | ratio | New legend ratio value |
| void QwtPlotLayoutEngine::setSpacing | ( | unsigned int | spacing | ) |
Set spacing value
| [in] | spacing | New spacing value in pixels |
| unsigned int QwtPlotLayoutEngine::spacing | ( | ) | const |
Get spacing value