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
92 public:
93 // Define the signature of a function creating a PGPlotter object.
94 typedef PGPlotter CreateFunction(const String &device, uInt mincolors, uInt maxcolors, uInt sizex,
95 uInt sizey);
96
97 // The default constructor does not attach to any plotter, that is
98 // <src>isAttached()</src> returns False. An exception is thrown if you
99 // attempt to plot to an unattached PGPlotter.
101
102 // Create PGPlotter object using the curreent create function.
103 PGPlotter(const String &device, uInt mincolors = 2, uInt maxcolors = 100, uInt sizex = 600,
104 uInt sizey = 450);
105
106 // Create from the given PGPlotterInterface instantiation.
107 // It takes over the pointer.
109
110 // Copies use reference semantics, i.e. after copying the new and old
111 // copy both draw onto the same surface.
112 // <group>
113 PGPlotter(const PGPlotter &other);
115 // </group>
116
117 // If this is the last reference, close the plot.
118 virtual ~PGPlotter();
119
120 // Create a PGPlotter object using the current create function.
121 static PGPlotter create(const String &device, uInt mincolors = 2, uInt maxcolors = 100,
122 uInt sizex = 600, uInt sizey = 450);
123
124 // Set the create function. It returns the current create function.
125 // It is, for example, used by ObjectController to attach to glish.
126 // The initial create function creates a detached PGPlotter object.
127 // If <src>override==False</src>, the function is only set if it was
128 // not already set.
130
131 // True if it is OK to plot to this object.
132 virtual Bool isAttached() const;
133
134 // Detach from the object. If this is the last reference to the object,
135 // call its destructor (this will call pgclos on a local device).
136 void detach();
137
138 // This is not a standard PGPLOT command. In the Glish/PGPLOT window, it
139 // puts a message in the message line. By default it sends it to the logger.
140 // In any event, this is intended for short helpful messages (e.g.
141 // saying which keys to press to mark a spectrum).
142 virtual void message(const String &text);
143
144 // This is an emulated standard PGPLOT command. It returns a record
145 // containing the fields:
146 // <srcblock>
147 // [ok=Bool, x=Float, y=Float, ch=String];
148 // If the remote device cannot do cursor feedback, ok==F.
149 // </srcblock>
150 virtual Record curs(Float x, Float y);
151
152 // Standard PGPLOT commands. Documentation for the individual commands
153 // can be found in the Glish manual and in the standard PGPLOT documentation
154 // which may be found at <src>http://astro.caltech.edu/~tjp/pgplot/</src>.
155 // The Glish/PGPLOT documentation is preferred since this interface follows
156 // it exactly (e.g. the array sizes are inferred both here and in Glish,
157 // whereas they must be passed into standard PGPLOT).
158 // <thrown>
159 // <li> An <linkto class="AipsError">AipsError</linkto> will be thrown
160 // if the plotter is unattached.
161 // </thrown>
162 // <group>
163 virtual void arro(Float x1, Float y1, Float x2, Float y2);
164 virtual void ask(Bool flag);
165 virtual void bbuf();
166 virtual void bin(const Vector<Float> &x, const Vector<Float> &data, Bool center);
167 virtual void box(const String &xopt, Float xtick, Int nxsub, const String &yopt, Float ytick,
168 Int nysub);
169 virtual void circ(Float xcent, Float ycent, Float radius);
170 virtual void conb(const Matrix<Float> &a, const Vector<Float> &c, const Vector<Float> &tr,
171 Float blank);
172 virtual void conl(const Matrix<Float> &a, Float c, const Vector<Float> &tr, const String &label,
173 Int intval, Int minint);
174 virtual void cons(const Matrix<Float> &a, const Vector<Float> &c, const Vector<Float> &tr);
175 virtual void cont(const Matrix<Float> &a, const Vector<Float> &c, Bool nc,
176 const Vector<Float> &tr);
177 virtual void ctab(const Vector<Float> &l, const Vector<Float> &r, const Vector<Float> &g,
178 const Vector<Float> &b, Float contra, Float bright);
179 virtual void draw(Float x, Float y);
180 virtual void ebuf();
181 virtual void env(Float xmin, Float xmax, Float ymin, Float ymax, Int just, Int axis);
182 virtual void eras();
183 virtual void errb(Int dir, const Vector<Float> &x, const Vector<Float> &y, const Vector<Float> &e,
184 Float t);
185 virtual void errx(const Vector<Float> &x1, const Vector<Float> &x2, const Vector<Float> &y,
186 Float t);
187 virtual void erry(const Vector<Float> &x, const Vector<Float> &y1, const Vector<Float> &y2,
188 Float t);
189 virtual void gray(const Matrix<Float> &a, Float fg, Float bg, const Vector<Float> &tr);
190 virtual void hi2d(const Matrix<Float> &data, const Vector<Float> &x, Int ioff, Float bias,
191 Bool center, const Vector<Float> &ylims);
192 virtual void hist(const Vector<Float> &data, Float datmin, Float datmax, Int nbin, Int pcflag);
193 virtual void iden();
194 virtual void imag(const Matrix<Float> &a, Float a1, Float a2, const Vector<Float> &tr);
195 virtual void lab(const String &xlbl, const String &ylbl, const String &toplbl);
196 virtual void ldev();
197 virtual Vector<Float> len(Int units, const String &string);
198 virtual void line(const Vector<Float> &xpts, const Vector<Float> &ypts);
199 virtual void move(Float x, Float y);
200 virtual void mtxt(const String &side, Float disp, Float coord, Float fjust, const String &text);
201 virtual String numb(Int mm, Int pp, Int form);
202 virtual void page();
203 virtual void panl(Int ix, Int iy);
204 virtual void pap(Float width, Float aspect);
205 virtual void pixl(const Matrix<Int> &ia, Float x1, Float x2, Float y1, Float y2);
206 virtual void pnts(const Vector<Float> &x, const Vector<Float> &y, const Vector<Int> symbol);
207 virtual void poly(const Vector<Float> &xpts, const Vector<Float> &ypts);
208 virtual void pt(const Vector<Float> &xpts, const Vector<Float> &ypts, Int symbol);
209 virtual void ptxt(Float x, Float y, Float angle, Float fjust, const String &text);
211 virtual Int qcf();
212 virtual Float qch();
213 virtual Int qci();
214 virtual Vector<Int> qcir();
215 virtual Vector<Int> qcol();
216 virtual Vector<Float> qcr(Int ci);
217 virtual Vector<Float> qcs(Int units);
218 virtual Int qfs();
220 virtual Int qid();
221 virtual String qinf(const String &item);
222 virtual Int qitf();
223 virtual Int qls();
224 virtual Int qlw();
226 virtual Int qtbg();
227 virtual Vector<Float> qtxt(Float x, Float y, Float angle, Float fjust, const String &text);
228 virtual Vector<Float> qvp(Int units);
229 virtual Vector<Float> qvsz(Int units);
231 virtual void rect(Float x1, Float x2, Float y1, Float y2);
232 virtual Float rnd(Float x, Int nsub);
233 virtual Vector<Float> rnge(Float x1, Float x2);
234 virtual void sah(Int fs, Float angle, Float vent);
235 virtual void save();
236 virtual void scf(Int font);
237 virtual void sch(Float size);
238 virtual void sci(Int ci);
239 virtual void scir(Int icilo, Int icihi);
240 virtual void scr(Int ci, Float cr, Float cg, Float cb);
241 virtual void scrn(Int ci, const String &name);
242 virtual void sfs(Int fs);
243 virtual void shls(Int ci, Float ch, Float cl, Float cs);
244 virtual void shs(Float angle, Float sepn, Float phase);
245 virtual void sitf(Int itf);
246 virtual void sls(Int ls);
247 virtual void slw(Int lw);
248 virtual void stbg(Int tbci);
249 virtual void subp(Int nxsub, Int nysub);
250 virtual void svp(Float xleft, Float xright, Float ybot, Float ytop);
251 virtual void swin(Float x1, Float x2, Float y1, Float y2);
252 virtual void tbox(const String &xopt, Float xtick, Int nxsub, const String &yopt, Float ytick,
253 Int nysub);
254 virtual void text(Float x, Float y, const String &text);
255 virtual void unsa();
256 virtual void updt();
257 virtual void vect(const Matrix<Float> &a, const Matrix<Float> &b, Float c, Int nc,
258 const Vector<Float> &tr, Float blank);
259 virtual void vsiz(Float xleft, Float xright, Float ybot, Float ytop);
260 virtual void vstd();
261 virtual void wedg(const String &side, Float disp, Float width, Float fg, Float bg,
262 const String &label);
263 virtual void wnad(Float x1, Float x2, Float y1, Float y2);
264 // </group>
265 private:
266 std::shared_ptr<PGPlotterInterface> worker_p;
268
269 // Throws an exception if !isAttached()
270 void ok() const;
271};
272
273} // namespace casacore
274
275#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:266
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:94
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:267
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:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
Int blank() const
Definition hdu.h:405
unsigned int uInt
Definition aipstype.h:49
TableExprNode phase(const TableExprNode &node)
The phase (i.e.
Definition ExprNode.h:1281
float Float
Definition aipstype.h:52
String name() const
Return the name of the field.
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
size_t size() const
Definition Block.h:566
const Bool True
Definition aipstype.h:41