Qwt User's Guide 6.1.2

- Main Page
- Related Pages
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Public Member Functions | Protected Member Functions | List of all members
QwtPlotLayout Class Reference

Layout engine for QwtPlot. More...

`#include <qwt_plot_layout.h>`

## Public Types
enum | Option { AlignScales = 0x01, IgnoreScrollbars = 0x02, IgnoreFrames = 0x04, IgnoreLegend = 0x08, IgnoreTitle = 0x10, IgnoreFooter = 0x20 }
typedef QFlags< Option > | Options
| Layout options.

## Public Member Functions
| QwtPlotLayout ()
| Constructor.
virtual | ~QwtPlotLayout ()
| Destructor.
void | setCanvasMargin (int margin, int axis=-1)
int | canvasMargin (int axis) const
void | setAlignCanvasToScales (bool)
| Set the align-canvas-to-axis-scales flag for all axes. More...
void | setAlignCanvasToScale (int axisId, bool)
bool | alignCanvasToScale (int axisId) const
void | setSpacing (int)
int | spacing () const
void | setLegendPosition (QwtPlot::LegendPosition pos, double ratio)
| Specify the position of the legend. More...
void | setLegendPosition (QwtPlot::LegendPosition pos)
| Specify the position of the legend. More...
QwtPlot::LegendPosition | legendPosition () const
void | setLegendRatio (double ratio)
double | legendRatio () const
virtual QSize | minimumSizeHint (const QwtPlot *) const
virtual void | activate (const QwtPlot *, const QRectF &rect, Options options=0x00)
| Recalculate the geometry of all components. More...
virtual void | invalidate ()
QRectF | titleRect () const
QRectF | footerRect () const
QRectF | legendRect () const
QRectF | scaleRect (int axis) const
QRectF | canvasRect () const

## Protected Member Functions
void | setTitleRect (const QRectF &)
| Set the geometry for the title. More...
void | setFooterRect (const QRectF &)
| Set the geometry for the footer. More...
void | setLegendRect (const QRectF &)
| Set the geometry for the legend. More...
void | setScaleRect (int axis, const QRectF &)
| Set the geometry for an axis. More...
void | setCanvasRect (const QRectF &)
| Set the geometry for the canvas. More...
QRectF | layoutLegend (Options options, const QRectF &) const
QRectF | alignLegend (const QRectF &canvasRect, const QRectF &legendRect) const
void | expandLineBreaks (Options options, const QRectF &rect, int &dimTitle, int &dimFooter, int dimAxes[QwtPlot::axisCnt]) const
void | alignScales (Options options, QRectF &canvasRect, QRectF scaleRect[QwtPlot::axisCnt]) const

## Detailed Description

Layout engine for QwtPlot.

It is used by the QwtPlot widget to organize its internal widgets or by QwtPlot::print() to render its content to a QPaintDevice like a QPrinter, QPixmap/QImage or QSvgRenderer.

See Also
  QwtPlot::setPlotLayout()

## Member Enumeration Documentation

enum QwtPlotLayout::Option

Options to configure the plot layout engine

See Also
  activate(), QwtPlotRenderer

Enumerator
AlignScales | Unused.
IgnoreScrollbars | Ignore the dimension of the scrollbars. There are no scrollbars, when the plot is not rendered to widgets.
IgnoreFrames | Ignore all frames.
IgnoreLegend | Ignore the legend.
IgnoreTitle | Ignore the title.
IgnoreFooter | Ignore the footer.

## Member Function Documentation

void QwtPlotLayout::activate | ( | const QwtPlot * | plot,
|  | const QRectF & | plotRect,
|  | Options | options = `0x00`
| ) |  |
| virtual

Recalculate the geometry of all components.

Parameters

  plot | Plot to be layout
  plotRect | Rectangle where to place the components
  options | Layout options

See Also
  invalidate(), titleRect(), footerRect() legendRect(), scaleRect(), canvasRect()

bool QwtPlotLayout::alignCanvasToScale | ( | int | axisId | ) | const

Return the align-canvas-to-axis-scales setting. The canvas may:

- extend beyond the axis scale ends to maximize its size
- align with the axis scale ends to control its size.

Parameters

  axisId | Axis index

Returns
  align-canvas-to-axis-scales setting

See Also
  setAlignCanvasToScale(), setAlignCanvasToScale(), setCanvasMargin()

QRectF QwtPlotLayout::alignLegend | ( | const QRectF & | canvasRect,
|  | const QRectF & | legendRect
| ) |  | const
| protected

Align the legend to the canvas

Parameters

  canvasRect | Geometry of the canvas
  legendRect | Maximum geometry for the legend

Returns
  Geometry for the aligned legend

void QwtPlotLayout::alignScales | ( | Options | options,
|  | QRectF & | canvasRect,
|  | QRectF | scaleRect[QwtPlot::axisCnt]
| ) |  | const
| protected

Align the ticks of the axis to the canvas borders using the empty corners.

Parameters

  options | Layout options
  canvasRect | Geometry of the canvas ( IN/OUT )
  scaleRect | Geometries of the scales ( IN/OUT )

See Also
  Options

int QwtPlotLayout::canvasMargin | ( | int | axisId | ) | const

Parameters

  axisId | Axis index

Returns
  Margin around the scale tick borders

See Also
  setCanvasMargin()

QRectF QwtPlotLayout::canvasRect | ( |  | ) | const

Returns
  Geometry for the canvas

See Also
  activate(), invalidate()

void QwtPlotLayout::expandLineBreaks | ( | Options | options,
|  | const QRectF & | rect,
|  | int & | dimTitle,
|  | int & | dimFooter,
|  | int | dimAxis[QwtPlot::axisCnt]
| ) |  | const
| protected

Expand all line breaks in text labels, and calculate the height of their widgets in orientation of the text.

Parameters

  options | Options how to layout the legend
  rect | Bounding rectangle for title, footer, axes and canvas.
  dimTitle | Expanded height of the title widget
  dimFooter | Expanded height of the footer widget
  dimAxis | Expanded heights of the axis in axis orientation.

See Also
  Options

QRectF QwtPlotLayout::footerRect | ( |  | ) | const

Returns
  Geometry for the footer

See Also
  activate(), invalidate()

void QwtPlotLayout::invalidate | ( |  | ) |
| virtual

Invalidate the geometry of all components.

See Also
  activate()

QRectF QwtPlotLayout::layoutLegend | ( | Options | options,
|  | const QRectF & | rect
| ) |  | const
| protected

Find the geometry for the legend

Parameters

  options | Options how to layout the legend
  rect | Rectangle where to place the legend

Returns
  Geometry for the legend

See Also
  Options

QwtPlot::LegendPosition QwtPlotLayout::legendPosition | ( |  | ) | const

Returns
  Position of the legend

See Also
  setLegendPosition(), QwtPlot::setLegendPosition(), QwtPlot::legendPosition()

double QwtPlotLayout::legendRatio | ( |  | ) | const

Returns
  The relative size of the legend in the plot.

See Also
  setLegendPosition()

QRectF QwtPlotLayout::legendRect | ( |  | ) | const

Returns
  Geometry for the legend

See Also
  activate(), invalidate()

QSize QwtPlotLayout::minimumSizeHint | ( | const QwtPlot * | plot | ) | const
| virtual

Returns
  Minimum size hint

Parameters

  plot | Plot widget

See Also
  QwtPlot::minimumSizeHint()

QRectF QwtPlotLayout::scaleRect | ( | int | axis | ) | const

Parameters

  axis | Axis index

Returns
  Geometry for the scale

See Also
  activate(), invalidate()

void QwtPlotLayout::setAlignCanvasToScale | ( | int | axisId,
|  | bool | on
| ) |  |

Change the align-canvas-to-axis-scales setting. The canvas may:

- extend beyond the axis scale ends to maximize its size,
- align with the axis scale ends to control its size.

The axisId parameter is somehow confusing as it identifies a border of the plot and not the axes, that are aligned. F.e when QwtPlot::yLeft is set, the left end of the the x-axes ( QwtPlot::xTop, QwtPlot::xBottom ) is aligned.

Parameters

  axisId | Axis index
  on | New align-canvas-to-axis-scales setting

See Also
  setCanvasMargin(), alignCanvasToScale(), setAlignCanvasToScales()

Warning
  In case of on == true canvasMargin() will have no effect

void QwtPlotLayout::setAlignCanvasToScales | ( | bool | on | ) |

Set the align-canvas-to-axis-scales flag for all axes.

Parameters

  on | True/False

See Also
  setAlignCanvasToScale(), alignCanvasToScale()

void QwtPlotLayout::setCanvasMargin | ( | int | margin,
|  | int | axis = `-1`
| ) |  |

Change a margin of the canvas. The margin is the space above/below the scale ticks. A negative margin will be set to -1, excluding the borders of the scales.

Parameters

  margin | New margin
  axis | One of QwtPlot::Axis. Specifies where the position of the margin. -1 means margin at all borders.

See Also
  canvasMargin()

Warning
  The margin will have no effect when alignCanvasToScale() is true

void QwtPlotLayout::setCanvasRect | ( | const QRectF & | rect | ) |
| protected

Set the geometry for the canvas.

This method is intended to be used from derived layouts overloading activate()

See Also
  canvasRect(), activate()

void QwtPlotLayout::setFooterRect | ( | const QRectF & | rect | ) |
| protected

Set the geometry for the footer.

This method is intended to be used from derived layouts overloading activate()

See Also
  footerRect(), activate()

void QwtPlotLayout::setLegendPosition | ( | QwtPlot::LegendPosition | pos,
|  | double | ratio
| ) |  |

Specify the position of the legend.

Parameters

  pos | The legend's position.
  ratio | Ratio between legend and the bounding rectangle of title, footer, canvas and axes. The legend will be shrunk if it would need more space than the given ratio. The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0 it will be reset to the default ratio. The default vertical/horizontal ratio is 0.33/0.5.

See Also
  QwtPlot::setLegendPosition()

void QwtPlotLayout::setLegendPosition | ( | QwtPlot::LegendPosition | pos | ) |

Specify the position of the legend.

Parameters

  pos | The legend's position. Valid values are `QwtPlot::LeftLegend`, `QwtPlot::RightLegend`, `QwtPlot::TopLegend`, `QwtPlot::BottomLegend`.

See Also
  QwtPlot::setLegendPosition()

void QwtPlotLayout::setLegendRatio | ( | double | ratio | ) |

Specify the relative size of the legend in the plot

Parameters

  ratio | Ratio between legend and the bounding rectangle of title, footer, canvas and axes. The legend will be shrunk if it would need more space than the given ratio. The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0 it will be reset to the default ratio. The default vertical/horizontal ratio is 0.33/0.5.

void QwtPlotLayout::setLegendRect | ( | const QRectF & | rect | ) |
| protected

Set the geometry for the legend.

This method is intended to be used from derived layouts overloading activate()

Parameters

  rect | Rectangle for the legend

See Also
  legendRect(), activate()

void QwtPlotLayout::setScaleRect | ( | int | axis,
|  | const QRectF & | rect
| ) |  |
| protected

Set the geometry for an axis.

This method is intended to be used from derived layouts overloading activate()

Parameters

  axis | Axis index
  rect | Rectangle for the scale

See Also
  scaleRect(), activate()

void QwtPlotLayout::setSpacing | ( | int | spacing | ) |

Change the spacing of the plot. The spacing is the distance between the plot components.

Parameters

  spacing | New spacing

See Also
  setCanvasMargin(), spacing()

void QwtPlotLayout::setTitleRect | ( | const QRectF & | rect | ) |
| protected

Set the geometry for the title.

This method is intended to be used from derived layouts overloading activate()

See Also
  titleRect(), activate()

int QwtPlotLayout::spacing | ( |  | ) | const

Returns
  Spacing

See Also
  margin(), setSpacing()

QRectF QwtPlotLayout::titleRect | ( |  | ) | const

Returns
  Geometry for the title

See Also
  activate(), invalidate()