qwt_plot_directpainter.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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_DIRECT_PAINTER_H
  10. #define QWT_PLOT_DIRECT_PAINTER_H
  11. #include "qwt_global.h"
  12. #include <qobject.h>
  13. class QRegion;
  14. class QwtPlotSeriesItem;
  15. /*!
  16. \brief Painter object trying to paint incrementally
  17. Often applications want to display samples while they are
  18. collected. When there are too many samples complete replots
  19. will be expensive to be processed in a collection cycle.
  20. QwtPlotDirectPainter offers an API to paint
  21. subsets ( f.e all additions points ) without erasing/repainting
  22. the plot canvas.
  23. On certain environments it might be important to calculate a proper
  24. clip region before painting. F.e. for Qt Embedded only the clipped part
  25. of the backing store will be copied to a ( maybe unaccelerated )
  26. frame buffer.
  27. \warning Incremental painting will only help when no replot is triggered
  28. by another operation ( like changing scales ) and nothing needs
  29. to be erased.
  30. */
  31. class QWT_EXPORT QwtPlotDirectPainter: public QObject
  32. {
  33. public:
  34. /*!
  35. \brief Paint attributes
  36. \sa setAttribute(), testAttribute(), drawSeries()
  37. */
  38. enum Attribute
  39. {
  40. /*!
  41. Initializing a QPainter is an expensive operation.
  42. When AtomicPainter is set each call of drawSeries() opens/closes
  43. a temporary QPainter. Otherwise QwtPlotDirectPainter tries to
  44. use the same QPainter as long as possible.
  45. */
  46. AtomicPainter = 0x01,
  47. /*!
  48. When FullRepaint is set the plot canvas is explicitly repainted
  49. after the samples have been rendered.
  50. */
  51. FullRepaint = 0x02,
  52. /*!
  53. When QwtPlotCanvas::BackingStore is enabled the painter
  54. has to paint to the backing store and the widget. In certain
  55. situations/environments it might be faster to paint to
  56. the backing store only and then copy the backing store to the canvas.
  57. This flag can also be useful for settings, where Qt fills the
  58. the clip region with the widget background.
  59. */
  60. CopyBackingStore = 0x04
  61. };
  62. //! Paint attributes
  63. typedef QFlags<Attribute> Attributes;
  64. QwtPlotDirectPainter( QObject *parent = NULL );
  65. virtual ~QwtPlotDirectPainter();
  66. void setAttribute( Attribute, bool on );
  67. bool testAttribute( Attribute ) const;
  68. void setClipping( bool );
  69. bool hasClipping() const;
  70. void setClipRegion( const QRegion & );
  71. QRegion clipRegion() const;
  72. void drawSeries( QwtPlotSeriesItem *, int from, int to );
  73. void reset();
  74. virtual bool eventFilter( QObject *, QEvent * );
  75. private:
  76. class PrivateData;
  77. PrivateData *d_data;
  78. };
  79. Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotDirectPainter::Attributes )
  80. #endif