casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PGPlotter.h
Go to the documentation of this file.
1 //# PGPlotter.h: Standard plotting object for application programmers.
2 //# Copyright (C) 1997,2000,2001
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //#
27 //# $Id$
28 
29 #ifndef CASA_PGPLOTTER_H
30 #define CASA_PGPLOTTER_H
31 
32 #include <casacore/casa/aips.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 class String;
40 
41 // <summary>
42 // Standard plotting object for application programmers.
43 // </summary>
44 
45 // <use visibility=export>
46 
47 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
48 // </reviewed>
49 
50 // <prerequisite>
51 // <li> <linkto class="PGPlotterInterface">PGPlotterInterface</linkto>
52 // </prerequisite>
53 //
54 // <synopsis>
55 // This is the class that a programmer should instantiate if he wants to open
56 // a "device" to plot to. The device might be local, or it might be remote
57 // (i.e., running under Glish). The philosophy of the plotting interface is
58 // described in the
59 // <linkto class="PGPlotterInterface">PGPlotterInterface</linkto> documentation.
60 //
61 // It is possible that the object might not be attached to a valid plot device
62 // (for example, the user might have said "no plotting." Programerss should
63 // check the <src>isAttached()</src> member before plotting. If you attempt to
64 // plot to an unattached plotter, an exception is thrown.
65 //
66 // Copying a <src>PGPlotter</src> uses reference semantics -- after copying
67 // plotting on the old and new objects will result in the plot commands
68 // appearing on the same device. The device is closed only when the last
69 // reference is destructed.
70 //
71 // You can detach a plotter from a device with the <src>detach()</src> call.
72 // If there are no other references to the plotter, this will close the device.
73 // (What it actually does is call the destructor on the object. For a local
74 // PGPPLOT device this will close it).
75 // </synopsis>
76 //
77 // <example>
78 // <srcblock>
79 // // plot y = x*x
80 // Vector<Float> x(100), y(100);
81 // indgen(x);
82 // y = x*x;
83 
84 // PGPlotter plotter("myplot.ps/ps");
85 // plotter.env(0, 100, 0, 100*100, 0, 0);
86 // plotter.line(x, y);
87 // </srcblock>
88 // </example>
89 //
90 // <todo asof="1997/12/31">
91 // <li> Add more plot calls.
92 // </todo>
93 
94 
96 {
97 public:
98  // Define the signature of a function creating a PGPlotter object.
99  typedef PGPlotter CreateFunction (const String &device,
100  uInt mincolors, uInt maxcolors,
101  uInt sizex, uInt sizey);
102 
103  // The default constructor does not attach to any plotter, that is
104  // <src>isAttached()</src> returns False. An exception is thrown if you
105  // attempt to plot to an unattached PGPlotter.
106  PGPlotter();
107 
108  // Create PGPlotter object using the curreent create function.
109  PGPlotter (const String &device,
110  uInt mincolors=2, uInt maxcolors=100,
111  uInt sizex=600, uInt sizey=450);
112 
113  // Create from the given PGPlotterInterface instantiation.
114  // It takes over the pointer.
116 
117  // Copies use reference semantics, i.e. after copying the new and old
118  // copy both draw onto the same surface.
119  // <group>
120  PGPlotter(const PGPlotter &other);
121  PGPlotter &operator=(const PGPlotter &other);
122  // </group>
123 
124  // If this is the last reference, close the plot.
125  virtual ~PGPlotter();
126 
127  // Create a PGPlotter object using the current create function.
128  static PGPlotter create (const String &device,
129  uInt mincolors=2, uInt maxcolors=100,
130  uInt sizex=600, uInt sizey=450);
131 
132  // Set the create function. It returns the current create function.
133  // It is, for example, used by ObjectController to attach to glish.
134  // The initial create function creates a detached PGPlotter object.
135  // If <src>override==False</src>, the function is only set if it was
136  // not already set.
138  Bool override=True);
139 
140  // True if it is OK to plot to this object.
141  virtual Bool isAttached() const;
142 
143  // Detach from the object. If this is the last reference to the object,
144  // call its destructor (this will call pgclos on a local device).
145  void detach();
146 
147  // This is not a standard PGPLOT command. In the Glish/PGPLOT window, it
148  // puts a message in the message line. By default it sends it to the logger.
149  // In any event, this is intended for short helpful messages (e.g.
150  // saying which keys to press to mark a spectrum).
151  virtual void message(const String &text);
152 
153  // This is an emulated standard PGPLOT command. It returns a record
154  // containing the fields:
155  // <srcblock>
156  // [ok=Bool, x=Float, y=Float, ch=String];
157  // If the remote device cannot do cursor feedback, ok==F.
158  // </srcblock>
159  virtual Record curs(Float x, Float y);
160 
161  // Standard PGPLOT commands. Documentation for the individual commands
162  // can be found in the Glish manual and in the standard PGPLOT documentation
163  // which may be found at <src>http://astro.caltech.edu/~tjp/pgplot/</src>.
164  // The Glish/PGPLOT documentation is preferred since this interface follows
165  // it exactly (e.g. the array sizes are inferred both here and in Glish,
166  // whereas they must be passed into standard PGPLOT).
167  // <thrown>
168  // <li> An <linkto class="AipsError">AipsError</linkto> will be thrown
169  // if the plotter is unattached.
170  // </thrown>
171  // <group>
172  virtual void arro(Float x1, Float y1, Float x2, Float y2);
173  virtual void ask(Bool flag);
174  virtual void bbuf();
175  virtual void bin(const Vector<Float> &x, const Vector<Float> &data,
176  Bool center);
177  virtual void box(const String &xopt, Float xtick, Int nxsub,
178  const String &yopt, Float ytick, Int nysub);
179  virtual void circ(Float xcent, Float ycent, Float radius);
180  virtual void conb(const Matrix<Float> &a, const Vector<Float> &c,
181  const Vector<Float> &tr, Float blank);
182  virtual void conl(const Matrix<Float> &a, Float c,
183  const Vector<Float> &tr, const String &label,
184  Int intval, Int minint);
185  virtual void cons(const Matrix<Float> &a, const Vector<Float> &c,
186  const Vector<Float> &tr);
187  virtual void cont(const Matrix<Float> &a, const Vector<Float> &c,
188  Bool nc, const Vector<Float> &tr);
189  virtual void ctab(const Vector<Float> &l, const Vector<Float> &r,
190  const Vector<Float> &g, const Vector<Float> &b,
191  Float contra, Float bright);
192  virtual void draw(Float x, Float y);
193  virtual void ebuf();
194  virtual void env(Float xmin, Float xmax, Float ymin, Float ymax, Int just,
195  Int axis);
196  virtual void eras();
197  virtual void errb(Int dir, const Vector<Float> &x, const Vector<Float> &y,
198  const Vector<Float> &e, Float t);
199  virtual void errx(const Vector<Float> &x1, const Vector<Float> &x2,
200  const Vector<Float> &y, Float t);
201  virtual void erry(const Vector<Float> &x, const Vector<Float> &y1,
202  const Vector<Float> &y2, Float t);
203  virtual void gray(const Matrix<Float> &a, Float fg, Float bg,
204  const Vector<Float> &tr);
205  virtual void hi2d(const Matrix<Float> &data, const Vector<Float> &x,
206  Int ioff, Float bias, Bool center,
207  const Vector<Float> &ylims);
208  virtual void hist(const Vector<Float> &data, Float datmin, Float datmax,
209  Int nbin, Int pcflag);
210  virtual void iden();
211  virtual void imag(const Matrix<Float> &a, Float a1, Float a2,
212  const Vector<Float> &tr);
213  virtual void lab(const String &xlbl, const String &ylbl,
214  const String &toplbl);
215  virtual void ldev();
216  virtual Vector<Float> len(Int units, const String &string);
217  virtual void line(const Vector<Float> &xpts, const Vector<Float> &ypts);
218  virtual void move(Float x, Float y);
219  virtual void mtxt(const String &side, Float disp, Float coord, Float fjust,
220  const String &text);
221  virtual String numb(Int mm, Int pp, Int form);
222  virtual void page();
223  virtual void panl(Int ix, Int iy);
224  virtual void pap(Float width, Float aspect);
225  virtual void pixl(const Matrix<Int> &ia, Float x1, Float x2,
226  Float y1, Float y2);
227  virtual void pnts(const Vector<Float> &x, const Vector<Float> &y,
228  const Vector<Int> symbol);
229  virtual void poly(const Vector<Float> &xpts, const Vector<Float> &ypts);
230  virtual void pt(const Vector<Float> &xpts, const Vector<Float> &ypts,
231  Int symbol);
232  virtual void ptxt(Float x, Float y, Float angle, Float fjust,
233  const String &text);
234  virtual Vector<Float> qah();
235  virtual Int qcf();
236  virtual Float qch();
237  virtual Int qci();
238  virtual Vector<Int> qcir();
239  virtual Vector<Int> qcol();
240  virtual Vector<Float> qcr(Int ci);
241  virtual Vector<Float> qcs(Int units);
242  virtual Int qfs();
243  virtual Vector<Float> qhs();
244  virtual Int qid();
245  virtual String qinf(const String &item);
246  virtual Int qitf();
247  virtual Int qls();
248  virtual Int qlw();
249  virtual Vector<Float> qpos();
250  virtual Int qtbg();
251  virtual Vector<Float> qtxt(Float x, Float y, Float angle, Float fjust,
252  const String &text);
253  virtual Vector<Float> qvp(Int units);
254  virtual Vector<Float> qvsz(Int units);
255  virtual Vector<Float> qwin();
256  virtual void rect(Float x1, Float x2, Float y1, Float y2);
257  virtual Float rnd(Float x, Int nsub);
258  virtual Vector<Float> rnge(Float x1, Float x2);
259  virtual void sah(Int fs, Float angle, Float vent);
260  virtual void save();
261  virtual void scf(Int font);
262  virtual void sch(Float size);
263  virtual void sci(Int ci);
264  virtual void scir(Int icilo, Int icihi);
265  virtual void scr(Int ci, Float cr, Float cg, Float cb);
266  virtual void scrn(Int ci, const String &name);
267  virtual void sfs(Int fs);
268  virtual void shls(Int ci, Float ch, Float cl, Float cs);
269  virtual void shs(Float angle, Float sepn, Float phase);
270  virtual void sitf(Int itf);
271  virtual void sls(Int ls);
272  virtual void slw(Int lw);
273  virtual void stbg(Int tbci);
274  virtual void subp(Int nxsub, Int nysub);
275  virtual void svp(Float xleft, Float xright, Float ybot, Float ytop);
276  virtual void swin(Float x1, Float x2, Float y1, Float y2);
277  virtual void tbox(const String &xopt, Float xtick, Int nxsub,
278  const String &yopt, Float ytick, Int nysub);
279  virtual void text(Float x, Float y, const String &text);
280  virtual void unsa();
281  virtual void updt();
282  virtual void vect(const Matrix<Float> &a, const Matrix<Float> &b,
283  Float c, Int nc,
284  const Vector<Float> &tr, Float blank);
285  virtual void vsiz(Float xleft, Float xright, Float ybot,
286  Float ytop);
287  virtual void vstd();
288  virtual void wedg(const String &side, Float disp, Float width,
289  Float fg, Float bg, const String &label);
290  virtual void wnad(Float x1, Float x2, Float y1, Float y2);
291  // </group>
292  private:
295 
296  // Throws an exception if !isAttached()
297  void ok() const;
298 };
299 
300 
301 } //# NAMESPACE CASACORE - END
302 
303 #endif
void detach()
Detach from the object.
virtual void cont(const Matrix< Float > &a, const Vector< Float > &c, Bool nc, const Vector< Float > &tr)
virtual void pixl(const Matrix< Int > &ia, Float x1, Float x2, Float y1, Float y2)
int Int
Definition: aipstype.h:50
virtual void save()
virtual void scf(Int font)
virtual Vector< Float > qcr(Int ci)
virtual String qinf(const String &item)
virtual void slw(Int lw)
static PGPlotter create(const String &device, uInt mincolors=2, uInt maxcolors=100, uInt sizex=600, uInt sizey=450)
Create a PGPlotter object using the current create function.
virtual void shs(Float angle, Float sepn, Float phase)
virtual void errx(const Vector< Float > &x1, const Vector< Float > &x2, const Vector< Float > &y, Float t)
virtual void vect(const Matrix< Float > &a, const Matrix< Float > &b, Float c, Int nc, const Vector< Float > &tr, Float blank)
virtual void subp(Int nxsub, Int nysub)
virtual void poly(const Vector< Float > &xpts, const Vector< Float > &ypts)
virtual void swin(Float x1, Float x2, Float y1, Float y2)
virtual void message(const String &text)
This is not a standard PGPLOT command.
virtual void scir(Int icilo, Int icihi)
virtual void env(Float xmin, Float xmax, Float ymin, Float ymax, Int just, Int axis)
void ok() const
Throws an exception if !isAttached()
virtual Int qtbg()
TableExprNode phase(const TableExprNode &node)
The phase (i.e.
Definition: ExprNode.h:1448
virtual void vstd()
virtual Record curs(Float x, Float y)
This is an emulated standard PGPLOT command.
virtual void shls(Int ci, Float ch, Float cl, Float cs)
virtual Vector< Float > qvp(Int units)
virtual void pnts(const Vector< Float > &x, const Vector< Float > &y, const Vector< Int > symbol)
PGPlotter()
The default constructor does not attach to any plotter, that is isAttached() returns False...
virtual void sitf(Int itf)
static CreateFunction * setCreateFunction(CreateFunction *, Bool override=True)
Set the create function.
virtual void mtxt(const String &side, Float disp, Float coord, Float fjust, const String &text)
virtual void conl(const Matrix< Float > &a, Float c, const Vector< Float > &tr, const String &label, Int intval, Int minint)
Abstract base class for PGPLOT style plotting.
virtual void box(const String &xopt, Float xtick, Int nxsub, const String &yopt, Float ytick, Int nysub)
virtual void ptxt(Float x, Float y, Float angle, Float fjust, const String &text)
virtual Vector< Float > qpos()
virtual void wnad(Float x1, Float x2, Float y1, Float y2)
static CreateFunction * creator_p
Definition: PGPlotter.h:294
virtual void updt()
virtual void move(Float x, Float y)
virtual void page()
virtual Int qls()
virtual Float rnd(Float x, Int nsub)
virtual void panl(Int ix, Int iy)
virtual void text(Float x, Float y, const String &text)
virtual void unsa()
virtual void circ(Float xcent, Float ycent, Float radius)
virtual String numb(Int mm, Int pp, Int form)
virtual void draw(Float x, Float y)
virtual Vector< Float > len(Int units, const String &string)
virtual void sci(Int ci)
virtual void scr(Int ci, Float cr, Float cg, Float cb)
virtual void hi2d(const Matrix< Float > &data, const Vector< Float > &x, Int ioff, Float bias, Bool center, const Vector< Float > &ylims)
virtual void bbuf()
virtual Int qcf()
Referenced counted pointer for constant data.
Definition: CountedPtr.h:80
virtual void eras()
virtual void rect(Float x1, Float x2, Float y1, Float y2)
virtual void svp(Float xleft, Float xright, Float ybot, Float ytop)
virtual ~PGPlotter()
If this is the last reference, close the plot.
virtual Vector< Int > qcol()
virtual void sls(Int ls)
virtual void wedg(const String &side, Float disp, Float width, Float fg, Float bg, const String &label)
virtual void erry(const Vector< Float > &x, const Vector< Float > &y1, const Vector< Float > &y2, Float t)
virtual void sch(Float size)
virtual void ebuf()
virtual Float qch()
virtual void errb(Int dir, const Vector< Float > &x, const Vector< Float > &y, const Vector< Float > &e, Float t)
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual void line(const Vector< Float > &xpts, const Vector< Float > &ypts)
virtual void cons(const Matrix< Float > &a, const Vector< Float > &c, const Vector< Float > &tr)
virtual void ldev()
virtual Bool isAttached() const
True if it is OK to plot to this object.
virtual Int qci()
virtual void sfs(Int fs)
virtual void pt(const Vector< Float > &xpts, const Vector< Float > &ypts, Int symbol)
float Float
Definition: aipstype.h:54
virtual Vector< Float > qah()
virtual void vsiz(Float xleft, Float xright, Float ybot, Float ytop)
virtual Vector< Float > qtxt(Float x, Float y, Float angle, Float fjust, const String &text)
virtual Int qitf()
virtual void conb(const Matrix< Float > &a, const Vector< Float > &c, const Vector< Float > &tr, Float blank)
virtual void ctab(const Vector< Float > &l, const Vector< Float > &r, const Vector< Float > &g, const Vector< Float > &b, Float contra, Float bright)
virtual void bin(const Vector< Float > &x, const Vector< Float > &data, Bool center)
virtual void scrn(Int ci, const String &name)
virtual Vector< Float > qvsz(Int units)
virtual void hist(const Vector< Float > &data, Float datmin, Float datmax, Int nbin, Int pcflag)
virtual void gray(const Matrix< Float > &a, Float fg, Float bg, const Vector< Float > &tr)
virtual Int qfs()
Standard plotting object for application programmers.
Definition: PGPlotter.h:95
virtual void stbg(Int tbci)
virtual Vector< Int > qcir()
virtual void ask(Bool flag)
const Double e
e and functions thereof:
virtual void arro(Float x1, Float y1, Float x2, Float y2)
Standard PGPLOT commands.
const Double c
Fundamental physical constants (SI units):
PGPlotter & operator=(const PGPlotter &other)
PGPlotter CreateFunction(const String &device, uInt mincolors, uInt maxcolors, uInt sizex, uInt sizey)
Define the signature of a function creating a PGPlotter object.
Definition: PGPlotter.h:99
String: the storage and methods of handling collections of characters.
Definition: String.h:225
virtual void pap(Float width, Float aspect)
virtual void iden()
virtual Int qlw()
virtual Vector< Float > rnge(Float x1, Float x2)
virtual void tbox(const String &xopt, Float xtick, Int nxsub, const String &yopt, Float ytick, Int nysub)
virtual void sah(Int fs, Float angle, Float vent)
virtual Vector< Float > qhs()
virtual Vector< Float > qcs(Int units)
CountedPtr< PGPlotterInterface > worker_p
Definition: PGPlotter.h:293
virtual Int qid()
virtual void imag(const Matrix< Float > &a, Float a1, Float a2, const Vector< Float > &tr)
const Bool True
Definition: aipstype.h:43
virtual Vector< Float > qwin()
unsigned int uInt
Definition: aipstype.h:51
virtual void lab(const String &xlbl, const String &ylbl, const String &toplbl)