source: tags/release-1.1/src/Utils/mycpgplot.hh @ 1323

Last change on this file since 1323 was 301, checked in by Matthew Whiting, 17 years ago

Mostly adding the distribution text to the start of files, with a few additional comments added too.

File size: 4.4 KB
Line 
1// -----------------------------------------------------------------------
2// mycpgplot.hh: Enumerations, shortcuts and other useful functions
3//               for use with PGPLOT.
4// -----------------------------------------------------------------------
5// Copyright (C) 2006, Matthew Whiting, ATNF
6//
7// This program is free software; you can redistribute it and/or modify it
8// under the terms of the GNU General Public License as published by the
9// Free Software Foundation; either version 2 of the License, or (at your
10// option) any later version.
11//
12// Duchamp is distributed in the hope that it will be useful, but WITHOUT
13// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15// for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Duchamp; if not, write to the Free Software Foundation,
19// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
20//
21// Correspondence concerning Duchamp may be directed to:
22//    Internet email: Matthew.Whiting [at] atnf.csiro.au
23//    Postal address: Dr. Matthew Whiting
24//                    Australia Telescope National Facility, CSIRO
25//                    PO Box 76
26//                    Epping NSW 1710
27//                    AUSTRALIA
28// -----------------------------------------------------------------------
29#ifndef MYCPGPLOT_H
30#define MYCPGPLOT_H
31#include <string>
32#include <cpgplot.h>
33
34// The following are in pgplot_related.c
35//
36/** Is a PGPLOT device open? */
37extern "C" int  cpgtest();
38
39/** Is a PGPLOT device a postscript (hardcopy) device? */
40extern "C" int  cpgIsPS();
41
42/** Do a logarithmic-scaled wedge, as in PGWEDG */
43extern "C" void cpgwedglog(const char* side, float disp, float width,
44                           float fg, float bg, const char *label);
45
46/** Do CPGHIST but with the y-axis logarithmic */
47extern "C" void cpghistlog(int npts, float *data, float datamin,
48                           float datamax, int nbin, int pgflag);
49
50/** Do a PGPLOT cumulative distribution */
51extern "C" void cpgcumul(int npts, float *data, float datamin,
52                         float datamax, int pgflag);
53
54//--------------------
55/**
56 * A namespace that holds definitions and basic functions to aid the
57 * use of PGPLOT.
58 */
59
60namespace mycpgplot
61{
62  /** Enumerated PGPLOT colour names. */
63  enum COLOUR {BACKGND=0, FOREGND, RED, GREEN, BLUE, CYAN,
64               MAGENTA, YELLOW, ORANGE, GREENYELLOW, GREENCYAN, BLUECYAN,
65               BLUEMAGENTA, REDMAGENTA, DARKGREY, LIGHTGREY, DARKGREEN};
66
67  /** Enumerated colour names for the inverse case, such as for /xs devices.*/
68  enum INVERSE {XS_BLACK, XS_WHITE};
69
70  /**
71   * Define the DARKGREEN colour, with RGB value of (0,0.7,0).
72   */
73  inline void setDarkGreen(){cpgscr(DARKGREEN,0.,0.7,0.);};
74
75  /**
76   * A device independent way to set the colour to white.
77   *
78   * Uses cpgIsPS() to determine whether a device is a postscript
79   * one. If so, we use the BACKGND colour (ie. 0), otherwise use
80   * FOREGND (1).
81   */
82  inline void setWhite(){
83    if(cpgIsPS()) cpgsci(BACKGND);
84    else cpgsci(FOREGND);
85  };
86
87  /**
88   * A device independent way to set the colour to black.
89   *
90   * Uses cpgIsPS() to determine whether a device is a postscript
91   * one. If so, we use the FOREGND colour (ie. 1), otherwise use
92   * BACKGND (0).
93   */
94  inline void setBlack(){
95    if(cpgIsPS()) cpgsci(FOREGND);
96    else cpgsci(BACKGND);
97  };
98
99  /** Enumerated PGPLOT line styles. */
100  enum LINESTYLE {FULL=1, DASHED, DASHDOT, DOTTED, DASHDOT3};
101
102  /** Enumerated PGPLOT area fill styles. */
103  enum FILLSTYLE {SOLID=1, OUTLINE, HATCHED, CROSSHATCHED};
104
105  /** Enumerated PGPLOT plotting symbols. */
106  enum SYMBOLS {SOLIDPENT=-5, SOLIDDIAMOND, DOT=1, PLUS, ASTERISK,
107                CIRCLE, CROSS, SQUARE, TRIANGLE, OPLUS, ODOT, FOURSTAR,
108                DIAMOND, STAR, SOLIDTRIANGLE, OPENPLUS, DAVID,
109                SOLIDSQUARE, SOLIDCIRCLE, SOLIDSTAR, LARGESQUARE,
110                CIRCLE1, CIRCLE2, CIRCLE3, CIRCLE4, CIRCLE5, CIRCLE6,
111                CIRCLE7, CIRCLE8, LEFT, RIGHT, UP, DOWN};
112
113  enum FONTS {NORMAL=1, ROMAN, ITALIC, SCRIPT};
114
115  const std::string degrees="\\(0718)";   ///< The degrees symbol: \f$^\circ\f$
116  const std::string plusminus="\\(2233)"; ///< The plus-minus symbol: \f$\pm\f$
117  const std::string times="\\(2235)";     ///< Similar to \f$\times\f$
118  const std::string tick="\\(2267)";      ///< A tick, which is good for square roots: similar to \f$\surd\f$
119  const std::string odot="\\(2281)";      ///< \f$\odot\f$
120  const std::string integral="\\(2268)";  ///< The integral symbol \f$\int\f$
121
122}
123
124
125#endif
Note: See TracBrowser for help on using the repository browser.