QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
Loading...
Searching...
No Matches
Classes | 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>

Inheritance diagram for QwtPlotLayout:
QwtParasitePlotLayout

Classes

class  PrivateData
 

Public Types

enum  Option {
  AlignScales = 0x01 , IgnoreScrollbars = 0x02 , IgnoreFrames = 0x04 , IgnoreLegend = 0x08 ,
  IgnoreTitle = 0x10 , IgnoreFooter = 0x20
}
 Options to configure the plot layout engine. More...
 

Public Member Functions

 QwtPlotLayout ()
 Constructor.
 
void setCanvasMargin (int margin, int axis=-1)
 Set the canvas margin for a specific axis position.
 
int canvasMargin (int axisId) const
 Get the canvas margin for a specific axis position.
 
void setAlignCanvasToScales (bool)
 Set the align-canvas-to-axis-scales flag for all axes.
 
void setAlignCanvasToScale (int axisId, bool)
 Set the align-canvas-to-axis-scales setting for a specific axis.
 
bool alignCanvasToScale (int axisId) const
 Get the align-canvas-to-axis-scales setting for a specific axis.
 
void setSpacing (int)
 Set the spacing between plot components.
 
int spacing () const
 Get the spacing between plot components.
 
void setLegendPosition (QwtPlot::LegendPosition pos, double ratio)
 Set the legend position with a specified ratio.
 
void setLegendPosition (QwtPlot::LegendPosition pos)
 Set the legend position.
 
QwtPlot::LegendPosition legendPosition () const
 Get the legend position.
 
void setLegendRatio (double ratio)
 Set the relative size of the legend in the plot.
 
double legendRatio () const
 Get the relative size of the legend in the plot.
 
virtual QSize minimumSizeHint (const QwtPlot *) const
 Calculate the minimum size hint for the plot.
 
virtual void activate (const QwtPlot *plot, const QRectF &plotRect, Options options=Options())
 Recalculate the geometry of all plot components.
 
virtual void invalidate ()
 Invalidate the geometry of all components.
 
QRectF titleRect () const
 Get the geometry for the title.
 
QRectF footerRect () const
 Get the geometry for the footer.
 
QRectF legendRect () const
 Get the geometry for the legend.
 
QRectF scaleRect (QwtAxisId) const
 Get the geometry for a scale axis.
 
QRectF canvasRect () const
 Get the geometry for the canvas.
 

Protected Member Functions

void setTitleRect (const QRectF &)
 Set the geometry for the title.
 
void setFooterRect (const QRectF &)
 Set the geometry for the footer.
 
void setLegendRect (const QRectF &)
 Set the geometry for the legend.
 
void setScaleRect (QwtAxisId, const QRectF &)
 Set the geometry for an axis.
 
void setCanvasRect (const QRectF &)
 Set the geometry for the canvas.
 
QwtPlotLayoutEnginelayoutEngine ()
 
void doActivate (const QwtPlot *plot, const QRectF &plotRect, Options options=Options())
 Concrete implementation of QwtPlotLayout::activate.
 

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

◆ 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.

Constructor & Destructor Documentation

◆ QwtPlotLayout()

QwtPlotLayout::QwtPlotLayout ( )
explicit

Constructor.

Creates a new QwtPlotLayout instance with default settings. The legend position is set to BottomLegend and canvas margin is set to -1.

Destructor

Destroys the QwtPlotLayout instance and releases all allocated resources.

Member Function Documentation

◆ activate()

void QwtPlotLayout::activate ( const QwtPlot plot,
const QRectF &  plotRect,
Options  options = Options() 
)
virtual

Recalculate the geometry of all plot components.

Parameters
plotThe plot widget to layout
plotRectThe rectangle where to place the components (in pixels)
optionsLayout options (e.g., ignore legend, ignore specific axes)

Calculates and stores the geometry for all sub-components (title, footer, legend, 4 axes, and canvas). Results are stored internally and can be retrieved via titleRect(), footerRect(), legendRect(), canvasRect(), and scaleRect().

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

Reimplemented in QwtParasitePlotLayout.

◆ alignCanvasToScale()

bool QwtPlotLayout::alignCanvasToScale ( int  axisPos) const

Get the align-canvas-to-axis-scales setting for a specific axis.

Parameters
axisPosAxis position (QwtAxis::Position)
Returns
True if canvas is aligned to scale ends, false if it extends beyond
See also
setAlignCanvasToScale(), setAlignCanvasToScales(), setCanvasMargin()

◆ canvasMargin()

int QwtPlotLayout::canvasMargin ( int  axisPos) const

Get the canvas margin for a specific axis position.

Parameters
axisPosAxis position (QwtAxis::Position)
Returns
The margin around the scale tick borders for the specified axis
See also
setCanvasMargin()

◆ canvasRect()

QRectF QwtPlotLayout::canvasRect ( ) const

Get the geometry for the canvas.

Returns
The canvas rectangle
See also
activate(), invalidate(), setCanvasRect()

◆ doActivate()

void QwtPlotLayout::doActivate ( const QwtPlot plot,
const QRectF &  plotRect,
Options  options = Options() 
)
protected

Concrete implementation of QwtPlotLayout::activate.

Parameters
plotRect
options

◆ footerRect()

QRectF QwtPlotLayout::footerRect ( ) const

Get the geometry for the footer.

Returns
The footer rectangle
See also
activate(), invalidate(), setFooterRect()

◆ invalidate()

void QwtPlotLayout::invalidate ( )
virtual

Invalidate the geometry of all components.

Resets all geometry rectangles (title, footer, legend, canvas, and scales) to empty rectangles. Must call activate() to recalculate geometries.

See also
activate()

◆ legendPosition()

QwtPlot::LegendPosition QwtPlotLayout::legendPosition ( ) const

Get the legend position.

Returns
The current legend position
See also
setLegendPosition(), QwtPlot::setLegendPosition(), QwtPlot::legendPosition()

◆ legendRatio()

double QwtPlotLayout::legendRatio ( ) const

Get the relative size of the legend in the plot.

Returns
The legend ratio value
See also
setLegendRatio(), setLegendPosition()

◆ legendRect()

QRectF QwtPlotLayout::legendRect ( ) const

Get the geometry for the legend.

Returns
The legend rectangle
See also
activate(), invalidate(), setLegendRect()

◆ minimumSizeHint()

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

Calculate the minimum size hint for the plot.

Parameters
plotThe plot widget to calculate size hint for
Returns
The minimum size hint
See also
QwtPlot::minimumSizeHint()

Reimplemented in QwtParasitePlotLayout.

◆ scaleRect()

QRectF QwtPlotLayout::scaleRect ( QwtAxisId  axisId) const

Get the geometry for a scale axis.

Parameters
axisIdAxis identifier
Returns
The scale rectangle for the specified axis, or empty QRectF if invalid
See also
activate(), invalidate(), setScaleRect()

◆ setAlignCanvasToScale()

void QwtPlotLayout::setAlignCanvasToScale ( int  axisPos,
bool  on 
)

Set the align-canvas-to-axis-scales setting for a specific axis.

Parameters
axisPosAxis position. This identifies a border of the plot. For example, QwtAxis::YLeft aligns the left end of X-axes.
onTrue to align canvas to scales, false to extend beyond scale ends

The canvas may either extend beyond the axis scale ends to maximize its size, or align with the axis scale ends to control its size.

Note
When on is true, canvasMargin() has no effect
See also
setAlignCanvasToScales(), alignCanvasToScale(), setCanvasMargin()

◆ setAlignCanvasToScales()

void QwtPlotLayout::setAlignCanvasToScales ( bool  on)

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

Parameters
onTrue to align canvas to scales, false otherwise
See also
setAlignCanvasToScale(), alignCanvasToScale()

◆ setCanvasMargin()

void QwtPlotLayout::setCanvasMargin ( int  margin,
int  axisPos = -1 
)

Set the canvas margin for a specific axis position.

Parameters
marginThe margin value. A negative margin (-1) excludes scale borders. Positive values add space between scale ticks and canvas edge. 0 means tight against tick marks.
axisPosAxis position (QwtAxis::Position). Use -1 to apply to all axes.

The margin is the space above/below the scale ticks. When alignCanvasToScale() is true, the margin has no effect.

See also
canvasMargin(), setAlignCanvasToScale()

◆ setCanvasRect()

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

◆ setFooterRect()

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

◆ setLegendPosition() [1/2]

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

Set the legend position.

Parameters
posThe legend position. Valid values are QwtPlot::LeftLegend, QwtPlot::RightLegend, QwtPlot::TopLegend, QwtPlot::BottomLegend.
See also
legendPosition(), QwtPlot::setLegendPosition()

◆ setLegendPosition() [2/2]

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

Set the legend position with a specified ratio.

Parameters
posThe legend position (LeftLegend, RightLegend, TopLegend, BottomLegend)
ratioRatio between legend and the bounding rectangle of title, footer, canvas and axes. Limited to (0.0, 1.0]. Values <= 0.0 use defaults. Default vertical/horizontal ratio is 0.33/0.5.
See also
legendPosition(), setLegendRatio(), QwtPlot::setLegendPosition()

◆ setLegendRatio()

void QwtPlotLayout::setLegendRatio ( double  ratio)

Set the relative size of the legend in the plot.

Parameters
ratioRatio between legend and the bounding rectangle of title, footer, canvas and axes. Limited to (0.0, 1.0]. Values <= 0.0 use defaults. Default vertical/horizontal ratio is 0.33/0.5.
See also
legendRatio(), setLegendPosition()

◆ setLegendRect()

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
rectRectangle for the legend
See also
legendRect(), activate()

◆ setScaleRect()

void QwtPlotLayout::setScaleRect ( QwtAxisId  axisId,
const QRectF &  rect 
)
protected

Set the geometry for an axis.

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

Parameters
axisIdAxis
rectRectangle for the scale
See also
scaleRect(), activate()

◆ setSpacing()

void QwtPlotLayout::setSpacing ( int  spacing)

Set the spacing between plot components.

Parameters
spacingThe spacing value in pixels. Must be >= 0.
See also
spacing(), setCanvasMargin()

◆ setTitleRect()

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

◆ spacing()

int QwtPlotLayout::spacing ( ) const

Get the spacing between plot components.

Returns
The spacing value in pixels
See also
setSpacing(), canvasMargin()

◆ titleRect()

QRectF QwtPlotLayout::titleRect ( ) const

Get the geometry for the title.

Returns
The title rectangle
See also
activate(), invalidate(), setTitleRect()

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