qwt_plot_canvas.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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_CANVAS_H
  10. #define QWT_PLOT_CANVAS_H
  11. #include "qwt_global.h"
  12. #include <qframe.h>
  13. #include <qpen.h>
  14. class QwtPlot;
  15. class QPixmap;
  16. /*!
  17. \brief Canvas of a QwtPlot.
  18. \sa QwtPlot
  19. */
  20. class QWT_EXPORT QwtPlotCanvas : public QFrame
  21. {
  22. Q_OBJECT
  23. public:
  24. /*!
  25. \brief Paint attributes
  26. - PaintCached\n
  27. Paint double buffered and reuse the content of the pixmap buffer
  28. for some spontaneous repaints that happen when a plot gets unhidden,
  29. deiconified or changes the focus.
  30. Disabling the cache will improve the performance for
  31. incremental paints (using QwtPlotCurve::draw).
  32. - PaintPacked\n
  33. Suppress system background repaints and paint it together with
  34. the canvas contents.
  35. Painting packed might avoid flickering for expensive repaints,
  36. when there is a notable gap between painting the background
  37. and the plot contents.
  38. The default setting enables PaintCached and PaintPacked
  39. \sa setPaintAttribute(), testPaintAttribute(), paintCache()
  40. */
  41. enum PaintAttribute
  42. {
  43. PaintCached = 1,
  44. PaintPacked = 2
  45. };
  46. /*!
  47. \brief Focus indicator
  48. - NoFocusIndicator\n
  49. Don't paint a focus indicator
  50. - CanvasFocusIndicator\n
  51. The focus is related to the complete canvas.
  52. Paint the focus indicator using paintFocus()
  53. - ItemFocusIndicator\n
  54. The focus is related to an item (curve, point, ...) on
  55. the canvas. It is up to the application to display a
  56. focus indication using f.e. highlighting.
  57. \sa setFocusIndicator(), focusIndicator(), paintFocus()
  58. */
  59. enum FocusIndicator
  60. {
  61. NoFocusIndicator,
  62. CanvasFocusIndicator,
  63. ItemFocusIndicator
  64. };
  65. explicit QwtPlotCanvas( QwtPlot * );
  66. virtual ~QwtPlotCanvas();
  67. QwtPlot *plot();
  68. const QwtPlot *plot() const;
  69. void setFocusIndicator( FocusIndicator );
  70. FocusIndicator focusIndicator() const;
  71. void setPaintAttribute( PaintAttribute, bool on = true );
  72. bool testPaintAttribute( PaintAttribute ) const;
  73. QPixmap *paintCache();
  74. const QPixmap *paintCache() const;
  75. void invalidatePaintCache();
  76. void replot();
  77. protected:
  78. virtual void hideEvent( QHideEvent * );
  79. virtual void paintEvent( QPaintEvent * );
  80. virtual void drawContents( QPainter * );
  81. virtual void drawFocusIndicator( QPainter * );
  82. void drawCanvas( QPainter *painter = NULL );
  83. private:
  84. void setSystemBackground( bool );
  85. class PrivateData;
  86. PrivateData *d_data;
  87. };
  88. #endif