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