source: trunk/src/Utils/mycpgplot.hh @ 397

Last change on this file since 397 was 397, checked in by MatthewWhiting, 17 years ago

Making sure config.h is done correctly.

File size: 5.1 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
33#undef PACKAGE_BUGREPORT
34#undef PACKAGE_NAME
35#undef PACKAGE_STRING
36#undef PACKAGE_TARNAME
37#undef PACKAGE_VERSION
38#undef HAVE_PGPLOT
39#include <duchamp/config.h>
40
41//--------------------
42/**
43 * A namespace that holds definitions and basic functions to aid the
44 * use of PGPLOT.
45 */
46
47namespace mycpgplot
48{
49  /** Enumerated PGPLOT colour names. */
50  enum COLOUR {BACKGND=0, FOREGND, RED, GREEN, BLUE, CYAN,
51               MAGENTA, YELLOW, ORANGE, GREENYELLOW, GREENCYAN, BLUECYAN,
52               BLUEMAGENTA, REDMAGENTA, DARKGREY, LIGHTGREY, DARKGREEN,
53               WCSGREEN};
54
55  /** Enumerated colour names for the inverse case, such as for /xs devices.*/
56  enum INVERSE {XS_BLACK, XS_WHITE};
57
58  /** Enumerated PGPLOT line styles. */
59  enum LINESTYLE {FULL=1, DASHED, DASHDOT, DOTTED, DASHDOT3};
60
61  /** Enumerated PGPLOT area fill styles. */
62  enum FILLSTYLE {SOLID=1, OUTLINE, HATCHED, CROSSHATCHED};
63
64  /** Enumerated PGPLOT plotting symbols. */
65  enum SYMBOLS {SOLIDPENT=-5, SOLIDDIAMOND, DOT=1, PLUS, ASTERISK,
66                CIRCLE, CROSS, SQUARE, TRIANGLE, OPLUS, ODOT, FOURSTAR,
67                DIAMOND, STAR, SOLIDTRIANGLE, OPENPLUS, DAVID,
68                SOLIDSQUARE, SOLIDCIRCLE, SOLIDSTAR, LARGESQUARE,
69                CIRCLE1, CIRCLE2, CIRCLE3, CIRCLE4, CIRCLE5, CIRCLE6,
70                CIRCLE7, CIRCLE8, LEFT, RIGHT, UP, DOWN};
71
72  enum FONTS {NORMAL=1, ROMAN, ITALIC, SCRIPT};
73
74  const std::string degrees="\\(0718)";   ///< The degrees symbol: \f$^\circ\f$
75  const std::string plusminus="\\(2233)"; ///< The plus-minus symbol: \f$\pm\f$
76  const std::string times="\\(2235)";     ///< Similar to \f$\times\f$
77  const std::string tick="\\(2267)";      ///< A tick, which is good for square roots: similar to \f$\surd\f$
78  const std::string odot="\\(2281)";      ///< \f$\odot\f$
79  const std::string integral="\\(2268)";  ///< The integral symbol \f$\int\f$
80
81}
82
83//////////////////////
84
85#ifdef HAVE_PGPLOT
86
87#include <cpgplot.h>
88
89// The following are in pgplot_related.c
90//
91/** Is a PGPLOT device open? */
92extern "C" int  cpgtest();
93
94/** Do a logarithmic-scaled wedge, as in PGWEDG */
95extern "C" void cpgwedglog(const char* side, float disp, float width,
96                           float fg, float bg, const char *label);
97
98/** Do CPGHIST but with the y-axis logarithmic */
99extern "C" void cpghistlog(int npts, float *data, float datamin,
100                           float datamax, int nbin, int pgflag);
101
102/** Do a PGPLOT cumulative distribution */
103extern "C" void cpgcumul(int npts, float *data, float datamin,
104                         float datamax, int pgflag);
105
106namespace mycpgplot {
107
108  /** Is a PGPLOT device a postscript (hardcopy) device? */
109  int  cpgIsPS();
110
111  /** A front-end to the cpgopen function, with other necessary definitions.*/
112  int mycpgopen(std::string device);
113
114  /** Define the DARKGREEN colour, with RGB value of (0,0.7,0).*/
115  void setDarkGreen();
116
117  /** Define the WCSGREEN colour, with RGB value of (0.3,0.5,0.3). */
118  void setWCSGreen();
119
120  /** A device-independent way to set the colour to white. */
121  void setWhite();
122
123  /** A device-independent way to set the colour to black. */
124   void setBlack();
125
126}
127
128#else // from ifdef HAVE_PGPLOT
129// PGPLOT has not been defined.
130// extern "C" int  cpgtest(){return 0;};
131// extern "C" int  cpgIsPS(){return 0;};
132// extern "C" void cpgwedglog(const char* side, float disp, float width,
133//                         float fg, float bg, const char *label){ };
134// extern "C" void cpghistlog(int npts, float *data, float datamin,
135//                         float datamax, int nbin, int pgflag){ };
136// extern "C" void cpgcumul(int npts, float *data, float datamin,
137//                       float datamax, int pgflag){ };
138// namespace mycpgplot {
139//   int mycpgopen(std::string device){return 0;};
140//   inline void setDarkGreen(){ };
141//   inline void setWCSGreen(){ };
142//   inline void setWhite(){ };
143//   inline void setBlack(){ };
144// }
145
146#endif // from ifdef HAVE_PGPLOT
147
148#endif
Note: See TracBrowser for help on using the repository browser.