QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
| Public 成员函数 | 所有成员列表
QwtPlotLayoutEngine类 参考

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::QwtPlotLayoutEngine ( )

Default constructor for QwtPlotLayoutEngine

Initializes the layout engine with default values: legend position Bottom, legend ratio 1.0, spacing 5 pixels.

成员函数说明

◆ alignCanvas()

bool QwtPlotLayoutEngine::alignCanvas ( int  axisPos) const

Check if canvas is aligned to scale for a specific axis position

参数
[in]axisPosAxis position (0-3)
返回
True if canvas is aligned to scale

◆ alignLegend()

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]legendHintPreferred size hint for the legend
[in]canvasRectCanvas rectangle
[in]legendRectInitial legend rectangle
返回
Aligned legend rectangle

◆ alignScales()

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]plotLayoutOptionsLayout options bitmask
[in]layoutDataPrecalculated layout data
[out]canvasRectCanvas rectangle (may be modified)
[out]scaleRectArray of scale rectangles (will be modified)
  1. Initialize backbone offset First calculate the backbone offset for each axis, which consists of:
  • Add canvas margin if not aligning canvas to scale
  • Add canvas content margins if not ignoring frames
  1. Handle the mutual influence of X and Y axes Iterate all axis positions and handle the spatial interaction between X and Y axes:

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

◆ alignScalesToCanvas()

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]plotLayoutOptionsLayout options bitmask
[in]layoutDataPrecalculated layout data
[in]canvasRectCanvas rectangle
[out]scaleRectArray of scale rectangles (will be modified)
  1. Initialize backbone offset First calculate the backbone offset for each axis, which consists of:
  • Add canvas margin if not aligning canvas to scale
  • Add canvas content margins if not ignoring frames
  1. Handle the mutual influence of X and Y axes Iterate all axis positions and handle the spatial interaction between X and Y axes:

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

◆ canvasMargin()

int QwtPlotLayoutEngine::canvasMargin ( int  axisPos) const

Get canvas margin for a specific axis position

参数
[in]axisPosAxis position (0-3)
返回
Canvas margin value

◆ layoutDimensions()

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]plotLayoutOptionsLayout options bitmask
[in]layoutDataPrecalculated layout data
[in]rectAvailable rectangle for layout
返回
Dimensions structure with calculated sizes

◆ layoutLegend()

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]plotLayoutOptionsLayout options bitmask
[in]legendDataPrecalculated legend data
[in]rectAvailable rectangle for layout
[in]legendHintPreferred size hint for the legend
返回
Calculated legend rectangle

◆ legendPos()

QwtPlot::LegendPosition QwtPlotLayoutEngine::legendPos ( ) const

Get the legend position

返回
Current legend position

◆ legendRatio()

double QwtPlotLayoutEngine::legendRatio ( ) const

Get the legend ratio

返回
Current legend ratio value

◆ setAlignCanvas()

void QwtPlotLayoutEngine::setAlignCanvas ( int  axisPos,
bool  on 
)

Set canvas alignment to scale for a specific axis position

参数
[in]axisPosAxis position (0-3)
[in]onTrue to align canvas to scale

◆ setCanvasMargin()

void QwtPlotLayoutEngine::setCanvasMargin ( int  axisPos,
int  margin 
)

Set canvas margin for a specific axis position

参数
[in]axisPosAxis position (0-3)
[in]marginNew canvas margin value

◆ setLegendPos()

void QwtPlotLayoutEngine::setLegendPos ( QwtPlot::LegendPosition  pos)

Set the legend position

参数
[in]posNew legend position

◆ setLegendRatio()

void QwtPlotLayoutEngine::setLegendRatio ( double  ratio)

Set the legend ratio

参数
[in]ratioNew legend ratio value

◆ setSpacing()

void QwtPlotLayoutEngine::setSpacing ( unsigned int  spacing)

Set spacing value

参数
[in]spacingNew spacing value in pixels

◆ spacing()

unsigned int QwtPlotLayoutEngine::spacing ( ) const

Get spacing value

返回
Current spacing value in pixels

该类的文档由以下文件生成: