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
frame.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 FRAME_HPP
44 #define FRAME_HPP 1
45 
46 
47 #include <string>
48 #include <vector>
49 #include <cairo.h>
50 #include "vec3d.hpp"
51 #include "ruler.hpp"
52 #include "coordmapper.hpp"
53 #include "graph.hpp"
54 #include "legend.hpp"
55 
56 
57 
68  PLOT_FIXED_ASPECT_DISABLED = 0,
69  PLOT_FIXED_ASPECT_EXTEND_RANGE,
70  PLOT_FIXED_ASPECT_INCREASE_MARGIN
71 };
72 
73 
81 enum PlotAxis {
82  PLOT_AXIS_X1 = 0,
83  PLOT_AXIS_Y1,
84  PLOT_AXIS_X2,
85  PLOT_AXIS_Y2,
86  PLOT_AXIS_Z
87 };
88 
89 
90 
107 class Frame {
108 
111  struct DObj {
112  PlotAxis _xaxis;
113  PlotAxis _yaxis;
114  Graph *_graph;
116  DObj( PlotAxis xaxis, PlotAxis yaxis, Graph *graph )
117  : _xaxis(xaxis), _yaxis(yaxis), _graph(graph) {}
118  };
119 
120  Ruler _ruler[4];
121  Coordmapper1D _cm[4];
122  bool _enable[4];
123  bool _fenable[4];
124  bool _autorange[8];
125  double _range_min[4];
126  double _range_max[4];
128  int _offx;
129  int _offy;
131  int _width;
132  int _height;
134  double _fontsize;
135  double _titlespace;
136  double _cmlspace;
137  Vec3D _bg;
138  Vec3D _fg;
140  std::vector<DObj> _dobj;
142  bool _legend_enable;
143  legend_position_e _legend_pos;
144  MultiEntryLegend _legend;
145  ColormapLegend *_cm_legend;
146  bool _cml_enable;
148  Label _title;
150  PlotFixedMode _fixedaspect;
152  bool _automargin;
153  double _tmargin[4];
160  void build_colormap_legend( void );
161  void draw_colormap_legend( cairo_t *cairo );
162  void draw_legend( cairo_t *cairo );
163  void calculate_autoranging( void );
164  void calculate_ruler_autoenable( void );
165  void calculate_rulers( cairo_t *cairo, bool ruler_tic_bbox_test );
166  void calculate_frame( cairo_t *cairo );
167  void draw_frame( cairo_t *cairo );
168  void mirror_rulers( void );
169  void set_frame_clipping( cairo_t *cairo );
170  void unset_frame_clipping( cairo_t *cairo );
171 
172 public:
173 
176  Frame();
177 
180  Frame( const Frame &frame );
181 
184  ~Frame();
185 
193  void set_geometry( int width, int height, int offx, int offy ) {
194  _width = width;
195  _height = height;
196  _offx = offx;
197  _offy = offy;
198  }
199 
202  void set_font_size( double size );
203 
206  double get_font_size( void ) {
207  return( _fontsize );
208  }
209 
212  void set_background( Vec3D &bg ) {
213  _bg = bg;
214  }
215 
218  void set_foreground( Vec3D &fg ) {
219  _fg = fg;
220  }
221 
227  Coordmapper get_coordmapper( PlotAxis xaxis, PlotAxis yaxis ) const;
228 
231  void get_margins( double margin[4] ) const;
232 
238  void get_frame_edges( double edge[4] ) const;
239 
242  void set_title( const std::string &title );
243 
246  void set_axis_label( PlotAxis axis, const std::string &label );
247 
254  void force_enable_ruler( PlotAxis axis, bool force );
255 
262  void ruler_autorange_enable( PlotAxis axis, bool min, bool max );
263 
270  void set_ranges( PlotAxis axis, double min, double max );
271 
277  void get_ranges( PlotAxis axis, double &min, double &max ) const;
278 
290  void set_fixed_aspect( PlotFixedMode mode );
291 
304  void set_automargin( bool enable );
305 
314  void add_graph( PlotAxis xaxis, PlotAxis yaxis,
315  Graph *graph, LegendEntry *legend = NULL );
316 
322  void clear_graphs( void );
323 
326  void enable_colormap_legend( bool enable );
327 
330  void enable_legend( bool enable );
331 
335 
338  //void set_colormap_legend( ColormapLegend *legend );
339 
353  void draw( cairo_t *cairo );
354 };
355 
356 
357 #endif
358 
Legend for presenting colormap key.
Definition: legend.hpp:223
Linear 1D coordinate mapper.
Definition: coordmapper.hpp:57
Linear-linear 2D coordinate mapper.
Definition: coordmapper.hpp:119
General purpose plotter frame for cairographics surfaces.
Definition: frame.hpp:107
void set_title(const std::string &title)
Set title for plot.
Definition: frame.cpp:244
void force_enable_ruler(PlotAxis axis, bool force)
Force enable ruler for axis.
Definition: frame.cpp:460
Coordmapper get_coordmapper(PlotAxis xaxis, PlotAxis yaxis) const
Get a 2d coordinate mapper for selected axes.
Definition: frame.cpp:268
void clear_graphs(void)
Clear all graphs from frame.
Definition: frame.cpp:202
void enable_colormap_legend(bool enable)
Set colormap legend enable/disable.
Definition: frame.cpp:720
void set_automargin(bool enable)
Set automatic margin setting on or off.
Definition: frame.cpp:182
void set_ranges(PlotAxis axis, double min, double max)
Set coordinate ranges for axis.
Definition: frame.cpp:274
void enable_legend(bool enable)
Set legend enable/disable.
Definition: frame.cpp:210
void get_margins(double margin[4]) const
Get margins.
Definition: frame.cpp:250
void set_background(Vec3D &bg)
Set background color.
Definition: frame.hpp:212
void set_axis_label(PlotAxis axis, const std::string &label)
Set axis label.
Definition: frame.cpp:149
void set_font_size(double size)
Set font size used for tics and labels.
Definition: frame.cpp:169
void set_foreground(Vec3D &fg)
Set foreground color.
Definition: frame.hpp:218
void get_frame_edges(double edge[4]) const
Get frame edge locations.
Definition: frame.cpp:259
~Frame()
Destructor.
Definition: frame.cpp:126
double get_font_size(void)
Get font size used for tics and labels.
Definition: frame.hpp:206
void get_ranges(PlotAxis axis, double &min, double &max) const
Get coordinate ranges for axis.
Definition: frame.cpp:318
void add_graph(PlotAxis xaxis, PlotAxis yaxis, Graph *graph, LegendEntry *legend=NULL)
Add graph to frame.
Definition: frame.cpp:194
void set_legend_position(legend_position_e pos)
Set legend position.
Definition: frame.cpp:216
Frame()
Default constructor.
Definition: frame.cpp:61
void ruler_autorange_enable(PlotAxis axis, bool min, bool max)
Enable/disable ruler autorange.
Definition: frame.cpp:222
void set_geometry(int width, int height, int offx, int offy)
Set size of plot.
Definition: frame.hpp:193
void draw(cairo_t *cairo)
Set colormap legend.
Definition: frame.cpp:806
void set_fixed_aspect(PlotFixedMode mode)
Set fixed aspect ratio mode.
Definition: frame.cpp:188
Abstract base class for drawable plots.
Definition: graph.hpp:56
Class for labels in plots.
Definition: label.hpp:57
Class for legend entry.
Definition: legend.hpp:94
Legend for presenting plot styles.
Definition: legend.hpp:176
Class for coordinate axis ruler.
Definition: ruler.hpp:62
Three dimensional vector.
Definition: vec3d.hpp:58
1D and 2D coordinate transformations for plotter.
PlotFixedMode
Fixed aspect ratio setting for frame.
Definition: frame.hpp:67
PlotAxis
Axis specification for plots.
Definition: frame.hpp:81
Base for plottable graphs.
Plot legends.
legend_position_e
Legend position.
Definition: legend.hpp:59
Rulers for plot frames.
Three dimensional vectors.


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