casa
$Rev:20696$
|
00001 //# PGPlotter.h: Standard plotting object for application programmers. 00002 //# Copyright (C) 1997,2000,2001 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# 00027 //# $Id: PGPlotter.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $ 00028 00029 #ifndef CASA_PGPLOTTER_H 00030 #define CASA_PGPLOTTER_H 00031 00032 #include <casa/aips.h> 00033 #include <casa/System/PGPlotterInterface.h> 00034 #include <casa/Utilities/CountedPtr.h> 00035 00036 namespace casa { //# NAMESPACE CASA - BEGIN 00037 00038 class String; 00039 template<class T> class Vector; 00040 00041 // <summary> 00042 // Standard plotting object for application programmers. 00043 // </summary> 00044 00045 // <use visibility=export> 00046 00047 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00048 // </reviewed> 00049 00050 // <prerequisite> 00051 // <li> <linkto class="PGPlotterInterface">PGPlotterInterface</linkto> 00052 // </prerequisite> 00053 // 00054 // <synopsis> 00055 // This is the class that a programmer should instantiate if he wants to open 00056 // a "device" to plot to. The device might be local, or it might be remote 00057 // (i.e., running under Glish). The philosophy of the plotting interface is 00058 // described in the 00059 // <linkto class="PGPlotterInterface">PGPlotterInterface</linkto> documentation. 00060 // 00061 // It is possible that the object might not be attached to a valid plot device 00062 // (for example, the user might have said "no plotting." Programerss should 00063 // check the <src>isAttached()</src> member before plotting. If you attempt to 00064 // plot to an unattached plotter, an exception is thrown. 00065 // 00066 // Copying a <src>PGPlotter</src> uses reference semantics -- after copying 00067 // plotting on the old and new objects will result in the plot commands 00068 // appearing on the same device. The device is closed only when the last 00069 // reference is destructed. 00070 // 00071 // You can detach a plotter from a device with the <src>detach()</src> call. 00072 // If there are no other references to the plotter, this will close the device. 00073 // (What it actually does is call the destructor on the object. For a local 00074 // PGPPLOT device this will close it). 00075 // </synopsis> 00076 // 00077 // <example> 00078 // <srcblock> 00079 // // plot y = x*x 00080 // Vector<Float> x(100), y(100); 00081 // indgen(x); 00082 // y = x*x; 00083 00084 // PGPlotter plotter("myplot.ps/ps"); 00085 // plotter.env(0, 100, 0, 100*100, 0, 0); 00086 // plotter.line(x, y); 00087 // </srcblock> 00088 // </example> 00089 // 00090 // <todo asof="1997/12/31"> 00091 // <li> Add more plot calls. 00092 // </todo> 00093 00094 00095 class PGPlotter : public PGPlotterInterface 00096 { 00097 public: 00098 // Define the signature of a function creating a PGPlotter object. 00099 typedef PGPlotter CreateFunction (const String &device, 00100 uInt mincolors, uInt maxcolors, 00101 uInt sizex, uInt sizey); 00102 00103 // The default constructor does not attach to any plotter, that is 00104 // <src>isAttached()</src> returns False. An exception is thrown if you 00105 // attempt to plot to an unattached PGPlotter. 00106 PGPlotter(); 00107 00108 // Create PGPlotter object using the curreent create function. 00109 PGPlotter (const String &device, 00110 uInt mincolors=2, uInt maxcolors=100, 00111 uInt sizex=600, uInt sizey=450); 00112 00113 // Create from the given PGPlotterInterface instantiation. 00114 // It takes over the pointer. 00115 PGPlotter (PGPlotterInterface*); 00116 00117 // Copies use reference semantics, i.e. after copying the new and old 00118 // copy both draw onto the same surface. 00119 // <group> 00120 PGPlotter(const PGPlotter &other); 00121 PGPlotter &operator=(const PGPlotter &other); 00122 // </group> 00123 00124 // If this is the last reference, close the plot. 00125 virtual ~PGPlotter(); 00126 00127 // Create a PGPlotter object using the current create function. 00128 static PGPlotter create (const String &device, 00129 uInt mincolors=2, uInt maxcolors=100, 00130 uInt sizex=600, uInt sizey=450); 00131 00132 // Set the create function. It returns the current create function. 00133 // It is, for example, used by ObjectController to attach to glish. 00134 // The initial create function creates a detached PGPlotter object. 00135 // If <src>override==False</src>, the function is only set if it was 00136 // not already set. 00137 static CreateFunction* setCreateFunction (CreateFunction*, 00138 Bool override=True); 00139 00140 // True if it is OK to plot to this object. 00141 virtual Bool isAttached() const; 00142 00143 // Detach from the object. If this is the last reference to the object, 00144 // call its destructor (this will call pgclos on a local device). 00145 void detach(); 00146 00147 // This is not a standard PGPLOT command. In the Glish/PGPLOT window, it 00148 // puts a message in the message line. By default it sends it to the logger. 00149 // In any event, this is intended for short helpful messages (e.g. 00150 // saying which keys to press to mark a spectrum). 00151 virtual void message(const String &text); 00152 00153 // This is an emulated standard PGPLOT command. It returns a record 00154 // containing the fields: 00155 // <srcblock> 00156 // [ok=Bool, x=Float, y=Float, ch=String]; 00157 // If the remote device cannot do cursor feedback, ok==F. 00158 // </srcblock> 00159 virtual Record curs(Float x, Float y); 00160 00161 // Standard PGPLOT commands. Documentation for the individual commands 00162 // can be found in the Glish manual and in the standard PGPLOT documentation 00163 // which may be found at <src>http://astro.caltech.edu/~tjp/pgplot/</src>. 00164 // The Glish/PGPLOT documentation is preferred since this interface follows 00165 // it exactly (e.g. the array sizes are inferred both here and in Glish, 00166 // whereas they must be passed into standard PGPLOT). 00167 // <thrown> 00168 // <li> An <linkto class="AipsError">AipsError</linkto> will be thrown 00169 // if the plotter is unattached. 00170 // </thrown> 00171 // <group> 00172 virtual void arro(Float x1, Float y1, Float x2, Float y2); 00173 virtual void ask(Bool flag); 00174 virtual void bbuf(); 00175 virtual void bin(const Vector<Float> &x, const Vector<Float> &data, 00176 Bool center); 00177 virtual void box(const String &xopt, Float xtick, Int nxsub, 00178 const String &yopt, Float ytick, Int nysub); 00179 virtual void circ(Float xcent, Float ycent, Float radius); 00180 virtual void conb(const Matrix<Float> &a, const Vector<Float> &c, 00181 const Vector<Float> &tr, Float blank); 00182 virtual void conl(const Matrix<Float> &a, Float c, 00183 const Vector<Float> &tr, const String &label, 00184 Int intval, Int minint); 00185 virtual void cons(const Matrix<Float> &a, const Vector<Float> &c, 00186 const Vector<Float> &tr); 00187 virtual void cont(const Matrix<Float> &a, const Vector<Float> &c, 00188 Bool nc, const Vector<Float> &tr); 00189 virtual void ctab(const Vector<Float> &l, const Vector<Float> &r, 00190 const Vector<Float> &g, const Vector<Float> &b, 00191 Float contra, Float bright); 00192 virtual void draw(Float x, Float y); 00193 virtual void ebuf(); 00194 virtual void env(Float xmin, Float xmax, Float ymin, Float ymax, Int just, 00195 Int axis); 00196 virtual void eras(); 00197 virtual void errb(Int dir, const Vector<Float> &x, const Vector<Float> &y, 00198 const Vector<Float> &e, Float t); 00199 virtual void errx(const Vector<Float> &x1, const Vector<Float> &x2, 00200 const Vector<Float> &y, Float t); 00201 virtual void erry(const Vector<Float> &x, const Vector<Float> &y1, 00202 const Vector<Float> &y2, Float t); 00203 virtual void gray(const Matrix<Float> &a, Float fg, Float bg, 00204 const Vector<Float> &tr); 00205 virtual void hi2d(const Matrix<Float> &data, const Vector<Float> &x, 00206 Int ioff, Float bias, Bool center, 00207 const Vector<Float> &ylims); 00208 virtual void hist(const Vector<Float> &data, Float datmin, Float datmax, 00209 Int nbin, Int pcflag); 00210 virtual void iden(); 00211 virtual void imag(const Matrix<Float> &a, Float a1, Float a2, 00212 const Vector<Float> &tr); 00213 virtual void lab(const String &xlbl, const String &ylbl, 00214 const String &toplbl); 00215 virtual void ldev(); 00216 virtual Vector<Float> len(Int units, const String &string); 00217 virtual void line(const Vector<Float> &xpts, const Vector<Float> &ypts); 00218 virtual void move(Float x, Float y); 00219 virtual void mtxt(const String &side, Float disp, Float coord, Float fjust, 00220 const String &text); 00221 virtual String numb(Int mm, Int pp, Int form); 00222 virtual void page(); 00223 virtual void panl(Int ix, Int iy); 00224 virtual void pap(Float width, Float aspect); 00225 virtual void pixl(const Matrix<Int> &ia, Float x1, Float x2, 00226 Float y1, Float y2); 00227 virtual void pnts(const Vector<Float> &x, const Vector<Float> &y, 00228 const Vector<Int> symbol); 00229 virtual void poly(const Vector<Float> &xpts, const Vector<Float> &ypts); 00230 virtual void pt(const Vector<Float> &xpts, const Vector<Float> &ypts, 00231 Int symbol); 00232 virtual void ptxt(Float x, Float y, Float angle, Float fjust, 00233 const String &text); 00234 virtual Vector<Float> qah(); 00235 virtual Int qcf(); 00236 virtual Float qch(); 00237 virtual Int qci(); 00238 virtual Vector<Int> qcir(); 00239 virtual Vector<Int> qcol(); 00240 virtual Vector<Float> qcr(Int ci); 00241 virtual Vector<Float> qcs(Int units); 00242 virtual Int qfs(); 00243 virtual Vector<Float> qhs(); 00244 virtual Int qid(); 00245 virtual String qinf(const String &item); 00246 virtual Int qitf(); 00247 virtual Int qls(); 00248 virtual Int qlw(); 00249 virtual Vector<Float> qpos(); 00250 virtual Int qtbg(); 00251 virtual Vector<Float> qtxt(Float x, Float y, Float angle, Float fjust, 00252 const String &text); 00253 virtual Vector<Float> qvp(Int units); 00254 virtual Vector<Float> qvsz(Int units); 00255 virtual Vector<Float> qwin(); 00256 virtual void rect(Float x1, Float x2, Float y1, Float y2); 00257 virtual Float rnd(Float x, Int nsub); 00258 virtual Vector<Float> rnge(Float x1, Float x2); 00259 virtual void sah(Int fs, Float angle, Float vent); 00260 virtual void save(); 00261 virtual void scf(Int font); 00262 virtual void sch(Float size); 00263 virtual void sci(Int ci); 00264 virtual void scir(Int icilo, Int icihi); 00265 virtual void scr(Int ci, Float cr, Float cg, Float cb); 00266 virtual void scrn(Int ci, const String &name); 00267 virtual void sfs(Int fs); 00268 virtual void shls(Int ci, Float ch, Float cl, Float cs); 00269 virtual void shs(Float angle, Float sepn, Float phase); 00270 virtual void sitf(Int itf); 00271 virtual void sls(Int ls); 00272 virtual void slw(Int lw); 00273 virtual void stbg(Int tbci); 00274 virtual void subp(Int nxsub, Int nysub); 00275 virtual void svp(Float xleft, Float xright, Float ybot, Float ytop); 00276 virtual void swin(Float x1, Float x2, Float y1, Float y2); 00277 virtual void tbox(const String &xopt, Float xtick, Int nxsub, 00278 const String &yopt, Float ytick, Int nysub); 00279 virtual void text(Float x, Float y, const String &text); 00280 virtual void unsa(); 00281 virtual void updt(); 00282 virtual void vect(const Matrix<Float> &a, const Matrix<Float> &b, 00283 Float c, Int nc, 00284 const Vector<Float> &tr, Float blank); 00285 virtual void vsiz(Float xleft, Float xright, Float ybot, 00286 Float ytop); 00287 virtual void vstd(); 00288 virtual void wedg(const String &side, Float disp, Float width, 00289 Float fg, Float bg, const String &label); 00290 virtual void wnad(Float x1, Float x2, Float y1, Float y2); 00291 // </group> 00292 private: 00293 CountedPtr<PGPlotterInterface> worker_p; 00294 static CreateFunction* creator_p; 00295 00296 // Throws an exception if !isAttached() 00297 void ok() const; 00298 }; 00299 00300 00301 } //# NAMESPACE CASA - END 00302 00303 #endif