QWT 7.0.1
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.
 
virtual ~QwtPlotLayout ()
 Destructor.
 
void setCanvasMargin (int margin, int axis=-1)
 Change a margin of the canvas.
 
int canvasMargin (int axisId) const
 
void setAlignCanvasToScales (bool)
 Set the align-canvas-to-axis-scales flag for all axes.
 
void setAlignCanvasToScale (int axisId, bool)
 Change the align-canvas-to-axis-scales setting.
 
bool alignCanvasToScale (int axisId) const
 Return the align-canvas-to-axis-scales setting.
 
void setSpacing (int)
 Change the spacing of the plot.
 
int spacing () const
 
void setLegendPosition (QwtPlot::LegendPosition pos, double ratio)
 Specify the position of the legend.
 
void setLegendPosition (QwtPlot::LegendPosition pos)
 Specify the position of the legend.
 
QwtPlot::LegendPosition legendPosition () const
 
void setLegendRatio (double ratio)
 Specify the relative size of the legend in the plot.
 
double legendRatio () const
 
virtual QSize minimumSizeHint (const QwtPlot *) const
 
virtual void activate (const QwtPlot *plot, const QRectF &plotRect, Options options=Options())
 Recalculate the geometry of all components./根据给定的外框矩形,重新计算并记录 QwtPlot 内所有子部件(标题、页脚、图例、4 条轴、画布)的几何位置。
 
virtual void invalidate ()
 Invalidate the geometry of all components.
 
QRectF titleRect () const
 
QRectF footerRect () const
 
QRectF legendRect () const
 
QRectF scaleRect (QwtAxisId) const
 
QRectF canvasRect () const
 

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

Member Function Documentation

◆ activate()

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

Recalculate the geometry of all components./根据给定的外框矩形,重新计算并记录 QwtPlot 内所有子部件(标题、页脚、图例、4 条轴、画布)的几何位置。

Parameters
plotPlot to be layout/待布局的 plot 对象
plotRectRectangle where to place the components/外部可用矩形(逻辑坐标,单位是像素)
optionsLayout options/布局选项,例如是否忽略图例、是否忽略某条轴等

结果全部写入 m_data->xxxRect,外部可通过 titleRect()/footerRect()/legendRect()/canvasRect()/scaleRect() 直接读取。

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

Reimplemented in QwtParasitePlotLayout.

◆ alignCanvasToScale()

bool QwtPlotLayout::alignCanvasToScale ( int  axisPos) 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
axisPosAxis position
Returns
align-canvas-to-axis-scales setting
See also
setAlignCanvasToScale(), setAlignCanvasToScale(), setCanvasMargin()

◆ canvasMargin()

int QwtPlotLayout::canvasMargin ( int  axisPos) const
Parameters
axisPosAxis position
Returns
Margin around the scale tick borders
See also
setCanvasMargin()

◆ canvasRect()

QRectF QwtPlotLayout::canvasRect ( ) const
Returns
Geometry for the canvas
See also
activate(), invalidate()

◆ doActivate()

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

QwtPlotLayout::activate的具体实现

Parameters
plotRect
options

◆ footerRect()

QRectF QwtPlotLayout::footerRect ( ) const
Returns
Geometry for the footer
See also
activate(), invalidate()

◆ invalidate()

void QwtPlotLayout::invalidate ( )
virtual

Invalidate the geometry of all components.

See also
activate()

◆ legendPosition()

QwtPlot::LegendPosition QwtPlotLayout::legendPosition ( ) const
Returns
Position of the legend
See also
setLegendPosition(), QwtPlot::setLegendPosition(), QwtPlot::legendPosition()

◆ legendRatio()

double QwtPlotLayout::legendRatio ( ) const
Returns
The relative size of the legend in the plot.
See also
setLegendPosition()

◆ legendRect()

QRectF QwtPlotLayout::legendRect ( ) const
Returns
Geometry for the legend
See also
activate(), invalidate()

◆ minimumSizeHint()

QSize QwtPlotLayout::minimumSizeHint ( const QwtPlot plot) const
virtual
Returns
Minimum size hint
Parameters
plotPlot widget
See also
QwtPlot::minimumSizeHint()

Reimplemented in QwtParasitePlotLayout.

◆ scaleRect()

QRectF QwtPlotLayout::scaleRect ( QwtAxisId  axisId) const
Parameters
axisIdAxis
Returns
Geometry for the scale
See also
activate(), invalidate()

◆ setAlignCanvasToScale()

void QwtPlotLayout::setAlignCanvasToScale ( int  axisPos,
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 QwtAxis::YLeft is set, the left end of the the x-axes ( QwtAxis::XTop, QwtAxis::XBottom ) is aligned.

设置画布是否与坐标轴刻度对齐。画布有两种表现方式:

  • 延伸:画布可超出轴刻度端点,以最大化绘图区域;
  • 对齐:画布严格对齐轴刻度端点,以便精确控制大小。

【注意】参数 axisId 实际指代的是“绘图边框”,而非被对齐的轴本身。例如传入 QwtAxis::YLeft 时,真正被对齐的是两条 X 轴 (QwtAxis::XTop 与 QwtAxis::XBottom)的左端。

Parameters
axisIdAxis index
onNew align-canvas-to-axis-scales setting
See also
setCanvasMargin(), alignCanvasToScale(), setAlignCanvasToScales()
Warning
In case of on == true canvasMargin() will have no effect

◆ setAlignCanvasToScales()

void QwtPlotLayout::setAlignCanvasToScales ( bool  on)

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

Parameters
onTrue/False
See also
setAlignCanvasToScale(), alignCanvasToScale()

◆ setCanvasMargin()

void QwtPlotLayout::setCanvasMargin ( int  margin,
int  axisPos = -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.

设置画布的边距(margin)。这个边距是指 坐标轴刻度线与画布边缘之间的空间

正数:在刻度线外增加空白区域 负数:会被设置为-1,表示排除坐标轴边框的影响 0:紧贴刻度线

Parameters
marginNew margin
axisPosOne of QwtAxis::Position. 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

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

Specify the position of the legend.

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

◆ setLegendPosition() [2/2]

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

Specify the position of the legend.

Parameters
posThe legend's position.
ratioRatio 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()

◆ setLegendRatio()

void QwtPlotLayout::setLegendRatio ( double  ratio)

Specify the relative size of the legend in the plot.

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

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

Change the spacing of the plot.

The spacing is the distance between the plot components.

Parameters
spacingNew spacing
See also
setCanvasMargin(), spacing()

◆ 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
Returns
Spacing
See also
margin(), setSpacing()

◆ titleRect()

QRectF QwtPlotLayout::titleRect ( ) const
Returns
Geometry for the title
See also
activate(), invalidate()

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