QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
QwtPlotLayoutEngine Class Reference

Layout engine for QwtPlot components. More...

#include <qwt_plot_layout_engine.h>

Classes

struct  Dimensions
 Structure holding dimension values for layout calculation. More...
 
class  LayoutData
 Data structure for layout calculation. More...
 

Public Member Functions

 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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ QwtPlotLayoutEngine()

QwtPlotLayoutEngine::QwtPlotLayoutEngine ( )

Default constructor for QwtPlotLayoutEngine.

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

Member Function Documentation

◆ alignCanvas()

bool QwtPlotLayoutEngine::alignCanvas ( int  axisPos) const

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

Parameters
[in]axisPosAxis position (0-3)
Returns
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.

Parameters
[in]legendHintPreferred size hint for the legend
[in]canvasRectCanvas rectangle
[in]legendRectInitial legend rectangle
Returns
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.

Parameters
[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.

Parameters
[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.

Parameters
[in]axisPosAxis position (0-3)
Returns
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.

Parameters
[in]plotLayoutOptionsLayout options bitmask
[in]layoutDataPrecalculated layout data
[in]rectAvailable rectangle for layout
Returns
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.

Parameters
[in]plotLayoutOptionsLayout options bitmask
[in]legendDataPrecalculated legend data
[in]rectAvailable rectangle for layout
[in]legendHintPreferred size hint for the legend
Returns
Calculated legend rectangle

◆ legendPos()

QwtPlot::LegendPosition QwtPlotLayoutEngine::legendPos ( ) const

Get the legend position.

Returns
Current legend position

◆ legendRatio()

double QwtPlotLayoutEngine::legendRatio ( ) const

Get the legend ratio.

Returns
Current legend ratio value

◆ setAlignCanvas()

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

Set canvas alignment to scale for a specific axis position.

Parameters
[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.

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

◆ setLegendPos()

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

Set the legend position.

Parameters
[in]posNew legend position

◆ setLegendRatio()

void QwtPlotLayoutEngine::setLegendRatio ( double  ratio)

Set the legend ratio.

Parameters
[in]ratioNew legend ratio value

◆ setSpacing()

void QwtPlotLayoutEngine::setSpacing ( unsigned int  spacing)

Set spacing value.

Parameters
[in]spacingNew spacing value in pixels

◆ spacing()

unsigned int QwtPlotLayoutEngine::spacing ( ) const

Get spacing value.

Returns
Current spacing value in pixels

The documentation for this class was generated from the following files: