source: ntrip/trunk/BNC/qwt/qwt_plot_rasteritem.h@ 10417

Last change on this file since 10417 was 9383, checked in by stoecker, 4 years ago

update to qwt verion 6.1.1 to fix build with newer Qt5

File size: 4.7 KB
Line 
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_PLOT_RASTERITEM_H
11#define QWT_PLOT_RASTERITEM_H
12
13#include "qwt_global.h"
14#include "qwt_plot_item.h"
15#include "qwt_interval.h"
16#include <qglobal.h>
17#include <qstring.h>
18#include <qimage.h>
19
20/*!
21 \brief A class, which displays raster data
22
23 Raster data is a grid of pixel values, that can be represented
24 as a QImage. It is used for many types of information like
25 spectrograms, cartograms, geographical maps ...
26
27 Often a plot has several types of raster data organized in layers.
28 ( f.e a geographical map, with weather statistics ).
29 Using setAlpha() raster items can be stacked easily.
30
31 QwtPlotRasterItem is only implemented for images of the following formats:
32 QImage::Format_Indexed8, QImage::Format_ARGB32.
33
34 \sa QwtPlotSpectrogram
35*/
36
37class QWT_EXPORT QwtPlotRasterItem: public QwtPlotItem
38{
39public:
40 /*!
41 \brief Cache policy
42 The default policy is NoCache
43 */
44 enum CachePolicy
45 {
46 /*!
47 renderImage() is called each time the item has to be repainted
48 */
49 NoCache,
50
51 /*!
52 renderImage() is called, whenever the image cache is not valid,
53 or the scales, or the size of the canvas has changed.
54
55 This type of cache is useful for improving the performance
56 of hide/show operations or manipulations of the alpha value.
57 All other situations are handled by the canvas backing store.
58 */
59 PaintCache
60 };
61
62 /*!
63 Attributes to modify the drawing algorithm.
64 \sa setPaintAttribute(), testPaintAttribute()
65 */
66 enum PaintAttribute
67 {
68 /*!
69 When the image is rendered according to the data pixels
70 ( QwtRasterData::pixelHint() ) it can be expanded to paint
71 device resolution before it is passed to QPainter.
72 The expansion algorithm rounds the pixel borders in the same
73 way as the axis ticks, what is usually better than the
74 scaling algorithm implemented in Qt.
75 Disabling this flag might make sense, to reduce the size of a
76 document/file. If this is possible for a document format
77 depends on the implementation of the specific QPaintEngine.
78 */
79
80 PaintInDeviceResolution = 1
81 };
82
83 //! Paint attributes
84 typedef QFlags<PaintAttribute> PaintAttributes;
85
86 explicit QwtPlotRasterItem( const QString& title = QString() );
87 explicit QwtPlotRasterItem( const QwtText& title );
88 virtual ~QwtPlotRasterItem();
89
90 void setPaintAttribute( PaintAttribute, bool on = true );
91 bool testPaintAttribute( PaintAttribute ) const;
92
93 void setAlpha( int alpha );
94 int alpha() const;
95
96 void setCachePolicy( CachePolicy );
97 CachePolicy cachePolicy() const;
98
99 void invalidateCache();
100
101 virtual void draw( QPainter *,
102 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
103 const QRectF &canvasRect ) const;
104
105 virtual QRectF pixelHint( const QRectF & ) const;
106
107 virtual QwtInterval interval(Qt::Axis) const;
108 virtual QRectF boundingRect() const;
109
110protected:
111 /*!
112 \brief Render an image
113
114 An implementation of render() might iterate over all
115 pixels of imageRect. Each pixel has to be translated into
116 the corresponding position in scale coordinates using the maps.
117 This position can be used to look up a value in a implementation
118 specific way and to map it into a color.
119
120 \param xMap X-Scale Map
121 \param yMap Y-Scale Map
122 \param area Requested area for the image in scale coordinates
123 \param imageSize Requested size of the image
124
125 \return Rendered image
126 */
127 virtual QImage renderImage( const QwtScaleMap &xMap,
128 const QwtScaleMap &yMap, const QRectF &area,
129 const QSize &imageSize ) const = 0;
130
131 virtual QwtScaleMap imageMap( Qt::Orientation,
132 const QwtScaleMap &map, const QRectF &area,
133 const QSize &imageSize, double pixelSize) const;
134
135private:
136 QwtPlotRasterItem( const QwtPlotRasterItem & );
137 QwtPlotRasterItem &operator=( const QwtPlotRasterItem & );
138
139 void init();
140
141 QImage compose( const QwtScaleMap &, const QwtScaleMap &,
142 const QRectF &imageArea, const QRectF &paintRect,
143 const QSize &imageSize, bool doCache) const;
144
145
146 class PrivateData;
147 PrivateData *d_data;
148};
149
150Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRasterItem::PaintAttributes )
151
152#endif
Note: See TracBrowser for help on using the repository browser.