QPRasterPlot.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef QPRASTERPLOT_H_
00028 #define QPRASTERPLOT_H_
00029
00030 #ifdef AIPS_HAS_QWT
00031
00032 #include <graphics/GenericPlotter/Plot.h>
00033 #include <casaqt/QwtPlotter/QPData.h>
00034 #include <casaqt/QwtPlotter/QPPlotItem.qo.h>
00035
00036 #include <qwt_color_map.h>
00037 #include <qwt_plot_spectrogram.h>
00038
00039 namespace casa {
00040
00041
00042 class QPRasterMap : public QwtColorMap {
00043 public:
00044
00045 QPRasterMap(bool isARGB = false);
00046
00047
00048 ~QPRasterMap();
00049
00050
00051 QwtColorMap* copy() const;
00052
00053
00054 QRgb rgb(const QwtDoubleInterval& interval, double value) const;
00055
00056
00057 unsigned char colorIndex(const QwtDoubleInterval& intv, double val) const;
00058
00059
00060 void setIsARGB(bool argb);
00061
00062 private:
00063
00064 bool m_isARGB;
00065 };
00066
00067
00068
00069 class QPRasterPlot : public QPPlotItem, public RasterPlot,
00070 public QwtPlotSpectrogram {
00071 public:
00072
00073
00074
00075 static const String CLASS_NAME;
00076
00077
00078
00079
00080
00081 QPRasterPlot(PlotRasterDataPtr data,
00082 PlotRasterData::Format format = PlotRasterData::RGB32,
00083 const String& title = "Qwt Raster Plot");
00084
00085
00086 QPRasterPlot(const RasterPlot& copy);
00087
00088
00089 ~QPRasterPlot();
00090
00091
00092
00093 using Plot::setLine;
00094
00095
00096
00097
00098
00099 bool isValid() const;
00100
00101
00102
00103
00104 unsigned int drawCount() const;
00105
00106
00107
00108
00109
00110
00111 void itemChanged();
00112
00113
00114
00115
00116
00117 QwtDoubleRect boundingRect() const;
00118
00119 #if QWT_VERSION < 0x060000
00120
00121 QWidget* legendItem() const;
00122 #endif
00123
00124
00125
00126
00127 void dataChanged() { itemChanged(); }
00128
00129
00130 bool linesShown() const;
00131
00132
00133 void setLinesShown(bool show = true);
00134
00135
00136 PlotLinePtr line() const;
00137
00138
00139 void setLine(const PlotLine& line);
00140
00141
00142
00143
00144
00145 PlotRasterDataPtr rasterData() const;
00146
00147
00148 PlotRasterData::Format dataFormat() const;
00149
00150
00151 void setDataFormat(PlotRasterData::Format f);
00152
00153
00154 PlotRasterData::Origin dataOrigin() const;
00155
00156
00157 void setDataOrigin(PlotRasterData::Origin o);
00158
00159
00160 void setXRange(double from, double to);
00161
00162
00163 void setYRange(double from, double to);
00164
00165
00166 vector<double> contourLines() const;
00167
00168
00169 void setContourLines(const vector<double>& lines);
00170
00171 protected:
00172
00173
00174
00175 const String& className() const { return CLASS_NAME; }
00176
00177
00178 #if QWT_VERSION >= 0x060000
00179 void draw_(QPainter* painter, const QwtScaleMap& xMap,
00180 const QwtScaleMap& yMap, const QRectF& canvasRect,
00181 unsigned int drawIndex, unsigned int drawCount) const;
00182 #else
00183 void draw_(QPainter* painter, const QwtScaleMap& xMap,
00184 const QwtScaleMap& yMap, const QRect& canvasRect,
00185 unsigned int drawIndex, unsigned int drawCount) const;
00186 #endif
00187
00188 private:
00189
00190 QPRasterData m_data;
00191 PlotRasterData::Format m_format;
00192 #if QWT_VERSION >= 0x060000
00193 QwtLinearColorMap* m_spectMap;
00194 QPRasterMap* m_rasterMap;
00195
00196 QRectF totalArea() const;
00197
00198 #else
00199 QwtLinearColorMap m_spectMap;
00200 QPRasterMap m_rasterMap;
00201
00202
00203
00204 QRect totalArea() const;
00205
00206 #endif
00207
00208
00209
00210 static QImage::Format format(PlotRasterData::Format f) {
00211 switch(f) {
00212 case PlotRasterData::RGB32: return QImage::Format_RGB32;
00213 case PlotRasterData::ARGB32: return QImage::Format_ARGB32;
00214
00215 default: return QImage::Format_Invalid;
00216 }
00217 }
00218 static PlotRasterData::Format format(QImage::Format f) {
00219 switch(f) {
00220 case QImage::Format_RGB32: return PlotRasterData::RGB32;
00221 case QImage::Format_ARGB32: return PlotRasterData::ARGB32;
00222
00223 default: return PlotRasterData::SPECTROGRAM;
00224 }
00225 }
00226
00227 };
00228
00229 }
00230
00231 #endif
00232
00233 #endif