Go to the documentation of this file.00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef COLORMAP_HPP
00044 #define COLORMAP_HPP 1
00045
00046
00047 #include <cairo.h>
00048 #include <vector>
00049 #include "palette.hpp"
00050 #include "graph.hpp"
00051 #include "coordmapper.hpp"
00052 #include "interpolation.hpp"
00053
00054
00055
00056 enum interpolation_e {
00057 INTERPOLATION_CLOSEST = 0,
00058 INTERPOLATION_BILINEAR,
00059 INTERPOLATION_BICUBIC
00060 };
00061
00062
00063 enum zscale_e {
00064 ZSCALE_LINEAR = 0,
00065 ZSCALE_LOG,
00066 ZSCALE_RELLOG
00067 };
00068
00069
00074 class Colormap : public Graph {
00075
00076 Palette _palette;
00078 interpolation_e _interpolation;
00079 zscale_e _zscale;
00081 double _zmin;
00082 double _zmax;
00084 double _datarange[4];
00085 size_t _n;
00086 size_t _m;
00088 std::vector<double> _f;
00090 Interpolation2D *_intrp;
00092 void make_data_interpolation( void );
00093
00094 void plot_to_image_surface( cairo_surface_t *surface, const Coordmapper *cm, int plim[4] );
00095
00096 public:
00097
00100 Colormap();
00101
00104 Colormap( const Colormap &colormap );
00105
00113 Colormap( const double datarange[4], size_t n, size_t m,
00114 const std::vector<double> &data );
00115
00118 virtual ~Colormap();
00119
00129 void set_data( const double datarange[4], size_t n, size_t m,
00130 const std::vector<double> &data );
00131
00137 void set_interpolation( interpolation_e interpolation );
00138
00153 void set_zscale( zscale_e zscale );
00154
00164 virtual void plot( cairo_t *cairo, const Coordmapper *cm, const double range[4] );
00165
00170 virtual void plot_sample( cairo_t *cairo, double x, double y, double width, double height );
00171
00177 virtual void get_bbox( double bbox[4] );
00178
00181 void set_palette( const Palette &palette );
00182
00185 Palette &palette( void ) { return( _palette ); }
00186
00189 void get_zrange( double &min, double &max ) const;
00190
00196 void set_zrange( double min, double max );
00197
00200 double get_value( double x, double y ) const;
00201 };
00202
00203
00204 #endif