casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef CASA_PGPLOTTER_H
27#define CASA_PGPLOTTER_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/casa/Arrays/ArrayFwd.h>
31#include <casacore/casa/System/PGPlotterInterface.h>
32#include <memory>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36class String;
37
38// <summary>
39// Standard plotting object for application programmers.
40// </summary>
41
42// <use visibility=export>
43
44// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
45// </reviewed>
46
47// <prerequisite>
48// <li> <linkto class="PGPlotterInterface">PGPlotterInterface</linkto>
49// </prerequisite>
50//
51// <synopsis>
52// This is the class that a programmer should instantiate if he wants to open
53// a "device" to plot to. The device might be local, or it might be remote
54// (i.e., running under Glish). The philosophy of the plotting interface is
55// described in the
56// <linkto class="PGPlotterInterface">PGPlotterInterface</linkto> documentation.
57//
58// It is possible that the object might not be attached to a valid plot device
59// (for example, the user might have said "no plotting." Programerss should
60// check the <src>isAttached()</src> member before plotting. If you attempt to
61// plot to an unattached plotter, an exception is thrown.
62//
63// Copying a <src>PGPlotter</src> uses reference semantics -- after copying
64// plotting on the old and new objects will result in the plot commands
65// appearing on the same device. The device is closed only when the last
66// reference is destructed.
67//
68// You can detach a plotter from a device with the <src>detach()</src> call.
69// If there are no other references to the plotter, this will close the device.
70// (What it actually does is call the destructor on the object. For a local
71// PGPPLOT device this will close it).
72// </synopsis>
73//
74// <example>
75// <srcblock>
76// // plot y = x*x
77// Vector<Float> x(100), y(100);
78// indgen(x);
79// y = x*x;
80
81// PGPlotter plotter("myplot.ps/ps");
82// plotter.env(0, 100, 0, 100*100, 0, 0);
83// plotter.line(x, y);
84// </srcblock>
85// </example>
86//
87// <todo asof="1997/12/31">
88// <li> Add more plot calls.
89// </todo>
90
91
93{
94public:
95 // Define the signature of a function creating a PGPlotter object.
96 typedef PGPlotter CreateFunction (const String &device,
97 uInt mincolors, uInt maxcolors,
98 uInt sizex, uInt sizey);
99
100 // The default constructor does not attach to any plotter, that is
101 // <src>isAttached()</src> returns False. An exception is thrown if you
102 // attempt to plot to an unattached PGPlotter.
104
105 // Create PGPlotter object using the curreent create function.
106 PGPlotter (const String &device,
107 uInt mincolors=2, uInt maxcolors=100,
108 uInt sizex=600, uInt sizey=450);
109
110 // Create from the given PGPlotterInterface instantiation.
111 // It takes over the pointer.
113
114 // Copies use reference semantics, i.e. after copying the new and old
115 // copy both draw onto the same surface.
116 // <group>
117 PGPlotter(const PGPlotter &other);
119 // </group>
120
121 // If this is the last reference, close the plot.
122 virtual ~PGPlotter();
123
124 // Create a PGPlotter object using the current create function.
125 static PGPlotter create (const String &device,
126 uInt mincolors=2, uInt maxcolors=100,
127 uInt sizex=600, uInt sizey=450);
128
129 // Set the create function. It returns the current create function.
130 // It is, for example, used by ObjectController to attach to glish.
131 // The initial create function creates a detached PGPlotter object.
132 // If <src>override==False</src>, the function is only set if it was
133 // not already set.
135 Bool override=True);
136
137 // True if it is OK to plot to this object.
138 virtual Bool isAttached() const;
139
140 // Detach from the object. If this is the last reference to the object,
141 // call its destructor (this will call pgclos on a local device).
142 void detach();
143
144 // This is not a standard PGPLOT command. In the Glish/PGPLOT window, it
145 // puts a message in the message line. By default it sends it to the logger.
146 // In any event, this is intended for short helpful messages (e.g.
147 // saying which keys to press to mark a spectrum).
148 virtual void message(const String &text);
149
150 // This is an emulated standard PGPLOT command. It returns a record
151 // containing the fields:
152 // <srcblock>
153 // [ok=Bool, x=Float, y=Float, ch=String];
154 // If the remote device cannot do cursor feedback, ok==F.
155 // </srcblock>
156 virtual Record curs(Float x, Float y);
157
158 // Standard PGPLOT commands. Documentation for the individual commands
159 // can be found in the Glish manual and in the standard PGPLOT documentation
160 // which may be found at <src>http://astro.caltech.edu/~tjp/pgplot/</src>.
161 // The Glish/PGPLOT documentation is preferred since this interface follows
162 // it exactly (e.g. the array sizes are inferred both here and in Glish,
163 // whereas they must be passed into standard PGPLOT).
164 // <thrown>
165 // <li> An <linkto class="AipsError">AipsError</linkto> will be thrown
166 // if the plotter is unattached.
167 // </thrown>
168 // <group>
169 virtual void arro(Float x1, Float y1, Float x2, Float y2);
170 virtual void ask(Bool flag);
171 virtual void bbuf();
172 virtual void bin(const Vector<Float> &x, const Vector<Float> &data,
173 Bool center);
174 virtual void box(const String &xopt, Float xtick, Int nxsub,
175 const String &yopt, Float ytick, Int nysub);
176 virtual void circ(Float xcent, Float ycent, Float radius);
177 virtual void conb(const Matrix<Float> &a, const Vector<Float> &c,
178 const Vector<Float> &tr, Float blank);
179 virtual void conl(const Matrix<Float> &a, Float c,
180 const Vector<Float> &tr, const String &label,
181 Int intval, Int minint);
182 virtual void cons(const Matrix<Float> &a, const Vector<Float> &c,
183 const Vector<Float> &tr);
184 virtual void cont(const Matrix<Float> &a, const Vector<Float> &c,
185 Bool nc, const Vector<Float> &tr);
186 virtual void ctab(const Vector<Float> &l, const Vector<Float> &r,
187 const Vector<Float> &g, const Vector<Float> &b,
188 Float contra, Float bright);
189 virtual void draw(Float x, Float y);
190 virtual void ebuf();
191 virtual void env(Float xmin, Float xmax, Float ymin, Float ymax, Int just,
192 Int axis);
193 virtual void eras();
194 virtual void errb(Int dir, const Vector<Float> &x, const Vector<Float> &y,
195 const Vector<Float> &e, Float t);
196 virtual void errx(const Vector<Float> &x1, const Vector<Float> &x2,
197 const Vector<Float> &y, Float t);
198 virtual void erry(const Vector<Float> &x, const Vector<Float> &y1,
199 const Vector<Float> &y2, Float t);
200 virtual void gray(const Matrix<Float> &a, Float fg, Float bg,
201 const Vector<Float> &tr);
202 virtual void hi2d(const Matrix<Float> &data, const Vector<Float> &x,
203 Int ioff, Float bias, Bool center,
204 const Vector<Float> &ylims);
205 virtual void hist(const Vector<Float> &data, Float datmin, Float datmax,
206 Int nbin, Int pcflag);
207 virtual void iden();
208 virtual void imag(const Matrix<Float> &a, Float a1, Float a2,
209 const Vector<Float> &tr);
210 virtual void lab(const String &xlbl, const String &ylbl,
211 const String &toplbl);
212 virtual void ldev();
213 virtual Vector<Float> len(Int units, const String &string);
214 virtual void line(const Vector<Float> &xpts, const Vector<Float> &ypts);
215 virtual void move(Float x, Float y);
216 virtual void mtxt(const String &side, Float disp, Float coord, Float fjust,
217 const String &text);
218 virtual String numb(Int mm, Int pp, Int form);
219 virtual void page();
220 virtual void panl(Int ix, Int iy);
221 virtual void pap(Float width, Float aspect);
222 virtual void pixl(const Matrix<Int> &ia, Float x1, Float x2,
223 Float y1, Float y2);
224 virtual void pnts(const Vector<Float> &x, const Vector<Float> &y,
225 const Vector<Int> symbol);
226 virtual void poly(const Vector<Float> &xpts, const Vector<Float> &ypts);
227 virtual void pt(const Vector<Float> &xpts, const Vector<Float> &ypts,
228 Int symbol);
229 virtual void ptxt(Float x, Float y, Float angle, Float fjust,
230 const String &text);
232 virtual Int qcf();
233 virtual Float qch();
234 virtual Int qci();
235 virtual Vector<Int> qcir();
236 virtual Vector<Int> qcol();
237 virtual Vector<Float> qcr(Int ci);
238 virtual Vector<Float> qcs(Int units);
239 virtual Int qfs();
241 virtual Int qid();
242 virtual String qinf(const String &item);
243 virtual Int qitf();
244 virtual Int qls();
245 virtual Int qlw();
247 virtual Int qtbg();
248 virtual Vector<Float> qtxt(Float x, Float y, Float angle, Float fjust,
249 const String &text);
250 virtual Vector<Float> qvp(Int units);
251 virtual Vector<Float> qvsz(Int units);
253 virtual void rect(Float x1, Float x2, Float y1, Float y2);
254 virtual Float rnd(Float x, Int nsub);
255 virtual Vector<Float> rnge(Float x1, Float x2);
256 virtual void sah(Int fs, Float angle, Float vent);
257 virtual void save();
258 virtual void scf(Int font);
259 virtual void sch(Float size);
260 virtual void sci(Int ci);
261 virtual void scir(Int icilo, Int icihi);
262 virtual void scr(Int ci, Float cr, Float cg, Float cb);
263 virtual void scrn(Int ci, const String &name);
264 virtual void sfs(Int fs);
265 virtual void shls(Int ci, Float ch, Float cl, Float cs);
266 virtual void shs(Float angle, Float sepn, Float phase);
267 virtual void sitf(Int itf);
268 virtual void sls(Int ls);
269 virtual void slw(Int lw);
270 virtual void stbg(Int tbci);
271 virtual void subp(Int nxsub, Int nysub);
272 virtual void svp(Float xleft, Float xright, Float ybot, Float ytop);
273 virtual void swin(Float x1, Float x2, Float y1, Float y2);
274 virtual void tbox(const String &xopt, Float xtick, Int nxsub,
275 const String &yopt, Float ytick, Int nysub);
276 virtual void text(Float x, Float y, const String &text);
277 virtual void unsa();
278 virtual void updt();
279 virtual void vect(const Matrix<Float> &a, const Matrix<Float> &b,
280 Float c, Int nc,
281 const Vector<Float> &tr, Float blank);
282 virtual void vsiz(Float xleft, Float xright, Float ybot,
283 Float ytop);
284 virtual void vstd();
285 virtual void wedg(const String &side, Float disp, Float width,
286 Float fg, Float bg, const String &label);
287 virtual void wnad(Float x1, Float x2, Float y1, Float y2);
288 // </group>
289 private:
290 std::shared_ptr<PGPlotterInterface> worker_p;
292
293 // Throws an exception if !isAttached()
294 void ok() const;
295};
296
297
298} //# NAMESPACE CASACORE - END
299
300#endif
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)
std::shared_ptr< PGPlotterInterface > worker_p
Definition PGPlotter.h:290
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:96
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:291
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()
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:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
TableExprNode phase(const TableExprNode &node)
The phase (i.e.
Definition ExprNode.h:1452
float Float
Definition aipstype.h:52
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41