Qwt User's Guide  6.2.0
qwt_painter_command.h
1 /******************************************************************************
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 
10 #ifndef QWT_PAINTER_COMMAND_H
11 #define QWT_PAINTER_COMMAND_H
12 
13 #include "qwt_global.h"
14 
15 #include <qpaintengine.h>
16 #include <qpixmap.h>
17 #include <qimage.h>
18 #include <qpolygon.h>
19 #include <qpainterpath.h>
20 
21 class QPainterPath;
22 
32 class QWT_EXPORT QwtPainterCommand
33 {
34  public:
36  enum Type
37  {
39  Invalid = -1,
40 
43 
46 
49 
51  State
52  };
53 
55  struct PixmapData
56  {
57  QRectF rect;
58  QPixmap pixmap;
59  QRectF subRect;
60  };
61 
63  struct ImageData
64  {
65  QRectF rect;
66  QImage image;
67  QRectF subRect;
68  Qt::ImageConversionFlags flags;
69  };
70 
72  struct StateData
73  {
74  QPaintEngine::DirtyFlags flags;
75 
76  QPen pen;
77  QBrush brush;
78  QPointF brushOrigin;
79  QBrush backgroundBrush;
80  Qt::BGMode backgroundMode;
81  QFont font;
82  QTransform transform;
83 
84  Qt::ClipOperation clipOperation;
85  QRegion clipRegion;
86  QPainterPath clipPath;
87  bool isClipEnabled;
88 
89  QPainter::RenderHints renderHints;
90  QPainter::CompositionMode compositionMode;
91  qreal opacity;
92  };
93 
96 
97  explicit QwtPainterCommand( const QPainterPath& );
98 
99  QwtPainterCommand( const QRectF& rect,
100  const QPixmap&, const QRectF& subRect );
101 
102  QwtPainterCommand( const QRectF& rect,
103  const QImage&, const QRectF& subRect,
104  Qt::ImageConversionFlags );
105 
106  explicit QwtPainterCommand( const QPaintEngineState& );
107 
109 
110  QwtPainterCommand& operator=(const QwtPainterCommand& );
111 
112  Type type() const;
113 
114  QPainterPath* path();
115  const QPainterPath* path() const;
116 
117  PixmapData* pixmapData();
118  const PixmapData* pixmapData() const;
119 
120  ImageData* imageData();
121  const ImageData* imageData() const;
122 
123  StateData* stateData();
124  const StateData* stateData() const;
125 
126  private:
127  void copy( const QwtPainterCommand& );
128  void reset();
129 
130  Type m_type;
131 
132  union
133  {
134  QPainterPath* m_path;
135  PixmapData* m_pixmapData;
136  ImageData* m_imageData;
137  StateData* m_stateData;
138  };
139 };
140 
143 {
144  return m_type;
145 }
146 
148 inline const QPainterPath* QwtPainterCommand::path() const
149 {
150  return m_path;
151 }
152 
154 inline const QwtPainterCommand::PixmapData*
156 {
157  return m_pixmapData;
158 }
159 
161 inline const QwtPainterCommand::ImageData*
163 {
164  return m_imageData;
165 }
166 
168 inline const QwtPainterCommand::StateData*
170 {
171  return m_stateData;
172 }
173 
174 #endif
Type
Type of the paint command.
@ Pixmap
Draw a QPixmap.
@ Path
Draw a QPainterPath.
@ Image
Draw a QImage.