qwt_plot_shapeitem.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
  2. * Qwt Widget Library
  3. * Copyright (C) 1997 Josef Wilgen
  4. * Copyright (C) 2002 Uwe Rathmann
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the Qwt License, Version 1.0
  8. *****************************************************************************/
  9. #ifndef QWT_PLOT_SHAPE_ITEM_H
  10. #define QWT_PLOT_SHAPE_ITEM_H
  11. #include "qwt_global.h"
  12. #include "qwt_plot_item.h"
  13. #include <qpainterpath.h>
  14. /*!
  15. \brief A plot item, which displays any graphical shape,
  16. that can be defined by a QPainterPath
  17. A QPainterPath is a shape composed from intersecting and uniting
  18. regions, rectangles, ellipses or irregular areas defined by lines, and curves.
  19. QwtPlotShapeItem displays a shape with a pen and brush.
  20. QwtPlotShapeItem offers a couple of optimizations like clipping or weeding.
  21. These algorithms need to convert the painter path into polygons that might be
  22. less performant for paths built from curves and ellipses.
  23. \sa QwtPlotZone
  24. */
  25. class QWT_EXPORT QwtPlotShapeItem: public QwtPlotItem
  26. {
  27. public:
  28. /*!
  29. Attributes to modify the drawing algorithm.
  30. The default disables all attributes
  31. \sa setPaintAttribute(), testPaintAttribute()
  32. */
  33. enum PaintAttribute
  34. {
  35. /*!
  36. Clip polygons before painting them. In situations, where points
  37. are far outside the visible area (f.e when zooming deep) this
  38. might be a substantial improvement for the painting performance
  39. But polygon clipping will convert the painter path into
  40. polygons what might introduce a negative impact on the
  41. performance of paths composed from curves or ellipses.
  42. */
  43. ClipPolygons = 0x01,
  44. };
  45. //! Paint attributes
  46. typedef QFlags<PaintAttribute> PaintAttributes;
  47. //! Mode how to display the item on the legend
  48. enum LegendMode
  49. {
  50. //! Display a scaled down version of the shape
  51. LegendShape,
  52. //! Display a filled rectangle
  53. LegendColor
  54. };
  55. explicit QwtPlotShapeItem( const QString &title = QString() );
  56. explicit QwtPlotShapeItem( const QwtText &title );
  57. virtual ~QwtPlotShapeItem();
  58. void setPaintAttribute( PaintAttribute, bool on = true );
  59. bool testPaintAttribute( PaintAttribute ) const;
  60. void setLegendMode( LegendMode );
  61. LegendMode legendMode() const;
  62. void setRect( const QRectF & );
  63. void setPolygon( const QPolygonF & );
  64. void setShape( const QPainterPath & );
  65. QPainterPath shape() const;
  66. void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
  67. void setPen( const QPen & );
  68. QPen pen() const;
  69. void setBrush( const QBrush & );
  70. QBrush brush() const;
  71. void setRenderTolerance( double );
  72. double renderTolerance() const;
  73. virtual QRectF boundingRect() const;
  74. virtual void draw( QPainter *,
  75. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  76. const QRectF &canvasRect ) const;
  77. virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
  78. virtual int rtti() const;
  79. private:
  80. void init();
  81. class PrivateData;
  82. PrivateData *d_data;
  83. };
  84. #endif