libpgplotxx.a (C++ interface to PGPLOT)
affpgplot.cc
Go to the documentation of this file.
1 
36 #define TF_AFFPGPLOT_CC_VERSION \
37  "TF_AFFPGPLOT_CC V1.1"
38 #define TF_AFFPGPLOT_CC_CVSID \
39  "$Id$"
40 
41 #include<iostream>
42 #include<pgplotxx/affpgplot.h>
43 #include<aff/fortranshape.h>
44 #include<aff/lib/collector.h>
45 
46 namespace pgplot {
47 
49  namespace pgaff {
50 
53  const Tarray& a,
54  const pgplot::Trange& range,
55  const Ttransform& tr)
56  {
57  aff::FortranArray<Tarray> fa(a, true);
58  float* pa=fa.castedpointer<float>();
59  int f1=fa.first(0);
60  int f2=fa.first(1);
61  int l1=fa.last(0);
62  int l2=fa.last(1);
63  int d1=fa.dimlast(0);
64  int d2=fa.dimlast(1);
65  dev.gray(pa, d1, d2, f1, l1, f2, l2,
66  range.min, range.max,
67  tr.pointer());
68  return(dev);
69  }
70 
71  /*----------------------------------------------------------------------*/
72 
75  const Tarray& a,
76  const pgplot::Trange& range,
77  const bool& xisfirst)
78  {
79  Trect win;
80  dev.qwin(win);
81  Ttransform tr=create_transform(a, win, xisfirst);
82  gray(dev,a,range,tr);
83  return(dev);
84  }
85 
86  /*----------------------------------------------------------------------*/
87 
90  const Tarray& a,
91  const bool& xisfirst)
92  {
93  Trect win;
94  dev.qwin(win);
95  Trange vrange=array_value_range(a);
96  gray(dev,a,vrange,xisfirst);
97  return(dev);
98  }
99 
100  /*----------------------------------------------------------------------*/
101 
102  Ttransform create_transform(const Tarray::Tcoc& a,
103  const pgplot::Trect& rect,
104  const bool& xisfirst)
105  {
106  Ttransform retval;
107  Tarray::Tshape shape(a.shape());
108  shape.setfirst(Tarray::Tshape::TIndexVec(1));
109  retval=0.;
110  int ix,iy,ibx,iby,nx,ny,fx,fy;
111  ibx=0;
112  iby=3;
113  if (xisfirst)
114  {
115  ix=1;
116  iy=5;
117  nx=shape.size(0);
118  ny=shape.size(1);
119  fx=shape.first(0);
120  fy=shape.first(1);
121  }
122  else
123  {
124  ix=2;
125  iy=4;
126  nx=shape.size(1);
127  ny=shape.size(0);
128  fx=shape.first(1);
129  fy=shape.first(0);
130  }
131  Trange xrange=rect.x;
132  Trange yrange=rect.y;
133  retval[ix]=xrange.fullrange()/float(nx);
134  retval[iy]=yrange.fullrange()/float(ny);
135  retval[ibx]=xrange.min-retval[ix]*(float(fx)-0.5);
136  retval[iby]=yrange.min-retval[iy]*(float(fy)-0.5);
137  return(retval);
138  }
139 
140  /*----------------------------------------------------------------------*/
141 
142  namespace util
143  {
144 
145  template<class C>
146  class Extractrange {
147  typedef typename C::Tcoc Tcont;
148  typedef typename C::Tvalue Tvalue;
149  public:
150  typedef Trange Tretval;
152  Extractrange(const Tcont& c): Mrange(c(c.first()),c(c.first())) { }
154  void operator() (const Tvalue& v)
155  { Mrange.extend(Trange(v,v)); }
157  Tretval result() const { return(Mrange); }
158  private:
160  }; // class Extractrange
161 
162  } // namespace util
163 
164  Trange array_value_range(const Tarray::Tcoc& a)
165  {
166  return(aff::func::util::collect<Tarray::Tcoc, util::Extractrange>(a));
167  } // array_value_range
168 
169  Trange series_value_range(const Tseries::Tcoc& a)
170  {
171  return(aff::func::util::collect<Tseries::Tcoc, util::Extractrange>(a));
172  } // array_value_range
173 
174  } // namespace pgaff
175 
176 } // namespace pgplot
177 /* ----- END OF affpgplot.cc ----- */
basic_device & qwin(float *x1, float *x2, float *y1, float *y2)
inquire window boundary coordinates
Definition: basicdevice.h:346
contains all pgplot stuff
Definition: affpgplot.cc:46
Trange array_value_range(const Tarray::Tcoc &a)
return range of values
Definition: affpgplot.cc:164
hold any parameter range
Definition: structs.h:42
Tretval result() const
return result of operation
Definition: affpgplot.cc:157
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
Trange x
coordinate ranges
Definition: structs.h:132
Trange & extend(const Trange &range)
extend this range if argument range is larger
Definition: structs.h:54
float fullrange() const
return absolute range
Definition: structs.h:91
Trange y
Definition: structs.h:132
aff::Array< float > Tarray
array type to be passed to gray function
Definition: affpgplot.h:66
Trange series_value_range(const Tseries::Tcoc &a)
Definition: affpgplot.cc:169
pgplot base class
Definition: basicdevice.h:57
aff::SimpleRigidArray< float, 6 > Ttransform
transform matrix for gray shade plot function
Definition: affpgplot.h:63
void operator()(const Tvalue &v)
collect another value
Definition: affpgplot.cc:154
basic_device & gray(const float *a, int idim, int jdim, int i1, int i2, int j1, int j2, float fg, float bg, const float *tr)
plot gray scale image
Definition: basicdevice.h:188
float min
range [min....max]
Definition: structs.h:44
hold any rectangle
Definition: structs.h:130
Extractrange(const Tcont &c)
initialize member data
Definition: affpgplot.cc:152
float max
Definition: structs.h:44
Ttransform create_transform(const Tarray::Tcoc &a, const pgplot::Trect &rect, const bool &xisfirst)
create standard transform array
Definition: affpgplot.cc:102