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
xygraph.hpp
Go to the documentation of this file.
1 
5 /* Copyright (c) 2005-2011,2013,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 XYGRAPH_HPP
44 #define XYGRAPH_HPP 1
45 
46 
47 #include <cairo.h>
48 #include <vector>
49 #include "vec3d.hpp"
50 #include "graph.hpp"
51 #include "coordmapper.hpp"
52 
53 
59 };
60 
61 
68 };
69 
70 
75 class XYGraph : public Graph {
76 
77  double _linewidth;
78  Vec3D _color;
79  line_style_e _linestyle;
80  point_style_e _pointstyle;
81  bool _point_filled;
82  double _point_scale;
83  bool _histogram;
84  bool _extend_histogram;
85 
86  std::vector<double> _xdata;
87  std::vector<double> _ydata;
88 
89  void plot_point( cairo_t *cairo, double x, double y );
90  void plot_standard_lines( cairo_t *cairo, const Coordmapper *cm, const double range[4], size_t N );
91  void plot_histogram_lines( cairo_t *cairo, const Coordmapper *cm, const double range[4], size_t N );
92 
93 public:
94 
97  XYGraph();
98 
104  XYGraph( const std::vector<double> &xdata,
105  const std::vector<double> &ydata );
106 
109  virtual ~XYGraph() {}
110 
120  virtual void plot( cairo_t *cairo, const Coordmapper *cm, const double range[4] );
121 
126  virtual void plot_sample( cairo_t *cairo, double x, double y, double width, double height );
127 
133  virtual void get_bbox( double bbox[4] );
134 
137  void set_data( const std::vector<double> &xdata,
138  const std::vector<double> &ydata );
139 
144  void set_line_width( double linewidth );
145 
150  void set_color( const Vec3D &color );
151 
156  void set_line_style( line_style_e linestyle,
157  double linewidth = 1.0 );
158 
163  void set_point_style( point_style_e pointstyle, bool filled = true, double scale = 1.0 );
164 
169  void set_histogram( bool histo );
170 
176  void extend_histogram( bool extend );
177 
178 };
179 
180 
181 #endif
Linear-linear 2D coordinate mapper.
Definition: coordmapper.hpp:119
Abstract base class for drawable plots.
Definition: graph.hpp:56
Three dimensional vector.
Definition: vec3d.hpp:58
Class for XY-type simple graph plots.
Definition: xygraph.hpp:75
virtual void get_bbox(double bbox[4])
Get bounding box of graph.
Definition: xygraph.cpp:205
void set_data(const std::vector< double > &xdata, const std::vector< double > &ydata)
Set new data arrays.
Definition: xygraph.cpp:226
void set_histogram(bool histo)
Set histogram style.
Definition: xygraph.cpp:261
virtual void plot_sample(cairo_t *cairo, double x, double y, double width, double height)
Plot sample for legend.
Definition: xygraph.cpp:186
virtual void plot(cairo_t *cairo, const Coordmapper *cm, const double range[4])
Plot graph with cairo.
Definition: xygraph.cpp:160
void set_color(const Vec3D &color)
Set graph color.
Definition: xygraph.cpp:234
void extend_histogram(bool extend)
Extend histogram.
Definition: xygraph.cpp:267
virtual ~XYGraph()
Destructor.
Definition: xygraph.hpp:109
void set_point_style(point_style_e pointstyle, bool filled=true, double scale=1.0)
Set point style.
Definition: xygraph.cpp:253
void set_line_width(double linewidth)
Set line width.
Definition: xygraph.cpp:240
XYGraph()
Default constructor for empty graph.
Definition: xygraph.cpp:50
void set_line_style(line_style_e linestyle, double linewidth=1.0)
Set line style.
Definition: xygraph.cpp:246
1D and 2D coordinate transformations for plotter.
Base for plottable graphs.
Three dimensional vectors.
point_style_e
XYGraph point style.
Definition: xygraph.hpp:64
@ XYGRAPH_POINT_DISABLE
Disable data point plotting.
Definition: xygraph.hpp:65
@ XYGRAPH_POINT_CIRCLE
Draw a circle.
Definition: xygraph.hpp:66
@ XYGRAPH_POINT_BOX
Draw a box.
Definition: xygraph.hpp:67
line_style_e
XYGraph line style.
Definition: xygraph.hpp:56
@ XYGRAPH_LINE_SOLID
Regular line between data points.
Definition: xygraph.hpp:58
@ XYGRAPH_LINE_DISABLE
Disable line plotting.
Definition: xygraph.hpp:57


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