KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gr_plot.h
Go to the documentation of this file.
1 /* =========================================================================== *
2 |
3 | Copyright (c) 1994-2008 by Kobus Barnard (author).
4 |
5 | Personal and educational use of this code is granted, provided that this
6 | header is kept intact, and that the authorship is not misrepresented, that
7 | its use is acknowledged in publications, and relevant papers are cited.
8 |
9 | For other use contact the author (kobus AT cs DOT arizona DOT edu).
10 |
11 | Please note that the code in this file has not necessarily been adequately
12 | tested. Naturally, there is no guarantee of performance, support, or fitness
13 | for any particular task. Nonetheless, I am interested in hearing about
14 | problems that you encounter.
15 |
16 | Author: Ernesto Brau
17 |
18 * =========================================================================== */
19 
20 /* $Id: gr_plot.h 18278 2014-11-25 01:42:10Z ksimek $ */
21 
22 #ifndef KJB_CPP_GR_PLOT_H
23 #define KJB_CPP_GR_PLOT_H
24 
25 #include <string>
26 #include <iterator>
27 #include <vector>
28 #include <m_cpp/m_vector.h>
29 
30 namespace kjb {
31 namespace opengl {
32 
33 
34 #ifdef KJB_HAVE_GLUT
35 #warning "[Code police] Put KJB_HAVE_* guards inside functions"
36 class Glut_window;
37 
38 class Glut_plot_window
39 {
40 public:
42  Glut_plot_window(size_t width, size_t height, const std::string& title);
43 
44  virtual ~Glut_plot_window();
45 
47  Glut_plot_window& add_plot(const Vector& x, const Vector& y);
48 
50  Glut_plot_window& add_plot(const Vector* x, const Vector* y);
51 
53  template<class OutIt>
54  Glut_plot_window& add_plot(OutIt first_x, OutIt last_x, OutIt first_y)
55  {
56  OutIt last_y = first_y;
57  std::advance(last_y, std::distance(first_x, last_x));
58 
59  Vector x(first_x, last_x);
60  Vector y(first_y, last_y);
61 
62  return add_plot(x, y);
63  }
64 
66  void update_bounds();
67 
69  void redisplay() const;
70 
71 private:
73  void render() const;
74 
76  void reshape(int w, int h);
77 
79  void update_bounds(const Vector& x, const Vector& y);
80 
81  Glut_window* wnd_;
82  std::vector<Vector> x_;
83  std::vector<Vector> y_;
84  std::vector<const Vector*> xp_;
85  std::vector<const Vector*> yp_;
86  double xmin_;
87  double xmax_;
88  double ymin_;
89  double ymax_;
90  static const size_t xmargin_ = 74;
91  static const size_t ymargin_ = 20;
92 };
93 #endif
94 
95 }} //namespace kjb::opengl
96 
97 #endif /*KJB_CPP_GR_PLOT_H */
98 
height
Definition: APPgetLargeConnectedEdges.m:33
x
Definition: APPgetLargeConnectedEdges.m:100
void render(const Cuboid &c)
Definition: psi_weighted_box.cpp:56
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...