qwt_painter_command.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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_PAINTER_COMMAND_H
  10. #define QWT_PAINTER_COMMAND_H
  11. #include "qwt_global.h"
  12. #include <qpaintengine.h>
  13. #include <qpixmap.h>
  14. #include <qimage.h>
  15. #include <qpolygon.h>
  16. #include <qpainterpath.h>
  17. class QPainterPath;
  18. /*!
  19. QwtPainterCommand represents the attributes of a paint operation
  20. how it is used between QPainter and QPaintDevice
  21. It is used by QwtGraphic to record and replay paint operations
  22. \sa QwtGraphic::commands()
  23. */
  24. class QWT_EXPORT QwtPainterCommand
  25. {
  26. public:
  27. //! Type of the paint command
  28. enum Type
  29. {
  30. //! Invalid command
  31. Invalid = -1,
  32. //! Draw a QPainterPath
  33. Path,
  34. //! Draw a QPixmap
  35. Pixmap,
  36. //! Draw a QImage
  37. Image,
  38. //! QPainter state change
  39. State
  40. };
  41. //! Attributes how to paint a QPixmap
  42. struct PixmapData
  43. {
  44. QRectF rect;
  45. QPixmap pixmap;
  46. QRectF subRect;
  47. };
  48. //! Attributes how to paint a QImage
  49. struct ImageData
  50. {
  51. QRectF rect;
  52. QImage image;
  53. QRectF subRect;
  54. Qt::ImageConversionFlags flags;
  55. };
  56. //! Attributes of a state change
  57. struct StateData
  58. {
  59. QPaintEngine::DirtyFlags flags;
  60. QPen pen;
  61. QBrush brush;
  62. QPointF brushOrigin;
  63. QBrush backgroundBrush;
  64. Qt::BGMode backgroundMode;
  65. QFont font;
  66. QMatrix matrix;
  67. QTransform transform;
  68. Qt::ClipOperation clipOperation;
  69. QRegion clipRegion;
  70. QPainterPath clipPath;
  71. bool isClipEnabled;
  72. QPainter::RenderHints renderHints;
  73. QPainter::CompositionMode compositionMode;
  74. qreal opacity;
  75. };
  76. QwtPainterCommand();
  77. QwtPainterCommand(const QwtPainterCommand &);
  78. QwtPainterCommand( const QPainterPath & );
  79. QwtPainterCommand( const QRectF &rect,
  80. const QPixmap &, const QRectF& subRect );
  81. QwtPainterCommand( const QRectF &rect,
  82. const QImage &, const QRectF& subRect,
  83. Qt::ImageConversionFlags );
  84. QwtPainterCommand( const QPaintEngineState & );
  85. ~QwtPainterCommand();
  86. QwtPainterCommand &operator=(const QwtPainterCommand & );
  87. Type type() const;
  88. QPainterPath *path();
  89. const QPainterPath *path() const;
  90. PixmapData* pixmapData();
  91. const PixmapData* pixmapData() const;
  92. ImageData* imageData();
  93. const ImageData* imageData() const;
  94. StateData* stateData();
  95. const StateData* stateData() const;
  96. private:
  97. void copy( const QwtPainterCommand & );
  98. void reset();
  99. Type d_type;
  100. union
  101. {
  102. QPainterPath *d_path;
  103. PixmapData *d_pixmapData;
  104. ImageData *d_imageData;
  105. StateData *d_stateData;
  106. };
  107. };
  108. //! \return Type of the command
  109. inline QwtPainterCommand::Type QwtPainterCommand::type() const
  110. {
  111. return d_type;
  112. }
  113. //! \return Painter path to be painted
  114. inline const QPainterPath *QwtPainterCommand::path() const
  115. {
  116. return d_path;
  117. }
  118. //! \return Attributes how to paint a QPixmap
  119. inline const QwtPainterCommand::PixmapData *
  120. QwtPainterCommand::pixmapData() const
  121. {
  122. return d_pixmapData;
  123. }
  124. //! \return Attributes how to paint a QImage
  125. inline const QwtPainterCommand::ImageData *
  126. QwtPainterCommand::imageData() const
  127. {
  128. return d_imageData;
  129. }
  130. //! \return Attributes of a state change
  131. inline const QwtPainterCommand::StateData *
  132. QwtPainterCommand::stateData() const
  133. {
  134. return d_stateData;
  135. }
  136. #endif