|
QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
|
Helpers for the corners where perpendicular scale backbones meet 更多...
类 | |
| struct | Targets |
| Target positions of the perpendicular backbones at one corner 更多... | |
函数 | |
| QWT_EXPORT void | cornerAxes (QwtAxisId axisId, QwtAxisId &startAxis, QwtAxisId &endAxis) |
| The perpendicular axes sharing the start/end corner of an axis | |
| QWT_EXPORT qreal | nearEdgeShift (QwtAxisId axisId) |
| Logical offset of the near band edge from the scale position | |
| QWT_EXPORT QwtScaleDraw::CornerMiter | miterFlags (const QwtPlot *plot, QwtAxisId axisId) |
| Compute the corner miter flags for an axis of a plot | |
| QWT_EXPORT Targets | widgetTargetPositions (const QwtPlot *plot, QwtAxisId axisId) |
| Target positions derived from the axis widgets of the whole plot family | |
| QWT_EXPORT Targets | layoutTargetPositions (const QwtPlot *plot, QwtAxisId axisId) |
| Target positions derived from the plot layout (for QwtPlotRenderer) | |
| QWT_EXPORT void | widgetExtensions (const QwtPlot *plot, QwtAxisId axisId, qreal devicePixelRatio, int &startExtension, int &endExtension) |
| Logical pixels an axis widget must reserve at its ends for the miter | |
Helpers for the corners where perpendicular scale backbones meet
When two perpendicular axes are visible, their backbones should intersect at the shared canvas corner instead of ending in a diagonal step. QwtScaleDraw extends (miters) the backbone into the corner for this purpose. These helpers answer the questions around that extension:
Parasite plots share the canvas of their host and stack their axis bands outside of the bands of the host, so the perpendicular band adjacent to the canvas may belong to any plot of the family. The target is the near edge of that innermost band - the band a border tick sits on. Bands stacked farther out are not crossed: extending a backbone to them would draw long lines through the whole axis stack and close the corners of unrelated bands.
All positions are in logical coordinates of the plot the axis belongs to; qQNaN() means "no corner at this end".
| void QwtScaleCorner::cornerAxes | ( | QwtAxisId | axisId, |
| QwtAxisId & | startAxis, | ||
| QwtAxisId & | endAxis | ||
| ) |
The perpendicular axes sharing the start/end corner of an axis
| axisId | Axis | |
| [out] | startAxis | Perpendicular axis at the start of the scale |
| [out] | endAxis | Perpendicular axis at the end of the scale |
| QwtScaleCorner::Targets QwtScaleCorner::layoutTargetPositions | ( | const QwtPlot * | plot, |
| QwtAxisId | axisId | ||
| ) |
Target positions derived from the plot layout (for QwtPlotRenderer)
Compute where the backbone miter should reach, from the plot layout
| plot | Plot the axis belongs to |
| axisId | Axis |
Variant of widgetTargetPositions() for QwtPlotRenderer: the renderer activates the plot layout for the paint device and positions the scales from the layout rectangles, so the widget geometries are not a reliable source here. Stacked parasite axes are not rendered into documents and are ignored. The plot layout must be activated when calling.
| QwtScaleDraw::CornerMiter QwtScaleCorner::miterFlags | ( | const QwtPlot * | plot, |
| QwtAxisId | axisId | ||
| ) |
Compute the corner miter flags for an axis of a plot
| plot | Plot the axis belongs to |
| axisId | Axis |
A corner exists when a perpendicular axis is visible and paints a backbone - in the plot itself or anywhere in its family (the host and the sibling parasites sharing the canvas).
| qreal QwtScaleCorner::nearEdgeShift | ( | QwtAxisId | axisId | ) |
Logical offset of the near band edge from the scale position
Added to a band position before rounding it to device pixels, and subtracted again afterwards: the near edge of a top/left backbone band is the last device pixel of its logical pixel, while the near edge of a bottom/right band is the first one.
| axisId | Axis the backbone band belongs to |
The near ( canvas side ) edge of a top/left backbone band is the last device pixel of the logical pixel of the scale position, while the near edge of a bottom/right band is the first one: rounding position + shift to device pixels and subtracting the shift again yields the near edge for both cases.
| void QwtScaleCorner::widgetExtensions | ( | const QwtPlot * | plot, |
| QwtAxisId | axisId, | ||
| qreal | devicePixelRatio, | ||
| int & | startExtension, | ||
| int & | endExtension | ||
| ) |
Logical pixels an axis widget must reserve at its ends for the miter
Compute how much an axis widget has to reserve for the corner miter
| plot | Plot the axis belongs to | |
| axisId | Axis | |
| devicePixelRatio | Device pixel ratio of the axis widget | |
| [out] | startExtension | Logical pixels to reserve at the start of the scale |
| [out] | endExtension | Logical pixels to reserve at the end of the scale |
QwtScaleWidget clips everything painted outside of its rectangle, so a backbone miter reaching the perpendicular backbone is only visible when the widget covers the corner pixels. The extensions are the gap between the widget borders and the outer edge of the perpendicular backbone band the miter reaches, rounded up to whole logical pixels. The caller grows the widget rectangle accordingly and passes the same values to QwtScaleWidget::setCornerExtension(), which keeps the scale span unchanged by absorbing them into the border distances.
| QwtScaleCorner::Targets QwtScaleCorner::widgetTargetPositions | ( | const QwtPlot * | plot, |
| QwtAxisId | axisId | ||
| ) |
Target positions derived from the axis widgets of the whole plot family
Compute where the backbone miter should reach, from the axis widgets
| plot | Plot the axis belongs to |
| axisId | Axis |
The targets are derived from the geometry and scale draw positions of the perpendicular axis widgets of the whole plot family. Per end the target is the near edge of the innermost band - the one closest to the canvas, where a border tick sits. Bands stacked farther out are not crossed. Call after the plot layout has been applied to the widgets of the family.