source: ntrip/trunk/GnssCenter/qwt/qwt_plot_rasteritem.h@ 5290

Last change on this file since 5290 was 4839, checked in by mervart, 12 years ago
File size: 4.6 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 - NoCache\n
42 renderImage() is called, whenever the item has to be repainted
43 - PaintCache\n
44 renderImage() is called, whenever the image cache is not valid,
45 or the scales, or the size of the canvas has changed. This type
46 of cache is only useful for improving the performance of hide/show
47 operations. All other situations are already handled by the
48 plot canvas cache.
49
50 The default policy is NoCache
51 */
52 enum CachePolicy
53 {
54 NoCache,
55 PaintCache
56 };
57
58 /*!
59 Attributes to modify the drawing algorithm.
60 \sa setPaintAttribute(), testPaintAttribute()
61 */
62 enum PaintAttribute
63 {
64 /*!
65 When the image is rendered according to the data pixels
66 ( QwtRasterData::pixelHint() ) it can be expanded to paint
67 device resolution before it is passed to QPainter.
68 The expansion algorithm rounds the pixel borders in the same
69 way as the axis ticks, what is usually better than the
70 scaling algorithm implemented in Qt.
71 Disabling this flag might make sense, to reduce the size of a
72 document/file. If this is possible for a document format
73 depends on the implementation of the specific QPaintEngine.
74 */
75
76 PaintInDeviceResolution = 1
77 };
78
79 //! Paint attributes
80 typedef QFlags<PaintAttribute> PaintAttributes;
81
82 explicit QwtPlotRasterItem( const QString& title = QString::null );
83 explicit QwtPlotRasterItem( const QwtText& title );
84 virtual ~QwtPlotRasterItem();
85
86 void setPaintAttribute( PaintAttribute, bool on = true );
87 bool testPaintAttribute( PaintAttribute ) const;
88
89 void setAlpha( int alpha );
90 int alpha() const;
91
92 void setCachePolicy( CachePolicy );
93 CachePolicy cachePolicy() const;
94
95 void invalidateCache();
96
97 virtual void draw( QPainter *p,
98 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
99 const QRectF &rect ) const;
100
101 virtual QRectF pixelHint( const QRectF & ) const;
102
103 virtual QwtInterval interval(Qt::Axis) const;
104 virtual QRectF boundingRect() const;
105
106protected:
107 /*!
108 \brief Render an image
109
110 An implementation of render() might iterate over all
111 pixels of imageRect. Each pixel has to be translated into
112 the corresponding position in scale coordinates using the maps.
113 This position can be used to look up a value in a implementation
114 specific way and to map it into a color.
115
116 \param xMap X-Scale Map
117 \param yMap Y-Scale Map
118 \param area Requested area for the image in scale coordinates
119 \param imageSize Requested size of the image
120 */
121 virtual QImage renderImage( const QwtScaleMap &xMap,
122 const QwtScaleMap &yMap, const QRectF &area,
123 const QSize &imageSize ) const = 0;
124
125 virtual QwtScaleMap imageMap( Qt::Orientation,
126 const QwtScaleMap &map, const QRectF &area,
127 const QSize &imageSize, double pixelSize) const;
128
129private:
130 QwtPlotRasterItem( const QwtPlotRasterItem & );
131 QwtPlotRasterItem &operator=( const QwtPlotRasterItem & );
132
133 void init();
134
135 QImage compose( const QwtScaleMap &, const QwtScaleMap &,
136 const QRectF &imageArea, const QRectF &paintRect,
137 const QSize &imageSize, bool doCache) const;
138
139
140 class PrivateData;
141 PrivateData *d_data;
142};
143
144Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRasterItem::PaintAttributes )
145
146#endif
Note: See TracBrowser for help on using the repository browser.