Navigation

Main Page
Download
Support
Installation
Tutorial
Examples
Reference Manual
   Version 1.0.5new_solver
      Class Index
      File List
   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
legend.hpp
Go to the documentation of this file.
1 
5 /* Copyright (c) 2005-2013 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 LEGEND_HPP
44 #define LEGEND_HPP 1
45 
46 
47 #include <vector>
48 #include <string>
49 #include "graph.hpp"
50 #include "label.hpp"
51 #include "vec3d.hpp"
52 #include "colormap.hpp"
53 
54 
60  LEGEND_POS_BOTTOM_LEFT = 0,
61  LEGEND_POS_BOTTOM_CENTER = 1,
62  LEGEND_POS_BOTTOM_RIGHT = 2,
63 
64  LEGEND_POS_MIDDLE_LEFT = 4+0,
65  LEGEND_POS_MIDDLE_CENTER = 4+1,
66  LEGEND_POS_MIDDLE_RIGHT = 4+2,
67 
68  LEGEND_POS_TOP_LEFT = 8+0,
69  LEGEND_POS_TOP_CENTER = 8+1,
70  LEGEND_POS_TOP_RIGHT = 8+2
71 };
72 
73 
74 #define LEGEND_POS_VERTICAL_MASK 12
75 #define LEGEND_POS_HORIZONTAL_MASK 3
76 
77 #define LEGEND_POS_BOTTOM 0
78 #define LEGEND_POS_MIDDLE 4
79 #define LEGEND_POS_TOP 8
80 
81 #define LEGEND_POS_LEFT 0
82 #define LEGEND_POS_CENTER 1
83 #define LEGEND_POS_RIGHT 2
84 
85 
94 class LegendEntry {
95 
96  Graph &_graph;
97  Label _label;
99 public:
100 
103  LegendEntry( Graph &graph, const std::string &label )
104  : _graph(graph), _label(label) {}
105 
108  LegendEntry( const LegendEntry &le )
109  : _graph(le._graph), _label(le._label) {}
110 
114 
118  _graph = le._graph;
119  _label = le._label;
120  return( *this );
121  }
122 
127  void plot( cairo_t *cairo, double x, double y );
128 
131  void get_size( cairo_t *cairo, double &width, double &height );
132 
135  void set_font_size( double fontsize );
136 };
137 
138 
150 class Legend {
151 
152 public:
153 
156  Legend() {}
157 
160  virtual ~Legend() {}
161 
166  virtual void plot( cairo_t *cairo, double x, double y ) = 0;
167 
170  virtual void get_size( cairo_t *cairo, double &width, double &height ) = 0;
171 };
172 
173 
176 class MultiEntryLegend : public Legend {
177 
178  double _fontsize;
179  std::vector<LegendEntry *> _entry;
181 public:
182 
186 
189  virtual ~MultiEntryLegend() {}
190 
195  virtual void plot( cairo_t *cairo, double x, double y );
196 
199  virtual void get_size( cairo_t *cairo, double &width, double &height );
200 
203  void set_font_size( double fontsize );
204 
207  double get_font_size( void );
208 
211  void add_entry( LegendEntry *entry );
212 
215  void clear_entries( void );
216 };
217 
218 
223 class ColormapLegend : public Legend {
224 
225  struct Tic {
226  double _loc;
227  Label _label;
231  Tic( double loc, const std::string &label ) : _loc(loc), _label(label) {}
232  };
233 
234  double _width;
235  double _height;
237  double _fontsize;
238  Vec3D _color;
239 
240  double _ticlen_in;
241  double _ticlen_out;
242  double _ticspace;
243 
244  double _range[2];
245  std::vector<Tic> _tic;
246 
247  Colormap &_colormap;
248 
249  void build_legend( double x, double y );
250  void plot_colormap_palette_to_image_surface( cairo_surface_t *surface, int plim[4] );
251  void plot_colomap_palette( cairo_t *cairo, int plim[4] );
252 
253 public:
254 
257  ColormapLegend( Colormap &colormap );
258 
261  virtual ~ColormapLegend() {}
262 
267  virtual void plot( cairo_t *cairo, double x, double y );
268 
271  virtual void get_size( cairo_t *cairo, double &width, double &height );
272 
275  void set_font_size( double fontsize );
276 
279  void set_color( const Vec3D &color );
280 
283  void set_height( double height );
284 };
285 
286 
287 #endif
288 
LegendEntry(Graph &graph, const std::string &label)
Contructor for legend entry.
Definition: legend.hpp:103
LegendEntry(const LegendEntry &le)
Copy constructor.
Definition: legend.hpp:108
Abstract base class for drawable plots.
Definition: graph.hpp:56
virtual void get_size(cairo_t *cairo, double &width, double &height)
Get size of legend.
Definition: legend.cpp:336
~LegendEntry()
Destructor.
Definition: legend.hpp:113
Base for plottable graphs.
Plot labels.
Legend()
Default constructor for legend.
Definition: legend.hpp:156
MultiEntryLegend()
Default constructor for legend.
Definition: legend.cpp:89
Three dimensional vectors.
virtual void plot(cairo_t *cairo, double x, double y)=0
Plot legend at (x,y).
virtual ~MultiEntryLegend()
Virtual destructor.
Definition: legend.hpp:189
void plot(cairo_t *cairo, double x, double y)
Plot legend entry at (x,y).
Definition: legend.cpp:58
Class for labels in plots.
Definition: label.hpp:56
Abstract base class for colormap type plots.
Definition: colormap.hpp:54
void set_height(double height)
Set height of legend.
Definition: legend.cpp:363
void add_entry(LegendEntry *entry)
Add entry to legend.
Definition: legend.cpp:96
virtual void get_size(cairo_t *cairo, double &width, double &height)
Get size of legend.
Definition: legend.cpp:124
Class for legend entry.
Definition: legend.hpp:94
virtual void plot(cairo_t *cairo, double x, double y)
Plot legend at (x,y).
Definition: legend.cpp:303
void set_font_size(double fontsize)
Set font size for legend labels.
Definition: legend.cpp:353
void set_font_size(double fontsize)
Set font size for legend labels.
Definition: legend.cpp:151
virtual ~ColormapLegend()
Virtual destructor.
Definition: legend.hpp:261
Base class for legend definition.
Definition: legend.hpp:150
Colormap graph for plotting
virtual ~Legend()
Virtual destructor.
Definition: legend.hpp:160
legend_position_e
Legend position.
Definition: legend.hpp:59
double get_font_size(void)
Get font size.
Definition: legend.cpp:145
Legend for presenting colormap key.
Definition: legend.hpp:223
void set_color(const Vec3D &color)
Set ruler color.
ColormapLegend(Colormap &colormap)
Default constructor for legend.
Definition: legend.cpp:165
virtual void plot(cairo_t *cairo, double x, double y)
Plot legend at (x,y).
Definition: legend.cpp:110
Three dimensional vector.
Definition: vec3d.hpp:58
LegendEntry & operator=(const LegendEntry &le)
Assignment operator.
Definition: legend.hpp:117
void get_size(cairo_t *cairo, double &width, double &height)
Get size of legend entry.
Definition: legend.cpp:68
void clear_entries(void)
Clear legend entries.
Definition: legend.cpp:104
virtual void get_size(cairo_t *cairo, double &width, double &height)=0
Get size of legend.
void set_font_size(double fontsize)
Set font size for legend labels.
Definition: legend.cpp:79
Legend for presenting plot styles.
Definition: legend.hpp:176


Reference manual for Ion Beam Simulator 1.0.5new_solver
Generated by Doxygen 1.8.5 on Tue May 19 2015 09:15:42.