casacore
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>
33#include <casacore/casa/Arrays/ArrayFwd.h>
34#include <casacore/casa/System/PGPlotterInterface.h>
35#include <casacore/casa/Utilities/CountedPtr.h>
36
37namespace casacore { //# NAMESPACE CASACORE - BEGIN
38
39class 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{
97public:
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.
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);
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);
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();
244 virtual Int qid();
245 virtual String qinf(const String &item);
246 virtual Int qitf();
247 virtual Int qls();
248 virtual Int qlw();
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);
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
Referenced counted pointer for constant data.
Definition: CountedPtr.h:81
virtual void arro(Float x1, Float y1, Float x2, Float y2)
Standard PGPLOT commands.
virtual void pap(Float width, Float aspect)
virtual void cont(const Matrix< Float > &a, const Vector< Float > &c, Bool nc, const Vector< Float > &tr)
virtual void lab(const String &xlbl, const String &ylbl, const String &toplbl)
virtual String qinf(const String &item)
virtual void iden()
PGPlotter(const PGPlotter &other)
Copies use reference semantics, i.e.
virtual void circ(Float xcent, Float ycent, Float radius)
virtual void save()
PGPlotter()
The default constructor does not attach to any plotter, that is isAttached() returns False.
virtual void wedg(const String &side, Float disp, Float width, Float fg, Float bg, const String &label)
virtual Float qch()
virtual void conb(const Matrix< Float > &a, const Vector< Float > &c, const Vector< Float > &tr, Float blank)
PGPlotter(PGPlotterInterface *)
Create from the given PGPlotterInterface instantiation.
virtual Int qid()
virtual Float rnd(Float x, Int nsub)
virtual void sci(Int ci)
virtual ~PGPlotter()
If this is the last reference, close the plot.
virtual void errx(const Vector< Float > &x1, const Vector< Float > &x2, const Vector< Float > &y, Float t)
virtual void tbox(const String &xopt, Float xtick, Int nxsub, const String &yopt, Float ytick, Int nysub)
virtual void shs(Float angle, Float sepn, Float phase)
virtual void mtxt(const String &side, Float disp, Float coord, Float fjust, const String &text)
virtual void svp(Float xleft, Float xright, Float ybot, Float ytop)
virtual void subp(Int nxsub, Int nysub)
virtual void updt()
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
virtual void gray(const Matrix< Float > &a, Float fg, Float bg, const Vector< Float > &tr)
virtual void sitf(Int itf)
virtual Int qlw()
virtual void unsa()
virtual void bin(const Vector< Float > &x, const Vector< Float > &data, Bool center)
virtual void panl(Int ix, Int iy)
PGPlotter & operator=(const PGPlotter &other)
virtual void hi2d(const Matrix< Float > &data, const Vector< Float > &x, Int ioff, Float bias, Bool center, const Vector< Float > &ylims)
virtual Vector< Float > qah()
virtual void scir(Int icilo, Int icihi)
virtual void shls(Int ci, Float ch, Float cl, Float cs)
virtual void hist(const Vector< Float > &data, Float datmin, Float datmax, Int nbin, Int pcflag)
virtual Int qfs()
virtual void move(Float x, Float y)
virtual void page()
virtual void stbg(Int tbci)
virtual void rect(Float x1, Float x2, Float y1, Float y2)
virtual Vector< Float > qpos()
virtual void box(const String &xopt, Float xtick, Int nxsub, const String &yopt, Float ytick, Int nysub)
virtual Int qitf()
virtual Int qls()
void detach()
Detach from the object.
virtual Vector< Float > qvp(Int units)
virtual void vsiz(Float xleft, Float xright, Float ybot, Float ytop)
virtual Vector< Float > qcs(Int units)
virtual void ctab(const Vector< Float > &l, const Vector< Float > &r, const Vector< Float > &g, const Vector< Float > &b, Float contra, Float bright)
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 pnts(const Vector< Float > &x, const Vector< Float > &y, const Vector< Int > symbol)
static CreateFunction * creator_p
Definition: PGPlotter.h:294
virtual Vector< Int > qcol()
static CreateFunction * setCreateFunction(CreateFunction *, Bool override=True)
Set the create function.
virtual Vector< Float > qcr(Int ci)
virtual void vect(const Matrix< Float > &a, const Matrix< Float > &b, Float c, Int nc, const Vector< Float > &tr, Float blank)
virtual void sls(Int ls)
virtual void text(Float x, Float y, const String &text)
virtual void ldev()
virtual void scf(Int font)
virtual void message(const String &text)
This is not a standard PGPLOT command.
virtual Vector< Float > qvsz(Int units)
virtual Vector< Float > len(Int units, const String &string)
virtual void scr(Int ci, Float cr, Float cg, Float cb)
virtual void sah(Int fs, Float angle, Float vent)
virtual void scrn(Int ci, const String &name)
virtual void vstd()
virtual void line(const Vector< Float > &xpts, const Vector< Float > &ypts)
virtual Vector< Float > qwin()
virtual void wnad(Float x1, Float x2, Float y1, Float y2)
virtual String numb(Int mm, Int pp, Int form)
virtual Vector< Int > qcir()
virtual void ask(Bool flag)
virtual void poly(const Vector< Float > &xpts, const Vector< Float > &ypts)
virtual void env(Float xmin, Float xmax, Float ymin, Float ymax, Int just, Int axis)
virtual void ebuf()
virtual void erry(const Vector< Float > &x, const Vector< Float > &y1, const Vector< Float > &y2, Float t)
virtual void sch(Float size)
virtual Int qcf()
void ok() const
Throws an exception if !isAttached()
virtual void pt(const Vector< Float > &xpts, const Vector< Float > &ypts, Int symbol)
virtual Vector< Float > rnge(Float x1, Float x2)
virtual void imag(const Matrix< Float > &a, Float a1, Float a2, const Vector< Float > &tr)
virtual void conl(const Matrix< Float > &a, Float c, const Vector< Float > &tr, const String &label, Int intval, Int minint)
virtual Record curs(Float x, Float y)
This is an emulated standard PGPLOT command.
virtual void eras()
virtual void cons(const Matrix< Float > &a, const Vector< Float > &c, const Vector< Float > &tr)
virtual Vector< Float > qtxt(Float x, Float y, Float angle, Float fjust, const String &text)
virtual Int qci()
virtual void swin(Float x1, Float x2, Float y1, Float y2)
virtual void sfs(Int fs)
virtual void ptxt(Float x, Float y, Float angle, Float fjust, const String &text)
virtual Vector< Float > qhs()
CountedPtr< PGPlotterInterface > worker_p
Definition: PGPlotter.h:293
virtual void draw(Float x, Float y)
virtual Bool isAttached() const
True if it is OK to plot to this object.
virtual Int qtbg()
virtual void slw(Int lw)
virtual void bbuf()
virtual void errb(Int dir, const Vector< Float > &x, const Vector< Float > &y, const Vector< Float > &e, Float t)
virtual void pixl(const Matrix< Int > &ia, Float x1, Float x2, Float y1, Float y2)
PGPlotter(const String &device, uInt mincolors=2, uInt maxcolors=100, uInt sizex=600, uInt sizey=450)
Create PGPlotter object using the curreent create function.
String: the storage and methods of handling collections of characters.
Definition: String.h:225
const Double c
Fundamental physical constants (SI units):
const Double e
e and functions thereof:
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
TableExprNode phase(const TableExprNode &node)
The phase (i.e.
Definition: ExprNode.h:1448
float Float
Definition: aipstype.h:54
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const Bool True
Definition: aipstype.h:43