20 #include <qpainterpath.h> 23 const QwtScaleMap &yMap,
const QPainterPath &path,
bool doAlign )
26 shape.setFillRule( path.fillRule() );
28 for (
int i = 0; i < path.elementCount(); i++ )
30 const QPainterPath::Element element = path.elementAt( i );
35 switch( element.type )
37 case QPainterPath::MoveToElement:
48 case QPainterPath::LineToElement:
59 case QPainterPath::CurveToElement:
61 const QPainterPath::Element element1 = path.elementAt( ++i );
62 const double x1 = xMap.
transform( element1.x );
63 const double y1 = yMap.
transform( element1.y );
65 const QPainterPath::Element element2 = path.elementAt( ++i );
66 const double x2 = xMap.
transform( element2.x );
67 const double y2 = yMap.
transform( element2.y );
69 shape.cubicTo( x, y, x1, y1, x2, y2 );
72 case QPainterPath::CurveToDataElement:
219 path.addRect( rect );
233 shape.addPolygon( polygon );
249 if ( shape.isEmpty() )
286 setPen( QPen( color, width, style ) );
359 tolerance =
qwtMaxF( tolerance, 0.0 );
387 const QRectF &canvasRect )
const 399 xMap, yMap, canvasRect.toRect() );
403 if ( ( br.left() > cr.right() ) || ( br.right() < cr.left() )
404 || ( br.top() > cr.bottom() ) || ( br.bottom() < cr.top() ) )
418 const QRectF clipRect = canvasRect.adjusted( -pw, -pw, pw, pw );
420 QPainterPath clippedPath;
421 clippedPath.setFillRule( path.fillRule() );
424 for (
int i = 0; i < polygons.size(); i++ )
427 clippedPath.addPolygon( polygons[i] );
438 QPainterPath fittedPath;
439 fittedPath.setFillRule( path.fillRule() );
442 for (
int i = 0; i < polygons.size(); i++ )
443 fittedPath.addPolygon( fitter.
fitCurve( polygons[ i ] ) );
451 painter->drawPath( path );
464 const QSizeF &size )
const 471 if ( size.isEmpty() )
478 QPainter painter( &icon );
479 painter.setRenderHint( QPainter::Antialiasing,
482 painter.translate( -br.topLeft() );
virtual void legendChanged()
Display a scaled down version of the shape.
Display a filled rectangle.
void setLegendMode(LegendMode)
QPainterPath shape() const
QWT_CONSTEXPR float qwtMaxF(float a, float b)
bool testPaintAttribute(PaintAttribute) const
LegendMode
Mode how to display the item on the legend.
void setPen(const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
QwtGraphic defaultIcon(const QBrush &, const QSizeF &) const
Return a default icon from a brush.
LegendMode legendMode() const
static qreal effectivePenWidth(const QPen &)
virtual int rtti() const QWT_OVERRIDE
void setDefaultSize(const QSizeF &)
Set a default size.
The item is represented on the legend.
void setPaintAttribute(PaintAttribute, bool on=true)
bool testRenderHint(RenderHint) const
A curve fitter implementing Douglas and Peucker algorithm.
static void clipPolygonF(const QRectF &, QPolygonF &, bool closePolygon=false)
virtual void draw(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const QWT_OVERRIDE
A class representing a text.
void setZ(double z)
Set the z value.
A paint device for scalable graphics.
void setRenderTolerance(double)
Set the tolerance for the weeding optimization.
void setRect(const QRectF &)
Set a path built from a rectangle.
void setPolygon(const QPolygonF &)
Set a path built from a polygon.
virtual QwtGraphic legendIcon(int index, const QSizeF &) const QWT_OVERRIDE
double invTransform(double p) const
QFlags< PaintAttribute > PaintAttributes
Paint attributes.
virtual void itemChanged()
A plot item, which displays any graphical shape, that can be defined by a QPainterPath.
QwtPlotShapeItem(const QString &title=QString())
Constructor.
QwtPlotShapeItem::PaintAttributes paintAttributes
QwtPlotShapeItem::LegendMode legendMode
double renderTolerance() const
static QPainterPath qwtTransformPath(const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QPainterPath &path, bool doAlign)
Base class for items on the plot canvas.
void setItemAttribute(ItemAttribute, bool on=true)
double transform(double s) const
void setShape(const QPainterPath &)
Set the shape to be displayed.
void setBrush(const QBrush &)
virtual QPolygonF fitCurve(const QPolygonF &) const QWT_OVERRIDE
static bool roundingAlignment()
virtual QRectF boundingRect() const QWT_OVERRIDE
Bounding rectangle of the shape.
virtual ~QwtPlotShapeItem()
Destructor.
const QwtText & title() const
virtual QRectF boundingRect() const