[301] | 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 | // ----------------------------------------------------------------------- |
---|
[146] | 29 | #ifndef MYCPGPLOT_H |
---|
| 30 | #define MYCPGPLOT_H |
---|
[187] | 31 | #include <string> |
---|
[316] | 32 | |
---|
[321] | 33 | #undef PACKAGE_BUGREPORT |
---|
| 34 | #undef PACKAGE_NAME |
---|
| 35 | #undef PACKAGE_STRING |
---|
| 36 | #undef PACKAGE_TARNAME |
---|
| 37 | #undef PACKAGE_VERSION |
---|
| 38 | #undef HAVE_PGPLOT |
---|
[397] | 39 | #include <duchamp/config.h> |
---|
[321] | 40 | |
---|
[528] | 41 | /// A namespace that holds definitions and basic functions to aid the |
---|
| 42 | /// use of PGPLOT. |
---|
[222] | 43 | |
---|
[146] | 44 | namespace mycpgplot |
---|
| 45 | { |
---|
[528] | 46 | /// @brief Enumerated PGPLOT colour names. |
---|
[201] | 47 | enum COLOUR {BACKGND=0, FOREGND, RED, GREEN, BLUE, CYAN, |
---|
| 48 | MAGENTA, YELLOW, ORANGE, GREENYELLOW, GREENCYAN, BLUECYAN, |
---|
[316] | 49 | BLUEMAGENTA, REDMAGENTA, DARKGREY, LIGHTGREY, DARKGREEN, |
---|
| 50 | WCSGREEN}; |
---|
[146] | 51 | |
---|
[528] | 52 | /// @brief Enumerated colour names for the inverse case, such as for /xs devices. |
---|
[146] | 53 | enum INVERSE {XS_BLACK, XS_WHITE}; |
---|
| 54 | |
---|
[528] | 55 | /// @brief Enumerated PGPLOT line styles. |
---|
[146] | 56 | enum LINESTYLE {FULL=1, DASHED, DASHDOT, DOTTED, DASHDOT3}; |
---|
| 57 | |
---|
[528] | 58 | /// @brief Enumerated PGPLOT area fill styles. |
---|
[146] | 59 | enum FILLSTYLE {SOLID=1, OUTLINE, HATCHED, CROSSHATCHED}; |
---|
| 60 | |
---|
[528] | 61 | /// @brief Enumerated PGPLOT plotting symbols. |
---|
[146] | 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, |
---|
[258] | 67 | CIRCLE7, CIRCLE8, LEFT, RIGHT, UP, DOWN}; |
---|
[146] | 68 | |
---|
[258] | 69 | enum FONTS {NORMAL=1, ROMAN, ITALIC, SCRIPT}; |
---|
| 70 | |
---|
[222] | 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$ |
---|
[146] | 77 | |
---|
| 78 | } |
---|
| 79 | |
---|
[317] | 80 | ////////////////////// |
---|
| 81 | |
---|
| 82 | #ifdef HAVE_PGPLOT |
---|
| 83 | |
---|
| 84 | #include <cpgplot.h> |
---|
| 85 | |
---|
| 86 | // The following are in pgplot_related.c |
---|
| 87 | // |
---|
[528] | 88 | /// @brief Is a PGPLOT device open? |
---|
[317] | 89 | extern "C" int cpgtest(); |
---|
| 90 | |
---|
[528] | 91 | /// @brief Do a logarithmic-scaled wedge, as in PGWEDG |
---|
[317] | 92 | extern "C" void cpgwedglog(const char* side, float disp, float width, |
---|
| 93 | float fg, float bg, const char *label); |
---|
| 94 | |
---|
[528] | 95 | /// @brief Do CPGHIST but with the y-axis logarithmic |
---|
[317] | 96 | extern "C" void cpghistlog(int npts, float *data, float datamin, |
---|
| 97 | float datamax, int nbin, int pgflag); |
---|
| 98 | |
---|
[528] | 99 | /// @brief Do a PGPLOT cumulative distribution |
---|
[317] | 100 | extern "C" void cpgcumul(int npts, float *data, float datamin, |
---|
| 101 | float datamax, int pgflag); |
---|
| 102 | |
---|
| 103 | namespace mycpgplot { |
---|
| 104 | |
---|
[528] | 105 | /// @brief Is a PGPLOT device a postscript (hardcopy) device? |
---|
[321] | 106 | int cpgIsPS(); |
---|
| 107 | |
---|
[528] | 108 | /// @brief A front-end to the cpgopen function, with other necessary definitions. |
---|
[317] | 109 | int mycpgopen(std::string device); |
---|
| 110 | |
---|
[528] | 111 | /// @brief Define the DARKGREEN colour, with RGB value of (0,0.7,0). |
---|
[332] | 112 | void setDarkGreen(); |
---|
[317] | 113 | |
---|
[528] | 114 | /// @brief Define the WCSGREEN colour, with RGB value of (0.3,0.5,0.3). |
---|
[332] | 115 | void setWCSGreen(); |
---|
[317] | 116 | |
---|
[528] | 117 | /// @brief A device-independent way to set the colour to white. |
---|
[332] | 118 | void setWhite(); |
---|
[317] | 119 | |
---|
[528] | 120 | /// @brief A device-independent way to set the colour to black. |
---|
[332] | 121 | void setBlack(); |
---|
[317] | 122 | |
---|
| 123 | } |
---|
| 124 | |
---|
[316] | 125 | #else // from ifdef HAVE_PGPLOT |
---|
[317] | 126 | // PGPLOT has not been defined. |
---|
| 127 | // extern "C" int cpgtest(){return 0;}; |
---|
| 128 | // extern "C" int cpgIsPS(){return 0;}; |
---|
| 129 | // extern "C" void cpgwedglog(const char* side, float disp, float width, |
---|
| 130 | // float fg, float bg, const char *label){ }; |
---|
| 131 | // extern "C" void cpghistlog(int npts, float *data, float datamin, |
---|
| 132 | // float datamax, int nbin, int pgflag){ }; |
---|
| 133 | // extern "C" void cpgcumul(int npts, float *data, float datamin, |
---|
| 134 | // float datamax, int pgflag){ }; |
---|
| 135 | // namespace mycpgplot { |
---|
| 136 | // int mycpgopen(std::string device){return 0;}; |
---|
| 137 | // inline void setDarkGreen(){ }; |
---|
| 138 | // inline void setWCSGreen(){ }; |
---|
| 139 | // inline void setWhite(){ }; |
---|
| 140 | // inline void setBlack(){ }; |
---|
| 141 | // } |
---|
[146] | 142 | |
---|
[316] | 143 | #endif // from ifdef HAVE_PGPLOT |
---|
| 144 | |
---|
[146] | 145 | #endif |
---|