QwtPlotShapeItem(3)

πŸ’… QwtPlotShapeItem β€” the QwtPlotShapeItem(3) page, Library Functions Manual, bestie edition πŸŽ€

okay so. hi. welcome to QwtPlotShapeItem(3) from the Library Functions Manual, part one of two, and I need you to sit down because this class is gorgeous. it's giving "I contain an entire vibe inside a QPainterPath" energy and I am obsessed. ✨


🌸 NAME 🌸

QwtPlotShapeItem β€” a plot item that literally displays any graphical shape you want, as long as that shape can be defined by a QPainterPath. that's it. that's the whole thing. iconic. πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <qwt_plot_shapeitem.h>

Inherits QwtPlotItem. yes, she has a mother. we respect her lineage. πŸ‘‘

✨ Public Types ✨

  • enum PaintAttribute { ClipPolygons = 0x01 }
  • enum LegendMode { LegendShape, LegendColor } β€” the mode that controls how to display the item on the legend, iykyk
  • typedef QFlags< PaintAttribute > PaintAttributes

🌈 Public Types inherited from QwtPlotItem

  • enum RttiValues { Rtti_PlotItem = 0, Rtti_PlotGrid, Rtti_PlotScale, Rtti_PlotLegend, Rtti_PlotMarker, Rtti_PlotCurve, Rtti_PlotSpectroCurve, Rtti_PlotIntervalCurve, Rtti_PlotHistogram, Rtti_PlotSpectrogram, Rtti_PlotGraphic, Rtti_PlotTradingCurve, Rtti_PlotBarChart, Rtti_PlotMultiBarChart, Rtti_PlotShape, Rtti_PlotTextLabel, Rtti_PlotZone, Rtti_PlotVectorField, Rtti_PlotUserItem = 1000 } β€” runtime type information, so the item knows what it is (main character energy, honestly)
  • enum ItemAttribute { Legend = 0x01, AutoScale = 0x02, Margins = 0x04 } β€” Plot Item Attributes
  • enum ItemInterest { ScaleInterest = 0x01, LegendInterest = 0x02 } β€” Plot Item Interests
  • enum RenderHint { RenderAntialiased = 0x1 } β€” render hints, so your edges don't look crusty
  • typedef QFlags< ItemAttribute > ItemAttributes
  • typedef QFlags< ItemInterest > ItemInterests
  • typedef QFlags< RenderHint > RenderHints

🫢 Public Member Functions 🫢

  • QwtPlotShapeItem (const QString &title=QString()) β€” constructor ✨
  • QwtPlotShapeItem (const QwtText &title) β€” constructor, but the fancy text version ✨
  • virtual ~QwtPlotShapeItem () β€” destructor πŸ’€
  • void setPaintAttribute (PaintAttribute, bool on=true)
  • bool testPaintAttribute (PaintAttribute) const
  • void setLegendMode (LegendMode)
  • LegendMode legendMode () const
  • void setRect (const QRectF &) β€” sets a path built from a rectangle
  • void setPolygon (const QPolygonF &) β€” sets a path built from a polygon
  • void setShape (const QPainterPath &) β€” sets the shape that's gonna be displayed
  • QPainterPath shape () const
  • void setPen (const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
  • void setPen (const QPen &) β€” assigns a pen. go off, pen queen πŸ–ŠοΈ
  • QPen pen () const
  • void setBrush (const QBrush &)
  • QBrush brush () const
  • void setRenderTolerance (double) β€” sets the tolerance for the weeding optimization
  • double renderTolerance () const
  • virtual QRectF boundingRect () const override β€” the bounding rectangle of the shape
  • virtual void draw (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const override
  • virtual QwtGraphic legendIcon (int index, const QSizeF &) const override
  • virtual int rtti () const override

πŸ’œ Public Member Functions inherited from QwtPlotItem

  • QwtPlotItem ()
  • QwtPlotItem (const QString &title)
  • QwtPlotItem (const QwtText &title)
  • virtual ~QwtPlotItem () β€” destroy the QwtPlotItem
  • void attach (QwtPlot *plot) β€” attaches the item to a plot
  • void detach () β€” this method detaches a QwtPlotItem from any QwtPlot it has been associated with. breakup era 😭
  • QwtPlot * plot () const β€” returns the attached plot
  • void setTitle (const QString &title)
  • void setTitle (const QwtText &title)
  • const QwtText & title () const
  • void setItemAttribute (ItemAttribute, bool on=true)
  • bool testItemAttribute (ItemAttribute) const
  • void setItemInterest (ItemInterest, bool on=true)
  • bool testItemInterest (ItemInterest) const
  • void setRenderHint (RenderHint, bool on=true)
  • bool testRenderHint (RenderHint) const
  • void setRenderThreadCount (uint numThreads)
  • uint renderThreadCount () const
  • void setLegendIconSize (const QSize &)
  • QSize legendIconSize () const
  • double z () const
  • void setZ (double z) β€” sets the z value
  • void show () β€” shows the item ✨
  • void hide () β€” hides the item πŸ™ˆ
  • virtual void setVisible (bool)
  • bool isVisible () const
  • void setAxes (QwtAxisId xAxis, QwtAxisId yAxis)
  • void setXAxis (QwtAxisId)
  • QwtAxisId xAxis () const β€” returns xAxis
  • void setYAxis (QwtAxisId)
  • QwtAxisId yAxis () const β€” returns yAxis
  • virtual void itemChanged ()
  • virtual void legendChanged ()
  • virtual void getCanvasMarginHint (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, double &left, double &top, double &right, double &bottom) const β€” calculates a hint for the canvas margin
  • virtual void updateScaleDiv (const QwtScaleDiv &, const QwtScaleDiv &) β€” updates the item to changes of the axes scale division
  • virtual void updateLegend (const QwtPlotItem *, const QList< QwtLegendData > &) β€” updates the item to changes of the legend info
  • QRectF scaleRect (const QwtScaleMap &, const QwtScaleMap &) const β€” calculates the bounding scale rectangle of 2 maps
  • QRectF paintRect (const QwtScaleMap &, const QwtScaleMap &) const β€” calculates the bounding paint rectangle of 2 maps
  • virtual QList< QwtLegendData > legendData () const β€” returns all the information that's needed to represent the item on the legend

🧚 Additional Inherited Members 🧚

Protected Member Functions inherited from QwtPlotItem

  • QwtGraphic defaultIcon (const QBrush &, const QSizeF &) const β€” returns a default icon from a brush

🌟 Detailed Description 🌟

A plot item that displays any graphical shape, and that shape can be defined by a QPainterPath. no cap. πŸ’–

A QPainterPath is a shape composed from intersecting and uniting regions, rectangles, ellipses or irregular areas defined by lines and curves. QwtPlotShapeItem displays a shape with a pen and brush. yes, both. she's versatile. πŸ’…

QwtPlotShapeItem offers a couple of optimizations, like clipping or weeding. these algorithms need to convert the painter path into polygons, and that might be less performant for paths that are built from curves and ellipses. so like, it's a tradeoff, bestie, not a free lunch. πŸ“

More complex shapes that can't be expressed by a QPainterPath can be displayed using QwtPlotGraphicItem. different class, different moment.

See also: QwtPlotZone, QwtPlotGraphicItem.

Definition at line 38 of file qwt_plot_shapeitem.h.


πŸŽ€ Member Typedef Documentation πŸŽ€

typedef QFlags<PaintAttribute > QwtPlotShapeItem::PaintAttributes

An ORed combination of PaintAttribute values. mix and match, choose your fighter. ✨

Definition at line 61 of file qwt_plot_shapeitem.h.


πŸ”₯ Member Enumeration Documentation πŸ”₯

enum QwtPlotShapeItem::LegendMode

The mode for how to display the item on the legend. she needs her little legend moment too, okay?

Enumerator:

  • LegendShape β€” display a scaled down version of the shape
  • LegendColor β€” display a filled rectangle

Definition at line 64 of file qwt_plot_shapeitem.h.


enum QwtPlotShapeItem::PaintAttribute

Attributes to modify the drawing algorithm. the default disables all attributes β€” so out of the box, nothing extra is on. fr fr.

See also: setPaintAttribute(), testPaintAttribute().

Enumerator:

  • ClipPolygons β€” clip polygons before painting them. in situations where points are far outside the visible area (f.e when zooming deep) this might be a substantial improvement for the painting performance
⚠️ but heads up bestie: polygon clipping will convert the painter path into polygons, and that might introduce a negative impact on the performance of paths composed from curves or ellipses. it's giving "win some, lose some." πŸ’€

Definition at line 47 of file qwt_plot_shapeitem.h.


πŸ’– Constructor & Destructor Documentation πŸ’–

QwtPlotShapeItem::QwtPlotShapeItem (const QString & title = QString()) β€” [explicit]

Constructor. sets the following item attributes:

  • QwtPlotItem::AutoScale: true
  • QwtPlotItem::Legend: false

Parameters: title β€” the title. that's it, that's the parameter.

Definition at line 112 of file qwt_plot_shapeitem.cpp.


QwtPlotShapeItem::QwtPlotShapeItem (const QwtText & title) β€” [explicit]

Constructor. sets the following item attributes:

  • QwtPlotItem::AutoScale: true
  • QwtPlotItem::Legend: false

Parameters: title β€” the title. same energy, fancy text edition.

Definition at line 127 of file qwt_plot_shapeitem.cpp.


QwtPlotShapeItem::~QwtPlotShapeItem () β€” [virtual]

Destructor. she's done. she's logging off. πŸ’€βœ¨

Definition at line 134 of file qwt_plot_shapeitem.cpp.

✨ MEMBER FUNCTION DOCUMENTATION ✨

Okay bestie, this is the actual meat of the page β€” every single member function, what it does, what it hands back, and where in the source it lives. Grab a snack, we're going through all of them πŸ’–


πŸŽ€ boundingRect() β€” the shape's lil boundary box

QRectF QwtPlotShapeItem::boundingRect () const [override], [virtual]

This one gives you the bounding rectangle of the shape. Like, the box that hugs it. πŸ’…

It's reimplemented from QwtPlotItem, and it's virtual, so she's out here overridin'.

Definition at line 205 of file qwt_plot_shapeitem.cpp.


πŸ–ŒοΈ brush() β€” what's filling the shape

QBrush QwtPlotShapeItem::brush () const

Returns the brush used to fill the shape. That's the inside-y part, not the outline ✨

See also: setBrush(), pen()

Definition at line 336 of file qwt_plot_shapeitem.cpp.


πŸ‘‘ draw() β€” the actual painting moment

void QwtPlotShapeItem::draw (QPainter * painter, const QwtScaleMap & xMap,
    const QwtScaleMap & yMap, const QRectF & canvasRect) const [override],
    [virtual]

Draws the shape item. This is where the magic happens, no cap. 🌈

Parameters:

  • painter β€” Painter
  • xMap β€” X-Scale Map
  • yMap β€” Y-Scale Map
  • canvasRect β€” Contents rect of the plot canvas

Implements QwtPlotItem. Both [override] and [virtual] are tagged on this one, so she's the real deal πŸ”₯

Definition at line 385 of file qwt_plot_shapeitem.cpp.


πŸ¦‹ legendIcon() β€” the lil icon in the legend

QwtGraphic QwtPlotShapeItem::legendIcon (int index, const QSizeF & size)
    const [override], [virtual]

Returns a rectangle filled with the color of the brush ( or the pen ). Cute, right? πŸ’–

Parameters:

  • index β€” Index of the legend entry ( usually there is only one )
  • size β€” Icon size

See also: setLegendIconSize(), legendData()

Reimplemented from QwtPlotItem.

Definition at line 463 of file qwt_plot_shapeitem.cpp.


🧚 legendMode() β€” how she shows up in the legend

QwtPlotShapeItem::LegendMode QwtPlotShapeItem::legendMode () const

Returns the mode for how to represent the item on the legend.

See also: legendMode() β€” and yes, bestie, the page literally links this function to itself πŸ™ˆ that's just how the docs are, I don't make the rules.

Definition at line 199 of file qwt_plot_shapeitem.cpp.


βœ’οΈ pen() β€” the outline situation

QPen QwtPlotShapeItem::pen () const

Returns the pen used to draw the outline of the shape. That's the border, the edges, the perimeter β€” you get it πŸ’…

See also: setPen(), brush()

Definition at line 310 of file qwt_plot_shapeitem.cpp.


πŸ“ renderTolerance() β€” how much weeding we're allowing

double QwtPlotShapeItem::renderTolerance () const

Returns the tolerance for the weeding optimization.

See also: setRenderTolerance()

Definition at line 372 of file qwt_plot_shapeitem.cpp.


⭐ rtti() β€” her runtime type ID

int QwtPlotShapeItem::rtti () const [override], [virtual]

Returns QwtPlotItem::Rtti_PlotShape.

Reimplemented from QwtPlotItem. [override] and [virtual] both on deck ✨

Definition at line 151 of file qwt_plot_shapeitem.cpp.


πŸ’œ setBrush() β€” give the shape its fill

void QwtPlotShapeItem::setBrush (const QBrush & brush)

Assigns a brush. The brush is used to fill the path. Iconic behaviour honestly 🫢

Parameters:

  • brush β€” Brush

See also: brush(), pen()

Definition at line 323 of file qwt_plot_shapeitem.cpp.


🌸 setLegendMode() β€” pick how she appears in the legend

void QwtPlotShapeItem::setLegendMode (LegendMode mode)

Sets the mode for how to represent the item on the legend.

Parameters:

  • mode β€” Mode

See also: legendMode()

Definition at line 186 of file qwt_plot_shapeitem.cpp.


🎨 setPaintAttribute() β€” flip a paint attribute on or off

void QwtPlotShapeItem::setPaintAttribute (PaintAttribute attribute, bool on
    = true)

Specifies an attribute for how to draw the shape. Note the default: on = true, so if you don't pass it, she's on by default πŸ’–

Parameters:

  • attribute β€” Paint attribute
  • on β€” On/Off

See also: testPaintAttribute()

Definition at line 163 of file qwt_plot_shapeitem.cpp.


πŸ–ŠοΈ setPen() (the color one) β€” build and assign a pen from scratch

void QwtPlotShapeItem::setPen (const QColor & color, qreal width = 0.0,
    Qt::PenStyle style = Qt::SolidLine)

Builds and assigns a pen. Defaults are width = 0.0 and style = Qt::SolidLine.

Heads up bestie, this part matters: in Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it non cosmetic ( see QPen::isCosmetic() ). This method has been introduced to hide this incompatibility. So like, that's literally why this overload exists πŸ’…

Parameters:

  • color β€” Pen color
  • width β€” Pen width
  • style β€” Pen style

See also: pen(), brush()

Definition at line 284 of file qwt_plot_shapeitem.cpp.


πŸ–‹οΈ setPen() (the QPen one) β€” just hand over a whole pen

void QwtPlotShapeItem::setPen (const QPen & pen)

Assigns a pen. The pen is used to draw the outline of the shape.

Parameters:

  • pen β€” Pen

See also: pen(), brush()

Definition at line 297 of file qwt_plot_shapeitem.cpp.


πŸ”· setPolygon() β€” build the path from a polygon

void QwtPlotShapeItem::setPolygon (const QPolygonF & polygon)

Sets a path built from a polygon ✨

Parameters:

  • polygon β€” Polygon

See also: setShape(), setRect(), shape()

Definition at line 230 of file qwt_plot_shapeitem.cpp.


πŸŸͺ setRect() β€” build the path from a rectangle

void QwtPlotShapeItem::setRect (const QRectF & rect)

Sets a path built from a rectangle. Simple, clean, slay πŸŽ€

Parameters:

  • rect β€” Rectangle

See also: setShape(), setPolygon(), shape()

Definition at line 216 of file qwt_plot_shapeitem.cpp.


🧡 setRenderTolerance() β€” the weeding dial

void QwtPlotShapeItem::setRenderTolerance (double tolerance)

Sets the tolerance for the weeding optimization. After translating the shape into target device coordinate ( usually widget geometries ) the painter path can be simplified by a point weeding algorithm ( Douglas-Peucker ).

Real talk bestie: for shapes built from curves and ellipses weeding might have the opposite effect because they have to be expanded to polygons. So don't just crank it and assume it's always faster 😭

Parameters:

  • tolerance β€” Accepted error when reducing the number of points. A value <= 0.0 disables weeding.

See also: renderTolerance(), QwtWeedingCurveFitter

Definition at line 357 of file qwt_plot_shapeitem.cpp.


πŸ’« setShape() β€” set the actual shape

void QwtPlotShapeItem::setShape (const QPainterPath & shape)

Sets the shape to be displayed. The main character of the whole item, honestly πŸ‘‘

Parameters:

  • shape β€” Shape

See also: setShape(), shape() β€” yep, another self-link, the docs love doing that πŸ™ˆ

Definition at line 244 of file qwt_plot_shapeitem.cpp.


🌈 shape() β€” get the shape back

QPainterPath QwtPlotShapeItem::shape () const

Returns the shape to be displayed.

See also: setShape()

Definition at line 266 of file qwt_plot_shapeitem.cpp.


πŸ” testPaintAttribute() β€” vibe check an attribute

bool QwtPlotShapeItem::testPaintAttribute (PaintAttribute attribute) const

Returns True, when attribute is enabled.

See also: setPaintAttribute()

Definition at line 175 of file qwt_plot_shapeitem.cpp.


🌟 AUTHOR 🌟

Generated automatically by Doxygen for Qwt User's Guide from the source code.


And that's the whole page, bestie, you ate that πŸ«ΆπŸ’– Every function, every parameter, every see-also, every single qwt_plot_shapeitem.cpp line number β€” all accounted for. This one came to you courtesy of the Qwt User's Guide, filed under QwtPlotShapeItem(3), and the footer date/version stuff is right there in the original if you need the exact stamp ✨ Go forth and draw some shapes πŸ’…πŸŽ€

πŸ“¦ where this page comes from