Qwt User's Guide  6.1.3
qwt_painter_command.h
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 
10 #ifndef QWT_PAINTER_COMMAND_H
11 #define QWT_PAINTER_COMMAND_H
12 
13 #include "qwt_global.h"
14 #include <qpaintengine.h>
15 #include <qpixmap.h>
16 #include <qimage.h>
17 #include <qpolygon.h>
18 
19 class QPainterPath;
20 
30 class QWT_EXPORT QwtPainterCommand
31 {
32 public:
34  enum Type
35  {
37  Invalid = -1,
38 
41 
44 
47 
49  State
50  };
51 
53  struct PixmapData
54  {
55  QRectF rect;
56  QPixmap pixmap;
57  QRectF subRect;
58  };
59 
61  struct ImageData
62  {
63  QRectF rect;
64  QImage image;
65  QRectF subRect;
66  Qt::ImageConversionFlags flags;
67  };
68 
70  struct StateData
71  {
72  QPaintEngine::DirtyFlags flags;
73 
74  QPen pen;
75  QBrush brush;
76  QPointF brushOrigin;
77  QBrush backgroundBrush;
78  Qt::BGMode backgroundMode;
79  QFont font;
80  QMatrix matrix;
81  QTransform transform;
82 
83  Qt::ClipOperation clipOperation;
84  QRegion clipRegion;
85  QPainterPath clipPath;
86  bool isClipEnabled;
87 
88  QPainter::RenderHints renderHints;
89  QPainter::CompositionMode compositionMode;
90  qreal opacity;
91  };
92 
95 
96  QwtPainterCommand( const QPainterPath & );
97 
98  QwtPainterCommand( const QRectF &rect,
99  const QPixmap &, const QRectF& subRect );
100 
101  QwtPainterCommand( const QRectF &rect,
102  const QImage &, const QRectF& subRect,
103  Qt::ImageConversionFlags );
104 
105  QwtPainterCommand( const QPaintEngineState & );
106 
108 
109  QwtPainterCommand &operator=(const QwtPainterCommand & );
110 
111  Type type() const;
112 
113  QPainterPath *path();
114  const QPainterPath *path() const;
115 
116  PixmapData* pixmapData();
117  const PixmapData* pixmapData() const;
118 
119  ImageData* imageData();
120  const ImageData* imageData() const;
121 
122  StateData* stateData();
123  const StateData* stateData() const;
124 
125 private:
126  void copy( const QwtPainterCommand & );
127  void reset();
128 
129  Type d_type;
130 
131  union
132  {
133  QPainterPath *d_path;
134  PixmapData *d_pixmapData;
135  ImageData *d_imageData;
136  StateData *d_stateData;
137  };
138 };
139 
142 {
143  return d_type;
144 }
145 
147 inline const QPainterPath *QwtPainterCommand::path() const
148 {
149  return d_path;
150 }
151 
153 inline const QwtPainterCommand::PixmapData*
155 {
156  return d_pixmapData;
157 }
158 
160 inline const QwtPainterCommand::ImageData *
162 {
163  return d_imageData;
164 }
165 
167 inline const QwtPainterCommand::StateData *
169 {
170  return d_stateData;
171 }
172 
173 #endif
QPainterPath * path()
Definition: qwt_painter_command.cpp:216
Draw a QPainterPath.
Definition: qwt_painter_command.h:40
ImageData * imageData()
Definition: qwt_painter_command.cpp:228
Type
Type of the paint command.
Definition: qwt_painter_command.h:34
Type type() const
Definition: qwt_painter_command.h:141
StateData * stateData()
Definition: qwt_painter_command.cpp:234
Draw a QPixmap.
Definition: qwt_painter_command.h:43
Definition: qwt_painter_command.h:30
Draw a QImage.
Definition: qwt_painter_command.h:46
PixmapData * pixmapData()
Definition: qwt_painter_command.cpp:222