source: trunk/src/Utils/mycpgplot.hh

Last change on this file was 1130, checked in by MatthewWhiting, 11 years ago

Ticket #132 - allowing fitting of an ellipse to the moment-0 map of a detection. Also allowing it to be written to annotation files and to the moment-0 cutout in the spectral output.

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