libpgplotxx.a (C++ interface to PGPLOT)
pgplotxxdemo.cc
Go to the documentation of this file.
1 
36 #include<iostream>
37 #include<string>
38 #include<cmath>
39 #include<pgplotxx/pgplotxx.h>
40 #include<pgplotxx/affpgplot.h>
41 #include<aff/shaper.h>
42 #include<aff/subarray.h>
43 #include<aff/seriesoperators.h>
44 
45 using std::cout;
46 using std::endl;
47 
55 {
56  cout << "pgplotxxdemo" << endl;
57  cout << "(example program for the C++ interface for PGPLOT)" << endl;
58 
59  /*
60  pgplot::device d("/xserve");
61  d.env(1.,5.,1.,10.,0,2);
62  */
63  pgplot::device d2("/xserve");
64  d2.subp(2,1);
65  /*
66  d2.env(1.,5.,1.,10.,1,2);
67  pgplot::basic_device::ldev();
68  */
69 
70  //----------------------------------------------------------------------
71  // go for gray plot
72 
73  pgplot::pgaff::Tarray A(aff::Shaper(0,6)(-3,3));
74  for (int i=A.first(0); i<=A.last(0); ++i)
75  {
76  for (int j=A.first(1); j<=A.last(1); ++j)
77  {
78  A(i,j)=float(5*i+j);
79  }
80  }
81 
82  pgplot::pgaff::Tarray B1=aff::subarray(A)(4,6)(1,2);
83  pgplot::pgaff::Tarray B2=aff::subarray(A)(0,4)(1,3);
84 
85  pgplot::Trect cwin(pgplot::Trange(-1.,3.),pgplot::Trange(-5.,5.));
86 
87  /*
88  d2.ask();
89  d2.env(cwin);
90  pgplot::pgaff::Ttransform tr=pgplot::pgaff::create_transform(A,cwin);
91  pgplot::Trange vrange=pgplot::pgaff::array_value_range(A).swap();
92  pgplot::pgaff::gray(d2, A, vrange, tr).gwedg(vrange);
93  */
94  d2.env(cwin);
96  pgplot::pgaff::gray(d2, B1, vrange).gwedg(vrange);
97  d2.env(cwin);
98  pgplot::pgaff::gray(d2, B1, false).gwedg(vrange.swap());
99  d2.env(cwin);
100  pgplot::pgaff::gray(d2, B2);
101  d2.env(cwin);
102  pgplot::pgaff::gray(d2, A);
103  /*
104  d2.env(cwin);
105  tr=pgplot::pgaff::create_transform(B2,cwin);
106  vrange=pgplot::pgaff::array_value_range(B2).swap();
107  pgplot::pgaff::gray(d2, B2, vrange, tr).gwedg(vrange);
108  */
109 
110  //----------------------------------------------------------------------
111 
112  const int imax=100;
113  pgplot::pgaff::Tseries x(0,imax-1);
114  pgplot::pgaff::Tseries y(0,imax-1);
115  for (int i=0; i<imax; ++i)
116  {
117  x(i)=std::sin(2.*3.14159265*i/imax);
118  y(i)=std::cos(2.*3.14159265*i/imax);
119  }
120  d2.subp(1,1).env(-1.,1.,-1.,1.,1,2);
121  pgplot::pgaff::line(d2,x,y);
122  pgplot::pgaff::pt(d2,0.6*x,0.6*y,-3);
123  for (int i=0; i<imax; ++i)
124  {
125  d2.pt1(x(i),y(i),i);
126  d2.pt1(0.8*x(i),0.8*y(i),-i);
127  }
128 
129 }
130 
131 /* ----- END OF pgplotxxdemo.cc ----- */
Trange & swap()
swap range
Definition: structs.h:118
Trange array_value_range(const Tarray::Tcoc &a)
return range of values
Definition: affpgplot.cc:164
hold any parameter range
Definition: structs.h:42
pgplot functions supporting aff containers (prototypes)
pgplot::basic_device & gray(pgplot::basic_device &dev, const Tarray &a, const pgplot::Trange &range, const Ttransform &tr)
function to plot gray image
Definition: affpgplot.cc:52
C++ interface for PGPLOT.
basic_device & gwedg(const Trange &range, const char *label="value", const float &disp=0.3, const float &width=3.0, const char *side="RG")
annotate an image plot with a wedge
Definition: basicdevice.h:537
main()
example program
Definition: pgplotxxdemo.cc:54
aff::Series< float > Tseries
Definition: affpgplot.h:67
aff::Array< float > Tarray
array type to be passed to gray function
Definition: affpgplot.h:66
basic_device & env(const float &xmin, const float &xmax, const float &ymin, const float &ymax, const int &just=0, const int &axis=0)
define PGPLOT window and axis
Definition: basicdevice.h:153
basic_device & subp(int nxsub, int nysub)
subdivide view surface into panels
Definition: basicdevice.h:454
basic_device & pt1(float xpt, float ypt, int symbol)
draw one marker symbol
Definition: basicdevice.h:259
hold any rectangle
Definition: structs.h:130
the standard device class
Definition: device.h:44
T & line(T &dev, const SX &x, const SY &y)
draw an open polygon from a dense series
Definition: affpgplot.h:112
T & pt(T &dev, const SX &x, const SY &y, const int &s)
draw symbols from series
Definition: affpgplot.h:198