Navigation

Main Page
Download
Support
Installation
Tutorial
Examples
Reference Manual
   Version 1.0.6dev
      Class Index
      File List
   Version 1.0.6
   Version 1.0.5new_solver
   Version 1.0.5dev
   Version 1.0.5b
   Version 1.0.4dev
   Version 1.0.4
Publications


Hosted by Get Ion Beam Simulator at SourceForge.net. Fast, secure and Free Open Source software downloads
meshcolormap.hpp
Go to the documentation of this file.
1 
5 /* Copyright (c) 2005-2012,2014 Taneli Kalvas. All rights reserved.
6  *
7  * You can redistribute this software and/or modify it under the terms
8  * of the GNU General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this library (file "COPYING" included in the package);
19  * if not, write to the Free Software Foundation, Inc., 51 Franklin
20  * Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  * If you have questions about your rights to use or distribute this
23  * software, please contact Berkeley Lab's Technology Transfer
24  * Department at TTD@lbl.gov. Other questions, comments and bug
25  * reports should be sent directly to the author via email at
26  * taneli.kalvas@jyu.fi.
27  *
28  * NOTICE. This software was developed under partial funding from the
29  * U.S. Department of Energy. As such, the U.S. Government has been
30  * granted for itself and others acting on its behalf a paid-up,
31  * nonexclusive, irrevocable, worldwide license in the Software to
32  * reproduce, prepare derivative works, and perform publicly and
33  * display publicly. Beginning five (5) years after the date
34  * permission to assert copyright is obtained from the U.S. Department
35  * of Energy, and subject to any subsequent five (5) year renewals,
36  * the U.S. Government is granted for itself and others acting on its
37  * behalf a paid-up, nonexclusive, irrevocable, worldwide license in
38  * the Software to reproduce, prepare derivative works, distribute
39  * copies to the public, perform publicly and display publicly, and to
40  * permit others to do so.
41  */
42 
43 #ifndef MESHCOLORMAP_HPP
44 #define MESHCOLORMAP_HPP 1
45 
46 
47 #include <cairo.h>
48 #include <vector>
49 #include "palette.hpp"
50 #include "graph.hpp"
51 #include "colormap.hpp"
52 #include "coordmapper.hpp"
53 #include "interpolation.hpp"
54 
55 
66 };
67 
79 enum zscale_e {
83 };
84 
85 
90 class MeshColormap : public Colormap {
91 
92  Palette _palette;
94  interpolation_e _interpolation;
95  zscale_e _zscale;
97  double _zmin;
98  double _zmax;
100  double _datarange[4];
101  size_t _n;
102  size_t _m;
104  std::vector<double> _f;
106  Interpolation2D *_intrp;
108  bool _zscale_prepared;
109  int _sign;
110  double _scale_A;
111  double _scale_B;
112  double _scale_C;
113 
114  void prepare_zscaling( void );
115  void prepare_data_interpolation( void );
116  void plot_to_image_surface( cairo_surface_t *surface, const Coordmapper *cm, int plim[4] );
117 
118 public:
119 
122  MeshColormap();
123 
126  MeshColormap( const MeshColormap &colormap );
127 
135  MeshColormap( const double datarange[4], size_t n, size_t m,
136  const std::vector<double> &data );
137 
140  virtual ~MeshColormap();
141 
144  void clear_data( void );
145 
155  void set_data( const double datarange[4], size_t n, size_t m,
156  const std::vector<double> &data );
157 
160  bool has_data( void ) const;
161 
164  interpolation_e get_interpolation( void ) const;
165 
171  void set_interpolation( interpolation_e interpolation );
172 
178  virtual double zscale( double val );
179 
185  virtual double zscale_inv( double val );
186 
189  zscale_e get_zscale( void ) const;
190 
205  void set_zscale( zscale_e zscale );
206 
216  virtual void plot( cairo_t *cairo, const Coordmapper *cm, const double range[4] );
217 
222  virtual void plot_sample( cairo_t *cairo, double x, double y, double width, double height );
223 
229  virtual void get_bbox( double bbox[4] );
230 
233  void set_palette( const Palette &palette );
234 
237  virtual Palette &palette( void ) { return( _palette ); }
238 
241  const Palette &palette( void ) const { return( _palette ); }
242 
245  void get_zrange( double &min, double &max ) const;
246 
252  void set_zrange( double min, double max );
253 
256  double get_value( double x, double y ) const;
257 };
258 
259 
260 #endif
Abstract base class for colormap type plots.
Definition: colormap.hpp:54
Linear-linear 2D coordinate mapper.
Definition: coordmapper.hpp:119
Base class for 2d interpolation.
Definition: interpolation.hpp:57
Class for colormap type plots on a regular rectangular mesh.
Definition: meshcolormap.hpp:90
virtual double zscale(double val)
Scale value val according to zscale mode.
Definition: meshcolormap.cpp:251
MeshColormap()
Default constructor for empty colormap graph.
Definition: meshcolormap.cpp:54
void set_zrange(double min, double max)
Set zrange for colormap plot.
Definition: meshcolormap.cpp:472
void get_zrange(double &min, double &max) const
Get zrange for colormap plot.
Definition: meshcolormap.cpp:465
void set_data(const double datarange[4], size_t n, size_t m, const std::vector< double > &data)
Define colormap from data.
Definition: meshcolormap.cpp:104
virtual void get_bbox(double bbox[4])
Get bounding box of graph.
Definition: meshcolormap.cpp:450
virtual void plot(cairo_t *cairo, const Coordmapper *cm, const double range[4])
Plot graph with cairo.
Definition: meshcolormap.cpp:342
void set_interpolation(interpolation_e interpolation)
Set interpolation mode.
Definition: meshcolormap.cpp:158
virtual void plot_sample(cairo_t *cairo, double x, double y, double width, double height)
Plot sample for legend.
Definition: meshcolormap.cpp:444
double get_value(double x, double y) const
Get value of interpolated colormap data.
Definition: meshcolormap.cpp:508
zscale_e get_zscale(void) const
Get zscale mode.
Definition: meshcolormap.cpp:165
bool has_data(void) const
Does colormap have data?
virtual double zscale_inv(double val)
Inverse scale value val according to zscale mode.
Definition: meshcolormap.cpp:221
virtual ~MeshColormap()
Destructor.
Definition: meshcolormap.cpp:86
void clear_data(void)
Clears colormap data.
Definition: meshcolormap.cpp:93
void set_zscale(zscale_e zscale)
Set zscale mode.
Definition: meshcolormap.cpp:171
virtual Palette & palette(void)
Get a reference to colormap palette.
Definition: meshcolormap.hpp:237
const Palette & palette(void) const
Get a reference to colormap palette.
Definition: meshcolormap.hpp:241
interpolation_e get_interpolation(void) const
Set interpolation mode.
Definition: meshcolormap.cpp:152
void set_palette(const Palette &palette)
Set colormap palette.
Definition: meshcolormap.cpp:459
Class for palette definition.
Definition: palette.hpp:59
Colormap graph for plotting
1D and 2D coordinate transformations for plotter.
Base for plottable graphs.
Two dimensional interpolation.
interpolation_e
Interpolation type enum.
Definition: meshcolormap.hpp:62
@ INTERPOLATION_CLOSEST
Closest point interpolation.
Definition: meshcolormap.hpp:63
@ INTERPOLATION_BILINEAR
Bilinear interpolation.
Definition: meshcolormap.hpp:64
@ INTERPOLATION_BICUBIC
Bicubic interpolation.
Definition: meshcolormap.hpp:65
zscale_e
Z-scale enum.
Definition: meshcolormap.hpp:79
@ ZSCALE_LOG
Logarithmic scale.
Definition: meshcolormap.hpp:81
@ ZSCALE_LINEAR
Linear scale.
Definition: meshcolormap.hpp:80
@ ZSCALE_RELLOG
Relative logarithmic scale.
Definition: meshcolormap.hpp:82
Palette for colormaps


Reference manual for Ion Beam Simulator 1.0.6dev
Generated by Doxygen 1.9.1 on Thu Sep 11 2025 09:37:24.